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 |
tidy_search.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\core;
015
016 /**
017 * Tidy search cron task.
018 *
019 * Will only run when the currently selected search backend supports tidying.
020 */
021 class tidy_search extends \phpbb\cron\task\base
022 {
023 /**
024 * phpBB root path
025 * @var string
026 */
027 protected $phpbb_root_path;
028
029 /**
030 * PHP file extension
031 * @var string
032 */
033 protected $php_ext;
034
035 /**
036 * Auth object
037 * @var \phpbb\auth\auth
038 */
039 protected $auth;
040
041 /**
042 * Config object
043 * @var \phpbb\config\config
044 */
045 protected $config;
046
047 /**
048 * Database object
049 * @var \phpbb\db\driver\driver_interface
050 */
051 protected $db;
052
053 /**
054 * User object
055 * @var \phpbb\user
056 */
057 protected $user;
058
059 /**
060 * Event dispatcher object
061 * @var \phpbb\event\dispatcher_interface
062 */
063 protected $phpbb_dispatcher;
064
065 /**
066 * Constructor.
067 *
068 * @param string $phpbb_root_path The phpBB root path
069 * @param string $php_ext The PHP file extension
070 * @param \phpbb\auth\auth $auth The auth object
071 * @param \phpbb\config\config $config The config object
072 * @param \phpbb\db\driver\driver_interface $db The database object
073 * @param \phpbb\user $user The user object
074 * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher The event dispatcher object
075 */
076 public function __construct($phpbb_root_path, $php_ext, \phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, \phpbb\event\dispatcher_interface $phpbb_dispatcher)
077 {
078 $this->phpbb_root_path = $phpbb_root_path;
079 $this->php_ext = $php_ext;
080 $this->auth = $auth;
081 $this->config = $config;
082 $this->db = $db;
083 $this->user = $user;
084 $this->phpbb_dispatcher = $phpbb_dispatcher;
085 }
086
087 /**
088 * Runs this cron task.
089 *
090 * @return null
091 */
092 public function run()
093 {
094 $search_type = $this->config['search_type'];
095
096 // We do some additional checks in the module to ensure it can actually be utilised
097 $error = false;
098 $search = new $search_type($error, $this->phpbb_root_path, $this->php_ext, $this->auth, $this->config, $this->db, $this->user, $this->phpbb_dispatcher);
099
100 if (!$error)
101 {
102 $search->tidy();
103 }
104 }
105
106 /**
107 * Returns whether this cron task can run, given current board configuration.
108 *
109 * Search cron task is runnable in all normal use. It may not be
110 * runnable if the search backend implementation selected in board
111 * configuration does not exist.
112 *
113 * @return bool
114 */
115 public function is_runnable()
116 {
117 return class_exists($this->config['search_type']);
118 }
119
120 /**
121 * Returns whether this cron task should run now, because enough time
122 * has passed since it was last run.
123 *
124 * The interval between search tidying is specified in board
125 * configuration.
126 *
127 * @return bool
128 */
129 public function should_run()
130 {
131 return $this->config['search_last_gc'] < time() - $this->config['search_gc'];
132 }
133 }
134