[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * DokuWiki Plugin styling (Action Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 class action_plugin_styling extends DokuWiki_Action_Plugin 9 { 10 11 /** 12 * Registers a callback functions 13 * 14 * @param Doku_Event_Handler $controller DokuWiki's event controller object 15 * @return void 16 */ 17 public function register(Doku_Event_Handler $controller) 18 { 19 $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handleHeader'); 20 } 21 22 /** 23 * Adds the preview parameter to the stylesheet loading in non-js mode 24 * 25 * @param Doku_Event $event event object by reference 26 * @param mixed $param [the parameters passed as fifth argument to register_hook() when this 27 * handler was registered] 28 * @return void 29 */ 30 public function handleHeader(Doku_Event &$event, $param) 31 { 32 global $ACT; 33 global $INPUT; 34 if ($ACT != 'admin' || $INPUT->str('page') != 'styling') return; 35 /** @var admin_plugin_styling $admin */ 36 $admin = plugin_load('admin', 'styling'); 37 if (!$admin->isAccessibleByCurrentUser()) return; 38 39 // set preview 40 $len = count($event->data['link']); 41 for ($i = 0; $i < $len; $i++) { 42 if ($event->data['link'][$i]['rel'] == 'stylesheet' && 43 strpos($event->data['link'][$i]['href'], 'lib/exe/css.php') !== false 44 ) { 45 $event->data['link'][$i]['href'] .= '&preview=1&tseed='.time(); 46 } 47 } 48 } 49 } 50 51 // vim:ts=4:sw=4:et:
title
Description
Body
title
Description
Body
title
Description
Body
title
Body