1<?php 2/** 3 * BBCode plugin: allows BBCode markup familiar from forum software 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Esther Brunner <esther@kaffeehaus.ch> 7 */ 8 9if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11require_once(DOKU_PLUGIN.'syntax.php'); 12 13/** 14 * All DokuWiki plugins to extend the parser/rendering mechanism 15 * need to inherit from this class 16 */ 17class syntax_plugin_bbcode_ulist extends DokuWiki_Syntax_Plugin { 18 19 function getType() { return 'container'; } 20 function getPType() { return 'block'; } 21 function getAllowedTypes() { return array('formatting', 'substition', 'disabled', 'protected'); } 22 function getSort() { return 105; } 23 function connectTo($mode) { $this->Lexer->addEntryPattern('\[list\]\s*?\[\*\](?=.*?\x5B/list\x5D)', $mode, 'plugin_bbcode_ulist'); } 24 function postConnect() { $this->Lexer->addExitPattern('\[/list\]', 'plugin_bbcode_ulist'); } 25 26 /** 27 * Handle the match 28 */ 29 function handle($match, $state, $pos, Doku_Handler $handler){ 30 switch ($state) { 31 case DOKU_LEXER_ENTER : 32 return array($state, ''); 33 34 case DOKU_LEXER_UNMATCHED : 35 return array($state, $match); 36 37 case DOKU_LEXER_EXIT : 38 return array($state, ''); 39 40 } 41 return array(); 42 } 43 44 /** 45 * Create output 46 */ 47 function render($mode, Doku_Renderer $renderer, $data) { 48 if($mode == 'xhtml'){ 49 list($state, $match) = $data; 50 switch ($state) { 51 case DOKU_LEXER_ENTER : 52 $renderer->doc .= '<ul><li class="level1"><div class="li">'; 53 break; 54 55 case DOKU_LEXER_UNMATCHED : 56 $match = $renderer->_xmlEntities($match); 57 $renderer->doc .= str_replace('[*]', '</div></li><li class="level1"><div class="li">', $match); 58 break; 59 60 case DOKU_LEXER_EXIT : 61 $renderer->doc .= '</div></li></ul>'; 62 break; 63 64 } 65 return true; 66 } 67 return false; 68 } 69 70} 71 72//Setup VIM: ex: et ts=4 enc=utf-8 : 73