1<?php 2/** 3* Plugin HighlightJs: Plugin providing highlight.js version 5.71. 4* 5* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6* @author Clément Chartier <clement@studiorvb.com> 7*/ 8 9if(!defined('DOKU_INC')) die(); 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11 12require_once(DOKU_PLUGIN.'action.php'); 13 14class action_plugin_highlightjs extends DokuWiki_Action_Plugin { 15 16 /** 17 * return some info 18 */ 19 function getInfo(){ 20 return confToHash(dirname(__FILE__).'/INFO.txt'); 21 } 22 23 /* 24 * plugin should use this method to register its handlers with the dokuwiki's event controller 25 */ 26 function register(&$controller) { 27 $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_code_button', array ()); 28 $controller->register_hook('TPL_CONTENT_DISPLAY', 'AFTER', $this, 'init_highlight'); 29 } 30 31 32 /* 33 * Add Toolbar icon 34 */ 35 function insert_code_button(& $event, $param) { 36 $event->data[] = array ( 37 'type' => 'format', 38 'title' => $this->getLang('toolbar_code'), 39 'icon' => DOKU_BASE . 'lib/plugins/highlightjs/images/page_white_code.png', 40 'open' => '<code>', 41 'close' => '</code>', 42 ); 43 } 44 45 /* 46 * Add Js & Css after template is displayed 47 */ 48 function init_highlight(&$event) { 49 global $ACT; 50 echo "<script language='javascript' src='".DOKU_BASE."lib/plugins/highlightjs/highlight/highlight.pack.js'></script>\n"; 51 echo "<link rel='stylesheet' title='Default' href='".DOKU_BASE."lib/plugins/highlightjs/highlight/styles/".$this->getConf('highlight_skin').".css' />\n"; 52 echo "<script language='javascript'>;\n"; 53 echo "hljs.initHighlightingOnLoad();\n</script>\n"; 54 } 55 56}