@@ -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 |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | * @author jc |
10 | 10 | * @property BaseWidget $_self |
11 | 11 | */ |
12 | -trait BaseHtmlPropertiesTrait{ |
|
12 | +trait BaseHtmlPropertiesTrait { |
|
13 | 13 | |
14 | - protected $properties=array (); |
|
14 | + protected $properties=array(); |
|
15 | 15 | abstract protected function ctrl($name, $value, $typeCtrl); |
16 | 16 | abstract protected function removeOldValues(&$oldValue, $allValues); |
17 | - abstract protected function _getElementBy($callback,$elements); |
|
17 | + abstract protected function _getElementBy($callback, $elements); |
|
18 | 18 | public function getProperties() { |
19 | 19 | return $this->_self->properties; |
20 | 20 | } |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | |
41 | 41 | public function addToProperty($name, $value, $separator=" ") { |
42 | 42 | if (\is_array($value)) { |
43 | - foreach ( $value as $v ) { |
|
43 | + foreach ($value as $v) { |
|
44 | 44 | $this->_self->addToProperty($name, $v, $separator); |
45 | 45 | } |
46 | - } else if ($value !== "" && $this->_self->propertyContains($name, $value) === false) { |
|
46 | + } else if ($value!=="" && $this->_self->propertyContains($name, $value)===false) { |
|
47 | 47 | $v=@$this->_self->properties[$name]; |
48 | - if (isset($v) && $v !== "") |
|
49 | - $v=$v . $separator . $value; |
|
48 | + if (isset($v) && $v!=="") |
|
49 | + $v=$v.$separator.$value; |
|
50 | 50 | else |
51 | 51 | $v=$value; |
52 | 52 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | public function addToPropertyCtrlCheck($name, $value, $typeCtrl) { |
87 | - if ($this->_self->ctrl($name, $value, $typeCtrl) === true) { |
|
87 | + if ($this->_self->ctrl($name, $value, $typeCtrl)===true) { |
|
88 | 88 | return $this->_self->addToProperty($name, $value); |
89 | 89 | } |
90 | 90 | return $this; |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
108 | - if ($this->_self->ctrl($name, $value, $typeCtrl) === true) |
|
108 | + if ($this->_self->ctrl($name, $value, $typeCtrl)===true) |
|
109 | 109 | return $this->_self->setProperty($name, $value); |
110 | 110 | return $this; |
111 | 111 | } |
112 | 112 | |
113 | - protected function getElementByPropertyValue($propertyName,$value, $elements) { |
|
114 | - return $this->_self->_getElementBy(function($element) use ($propertyName,$value){return $element->propertyContains($propertyName, $value) === true;}, $elements); |
|
113 | + protected function getElementByPropertyValue($propertyName, $value, $elements) { |
|
114 | + return $this->_self->_getElementBy(function($element) use ($propertyName, $value){return $element->propertyContains($propertyName, $value)===true; }, $elements); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | \ No newline at end of file |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | * @version 1.3 |
16 | 16 | */ |
17 | 17 | abstract class BaseHtml extends BaseWidget { |
18 | - use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait; |
|
18 | + use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait; |
|
19 | 19 | protected $_template; |
20 | 20 | protected $tagName; |
21 | - protected $_wrapBefore=array (); |
|
22 | - protected $_wrapAfter=array (); |
|
21 | + protected $_wrapBefore=array(); |
|
22 | + protected $_wrapAfter=array(); |
|
23 | 23 | protected $_bsComponent; |
24 | 24 | protected $_compiled=false; |
25 | 25 | |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | */ |
31 | 31 | abstract public function run(JsUtils $js); |
32 | 32 | |
33 | - private function _callSetter($setter,$key,$value,&$array){ |
|
33 | + private function _callSetter($setter, $key, $value, &$array) { |
|
34 | 34 | $result=false; |
35 | 35 | if (method_exists($this, $setter) && !JString::startswith($key, "_")) { |
36 | 36 | try { |
37 | 37 | $this->$setter($value); |
38 | 38 | unset($array[$key]); |
39 | 39 | $result=true; |
40 | - } catch ( \Exception $e ) { |
|
40 | + }catch (\Exception $e) { |
|
41 | 41 | $result=false; |
42 | 42 | } |
43 | 43 | } |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | protected function getTemplate(JsUtils $js=NULL) { |
48 | - return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
48 | + return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | protected function ctrl($name, $value, $typeCtrl) { |
52 | 52 | if (\is_array($typeCtrl)) { |
53 | - if (array_search($value, $typeCtrl) === false) { |
|
54 | - throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
53 | + if (array_search($value, $typeCtrl)===false) { |
|
54 | + throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
55 | 55 | } |
56 | 56 | } else { |
57 | 57 | if (!$typeCtrl($value)) { |
58 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
58 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | return true; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | |
66 | 66 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
67 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
67 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
68 | 68 | return $name=$value; |
69 | 69 | } |
70 | 70 | return $this; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
74 | 74 | if (\is_array($typeCtrl)) { |
75 | 75 | $this->removeOldValues($name, $typeCtrl); |
76 | - $name.=$separator . $value; |
|
76 | + $name.=$separator.$value; |
|
77 | 77 | } |
78 | 78 | return $this; |
79 | 79 | } |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | |
82 | 82 | |
83 | 83 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
84 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
84 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
85 | 85 | if (\is_array($typeCtrl)) { |
86 | 86 | $this->removeOldValues($name, $typeCtrl); |
87 | 87 | } |
88 | - $name.=$separator . $value; |
|
88 | + $name.=$separator.$value; |
|
89 | 89 | } |
90 | 90 | return $this; |
91 | 91 | } |
92 | 92 | |
93 | 93 | protected function addToMember(&$name, $value, $separator=" ") { |
94 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
94 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 | |
@@ -102,18 +102,18 @@ discard block |
||
102 | 102 | $oldValue=trim($oldValue); |
103 | 103 | } |
104 | 104 | |
105 | - protected function _getElementBy($callback,$elements){ |
|
105 | + protected function _getElementBy($callback, $elements) { |
|
106 | 106 | if (\is_array($elements)) { |
107 | 107 | $elements=\array_values($elements); |
108 | 108 | $flag=false; |
109 | 109 | $index=0; |
110 | - while ( !$flag && $index < sizeof($elements) ) { |
|
110 | + while (!$flag && $index<sizeof($elements)) { |
|
111 | 111 | if ($elements[$index] instanceof BaseHtml) |
112 | 112 | $flag=($callback($elements[$index])); |
113 | 113 | $index++; |
114 | 114 | } |
115 | - if ($flag === true) |
|
116 | - return $elements[$index - 1]; |
|
115 | + if ($flag===true) |
|
116 | + return $elements[$index-1]; |
|
117 | 117 | } elseif ($elements instanceof BaseHtml) { |
118 | 118 | if ($callback($elements)) |
119 | 119 | return $elements; |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | public function fromArray($array) { |
144 | - foreach ( $this as $key => $value ) { |
|
145 | - if(array_key_exists($key, $array)===true) |
|
146 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
144 | + foreach ($this as $key => $value) { |
|
145 | + if (array_key_exists($key, $array)===true) |
|
146 | + $this->_callSetter("set".ucfirst($key), $key, $array[$key], $array); |
|
147 | 147 | } |
148 | - foreach ( $array as $key => $value ) { |
|
149 | - if($this->_callSetter($key, $key, $value, $array)===false){ |
|
150 | - $this->_callSetter("set" . ucfirst($key), $key, $value, $array); |
|
148 | + foreach ($array as $key => $value) { |
|
149 | + if ($this->_callSetter($key, $key, $value, $array)===false) { |
|
150 | + $this->_callSetter("set".ucfirst($key), $key, $value, $array); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | return $array; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | |
156 | 156 | public function fromDatabaseObjects($objects, $function) { |
157 | 157 | if (isset($objects)) { |
158 | - foreach ( $objects as $object ) { |
|
158 | + foreach ($objects as $object) { |
|
159 | 159 | $this->fromDatabaseObject($object, $function); |
160 | 160 | } |
161 | 161 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | |
178 | 178 | public function getElementById($identifier, $elements) { |
179 | - return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements); |
|
179 | + return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | public function getBsComponent() { |
@@ -189,11 +189,11 @@ discard block |
||
189 | 189 | } |
190 | 190 | |
191 | 191 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
192 | - if(!$this->_compiled){ |
|
193 | - if(isset($js)){ |
|
192 | + if (!$this->_compiled) { |
|
193 | + if (isset($js)) { |
|
194 | 194 | $beforeCompile=$js->getParam("beforeCompileHtml"); |
195 | - if(\is_callable($beforeCompile)){ |
|
196 | - $beforeCompile($this,$js,$view); |
|
195 | + if (\is_callable($beforeCompile)) { |
|
196 | + $beforeCompile($this, $js, $view); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | $this->_compiled=true; |
@@ -201,21 +201,21 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
204 | - $this->compile_once($js,$view); |
|
204 | + $this->compile_once($js, $view); |
|
205 | 205 | $result=$this->getTemplate($js); |
206 | - foreach ( $this as $key => $value ) { |
|
207 | - if (JString::startswith($key, "_") === false && $key !== "events") { |
|
206 | + foreach ($this as $key => $value) { |
|
207 | + if (JString::startswith($key, "_")===false && $key!=="events") { |
|
208 | 208 | if (\is_array($value)) { |
209 | 209 | $v=PropertyWrapper::wrap($value, $js); |
210 | 210 | } else { |
211 | 211 | $v=$value; |
212 | 212 | } |
213 | - $result=str_ireplace("%" . $key . "%", $v, $result); |
|
213 | + $result=str_ireplace("%".$key."%", $v, $result); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | if (isset($js)===true) { |
217 | 217 | $this->run($js); |
218 | - if (isset($view) === true) { |
|
218 | + if (isset($view)===true) { |
|
219 | 219 | $js->addViewElement($this->_identifier, $result, $view); |
220 | 220 | } |
221 | 221 | } |
@@ -21,83 +21,83 @@ 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 | $this->_generateFields($form, [$v], $headers, $i, $wrappers); |
64 | 64 | $i++; |
65 | 65 | } |
66 | - }else{ |
|
66 | + } else { |
|
67 | 67 | $separators[]=$count; |
68 | - for($i=0;$i<$size;$i++){ |
|
69 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
68 | + for ($i=0; $i<$size; $i++) { |
|
69 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
70 | 70 | $this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers); |
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - protected function _generateFields($form,$values,$headers,$sepFirst,$wrappers){ |
|
75 | + protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers) { |
|
76 | 76 | $wrapper=null; |
77 | - if(isset($headers[$sepFirst+1])) |
|
78 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
79 | - if(isset($wrappers[$sepFirst+1])){ |
|
77 | + if (isset($headers[$sepFirst+1])) |
|
78 | + $form->addHeader($headers[$sepFirst+1], 4, true); |
|
79 | + if (isset($wrappers[$sepFirst+1])) { |
|
80 | 80 | $wrapper=$wrappers[$sepFirst+1]; |
81 | 81 | } |
82 | - if(\sizeof($values)===1){ |
|
82 | + if (\sizeof($values)===1) { |
|
83 | 83 | $added=$form->addField($values[0]); |
84 | - }elseif(\sizeof($values)>1){ |
|
84 | + }elseif (\sizeof($values)>1) { |
|
85 | 85 | $added=$form->addFields($values); |
86 | - }else |
|
86 | + } else |
|
87 | 87 | return; |
88 | - if(isset($wrapper)){ |
|
89 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
88 | + if (isset($wrapper)) { |
|
89 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @return HtmlForm |
95 | 95 | */ |
96 | - public function getForm(){ |
|
96 | + public function getForm() { |
|
97 | 97 | return $this->content["form"]; |
98 | 98 | } |
99 | 99 | |
100 | - public function addSeparatorAfter($fieldNum){ |
|
100 | + public function addSeparatorAfter($fieldNum) { |
|
101 | 101 | $fieldNum=$this->_getIndex($fieldNum); |
102 | 102 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
103 | 103 | return $this; |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | return $this; |
113 | 113 | } |
114 | 114 | |
115 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
116 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
117 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
115 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
116 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
117 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
118 | 118 | $button->setProperty("type", "reset"); |
119 | 119 | return $button; |
120 | - }, $index,$attributes); |
|
120 | + }, $index, $attributes); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -136,19 +136,19 @@ discard block |
||
136 | 136 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
137 | 137 | } |
138 | 138 | |
139 | - public function addDividerBefore($index,$title){ |
|
139 | + public function addDividerBefore($index, $title) { |
|
140 | 140 | $index=$this->_getIndex($index); |
141 | 141 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
142 | 142 | return $this; |
143 | 143 | } |
144 | 144 | |
145 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
145 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
146 | 146 | $index=$this->_getIndex($index); |
147 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
147 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
148 | 148 | return $this; |
149 | 149 | } |
150 | 150 | |
151 | - public function run(JsUtils $js){ |
|
151 | + public function run(JsUtils $js) { |
|
152 | 152 | return parent::run($js); |
153 | 153 | } |
154 | 154 | } |
155 | 155 | \ No newline at end of file |
@@ -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 | } |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
303 | - parent::compile_once($js,$view); |
|
303 | + parent::compile_once($js, $view); |
|
304 | 304 | if ($this->propertyContains("class", "sortable")) { |
305 | - $this->addEvent("execute", "$('#" . $this->identifier . "').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
305 | + $this->addEvent("execute", "$('#".$this->identifier."').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
306 | 306 | } |
307 | - if(isset($this->_activeRowSelector)){ |
|
307 | + if (isset($this->_activeRowSelector)) { |
|
308 | 308 | $this->_activeRowSelector->compile(); |
309 | 309 | } |
310 | 310 | } |
@@ -318,13 +318,13 @@ discard block |
||
318 | 318 | public function fromDatabaseObject($object, $function) { |
319 | 319 | $result=$function($object); |
320 | 320 | if (\is_array($result)) { |
321 | - $result= $this->addRow($function($object)); |
|
321 | + $result=$this->addRow($function($object)); |
|
322 | 322 | } else { |
323 | - $result= $this->getBody()->_addRow($result); |
|
323 | + $result=$this->getBody()->_addRow($result); |
|
324 | 324 | } |
325 | - if(isset($this->_afterCompileEvents["onNewRow"])){ |
|
326 | - if(\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
327 | - $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
325 | + if (isset($this->_afterCompileEvents["onNewRow"])) { |
|
326 | + if (\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
327 | + $this->_afterCompileEvents["onNewRow"]($result, $object); |
|
328 | 328 | } |
329 | 329 | return $result; |
330 | 330 | } |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | return $this; |
340 | 340 | } |
341 | 341 | |
342 | - public function refresh(){ |
|
342 | + public function refresh() { |
|
343 | 343 | $this->_footer=$this->getFooter(); |
344 | 344 | $this->addEvent("execute", '$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");'); |
345 | 345 | } |
346 | 346 | |
347 | - public function run(JsUtils $js){ |
|
348 | - $result= parent::run($js); |
|
349 | - if(isset($this->_footer)) |
|
347 | + public function run(JsUtils $js) { |
|
348 | + $result=parent::run($js); |
|
349 | + if (isset($this->_footer)) |
|
350 | 350 | $this->_footer->run($js); |
351 | 351 | return $result; |
352 | 352 | } |
@@ -369,38 +369,38 @@ discard block |
||
369 | 369 | * @param boolean $multiple |
370 | 370 | * @return HtmlTable |
371 | 371 | */ |
372 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
373 | - $this->_activeRowSelector=new ActiveRow($this,$class,$event,$multiple); |
|
372 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
373 | + $this->_activeRowSelector=new ActiveRow($this, $class, $event, $multiple); |
|
374 | 374 | return $this; |
375 | 375 | } |
376 | 376 | |
377 | - public function hideColumn($colIndex){ |
|
378 | - if(isset($this->content["thead"])){ |
|
377 | + public function hideColumn($colIndex) { |
|
378 | + if (isset($this->content["thead"])) { |
|
379 | 379 | $this->content["thead"]->hideColumn($colIndex); |
380 | 380 | } |
381 | 381 | $this->content["tbody"]->hideColumn($colIndex); |
382 | - if(isset($this->content["tfoot"])){ |
|
382 | + if (isset($this->content["tfoot"])) { |
|
383 | 383 | $this->content["tfoot"]->hideColumn($colIndex); |
384 | 384 | } |
385 | 385 | return $this; |
386 | 386 | } |
387 | 387 | |
388 | - public function setColWidth($colIndex,$width){ |
|
388 | + public function setColWidth($colIndex, $width) { |
|
389 | 389 | $part=$this->_getFirstPart(); |
390 | - if($part!==null && $part->count()>0) |
|
390 | + if ($part!==null && $part->count()>0) |
|
391 | 391 | $part->getCell(0, $colIndex)->setWidth($width); |
392 | 392 | return $this; |
393 | 393 | } |
394 | 394 | |
395 | - public function setColWidths($widths){ |
|
395 | + public function setColWidths($widths) { |
|
396 | 396 | $part=$this->_getFirstPart(); |
397 | - if($part!==null && $part->count()>0){ |
|
397 | + if ($part!==null && $part->count()>0) { |
|
398 | 398 | $count=$part->getColCount(); |
399 | - if(!\is_array($widths)){ |
|
399 | + if (!\is_array($widths)) { |
|
400 | 400 | $widths=\array_fill(0, $count, $widths); |
401 | 401 | } |
402 | - $max=\min(\sizeof($widths),$count); |
|
403 | - for($i=0;$i<$max;$i++){ |
|
402 | + $max=\min(\sizeof($widths), $count); |
|
403 | + for ($i=0; $i<$max; $i++) { |
|
404 | 404 | $part->getCell(0, $i)->setWidth($widths[$i]); |
405 | 405 | } |
406 | 406 | } |
@@ -8,11 +8,11 @@ |
||
8 | 8 | class HtmlCardGroups extends HtmlViewGroups { |
9 | 9 | |
10 | 10 | public function __construct($identifier, $cards=array()) { |
11 | - parent::__construct($identifier, "ui cards",$cards); |
|
11 | + parent::__construct($identifier, "ui cards", $cards); |
|
12 | 12 | } |
13 | 13 | |
14 | - protected function createElement(){ |
|
15 | - return new HtmlCard("card-" . $this->count()); |
|
14 | + protected function createElement() { |
|
15 | + return new HtmlCard("card-".$this->count()); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function newItem($identifier) { |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | abstract class HtmlViewGroups extends HtmlSemCollection { |
10 | 10 | |
11 | - public function __construct($identifier, $uiClass,$items=array()) { |
|
11 | + public function __construct($identifier, $uiClass, $items=array()) { |
|
12 | 12 | parent::__construct($identifier, "div", $uiClass); |
13 | 13 | $this->addItems($items); |
14 | 14 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param int $wide |
41 | 41 | */ |
42 | 42 | public function setWide($wide) { |
43 | - $wide=Wide::getConstants()["W" . $wide]; |
|
43 | + $wide=Wide::getConstants()["W".$wide]; |
|
44 | 44 | return $this->addToPropertyCtrl("class", $wide, Wide::getConstants()); |
45 | 45 | } |
46 | 46 |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class HtmlCard extends HtmlViewItem { |
8 | 8 | |
9 | - public function __construct($identifier,$content=NULL) { |
|
9 | + public function __construct($identifier, $content=NULL) { |
|
10 | 10 | parent::__construct($identifier, "ui card", $content); |
11 | 11 | } |
12 | 12 | } |
13 | 13 | \ No newline at end of file |