forked from cosmocode/edittable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer_table_edit.php
93 lines (79 loc) · 3.02 KB
/
renderer_table_edit.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
<?php
/**
* Helper functions for table editing
*
* @author Adrian Lang <[email protected]>
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*/
require_once DOKU_PLUGIN."/edittable/inverse.php";
class Doku_Renderer_xhtml_table_edit extends Doku_Renderer_wiki {
function table_open($maxcols = null, $numrows = null){
parent::block();
// initialize the row counter used for classes
$this->_counter['row_counter'] = 0;
$this->_counter['table_begin_pos'] = strlen($this->doc);
$this->doc .= '<table class="inline edit">'.DOKU_LF;
}
function table_close() {
parent::block();
$this->doc .= '</table>'.DOKU_LF;
}
function tableheader_open($colspan = 1, $align = null, $rowspan = 1){
$this->_tablefield_open('th', $colspan, $align, $rowspan);
}
function tableheader_close(){
$this->_tablefield_close('th');
}
function tablecell_open($colspan = 1, $align = null, $rowspan = 1){
$this->_tablefield_open('td', $colspan, $align, $rowspan);
}
function tablecell_close(){
$this->_tablefield_close('td');
}
function tablerow_open(){
parent::block();
// initialize the cell counter used for classes
$this->_counter['cell_counter'] = 0;
$class = 'row' . $this->_counter['row_counter']++;
$this->doc .= DOKU_TAB . '<tr class="'.$class.'">' . DOKU_LF . DOKU_TAB . DOKU_TAB;
}
function tablerow_close() {
parent::block();
$this->doc .= '</tr>';
}
function _tablefield_open($tag, $colspan, $align, $rowspan) {
parent::block();
$basename = 'table[' . $this->_counter['row_counter'] . '][' . $this->_counter['cell_counter'] . ']';
$class = 'class="col' . $this->_counter['cell_counter']++;
$class .= '"';
$this->doc .= "<$tag $class";
if ( $colspan > 1 ) {
$this->_counter['cell_counter'] += $colspan-1;
$this->doc .= ' colspan="'.$colspan.'"';
}
if ( $rowspan > 1 ) {
$this->doc .= ' rowspan="'.$rowspan.'"';
}
$this->doc .= '>';
foreach(compact('rowspan', 'colspan', 'align', 'tag') as $name => $val) {
$this->doc .= '<input ' . html_attbuild(array('type' => 'hidden',
'name' => "{$basename}[{$name}]",
'value' => $val)) . ' />';
}
$this->doc .='<input name="' . $basename . '[text]" class="' . $align .
'align"';
$this->doc .= 'value="';
$this->pre_table_doc = $this->doc;
$this->doc = '';
}
function _tablefield_close($tag) {
parent::block();
$this->doc = $this->pre_table_doc . hsc($this->doc) . '" /></' . $tag . '>';
}
function cdata($text) {
$this->doc .= $this->_xmlEntities(parent::cdata($text));
}
function _xmlEntities($string) {
return htmlspecialchars($string,ENT_QUOTES,'UTF-8');
}
}