-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.php
45 lines (39 loc) · 1.24 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
<?php
/**
* Display Fortune cookies
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
*/
class action_plugin_xfortune extends DokuWiki_Action_Plugin {
/** @inheritdoc */
function register(Doku_Event_Handler $controller) {
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax_call_unknown');
$controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'handle_claim');
}
/**
* Handle the ajax call
*
* @param Doku_Event $event
* @param $param
*/
function handle_ajax_call_unknown(Doku_Event $event, $param) {
if($event->data != 'plugin_xfortune') return;
$event->preventDefault();
$event->stopPropagation();
global $INPUT;
echo helper_plugin_xfortune::getCookieHTML($INPUT->str('cookie'));
}
/**
* Set a small cookie as tagline
*
* @param Doku_Event $event
* @param $param
*/
function handle_claim(Doku_Event $event, $param) {
if($this->getConf('claim') === '') return;
global $conf;
$cookie = helper_plugin_xfortune::getCookieHTML($this->getConf('claim'), 2, 130);
$conf['tagline'] = $cookie;
}
}