adjusted docblocks for renamed class aliases
[dokuwiki.git] / lib / plugins / styling / action.php
blob39da8602892ed92dcb2fa6082dec1d9bb9818d40
1 <?php
3 use dokuwiki\Extension\ActionPlugin;
4 use dokuwiki\Extension\EventHandler;
5 use dokuwiki\Extension\Event;
7 /**
8 * DokuWiki Plugin styling (Action Component)
10 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
11 * @author Andreas Gohr <andi@splitbrain.org>
13 class action_plugin_styling extends ActionPlugin
15 /**
16 * Registers a callback functions
18 * @param EventHandler $controller DokuWiki's event controller object
19 * @return void
21 public function register(EventHandler $controller)
23 $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handleHeader');
26 /**
27 * Adds the preview parameter to the stylesheet loading in non-js mode
29 * @param Event $event event object by reference
30 * @param mixed $param [the parameters passed as fifth argument to register_hook() when this
31 * handler was registered]
32 * @return void
34 public function handleHeader(Event &$event, $param)
36 global $ACT;
37 global $INPUT;
38 if ($ACT != 'admin' || $INPUT->str('page') != 'styling') return;
39 /** @var admin_plugin_styling $admin */
40 $admin = plugin_load('admin', 'styling');
41 if (!$admin->isAccessibleByCurrentUser()) return;
43 // set preview
44 $len = count($event->data['link']);
45 for ($i = 0; $i < $len; $i++) {
46 if (
47 $event->data['link'][$i]['rel'] == 'stylesheet' &&
48 strpos($event->data['link'][$i]['href'], 'lib/exe/css.php') !== false
49 ) {
50 $event->data['link'][$i]['href'] .= '&preview=1&tseed=' . time();
56 // vim:ts=4:sw=4:et: