* * @license GPL2 (http://www.gnu.org/licenses/gpl.html) * @author Dmitry A. Vinogradov * * Format: Bla-bla-bla * Examples: This text is hidden * This text is hidden */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_hidetext extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Dmitry A. Vinogradov', 'email' => 'vshekun@gmail.com', 'date' => '2009-09-28', 'name' => 'HideText', 'desc' => 'For hiding big text', 'url' => 'https://www.dokuwiki.org/plugin:hidetext', ); } /** * What kind of syntax are we? */ function getType(){ return 'formatting'; } function getAllowedTypes() { return array('container', 'formatting', 'substition', 'disabled', 'protected'); } /** * Where to sort in? */ function getSort(){ return 201; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addEntryPattern(']*>',$mode,'plugin_hidetext'); } function postConnect() { $this->Lexer->addExitPattern('','plugin_hidetext'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ switch ($state) { case DOKU_LEXER_ENTER : return array($state, substr($match, 9, -1) ); break; case DOKU_LEXER_UNMATCHED : return array($state, $match); break; case DOKU_LEXER_EXIT : return array($state, ''); break; } return array(); } /** * Create output */ function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ list($state, $match) = $data; switch ($state) { case DOKU_LEXER_ENTER : if ( $match == "" ) $match = '>>>'; $id = "hidetext".rand(100,500); $renderer->doc .= ""; $renderer->doc .= $match; $renderer->doc .= ""; $renderer->doc .= "
"; $renderer->doc .= ""; break; case DOKU_LEXER_UNMATCHED : $renderer->doc .= $renderer->_xmlEntities($match); break; case DOKU_LEXER_EXIT : $renderer->doc .= "
"; break; } return true; } return false; } }