-
Notifications
You must be signed in to change notification settings - Fork 3
/
action.php
38 lines (33 loc) · 1.28 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
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html
* @author Patrick Brown <ptbrown@whoopdedo.org>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
class action_plugin_emoji extends DokuWiki_Action_Plugin {
public function register(Doku_Event_Handler $controller) {
$controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'tplMetaheaderOutput');
}
public function tplMetaheaderOutput(Doku_Event &$event, $param) {
$assetsrc = DOKU_BASE.'lib/plugins/emoji/';
switch($this->getConf('assetsrc')) {
case 'cdn':
$assetsrc = '//cdn.jsdelivr.net/emojione/';
break;
case 'external':
$asseturi = $this->getConf('asseturi');
if($asseturi)
$assetsrc = $asseturi;
break;
}
/* Insert JS variable for CDN server. */
/* Use a global variable because otherwise there would need to be yet */
/* another hook to modify the JSINFO array that has already been written. */
$json = new JSON();
$event->data['script'][] = array(
'type' => 'text/javascript',
'_data' => 'var emoji_assetsrc = '.$json->encode($assetsrc).';'
);
}
}