Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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. |
|
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
wrapper.php
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 use phpbb\routing\helper;
017
018 /**
019 * Cron task wrapper class.
020 * Enhances cron tasks with convenience methods that work identically for all tasks.
021 */
022 class wrapper
023 {
024 /**
025 * @var helper
026 */
027 protected $routing_helper;
028
029 /**
030 * @var task
031 */
032 protected $task;
033
034 /**
035 * @var string
036 */
037 protected $phpbb_root_path;
038
039 /**
040 * @var string
041 */
042 protected $php_ext;
043
044 /**
045 * @var \phpbb\template\template
046 */
047 protected $template;
048
049 /**
050 * Constructor.
051 *
052 * Wraps a task $task, which must implement cron_task interface.
053 *
054 * @param task $task The cron task to wrap.
055 * @param helper $routing_helper Routing helper for route generation
056 * @param string $phpbb_root_path Relative path to phpBB root
057 * @param string $php_ext PHP file extension
058 * @param \phpbb\template\template $template
059 */
060 public function __construct(task $task, helper $routing_helper, $phpbb_root_path, $php_ext, $template)
061 {
062 $this->task = $task;
063 $this->routing_helper = $routing_helper;
064 $this->phpbb_root_path = $phpbb_root_path;
065 $this->php_ext = $php_ext;
066 $this->template = $template;
067 }
068
069 /**
070 * Returns whether the wrapped task is parametrised.
071 *
072 * Parametrized tasks accept parameters during initialization and must
073 * normally be scheduled with parameters.
074 *
075 * @return bool Whether or not this task is parametrized.
076 */
077 public function is_parametrized()
078 {
079 return $this->task instanceof parametrized;
080 }
081
082 /**
083 * Returns whether the wrapped task is ready to run.
084 *
085 * A task is ready to run when it is runnable according to current configuration
086 * and enough time has passed since it was last run.
087 *
088 * @return bool Whether the wrapped task is ready to run.
089 */
090 public function is_ready()
091 {
092 return $this->task->is_runnable() && $this->task->should_run();
093 }
094
095 /**
096 * Returns a url through which this task may be invoked via web.
097 *
098 * When system cron is not in use, running a cron task is accomplished
099 * by outputting an image with the url returned by this function as
100 * source.
101 *
102 * @return string URL through which this task may be invoked.
103 */
104 public function get_url()
105 {
106 $params['cron_type'] = $this->get_name();
107 if ($this->is_parametrized())
108 {
109 $params = array_merge($params, $this->task->get_parameters());
110 }
111
112 return $this->routing_helper->route('phpbb_cron_run', $params);
113 }
114
115 /**
116 * Returns HTML for an invisible `img` tag that can be displayed on page
117 * load to trigger a request to the relevant cron task endpoint.
118 *
119 * @return string HTML to render to trigger cron task
120 */
121 public function get_html_tag()
122 {
123 $this->template->set_filenames([
124 'cron_html_tag' => 'cron.html',
125 ]);
126
127 $this->template->assign_var('CRON_TASK_URL', $this->get_url());
128
129 return $this->template->assign_display('cron_html_tag');
130 }
131
132 /**
133 * Forwards all other method calls to the wrapped task implementation.
134 *
135 * @return mixed
136 */
137 public function __call($name, $args)
138 {
139 return call_user_func_array(array($this->task, $name), $args);
140 }
141 }
142