From eccaa6b2507b4217809b2cd955c0014bd043fe59 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sat, 22 Oct 2011 00:17:10 +0200 Subject: caching, fix setting of metadata in syntax plugin --- syntax.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'syntax.php') diff --git a/syntax.php b/syntax.php index fc6f648..779b40d 100644 --- a/syntax.php +++ b/syntax.php @@ -8,11 +8,11 @@ if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once DOKU_PLUGIN.'syntax.php'; class syntax_plugin_treenav extends DokuWiki_Syntax_Plugin { - private $keys = array("icon", "title"); + private $keys = array('icon', 'title'); function getType() { return 'baseonly'; } function getSort() { return 32; } - + function connectTo($mode) { foreach ($this->keys as $key) { $this->Lexer->addSpecialPattern('~~'.$key.':.*?~~',$mode,'plugin_treenav'); @@ -25,17 +25,16 @@ class syntax_plugin_treenav extends DokuWiki_Syntax_Plugin { $match = substr($match, 2, -2); @list($key, $value) = explode(':', $match, 2); if (in_array($key, $this->keys)) { - $this->setMetadata($key, $value); + return array($key, $value); } } } - - function setMetadata($key, $value) { - global $ID; - $data = p_get_metadata($ID, "treenav", false) or array(); - $data[$key] = $value; - return p_set_metadata($ID, array("treenav" => $data)); + function render($mode, &$renderer, $data) { + if ($mode === 'metadata') { + $renderer->meta['treenav'][$data[0]] = $data[1]; + } } + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.1