From c06c1c7a81c74301fd1e6f575f9af95dedb6d6d3 Mon Sep 17 00:00:00 2001 From: Esther Brunner Date: Tue, 27 Feb 2007 13:31:23 +0100 Subject: additions for the info plugin darcs-hash:20070227123123-20862-168124d05e49273adec628bf6bdf78792b366548.gz --- lib/plugins/info/syntax.php | 100 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 93 insertions(+), 7 deletions(-) (limited to 'lib/plugins/info') diff --git a/lib/plugins/info/syntax.php b/lib/plugins/info/syntax.php index b93ef4887..044b046f8 100644 --- a/lib/plugins/info/syntax.php +++ b/lib/plugins/info/syntax.php @@ -4,6 +4,7 @@ * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Andreas Gohr + * @author Esther Brunner */ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); @@ -24,7 +25,7 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { return array( 'author' => 'Andreas Gohr', 'email' => 'andi@splitbrain.org', - 'date' => '2005-08-03', + 'date' => '2006-12-09', 'name' => 'Info Plugin', 'desc' => 'Displays information about various DokuWiki internals', 'url' => 'http://wiki.splitbrain.org/plugin:info', @@ -86,7 +87,22 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { $renderer->doc .= $this->_syntaxtypes_xhtml(); break; case 'syntaxplugins': - $this->_syntaxplugins_xhtml($renderer); + $this->_plugins_xhtml('syntax', $renderer); + break; + case 'adminplugins': + $this->_plugins_xhtml('admin', $renderer); + break; + case 'actionplugins': + $this->_plugins_xhtml('action', $renderer); + break; + case 'rendererplugins': + $this->_plugins_xhtml('renderer', $renderer); + break; + case 'helperplugins': + $this->_plugins_xhtml('helper', $renderer); + break; + case 'helpermethods': + $this->_helpermethods_xhtml($renderer); break; default: $renderer->doc .= "no info about ".htmlspecialchars($data[0]); @@ -97,17 +113,17 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { } /** - * list all installed syntax plugins + * list all installed plugins * * uses some of the original renderer methods */ - function _syntaxplugins_xhtml(& $renderer){ + function _plugins_xhtml($type, &$renderer){ global $lang; $renderer->doc .= '
    '; - $plugins = plugin_list('syntax'); + $plugins = plugin_list($type); foreach($plugins as $p){ - if (!$po =& plugin_load('syntax',$p)) continue; + if (!$po =& plugin_load($type,$p)) continue; $info = $po->getInfo(); $renderer->doc .= '
  • '; @@ -119,13 +135,65 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { $renderer->doc .= ' '; $renderer->emaillink($info['email'],$info['author']); $renderer->doc .= '
    '; - $renderer->doc .= strtr(htmlspecialchars($info['desc']),array("\n"=>"
    ")); + $renderer->doc .= strtr(hsc($info['desc']),array("\n"=>"
    ")); $renderer->doc .= '
  • '; unset($po); } $renderer->doc .= '
'; } + + /** + * list all installed plugins + * + * uses some of the original renderer methods + */ + function _helpermethods_xhtml(&$renderer){ + global $lang; + + $plugins = plugin_list('helper'); + foreach($plugins as $p){ + if (!$po =& plugin_load('helper',$p)) continue; + + if (!method_exists($po, 'getMethods')) continue; + $methods = $po->getMethods(); + $info = $po->getInfo(); + + $hid = $this->_addToTOC($info['name'], 2, $renderer); + $doc = '

'.hsc($info['name']).'

'; + $doc .= '
'; + $doc .= '

'.strtr(hsc($info['desc']), array("\n"=>"
")).'

'; + $doc .= '
$'.$p." =& plugin_load('helper', '".$p."');
"; + $doc .= '
'; + foreach ($methods as $method){ + $title = '$'.$p.'->'.$method['name'].'()'; + $hid = $this->_addToTOC($title, 3, $renderer); + $doc .= '

'.hsc($title).'

'; + $doc .= '
'; + $doc .= ''; + $doc .= ''; + if ($method['params']){ + $c = count($method['params']); + $doc .= ''; + } + if ($method['return']){ + $doc .= ''; + } + $doc .= '
Description'.$method['desc']. + '
Parameters'; + $params = array(); + foreach ($method['params'] as $desc => $type){ + $params[] = hsc($desc).''.hsc($type); + } + $doc .= join($params, '
').'
Return value'.hsc(key($method['return'])). + ''.hsc(current($method['return'])).'
'; + $doc .= '
'; + } + unset($po); + + $renderer->doc .= $doc; + } + } /** * lists all known syntax types and their registered modes @@ -161,6 +229,24 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { } return $doc; } + + /** + * Adds a TOC item + */ + function _addToTOC($text, $level, &$renderer){ + global $conf; + + if (($level >= $conf['toptoclevel']) && ($level <= $conf['maxtoclevel'])){ + $hid = $renderer->_headerToLink($text, 'true'); + $renderer->toc[] = array( + 'hid' => $hid, + 'title' => $text, + 'type' => 'ul', + 'level' => $level - $conf['toptoclevel'] + 1 + ); + } + return $hid; + } } //Setup VIM: ex: et ts=4 enc=utf-8 : -- cgit v1.2.3