@@ -73,6 +73,9 @@ discard block |
||
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | + /** |
|
77 | + * @param HtmlForm $form |
|
78 | + */ |
|
76 | 79 | protected function _generateFields($form,$values,$headers,$sepFirst,$sepLast,$wrappers){ |
77 | 80 | $wrapper=null; |
78 | 81 | //$fields=\array_slice($values, $sepFirst+1,$sepLast-$sepFirst); |
@@ -138,12 +141,20 @@ discard block |
||
138 | 141 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
139 | 142 | } |
140 | 143 | |
144 | + /** |
|
145 | + * @param integer $index |
|
146 | + * @param string $title |
|
147 | + */ |
|
141 | 148 | public function addDividerBefore($index,$title){ |
142 | 149 | $index=$this->_getIndex($index); |
143 | 150 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
144 | 151 | return $this; |
145 | 152 | } |
146 | 153 | |
154 | + /** |
|
155 | + * @param string $index |
|
156 | + * @param string $contentAfter |
|
157 | + */ |
|
147 | 158 | public function addWrapper($index,$contentBefore,$contentAfter=null){ |
148 | 159 | $index=$this->_getIndex($index); |
149 | 160 | $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
@@ -21,85 +21,85 @@ discard block |
||
21 | 21 | use BaseTrait; |
22 | 22 | |
23 | 23 | public function __construct($identifier, $modelInstance=NULL) { |
24 | - parent::__construct($identifier, null,$modelInstance); |
|
24 | + parent::__construct($identifier, null, $modelInstance); |
|
25 | 25 | $this->_form=new HtmlForm($identifier); |
26 | 26 | $this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true); |
27 | 27 | } |
28 | 28 | |
29 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
29 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
30 | 30 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
31 | 31 | } |
32 | 32 | |
33 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
34 | - if(!$this->_generated){ |
|
33 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
34 | + if (!$this->_generated) { |
|
35 | 35 | $this->_instanceViewer->setInstance($this->_modelInstance); |
36 | 36 | |
37 | 37 | $form=$this->content["form"]; |
38 | 38 | $this->_generateContent($form); |
39 | 39 | |
40 | - if(isset($this->_toolbar)){ |
|
40 | + if (isset($this->_toolbar)) { |
|
41 | 41 | $this->_setToolbarPosition($form); |
42 | 42 | } |
43 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
43 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
44 | 44 | $this->_generated=true; |
45 | 45 | } |
46 | - return parent::compile($js,$view); |
|
46 | + return parent::compile($js, $view); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @param HtmlForm $form |
51 | 51 | */ |
52 | - protected function _generateContent($form){ |
|
53 | - $values= $this->_instanceViewer->getValues(); |
|
52 | + protected function _generateContent($form) { |
|
53 | + $values=$this->_instanceViewer->getValues(); |
|
54 | 54 | $count=$this->_instanceViewer->count(); |
55 | 55 | $separators=$this->_instanceViewer->getSeparators(); |
56 | 56 | $headers=$this->_instanceViewer->getHeaders(); |
57 | 57 | $wrappers=$this->_instanceViewer->getWrappers(); |
58 | 58 | \sort($separators); |
59 | 59 | $size=\sizeof($separators); |
60 | - if($size===1){ |
|
60 | + if ($size===1) { |
|
61 | 61 | $i=-1; |
62 | - foreach ($values as $v){ |
|
62 | + foreach ($values as $v) { |
|
63 | 63 | //$form->addField($v); |
64 | 64 | $this->_generateFields($form, [$v], $headers, $i, $i+1, $wrappers); |
65 | 65 | $i++; |
66 | 66 | } |
67 | - }else{ |
|
67 | + } else { |
|
68 | 68 | $separators[]=$count; |
69 | - for($i=0;$i<$size;$i++){ |
|
70 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
69 | + for ($i=0; $i<$size; $i++) { |
|
70 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
71 | 71 | $this->_generateFields($form, $fields, $headers, $separators[$i], $separators[$i+1], $wrappers); |
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - protected function _generateFields($form,$values,$headers,$sepFirst,$sepLast,$wrappers){ |
|
76 | + protected function _generateFields($form, $values, $headers, $sepFirst, $sepLast, $wrappers) { |
|
77 | 77 | $wrapper=null; |
78 | 78 | //$fields=\array_slice($values, $sepFirst+1,$sepLast-$sepFirst); |
79 | - if(isset($headers[$sepFirst+1])) |
|
80 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
81 | - if(isset($wrappers[$sepFirst+1])){ |
|
79 | + if (isset($headers[$sepFirst+1])) |
|
80 | + $form->addHeader($headers[$sepFirst+1], 4, true); |
|
81 | + if (isset($wrappers[$sepFirst+1])) { |
|
82 | 82 | $wrapper=$wrappers[$sepFirst+1]; |
83 | 83 | } |
84 | - if(\sizeof($values)===1){ |
|
84 | + if (\sizeof($values)===1) { |
|
85 | 85 | $added=$form->addField($values[0]); |
86 | - }elseif(\sizeof($values)>1){ |
|
86 | + }elseif (\sizeof($values)>1) { |
|
87 | 87 | $added=$form->addFields($values); |
88 | - }else |
|
88 | + } else |
|
89 | 89 | return; |
90 | - if(isset($wrapper)){ |
|
91 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
90 | + if (isset($wrapper)) { |
|
91 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
96 | 96 | * @return HtmlForm |
97 | 97 | */ |
98 | - public function getForm(){ |
|
98 | + public function getForm() { |
|
99 | 99 | return $this->content["form"]; |
100 | 100 | } |
101 | 101 | |
102 | - public function addSeparatorAfter($fieldNum){ |
|
102 | + public function addSeparatorAfter($fieldNum) { |
|
103 | 103 | $fieldNum=$this->_getIndex($fieldNum); |
104 | 104 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
105 | 105 | return $this; |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 | |
117 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
118 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
119 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
117 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
118 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
119 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
120 | 120 | $button->setProperty("type", "reset"); |
121 | 121 | return $button; |
122 | - }, $index,$attributes); |
|
122 | + }, $index, $attributes); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -138,19 +138,19 @@ discard block |
||
138 | 138 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
139 | 139 | } |
140 | 140 | |
141 | - public function addDividerBefore($index,$title){ |
|
141 | + public function addDividerBefore($index, $title) { |
|
142 | 142 | $index=$this->_getIndex($index); |
143 | 143 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
144 | 144 | return $this; |
145 | 145 | } |
146 | 146 | |
147 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
147 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
148 | 148 | $index=$this->_getIndex($index); |
149 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
149 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
150 | 150 | return $this; |
151 | 151 | } |
152 | 152 | |
153 | - public function run(JsUtils $js){ |
|
153 | + public function run(JsUtils $js) { |
|
154 | 154 | return parent::run($js); |
155 | 155 | } |
156 | 156 | } |
157 | 157 | \ No newline at end of file |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $this->_generateFields($form, [$v], $headers, $i, $i+1, $wrappers); |
65 | 65 | $i++; |
66 | 66 | } |
67 | - }else{ |
|
67 | + } else{ |
|
68 | 68 | $separators[]=$count; |
69 | 69 | for($i=0;$i<$size;$i++){ |
70 | 70 | $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
@@ -76,17 +76,19 @@ discard block |
||
76 | 76 | protected function _generateFields($form,$values,$headers,$sepFirst,$sepLast,$wrappers){ |
77 | 77 | $wrapper=null; |
78 | 78 | //$fields=\array_slice($values, $sepFirst+1,$sepLast-$sepFirst); |
79 | - if(isset($headers[$sepFirst+1])) |
|
80 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
79 | + if(isset($headers[$sepFirst+1])) { |
|
80 | + $form->addHeader($headers[$sepFirst+1],4,true); |
|
81 | + } |
|
81 | 82 | if(isset($wrappers[$sepFirst+1])){ |
82 | 83 | $wrapper=$wrappers[$sepFirst+1]; |
83 | 84 | } |
84 | 85 | if(\sizeof($values)===1){ |
85 | 86 | $added=$form->addField($values[0]); |
86 | - }elseif(\sizeof($values)>1){ |
|
87 | + } elseif(\sizeof($values)>1){ |
|
87 | 88 | $added=$form->addFields($values); |
88 | - }else |
|
89 | - return; |
|
89 | + } else { |
|
90 | + return; |
|
91 | + } |
|
90 | 92 | if(isset($wrapper)){ |
91 | 93 | $added->wrap($wrapper[0],$wrapper[1]); |
92 | 94 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * |
12 | 12 | */ |
13 | 13 | class HtmlTableContent extends HtmlSemCollection { |
14 | - protected $_tdTagNames=[ "thead" => "th","tbody" => "td","tfoot" => "th" ]; |
|
14 | + protected $_tdTagNames=["thead" => "th", "tbody" => "td", "tfoot" => "th"]; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function setRowCount($rowCount, $colCount) { |
36 | 36 | $count=$this->count(); |
37 | - for($i=$count; $i < $rowCount; $i++) { |
|
37 | + for ($i=$count; $i<$rowCount; $i++) { |
|
38 | 38 | $this->addItem($colCount); |
39 | 39 | } |
40 | 40 | return $this; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $tr=new HtmlTR("", $value); |
57 | 57 | $tr->setContainer($this, $count); |
58 | 58 | $tr->setTdTagName($this->_tdTagNames[$this->tagName]); |
59 | - if (isset($value) === true) { |
|
59 | + if (isset($value)===true) { |
|
60 | 60 | $tr->setColCount($value); |
61 | 61 | } |
62 | 62 | return $tr; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function setCellValue($row, $col, $value="") { |
116 | 116 | $cell=$this->getCell($row, $col); |
117 | - if (isset($cell) === true) { |
|
117 | + if (isset($cell)===true) { |
|
118 | 118 | $cell->setValue($value); |
119 | 119 | } |
120 | 120 | return $this; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param mixed $values |
126 | 126 | */ |
127 | 127 | public function setValues($values=array()) { |
128 | - return $this->_addOrSetValues($values, function($row,$_values){$row->setValues($_values);}); |
|
128 | + return $this->_addOrSetValues($values, function($row, $_values) {$row->setValues($_values); }); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param mixed $values |
134 | 134 | */ |
135 | 135 | public function addValues($values=array()) { |
136 | - return $this->_addOrSetValues($values, function($row,$_values){$row->addValues($_values);}); |
|
136 | + return $this->_addOrSetValues($values, function($row, $_values) {$row->addValues($_values); }); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -141,21 +141,21 @@ discard block |
||
141 | 141 | * @param mixed $values |
142 | 142 | * @param callable $callback |
143 | 143 | */ |
144 | - protected function _addOrSetValues($values,$callback) { |
|
144 | + protected function _addOrSetValues($values, $callback) { |
|
145 | 145 | $count=$this->count(); |
146 | 146 | $isArray=true; |
147 | 147 | if (!\is_array($values)) { |
148 | 148 | $values=\array_fill(0, $count, $values); |
149 | 149 | $isArray=false; |
150 | 150 | } |
151 | - if (JArray::dimension($values) == 1 && $isArray) |
|
152 | - $values=[ $values ]; |
|
151 | + if (JArray::dimension($values)==1 && $isArray) |
|
152 | + $values=[$values]; |
|
153 | 153 | |
154 | 154 | $count=\min(\sizeof($values), $count); |
155 | 155 | |
156 | - for($i=0; $i < $count; $i++) { |
|
156 | + for ($i=0; $i<$count; $i++) { |
|
157 | 157 | $row=$this->content[$i]; |
158 | - $callback($row,$values[$i]); |
|
158 | + $callback($row, $values[$i]); |
|
159 | 159 | } |
160 | 160 | return $this; |
161 | 161 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $values=\array_fill(0, $count, $values); |
167 | 167 | } |
168 | 168 | $count=\min(\sizeof($values), $count); |
169 | - for($i=0; $i < $count; $i++) { |
|
169 | + for ($i=0; $i<$count; $i++) { |
|
170 | 170 | $this->getCell($i, $colIndex)->setValue($values[$i]); |
171 | 171 | } |
172 | 172 | return $this; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | public function addColVariations($colIndex, $variations=array()) { |
176 | 176 | $count=$this->count(); |
177 | - for($i=0; $i < $count; $i++) { |
|
177 | + for ($i=0; $i<$count; $i++) { |
|
178 | 178 | $this->getCell($i, $colIndex)->addVariations($variations); |
179 | 179 | } |
180 | 180 | return $this; |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | |
192 | 192 | private function colAlign($colIndex, $function) { |
193 | 193 | $count=$this->count(); |
194 | - for($i=0; $i < $count; $i++) { |
|
194 | + for ($i=0; $i<$count; $i++) { |
|
195 | 195 | $index=$this->content[$i]->getColPosition($colIndex); |
196 | - if ($index !== NULL) |
|
196 | + if ($index!==NULL) |
|
197 | 197 | $this->getCell($i, $index)->$function(); |
198 | 198 | } |
199 | 199 | return $this; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function getColCount() { |
227 | 227 | $result=0; |
228 | - if ($this->count() > 0) |
|
228 | + if ($this->count()>0) |
|
229 | 229 | $result=$this->getItem(0)->count(); |
230 | 230 | return $result; |
231 | 231 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | public function delete($rowIndex, $colIndex=NULL) { |
240 | 240 | if (isset($colIndex)) { |
241 | 241 | $row=$this->getItem($rowIndex); |
242 | - if (isset($row) === true) { |
|
242 | + if (isset($row)===true) { |
|
243 | 243 | $row->delete($colIndex); |
244 | 244 | } |
245 | 245 | } else { |
@@ -272,17 +272,17 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function conditionalCellFormat($callback, $format) { |
274 | 274 | $rows=$this->content; |
275 | - foreach ( $rows as $row ) { |
|
275 | + foreach ($rows as $row) { |
|
276 | 276 | $row->conditionalCellFormat($callback, $format); |
277 | 277 | } |
278 | 278 | return $this; |
279 | 279 | } |
280 | 280 | |
281 | - public function conditionalColFormat($colIndex,$callback,$format){ |
|
281 | + public function conditionalColFormat($colIndex, $callback, $format) { |
|
282 | 282 | $rows=$this->content; |
283 | - foreach ( $rows as $row ) { |
|
283 | + foreach ($rows as $row) { |
|
284 | 284 | $cell=$row->getItem($colIndex); |
285 | - $cell->conditionnalCellFormat($callback,$format); |
|
285 | + $cell->conditionnalCellFormat($callback, $format); |
|
286 | 286 | } |
287 | 287 | return $this; |
288 | 288 | } |
@@ -294,17 +294,17 @@ discard block |
||
294 | 294 | */ |
295 | 295 | public function conditionalRowFormat($callback, $format) { |
296 | 296 | $rows=$this->content; |
297 | - foreach ( $rows as $row ) { |
|
297 | + foreach ($rows as $row) { |
|
298 | 298 | $row->conditionalRowFormat($callback, $format); |
299 | 299 | } |
300 | 300 | return $this; |
301 | 301 | } |
302 | 302 | |
303 | - public function hideColumn($colIndex){ |
|
303 | + public function hideColumn($colIndex) { |
|
304 | 304 | $rows=$this->content; |
305 | - foreach ( $rows as $row ) { |
|
305 | + foreach ($rows as $row) { |
|
306 | 306 | $cell=$row->getItem($colIndex); |
307 | - $cell->addToProperty("style","display:none;"); |
|
307 | + $cell->addToProperty("style", "display:none;"); |
|
308 | 308 | } |
309 | 309 | return $this; |
310 | 310 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function applyCells($callback) { |
317 | 317 | $rows=$this->content; |
318 | - foreach ( $rows as $row ) { |
|
318 | + foreach ($rows as $row) { |
|
319 | 319 | $row->applyCells($callback); |
320 | 320 | } |
321 | 321 | return $this; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | */ |
328 | 328 | public function applyRows($callback) { |
329 | 329 | $rows=$this->content; |
330 | - foreach ( $rows as $row ) { |
|
330 | + foreach ($rows as $row) { |
|
331 | 331 | $row->apply($callback); |
332 | 332 | } |
333 | 333 | return $this; |
@@ -22,8 +22,9 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function __construct($identifier, $tagName="tbody", $rowCount=NULL, $colCount=NULL) { |
24 | 24 | parent::__construct($identifier, $tagName, ""); |
25 | - if (isset($rowCount) && isset($colCount)) |
|
26 | - $this->setRowCount($rowCount, $colCount); |
|
25 | + if (isset($rowCount) && isset($colCount)) { |
|
26 | + $this->setRowCount($rowCount, $colCount); |
|
27 | + } |
|
27 | 28 | } |
28 | 29 | |
29 | 30 | /** |
@@ -148,8 +149,9 @@ discard block |
||
148 | 149 | $values=\array_fill(0, $count, $values); |
149 | 150 | $isArray=false; |
150 | 151 | } |
151 | - if (JArray::dimension($values) == 1 && $isArray) |
|
152 | - $values=[ $values ]; |
|
152 | + if (JArray::dimension($values) == 1 && $isArray) { |
|
153 | + $values=[ $values ]; |
|
154 | + } |
|
153 | 155 | |
154 | 156 | $count=\min(\sizeof($values), $count); |
155 | 157 | |
@@ -193,8 +195,9 @@ discard block |
||
193 | 195 | $count=$this->count(); |
194 | 196 | for($i=0; $i < $count; $i++) { |
195 | 197 | $index=$this->content[$i]->getColPosition($colIndex); |
196 | - if ($index !== NULL) |
|
197 | - $this->getCell($i, $index)->$function(); |
|
198 | + if ($index !== NULL) { |
|
199 | + $this->getCell($i, $index)->$function(); |
|
200 | + } |
|
198 | 201 | } |
199 | 202 | return $this; |
200 | 203 | } |
@@ -225,8 +228,9 @@ discard block |
||
225 | 228 | */ |
226 | 229 | public function getColCount() { |
227 | 230 | $result=0; |
228 | - if ($this->count() > 0) |
|
229 | - $result=$this->getItem(0)->count(); |
|
231 | + if ($this->count() > 0) { |
|
232 | + $result=$this->getItem(0)->count(); |
|
233 | + } |
|
230 | 234 | return $result; |
231 | 235 | } |
232 | 236 |
@@ -15,117 +15,117 @@ discard block |
||
15 | 15 | protected $_paramParts=array(); |
16 | 16 | |
17 | 17 | public function __construct($identifier, $header="", $content="", $actions=null) { |
18 | - parent::__construct($identifier, "div","ui modal"); |
|
19 | - if(isset($header)){ |
|
18 | + parent::__construct($identifier, "div", "ui modal"); |
|
19 | + if (isset($header)) { |
|
20 | 20 | $this->setHeader($header); |
21 | 21 | } |
22 | - if(isset($content)){ |
|
22 | + if (isset($content)) { |
|
23 | 23 | $this->setContent($content); |
24 | 24 | } |
25 | - if(isset($actions)){ |
|
25 | + if (isset($actions)) { |
|
26 | 26 | $this->setActions($actions); |
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function setHeader($value) { |
31 | - $this->content["header"]=new HtmlSemDoubleElement("header-" . $this->identifier, "a", "header", $value); |
|
31 | + $this->content["header"]=new HtmlSemDoubleElement("header-".$this->identifier, "a", "header", $value); |
|
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function setContent($value) { |
36 | - $this->content["content"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", $value); |
|
36 | + $this->content["content"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", $value); |
|
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | 40 | public function setActions($actions) { |
41 | - $this->content["actions"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "actions"); |
|
42 | - if(\is_array($actions)){ |
|
43 | - foreach ($actions as $action){ |
|
41 | + $this->content["actions"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "actions"); |
|
42 | + if (\is_array($actions)) { |
|
43 | + foreach ($actions as $action) { |
|
44 | 44 | $this->addAction($action); |
45 | 45 | } |
46 | 46 | } |
47 | - else{ |
|
47 | + else { |
|
48 | 48 | $this->addAction($actions); |
49 | 49 | } |
50 | 50 | return $this; |
51 | 51 | } |
52 | 52 | |
53 | - public function addAction($action){ |
|
54 | - if(!$action instanceof BaseHtml){ |
|
53 | + public function addAction($action) { |
|
54 | + if (!$action instanceof BaseHtml) { |
|
55 | 55 | $class=""; |
56 | - if(\array_search($action, ["Okay","Yes"])!==false){ |
|
56 | + if (\array_search($action, ["Okay", "Yes"])!==false) { |
|
57 | 57 | $class="approve"; |
58 | 58 | } |
59 | - if(\array_search($action, ["Close","Cancel","No"])!==false){ |
|
59 | + if (\array_search($action, ["Close", "Cancel", "No"])!==false) { |
|
60 | 60 | $class="cancel"; |
61 | 61 | } |
62 | - $action=new HtmlButton("action-".$this->identifier,$action); |
|
63 | - if($class!=="") |
|
62 | + $action=new HtmlButton("action-".$this->identifier, $action); |
|
63 | + if ($class!=="") |
|
64 | 64 | $action->addToProperty("class", $class); |
65 | 65 | } |
66 | 66 | return $this->addElementInPart($action, "actions"); |
67 | 67 | } |
68 | 68 | |
69 | - public function addContent($content,$before=false){ |
|
70 | - $this->content["content"]->addContent($content,$before); |
|
69 | + public function addContent($content, $before=false) { |
|
70 | + $this->content["content"]->addContent($content, $before); |
|
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
74 | - public function addImageContent($image,$description=NULL){ |
|
74 | + public function addImageContent($image, $description=NULL) { |
|
75 | 75 | $content=$this->content["content"]; |
76 | - if(isset($description)){ |
|
77 | - $description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description); |
|
78 | - $content->addContent($description,true); |
|
76 | + if (isset($description)) { |
|
77 | + $description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description); |
|
78 | + $content->addContent($description, true); |
|
79 | 79 | } |
80 | - if($image!==""){ |
|
81 | - $img=new HtmlImage("image-".$this->identifier,$image,"","medium"); |
|
82 | - $content->addContent($img,true); |
|
83 | - $content->addToProperty("class","image"); |
|
80 | + if ($image!=="") { |
|
81 | + $img=new HtmlImage("image-".$this->identifier, $image, "", "medium"); |
|
82 | + $content->addContent($img, true); |
|
83 | + $content->addToProperty("class", "image"); |
|
84 | 84 | } |
85 | 85 | return $this; |
86 | 86 | } |
87 | 87 | |
88 | - public function addIconContent($icon,$description=NULL){ |
|
88 | + public function addIconContent($icon, $description=NULL) { |
|
89 | 89 | $content=$this->content["content"]; |
90 | - if(isset($description)){ |
|
91 | - $description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description); |
|
92 | - $content->addContent($description,true); |
|
90 | + if (isset($description)) { |
|
91 | + $description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description); |
|
92 | + $content->addContent($description, true); |
|
93 | 93 | } |
94 | - if($icon!==""){ |
|
95 | - $img=new HtmlIcon("image-".$this->identifier,$icon); |
|
96 | - $content->addContent($img,true); |
|
97 | - $content->addToProperty("class","image"); |
|
94 | + if ($icon!=="") { |
|
95 | + $img=new HtmlIcon("image-".$this->identifier, $icon); |
|
96 | + $content->addContent($img, true); |
|
97 | + $content->addToProperty("class", "image"); |
|
98 | 98 | } |
99 | 99 | return $this; |
100 | 100 | } |
101 | 101 | |
102 | - private function addContentInPart($content,$uiClass,$part) { |
|
103 | - return $this->addElementInPart(new HtmlSemDoubleElement($part."-" . $this->identifier, "div", $uiClass, $content), $part); |
|
102 | + private function addContentInPart($content, $uiClass, $part) { |
|
103 | + return $this->addElementInPart(new HtmlSemDoubleElement($part."-".$this->identifier, "div", $uiClass, $content), $part); |
|
104 | 104 | } |
105 | 105 | |
106 | - private function addElementInPart($element,$part) { |
|
106 | + private function addElementInPart($element, $part) { |
|
107 | 107 | $this->content[$part]->addContent($element); |
108 | 108 | return $element; |
109 | 109 | } |
110 | 110 | |
111 | - public function showDimmer($value){ |
|
112 | - $value=$value?"show":"hide"; |
|
111 | + public function showDimmer($value) { |
|
112 | + $value=$value ? "show" : "hide"; |
|
113 | 113 | $this->_paramParts[]=["'".$value." dimmer'"]; |
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 | |
117 | - public function setInverted($recursive=true){ |
|
117 | + public function setInverted($recursive=true) { |
|
118 | 118 | $this->_params["inverted"]=true; |
119 | 119 | return $this; |
120 | 120 | } |
121 | 121 | |
122 | - public function setBasic(){ |
|
122 | + public function setBasic() { |
|
123 | 123 | return $this->addToProperty("class", "basic"); |
124 | 124 | } |
125 | 125 | |
126 | 126 | |
127 | - public function setTransition($value){ |
|
128 | - $this->_paramParts[]=["'setting'","'transition'","'".$value."'"]; |
|
127 | + public function setTransition($value) { |
|
128 | + $this->_paramParts[]=["'setting'", "'transition'", "'".$value."'"]; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | * @param string $viewName |
136 | 136 | * @param $params The parameters to pass to the view |
137 | 137 | */ |
138 | - public function renderView(JsUtils $js,$initialController,$viewName, $params=array()) { |
|
139 | - return $this->setContent($js->renderContent($initialController, $viewName,$params)); |
|
138 | + public function renderView(JsUtils $js, $initialController, $viewName, $params=array()) { |
|
139 | + return $this->setContent($js->renderContent($initialController, $viewName, $params)); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * @param string $actionName the action name |
148 | 148 | * @param array $params |
149 | 149 | */ |
150 | - public function forward(JsUtils $js,$initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
151 | - return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName,$params)); |
|
150 | + public function forward(JsUtils $js, $initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
151 | + return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName, $params)); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile() |
159 | 159 | */ |
160 | 160 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
161 | - $this->content=JArray::sortAssociative($this->content, ["header","content","actions" ]); |
|
161 | + $this->content=JArray::sortAssociative($this->content, ["header", "content", "actions"]); |
|
162 | 162 | return parent::compile($js, $view); |
163 | 163 | } |
164 | 164 | /* |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | * @see BaseHtml::run() |
167 | 167 | */ |
168 | 168 | public function run(JsUtils $js) { |
169 | - if(isset($this->_bsComponent)===false) |
|
170 | - $this->_bsComponent=$js->semantic()->modal("#".$this->identifier,$this->_params,$this->_paramParts); |
|
169 | + if (isset($this->_bsComponent)===false) |
|
170 | + $this->_bsComponent=$js->semantic()->modal("#".$this->identifier, $this->_params, $this->_paramParts); |
|
171 | 171 | $this->addEventsOnRun($js); |
172 | 172 | return $this->_bsComponent; |
173 | 173 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @return \Ajax\semantic\html\elements\HtmlDivider |
23 | 23 | */ |
24 | 24 | public function setVertical() { |
25 | - return $this->addToPropertyCtrl("class", "vertical", array ("vertical","horizontal" )); |
|
25 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical", "horizontal")); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return \Ajax\semantic\html\elements\HtmlDivider |
31 | 31 | */ |
32 | 32 | public function setHorizontal() { |
33 | - return $this->addToPropertyCtrl("class", "horizontal", array ("vertical","horizontal" )); |
|
33 | + return $this->addToPropertyCtrl("class", "horizontal", array("vertical", "horizontal")); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | return $this->addToProperty("class", "header"); |
58 | 58 | } |
59 | 59 | |
60 | - public function setIgnored(){ |
|
60 | + public function setIgnored() { |
|
61 | 61 | return $this->addToProperty("class", "ignored"); |
62 | 62 | } |
63 | 63 | } |
64 | 64 | \ No newline at end of file |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | * @author jc |
8 | 8 | * @property HtmlTable $_self |
9 | 9 | */ |
10 | -trait TableTrait{ |
|
10 | +trait TableTrait { |
|
11 | 11 | |
12 | 12 | abstract public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false); |
13 | 13 | abstract public function getOn($event, $url, $responseElement="", $parameters=array()); |
14 | 14 | |
15 | - protected function addToPropertyTable($property,$value){ |
|
15 | + protected function addToPropertyTable($property, $value) { |
|
16 | 16 | return $this->_self->addToProperty($property, $value); |
17 | 17 | } |
18 | 18 | |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | public function setBasic($very=false) { |
24 | 24 | $table=$this->_self; |
25 | 25 | if ($very) |
26 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
27 | - return $table->addToPropertyCtrl("class", "basic", array ("basic" )); |
|
26 | + $table->addToPropertyCtrl("class", "very", array("very")); |
|
27 | + return $table->addToPropertyCtrl("class", "basic", array("basic")); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function setCompact($very=false) { |
31 | 31 | $table=$this->_self; |
32 | 32 | if ($very) |
33 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
34 | - return $table->addToPropertyCtrl("class", "compact", array ("compact" )); |
|
33 | + $table->addToPropertyCtrl("class", "very", array("very")); |
|
34 | + return $table->addToPropertyCtrl("class", "compact", array("compact")); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function setCollapsing() { |
@@ -70,16 +70,16 @@ discard block |
||
70 | 70 | return $this->addToPropertyTable("class", "striped"); |
71 | 71 | } |
72 | 72 | |
73 | - public function onRowClick($jsCode, $stopPropagation=false, $preventDefault=false){ |
|
74 | - $this->onRowClick($jsCode,$stopPropagation,$preventDefault); |
|
73 | + public function onRowClick($jsCode, $stopPropagation=false, $preventDefault=false) { |
|
74 | + $this->onRowClick($jsCode, $stopPropagation, $preventDefault); |
|
75 | 75 | } |
76 | 76 | |
77 | - public function onRow($event,$jsCode, $stopPropagation=false, $preventDefault=false){ |
|
78 | - $this->_self->addEvent($event."{{tr}}",$jsCode,$stopPropagation,$preventDefault); |
|
77 | + public function onRow($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
|
78 | + $this->_self->addEvent($event."{{tr}}", $jsCode, $stopPropagation, $preventDefault); |
|
79 | 79 | } |
80 | 80 | |
81 | - public function getOnRow($event, $url, $responseElement="", $parameters=array()){ |
|
82 | - $parameters=\array_merge($parameters,["stopPropagation"=>false,"preventDefault"=>false]); |
|
83 | - return $this->_self->getOn($event."{{tbody tr}}", $url,$responseElement,$parameters); |
|
81 | + public function getOnRow($event, $url, $responseElement="", $parameters=array()) { |
|
82 | + $parameters=\array_merge($parameters, ["stopPropagation"=>false, "preventDefault"=>false]); |
|
83 | + return $this->_self->getOn($event."{{tbody tr}}", $url, $responseElement, $parameters); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | \ No newline at end of file |
@@ -22,15 +22,17 @@ |
||
22 | 22 | |
23 | 23 | public function setBasic($very=false) { |
24 | 24 | $table=$this->_self; |
25 | - if ($very) |
|
26 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
25 | + if ($very) { |
|
26 | + $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
27 | + } |
|
27 | 28 | return $table->addToPropertyCtrl("class", "basic", array ("basic" )); |
28 | 29 | } |
29 | 30 | |
30 | 31 | public function setCompact($very=false) { |
31 | 32 | $table=$this->_self; |
32 | - if ($very) |
|
33 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
33 | + if ($very) { |
|
34 | + $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
35 | + } |
|
34 | 36 | return $table->addToPropertyCtrl("class", "compact", array ("compact" )); |
35 | 37 | } |
36 | 38 |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | |
28 | 28 | public function __construct($identifier, $rowCount, $colCount) { |
29 | 29 | parent::__construct($identifier, "table", "ui table"); |
30 | - $this->content=array (); |
|
30 | + $this->content=array(); |
|
31 | 31 | $this->setRowCount($rowCount, $colCount); |
32 | - $this->_variations=[ Variation::CELLED,Variation::PADDED,Variation::COMPACT ]; |
|
33 | - $this->_compileParts=["thead","tbody","tfoot"]; |
|
32 | + $this->_variations=[Variation::CELLED, Variation::PADDED, Variation::COMPACT]; |
|
33 | + $this->_compileParts=["thead", "tbody", "tfoot"]; |
|
34 | 34 | $this->_afterCompileEvents=[]; |
35 | 35 | } |
36 | 36 | |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | * @return HtmlTableContent |
41 | 41 | */ |
42 | 42 | public function getPart($key) { |
43 | - if (\array_key_exists($key, $this->content) === false) { |
|
43 | + if (\array_key_exists($key, $this->content)===false) { |
|
44 | 44 | $this->content[$key]=new HtmlTableContent("", $key); |
45 | - if ($key !== "tbody") { |
|
45 | + if ($key!=="tbody") { |
|
46 | 46 | $this->content[$key]->setRowCount(1, $this->_colCount); |
47 | 47 | } |
48 | 48 | } |
49 | 49 | return $this->content[$key]; |
50 | 50 | } |
51 | 51 | |
52 | - protected function _getFirstPart(){ |
|
53 | - if(isset($this->content["thead"])){ |
|
52 | + protected function _getFirstPart() { |
|
53 | + if (isset($this->content["thead"])) { |
|
54 | 54 | return $this->content["thead"]; |
55 | 55 | } |
56 | 56 | return $this->content["tbody"]; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return boolean |
96 | 96 | */ |
97 | 97 | public function hasPart($key) { |
98 | - return \array_key_exists($key, $this->content) === true; |
|
98 | + return \array_key_exists($key, $this->content)===true; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | private function colAlign($colIndex, $function) { |
232 | 232 | if (\is_array($colIndex)) { |
233 | - foreach ( $colIndex as $cIndex ) { |
|
233 | + foreach ($colIndex as $cIndex) { |
|
234 | 234 | $this->colAlign($cIndex, $function); |
235 | 235 | } |
236 | 236 | } else { |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @see HtmlSemDoubleElement::compile() |
292 | 292 | */ |
293 | 293 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
294 | - if(\sizeof($this->_compileParts)<3){ |
|
294 | + if (\sizeof($this->_compileParts)<3) { |
|
295 | 295 | $this->_template="%content%"; |
296 | 296 | $this->refresh(); |
297 | 297 | } |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | |
302 | 302 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
303 | 303 | if ($this->propertyContains("class", "sortable")) { |
304 | - $this->addEvent("execute", "$('#" . $this->identifier . "').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
304 | + $this->addEvent("execute", "$('#".$this->identifier."').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
305 | 305 | } |
306 | - if(isset($this->_activeRowSelector)){ |
|
306 | + if (isset($this->_activeRowSelector)) { |
|
307 | 307 | $this->_activeRowSelector->compile(); |
308 | 308 | } |
309 | 309 | } |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | public function fromDatabaseObject($object, $function) { |
318 | 318 | $result=$function($object); |
319 | 319 | if (\is_array($result)) { |
320 | - $result= $this->addRow($function($object)); |
|
320 | + $result=$this->addRow($function($object)); |
|
321 | 321 | } else { |
322 | - $result= $this->getBody()->_addRow($result); |
|
322 | + $result=$this->getBody()->_addRow($result); |
|
323 | 323 | } |
324 | - if(isset($this->_afterCompileEvents["onNewRow"])){ |
|
325 | - if(\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
326 | - $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
324 | + if (isset($this->_afterCompileEvents["onNewRow"])) { |
|
325 | + if (\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
326 | + $this->_afterCompileEvents["onNewRow"]($result, $object); |
|
327 | 327 | } |
328 | 328 | return $result; |
329 | 329 | } |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | return $this; |
339 | 339 | } |
340 | 340 | |
341 | - public function refresh(){ |
|
341 | + public function refresh() { |
|
342 | 342 | $this->_footer=$this->getFooter(); |
343 | 343 | $this->addEvent("execute", '$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");'); |
344 | 344 | } |
345 | 345 | |
346 | - public function run(JsUtils $js){ |
|
347 | - $result= parent::run($js); |
|
348 | - if(isset($this->_footer)) |
|
346 | + public function run(JsUtils $js) { |
|
347 | + $result=parent::run($js); |
|
348 | + if (isset($this->_footer)) |
|
349 | 349 | $this->_footer->run($js); |
350 | 350 | return $result; |
351 | 351 | } |
@@ -368,38 +368,38 @@ discard block |
||
368 | 368 | * @param boolean $multiple |
369 | 369 | * @return HtmlTable |
370 | 370 | */ |
371 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
372 | - $this->_activeRowSelector=new ActiveRow($this,$class,$event,$multiple); |
|
371 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
372 | + $this->_activeRowSelector=new ActiveRow($this, $class, $event, $multiple); |
|
373 | 373 | return $this; |
374 | 374 | } |
375 | 375 | |
376 | - public function hideColumn($colIndex){ |
|
377 | - if(isset($this->content["thead"])){ |
|
376 | + public function hideColumn($colIndex) { |
|
377 | + if (isset($this->content["thead"])) { |
|
378 | 378 | $this->content["thead"]->hideColumn($colIndex); |
379 | 379 | } |
380 | 380 | $this->content["tbody"]->hideColumn($colIndex); |
381 | - if(isset($this->content["tfoot"])){ |
|
381 | + if (isset($this->content["tfoot"])) { |
|
382 | 382 | $this->content["tfoot"]->hideColumn($colIndex); |
383 | 383 | } |
384 | 384 | return $this; |
385 | 385 | } |
386 | 386 | |
387 | - public function setColWidth($colIndex,$width){ |
|
387 | + public function setColWidth($colIndex, $width) { |
|
388 | 388 | $part=$this->_getFirstPart(); |
389 | - if($part!==null && $part->count()>0) |
|
389 | + if ($part!==null && $part->count()>0) |
|
390 | 390 | $part->getCell(0, $colIndex)->setWidth($width); |
391 | 391 | return $this; |
392 | 392 | } |
393 | 393 | |
394 | - public function setColWidths($widths){ |
|
394 | + public function setColWidths($widths) { |
|
395 | 395 | $part=$this->_getFirstPart(); |
396 | - if($part!==null && $part->count()>0){ |
|
396 | + if ($part!==null && $part->count()>0) { |
|
397 | 397 | $count=$part->getColCount(); |
398 | - if(!\is_array($widths)){ |
|
398 | + if (!\is_array($widths)) { |
|
399 | 399 | $widths=\array_fill(0, $count, $widths); |
400 | 400 | } |
401 | - $max=\min(\sizeof($widths),$count); |
|
402 | - for($i=0;$i<$max;$i++){ |
|
401 | + $max=\min(\sizeof($widths), $count); |
|
402 | + for ($i=0; $i<$max; $i++) { |
|
403 | 403 | $part->getCell(0, $i)->setWidth($widths[$i]); |
404 | 404 | } |
405 | 405 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * @property HtmlSemDoubleElement $_self |
16 | 16 | */ |
17 | 17 | trait BaseTrait { |
18 | - protected $_variations=[ ]; |
|
19 | - protected $_states=[ ]; |
|
18 | + protected $_variations=[]; |
|
19 | + protected $_states=[]; |
|
20 | 20 | protected $_baseClass; |
21 | 21 | |
22 | 22 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | abstract public function setProperty($name, $value); |
31 | 31 | |
32 | - abstract public function addContent($content,$before=false); |
|
32 | + abstract public function addContent($content, $before=false); |
|
33 | 33 | |
34 | 34 | abstract public function onCreate($jsCode); |
35 | 35 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $this->_self->setProperty("class", $this->_self->_baseClass); |
51 | 51 | if (\is_string($variations)) |
52 | 52 | $variations=\explode(" ", $variations); |
53 | - foreach ( $variations as $variation ) { |
|
53 | + foreach ($variations as $variation) { |
|
54 | 54 | $this->_self->addVariation($variation); |
55 | 55 | } |
56 | 56 | return $this; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | public function addVariations($variations=array()) { |
65 | 65 | if (\is_string($variations)) |
66 | 66 | $variations=\explode(" ", $variations); |
67 | - foreach ( $variations as $variation ) { |
|
67 | + foreach ($variations as $variation) { |
|
68 | 68 | $this->_self->addVariation($variation); |
69 | 69 | } |
70 | 70 | return $this; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function addStates($states=array()) { |
74 | 74 | if (\is_string($states)) |
75 | 75 | $states=\explode(" ", $states); |
76 | - foreach ( $states as $state ) { |
|
76 | + foreach ($states as $state) { |
|
77 | 77 | $this->_self->addState($state); |
78 | 78 | } |
79 | 79 | return $this; |
@@ -83,17 +83,17 @@ discard block |
||
83 | 83 | $this->_self->setProperty("class", $this->_self->_baseClass); |
84 | 84 | if (\is_string($states)) |
85 | 85 | $states=\explode(" ", $states); |
86 | - foreach ( $states as $state ) { |
|
86 | + foreach ($states as $state) { |
|
87 | 87 | $this->_self->addState($state); |
88 | 88 | } |
89 | 89 | return $this; |
90 | 90 | } |
91 | 91 | |
92 | 92 | public function addIcon($icon, $before=true) { |
93 | - return $this->_self->addContent(new HtmlIcon("icon-" . $this->_self->identifier, $icon), $before); |
|
93 | + return $this->_self->addContent(new HtmlIcon("icon-".$this->_self->identifier, $icon), $before); |
|
94 | 94 | } |
95 | 95 | |
96 | - public function addSticky($context="body"){ |
|
96 | + public function addSticky($context="body") { |
|
97 | 97 | $this->_self->onCreate("$('#".$this->_self->identifier."').sticky({ context: '".$context."'});"); |
98 | 98 | return $this; |
99 | 99 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @return HtmlSemDoubleElement |
115 | 115 | */ |
116 | 116 | public function setDisabled($disable=true) { |
117 | - if($disable) |
|
117 | + if ($disable) |
|
118 | 118 | $this->_self->addToProperty("class", "disabled"); |
119 | 119 | return $this; |
120 | 120 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return HtmlSemDoubleElement |
142 | 142 | */ |
143 | - public function asHeader(){ |
|
143 | + public function asHeader() { |
|
144 | 144 | return $this->_self->addToProperty("class", "header"); |
145 | 145 | } |
146 | 146 | |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | * show it is currently the active user selection |
149 | 149 | * @return HtmlSemDoubleElement |
150 | 150 | */ |
151 | - public function setActive($value=true){ |
|
152 | - if($value) |
|
151 | + public function setActive($value=true) { |
|
152 | + if ($value) |
|
153 | 153 | $this->_self->addToProperty("class", "active"); |
154 | 154 | return $this; |
155 | 155 | } |
156 | 156 | |
157 | - public function setAttached($value=true){ |
|
158 | - if($value) |
|
159 | - $this->_self->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
157 | + public function setAttached($value=true) { |
|
158 | + if ($value) |
|
159 | + $this->_self->addToPropertyCtrl("class", "attached", array("attached")); |
|
160 | 160 | return $this; |
161 | 161 | } |
162 | 162 | |
@@ -164,13 +164,13 @@ discard block |
||
164 | 164 | * can be formatted to appear on dark backgrounds |
165 | 165 | */ |
166 | 166 | public function setInverted($recursive=true) { |
167 | - if($recursive===true){ |
|
167 | + if ($recursive===true) { |
|
168 | 168 | $content=$this->_self->getContent(); |
169 | - if($content instanceof HtmlSemDoubleElement) |
|
169 | + if ($content instanceof HtmlSemDoubleElement) |
|
170 | 170 | $content->setInverted($recursive); |
171 | - elseif(\is_array($content) || $content instanceof \Traversable){ |
|
172 | - foreach ($content as $elm){ |
|
173 | - if($elm instanceof HtmlSemDoubleElement){ |
|
171 | + elseif (\is_array($content) || $content instanceof \Traversable) { |
|
172 | + foreach ($content as $elm) { |
|
173 | + if ($elm instanceof HtmlSemDoubleElement) { |
|
174 | 174 | $elm->setInverted($recursive); |
175 | 175 | } |
176 | 176 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | public function setFloated($direction="right") { |
187 | - return $this->_self->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
187 | + return $this->_self->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | public function floatRight() { |
@@ -199,14 +199,14 @@ discard block |
||
199 | 199 | return $this->_self->_baseClass; |
200 | 200 | } |
201 | 201 | |
202 | - protected function addBehavior(&$array,$key,$value,$before="",$after=""){ |
|
203 | - if(\is_string($value)){ |
|
204 | - if(isset($array[$key])){ |
|
202 | + protected function addBehavior(&$array, $key, $value, $before="", $after="") { |
|
203 | + if (\is_string($value)) { |
|
204 | + if (isset($array[$key])) { |
|
205 | 205 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
206 | 206 | $array[$key]=$before.$p.$value.$after; |
207 | - }else |
|
207 | + } else |
|
208 | 208 | $array[$key]=$before.$value.$after; |
209 | - }else{ |
|
209 | + } else { |
|
210 | 210 | $array[$key]=$value; |
211 | 211 | } |
212 | 212 | return $this; |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | |
49 | 49 | public function setVariations($variations) { |
50 | 50 | $this->_self->setProperty("class", $this->_self->_baseClass); |
51 | - if (\is_string($variations)) |
|
52 | - $variations=\explode(" ", $variations); |
|
51 | + if (\is_string($variations)) { |
|
52 | + $variations=\explode(" ", $variations); |
|
53 | + } |
|
53 | 54 | foreach ( $variations as $variation ) { |
54 | 55 | $this->_self->addVariation($variation); |
55 | 56 | } |
@@ -62,8 +63,9 @@ discard block |
||
62 | 63 | } |
63 | 64 | |
64 | 65 | public function addVariations($variations=array()) { |
65 | - if (\is_string($variations)) |
|
66 | - $variations=\explode(" ", $variations); |
|
66 | + if (\is_string($variations)) { |
|
67 | + $variations=\explode(" ", $variations); |
|
68 | + } |
|
67 | 69 | foreach ( $variations as $variation ) { |
68 | 70 | $this->_self->addVariation($variation); |
69 | 71 | } |
@@ -71,8 +73,9 @@ discard block |
||
71 | 73 | } |
72 | 74 | |
73 | 75 | public function addStates($states=array()) { |
74 | - if (\is_string($states)) |
|
75 | - $states=\explode(" ", $states); |
|
76 | + if (\is_string($states)) { |
|
77 | + $states=\explode(" ", $states); |
|
78 | + } |
|
76 | 79 | foreach ( $states as $state ) { |
77 | 80 | $this->_self->addState($state); |
78 | 81 | } |
@@ -81,8 +84,9 @@ discard block |
||
81 | 84 | |
82 | 85 | public function setStates($states) { |
83 | 86 | $this->_self->setProperty("class", $this->_self->_baseClass); |
84 | - if (\is_string($states)) |
|
85 | - $states=\explode(" ", $states); |
|
87 | + if (\is_string($states)) { |
|
88 | + $states=\explode(" ", $states); |
|
89 | + } |
|
86 | 90 | foreach ( $states as $state ) { |
87 | 91 | $this->_self->addState($state); |
88 | 92 | } |
@@ -114,8 +118,9 @@ discard block |
||
114 | 118 | * @return HtmlSemDoubleElement |
115 | 119 | */ |
116 | 120 | public function setDisabled($disable=true) { |
117 | - if($disable) |
|
118 | - $this->_self->addToProperty("class", "disabled"); |
|
121 | + if($disable) { |
|
122 | + $this->_self->addToProperty("class", "disabled"); |
|
123 | + } |
|
119 | 124 | return $this; |
120 | 125 | } |
121 | 126 | |
@@ -149,14 +154,16 @@ discard block |
||
149 | 154 | * @return HtmlSemDoubleElement |
150 | 155 | */ |
151 | 156 | public function setActive($value=true){ |
152 | - if($value) |
|
153 | - $this->_self->addToProperty("class", "active"); |
|
157 | + if($value) { |
|
158 | + $this->_self->addToProperty("class", "active"); |
|
159 | + } |
|
154 | 160 | return $this; |
155 | 161 | } |
156 | 162 | |
157 | 163 | public function setAttached($value=true){ |
158 | - if($value) |
|
159 | - $this->_self->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
164 | + if($value) { |
|
165 | + $this->_self->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
166 | + } |
|
160 | 167 | return $this; |
161 | 168 | } |
162 | 169 | |
@@ -166,9 +173,9 @@ discard block |
||
166 | 173 | public function setInverted($recursive=true) { |
167 | 174 | if($recursive===true){ |
168 | 175 | $content=$this->_self->getContent(); |
169 | - if($content instanceof HtmlSemDoubleElement) |
|
170 | - $content->setInverted($recursive); |
|
171 | - elseif(\is_array($content) || $content instanceof \Traversable){ |
|
176 | + if($content instanceof HtmlSemDoubleElement) { |
|
177 | + $content->setInverted($recursive); |
|
178 | + } elseif(\is_array($content) || $content instanceof \Traversable){ |
|
172 | 179 | foreach ($content as $elm){ |
173 | 180 | if($elm instanceof HtmlSemDoubleElement){ |
174 | 181 | $elm->setInverted($recursive); |
@@ -204,9 +211,10 @@ discard block |
||
204 | 211 | if(isset($array[$key])){ |
205 | 212 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
206 | 213 | $array[$key]=$before.$p.$value.$after; |
207 | - }else |
|
208 | - $array[$key]=$before.$value.$after; |
|
209 | - }else{ |
|
214 | + } else { |
|
215 | + $array[$key]=$before.$value.$after; |
|
216 | + } |
|
217 | + } else{ |
|
210 | 218 | $array[$key]=$value; |
211 | 219 | } |
212 | 220 | return $this; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | */ |
26 | 26 | class DataTable extends Widget { |
27 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait; |
|
27 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait; |
|
28 | 28 | protected $_searchField; |
29 | 29 | protected $_urls; |
30 | 30 | protected $_pagination; |
@@ -42,35 +42,35 @@ discard block |
||
42 | 42 | protected $_colWidths; |
43 | 43 | |
44 | 44 | |
45 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
46 | - parent::__construct($identifier, $model,$modelInstance); |
|
47 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
45 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
46 | + parent::__construct($identifier, $model, $modelInstance); |
|
47 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
48 | 48 | $this->_urls=[]; |
49 | - $this->_emptyMessage=new HtmlMessage("","nothing to display"); |
|
49 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
50 | 50 | $this->_emptyMessage->setIcon("info circle"); |
51 | 51 | } |
52 | 52 | |
53 | - public function run(JsUtils $js){ |
|
54 | - if($this->_hasCheckboxes && isset($js)){ |
|
53 | + public function run(JsUtils $js) { |
|
54 | + if ($this->_hasCheckboxes && isset($js)) { |
|
55 | 55 | $this->_runCheckboxes($js); |
56 | 56 | } |
57 | - if($this->_visibleHover){ |
|
58 | - $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
59 | - $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
57 | + if ($this->_visibleHover) { |
|
58 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
59 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
60 | 60 | } |
61 | - if(\is_array($this->_deleteBehavior)) |
|
62 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
63 | - if(\is_array($this->_editBehavior)) |
|
64 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
61 | + if (\is_array($this->_deleteBehavior)) |
|
62 | + $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
63 | + if (\is_array($this->_editBehavior)) |
|
64 | + $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
65 | 65 | return parent::run($js); |
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - protected function _generateBehavior($op,$params,JsUtils $js){ |
|
71 | - if(isset($this->_urls[$op])){ |
|
72 | - $params=\array_merge($params,["attr"=>"data-ajax"]); |
|
73 | - $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector(),$params); |
|
70 | + protected function _generateBehavior($op, $params, JsUtils $js) { |
|
71 | + if (isset($this->_urls[$op])) { |
|
72 | + $params=\array_merge($params, ["attr"=>"data-ajax"]); |
|
73 | + $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector(), $params); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -83,154 +83,154 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | |
86 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
87 | - if(!$this->_generated){ |
|
86 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
87 | + if (!$this->_generated) { |
|
88 | 88 | $this->_instanceViewer->setInstance($this->_model); |
89 | 89 | $captions=$this->_instanceViewer->getCaptions(); |
90 | 90 | $table=$this->content["table"]; |
91 | - if($this->_hasCheckboxes){ |
|
91 | + if ($this->_hasCheckboxes) { |
|
92 | 92 | $this->_generateMainCheckbox($captions); |
93 | 93 | } |
94 | 94 | $table->setRowCount(0, \sizeof($captions)); |
95 | - $this->_generateHeader($table,$captions); |
|
95 | + $this->_generateHeader($table, $captions); |
|
96 | 96 | |
97 | - if(isset($this->_compileParts)) |
|
97 | + if (isset($this->_compileParts)) |
|
98 | 98 | $table->setCompileParts($this->_compileParts); |
99 | 99 | |
100 | - if(isset($this->_searchField) && isset($js)){ |
|
101 | - if(isset($this->_urls["refresh"])) |
|
102 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
100 | + if (isset($this->_searchField) && isset($js)) { |
|
101 | + if (isset($this->_urls["refresh"])) |
|
102 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | $this->_generateContent($table); |
106 | 106 | |
107 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
107 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
108 | 108 | $table->getHeader()->getCell(0, 0)->addClass("no-sort"); |
109 | 109 | } |
110 | 110 | |
111 | - if(isset($this->_toolbar)){ |
|
111 | + if (isset($this->_toolbar)) { |
|
112 | 112 | $this->_setToolbarPosition($table, $captions); |
113 | 113 | } |
114 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
115 | - $this->_generatePagination($table,$js); |
|
114 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
115 | + $this->_generatePagination($table, $js); |
|
116 | 116 | } |
117 | 117 | |
118 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
118 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
119 | 119 | $this->_compileForm(); |
120 | 120 | $this->_applyStyleAttributes($table); |
121 | 121 | $this->_generated=true; |
122 | 122 | } |
123 | - return parent::compile($js,$view); |
|
123 | + return parent::compile($js, $view); |
|
124 | 124 | } |
125 | 125 | |
126 | - protected function _applyStyleAttributes($table){ |
|
127 | - if(isset($this->_hiddenColumns)) |
|
126 | + protected function _applyStyleAttributes($table) { |
|
127 | + if (isset($this->_hiddenColumns)) |
|
128 | 128 | $this->_hideColumns(); |
129 | - if(isset($this->_colWidths)){ |
|
130 | - foreach ($this->_colWidths as $colIndex=>$width){ |
|
131 | - $table->setColWidth($colIndex,$width); |
|
129 | + if (isset($this->_colWidths)) { |
|
130 | + foreach ($this->_colWidths as $colIndex=>$width) { |
|
131 | + $table->setColWidth($colIndex, $width); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | - protected function _hideColumns(){ |
|
137 | - foreach ($this->_hiddenColumns as $colIndex){ |
|
136 | + protected function _hideColumns() { |
|
137 | + foreach ($this->_hiddenColumns as $colIndex) { |
|
138 | 138 | $this->_self->hideColumn($colIndex); |
139 | 139 | } |
140 | 140 | return $this; |
141 | 141 | } |
142 | 142 | |
143 | - protected function _generateHeader(HtmlTable $table,$captions){ |
|
143 | + protected function _generateHeader(HtmlTable $table, $captions) { |
|
144 | 144 | $table->setHeaderValues($captions); |
145 | - if(isset($this->_sortable)){ |
|
145 | + if (isset($this->_sortable)) { |
|
146 | 146 | $table->setSortable($this->_sortable); |
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | |
151 | 151 | |
152 | - protected function _generateContent($table){ |
|
152 | + protected function _generateContent($table) { |
|
153 | 153 | $objects=$this->_modelInstance; |
154 | - if(isset($this->_pagination)){ |
|
154 | + if (isset($this->_pagination)) { |
|
155 | 155 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
156 | 156 | } |
157 | 157 | InstanceViewer::setIndex(0); |
158 | 158 | $table->fromDatabaseObjects($objects, function($instance) use($table){ |
159 | 159 | return $this->_generateRow($instance, $table); |
160 | 160 | }); |
161 | - if($table->getRowCount()==0){ |
|
161 | + if ($table->getRowCount()==0) { |
|
162 | 162 | $result=$table->addRow(); |
163 | 163 | $result->mergeRow(); |
164 | 164 | $result->setValues([$this->_emptyMessage]); |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | - protected function _generateRow($instance,&$table,$checkedClass=null){ |
|
168 | + protected function _generateRow($instance, &$table, $checkedClass=null) { |
|
169 | 169 | $this->_instanceViewer->setInstance($instance); |
170 | 170 | InstanceViewer::$index++; |
171 | - $values= $this->_instanceViewer->getValues(); |
|
171 | + $values=$this->_instanceViewer->getValues(); |
|
172 | 172 | $id=$this->_instanceViewer->getIdentifier(); |
173 | - if($this->_hasCheckboxes){ |
|
174 | - $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,""); |
|
173 | + if ($this->_hasCheckboxes) { |
|
174 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
175 | 175 | $ck->setOnChange("event.stopPropagation();"); |
176 | 176 | $field=$ck->getField(); |
177 | - $field->setProperty("value",$id); |
|
177 | + $field->setProperty("value", $id); |
|
178 | 178 | $field->setProperty("name", "selection[]"); |
179 | - if(isset($checkedClass)) |
|
179 | + if (isset($checkedClass)) |
|
180 | 180 | $field->setClass($checkedClass); |
181 | 181 | \array_unshift($values, $ck); |
182 | 182 | } |
183 | 183 | $result=$table->newRow(); |
184 | 184 | $result->setIdentifier($this->identifier."-tr-".$id); |
185 | - $result->setProperty("data-ajax",$id); |
|
185 | + $result->setProperty("data-ajax", $id); |
|
186 | 186 | $result->setValues($values); |
187 | - $result->addToProperty("class",$this->_rowClass); |
|
187 | + $result->addToProperty("class", $this->_rowClass); |
|
188 | 188 | return $result; |
189 | 189 | } |
190 | 190 | |
191 | - protected function _generatePagination($table,$js=NULL){ |
|
192 | - if(isset($this->_toolbar)){ |
|
193 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
191 | + protected function _generatePagination($table, $js=NULL) { |
|
192 | + if (isset($this->_toolbar)) { |
|
193 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
194 | 194 | $this->_toolbar->setFloated("left"); |
195 | 195 | } |
196 | 196 | $footer=$table->getFooter(); |
197 | 197 | $footer->mergeCol(); |
198 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
198 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
199 | 199 | $menu->floatRight(); |
200 | 200 | $menu->setActiveItem($this->_pagination->getPage()-1); |
201 | 201 | $footer->addValues($menu); |
202 | - $this->_associatePaginationBehavior($menu,$js); |
|
202 | + $this->_associatePaginationBehavior($menu, $js); |
|
203 | 203 | } |
204 | 204 | |
205 | - protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){ |
|
206 | - if(isset($this->_urls["refresh"])){ |
|
207 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
205 | + protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) { |
|
206 | + if (isset($this->_urls["refresh"])) { |
|
207 | + $menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | - protected function _getFieldName($index){ |
|
211 | + protected function _getFieldName($index) { |
|
212 | 212 | $fieldName=parent::_getFieldName($index); |
213 | - if(\is_object($fieldName)) |
|
213 | + if (\is_object($fieldName)) |
|
214 | 214 | $fieldName="field-".$index; |
215 | 215 | return $fieldName."[]"; |
216 | 216 | } |
217 | 217 | |
218 | - protected function _getFieldCaption($index){ |
|
218 | + protected function _getFieldCaption($index) { |
|
219 | 219 | return null; |
220 | 220 | } |
221 | 221 | |
222 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
223 | - switch ($this->_toolbarPosition){ |
|
222 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
223 | + switch ($this->_toolbarPosition) { |
|
224 | 224 | case PositionInTable::BEFORETABLE: |
225 | 225 | case PositionInTable::AFTERTABLE: |
226 | - if(isset($this->_compileParts)===false){ |
|
226 | + if (isset($this->_compileParts)===false) { |
|
227 | 227 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
228 | 228 | } |
229 | 229 | break; |
230 | 230 | case PositionInTable::HEADER: |
231 | 231 | case PositionInTable::FOOTER: |
232 | 232 | case PositionInTable::BODY: |
233 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
233 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
234 | 234 | break; |
235 | 235 | } |
236 | 236 | } |
@@ -242,16 +242,16 @@ discard block |
||
242 | 242 | * @param callable $callback function called after the field compilation |
243 | 243 | * @return DataTable |
244 | 244 | */ |
245 | - public function afterCompile($index,$callback){ |
|
246 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
245 | + public function afterCompile($index, $callback) { |
|
246 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
247 | 247 | return $this; |
248 | 248 | } |
249 | 249 | |
250 | - private function addToolbarRow($part,$table,$captions){ |
|
250 | + private function addToolbarRow($part, $table, $captions) { |
|
251 | 251 | $hasPart=$table->hasPart($part); |
252 | - if($hasPart){ |
|
252 | + if ($hasPart) { |
|
253 | 253 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
254 | - }else{ |
|
254 | + } else { |
|
255 | 255 | $row=$table->getPart($part)->getRow(0); |
256 | 256 | } |
257 | 257 | $row->mergeCol(); |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @see Widget::getHtmlComponent() |
264 | 264 | * @return HtmlTable |
265 | 265 | */ |
266 | - public function getHtmlComponent(){ |
|
266 | + public function getHtmlComponent() { |
|
267 | 267 | return $this->content["table"]; |
268 | 268 | } |
269 | 269 | |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | * @return DataTable |
278 | 278 | */ |
279 | 279 | public function setUrls($urls) { |
280 | - if(\is_array($urls)){ |
|
281 | - $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
|
282 | - $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
|
283 | - $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
|
284 | - }else{ |
|
285 | - $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
|
280 | + if (\is_array($urls)) { |
|
281 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
282 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
283 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
284 | + } else { |
|
285 | + $this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls]; |
|
286 | 286 | } |
287 | 287 | return $this; |
288 | 288 | } |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | * @param number $pages_visibles The number of visible pages in the Pagination component |
296 | 296 | * @return DataTable |
297 | 297 | */ |
298 | - public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){ |
|
299 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount); |
|
298 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
299 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
300 | 300 | return $this; |
301 | 301 | } |
302 | 302 | |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | * @param number $pages_visibles The number of visible pages in the Pagination component |
308 | 308 | * @return DataTable |
309 | 309 | */ |
310 | - public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){ |
|
311 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page); |
|
310 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
311 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
312 | 312 | return $this; |
313 | 313 | } |
314 | 314 | |
@@ -318,20 +318,20 @@ discard block |
||
318 | 318 | * @param array $compileParts |
319 | 319 | * @return DataTable |
320 | 320 | */ |
321 | - public function refresh($compileParts=["tbody"]){ |
|
321 | + public function refresh($compileParts=["tbody"]) { |
|
322 | 322 | $this->_compileParts=$compileParts; |
323 | 323 | return $this; |
324 | 324 | } |
325 | 325 | |
326 | 326 | |
327 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
327 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
328 | 328 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
329 | 329 | } |
330 | 330 | |
331 | - public function getSearchField(){ |
|
332 | - if(isset($this->_searchField)===false){ |
|
333 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
334 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
331 | + public function getSearchField() { |
|
332 | + if (isset($this->_searchField)===false) { |
|
333 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
334 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
335 | 335 | } |
336 | 336 | return $this->_searchField; |
337 | 337 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | return $this; |
348 | 348 | } |
349 | 349 | |
350 | - public function asForm(){ |
|
350 | + public function asForm() { |
|
351 | 351 | return $this->getForm(); |
352 | 352 | } |
353 | 353 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | |
356 | 356 | protected function getTargetSelector() { |
357 | 357 | $result=$this->_targetSelector; |
358 | - if(!isset($result)) |
|
358 | + if (!isset($result)) |
|
359 | 359 | $result="#".$this->identifier; |
360 | 360 | return $result; |
361 | 361 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | } |
372 | 372 | |
373 | 373 | public function getRefreshSelector() { |
374 | - if(isset($this->_refreshSelector)) |
|
374 | + if (isset($this->_refreshSelector)) |
|
375 | 375 | return $this->_refreshSelector; |
376 | 376 | return "#".$this->identifier." tbody"; |
377 | 377 | } |
@@ -389,9 +389,9 @@ discard block |
||
389 | 389 | * {@inheritDoc} |
390 | 390 | * @see \Ajax\common\Widget::show() |
391 | 391 | */ |
392 | - public function show($modelInstance){ |
|
393 | - if(\is_array($modelInstance)){ |
|
394 | - if(\is_array(array_values($modelInstance)[0])) |
|
392 | + public function show($modelInstance) { |
|
393 | + if (\is_array($modelInstance)) { |
|
394 | + if (\is_array(array_values($modelInstance)[0])) |
|
395 | 395 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
396 | 396 | } |
397 | 397 | $this->_modelInstance=$modelInstance; |
@@ -426,24 +426,24 @@ discard block |
||
426 | 426 | return $this; |
427 | 427 | } |
428 | 428 | |
429 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
430 | - $this->_self->setActiveRowSelector($class,$event,$multiple); |
|
429 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
430 | + $this->_self->setActiveRowSelector($class, $event, $multiple); |
|
431 | 431 | return $this; |
432 | 432 | } |
433 | 433 | |
434 | - public function hideColumn($colIndex){ |
|
435 | - if(!\is_array($this->_hiddenColumns)) |
|
434 | + public function hideColumn($colIndex) { |
|
435 | + if (!\is_array($this->_hiddenColumns)) |
|
436 | 436 | $this->_hiddenColumns=[]; |
437 | 437 | $this->_hiddenColumns[]=$colIndex; |
438 | 438 | return $this; |
439 | 439 | } |
440 | 440 | |
441 | - public function setColWidth($colIndex,$width){ |
|
441 | + public function setColWidth($colIndex, $width) { |
|
442 | 442 | $this->_colWidths[$colIndex]=$width; |
443 | 443 | return $this; |
444 | 444 | } |
445 | 445 | public function setColWidths($_colWidths) { |
446 | - $this->_colWidths = $_colWidths; |
|
446 | + $this->_colWidths=$_colWidths; |
|
447 | 447 | return $this; |
448 | 448 | } |
449 | 449 | } |
450 | 450 | \ No newline at end of file |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | use Ajax\semantic\html\modules\HtmlModal; |
21 | 21 | |
22 | 22 | abstract class Widget extends HtmlDoubleElement { |
23 | - use FieldAsTrait,FormTrait; |
|
23 | + use FieldAsTrait, FormTrait; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var string classname |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | protected $_generated; |
54 | 54 | |
55 | 55 | |
56 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
56 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
57 | 57 | parent::__construct($identifier); |
58 | 58 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
59 | 59 | $this->setModel($model); |
60 | - if(isset($modelInstance)){ |
|
60 | + if (isset($modelInstance)) { |
|
61 | 61 | $this->show($modelInstance); |
62 | 62 | } |
63 | 63 | $this->_generated=false; |
64 | 64 | } |
65 | 65 | |
66 | - protected function _init($instanceViewer,$contentKey,$content,$edition){ |
|
66 | + protected function _init($instanceViewer, $contentKey, $content, $edition) { |
|
67 | 67 | $this->_instanceViewer=$instanceViewer; |
68 | 68 | $this->content=[$contentKey=>$content]; |
69 | 69 | $this->_self=$content; |
@@ -75,31 +75,31 @@ discard block |
||
75 | 75 | * @param int|string $fieldName |
76 | 76 | * @return int|string |
77 | 77 | */ |
78 | - protected function _getIndex($fieldName){ |
|
78 | + protected function _getIndex($fieldName) { |
|
79 | 79 | $index=$fieldName; |
80 | - if(\is_string($fieldName)){ |
|
80 | + if (\is_string($fieldName)) { |
|
81 | 81 | $fields=$this->_instanceViewer->getVisibleProperties(); |
82 | 82 | $index=\array_search($fieldName, $fields); |
83 | 83 | } |
84 | 84 | return $index; |
85 | 85 | } |
86 | 86 | |
87 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
87 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
88 | 88 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
89 | 89 | } |
90 | 90 | |
91 | - protected function _getFieldName($index){ |
|
91 | + protected function _getFieldName($index) { |
|
92 | 92 | return $this->_instanceViewer->getFieldName($index); |
93 | 93 | } |
94 | 94 | |
95 | - protected function _getFieldCaption($index){ |
|
95 | + protected function _getFieldCaption($index) { |
|
96 | 96 | return $this->_instanceViewer->getCaption($index); |
97 | 97 | } |
98 | 98 | |
99 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
99 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
100 | 100 | |
101 | - public function show($modelInstance){ |
|
102 | - if(\is_array($modelInstance)){ |
|
101 | + public function show($modelInstance) { |
|
102 | + if (\is_array($modelInstance)) { |
|
103 | 103 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
104 | 104 | } |
105 | 105 | $this->_modelInstance=$modelInstance; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | abstract public function getHtmlComponent(); |
127 | 127 | |
128 | - public function setAttached($value=true){ |
|
128 | + public function setAttached($value=true) { |
|
129 | 129 | return $this->getHtmlComponent()->setAttached($value); |
130 | 130 | } |
131 | 131 | |
@@ -136,66 +136,66 @@ discard block |
||
136 | 136 | * @param callable $callback function called after the field compilation |
137 | 137 | * @return Widget |
138 | 138 | */ |
139 | - public function afterCompile($index,$callback){ |
|
139 | + public function afterCompile($index, $callback) { |
|
140 | 140 | $index=$this->_getIndex($index); |
141 | 141 | $this->_instanceViewer->afterCompile($index, $callback); |
142 | 142 | return $this; |
143 | 143 | } |
144 | 144 | |
145 | - public function setColor($color){ |
|
145 | + public function setColor($color) { |
|
146 | 146 | return $this->getHtmlComponent()->setColor($color); |
147 | 147 | } |
148 | 148 | |
149 | 149 | |
150 | - public function setCaptions($captions){ |
|
150 | + public function setCaptions($captions) { |
|
151 | 151 | $this->_instanceViewer->setCaptions($captions); |
152 | 152 | return $this; |
153 | 153 | } |
154 | 154 | |
155 | - public function setCaption($index,$caption){ |
|
155 | + public function setCaption($index, $caption) { |
|
156 | 156 | $this->_instanceViewer->setCaption($this->_getIndex($index), $caption); |
157 | 157 | return $this; |
158 | 158 | } |
159 | 159 | |
160 | - public function setFields($fields){ |
|
160 | + public function setFields($fields) { |
|
161 | 161 | $this->_instanceViewer->setVisibleProperties($fields); |
162 | 162 | return $this; |
163 | 163 | } |
164 | 164 | |
165 | - public function addField($field){ |
|
165 | + public function addField($field) { |
|
166 | 166 | $this->_instanceViewer->addField($field); |
167 | 167 | return $this; |
168 | 168 | } |
169 | 169 | |
170 | - public function addMessage($attributes=NULL,$fieldName="message"){ |
|
170 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
171 | 171 | $this->_instanceViewer->addField($fieldName); |
172 | 172 | $count=$this->_instanceViewer->visiblePropertiesCount(); |
173 | - return $this->fieldAsMessage($count-1,$attributes); |
|
173 | + return $this->fieldAsMessage($count-1, $attributes); |
|
174 | 174 | } |
175 | 175 | |
176 | - public function addErrorMessage(){ |
|
177 | - return $this->addMessage(["error"=>true],"message"); |
|
176 | + public function addErrorMessage() { |
|
177 | + return $this->addMessage(["error"=>true], "message"); |
|
178 | 178 | } |
179 | 179 | |
180 | - public function insertField($index,$field){ |
|
180 | + public function insertField($index, $field) { |
|
181 | 181 | $index=$this->_getIndex($index); |
182 | 182 | $this->_instanceViewer->insertField($index, $field); |
183 | 183 | return $this; |
184 | 184 | } |
185 | 185 | |
186 | - public function insertInField($index,$field){ |
|
186 | + public function insertInField($index, $field) { |
|
187 | 187 | $index=$this->_getIndex($index); |
188 | 188 | $this->_instanceViewer->insertInField($index, $field); |
189 | 189 | return $this; |
190 | 190 | } |
191 | 191 | |
192 | - public function setValueFunction($index,$callback){ |
|
192 | + public function setValueFunction($index, $callback) { |
|
193 | 193 | $index=$this->_getIndex($index); |
194 | 194 | $this->_instanceViewer->setValueFunction($index, $callback); |
195 | 195 | return $this; |
196 | 196 | } |
197 | 197 | |
198 | - public function setIdentifierFunction($callback){ |
|
198 | + public function setIdentifierFunction($callback) { |
|
199 | 199 | $this->_instanceViewer->setIdentifierFunction($callback); |
200 | 200 | return $this; |
201 | 201 | } |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | /** |
204 | 204 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
205 | 205 | */ |
206 | - public function getToolbar(){ |
|
207 | - if(isset($this->_toolbar)===false){ |
|
206 | + public function getToolbar() { |
|
207 | + if (isset($this->_toolbar)===false) { |
|
208 | 208 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
209 | 209 | } |
210 | 210 | return $this->_toolbar; |
@@ -216,15 +216,15 @@ discard block |
||
216 | 216 | * @param callable $callback function to call on $element |
217 | 217 | * @return \Ajax\common\html\HtmlDoubleElement |
218 | 218 | */ |
219 | - public function addInToolbar($element,$callback=NULL){ |
|
219 | + public function addInToolbar($element, $callback=NULL) { |
|
220 | 220 | $tb=$this->getToolbar(); |
221 | - if($element instanceof BaseWidget){ |
|
222 | - if($element->getIdentifier()===""){ |
|
221 | + if ($element instanceof BaseWidget) { |
|
222 | + if ($element->getIdentifier()==="") { |
|
223 | 223 | $element->setIdentifier("tb-item-".$this->identifier."-".$tb->count()); |
224 | 224 | } |
225 | 225 | } |
226 | - if(isset($callback)){ |
|
227 | - if(\is_callable($callback)){ |
|
226 | + if (isset($callback)) { |
|
227 | + if (\is_callable($callback)) { |
|
228 | 228 | $callback($element); |
229 | 229 | } |
230 | 230 | } |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | * @param callable $callback function($element) |
238 | 238 | * @return \Ajax\common\html\HtmlDoubleElement |
239 | 239 | */ |
240 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
241 | - $result=$this->addInToolbar($caption,$callback); |
|
242 | - if(isset($icon)) |
|
240 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
241 | + $result=$this->addInToolbar($caption, $callback); |
|
242 | + if (isset($icon)) |
|
243 | 243 | $result->addIcon($icon); |
244 | 244 | return $result; |
245 | 245 | } |
@@ -249,14 +249,14 @@ discard block |
||
249 | 249 | * @param callable $callback function($element) |
250 | 250 | * @return \Ajax\common\Widget |
251 | 251 | */ |
252 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
253 | - if(JArray::isAssociative($items)){ |
|
254 | - foreach ($items as $icon=>$item){ |
|
255 | - $this->addItemInToolbar($item,$icon,$callback); |
|
252 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
253 | + if (JArray::isAssociative($items)) { |
|
254 | + foreach ($items as $icon=>$item) { |
|
255 | + $this->addItemInToolbar($item, $icon, $callback); |
|
256 | 256 | } |
257 | - }else{ |
|
258 | - foreach ($items as $item){ |
|
259 | - $this->addItemInToolbar($item,null,$callback); |
|
257 | + } else { |
|
258 | + foreach ($items as $item) { |
|
259 | + $this->addItemInToolbar($item, null, $callback); |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | return $this; |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | * @param callable $callback function($element) |
269 | 269 | * @return \Ajax\common\html\HtmlDoubleElement |
270 | 270 | */ |
271 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
271 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
272 | 272 | $dd=$value; |
273 | 273 | if (\is_string($value)) { |
274 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
274 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
275 | 275 | } |
276 | - return $this->addInToolbar($dd,$callback); |
|
276 | + return $this->addInToolbar($dd, $callback); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | * @param callable $callback function($element) |
283 | 283 | * @return \Ajax\common\html\HtmlDoubleElement |
284 | 284 | */ |
285 | - public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){ |
|
286 | - $bt=new HtmlButton("bt-".$caption,$caption,$cssStyle); |
|
287 | - return $this->addInToolbar($bt,$callback); |
|
285 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
286 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
287 | + return $this->addInToolbar($bt, $callback); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | * @param callable $callback function($element) |
294 | 294 | * @return \Ajax\common\html\HtmlDoubleElement |
295 | 295 | */ |
296 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
297 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
298 | - return $this->addInToolbar($bts,$callback); |
|
296 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
297 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
298 | + return $this->addInToolbar($bts, $callback); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -305,15 +305,15 @@ discard block |
||
305 | 305 | * @param boolean $labeled |
306 | 306 | * @return \Ajax\common\html\HtmlDoubleElement |
307 | 307 | */ |
308 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
309 | - $bt=new HtmlButton("",$caption); |
|
310 | - $bt->addIcon($icon,$before,$labeled); |
|
308 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
309 | + $bt=new HtmlButton("", $caption); |
|
310 | + $bt->addIcon($icon, $before, $labeled); |
|
311 | 311 | return $this->addInToolbar($bt); |
312 | 312 | } |
313 | 313 | |
314 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
315 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
316 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters); |
|
314 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
315 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
316 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
|
317 | 317 | return $this->addInToolbar($button); |
318 | 318 | } |
319 | 319 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model |
344 | 344 | * @return \Ajax\common\Widget |
345 | 345 | */ |
346 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
346 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
347 | 347 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
348 | 348 | return $this; |
349 | 349 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * @param string|boolean $disable |
353 | 353 | * @return string |
354 | 354 | */ |
355 | - public function jsDisabled($disable=true){ |
|
355 | + public function jsDisabled($disable=true) { |
|
356 | 356 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
357 | 357 | } |
358 | 358 | |
@@ -361,12 +361,12 @@ discard block |
||
361 | 361 | * @param callable $callback function($element) |
362 | 362 | * @return \Ajax\common\html\HtmlDoubleElement |
363 | 363 | */ |
364 | - public function addEditButtonInToolbar($caption,$callback=NULL){ |
|
365 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
364 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
365 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
366 | 366 | $bt->setToggle(); |
367 | 367 | $bt->setActive($this->_edition); |
368 | 368 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
369 | - return $this->addInToolbar($bt,$callback); |
|
369 | + return $this->addInToolbar($bt, $callback); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | public function setToolbar(HtmlMenu $_toolbar) { |
@@ -380,35 +380,35 @@ discard block |
||
380 | 380 | } |
381 | 381 | |
382 | 382 | public function getForm() { |
383 | - if(!isset($this->_form)){ |
|
383 | + if (!isset($this->_form)) { |
|
384 | 384 | $this->_form=new HtmlForm("frm-".$this->identifier); |
385 | 385 | $this->setEdition(true); |
386 | 386 | } |
387 | 387 | return $this->_form; |
388 | 388 | } |
389 | 389 | |
390 | - public function run(JsUtils $js){ |
|
390 | + public function run(JsUtils $js) { |
|
391 | 391 | $result=parent::run($js); |
392 | - if(isset($this->_form)){ |
|
392 | + if (isset($this->_form)) { |
|
393 | 393 | $result=$this->runForm($js); |
394 | 394 | } |
395 | 395 | return $result; |
396 | 396 | } |
397 | 397 | |
398 | - protected function runForm(JsUtils $js){ |
|
398 | + protected function runForm(JsUtils $js) { |
|
399 | 399 | $fields=$this->getContentInstances(HtmlFormField::class); |
400 | - foreach ($fields as $field){ |
|
400 | + foreach ($fields as $field) { |
|
401 | 401 | $this->_form->addField($field); |
402 | 402 | } |
403 | 403 | return $this->_form->run($js); |
404 | 404 | } |
405 | 405 | |
406 | - protected function _compileForm(){ |
|
407 | - if(isset($this->_form)){ |
|
406 | + protected function _compileForm() { |
|
407 | + if (isset($this->_form)) { |
|
408 | 408 | $noValidate=""; |
409 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
409 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
410 | 410 | $noValidate="novalidate"; |
411 | - $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
|
411 | + $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
@@ -417,32 +417,32 @@ discard block |
||
417 | 417 | return $this; |
418 | 418 | } |
419 | 419 | |
420 | - public function moveFieldTo($from,$to){ |
|
420 | + public function moveFieldTo($from, $to) { |
|
421 | 421 | return $this->_instanceViewer->moveFieldTo($from, $to); |
422 | 422 | } |
423 | 423 | |
424 | - public function swapFields($index1,$index2){ |
|
424 | + public function swapFields($index1, $index2) { |
|
425 | 425 | $index1=$this->_getIndex($index1); |
426 | 426 | $index2=$this->_getIndex($index2); |
427 | 427 | return $this->_instanceViewer->swapFields($index1, $index2); |
428 | 428 | } |
429 | 429 | |
430 | - public function removeField($index){ |
|
430 | + public function removeField($index) { |
|
431 | 431 | $index=$this->_getIndex($index); |
432 | 432 | $this->_instanceViewer->removeField($index); |
433 | 433 | return $this; |
434 | 434 | } |
435 | 435 | |
436 | - public function asModal($header=null){ |
|
437 | - $modal=new HtmlModal("modal-".$this->identifier,$header); |
|
436 | + public function asModal($header=null) { |
|
437 | + $modal=new HtmlModal("modal-".$this->identifier, $header); |
|
438 | 438 | $modal->setContent($this); |
439 | - if(isset($this->_form)){ |
|
439 | + if (isset($this->_form)) { |
|
440 | 440 | $this->_form->onSuccess($modal->jsHide()); |
441 | 441 | } |
442 | 442 | return $modal; |
443 | 443 | } |
444 | 444 | |
445 | 445 | public function addToProperty($name, $value, $separator=" ") { |
446 | - return $this->getHtmlComponent()->addToProperty($name,$value,$separator); |
|
446 | + return $this->getHtmlComponent()->addToProperty($name, $value, $separator); |
|
447 | 447 | } |
448 | 448 | } |
449 | 449 | \ No newline at end of file |