1<?php
2/**
3 * Renderer for XHTML output
4 *
5 * @author Pierre Spring <pierre.spring@liip.ch>
6 * @author Myron Turner <turnermm02@shaw.ca>
7 */
8// must be run within Dokuwiki
9if(!defined('DOKU_INC')) die();
10
11// we inherit from the XHTML renderer instead directly of the base renderer
12require_once DOKU_INC.'inc/parser/xhtml.php';
13
14/**
15 * The Renderer
16 */
17class renderer_plugin_ckgdoku extends Doku_Renderer_xhtml
18{
19
20    var $ver_anteater;
21    var $dwiki_version;
22
23/**
24 * Establish version in constructor
25 * @author Myron Turner <turnermm02@shaw.ca>
26 */
27
28    function __construct() {
29      global $conf;
30      $this->ver_anteater = mktime(0,0,0,11,7,2010);
31      $this->dwiki_version=mktime(0,0,0,01,01,2008);
32
33      if(isset($conf['fnencode'])) {
34          $this->ver_anteater = mktime(0,0,0,11,7,2010);
35          $this->dwiki_version=mktime(0,0,0,11,7,2010);
36      }
37      else if(function_exists('getVersionData')) {
38          $verdata= getVersionData();
39          if(isset($verdata) && preg_match('/(\d+)-(\d+)-(\d+)/',$verdata['date'],$ver_date)) {
40              if($ver_date[1] >= 2005 && ($ver_date[3] > 0 && $ver_date[3] < 31) && ($ver_date[2] > 0 && $ver_date[2] <= 12)) {
41                                              // month        day               year
42              $this->dwiki_version=@mktime(0,  0,  0, $ver_date[2],$ver_date[3], $ver_date[1]);
43              if(!$this->dwiki_version) $this->dwiki_version = mktime(0,0,0,01,01,2008);
44              $this->ver_anteater = mktime(0,0,0,11,7,2010);
45          }
46        }
47      }
48    }
49
50
51    /**
52     * the format we produce
53     */
54    function getFormat()
55    {
56        // this should be 'ckgdoku' usally, but we inherit from the xhtml renderer
57        // and produce XHTML as well, so we can gain magically compatibility
58        // by saying we're the 'xhtml' renderer here.
59        return 'xhtml';
60    }
61
62
63
64
65    /*
66     * The standard xhtml renderer adds anchors we do not need.
67     */
68    function header($text, $level, $pos) {
69        // write the header
70        $this->doc .= DOKU_LF.'<h'.$level.'>';
71        $this->doc .= $this->_xmlEntities($text);
72        $this->doc .= "</h$level>".DOKU_LF;
73    }
74
75    /*
76     * The FCKEditor prefers <b> over <strong>
77     */
78    function strong_open()
79    {
80
81        $this->doc .= '<b>';
82    }
83    function strong_close()
84    {
85        $this->doc .= '</b>';
86    }
87
88    /*
89     * The FCKEditor prefers <strike> over <del>
90     */
91    function deleted_open()
92    {
93        $this->doc .= '<strike>';
94    }
95    function deleted_close()
96    {
97        $this->doc .= '</strike>';
98    }
99
100    /**
101     * isolate table from bottom and top editor window margins
102     * @author Myron Turner <turnermm02@shaw.ca>
103     */
104    function table_close($pos = NULL)
105    {
106        global $conf;
107        $this->doc .= "</table>\n<span class='np_break'>&nbsp;</span>\n";
108        if($this->dwiki_version >= $this->ver_anteater) {
109           $this->doc .= "</div>";
110        }
111    }
112
113    function table_open($maxcols = null, $numrows = null, $pos = null, $classes = NULL){
114        $this->doc .= "\n<span class='np_break'>&nbsp;</span>\n";
115        parent::table_open($maxcols, $numrows, $pos,$classes);
116    }
117    /*
118     * Dokuwiki displays __underlines__ as follows
119     *     <em class="u">underlines</em>
120     * in the fck editor this conflicts with
121     * the //italic// style that is displayed as
122     *     <em>italic</em>
123     * which makes the rathe obvious
124     */
125    function underline_open()
126    {
127        $this->doc .= '<u>';
128    }
129    function underline_close()
130    {
131        $this->doc .= '</u>';
132    }
133
134    function listcontent_open()
135    {
136    }
137
138    function listcontent_close()
139    {
140    }
141}
142