1<?php 2 3/** 4 * Info tIndexmenu tag: Tag a page with a sort number. 5 * 6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 7 * @author Samuele Tognini <samuele@netsons.org> 8 * @author Rene Hadler <rene.hadler@iteas.at> 9 * 10 */ 11 12if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 13if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 14require_once(DOKU_PLUGIN.'syntax.php'); 15 16/** 17 * All DokuWiki plugins to extend the parser/rendering mechanism 18 * need to inherit from this class 19 */ 20class syntax_plugin_indexmenu_tag extends DokuWiki_Syntax_Plugin { 21 22 /** 23 * return some info 24 */ 25 function getInfo(){ 26 return array( 27 'author' => 'Samuele Tognini mod. by Rene Hadler', 28 'email' => 'samuele@netsons.org, rene.hadler@iteas.at', 29 'date' => rtrim(io_readFile(DOKU_PLUGIN.'tindexmenu/VERSION.txt')), 30 'name' => 'tIndexmenu tag', 31 'desc' => 'tIndexmenu tag plugin.', 32 'url' => 'http://wiki.splitbrain.org/plugin:tindexmenu' 33 ); 34 } 35 36 /** 37 * What kind of syntax are we? 38 */ 39 function getType(){ 40 return 'substition'; 41 } 42 43 /** 44 * Where to sort in? 45 */ 46 function getSort(){ 47 return 139; 48 } 49 50 /** 51 * Connect pattern to lexer 52 */ 53 function connectTo($mode) { 54 $this->Lexer->addSpecialPattern('{{indexmenu_n>.+?}}',$mode,'plugin_indexmenu_tag'); 55 } 56 57 /** 58 * Handle the match 59 */ 60 function handle($match, $state, $pos, &$handler){ 61 $match = substr($match,14,-2); 62 return array($match); 63 } 64 65 /** 66 * Render output 67 */ 68 function render($mode, &$renderer, $data) { 69 if (is_numeric($data[0])) $renderer->meta['indexmenu_n'] = $data[0];; 70 } 71}