1<?php
2/**
3 * Plugin nspages : Displays nicely a list of the pages of a namespace
4 *
5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 */
7
8if(!defined('DOKU_INC')) die();
9
10class rendererXhtmlHelper {
11    private $renderer;
12    private $percentWidth;
13    private $plugin;
14    private $anchorName;
15
16    function __construct($renderer, $nbCols, $plugin, $anchorName){
17        $this->renderer =& $renderer;
18        $this->percentWidth = $this->buildWidth($nbCols);
19        $this->plugin = $plugin;
20        $this->anchorName = $anchorName;
21    }
22
23    private function buildWidth($nbCols){
24        return (100 / $nbCols) . '%';
25    }
26
27    function printHeaderChar($char, $continued = false){
28        $text = $char;
29        if ( $continued ){
30            $text .= $this->plugin->getLang('continued');
31        }
32
33        $this->renderer->doc .= '<div '
34            . $this->fullAnchor($char, $continued)
35            . 'class="catpagechars';
36        if ( $continued ){
37            $this->renderer->doc .= ' continued';
38        }
39        $this->renderer->doc .= '">' . $text . "</div>\n";
40    }
41
42    private function fullAnchor($char, $continued){
43        if ( $continued === true || is_null($this->anchorName) ){
44            return '';
45        }
46
47        return 'id="nspages_' . $this->anchorName . '_' . $char . '" ';
48    }
49
50    function openColumn(){
51        $this->renderer->doc .= "\n".'<div class="catpagecol" style="width: '.$this->percentWidth.'" >';
52    }
53
54    function closeColumn(){
55        $this->renderer->doc .= "</div>\n";
56    }
57
58    function openListOfItems(){
59        $this->renderer->doc .= "<ul class=\"nspagesul\">\n";
60    }
61
62    function closeListOfItems(){
63        $this->renderer->doc .= '</ul>';
64    }
65}
66