@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | namespace Ajax\common\traits; |
3 | 3 | use Ajax\common\BaseGui; |
4 | 4 | |
5 | -trait JsUtilsInternalTrait{ |
|
5 | +trait JsUtilsInternalTrait { |
|
6 | 6 | |
7 | - protected $jquery_code_for_compile=array (); |
|
8 | - protected $jquery_code_for_compile_at_last=array (); |
|
7 | + protected $jquery_code_for_compile=array(); |
|
8 | + protected $jquery_code_for_compile_at_last=array(); |
|
9 | 9 | |
10 | 10 | protected function _addToCompile($jsScript) { |
11 | 11 | $this->jquery_code_for_compile[]=$jsScript; |
@@ -15,28 +15,28 @@ discard block |
||
15 | 15 | * @param BaseGui $library |
16 | 16 | * @param mixed $view |
17 | 17 | */ |
18 | - protected function _compileLibrary(BaseGui $library=NULL, &$view=NULL){ |
|
19 | - if(isset($view)) |
|
18 | + protected function _compileLibrary(BaseGui $library=NULL, &$view=NULL) { |
|
19 | + if (isset($view)) |
|
20 | 20 | $library->compileHtml($this, $view); |
21 | 21 | if ($library->isAutoCompile()) { |
22 | 22 | $library->compile(true); |
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | - protected function defer($script){ |
|
26 | + protected function defer($script) { |
|
27 | 27 | $result="window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { defer(method) }, 50);};"; |
28 | 28 | $result.="window.defer(function(){".$script."})"; |
29 | 29 | return $result; |
30 | 30 | } |
31 | 31 | |
32 | - protected function ready($script){ |
|
32 | + protected function ready($script) { |
|
33 | 33 | $result='$(document).ready(function() {'."\n"; |
34 | 34 | $result.=$script.'})'; |
35 | 35 | return $result; |
36 | 36 | } |
37 | 37 | |
38 | 38 | protected function minify($input) { |
39 | - if(trim($input) === "") return $input; |
|
39 | + if (trim($input)==="") return $input; |
|
40 | 40 | return preg_replace( |
41 | 41 | array( |
42 | 42 | // Remove comment(s) |
@@ -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 | protected $_merged=false; |
16 | 16 | |
17 | 17 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function setRowCount($rowCount, $colCount) { |
37 | 37 | $count=$this->count(); |
38 | - for($i=$count; $i < $rowCount; $i++) { |
|
38 | + for ($i=$count; $i<$rowCount; $i++) { |
|
39 | 39 | $this->addItem($colCount); |
40 | 40 | } |
41 | 41 | return $this; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $tr=new HtmlTR("", $value); |
58 | 58 | $tr->setContainer($this, $count); |
59 | 59 | $tr->setTdTagName($this->_tdTagNames[$this->tagName]); |
60 | - if (isset($value) === true) { |
|
60 | + if (isset($value)===true) { |
|
61 | 61 | $tr->setColCount($value); |
62 | 62 | } |
63 | 63 | return $tr; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function setCellValue($row, $col, $value="") { |
117 | 117 | $cell=$this->getCell($row, $col); |
118 | - if (isset($cell) === true) { |
|
118 | + if (isset($cell)===true) { |
|
119 | 119 | $cell->setValue($value); |
120 | 120 | } |
121 | 121 | return $this; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param mixed $values |
127 | 127 | */ |
128 | 128 | public function setValues($values=array()) { |
129 | - return $this->_addOrSetValues($values, function(HtmlTR $row,$_values){$row->setValues($_values);}); |
|
129 | + return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) {$row->setValues($_values); }); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param mixed $values |
135 | 135 | */ |
136 | 136 | public function addValues($values=array()) { |
137 | - return $this->_addOrSetValues($values, function(HtmlTR $row,$_values){$row->addValues($_values);}); |
|
137 | + return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) {$row->addValues($_values); }); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -142,21 +142,21 @@ discard block |
||
142 | 142 | * @param mixed $values |
143 | 143 | * @param callable $callback |
144 | 144 | */ |
145 | - protected function _addOrSetValues($values,$callback) { |
|
145 | + protected function _addOrSetValues($values, $callback) { |
|
146 | 146 | $count=$this->count(); |
147 | 147 | $isArray=true; |
148 | 148 | if (!\is_array($values)) { |
149 | 149 | $values=\array_fill(0, $count, $values); |
150 | 150 | $isArray=false; |
151 | 151 | } |
152 | - if (JArray::dimension($values) == 1 && $isArray) |
|
153 | - $values=[ $values ]; |
|
152 | + if (JArray::dimension($values)==1 && $isArray) |
|
153 | + $values=[$values]; |
|
154 | 154 | |
155 | 155 | $count=\min(\sizeof($values), $count); |
156 | 156 | |
157 | - for($i=0; $i < $count; $i++) { |
|
157 | + for ($i=0; $i<$count; $i++) { |
|
158 | 158 | $row=$this->content[$i]; |
159 | - $callback($row,$values[$i]); |
|
159 | + $callback($row, $values[$i]); |
|
160 | 160 | } |
161 | 161 | return $this; |
162 | 162 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $values=\array_fill(0, $count, $values); |
168 | 168 | } |
169 | 169 | $count=\min(\sizeof($values), $count); |
170 | - for($i=0; $i < $count; $i++) { |
|
170 | + for ($i=0; $i<$count; $i++) { |
|
171 | 171 | $this->getCell($i, $colIndex)->setValue($values[$i]); |
172 | 172 | } |
173 | 173 | return $this; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | public function addColVariations($colIndex, $variations=array()) { |
177 | 177 | $count=$this->count(); |
178 | - for($i=0; $i < $count; $i++) { |
|
178 | + for ($i=0; $i<$count; $i++) { |
|
179 | 179 | $this->getCell($i, $colIndex)->addVariations($variations); |
180 | 180 | } |
181 | 181 | return $this; |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | |
193 | 193 | private function colAlign($colIndex, $function) { |
194 | 194 | $count=$this->count(); |
195 | - for($i=0; $i < $count; $i++) { |
|
195 | + for ($i=0; $i<$count; $i++) { |
|
196 | 196 | $index=$this->content[$i]->getColPosition($colIndex); |
197 | - if ($index !== NULL) |
|
197 | + if ($index!==NULL) |
|
198 | 198 | $this->getCell($i, $index)->$function(); |
199 | 199 | } |
200 | 200 | return $this; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function getColCount() { |
228 | 228 | $result=0; |
229 | - if ($this->count() > 0) |
|
229 | + if ($this->count()>0) |
|
230 | 230 | $result=$this->getItem(0)->count(); |
231 | 231 | return $result; |
232 | 232 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | public function delete($rowIndex, $colIndex=NULL) { |
241 | 241 | if (isset($colIndex)) { |
242 | 242 | $row=$this->getItem($rowIndex); |
243 | - if (isset($row) === true) { |
|
243 | + if (isset($row)===true) { |
|
244 | 244 | $row->delete($colIndex); |
245 | 245 | } |
246 | 246 | } else { |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | return $this; |
250 | 250 | } |
251 | 251 | |
252 | - public function toDelete($rowIndex, $colIndex){ |
|
252 | + public function toDelete($rowIndex, $colIndex) { |
|
253 | 253 | $row=$this->getItem($rowIndex); |
254 | - if (isset($row) === true) |
|
254 | + if (isset($row)===true) |
|
255 | 255 | $row->toDelete($colIndex); |
256 | 256 | return $this; |
257 | 257 | } |
@@ -280,17 +280,17 @@ discard block |
||
280 | 280 | */ |
281 | 281 | public function conditionalCellFormat($callback, $format) { |
282 | 282 | $rows=$this->content; |
283 | - foreach ( $rows as $row ) { |
|
283 | + foreach ($rows as $row) { |
|
284 | 284 | $row->conditionalCellFormat($callback, $format); |
285 | 285 | } |
286 | 286 | return $this; |
287 | 287 | } |
288 | 288 | |
289 | - public function conditionalColFormat($colIndex,$callback,$format){ |
|
289 | + public function conditionalColFormat($colIndex, $callback, $format) { |
|
290 | 290 | $rows=$this->content; |
291 | - foreach ( $rows as $row ) { |
|
291 | + foreach ($rows as $row) { |
|
292 | 292 | $cell=$row->getItem($colIndex); |
293 | - $cell->conditionnalCellFormat($callback,$format); |
|
293 | + $cell->conditionnalCellFormat($callback, $format); |
|
294 | 294 | } |
295 | 295 | return $this; |
296 | 296 | } |
@@ -302,17 +302,17 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public function conditionalRowFormat($callback, $format) { |
304 | 304 | $rows=$this->content; |
305 | - foreach ( $rows as $row ) { |
|
305 | + foreach ($rows as $row) { |
|
306 | 306 | $row->conditionalRowFormat($callback, $format); |
307 | 307 | } |
308 | 308 | return $this; |
309 | 309 | } |
310 | 310 | |
311 | - public function hideColumn($colIndex){ |
|
311 | + public function hideColumn($colIndex) { |
|
312 | 312 | $rows=$this->content; |
313 | - foreach ( $rows as $row ) { |
|
313 | + foreach ($rows as $row) { |
|
314 | 314 | $cell=$row->getItem($colIndex); |
315 | - $cell->addToProperty("style","display:none;"); |
|
315 | + $cell->addToProperty("style", "display:none;"); |
|
316 | 316 | } |
317 | 317 | return $this; |
318 | 318 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | */ |
324 | 324 | public function applyCells($callback) { |
325 | 325 | $rows=$this->content; |
326 | - foreach ( $rows as $row ) { |
|
326 | + foreach ($rows as $row) { |
|
327 | 327 | $row->applyCells($callback); |
328 | 328 | } |
329 | 329 | return $this; |
@@ -335,25 +335,25 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public function applyRows($callback) { |
337 | 337 | $rows=$this->content; |
338 | - foreach ( $rows as $row ) { |
|
338 | + foreach ($rows as $row) { |
|
339 | 339 | $row->apply($callback); |
340 | 340 | } |
341 | 341 | return $this; |
342 | 342 | } |
343 | 343 | |
344 | - public function mergeIdentiqualValues($colIndex,$function="strip_tags"){ |
|
344 | + public function mergeIdentiqualValues($colIndex, $function="strip_tags") { |
|
345 | 345 | $rows=$this->content; |
346 | 346 | $identiqual=null; |
347 | 347 | $counter=0; |
348 | 348 | $cellToMerge=null; |
349 | 349 | $functionExists=\function_exists($function); |
350 | - foreach ( $rows as $row ) { |
|
350 | + foreach ($rows as $row) { |
|
351 | 351 | $cell=$row->getItem($colIndex); |
352 | 352 | $value=$cell->getContent(); |
353 | - if($functionExists) |
|
354 | - $value=\call_user_func($function,$value); |
|
355 | - if($value!==$identiqual){ |
|
356 | - if($counter>0 && isset($cellToMerge)){ |
|
353 | + if ($functionExists) |
|
354 | + $value=\call_user_func($function, $value); |
|
355 | + if ($value!==$identiqual) { |
|
356 | + if ($counter>0 && isset($cellToMerge)) { |
|
357 | 357 | $cellToMerge->setRowspan($counter); |
358 | 358 | } |
359 | 359 | $counter=0; |
@@ -362,17 +362,17 @@ discard block |
||
362 | 362 | } |
363 | 363 | $counter++; |
364 | 364 | } |
365 | - if($counter>0 && isset($cellToMerge)){ |
|
365 | + if ($counter>0 && isset($cellToMerge)) { |
|
366 | 366 | $cellToMerge->setRowspan($counter); |
367 | 367 | } |
368 | 368 | return $this; |
369 | 369 | } |
370 | 370 | |
371 | - public function _isMerged(){ |
|
371 | + public function _isMerged() { |
|
372 | 372 | return $this->_merged; |
373 | 373 | } |
374 | 374 | |
375 | - public function _setMerged($value){ |
|
375 | + public function _setMerged($value) { |
|
376 | 376 | $this->_merged=$value; |
377 | 377 | return $this; |
378 | 378 | } |
@@ -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,59 +136,59 @@ 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 addFields($fields){ |
|
170 | + public function addFields($fields) { |
|
171 | 171 | $this->_instanceViewer->addFields($fields); |
172 | 172 | return $this; |
173 | 173 | } |
174 | 174 | |
175 | - public function addMessage($attributes=NULL,$fieldName="message"){ |
|
175 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
176 | 176 | $this->_instanceViewer->addField($fieldName); |
177 | 177 | $count=$this->_instanceViewer->visiblePropertiesCount(); |
178 | - return $this->fieldAsMessage($count-1,$attributes); |
|
178 | + return $this->fieldAsMessage($count-1, $attributes); |
|
179 | 179 | } |
180 | 180 | |
181 | - public function addErrorMessage(){ |
|
182 | - return $this->addMessage(["error"=>true],"message"); |
|
181 | + public function addErrorMessage() { |
|
182 | + return $this->addMessage(["error"=>true], "message"); |
|
183 | 183 | } |
184 | 184 | |
185 | - public function insertField($index,$field){ |
|
185 | + public function insertField($index, $field) { |
|
186 | 186 | $index=$this->_getIndex($index); |
187 | 187 | $this->_instanceViewer->insertField($index, $field); |
188 | 188 | return $this; |
189 | 189 | } |
190 | 190 | |
191 | - public function insertInField($index,$field){ |
|
191 | + public function insertInField($index, $field) { |
|
192 | 192 | $index=$this->_getIndex($index); |
193 | 193 | $this->_instanceViewer->insertInField($index, $field); |
194 | 194 | return $this; |
@@ -200,13 +200,13 @@ discard block |
||
200 | 200 | * @param callable $callback function parameters are : $value : the field value, $instance : the active instance of model, $fieldIndex : the field index, $rowIndex : the row index |
201 | 201 | * @return Widget |
202 | 202 | */ |
203 | - public function setValueFunction($index,$callback){ |
|
203 | + public function setValueFunction($index, $callback) { |
|
204 | 204 | $index=$this->_getIndex($index); |
205 | 205 | $this->_instanceViewer->setValueFunction($index, $callback); |
206 | 206 | return $this; |
207 | 207 | } |
208 | 208 | |
209 | - public function setIdentifierFunction($callback){ |
|
209 | + public function setIdentifierFunction($callback) { |
|
210 | 210 | $this->_instanceViewer->setIdentifierFunction($callback); |
211 | 211 | return $this; |
212 | 212 | } |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | /** |
215 | 215 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
216 | 216 | */ |
217 | - public function getToolbar(){ |
|
218 | - if(isset($this->_toolbar)===false){ |
|
217 | + public function getToolbar() { |
|
218 | + if (isset($this->_toolbar)===false) { |
|
219 | 219 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
220 | 220 | } |
221 | 221 | return $this->_toolbar; |
@@ -227,15 +227,15 @@ discard block |
||
227 | 227 | * @param callable $callback function to call on $element |
228 | 228 | * @return \Ajax\common\html\HtmlDoubleElement |
229 | 229 | */ |
230 | - public function addInToolbar($element,$callback=NULL){ |
|
230 | + public function addInToolbar($element, $callback=NULL) { |
|
231 | 231 | $tb=$this->getToolbar(); |
232 | - if($element instanceof BaseWidget){ |
|
233 | - if($element->getIdentifier()===""){ |
|
232 | + if ($element instanceof BaseWidget) { |
|
233 | + if ($element->getIdentifier()==="") { |
|
234 | 234 | $element->setIdentifier("tb-item-".$this->identifier."-".$tb->count()); |
235 | 235 | } |
236 | 236 | } |
237 | - if(isset($callback)){ |
|
238 | - if(\is_callable($callback)){ |
|
237 | + if (isset($callback)) { |
|
238 | + if (\is_callable($callback)) { |
|
239 | 239 | $callback($element); |
240 | 240 | } |
241 | 241 | } |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * @param callable $callback function($element) |
249 | 249 | * @return \Ajax\common\html\HtmlDoubleElement |
250 | 250 | */ |
251 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
252 | - $result=$this->addInToolbar($caption,$callback); |
|
253 | - if(isset($icon)) |
|
251 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
252 | + $result=$this->addInToolbar($caption, $callback); |
|
253 | + if (isset($icon)) |
|
254 | 254 | $result->addIcon($icon); |
255 | 255 | return $result; |
256 | 256 | } |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | * @param callable $callback function($element) |
261 | 261 | * @return \Ajax\common\Widget |
262 | 262 | */ |
263 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
264 | - if(JArray::isAssociative($items)){ |
|
265 | - foreach ($items as $icon=>$item){ |
|
266 | - $this->addItemInToolbar($item,$icon,$callback); |
|
263 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
264 | + if (JArray::isAssociative($items)) { |
|
265 | + foreach ($items as $icon=>$item) { |
|
266 | + $this->addItemInToolbar($item, $icon, $callback); |
|
267 | 267 | } |
268 | - }else{ |
|
269 | - foreach ($items as $item){ |
|
270 | - $this->addItemInToolbar($item,null,$callback); |
|
268 | + } else { |
|
269 | + foreach ($items as $item) { |
|
270 | + $this->addItemInToolbar($item, null, $callback); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | return $this; |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | * @param callable $callback function($element) |
280 | 280 | * @return \Ajax\common\html\HtmlDoubleElement |
281 | 281 | */ |
282 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
282 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
283 | 283 | $dd=$value; |
284 | 284 | if (\is_string($value)) { |
285 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
285 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
286 | 286 | } |
287 | - return $this->addInToolbar($dd,$callback); |
|
287 | + return $this->addInToolbar($dd, $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 addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){ |
|
297 | - $bt=new HtmlButton("bt-".$caption,$caption,$cssStyle); |
|
298 | - return $this->addInToolbar($bt,$callback); |
|
296 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
297 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
298 | + return $this->addInToolbar($bt, $callback); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | * @param callable $callback function($element) |
305 | 305 | * @return \Ajax\common\html\HtmlDoubleElement |
306 | 306 | */ |
307 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
308 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
309 | - return $this->addInToolbar($bts,$callback); |
|
307 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
308 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
309 | + return $this->addInToolbar($bts, $callback); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -316,15 +316,15 @@ discard block |
||
316 | 316 | * @param boolean $labeled |
317 | 317 | * @return \Ajax\common\html\HtmlDoubleElement |
318 | 318 | */ |
319 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
320 | - $bt=new HtmlButton("",$caption); |
|
321 | - $bt->addIcon($icon,$before,$labeled); |
|
319 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
320 | + $bt=new HtmlButton("", $caption); |
|
321 | + $bt->addIcon($icon, $before, $labeled); |
|
322 | 322 | return $this->addInToolbar($bt); |
323 | 323 | } |
324 | 324 | |
325 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
326 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
327 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters); |
|
325 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
326 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
327 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
|
328 | 328 | return $this->addInToolbar($button); |
329 | 329 | } |
330 | 330 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model |
355 | 355 | * @return \Ajax\common\Widget |
356 | 356 | */ |
357 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
357 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
358 | 358 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
359 | 359 | return $this; |
360 | 360 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @param string|boolean $disable |
364 | 364 | * @return string |
365 | 365 | */ |
366 | - public function jsDisabled($disable=true){ |
|
366 | + public function jsDisabled($disable=true) { |
|
367 | 367 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
368 | 368 | } |
369 | 369 | |
@@ -372,12 +372,12 @@ discard block |
||
372 | 372 | * @param callable $callback function($element) |
373 | 373 | * @return \Ajax\common\html\HtmlDoubleElement |
374 | 374 | */ |
375 | - public function addEditButtonInToolbar($caption,$callback=NULL){ |
|
376 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
375 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
376 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
377 | 377 | $bt->setToggle(); |
378 | 378 | $bt->setActive($this->_edition); |
379 | 379 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
380 | - return $this->addInToolbar($bt,$callback); |
|
380 | + return $this->addInToolbar($bt, $callback); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | public function setToolbar(HtmlMenu $_toolbar) { |
@@ -391,35 +391,35 @@ discard block |
||
391 | 391 | } |
392 | 392 | |
393 | 393 | public function getForm() { |
394 | - if(!isset($this->_form)){ |
|
394 | + if (!isset($this->_form)) { |
|
395 | 395 | $this->_form=new HtmlForm("frm-".$this->identifier); |
396 | 396 | $this->setEdition(true); |
397 | 397 | } |
398 | 398 | return $this->_form; |
399 | 399 | } |
400 | 400 | |
401 | - public function run(JsUtils $js){ |
|
401 | + public function run(JsUtils $js) { |
|
402 | 402 | $result=parent::run($js); |
403 | - if(isset($this->_form)){ |
|
403 | + if (isset($this->_form)) { |
|
404 | 404 | $result=$this->runForm($js); |
405 | 405 | } |
406 | 406 | return $result; |
407 | 407 | } |
408 | 408 | |
409 | - protected function runForm(JsUtils $js){ |
|
409 | + protected function runForm(JsUtils $js) { |
|
410 | 410 | $fields=$this->getContentInstances(HtmlFormField::class); |
411 | - foreach ($fields as $field){ |
|
411 | + foreach ($fields as $field) { |
|
412 | 412 | $this->_form->addField($field); |
413 | 413 | } |
414 | 414 | return $this->_form->run($js); |
415 | 415 | } |
416 | 416 | |
417 | - protected function _compileForm(){ |
|
418 | - if(isset($this->_form)){ |
|
417 | + protected function _compileForm() { |
|
418 | + if (isset($this->_form)) { |
|
419 | 419 | $noValidate=""; |
420 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
420 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
421 | 421 | $noValidate="novalidate"; |
422 | - $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
|
422 | + $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
423 | 423 | } |
424 | 424 | } |
425 | 425 | |
@@ -428,32 +428,32 @@ discard block |
||
428 | 428 | return $this; |
429 | 429 | } |
430 | 430 | |
431 | - public function moveFieldTo($from,$to){ |
|
431 | + public function moveFieldTo($from, $to) { |
|
432 | 432 | return $this->_instanceViewer->moveFieldTo($from, $to); |
433 | 433 | } |
434 | 434 | |
435 | - public function swapFields($index1,$index2){ |
|
435 | + public function swapFields($index1, $index2) { |
|
436 | 436 | $index1=$this->_getIndex($index1); |
437 | 437 | $index2=$this->_getIndex($index2); |
438 | 438 | return $this->_instanceViewer->swapFields($index1, $index2); |
439 | 439 | } |
440 | 440 | |
441 | - public function removeField($index){ |
|
441 | + public function removeField($index) { |
|
442 | 442 | $index=$this->_getIndex($index); |
443 | 443 | $this->_instanceViewer->removeField($index); |
444 | 444 | return $this; |
445 | 445 | } |
446 | 446 | |
447 | - public function asModal($header=null){ |
|
448 | - $modal=new HtmlModal("modal-".$this->identifier,$header); |
|
447 | + public function asModal($header=null) { |
|
448 | + $modal=new HtmlModal("modal-".$this->identifier, $header); |
|
449 | 449 | $modal->setContent($this); |
450 | - if(isset($this->_form)){ |
|
450 | + if (isset($this->_form)) { |
|
451 | 451 | $this->_form->onSuccess($modal->jsHide()); |
452 | 452 | } |
453 | 453 | return $modal; |
454 | 454 | } |
455 | 455 | |
456 | 456 | public function addToProperty($name, $value, $separator=" ") { |
457 | - return $this->getHtmlComponent()->addToProperty($name,$value,$separator); |
|
457 | + return $this->getHtmlComponent()->addToProperty($name, $value, $separator); |
|
458 | 458 | } |
459 | 459 | } |
@@ -14,27 +14,27 @@ discard block |
||
14 | 14 | * @author jc |
15 | 15 | * |
16 | 16 | */ |
17 | -trait FormTrait{ |
|
17 | +trait FormTrait { |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @return HtmlForm |
21 | 21 | */ |
22 | 22 | abstract protected function getForm(); |
23 | 23 | |
24 | - protected function addCompoValidation(Form $compo,HtmlFormField $field){ |
|
24 | + protected function addCompoValidation(Form $compo, HtmlFormField $field) { |
|
25 | 25 | $validation=$field->getValidation(); |
26 | - if(isset($validation)){ |
|
26 | + if (isset($validation)) { |
|
27 | 27 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
28 | 28 | $compo->addFieldValidation($validation); |
29 | 29 | } |
30 | 30 | return $compo; |
31 | 31 | } |
32 | 32 | |
33 | - protected function _runValidationParams(Form &$compo,JsUtils $js=NULL){ |
|
33 | + protected function _runValidationParams(Form &$compo, JsUtils $js=NULL) { |
|
34 | 34 | $form=$this->getForm(); |
35 | 35 | $params=$form->getValidationParams(); |
36 | - if(isset($params["_ajaxSubmit"])){ |
|
37 | - $compilation=$this->_compileAjaxSubmit($params["_ajaxSubmit"],$js); |
|
36 | + if (isset($params["_ajaxSubmit"])) { |
|
37 | + $compilation=$this->_compileAjaxSubmit($params["_ajaxSubmit"], $js); |
|
38 | 38 | $this->onSuccess($compilation); |
39 | 39 | $form->removeValidationParam("_ajaxSubmit"); |
40 | 40 | } |
@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | $form->addEventsOnRun($js); |
44 | 44 | } |
45 | 45 | |
46 | - protected function _compileAjaxSubmit($ajaxSubmit,JsUtils $js=null){ |
|
46 | + protected function _compileAjaxSubmit($ajaxSubmit, JsUtils $js=null) { |
|
47 | 47 | $compilation=""; |
48 | - if(\is_array($ajaxSubmit)){ |
|
49 | - foreach ($ajaxSubmit as $ajaxSubmitItem){ |
|
48 | + if (\is_array($ajaxSubmit)) { |
|
49 | + foreach ($ajaxSubmit as $ajaxSubmitItem) { |
|
50 | 50 | $compilation.=$ajaxSubmitItem->compile($js); |
51 | 51 | } |
52 | - }elseif($ajaxSubmit instanceof AjaxCall){ |
|
52 | + }elseif ($ajaxSubmit instanceof AjaxCall) { |
|
53 | 53 | $compilation=$ajaxSubmit->compile($js); |
54 | 54 | } |
55 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
55 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
56 | 56 | return $compilation; |
57 | 57 | } |
58 | 58 | |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | return $this; |
66 | 66 | } |
67 | 67 | |
68 | - public function setAttached($value=true){ |
|
68 | + public function setAttached($value=true) { |
|
69 | 69 | $form=$this->getForm(); |
70 | - if($value) |
|
71 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
70 | + if ($value) |
|
71 | + $form->addToPropertyCtrl("class", "attached", array("attached")); |
|
72 | 72 | return $form; |
73 | 73 | } |
74 | 74 | |
75 | - public function addErrorMessage(){ |
|
75 | + public function addErrorMessage() { |
|
76 | 76 | return $this->getForm()->addContent((new HtmlMessage(""))->setError()); |
77 | 77 | } |
78 | 78 | |
@@ -88,47 +88,47 @@ discard block |
||
88 | 88 | * @param array $parameters |
89 | 89 | * @return HtmlForm |
90 | 90 | */ |
91 | - public function submitOn($event,$identifierOrElement,$url,$responseElement,$parameters=NULL){ |
|
91 | + public function submitOn($event, $identifierOrElement, $url, $responseElement, $parameters=NULL) { |
|
92 | 92 | $form=$this->getForm(); |
93 | - if($identifierOrElement instanceof BaseHtml) |
|
93 | + if ($identifierOrElement instanceof BaseHtml) |
|
94 | 94 | $elem=$identifierOrElement; |
95 | 95 | else |
96 | 96 | $elem=$form->getElementById($identifierOrElement, $form->getContent()); |
97 | - if(isset($elem)){ |
|
98 | - $this->_buttonAsSubmit($elem, $event,$url,$responseElement,$parameters); |
|
97 | + if (isset($elem)) { |
|
98 | + $this->_buttonAsSubmit($elem, $event, $url, $responseElement, $parameters); |
|
99 | 99 | } |
100 | 100 | return $form; |
101 | 101 | } |
102 | 102 | |
103 | - public function submitOnClick($identifier,$url,$responseElement,$parameters=NULL){ |
|
104 | - return $this->submitOn("click", $identifier, $url, $responseElement,$parameters); |
|
103 | + public function submitOnClick($identifier, $url, $responseElement, $parameters=NULL) { |
|
104 | + return $this->submitOn("click", $identifier, $url, $responseElement, $parameters); |
|
105 | 105 | } |
106 | 106 | |
107 | - public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
108 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
109 | - return $this->_buttonAsSubmit($bt, "click",$url,$responseElement,$parameters); |
|
107 | + public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
108 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
109 | + return $this->_buttonAsSubmit($bt, "click", $url, $responseElement, $parameters); |
|
110 | 110 | } |
111 | 111 | |
112 | - protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL){ |
|
112 | + protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement=NULL, $parameters=NULL) { |
|
113 | 113 | $form=$this->getForm(); |
114 | - if(isset($url) && isset($responseElement)){ |
|
115 | - $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true); |
|
116 | - $this->setSubmitParams($url,$responseElement,$parameters); |
|
114 | + if (isset($url) && isset($responseElement)) { |
|
115 | + $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');", true, true); |
|
116 | + $this->setSubmitParams($url, $responseElement, $parameters); |
|
117 | 117 | } |
118 | 118 | return $button; |
119 | 119 | } |
120 | 120 | |
121 | - public function setSubmitParams($url,$responseElement=NULL,$parameters=NULL){ |
|
121 | + public function setSubmitParams($url, $responseElement=NULL, $parameters=NULL) { |
|
122 | 122 | $form=$this->getForm(); |
123 | - $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
|
124 | - if(\is_array($parameters)) |
|
125 | - $params=\array_merge($params,$parameters); |
|
123 | + $params=["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url, "stopPropagation"=>true]; |
|
124 | + if (\is_array($parameters)) |
|
125 | + $params=\array_merge($params, $parameters); |
|
126 | 126 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
127 | 127 | return $this; |
128 | 128 | } |
129 | 129 | |
130 | - public function addReset($identifier,$value,$cssStyle=NULL){ |
|
131 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
130 | + public function addReset($identifier, $value, $cssStyle=NULL) { |
|
131 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
132 | 132 | $bt->setProperty("type", "reset"); |
133 | 133 | return $bt; |
134 | 134 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @param string $jsCode |
139 | 139 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
140 | 140 | */ |
141 | - public function onValid($jsCode){ |
|
141 | + public function onValid($jsCode) { |
|
142 | 142 | $form=$this->getForm(); |
143 | 143 | $form->addValidationParam("onValid", "%function(){".$jsCode."}%"); |
144 | 144 | return $form; |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | * @param string $jsCode can use event and fields parameters |
150 | 150 | * @return HtmlForm |
151 | 151 | */ |
152 | - public function onSuccess($jsCode){ |
|
152 | + public function onSuccess($jsCode) { |
|
153 | 153 | $form=$this->getForm(); |
154 | - $form->addValidationParam("onSuccess", $jsCode,"%function(event,fields){","}%"); |
|
154 | + $form->addValidationParam("onSuccess", $jsCode, "%function(event,fields){", "}%"); |
|
155 | 155 | return $form; |
156 | 156 | } |
157 | 157 | } |
@@ -20,19 +20,19 @@ discard block |
||
20 | 20 | |
21 | 21 | public function __construct($identifier) { |
22 | 22 | parent::__construct($identifier, "tr", ""); |
23 | - $this->_states=[ State::ACTIVE,State::POSITIVE,State::NEGATIVE,State::WARNING,State::ERROR,State::DISABLED ]; |
|
23 | + $this->_states=[State::ACTIVE, State::POSITIVE, State::NEGATIVE, State::WARNING, State::ERROR, State::DISABLED]; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function setColCount($colCount) { |
27 | 27 | $count=$this->count(); |
28 | - for($i=$count; $i < $colCount; $i++) { |
|
28 | + for ($i=$count; $i<$colCount; $i++) { |
|
29 | 29 | $item=$this->addItem(NULL); |
30 | 30 | $item->setTagName($this->_tdTagName); |
31 | 31 | } |
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | - public function getColCount(){ |
|
35 | + public function getColCount() { |
|
36 | 36 | return $this->count(); |
37 | 37 | } |
38 | 38 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param mixed $values |
69 | 69 | */ |
70 | 70 | public function setValues($values=array()) { |
71 | - return $this->_addOrSetValues($values, function(HtmlTD &$cell,$value){$cell->setValue($value);}); |
|
71 | + return $this->_addOrSetValues($values, function(HtmlTD &$cell, $value) {$cell->setValue($value); }); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,27 +76,27 @@ discard block |
||
76 | 76 | * @param mixed $values |
77 | 77 | */ |
78 | 78 | public function addValues($values=array()) { |
79 | - return $this->_addOrSetValues($values, function(HtmlTD &$cell,$value){$cell->addValue($value);}); |
|
79 | + return $this->_addOrSetValues($values, function(HtmlTD &$cell, $value) {$cell->addValue($value); }); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Sets or adds values to the row cols |
84 | 84 | * @param mixed $values |
85 | 85 | */ |
86 | - protected function _addOrSetValues($values,$callback) { |
|
86 | + protected function _addOrSetValues($values, $callback) { |
|
87 | 87 | $count=$this->count(); |
88 | 88 | if (!\is_array($values)) { |
89 | 89 | $values=\array_fill(0, $count, $values); |
90 | 90 | } else { |
91 | - if (JArray::isAssociative($values) === true) { |
|
91 | + if (JArray::isAssociative($values)===true) { |
|
92 | 92 | $values=\array_values($values); |
93 | 93 | } |
94 | 94 | } |
95 | 95 | $count=\min(\sizeof($values), $count); |
96 | 96 | |
97 | - for($i=0; $i < $count; $i++) { |
|
97 | + for ($i=0; $i<$count; $i++) { |
|
98 | 98 | $cell=$this->content[$i]; |
99 | - $callback($cell,$values[$i]); |
|
99 | + $callback($cell, $values[$i]); |
|
100 | 100 | } |
101 | 101 | return $this; |
102 | 102 | } |
@@ -120,24 +120,24 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | public function getColPosition($colIndex) { |
123 | - if($this->_container->_isMerged()!==true) |
|
123 | + if ($this->_container->_isMerged()!==true) |
|
124 | 124 | return $colIndex; |
125 | 125 | $pos=0; |
126 | 126 | $rows=$this->_container->getContent(); |
127 | - for($i=0; $i < $this->_row; $i++) { |
|
127 | + for ($i=0; $i<$this->_row; $i++) { |
|
128 | 128 | $max=\min($colIndex, $rows[$i]->count()); |
129 | - for($j=0; $j < $max; $j++) { |
|
129 | + for ($j=0; $j<$max; $j++) { |
|
130 | 130 | $rowspan=$rows[$i]->getItem($j)->getRowspan(); |
131 | - if ($rowspan + $i > $this->_row) |
|
131 | + if ($rowspan+$i>$this->_row) |
|
132 | 132 | $pos++; |
133 | 133 | } |
134 | 134 | } |
135 | - if ($pos > $colIndex) |
|
135 | + if ($pos>$colIndex) |
|
136 | 136 | return NULL; |
137 | 137 | $count=$this->count(); |
138 | - for($i=0; $i < $count; $i++) { |
|
138 | + for ($i=0; $i<$count; $i++) { |
|
139 | 139 | $pos+=$this->content[$i]->getColspan(); |
140 | - if ($pos >= $colIndex + 1) |
|
140 | + if ($pos>=$colIndex+1) |
|
141 | 141 | return $i; |
142 | 142 | } |
143 | 143 | return null; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | public function conditionalCellFormat($callback, $format) { |
147 | 147 | $cells=$this->content; |
148 | - foreach ( $cells as $cell ) { |
|
148 | + foreach ($cells as $cell) { |
|
149 | 149 | $cell->conditionalCellFormat($callback, $format); |
150 | 150 | } |
151 | 151 | return $this; |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | |
161 | 161 | public function containsStr($needle) { |
162 | 162 | $cells=$this->content; |
163 | - foreach ( $cells as $cell ) { |
|
164 | - if (\strpos($cell->getContent(), $needle) !== false) |
|
163 | + foreach ($cells as $cell) { |
|
164 | + if (\strpos($cell->getContent(), $needle)!==false) |
|
165 | 165 | return true; |
166 | 166 | } |
167 | 167 | return false; |
@@ -174,13 +174,13 @@ discard block |
||
174 | 174 | |
175 | 175 | public function applyCells($callback) { |
176 | 176 | $cells=$this->content; |
177 | - foreach ( $cells as $cell ) { |
|
177 | + foreach ($cells as $cell) { |
|
178 | 178 | $cell->apply($callback); |
179 | 179 | } |
180 | 180 | return $this; |
181 | 181 | } |
182 | 182 | |
183 | - public function toDelete($colIndex){ |
|
183 | + public function toDelete($colIndex) { |
|
184 | 184 | $this->getItem($colIndex)->toDelete(); |
185 | 185 | return $this; |
186 | 186 | } |
@@ -12,13 +12,13 @@ |
||
12 | 12 | * @param array $parameters |
13 | 13 | * @return Response |
14 | 14 | */ |
15 | - public function renderView($viewName,$parameters=[]){ |
|
15 | + public function renderView($viewName, $parameters=[]) { |
|
16 | 16 | $twig=$this->container->get("twig"); |
17 | 17 | $this->compile($parameters); |
18 | 18 | return new Response($twig->render($viewName, $parameters)); |
19 | 19 | } |
20 | 20 | |
21 | - public function generateUrl($path){ |
|
21 | + public function generateUrl($path) { |
|
22 | 22 | $request=Request::createFromGlobals(); |
23 | 23 | return $request->getBaseUrl().$path; |
24 | 24 | } |
@@ -6,8 +6,8 @@ |
||
6 | 6 | |
7 | 7 | class JquerySemantic extends Jquery_ { |
8 | 8 | |
9 | - public function __construct(RouterInterface $router,ContainerInterface $container ){ |
|
10 | - parent::__construct(["semantic"=>true,"defer"=>true],$router); |
|
9 | + public function __construct(RouterInterface $router, ContainerInterface $container) { |
|
10 | + parent::__construct(["semantic"=>true, "defer"=>true], $router); |
|
11 | 11 | $this->container=$container; |
12 | 12 | } |
13 | 13 | } |
@@ -6,8 +6,8 @@ |
||
6 | 6 | |
7 | 7 | class JqueryBootstrap extends Jquery_ { |
8 | 8 | |
9 | - public function __construct(RouterInterface $router,ContainerInterface $container ){ |
|
10 | - parent::__construct(["bootstrap"=>true,"defer"=>true],$router); |
|
9 | + public function __construct(RouterInterface $router, ContainerInterface $container) { |
|
10 | + parent::__construct(["bootstrap"=>true, "defer"=>true], $router); |
|
11 | 11 | $this->container=$container; |
12 | 12 | } |
13 | 13 | } |
@@ -12,34 +12,34 @@ discard block |
||
12 | 12 | use Ajax\semantic\html\base\traits\MenuItemTrait; |
13 | 13 | |
14 | 14 | class HtmlDropdownItem extends HtmlSemDoubleElement { |
15 | - use IconTrait,MenuItemTrait; |
|
16 | - public function __construct($identifier, $content="",$value=NULL,$image=NULL,$description=NULL) { |
|
15 | + use IconTrait, MenuItemTrait; |
|
16 | + public function __construct($identifier, $content="", $value=NULL, $image=NULL, $description=NULL) { |
|
17 | 17 | parent::__construct($identifier, "a"); |
18 | 18 | $this->setClass("item"); |
19 | 19 | $this->setContent($content); |
20 | - if($value!==NULL) |
|
20 | + if ($value!==NULL) |
|
21 | 21 | $this->setData($value); |
22 | - if($image!==NULL) |
|
22 | + if ($image!==NULL) |
|
23 | 23 | $this->asMiniAvatar($image); |
24 | - if($description!==NULL) |
|
24 | + if ($description!==NULL) |
|
25 | 25 | $this->setDescription($description); |
26 | 26 | } |
27 | 27 | |
28 | - public function setDescription($description){ |
|
29 | - $descO=new HtmlDoubleElement("desc-".$this->identifier,"span"); |
|
28 | + public function setDescription($description) { |
|
29 | + $descO=new HtmlDoubleElement("desc-".$this->identifier, "span"); |
|
30 | 30 | $descO->setClass("description"); |
31 | 31 | $descO->setContent($description); |
32 | - return $this->addContent($descO,true); |
|
32 | + return $this->addContent($descO, true); |
|
33 | 33 | } |
34 | 34 | |
35 | - public function setData($value){ |
|
35 | + public function setData($value) { |
|
36 | 36 | $this->setProperty("data-value", $value); |
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | - public function asOption(){ |
|
40 | + public function asOption() { |
|
41 | 41 | $this->tagName="option"; |
42 | - if($this->getProperty("data-value")!==null) |
|
42 | + if ($this->getProperty("data-value")!==null) |
|
43 | 43 | $this->setProperty("value", $this->getProperty("data-value")); |
44 | 44 | } |
45 | 45 | |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @param string $image the image src |
48 | 48 | * @return HtmlImg |
49 | 49 | */ |
50 | - public function asMiniAvatar($image){ |
|
50 | + public function asMiniAvatar($image) { |
|
51 | 51 | $this->tagName="div"; |
52 | - $img=new HtmlImg("image-".$this->identifier,$image); |
|
52 | + $img=new HtmlImg("image-".$this->identifier, $image); |
|
53 | 53 | $img->setClass("ui mini avatar image"); |
54 | - $this->addContent($img,true); |
|
54 | + $this->addContent($img, true); |
|
55 | 55 | return $this; |
56 | 56 | } |
57 | 57 | |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | * @param string $icon |
61 | 61 | * @return HtmlDropdownItem |
62 | 62 | */ |
63 | - public function asIcon($caption,$icon){ |
|
63 | + public function asIcon($caption, $icon) { |
|
64 | 64 | $this->setContent($caption); |
65 | - $this->addContent(new HtmlIcon("", $icon),true); |
|
65 | + $this->addContent(new HtmlIcon("", $icon), true); |
|
66 | 66 | return $this; |
67 | 67 | } |
68 | 68 | |
@@ -71,23 +71,23 @@ discard block |
||
71 | 71 | * @param string $color |
72 | 72 | * @return HtmlDropdownItem |
73 | 73 | */ |
74 | - public function asCircularLabel($caption,$color){ |
|
74 | + public function asCircularLabel($caption, $color) { |
|
75 | 75 | $this->setContent($caption); |
76 | 76 | $lbl=new HtmlLabel(""); |
77 | 77 | $lbl->setCircular()->setColor($color)->setEmpty(); |
78 | - $this->addContent($lbl,true); |
|
78 | + $this->addContent($lbl, true); |
|
79 | 79 | return $this; |
80 | 80 | } |
81 | 81 | |
82 | 82 | |
83 | 83 | |
84 | 84 | public function addMenuItem($items) { |
85 | - $menu=new HtmlMenu("menu-" . $this->identifier, $items); |
|
85 | + $menu=new HtmlMenu("menu-".$this->identifier, $items); |
|
86 | 86 | $content=$this->content; |
87 | 87 | $this->setTagName("div"); |
88 | 88 | $this->setProperty("class", "item"); |
89 | 89 | $icon=new HtmlIcon("", "dropdown"); |
90 | - $this->content=[$icon,new HtmlSemDoubleElement("","span","text",$content),$menu]; |
|
90 | + $this->content=[$icon, new HtmlSemDoubleElement("", "span", "text", $content), $menu]; |
|
91 | 91 | return $menu; |
92 | 92 | } |
93 | 93 | |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | * @param string $icon |
97 | 97 | * @return HtmlDropdownItem |
98 | 98 | */ |
99 | - public static function searchInput($placeholder=NULL,$icon=NULL){ |
|
100 | - return (new HtmlDropdownItem(""))->asSearchInput($placeholder,$icon); |
|
99 | + public static function searchInput($placeholder=NULL, $icon=NULL) { |
|
100 | + return (new HtmlDropdownItem(""))->asSearchInput($placeholder, $icon); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | 104 | * @return HtmlDropdownItem |
105 | 105 | */ |
106 | - public static function divider(){ |
|
106 | + public static function divider() { |
|
107 | 107 | return (new HtmlDropdownItem(""))->asDivider(); |
108 | 108 | } |
109 | 109 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * @param string $icon |
113 | 113 | * @return HtmlDropdownItem |
114 | 114 | */ |
115 | - public static function header($caption=NULL,$icon=NULL){ |
|
116 | - return (new HtmlDropdownItem(""))->asHeader($caption,$icon); |
|
115 | + public static function header($caption=NULL, $icon=NULL) { |
|
116 | + return (new HtmlDropdownItem(""))->asHeader($caption, $icon); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @param string $color |
122 | 122 | * @return HtmlDropdownItem |
123 | 123 | */ |
124 | - public static function circular($caption,$color){ |
|
125 | - return (new HtmlDropdownItem(""))->asCircularLabel($caption,$color); |
|
124 | + public static function circular($caption, $color) { |
|
125 | + return (new HtmlDropdownItem(""))->asCircularLabel($caption, $color); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | * @param string $icon |
131 | 131 | * @return HtmlDropdownItem |
132 | 132 | */ |
133 | - public static function icon($caption,$icon){ |
|
134 | - return (new HtmlDropdownItem(""))->asIcon($caption,$icon); |
|
133 | + public static function icon($caption, $icon) { |
|
134 | + return (new HtmlDropdownItem(""))->asIcon($caption, $icon); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param string $image |
140 | 140 | * @return HtmlDropdownItem |
141 | 141 | */ |
142 | - public static function avatar($caption,$image){ |
|
143 | - return (new HtmlDropdownItem("",$caption))->asMiniAvatar($image); |
|
142 | + public static function avatar($caption, $image) { |
|
143 | + return (new HtmlDropdownItem("", $caption))->asMiniAvatar($image); |
|
144 | 144 | } |
145 | 145 | } |