1<?php 2if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 3if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 4require_once(DOKU_PLUGIN.'syntax.php'); 5 6class syntax_plugin_list_xrefs extends DokuWiki_Syntax_Plugin { 7 8 function getInfo(){ 9 return array( 10 'author' => 'Troy Rollo', 11 'email' => 'dokuwiki@troy.rollo.name', 12 'date' => '2006-03-27', 13 'name' => 'Complex Lists Cross-References Plugin', 14 'desc' => 'Add cross-referencing to complex lists', 15 'url' => 'http://wiki.splitbrain.org/plugin:complex_lists' 16 ); 17 } 18 19 function syntax_plugin_list_xrefs(){ 20 $this->init = 0; 21 } 22 23 function getAllowedTypes() 24 { 25 return array('formatting', 'substition'); 26 } 27 28 function getType(){ 29 return 'formatting'; 30 } 31 32 function getSort(){ 33 return 15; 34 } 35 36 function connectTo($mode) { 37 if (!$this->init) 38 { 39 $this->init = 1; 40 $this->connectTo('plugin_list_xrefs'); 41 } 42 $this->Lexer->addSpecialPattern('#[*@][^#]+#', $mode, 'plugin_list_xrefs'); 43 $this->Lexer->addEntryPattern('#[(]', $mode, 'plugin_list_xrefs'); 44 45 } 46 47 function postConnect() { 48 $this->Lexer->addExitPattern('[)]#', 'plugin_list_xrefs'); 49 } 50 51 function handle($match, $state, $pos, &$handler){ 52 if ($state == DOKU_LEXER_SPECIAL) 53 { 54 $str = trim($match, '#'); 55 $tok = substr($str, 0, 1); 56 $str = substr($str, 1); 57 switch ($tok) 58 { 59 case '*': 60 return array($state, 1, $str); 61 62 case '@': 63 return array($state, 2, $str); 64 } 65 } 66 return array($state, $match); 67 } 68 69 function render($mode, &$renderer, $data) { 70 if ($data[0] == DOKU_LEXER_SPECIAL) 71 { 72 $renderer->doc .= '<!--CPLX-LIST-XREF#' . $data[1] . '#' . $data[2] . '-->'; 73 return true; 74 } 75 else if ($data[0] == DOKU_LEXER_UNMATCHED) 76 { 77 $renderer->doc .= $data[1]; 78 } 79 return false; 80 } 81 82} 83 84//Setup VIM: ex: et ts=4 enc=utf-8 : 85?> 86