From 169c72406cf283b0bb8c7e6ec8ee17e6e0be4f8b Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 6 Feb 2007 02:54:54 +0100 Subject: refactor xhtml TOC creation into a class function, FS#1058 - changed inc/parser/xhtml.php, render_TOC() function it now takes a toc array as a parameter - refactor render_TOC() and _tocitem() into static class functions The xhtml renderer can build its TOC using $this->render_TOC($this->toc) Templates can create a separate TOC using echo Doku_Renderer_xhtml::render_TOC(p_get_metadata($ID, 'description tableofcontents')); darcs-hash:20070206015454-9b6ab-b3bd7ff772b756f8aaf496cb319eb73994cdbd94.gz --- inc/parser/xhtml.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 266bfcf4a..b2d5ad46b 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -79,7 +79,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { // prepend the TOC if($this->info['toc']){ - $this->doc = $this->render_TOC().$this->doc; + $this->doc = $this->render_TOC($this->toc).$this->doc; } // make sure there are no empty paragraphs @@ -91,15 +91,15 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * * @author Andreas Gohr */ - function render_TOC(){ - if(count($this->toc) < 3) return ''; + function render_TOC($toc){ + if(count($toc) < 3) return ''; global $lang; $out = '
'.DOKU_LF; $out .= '
'; $out .= $lang['toc']; $out .= '
'.DOKU_LF; $out .= '
'.DOKU_LF; - $out .= html_buildlist($this->toc,'toc',array($this,'_tocitem')); + $out .= html_buildlist($toc,'toc',array(__CLASS__,'_tocitem')); $out .= '
'.DOKU_LF.'
'.DOKU_LF; return $out; } @@ -109,7 +109,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { */ function _tocitem($item){ return ''. - $this->_xmlEntities($item['title']).''; + Doku_Renderer_xhtml::_xmlEntities($item['title']).''; } function toc_additem($id, $text, $level) { -- cgit v1.2.3