11<?php
2-
32namespace Ajax \semantic \html \content \table ;
43
54use Ajax \semantic \html \base \HtmlSemDoubleElement ;
1312
1413class HtmlTD extends HtmlSemDoubleElement {
1514 use TextAlignmentTrait,TableElementTrait;
15+
1616 private $ _container ;
17+
1718 private $ _row ;
19+
1820 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 ;
2227
2328 /**
2429 *
2530 * @param string $identifier
2631 * @param mixed $content
2732 * @param string $tagName
2833 */
29- public function __construct ($ identifier , $ content= NULL , $ tagName= "td " ) {
34+ public function __construct ($ identifier , $ content = NULL , $ tagName = "td " ) {
3035 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+ ];
3347 }
3448
3549 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 ;
3953 }
4054
4155 public function setValue ($ value ) {
42- $ this ->content = $ value ;
56+ $ this ->content = $ value ;
4357 return $ this ;
4458 }
4559
@@ -49,50 +63,60 @@ public function addValue($value) {
4963 }
5064
5165 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 --) {
5468 $ this ->_container ->toDelete ($ i , $ this ->_col );
5569 }
5670 $ this ->setProperty ("rowspan " , $ rowspan );
5771 return $ this ->_container ->_setMerged (true );
5872 }
5973
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+
6083 public function mergeRow () {
61- if (! $ this ->_rowMerged ){
62- $ this ->_rowMerged = true ;
84+ if (! $ this ->_rowMerged ) {
85+ $ this ->_rowMerged = true ;
6386 return $ this ->setRowspan ($ this ->_container ->count ());
6487 }
6588 return $ this ->_container ;
6689 }
6790
6891 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 ());
7296 }
7397 return $ this ->_container ;
7498 }
7599
76100 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 --) {
79103 $ this ->_container ->delete ($ this ->_row , $ this ->_col + 1 );
80104 }
81105 $ this ->setProperty ("colspan " , $ colspan );
82106 return $ this ->_container ;
83107 }
84108
85109 public function getColspan () {
86- $ colspan= 1 ;
110+ $ colspan = 1 ;
87111 if (\array_key_exists ("colspan " , $ this ->properties ))
88- $ colspan= $ this ->getProperty ("colspan " );
112+ $ colspan = $ this ->getProperty ("colspan " );
89113 return $ colspan ;
90114 }
91115
92116 public function getRowspan () {
93- $ rowspan= 1 ;
117+ $ rowspan = 1 ;
94118 if (\array_key_exists ("rowspan " , $ this ->properties ))
95- $ rowspan= $ this ->getProperty ("rowspan " );
119+ $ rowspan = $ this ->getProperty ("rowspan " );
96120 return $ rowspan ;
97121 }
98122
@@ -108,28 +132,30 @@ public function apply($callback) {
108132 return $ this ;
109133 }
110134
111- public function setSelectable ($ href= "# " ) {
135+ public function setSelectable ($ href = "# " ) {
112136 if (\is_string ($ this ->content )) {
113- $ this ->content = new HtmlLink ("" , $ href , $ this ->content );
137+ $ this ->content = new HtmlLink ("" , $ href , $ this ->content );
114138 }
115139 return $ this ->addToProperty ("class " , "selectable " );
116140 }
117141
118- public function setWidth ($ width ){
142+ public function setWidth ($ width ) {
119143 if (\is_int ($ width )) {
120- $ width= Wide::getConstants ()["W " . $ width ];
144+ $ width = Wide::getConstants ()["W " . $ width ];
121145 }
122146 $ this ->addToPropertyCtrl ("class " , $ width , Wide::getConstants ());
123- return $ this ->addToPropertyCtrl ("class " , "wide " , array ("wide " ));
147+ return $ this ->addToPropertyCtrl ("class " , "wide " , array (
148+ "wide "
149+ ));
124150 }
125151
126- public function toDelete (){
127- $ this ->_deleted = true ;
152+ public function toDelete () {
153+ $ this ->_deleted = true ;
128154 return $ this ;
129155 }
130156
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 );
134160 }
135161}
0 commit comments