From 107b01d60353b74aebd1901b6f19e70a998b2594 Mon Sep 17 00:00:00 2001 From: andi Date: Sat, 21 May 2005 23:04:30 +0200 Subject: sorting support for syntax plugins, info plugin now actually does something Syntax plugins now need to implement getSort() which should return a number. This number is used to add all syntax modes in the correct order. To see a list in which order current modes are loaded you can use the info plugin like this: ~~INFO:syntaxmodes~~ lists all known modes (includes existing plugins) with their sorting score ~~INFO:syntaxtypes~~ lists all syntax types and their registered modes (useful for implementing the getType() function. darcs-hash:20050521210430-9977f-2baaf6043afc6ea3fed41cdca97564218fb519c2.gz --- inc/plugins/info/syntax.php | 53 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) (limited to 'inc/plugins') diff --git a/inc/plugins/info/syntax.php b/inc/plugins/info/syntax.php index 4567de685..bf45e5d11 100644 --- a/inc/plugins/info/syntax.php +++ b/inc/plugins/info/syntax.php @@ -22,7 +22,14 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { function getType(){ return 'substition'; } - + + /** + * Where to sort in? + */ + function getSort(){ + return 155; + } + /** * Connect pattern to lexer @@ -47,8 +54,14 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { if($mode == 'xhtml'){ //handle various info stuff switch ($data[0]){ - case 'foo': - $renderer->doc .= "foo is foo"; + case 'version'; + $renderer->doc .= getVersion(); + break; + case 'syntaxmodes'; + $renderer->doc .= $this->_syntaxmodes_xhtml(); + break; + case 'syntaxtypes'; + $renderer->doc .= $this->_syntaxtypes_xhtml(); break; default: $renderer->doc .= "no info about ".htmlspecialchars($data[0]); @@ -58,6 +71,40 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { return false; } + /** + * lists all known syntax types and their registered modes + */ + function _syntaxtypes_xhtml(){ + global $PARSER_MODES; + $doc = ''; + + $doc .= ''; + foreach($PARSER_MODES as $mode => $modes){ + $doc .= ''; + $doc .= ''; + $doc .= ''; + $doc .= ''; + } + $doc .= '
'; + $doc .= $mode; + $doc .= ''; + $doc .= join(', ',$modes); + $doc .= '
'; + return $doc; + } + + /** + * lists all known syntax modes and their sorting value + */ + function _syntaxmodes_xhtml(){ + $modes = p_get_parsermodes(); + $doc = ''; + + foreach ($modes as $mode){ + $doc .= $mode['mode'].' ('.$mode['sort'].'), '; + } + return $doc; + } } //Setup VIM: ex: et ts=4 enc=utf-8 : -- cgit v1.2.3