1
1
<?php
2
-
3
2
namespace Ajax \semantic \html \content \table ;
4
3
5
4
use Ajax \semantic \html \base \HtmlSemDoubleElement ;
13
12
14
13
class HtmlTD extends HtmlSemDoubleElement {
15
14
use TextAlignmentTrait,TableElementTrait;
15
+
16
16
private $ _container ;
17
+
17
18
private $ _row ;
19
+
18
20
private $ _col ;
19
- private $ _colMerged =false ;
20
- private $ _rowMerged =false ;
21
- private $ _deleted =false ;
21
+
22
+ private $ _colMerged = false ;
23
+
24
+ private $ _rowMerged = false ;
25
+
26
+ private $ _deleted = false ;
22
27
23
28
/**
24
29
*
25
30
* @param string $identifier
26
31
* @param mixed $content
27
32
* @param string $tagName
28
33
*/
29
- public function __construct ($ identifier , $ content= NULL , $ tagName= "td " ) {
34
+ public function __construct ($ identifier , $ content = NULL , $ tagName = "td " ) {
30
35
parent ::__construct ($ identifier , $ tagName , "" , $ content );
31
- $ this ->_variations =[ Variation::COLLAPSING ];
32
- $ this ->_states =[ State::ACTIVE ,State::POSITIVE ,State::NEGATIVE ,State::WARNING ,State::ERROR ,State::DISABLED ];
36
+ $ this ->_variations = [
37
+ Variation::COLLAPSING
38
+ ];
39
+ $ this ->_states = [
40
+ State::ACTIVE ,
41
+ State::POSITIVE ,
42
+ State::NEGATIVE ,
43
+ State::WARNING ,
44
+ State::ERROR ,
45
+ State::DISABLED
46
+ ];
33
47
}
34
48
35
49
public function setContainer ($ container , $ row , $ col ) {
36
- $ this ->_container = $ container ;
37
- $ this ->_row = $ row ;
38
- $ this ->_col = $ col ;
50
+ $ this ->_container = $ container ;
51
+ $ this ->_row = $ row ;
52
+ $ this ->_col = $ col ;
39
53
}
40
54
41
55
public function setValue ($ value ) {
42
- $ this ->content = $ value ;
56
+ $ this ->content = $ value ;
43
57
return $ this ;
44
58
}
45
59
@@ -49,50 +63,60 @@ public function addValue($value) {
49
63
}
50
64
51
65
public function setRowspan ($ rowspan ) {
52
- $ to= min ($ this ->_container ->count (), $ this ->_row + $ rowspan - 1 );
53
- for ($ i= $ to ; $ i > $ this ->_row ; $ i --) {
66
+ $ to = min ($ this ->_container ->count (), $ this ->_row + $ rowspan - 1 );
67
+ for ($ i = $ to ; $ i > $ this ->_row ; $ i --) {
54
68
$ this ->_container ->toDelete ($ i , $ this ->_col );
55
69
}
56
70
$ this ->setProperty ("rowspan " , $ rowspan );
57
71
return $ this ->_container ->_setMerged (true );
58
72
}
59
73
74
+ public function setRowspanned ($ rowspan ) {
75
+ $ to = min ($ this ->_container ->count (), $ this ->_row + $ rowspan - 1 );
76
+ for ($ i = $ to ; $ i > $ this ->_row ; $ i --) {
77
+ $ this ->_container ->toRowspanned ($ i , $ this ->_col );
78
+ }
79
+ $ this ->setProperty ("rowspan " , $ rowspan );
80
+ return $ this ->_container ->_setMerged (true );
81
+ }
82
+
60
83
public function mergeRow () {
61
- if (! $ this ->_rowMerged ){
62
- $ this ->_rowMerged = true ;
84
+ if (! $ this ->_rowMerged ) {
85
+ $ this ->_rowMerged = true ;
63
86
return $ this ->setRowspan ($ this ->_container ->count ());
64
87
}
65
88
return $ this ->_container ;
66
89
}
67
90
68
91
public function mergeCol () {
69
- if (!$ this ->_colMerged ){
70
- $ this ->_colMerged =true ;
71
- return $ this ->setColspan ($ this ->_container ->getRow ($ this ->_row )->count ());
92
+ if (! $ this ->_colMerged ) {
93
+ $ this ->_colMerged = true ;
94
+ return $ this ->setColspan ($ this ->_container ->getRow ($ this ->_row )
95
+ ->count ());
72
96
}
73
97
return $ this ->_container ;
74
98
}
75
99
76
100
public function setColspan ($ colspan ) {
77
- $ to= min ($ this ->_container ->getRow ($ this ->_row )->count (), $ this ->_col + $ colspan - 1 );
78
- for ($ i= $ to ; $ i > $ this ->_col ; $ i --) {
101
+ $ to = min ($ this ->_container ->getRow ($ this ->_row )->count (), $ this ->_col + $ colspan - 1 );
102
+ for ($ i = $ to ; $ i > $ this ->_col ; $ i --) {
79
103
$ this ->_container ->delete ($ this ->_row , $ this ->_col + 1 );
80
104
}
81
105
$ this ->setProperty ("colspan " , $ colspan );
82
106
return $ this ->_container ;
83
107
}
84
108
85
109
public function getColspan () {
86
- $ colspan= 1 ;
110
+ $ colspan = 1 ;
87
111
if (\array_key_exists ("colspan " , $ this ->properties ))
88
- $ colspan= $ this ->getProperty ("colspan " );
112
+ $ colspan = $ this ->getProperty ("colspan " );
89
113
return $ colspan ;
90
114
}
91
115
92
116
public function getRowspan () {
93
- $ rowspan= 1 ;
117
+ $ rowspan = 1 ;
94
118
if (\array_key_exists ("rowspan " , $ this ->properties ))
95
- $ rowspan= $ this ->getProperty ("rowspan " );
119
+ $ rowspan = $ this ->getProperty ("rowspan " );
96
120
return $ rowspan ;
97
121
}
98
122
@@ -108,28 +132,30 @@ public function apply($callback) {
108
132
return $ this ;
109
133
}
110
134
111
- public function setSelectable ($ href= "# " ) {
135
+ public function setSelectable ($ href = "# " ) {
112
136
if (\is_string ($ this ->content )) {
113
- $ this ->content = new HtmlLink ("" , $ href , $ this ->content );
137
+ $ this ->content = new HtmlLink ("" , $ href , $ this ->content );
114
138
}
115
139
return $ this ->addToProperty ("class " , "selectable " );
116
140
}
117
141
118
- public function setWidth ($ width ){
142
+ public function setWidth ($ width ) {
119
143
if (\is_int ($ width )) {
120
- $ width= Wide::getConstants ()["W " . $ width ];
144
+ $ width = Wide::getConstants ()["W " . $ width ];
121
145
}
122
146
$ this ->addToPropertyCtrl ("class " , $ width , Wide::getConstants ());
123
- return $ this ->addToPropertyCtrl ("class " , "wide " , array ("wide " ));
147
+ return $ this ->addToPropertyCtrl ("class " , "wide " , array (
148
+ "wide "
149
+ ));
124
150
}
125
151
126
- public function toDelete (){
127
- $ this ->_deleted = true ;
152
+ public function toDelete () {
153
+ $ this ->_deleted = true ;
128
154
return $ this ;
129
155
}
130
156
131
- public function compile (JsUtils $ js= NULL , &$ view= NULL ) {
132
- if (! $ this ->_deleted )
133
- return parent ::compile ($ js ,$ view );
157
+ public function compile (JsUtils $ js = NULL , &$ view = NULL ) {
158
+ if (! $ this ->_deleted )
159
+ return parent ::compile ($ js , $ view );
134
160
}
135
161
}
0 commit comments