Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

wrapper.php

Zuletzt modifiziert: 09.10.2024, 12:54 - Dateigröße: 2.53 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  namespace phpbb\cron\task;
015   
016  /**
017  * Cron task wrapper class.
018  * Enhances cron tasks with convenience methods that work identically for all tasks.
019  */
020  class wrapper
021  {
022      protected $task;
023      protected $phpbb_root_path;
024      protected $php_ext;
025   
026      /**
027      * Constructor.
028      *
029      * Wraps a task $task, which must implement cron_task interface.
030      *
031      * @param \phpbb\cron\task\task $task The cron task to wrap.
032      * @param string $phpbb_root_path Relative path to phpBB root
033      * @param string $php_ext PHP file extension
034      */
035      public function __construct(\phpbb\cron\task\task $task, $phpbb_root_path, $php_ext)
036      {
037          $this->task = $task;
038          $this->phpbb_root_path = $phpbb_root_path;
039          $this->php_ext = $php_ext;
040      }
041   
042      /**
043      * Returns whether the wrapped task is parametrised.
044      *
045      * Parametrized tasks accept parameters during initialization and must
046      * normally be scheduled with parameters.
047      *
048      * @return bool        Whether or not this task is parametrized.
049      */
050      public function is_parametrized()
051      {
052          return $this->task instanceof \phpbb\cron\task\parametrized;
053      }
054   
055      /**
056      * Returns whether the wrapped task is ready to run.
057      *
058      * A task is ready to run when it is runnable according to current configuration
059      * and enough time has passed since it was last run.
060      *
061      * @return bool        Whether the wrapped task is ready to run.
062      */
063      public function is_ready()
064      {
065          return $this->task->is_runnable() && $this->task->should_run();
066      }
067   
068      /**
069      * Returns a url through which this task may be invoked via web.
070      *
071      * When system cron is not in use, running a cron task is accomplished
072      * by outputting an image with the url returned by this function as
073      * source.
074      *
075      * @return string        URL through which this task may be invoked.
076      */
077      public function get_url()
078      {
079          $name = $this->get_name();
080          if ($this->is_parametrized())
081          {
082              $params = $this->task->get_parameters();
083              $extra = '';
084              foreach ($params as $key => $value)
085              {
086                  $extra .= '&amp;' . $key . '=' . urlencode($value);
087              }
088          }
089          else
090          {
091              $extra = '';
092          }
093          $url = append_sid($this->phpbb_root_path . 'cron.' . $this->php_ext, 'cron_type=' . $name . $extra);
094          return $url;
095      }
096   
097      /**
098      * Forwards all other method calls to the wrapped task implementation.
099      *
100      * @return mixed
101      */
102      public function __call($name, $args)
103      {
104          return call_user_func_array(array($this->task, $name), $args);
105      }
106  }
107