Subversion Repositories Applications.papyrus

Rev

Rev 175 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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