1<?php 2// must be run within Dokuwiki 3if(!defined('DOKU_INC')) die(); 4 5/** 6 * All DokuWiki plugins to extend the parser/rendering mechanism 7 * need to inherit from this class 8 */ 9class syntax_plugin_alphalist2 extends DokuWiki_Syntax_Plugin { 10 11 public function getType(){ return 'container'; } 12 public function getAllowedTypes() { 13 global $PARSER_MODES; 14 return array_keys($PARSER_MODES); 15 } 16 public function getSort(){ return 158; } 17 public function connectTo($mode) { $this->Lexer->addEntryPattern('<alphalist.*?>(?=.*?</alphalist>)',$mode,'plugin_alphalist2'); } 18 public function postConnect() { $this->Lexer->addExitPattern('</alphalist>','plugin_alphalist2'); } 19 20 /** 21 * Handle the match 22 */ 23 public function handle($match, $state, $pos, Doku_Handler $handler) { 24 switch ($state) { 25 case DOKU_LEXER_ENTER : 26 $attrs = substr($match, strlen('<alphalist'), -1); 27 $classes = preg_split('/\s+/', $attrs, -1, PREG_SPLIT_NO_EMPTY); 28 return array($state, $classes); 29 30 case DOKU_LEXER_UNMATCHED : return array($state, $match); 31 case DOKU_LEXER_EXIT : return array($state, ''); 32 } 33 return array(); } 34 35 /** 36 * Create output 37 */ 38 public function render($mode, Doku_Renderer $renderer, $data) { 39 // $data is what the function handle() return'ed. 40 if($mode == 'xhtml'){ 41 /** @var Doku_Renderer_xhtml $renderer */ 42 list($state, $match) = $data; 43 switch ($state) { 44 case DOKU_LEXER_ENTER : 45 $classes = $match; 46 array_unshift($classes, 'plugin__alphalist2'); 47 $renderer->doc .= '<div class="' . implode(' ', $classes) . '">'; 48 break; 49 50 case DOKU_LEXER_UNMATCHED : 51 $renderer->doc .= $renderer->_xmlEntities($match); 52 break; 53 case DOKU_LEXER_EXIT : 54 $renderer->doc .= "</div>"; 55 break; 56 } 57 return true; 58 } 59 return false; 60 } 61} 62