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 |
renderer.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\textformatter\s9e;
015
016 /**
017 * s9e\TextFormatter\Renderer adapter
018 */
019 class renderer implements \phpbb\textformatter\renderer_interface
020 {
021 /**
022 * @var \s9e\TextFormatter\Plugins\Censor\Helper
023 */
024 protected $censor;
025
026 /**
027 * @var \phpbb\event\dispatcher_interface
028 */
029 protected $dispatcher;
030
031 /**
032 * @var quote_helper
033 */
034 protected $quote_helper;
035
036 /**
037 * @var \s9e\TextFormatter\Renderer
038 */
039 protected $renderer;
040
041 /**
042 * @var bool Status of the viewcensors option
043 */
044 protected $viewcensors = false;
045
046 /**
047 * @var bool Status of the viewflash option
048 */
049 protected $viewflash = false;
050
051 /**
052 * @var bool Status of the viewimg option
053 */
054 protected $viewimg = false;
055
056 /**
057 * @var bool Status of the viewsmilies option
058 */
059 protected $viewsmilies = false;
060
061 /**
062 * Constructor
063 *
064 * @param \phpbb\cache\driver\driver_interface $cache
065 * @param string $cache_dir Path to the cache dir
066 * @param string $key Cache key
067 * @param factory $factory
068 * @param \phpbb\event\dispatcher_interface $dispatcher
069 */
070 public function __construct(\phpbb\cache\driver\driver_interface $cache, $cache_dir, $key, factory $factory, \phpbb\event\dispatcher_interface $dispatcher)
071 {
072 $renderer_data = $cache->get($key);
073 if ($renderer_data)
074 {
075 $class = $renderer_data['class'];
076 if (!class_exists($class, false))
077 {
078 // Try to load the renderer class from its cache file
079 $cache_file = $cache_dir . $class . '.php';
080
081 if (file_exists($cache_file))
082 {
083 include($cache_file);
084 }
085 }
086 if (class_exists($class, false))
087 {
088 $renderer = new $class;
089 }
090 if (isset($renderer_data['censor']))
091 {
092 $censor = $renderer_data['censor'];
093 }
094 }
095 if (!isset($renderer))
096 {
097 $objects = $factory->regenerate();
098 $renderer = $objects['renderer'];
099 }
100
101 if (isset($censor))
102 {
103 $this->censor = $censor;
104 }
105 $this->dispatcher = $dispatcher;
106 $this->renderer = $renderer;
107 $renderer = $this;
108
109 /**
110 * Configure the renderer service
111 *
112 * @event core.text_formatter_s9e_renderer_setup
113 * @var \phpbb\textformatter\s9e\renderer renderer This renderer service
114 * @since 3.2.0-a1
115 */
116 $vars = array('renderer');
117 extract($dispatcher->trigger_event('core.text_formatter_s9e_renderer_setup', compact($vars)));
118 }
119
120 /**
121 * Configure the quote_helper object used to display extended information in quotes
122 *
123 * @param quote_helper $quote_helper
124 */
125 public function configure_quote_helper(quote_helper $quote_helper)
126 {
127 $this->quote_helper = $quote_helper;
128 }
129
130 /**
131 * Automatically set the smilies path based on config
132 *
133 * @param \phpbb\config\config $config
134 * @param \phpbb\path_helper $path_helper
135 * @return null
136 */
137 public function configure_smilies_path(\phpbb\config\config $config, \phpbb\path_helper $path_helper)
138 {
139 /**
140 * @see smiley_text()
141 */
142 $root_path = $path_helper->get_web_root_path();
143
144 $this->set_smilies_path($root_path . $config['smilies_path']);
145 }
146
147 /**
148 * Configure this renderer as per the user's settings
149 *
150 * Should set the locale as well as the viewcensor/viewflash/viewimg/viewsmilies options.
151 *
152 * @param \phpbb\user $user
153 * @param \phpbb\config\config $config
154 * @param \phpbb\auth\auth $auth
155 * @return void
156 */
157 public function configure_user(\phpbb\user $user, \phpbb\config\config $config, \phpbb\auth\auth $auth)
158 {
159 $censor = $user->optionget('viewcensors') || !$config['allow_nocensors'] || !$auth->acl_get('u_chgcensors');
160
161 $this->set_viewcensors($censor);
162 $this->set_viewflash($user->optionget('viewflash'));
163 $this->set_viewimg($user->optionget('viewimg'));
164 $this->set_viewsmilies($user->optionget('viewsmilies'));
165
166 // Set the stylesheet parameters
167 foreach (array_keys($this->renderer->getParameters()) as $param_name)
168 {
169 if (strpos($param_name, 'L_') === 0)
170 {
171 // L_FOO is set to $user->lang('FOO')
172 $this->renderer->setParameter($param_name, $user->lang(substr($param_name, 2)));
173 }
174 }
175
176 // Set this user's style id and other parameters
177 $this->renderer->setParameters(array(
178 'S_IS_BOT' => $user->data['is_bot'] ?? false,
179 'S_REGISTERED_USER' => $user->data['is_registered'] ?? false,
180 'S_USER_LOGGED_IN' => ($user->data['user_id'] != ANONYMOUS),
181 'STYLE_ID' => $user->style['style_id'],
182 ));
183 }
184
185 /**
186 * Return the instance of s9e\TextFormatter\Renderer used by this object
187 *
188 * @return \s9e\TextFormatter\Renderer
189 */
190 public function get_renderer()
191 {
192 return $this->renderer;
193 }
194
195 /**
196 * {@inheritdoc}
197 */
198 public function get_viewcensors()
199 {
200 return $this->viewcensors;
201 }
202
203 /**
204 * {@inheritdoc}
205 */
206 public function get_viewflash()
207 {
208 return $this->viewflash;
209 }
210
211 /**
212 * {@inheritdoc}
213 */
214 public function get_viewimg()
215 {
216 return $this->viewimg;
217 }
218
219 /**
220 * {@inheritdoc}
221 */
222 public function get_viewsmilies()
223 {
224 return $this->viewsmilies;
225 }
226
227 /**
228 * {@inheritdoc}
229 */
230 public function render($xml)
231 {
232 if (isset($this->quote_helper))
233 {
234 $xml = $this->quote_helper->inject_metadata($xml);
235 }
236
237 $renderer = $this;
238
239 /**
240 * Modify a parsed text before it is rendered
241 *
242 * @event core.text_formatter_s9e_render_before
243 * @var \phpbb\textformatter\s9e\renderer renderer This renderer service
244 * @var string xml The parsed text, in its XML form
245 * @since 3.2.0-a1
246 */
247 $vars = array('renderer', 'xml');
248 extract($this->dispatcher->trigger_event('core.text_formatter_s9e_render_before', compact($vars)));
249
250 $html = $this->renderer->render($xml);
251 if (isset($this->censor) && $this->viewcensors)
252 {
253 $html = $this->censor->censorHtml($html, true);
254 }
255
256 /**
257 * Modify a rendered text
258 *
259 * @event core.text_formatter_s9e_render_after
260 * @var string html The rendered text's HTML
261 * @var \phpbb\textformatter\s9e\renderer renderer This renderer service
262 * @since 3.2.0-a1
263 */
264 $vars = array('html', 'renderer');
265 extract($this->dispatcher->trigger_event('core.text_formatter_s9e_render_after', compact($vars)));
266
267 return $html;
268 }
269
270 /**
271 * {@inheritdoc}
272 */
273 public function set_smilies_path($path)
274 {
275 $this->renderer->setParameter('T_SMILIES_PATH', $path);
276 }
277
278 /**
279 * {@inheritdoc}
280 */
281 public function set_viewcensors($value)
282 {
283 $this->viewcensors = $value;
284 $this->renderer->setParameter('S_VIEWCENSORS', $value);
285 }
286
287 /**
288 * {@inheritdoc}
289 */
290 public function set_viewflash($value)
291 {
292 $this->viewflash = $value;
293 $this->renderer->setParameter('S_VIEWFLASH', $value);
294 }
295
296 /**
297 * {@inheritdoc}
298 */
299 public function set_viewimg($value)
300 {
301 $this->viewimg = $value;
302 $this->renderer->setParameter('S_VIEWIMG', $value);
303 }
304
305 /**
306 * {@inheritdoc}
307 */
308 public function set_viewsmilies($value)
309 {
310 $this->viewsmilies = $value;
311 $this->renderer->setParameter('S_VIEWSMILIES', $value);
312 }
313 }
314