C:\xampp\php\pear\Text\Wiki\Render\Xhtml\Table.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
 * Table rule end renderer for Xhtml
 *
 * PHP versions 4 and 5
 *
 * @category   Text
 * @package    Text_Wiki
 * @author     Paul M. Jones <pmjones@php.net>
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
 * @version    CVS: $Id: Table.php 202250 2005-12-06 15:29:29Z ritzmo $
 * @link       http://pear.php.net/package/Text_Wiki
 */

/**
 * This class renders tables in XHTML.
 *
 * @category   Text
 * @package    Text_Wiki
 * @author     Paul M. Jones <pmjones@php.net>
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
 * @version    Release: @package_version@
 * @link       http://pear.php.net/package/Text_Wiki
 */
class Text_Wiki_Render_Xhtml_Table extends Text_Wiki_Render {

    var 
$conf = array(
        
'css_table' => null,
        
'css_caption' => null,
        
'css_tr' => null,
        
'css_th' => null,
        
'css_td' => null
    
);


    
/**
    *
    * Renders a token into text matching the requested format.
    *
    * @access public
    *
    * @param array $options The "options" portion of the token (second
    * element).
    *
    * @return string The text rendered from the token options.
    *
    */

    
function token($options)
    {
        
// make nice variable names (type, attr, span)
        
$span $rowspan 1;
        
extract($options);

        
// free format
        
$format = isset($format) ? ' '$format '';

        
$pad '    ';

        switch (
$type) {

        case 
'table_start':
            
$css $this->formatConf(' class="%s"''css_table');
            return 
"\n\n<table$css$format>\n";
            break;

        case 
'table_end':
            return 
"</table>\n\n";
            break;

        case 
'caption_start':
            
$css $this->formatConf(' class="%s"''css_caption');
            return 
"<caption$css$format>\n";
            break;

        case 
'caption_end':
            return 
"</caption>\n";
            break;

        case 
'row_start':
            
$css $this->formatConf(' class="%s"''css_tr');
            return 
"$pad<tr$css$format>\n";
            break;

        case 
'row_end':
            return 
"$pad</tr>\n";
            break;

        case 
'cell_start':

            
// base html
            
$html $pad $pad;

            
// is this a TH or TD cell?
            
if ($attr == 'header') {
                
// start a header cell
                
$css $this->formatConf(' class="%s"''css_th');
                
$html .= "<th$css";
            } else {
                
// start a normal cell
                
$css $this->formatConf(' class="%s"''css_td');
                
$html .= "<td$css";
            }

            
// add the column span
            
if ($span 1) {
                
$html .= " colspan=\"$span\"";
            }

            
// add the row span
            
if ($rowspan 1) {
                
$html .= " rowspan=\"$rowspan\"";
            }

            
// add alignment
            
if ($attr != 'header' && $attr != '') {
                
$html .= " style=\"text-align: $attr;\"";
            }

            
// done!
            
$html .= "$format>";
            return 
$html;
            break;

        case 
'cell_end':
            if (
$attr == 'header') {
                return 
"</th>\n";
            } else {
                return 
"</td>\n";
            }
            break;

        default:
            return 
'';

        }
    }
}
?>
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586