Subversion Repositories Applications.papyrus

Rev

Rev 175 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
175 jpm 1
<?php
2
 
3
class Text_Wiki_Render_Xhtml_Table extends Text_Wiki_Render {
4
 
5
    var $conf = array(
6
        'css_table' => null,
7
        'css_tr' => null,
8
        'css_th' => null,
9
        'css_td' => null
10
    );
11
 
12
 
13
    /**
14
    *
15
    * Renders a token into text matching the requested format.
16
    *
17
    * @access public
18
    *
19
    * @param array $options The "options" portion of the token (second
20
    * element).
21
    *
22
    * @return string The text rendered from the token options.
23
    *
24
    */
25
 
26
    function token($options)
27
    {
28
        // make nice variable names (type, attr, span)
29
        extract($options);
832 florian 30
        if (!isset($span)) $span=1;
31
        if (!isset($type)) $type='';
32
        if (!isset($attr)) $attr='';
33
 
175 jpm 34
        $pad = '    ';
35
 
36
        switch ($type) {
37
 
38
        case 'table_start':
39
            $css = $this->formatConf(' class="%s"', 'css_table');
40
            return "\n\n".'<table'.$css.' '.trim($attr).'>'."\n";
41
 
42
        case 'table_end':
43
            return "</table>\n\n";
44
 
45
        case 'row_start':
46
            $css = $this->formatConf(' class="%s"', 'css_tr');
47
            return "$pad<tr$css $attr>\n";
48
        case 'row_end':
49
            return "$pad</tr>\n";
50
 
51
        case 'cell_start':
52
 
53
            // base html
54
            $html = $pad . $pad;
55
 
56
            // is this a TH or TD cell?
57
            if ($attr == 'header') {
58
                // start a header cell
59
                $css = $this->formatConf(' class="%s"', 'css_th');
60
                $html .= "<th$css";
61
            } else {
62
                // start a normal cell
63
                $css = $this->formatConf(' class="%s"', 'css_td');
64
                $html .= "<td$css";
65
            }
66
 
67
            // add the column span
68
            if ($span > 1) {
69
                $html .= " colspan=\"$span\"";
70
            }
71
 
72
            // add alignment
73
            if ($attr != 'header' && $attr != '') {
74
                $html .= " $attr";
75
            }
76
 
77
            // done!
78
            $html .= '>';
79
            return $html;
80
 
81
        case 'cell_end':
82
            if ($attr == 'header') {
83
                return "</th>\n";
84
            } else {
85
                return "</td>\n";
86
            }
87
 
88
        default:
89
            return '';
90
 
91
        }
92
    }
93
}
94
?>