1<?php 2/** 3 * Plugin hiddenSwitch: Enable to hide details 4 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 5 * @author Guillaume Turri <guillaume.turri@gmail.com> 6 */ 7 8if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 9if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 10require_once(DOKU_PLUGIN.'syntax.php'); 11 12class syntax_plugin_hiddenSwitch extends DokuWiki_Syntax_Plugin { 13 14 function getType(){ return 'substition'; } 15 function getSort(){ 16 //Make sure it's lower than the one of the plugin hidden, to avoid confusion between "<hidden.*" and <hiddenSwitch.*" 17 return 188; 18 } 19 20 function connectTo($mode) { 21 $this->Lexer->addSpecialPattern('<hiddenSwitch[^>]*>', $mode,'plugin_hiddenSwitch'); 22 } 23 24 function handle($match, $state, $pos, Doku_Handler $handler) { 25 $return = array('text' => $this->getLang('default')); 26 $match = trim(utf8_substr($match, 14, -1)); //14 = strlen("<hiddenSwitch ") 27 if ( $match !== '' ){ 28 $return['text'] = $match; 29 } 30 $return['text'] = htmlspecialchars($return['text']); 31 return $return; 32 } // handle() 33 34 function render($mode, Doku_Renderer $renderer, $data) { 35 if($mode == 'xhtml'){ 36 $renderer->doc .= '<input type="button" class="button hiddenSwitch" value="' . $data['text'] . '" />'; 37 return true; 38 } 39 40 return false; 41 } // render() 42 43} // class syntax_plugin_nspages 44