-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.php
51 lines (44 loc) · 1.53 KB
/
action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* DokuWiki Plugin rawless (Action Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Gerry Weißbach / i-net /// software <[email protected]>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
class action_plugin_rawless extends DokuWiki_Action_Plugin {
/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @return void
*/
public function register(Doku_Event_Handler $controller) {
if ( strrpos( $_SERVER['SCRIPT_FILENAME'], 'css.php', -7 ) ) {
$controller->register_hook('INIT_LANG_LOAD', 'BEFORE', $this, 'handle_lang_load');
}
}
/**
* [Custom event handler which performs action]
*
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return void
*/
public function handle_lang_load(Doku_Event &$event, $param) {
global $INPUT;
if ( $INPUT->has('rawless') ) {
spl_autoload_register(function($class){
if ( $class == 'lessc' ) {
require_once __DIR__ . '/lessc.inc.php';
}
if ( $class === 'LesserPHP\\Lessc' ) {
require_once __DIR__ . '/lesserc.inc.php';
}
}, true, true);
}
}
}
// vim:ts=4:sw=4:et: