@@ -84,6 +84,9 @@ discard block |
||
84 | 84 | return $this; |
85 | 85 | } |
86 | 86 | |
87 | + /** |
|
88 | + * @param integer $index |
|
89 | + */ |
|
87 | 90 | public function removeItem($index){ |
88 | 91 | return array_splice($this->content, $index, 1); |
89 | 92 | } |
@@ -99,6 +102,9 @@ discard block |
||
99 | 102 | return $this->addItem($function($object)); |
100 | 103 | } |
101 | 104 | |
105 | + /** |
|
106 | + * @param \Closure $callBack |
|
107 | + */ |
|
102 | 108 | public function apply($callBack){ |
103 | 109 | foreach ($this->content as $item){ |
104 | 110 | $callBack($item); |
@@ -70,7 +70,7 @@ |
||
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @param int $index |
73 | - * @return \Ajax\semantic\html\content\HtmlTR |
|
73 | + * @return \Ajax\common\html\HtmlDoubleElement |
|
74 | 74 | */ |
75 | 75 | public function getRow($index){ |
76 | 76 | return $this->getItem($index); |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | * @author jc |
10 | 10 | * |
11 | 11 | */ |
12 | -class HtmlTableContent extends HtmlSemCollection{ |
|
12 | +class HtmlTableContent extends HtmlSemCollection { |
|
13 | 13 | |
14 | - protected $_tdTagNames=["thead"=>"th","tbody"=>"td","tfoot"=>"th"]; |
|
14 | + protected $_tdTagNames=["thead"=>"th", "tbody"=>"td", "tfoot"=>"th"]; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @param string $identifier |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | * @param int $rowCount |
20 | 20 | * @param int $colCount |
21 | 21 | */ |
22 | - public function __construct( $identifier,$tagName="tbody",$rowCount=NULL,$colCount=NULL){ |
|
23 | - parent::__construct( $identifier, $tagName, ""); |
|
24 | - if(isset($rowCount) && isset($colCount)) |
|
22 | + public function __construct($identifier, $tagName="tbody", $rowCount=NULL, $colCount=NULL) { |
|
23 | + parent::__construct($identifier, $tagName, ""); |
|
24 | + if (isset($rowCount) && isset($colCount)) |
|
25 | 25 | $this->setRowCount($rowCount, $colCount); |
26 | 26 | } |
27 | 27 | |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | * @param int $colCount |
31 | 31 | * @return \Ajax\semantic\html\content\table\HtmlTableContent |
32 | 32 | */ |
33 | - public function setRowCount($rowCount,$colCount){ |
|
33 | + public function setRowCount($rowCount, $colCount) { |
|
34 | 34 | $count=$this->count(); |
35 | - for($i=$count;$i<$rowCount;$i++){ |
|
35 | + for ($i=$count; $i<$rowCount; $i++) { |
|
36 | 36 | $this->addItem($colCount); |
37 | 37 | } |
38 | - for($i=0;$i<$rowCount;$i++){ |
|
38 | + for ($i=0; $i<$rowCount; $i++) { |
|
39 | 39 | $item=$this->content[$i]; |
40 | 40 | $item->setTdTagName($this->_tdTagNames[$this->tagName]); |
41 | 41 | $this->content[$i]->setColCount($colCount); |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | * {@inheritDoc} |
48 | 48 | * @see \Ajax\common\html\HtmlCollection::createItem() |
49 | 49 | */ |
50 | - protected function createItem($value){ |
|
50 | + protected function createItem($value) { |
|
51 | 51 | $count=$this->count(); |
52 | - $tr= new HtmlTR("", $value); |
|
52 | + $tr=new HtmlTR("", $value); |
|
53 | 53 | $tr->setContainer($this, $count); |
54 | 54 | return $tr; |
55 | 55 | } |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | * @param int $col |
61 | 61 | * @return \Ajax\semantic\html\content\HtmlTD |
62 | 62 | */ |
63 | - public function getCell($row,$col){ |
|
63 | + public function getCell($row, $col) { |
|
64 | 64 | $row=$this->getItem($row); |
65 | - if(isset($row)){ |
|
65 | + if (isset($row)) { |
|
66 | 66 | $col=$row->getItem($col); |
67 | 67 | } |
68 | 68 | return $col; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param int $index |
73 | 73 | * @return \Ajax\semantic\html\content\HtmlTR |
74 | 74 | */ |
75 | - public function getRow($index){ |
|
75 | + public function getRow($index) { |
|
76 | 76 | return $this->getItem($index); |
77 | 77 | } |
78 | 78 | |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | * @param mixed $value |
83 | 83 | * @return \Ajax\semantic\html\content\table\HtmlTableContent |
84 | 84 | */ |
85 | - public function setCellValue($row,$col,$value=""){ |
|
85 | + public function setCellValue($row, $col, $value="") { |
|
86 | 86 | $cell=$this->getCell($row, $col); |
87 | - if(isset($cell)===true){ |
|
87 | + if (isset($cell)===true) { |
|
88 | 88 | $cell->setValue($value); |
89 | 89 | } |
90 | 90 | return $this; |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | * Sets the cells values |
95 | 95 | * @param mixed $values |
96 | 96 | */ |
97 | - public function setValues($values=array()){ |
|
97 | + public function setValues($values=array()) { |
|
98 | 98 | $count=$this->count(); |
99 | - if(\is_array($values)===false){ |
|
99 | + if (\is_array($values)===false) { |
|
100 | 100 | $values=\array_fill(0, $count, $values); |
101 | 101 | } |
102 | - $count=\min(\sizeof($values),$count); |
|
102 | + $count=\min(\sizeof($values), $count); |
|
103 | 103 | |
104 | - for ($i=0;$i<$count;$i++){ |
|
104 | + for ($i=0; $i<$count; $i++) { |
|
105 | 105 | $row=$this->content[$i]; |
106 | 106 | $row->setValues($values[$i]); |
107 | 107 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * Returns the number of rows (TR) |
112 | 112 | * @return int |
113 | 113 | */ |
114 | - public function getRowCount(){ |
|
114 | + public function getRowCount() { |
|
115 | 115 | return $this->count(); |
116 | 116 | } |
117 | 117 | |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * Returns the number of columns (TD) |
120 | 120 | * @return int |
121 | 121 | */ |
122 | - public function getColCount(){ |
|
122 | + public function getColCount() { |
|
123 | 123 | $result=0; |
124 | - if($this->count()>0) |
|
124 | + if ($this->count()>0) |
|
125 | 125 | $result=$this->getItem(0)->getColCount(); |
126 | 126 | return $result; |
127 | 127 | } |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | * @param int $colIndex |
133 | 133 | * @return \Ajax\semantic\html\content\table\HtmlTableContent |
134 | 134 | */ |
135 | - public function delete($rowIndex,$colIndex=NULL){ |
|
136 | - if(isset($colIndex)){ |
|
135 | + public function delete($rowIndex, $colIndex=NULL) { |
|
136 | + if (isset($colIndex)) { |
|
137 | 137 | $row=$this->getItem($rowIndex); |
138 | - if(isset($row)===true){ |
|
138 | + if (isset($row)===true) { |
|
139 | 139 | $row->delete($colIndex); |
140 | 140 | } |
141 | - }else{ |
|
141 | + }else { |
|
142 | 142 | $this->removeItem($rowIndex); |
143 | 143 | } |
144 | 144 | return $this; |