|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * DokuWiki Plugin syntaxhighlighter4 (Action Component) |
| 3 | + * DokuWiki Plugin syntaxhighlighter4 (Action Component). |
4 | 4 | *
|
5 | 5 | * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
|
6 | 6 | * @author Cr@zy <webmaster@crazyws.fr>
|
7 | 7 | */
|
8 | 8 |
|
9 | 9 | // must be run within Dokuwiki
|
10 |
| -if(!defined('DOKU_INC')) die(); |
11 |
| - |
12 |
| -class action_plugin_syntaxhighlighter4 extends DokuWiki_Action_Plugin { |
| 10 | +if (!defined('DOKU_INC')) { |
| 11 | + die(); |
| 12 | +} |
13 | 13 |
|
| 14 | +class action_plugin_syntaxhighlighter4 extends DokuWiki_Action_Plugin |
| 15 | +{ |
14 | 16 | /**
|
15 |
| - * Registers a callback function for a given event |
| 17 | + * Registers a callback function for a given event. |
16 | 18 | *
|
17 | 19 | * @param Doku_Event_Handler $controller DokuWiki's event controller object
|
| 20 | + * |
18 | 21 | * @return void
|
19 | 22 | */
|
20 |
| - public function register(Doku_Event_Handler $controller) { |
21 |
| - $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handle_metaheader'); |
22 |
| - $controller->register_hook('TPL_ACT_RENDER', 'AFTER', $this, 'handle_jsprocessing'); |
| 23 | + public function register(Doku_Event_Handler $controller) |
| 24 | + { |
| 25 | + $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handle_metaheader'); |
| 26 | + $controller->register_hook('TPL_ACT_RENDER', 'AFTER', $this, 'handle_jsprocessing'); |
23 | 27 | }
|
24 | 28 |
|
25 | 29 | /**
|
26 |
| - * [Custom event handler which performs action] |
| 30 | + * [Custom event handler which performs action]. |
| 31 | + * |
| 32 | + * @param Doku_Event $event event object by reference |
| 33 | + * @param mixed $param [the parameters passed as fifth argument to register_hook() when this |
| 34 | + * handler was registered] |
27 | 35 | *
|
28 |
| - * @param Doku_Event $event event object by reference |
29 |
| - * @param mixed $param [the parameters passed as fifth argument to register_hook() when this |
30 |
| - * handler was registered] |
31 | 36 | * @return void
|
32 | 37 | */
|
33 |
| - |
34 |
| - public function handle_metaheader(Doku_Event &$event, $param) { |
| 38 | + public function handle_metaheader(Doku_Event &$event, $param) |
| 39 | + { |
35 | 40 | // Add SyntaxHighlighter theme.
|
36 |
| - $event->data['link'][] = array('rel' => 'stylesheet', |
37 |
| - 'type' => 'text/css', |
38 |
| - 'href' => DOKU_BASE . 'lib/plugins/syntaxhighlighter4/dist/'.$this->getConf('theme'), |
39 |
| - ); |
| 41 | + $event->data['link'][] = ['rel' => 'stylesheet', |
| 42 | + 'type' => 'text/css', |
| 43 | + 'href' => DOKU_BASE.'lib/plugins/syntaxhighlighter4/dist/'.$this->getConf('theme'), |
| 44 | + ]; |
40 | 45 |
|
41 | 46 | // Register SyntaxHighlighter javascript.
|
42 |
| - $event->data["script"][] = array("type" => "text/javascript", |
43 |
| - "src" => DOKU_BASE . "lib/plugins/syntaxhighlighter4/dist/syntaxhighlighter.js", |
44 |
| - "_data" => "" |
45 |
| - ); |
| 47 | + $event->data['script'][] = ['type' => 'text/javascript', |
| 48 | + 'src' => DOKU_BASE.'lib/plugins/syntaxhighlighter4/dist/syntaxhighlighter.js', |
| 49 | + '_data' => '', |
| 50 | + ]; |
46 | 51 | }
|
47 | 52 |
|
48 |
| - public function handle_jsprocessing(Doku_Event &$event, $param) { |
| 53 | + public function handle_jsprocessing(Doku_Event &$event, $param) |
| 54 | + { |
49 | 55 | global $ID, $INFO;
|
50 | 56 |
|
51 | 57 | // Ensures code will be written only on base page
|
52 |
| - if ($ID != $INFO["id"]) { |
| 58 | + if ($ID != $INFO['id']) { |
53 | 59 | return;
|
54 | 60 | }
|
55 | 61 |
|
56 | 62 | // Load Syntaxhighlighter config
|
57 |
| - ptln(""); |
| 63 | + ptln(''); |
58 | 64 | ptln("<script type='text/javascript'>");
|
59 |
| - ptln("syntaxhighlighterConfig = {"); |
60 |
| - ptln(" autoLinks: " . ($this->getConf('autoLinks') == 1 ? 'true' : 'false') . ","); |
| 65 | + ptln('syntaxhighlighterConfig = {'); |
| 66 | + ptln(' autoLinks: '.($this->getConf('autoLinks') == 1 ? 'true' : 'false').','); |
61 | 67 | $firstLine = $this->getConf('first-line');
|
62 | 68 | if ($firstLine > 0) {
|
63 |
| - ptln(" firstLine: " . $firstLine . ","); |
| 69 | + ptln(' firstLine: '.$firstLine.','); |
64 | 70 | }
|
65 |
| - ptln(" gutter: " . ($this->getConf('gutter') == 1 ? 'true' : 'false') . ","); |
66 |
| - ptln(" htmlScript: " . ($this->getConf('htmlScript') == 1 ? 'true' : 'false') . ","); |
| 71 | + ptln(' gutter: '.($this->getConf('gutter') == 1 ? 'true' : 'false').','); |
| 72 | + ptln(' htmlScript: '.($this->getConf('htmlScript') == 1 ? 'true' : 'false').','); |
67 | 73 | $tabSize = $this->getConf('tabSize');
|
68 | 74 | if ($tabSize > 0) {
|
69 |
| - ptln(" tabSize: " . $tabSize . ","); |
| 75 | + ptln(' tabSize: '.$tabSize.','); |
70 | 76 | }
|
71 |
| - ptln(" smartTabs: " . ($this->getConf('smartTabs') == 1 ? 'true' : 'false')); |
72 |
| - ptln("}"); |
73 |
| - ptln("</script>"); |
| 77 | + ptln(' smartTabs: '.($this->getConf('smartTabs') == 1 ? 'true' : 'false')); |
| 78 | + ptln('}'); |
| 79 | + ptln('</script>'); |
74 | 80 | }
|
75 |
| - |
76 | 81 | }
|
77 | 82 |
|
78 | 83 | // vim:ts=4:sw=4:et:
|
0 commit comments