From 169c72406cf283b0bb8c7e6ec8ee17e6e0be4f8b Mon Sep 17 00:00:00 2001
From: chris <chris@jalakai.co.uk>
Date: Tue, 6 Feb 2007 02:54:54 +0100
Subject: [PATCH] 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(-)

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 <andi@splitbrain.org>
      */
-    function render_TOC(){
-        if(count($this->toc) < 3) return '';
+    function render_TOC($toc){
+        if(count($toc) < 3) return '';
         global $lang;
         $out  = '<div class="toc">'.DOKU_LF;
         $out .= '<div class="tocheader toctoggle" id="toc__header">';
         $out .= $lang['toc'];
         $out .= '</div>'.DOKU_LF;
         $out .= '<div id="toc__inside">'.DOKU_LF;
-        $out .= html_buildlist($this->toc,'toc',array($this,'_tocitem'));
+        $out .= html_buildlist($toc,'toc',array(__CLASS__,'_tocitem'));
         $out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF;
         return $out;
     }
@@ -109,7 +109,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
      */
     function _tocitem($item){
         return '<span class="li"><a href="#'.$item['hid'].'" class="toc">'.
-               $this->_xmlEntities($item['title']).'</a></span>';
+               Doku_Renderer_xhtml::_xmlEntities($item['title']).'</a></span>';
     }
 
     function toc_additem($id, $text, $level) {
-- 
GitLab