@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | */ |
27 | 27 | class DataTable extends Widget { |
28 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait; |
|
28 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait; |
|
29 | 29 | |
30 | 30 | protected $_searchField; |
31 | 31 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | protected $_displayBehavior; |
43 | 43 | |
44 | - protected $_visibleHover = false; |
|
44 | + protected $_visibleHover=false; |
|
45 | 45 | |
46 | 46 | protected $_targetSelector; |
47 | 47 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | protected $_json; |
53 | 53 | |
54 | - protected $_rowClass = "_element"; |
|
54 | + protected $_rowClass="_element"; |
|
55 | 55 | |
56 | 56 | protected $_sortable; |
57 | 57 | |
@@ -61,26 +61,26 @@ discard block |
||
61 | 61 | |
62 | 62 | protected $_paginationToolbar; |
63 | 63 | |
64 | - public function __construct($identifier, $model, $modelInstance = NULL) { |
|
64 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
65 | 65 | parent::__construct($identifier, $model, $modelInstance); |
66 | 66 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
67 | - $this->_urls = []; |
|
68 | - $this->_emptyMessage = new HtmlMessage("", "nothing to display"); |
|
67 | + $this->_urls=[]; |
|
68 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
69 | 69 | $this->_emptyMessage->setIcon("info circle"); |
70 | 70 | } |
71 | 71 | |
72 | 72 | public function run(JsUtils $js) { |
73 | - if ($this->_runned !== true) { |
|
74 | - $offset = $js->scriptCount(); |
|
73 | + if ($this->_runned!==true) { |
|
74 | + $offset=$js->scriptCount(); |
|
75 | 75 | if ($this->_hasCheckboxes && isset($js)) { |
76 | 76 | $this->_runCheckboxes($js); |
77 | 77 | } |
78 | 78 | if ($this->_visibleHover) { |
79 | - $js->execOn("mouseover", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [ |
|
79 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [ |
|
80 | 80 | "preventDefault" => false, |
81 | 81 | "stopPropagation" => true |
82 | 82 | ]); |
83 | - $js->execOn("mouseout", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [ |
|
83 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [ |
|
84 | 84 | "preventDefault" => false, |
85 | 85 | "stopPropagation" => true |
86 | 86 | ]); |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | if (isset($this->_pagination)) |
97 | 97 | $this->_associatePaginationBehavior($js, $offset); |
98 | 98 | $this->_associateSearchFieldBehavior($js, $offset); |
99 | - $this->_runned = true; |
|
99 | + $this->_runned=true; |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | 103 | protected function _generateBehavior($op, $params, JsUtils $js) { |
104 | 104 | if (isset($this->_urls[$op])) { |
105 | - $params = \array_merge($params, [ |
|
105 | + $params=\array_merge($params, [ |
|
106 | 106 | "attr" => "data-ajax" |
107 | 107 | ]); |
108 | - $js->ajaxOnClick("#" . $this->identifier . " ._" . $op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
108 | + $js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -124,21 +124,21 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | public function refreshTD($fieldName, $jquery, $view) { |
127 | - $index = $this->_getIndex($fieldName); |
|
127 | + $index=$this->_getIndex($fieldName); |
|
128 | 128 | $this->compile($jquery, $view); |
129 | 129 | return $this->refreshTR() |
130 | 130 | ->getTable() |
131 | 131 | ->getCell(0, $index); |
132 | 132 | } |
133 | 133 | |
134 | - public function compile(JsUtils $js = NULL, &$view = NULL) { |
|
135 | - if (! $this->_generated) { |
|
134 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
135 | + if (!$this->_generated) { |
|
136 | 136 | if (isset($this->_buttonsColumn)) { |
137 | 137 | $this->_instanceViewer->sortColumnContent($this->_buttonsColumn, $this->_buttons); |
138 | 138 | } |
139 | 139 | $this->_instanceViewer->setInstance($this->_model); |
140 | - $captions = $this->_instanceViewer->getCaptions(); |
|
141 | - $table = $this->content["table"]; |
|
140 | + $captions=$this->_instanceViewer->getCaptions(); |
|
141 | + $table=$this->content["table"]; |
|
142 | 142 | if ($this->_hasCheckboxes) { |
143 | 143 | $this->_generateMainCheckbox($captions); |
144 | 144 | } |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | $this->compileExtraElements($table, $captions); |
154 | 154 | $this->_compileSearchFieldBehavior($js); |
155 | 155 | |
156 | - $this->content = JArray::sortAssociative($this->content, [ |
|
156 | + $this->content=JArray::sortAssociative($this->content, [ |
|
157 | 157 | PositionInTable::BEFORETABLE, |
158 | 158 | "table", |
159 | 159 | PositionInTable::AFTERTABLE |
160 | 160 | ]); |
161 | 161 | $this->_compileForm(); |
162 | 162 | $this->_applyStyleAttributes($table); |
163 | - $this->_generated = true; |
|
163 | + $this->_generated=true; |
|
164 | 164 | } |
165 | 165 | return parent::compile($js, $view); |
166 | 166 | } |
@@ -205,21 +205,21 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | protected function _generateContent($table) { |
208 | - $objects = $this->_modelInstance; |
|
208 | + $objects=$this->_modelInstance; |
|
209 | 209 | if (isset($this->_pagination)) { |
210 | - $objects = $this->_pagination->getObjects($this->_modelInstance); |
|
210 | + $objects=$this->_pagination->getObjects($this->_modelInstance); |
|
211 | 211 | } |
212 | 212 | InstanceViewer::setIndex(0); |
213 | - $fields = $this->_instanceViewer->getSimpleProperties(); |
|
214 | - $groupByFields = $this->_instanceViewer->getGroupByFields(); |
|
215 | - if (! is_array($groupByFields)) { |
|
216 | - $table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields) { |
|
213 | + $fields=$this->_instanceViewer->getSimpleProperties(); |
|
214 | + $groupByFields=$this->_instanceViewer->getGroupByFields(); |
|
215 | + if (!is_array($groupByFields)) { |
|
216 | + $table->fromDatabaseObjects($objects, function($instance) use ($table, $fields) { |
|
217 | 217 | return $this->_generateRow($instance, $fields, $table); |
218 | 218 | }); |
219 | 219 | } else { |
220 | - $activeValues = array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null)); |
|
221 | - $uuids = []; |
|
222 | - $table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids) { |
|
220 | + $activeValues=array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null)); |
|
221 | + $uuids=[]; |
|
222 | + $table->fromDatabaseObjects($objects, function($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids) { |
|
223 | 223 | $this->_instanceViewer->setInstance($instance); |
224 | 224 | foreach ($groupByFields as $index => $gbField) { |
225 | 225 | $this->_generateGroupByRow($index, $gbField, $table, $fields, $activeValues, $uuids); |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | return $this->_generateRow($instance, $fields, $table, null, $uuids); |
228 | 228 | }); |
229 | 229 | } |
230 | - if ($table->getRowCount() == 0) { |
|
231 | - $result = $table->addRow(); |
|
230 | + if ($table->getRowCount()==0) { |
|
231 | + $result=$table->addRow(); |
|
232 | 232 | $result->mergeRow(); |
233 | 233 | $result->setValues([ |
234 | 234 | $this->_emptyMessage |
@@ -237,20 +237,20 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | protected function _generateGroupByRow($index, $gbField, $table, $fields, &$activeValues, &$uuids) { |
240 | - $newValue = $this->_instanceViewer->getValue($gbField); |
|
241 | - if ($this->getElementContent($activeValues[$gbField]) !== $this->getElementContent($newValue)) { |
|
242 | - if ($index == 0) { |
|
243 | - $uuids = []; |
|
240 | + $newValue=$this->_instanceViewer->getValue($gbField); |
|
241 | + if ($this->getElementContent($activeValues[$gbField])!==$this->getElementContent($newValue)) { |
|
242 | + if ($index==0) { |
|
243 | + $uuids=[]; |
|
244 | 244 | } |
245 | - $uuid = uniqid("grp"); |
|
246 | - $uuids[$gbField] = $uuid; |
|
247 | - $id = $this->_instanceViewer->getIdentifier(); |
|
248 | - $result = $table->addMergeRow(sizeof($fields) + 1, $newValue); |
|
249 | - $result->setIdentifier($this->identifier . "-tr-gb-" . $id); |
|
245 | + $uuid=uniqid("grp"); |
|
246 | + $uuids[$gbField]=$uuid; |
|
247 | + $id=$this->_instanceViewer->getIdentifier(); |
|
248 | + $result=$table->addMergeRow(sizeof($fields)+1, $newValue); |
|
249 | + $result->setIdentifier($this->identifier."-tr-gb-".$id); |
|
250 | 250 | $result->setProperty("data-ajax", $id); |
251 | 251 | $result->setProperty("data-group", $uuid); |
252 | 252 | $result->addToProperty("class", $this->_rowClass); |
253 | - $activeValues[$gbField] = $newValue; |
|
253 | + $activeValues[$gbField]=$newValue; |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | public function getFieldValue($index) { |
265 | - $index = $this->_getIndex($index); |
|
265 | + $index=$this->_getIndex($index); |
|
266 | 266 | if (is_numeric($index)) { |
267 | - $values = $this->_instanceViewer->getValues(); |
|
267 | + $values=$this->_instanceViewer->getValues(); |
|
268 | 268 | if (isset($values[$index])) { |
269 | 269 | return $values[$index]; |
270 | 270 | } |
@@ -272,31 +272,31 @@ discard block |
||
272 | 272 | return null; |
273 | 273 | } |
274 | 274 | |
275 | - protected function _generateRow($instance, $fields, &$table, $checkedClass = null, $uuids = null) { |
|
275 | + protected function _generateRow($instance, $fields, &$table, $checkedClass=null, $uuids=null) { |
|
276 | 276 | $this->_instanceViewer->setInstance($instance); |
277 | - InstanceViewer::$index ++; |
|
278 | - $values = $this->_instanceViewer->getValues(); |
|
279 | - $id = $this->_instanceViewer->getIdentifier(); |
|
280 | - $dataAjax = $id; |
|
281 | - $id = $this->cleanIdentifier($id); |
|
277 | + InstanceViewer::$index++; |
|
278 | + $values=$this->_instanceViewer->getValues(); |
|
279 | + $id=$this->_instanceViewer->getIdentifier(); |
|
280 | + $dataAjax=$id; |
|
281 | + $id=$this->cleanIdentifier($id); |
|
282 | 282 | if ($this->_hasCheckboxes) { |
283 | - $ck = new HtmlCheckbox("ck-" . $this->identifier . "-" . $id, ""); |
|
284 | - $checked = false; |
|
283 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
284 | + $checked=false; |
|
285 | 285 | if (isset($this->_checkedCallback)) { |
286 | - $func = $this->_checkedCallback; |
|
287 | - $checked = $func($instance); |
|
286 | + $func=$this->_checkedCallback; |
|
287 | + $checked=$func($instance); |
|
288 | 288 | } |
289 | 289 | $ck->setChecked($checked); |
290 | 290 | // $ck->setOnChange("event.stopPropagation();"); |
291 | - $field = $ck->getField(); |
|
291 | + $field=$ck->getField(); |
|
292 | 292 | $field->setProperty("value", $dataAjax); |
293 | 293 | $field->setProperty("name", "selection[]"); |
294 | 294 | if (isset($checkedClass)) |
295 | 295 | $field->setClass($checkedClass); |
296 | 296 | \array_unshift($values, $ck); |
297 | 297 | } |
298 | - $result = $table->newRow(); |
|
299 | - $result->setIdentifier($this->identifier . "-tr-" . $id); |
|
298 | + $result=$table->newRow(); |
|
299 | + $result->setIdentifier($this->identifier."-tr-".$id); |
|
300 | 300 | $result->setProperty("data-ajax", $dataAjax); |
301 | 301 | $result->setValues($values); |
302 | 302 | $result->addToProperty("class", $this->_rowClass); |
@@ -309,63 +309,63 @@ discard block |
||
309 | 309 | |
310 | 310 | protected function _generatePagination($table) { |
311 | 311 | if (isset($this->_toolbar)) { |
312 | - if ($this->_toolbarPosition == PositionInTable::FOOTER) |
|
312 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
313 | 313 | $this->_toolbar->setFloated("left"); |
314 | 314 | } |
315 | - $footer = $table->getFooter(); |
|
315 | + $footer=$table->getFooter(); |
|
316 | 316 | $footer->mergeCol(); |
317 | - $this->_paginationToolbar = $this->_pagination->generateMenu($this->identifier); |
|
317 | + $this->_paginationToolbar=$this->_pagination->generateMenu($this->identifier); |
|
318 | 318 | $footer->addValues($this->_paginationToolbar); |
319 | 319 | } |
320 | 320 | |
321 | - protected function _associatePaginationBehavior(JsUtils $js = NULL, $offset = null) { |
|
321 | + protected function _associatePaginationBehavior(JsUtils $js=NULL, $offset=null) { |
|
322 | 322 | if (isset($this->_urls["refresh"])) { |
323 | - $menu = $this->_pagination->getMenu(); |
|
323 | + $menu=$this->_pagination->getMenu(); |
|
324 | 324 | if (isset($menu) && isset($js)) { |
325 | - $js->postOnClick("#" . $menu->getIdentifier() . " .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", $this->getRefreshSelector(), [ |
|
325 | + $js->postOnClick("#".$menu->getIdentifier()." .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}", $this->getRefreshSelector(), [ |
|
326 | 326 | "preventDefault" => false, |
327 | 327 | "jqueryDone" => "replaceWith", |
328 | 328 | "hasLoader" => false, |
329 | - "jsCallback" => '$("#' . $this->identifier . '").trigger("pageChange");$("#' . $this->identifier . '").trigger("activeRowChange");' |
|
329 | + "jsCallback" => '$("#'.$this->identifier.'").trigger("pageChange");$("#'.$this->identifier.'").trigger("activeRowChange");' |
|
330 | 330 | ]); |
331 | - $page = $_POST["p"] ?? null; |
|
331 | + $page=$_POST["p"] ?? null; |
|
332 | 332 | if (isset($page)) { |
333 | - $js->execAtLast('$("#' . $this->getIdentifier() . ' .pagination").children("a.item").removeClass("active");$("#' . $this->getIdentifier() . ' .pagination").children("a.item[data-page=' . $page . ']:not(.no-active)").addClass("active");'); |
|
333 | + $js->execAtLast('$("#'.$this->getIdentifier().' .pagination").children("a.item").removeClass("active");$("#'.$this->getIdentifier().' .pagination").children("a.item[data-page='.$page.']:not(.no-active)").addClass("active");'); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | - protected function _compileSearchFieldBehavior(JsUtils $js = NULL) { |
|
339 | + protected function _compileSearchFieldBehavior(JsUtils $js=NULL) { |
|
340 | 340 | if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) { |
341 | - $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", "#" . $this->identifier . " tbody", [ |
|
341 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'".JString::doubleBackSlashes($this->_model)."'}", "#".$this->identifier." tbody", [ |
|
342 | 342 | "preventDefault" => false, |
343 | 343 | "jqueryDone" => "replaceWith", |
344 | 344 | "hasLoader" => "internal", |
345 | - "jsCallback" => '$("#' . $this->identifier . '").trigger("searchTerminate",[$(self).val()]);' |
|
345 | + "jsCallback" => '$("#'.$this->identifier.'").trigger("searchTerminate",[$(self).val()]);' |
|
346 | 346 | ]); |
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | - protected function _associateSearchFieldBehavior(JsUtils $js = NULL, $offset = null) {} |
|
350 | + protected function _associateSearchFieldBehavior(JsUtils $js=NULL, $offset=null) {} |
|
351 | 351 | |
352 | 352 | protected function _getFieldName($index) { |
353 | - $fieldName = parent::_getFieldName($index); |
|
353 | + $fieldName=parent::_getFieldName($index); |
|
354 | 354 | if (\is_object($fieldName)) |
355 | - $fieldName = "field-" . $index; |
|
356 | - return $fieldName . "[]"; |
|
355 | + $fieldName="field-".$index; |
|
356 | + return $fieldName."[]"; |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | protected function _getFieldCaption($index) { |
360 | 360 | return null; |
361 | 361 | } |
362 | 362 | |
363 | - protected function applyToolbarPosition(string $position, $table, $captions = NULL) { |
|
363 | + protected function applyToolbarPosition(string $position, $table, $captions=NULL) { |
|
364 | 364 | switch ($position) { |
365 | 365 | case PositionInTable::BEFORETABLE: |
366 | 366 | case PositionInTable::AFTERTABLE: |
367 | - if (isset($this->_compileParts) === false) { |
|
368 | - $this->content[$position] = $this->_toolbar; |
|
367 | + if (isset($this->_compileParts)===false) { |
|
368 | + $this->content[$position]=$this->_toolbar; |
|
369 | 369 | } |
370 | 370 | break; |
371 | 371 | case PositionInTable::HEADER: |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | } |
377 | 377 | } |
378 | 378 | |
379 | - protected function _setToolbarPosition($table, $captions = NULL) { |
|
379 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
380 | 380 | if (\is_array($this->_toolbarPosition)) { |
381 | 381 | foreach ($this->_toolbarPosition as $tbp) { |
382 | 382 | $this->applyToolbarPosition($tbp, $table, $captions); |
@@ -402,11 +402,11 @@ discard block |
||
402 | 402 | } |
403 | 403 | |
404 | 404 | private function addToolbarRow($part, $table, $captions) { |
405 | - $hasPart = $table->hasPart($part); |
|
405 | + $hasPart=$table->hasPart($part); |
|
406 | 406 | if ($hasPart) { |
407 | - $row = $table->getPart($part)->addRow(\sizeof($captions)); |
|
407 | + $row=$table->getPart($part)->addRow(\sizeof($captions)); |
|
408 | 408 | } else { |
409 | - $row = $table->getPart($part)->getRow(0); |
|
409 | + $row=$table->getPart($part)->getRow(0); |
|
410 | 410 | } |
411 | 411 | $row->mergeCol(); |
412 | 412 | $row->setValues([ |
@@ -438,12 +438,12 @@ discard block |
||
438 | 438 | */ |
439 | 439 | public function setUrls($urls) { |
440 | 440 | if (\is_array($urls)) { |
441 | - $this->_urls["refresh"] = JArray::getValue($urls, "refresh", 0); |
|
442 | - $this->_urls["edit"] = JArray::getValue($urls, "edit", 1); |
|
443 | - $this->_urls["delete"] = JArray::getValue($urls, "delete", 2); |
|
444 | - $this->_urls["display"] = JArray::getValue($urls, "display", 3); |
|
441 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
442 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
443 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
444 | + $this->_urls["display"]=JArray::getValue($urls, "display", 3); |
|
445 | 445 | } else { |
446 | - $this->_urls = [ |
|
446 | + $this->_urls=[ |
|
447 | 447 | "refresh" => $urls, |
448 | 448 | "edit" => $urls, |
449 | 449 | "delete" => $urls, |
@@ -466,8 +466,8 @@ discard block |
||
466 | 466 | * The number of visible pages in the Pagination component |
467 | 467 | * @return DataTable |
468 | 468 | */ |
469 | - public function paginate($page, $total_rowcount, $items_per_page = 10, $pages_visibles = null) { |
|
470 | - $this->_pagination = new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
469 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
470 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
471 | 471 | return $this; |
472 | 472 | } |
473 | 473 | |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * The number of visible pages in the Pagination component |
483 | 483 | * @return DataTable |
484 | 484 | */ |
485 | - public function autoPaginate($page = 1, $items_per_page = 10, $pages_visibles = 4) { |
|
486 | - $this->_pagination = new Pagination($items_per_page, $pages_visibles, $page); |
|
485 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
486 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
487 | 487 | return $this; |
488 | 488 | } |
489 | 489 | |
@@ -492,10 +492,10 @@ discard block |
||
492 | 492 | * @param array $compileParts |
493 | 493 | * @return DataTable |
494 | 494 | */ |
495 | - public function refresh($compileParts = [ |
|
495 | + public function refresh($compileParts=[ |
|
496 | 496 | 'tbody' |
497 | 497 | ]) { |
498 | - $this->_compileParts = $compileParts; |
|
498 | + $this->_compileParts=$compileParts; |
|
499 | 499 | return $this; |
500 | 500 | } |
501 | 501 | |
@@ -505,14 +505,14 @@ discard block |
||
505 | 505 | * @param string $position |
506 | 506 | * @return \Ajax\common\html\HtmlDoubleElement |
507 | 507 | */ |
508 | - public function addSearchInToolbar($position = Direction::RIGHT) { |
|
508 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
509 | 509 | return $this->addInToolbar($this->getSearchField()) |
510 | 510 | ->setPosition($position); |
511 | 511 | } |
512 | 512 | |
513 | 513 | public function getSearchField() { |
514 | - if (isset($this->_searchField) === false) { |
|
515 | - $this->_searchField = new HtmlInput("search-" . $this->identifier, "search", "", "Search..."); |
|
514 | + if (isset($this->_searchField)===false) { |
|
515 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
516 | 516 | $this->_searchField->addIcon("search", Direction::RIGHT); |
517 | 517 | } |
518 | 518 | return $this->_searchField; |
@@ -540,9 +540,9 @@ discard block |
||
540 | 540 | } |
541 | 541 | |
542 | 542 | protected function getTargetSelector($op) { |
543 | - $result = $this->_targetSelector; |
|
544 | - if (! isset($result[$op])) |
|
545 | - $result = "#" . $this->identifier; |
|
543 | + $result=$this->_targetSelector; |
|
544 | + if (!isset($result[$op])) |
|
545 | + $result="#".$this->identifier; |
|
546 | 546 | return $result[$op]; |
547 | 547 | } |
548 | 548 | |
@@ -554,20 +554,20 @@ discard block |
||
554 | 554 | * @return DataTable |
555 | 555 | */ |
556 | 556 | public function setTargetSelector($_targetSelector) { |
557 | - if (! \is_array($_targetSelector)) { |
|
558 | - $_targetSelector = [ |
|
557 | + if (!\is_array($_targetSelector)) { |
|
558 | + $_targetSelector=[ |
|
559 | 559 | "edit" => $_targetSelector, |
560 | 560 | "delete" => $_targetSelector |
561 | 561 | ]; |
562 | 562 | } |
563 | - $this->_targetSelector = $_targetSelector; |
|
563 | + $this->_targetSelector=$_targetSelector; |
|
564 | 564 | return $this; |
565 | 565 | } |
566 | 566 | |
567 | 567 | public function getRefreshSelector() { |
568 | 568 | if (isset($this->_refreshSelector)) |
569 | 569 | return $this->_refreshSelector; |
570 | - return "#" . $this->identifier . " tbody"; |
|
570 | + return "#".$this->identifier." tbody"; |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | /** |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | * @return DataTable |
577 | 577 | */ |
578 | 578 | public function setRefreshSelector($_refreshSelector) { |
579 | - $this->_refreshSelector = $_refreshSelector; |
|
579 | + $this->_refreshSelector=$_refreshSelector; |
|
580 | 580 | return $this; |
581 | 581 | } |
582 | 582 | |
@@ -588,9 +588,9 @@ discard block |
||
588 | 588 | public function show($modelInstance) { |
589 | 589 | if (\is_array($modelInstance)) { |
590 | 590 | if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
591 | - $modelInstance = \json_decode(\json_encode($modelInstance), FALSE); |
|
591 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
592 | 592 | } |
593 | - $this->_modelInstance = $modelInstance; |
|
593 | + $this->_modelInstance=$modelInstance; |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | public function getRowClass() { |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | * @return DataTable |
605 | 605 | */ |
606 | 606 | public function setRowClass($_rowClass) { |
607 | - $this->_rowClass = $_rowClass; |
|
607 | + $this->_rowClass=$_rowClass; |
|
608 | 608 | return $this; |
609 | 609 | } |
610 | 610 | |
@@ -615,16 +615,16 @@ discard block |
||
615 | 615 | * @return DataTable |
616 | 616 | */ |
617 | 617 | public function setEmptyMessage($_emptyMessage) { |
618 | - $this->_emptyMessage = $_emptyMessage; |
|
618 | + $this->_emptyMessage=$_emptyMessage; |
|
619 | 619 | return $this; |
620 | 620 | } |
621 | 621 | |
622 | - public function setSortable($colIndex = NULL) { |
|
623 | - $this->_sortable = $colIndex; |
|
622 | + public function setSortable($colIndex=NULL) { |
|
623 | + $this->_sortable=$colIndex; |
|
624 | 624 | return $this; |
625 | 625 | } |
626 | 626 | |
627 | - public function setActiveRowSelector($class = "active", $event = "click", $multiple = false) { |
|
627 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
628 | 628 | $this->_self->setActiveRowSelector($class, $event, $multiple); |
629 | 629 | return $this; |
630 | 630 | } |
@@ -634,19 +634,19 @@ discard block |
||
634 | 634 | } |
635 | 635 | |
636 | 636 | public function hideColumn($colIndex) { |
637 | - if (! \is_array($this->_hiddenColumns)) |
|
638 | - $this->_hiddenColumns = []; |
|
639 | - $this->_hiddenColumns[] = $colIndex; |
|
637 | + if (!\is_array($this->_hiddenColumns)) |
|
638 | + $this->_hiddenColumns=[]; |
|
639 | + $this->_hiddenColumns[]=$colIndex; |
|
640 | 640 | return $this; |
641 | 641 | } |
642 | 642 | |
643 | 643 | public function setColWidth($colIndex, $width) { |
644 | - $this->_colWidths[$colIndex] = $width; |
|
644 | + $this->_colWidths[$colIndex]=$width; |
|
645 | 645 | return $this; |
646 | 646 | } |
647 | 647 | |
648 | 648 | public function setColWidths($_colWidths) { |
649 | - $this->_colWidths = $_colWidths; |
|
649 | + $this->_colWidths=$_colWidths; |
|
650 | 650 | return $this; |
651 | 651 | } |
652 | 652 | |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | return $this; |
656 | 656 | } |
657 | 657 | |
658 | - public function trigger($event, $params = "[]") { |
|
658 | + public function trigger($event, $params="[]") { |
|
659 | 659 | return $this->getHtmlComponent()->trigger($event, $params); |
660 | 660 | } |
661 | 661 | |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * @param mixed $_displayBehavior |
694 | 694 | */ |
695 | 695 | public function setDisplayBehavior($_displayBehavior) { |
696 | - $this->_displayBehavior = $_displayBehavior; |
|
696 | + $this->_displayBehavior=$_displayBehavior; |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | /** |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | * @param boolean $_visibleHover |
718 | 718 | */ |
719 | 719 | public function setVisibleHover($_visibleHover) { |
720 | - $this->_visibleHover = $_visibleHover; |
|
720 | + $this->_visibleHover=$_visibleHover; |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | /** |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | return $this->_paginationToolbar; |
729 | 729 | } |
730 | 730 | |
731 | - public function setInverted($recursive = true) { |
|
731 | + public function setInverted($recursive=true) { |
|
732 | 732 | $this->getHtmlComponent()->setInverted($recursive); |
733 | 733 | if ($this->_emptyMessage instanceof HtmlSemDoubleElement) { |
734 | 734 | $this->_emptyMessage->setInverted($recursive); |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | private $ajaxCall; |
18 | 18 | |
19 | - public function __construct($type, $url, $params, $jsCallback = null, $method = 'post', $parameters = [], $prompt = NULL, $value = NULL) { |
|
19 | + public function __construct($type, $url, $params, $jsCallback=null, $method='post', $parameters=[], $prompt=NULL, $value=NULL) { |
|
20 | 20 | parent::__construct($type, $prompt, $value); |
21 | - $parameters = \array_merge([ |
|
21 | + $parameters=\array_merge([ |
|
22 | 22 | 'async' => false, |
23 | 23 | 'url' => $url, |
24 | 24 | 'params' => $params, |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | 'preventDefault' => false, |
30 | 30 | 'responseElement' => null |
31 | 31 | ], $parameters); |
32 | - $this->ajaxCall = new AjaxCall($method, $parameters); |
|
32 | + $this->ajaxCall=new AjaxCall($method, $parameters); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function compile(JsUtils $js) { |
36 | - $js->exec(Rule::custom($this->getType(), "function(value,ruleValue){var result=true;" . $this->ajaxCall->compile($js) . "return result;}"), true); |
|
36 | + $js->exec(Rule::custom($this->getType(), "function(value,ruleValue){var result=true;".$this->ajaxCall->compile($js)."return result;}"), true); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -15,9 +15,9 @@ |
||
15 | 15 | |
16 | 16 | protected $jsFunction; |
17 | 17 | |
18 | - public function __construct($type, $jsFunction, $prompt = NULL, $value = NULL) { |
|
18 | + public function __construct($type, $jsFunction, $prompt=NULL, $value=NULL) { |
|
19 | 19 | parent::__construct($type, $prompt, $value); |
20 | - $this->jsFunction = $jsFunction; |
|
20 | + $this->jsFunction=$jsFunction; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function compile(JsUtils $js) { |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @version 1.001 |
9 | 9 | * Generates a JSON field validator |
10 | 10 | */ |
11 | -class FieldValidation implements \JsonSerializable{ |
|
11 | +class FieldValidation implements \JsonSerializable { |
|
12 | 12 | /** |
13 | 13 | * @var string |
14 | 14 | */ |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | protected $optional; |
33 | 33 | |
34 | - public function __construct($identifier){ |
|
34 | + public function __construct($identifier) { |
|
35 | 35 | $this->identifier=$identifier; |
36 | 36 | $this->rules=[]; |
37 | 37 | } |
@@ -55,31 +55,31 @@ discard block |
||
55 | 55 | * @param string $value |
56 | 56 | * @return Rule |
57 | 57 | */ |
58 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
59 | - if($type instanceof Rule) { |
|
60 | - $rule = $type; |
|
61 | - if($type instanceof CustomRule){ |
|
58 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
59 | + if ($type instanceof Rule) { |
|
60 | + $rule=$type; |
|
61 | + if ($type instanceof CustomRule) { |
|
62 | 62 | $this->customRules[]=$type; |
63 | 63 | $this->hasCustomRules=true; |
64 | 64 | } |
65 | - }elseif(\is_array($type)){ |
|
65 | + }elseif (\is_array($type)) { |
|
66 | 66 | $value=JArray::getValue($type, "value", 2); |
67 | 67 | $prompt=JArray::getValue($type, "prompt", 1); |
68 | 68 | $type=JArray::getValue($type, "type", 0); |
69 | - $rule=new Rule($type,$prompt,$value); |
|
70 | - }else { |
|
71 | - $rule = new Rule($type, $prompt, $value); |
|
69 | + $rule=new Rule($type, $prompt, $value); |
|
70 | + } else { |
|
71 | + $rule=new Rule($type, $prompt, $value); |
|
72 | 72 | } |
73 | 73 | $this->rules[]=$rule; |
74 | 74 | return $rule; |
75 | 75 | } |
76 | 76 | |
77 | - public function jsonSerialize(){ |
|
78 | - $result=["identifier"=>$this->identifier,"rules"=>$this->rules]; |
|
79 | - if($this->optional){ |
|
77 | + public function jsonSerialize() { |
|
78 | + $result=["identifier"=>$this->identifier, "rules"=>$this->rules]; |
|
79 | + if ($this->optional) { |
|
80 | 80 | $result["optional"]=true; |
81 | 81 | } |
82 | - if(isset($this->depends)){ |
|
82 | + if (isset($this->depends)) { |
|
83 | 83 | $result["depends"]=$this->depends; |
84 | 84 | } |
85 | 85 | return $result; |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 | |
98 | - public function compile(JsUtils $js){ |
|
99 | - if($this->hasCustomRules) { |
|
98 | + public function compile(JsUtils $js) { |
|
99 | + if ($this->hasCustomRules) { |
|
100 | 100 | foreach ($this->customRules as $rule) { |
101 | 101 | $rule->compile($js); |
102 | 102 | } |
@@ -16,34 +16,34 @@ discard block |
||
16 | 16 | use FieldTrait; |
17 | 17 | protected $_container; |
18 | 18 | protected $_validation; |
19 | - public function __construct($identifier, $field,$label=NULL) { |
|
20 | - parent::__construct($identifier, "div","field"); |
|
19 | + public function __construct($identifier, $field, $label=NULL) { |
|
20 | + parent::__construct($identifier, "div", "field"); |
|
21 | 21 | $this->content=array(); |
22 | - $this->_states=[State::ERROR,State::DISABLED]; |
|
23 | - if(isset($label) && $label!=="") |
|
22 | + $this->_states=[State::ERROR, State::DISABLED]; |
|
23 | + if (isset($label) && $label!=="") |
|
24 | 24 | $this->setLabel($label); |
25 | 25 | $this->setField($field); |
26 | 26 | $this->_validation=NULL; |
27 | 27 | } |
28 | 28 | |
29 | - public function addPointingLabel($label,$pointing=Direction::NONE){ |
|
30 | - $labelO=new HtmlLabel("",$label); |
|
29 | + public function addPointingLabel($label, $pointing=Direction::NONE) { |
|
30 | + $labelO=new HtmlLabel("", $label); |
|
31 | 31 | $labelO->setPointing($pointing); |
32 | - $this->addContent($labelO,$pointing==="below" || $pointing==="right"); |
|
32 | + $this->addContent($labelO, $pointing==="below" || $pointing==="right"); |
|
33 | 33 | return $labelO; |
34 | 34 | } |
35 | 35 | |
36 | - public function setLabel($label){ |
|
36 | + public function setLabel($label) { |
|
37 | 37 | $labelO=$label; |
38 | - if(\is_string($label)){ |
|
39 | - $labelO=new HtmlSemDoubleElement("","label",""); |
|
38 | + if (\is_string($label)) { |
|
39 | + $labelO=new HtmlSemDoubleElement("", "label", ""); |
|
40 | 40 | $labelO->setContent($label); |
41 | - $labelO->setProperty("for", \str_replace("field-", "",$this->identifier)); |
|
41 | + $labelO->setProperty("for", \str_replace("field-", "", $this->identifier)); |
|
42 | 42 | } |
43 | 43 | $this->content["label"]=$labelO; |
44 | 44 | } |
45 | 45 | |
46 | - public function setField($field){ |
|
46 | + public function setField($field) { |
|
47 | 47 | $this->content["field"]=$field; |
48 | 48 | } |
49 | 49 | |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * Returns the label or null |
52 | 52 | * @return mixed |
53 | 53 | */ |
54 | - public function getLabel(){ |
|
55 | - if(\array_key_exists("label", $this->content)) |
|
54 | + public function getLabel() { |
|
55 | + if (\array_key_exists("label", $this->content)) |
|
56 | 56 | return $this->content["label"]; |
57 | 57 | } |
58 | 58 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * Return the field |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | - public function getField(){ |
|
63 | + public function getField() { |
|
64 | 64 | return $this->content["field"]; |
65 | 65 | } |
66 | 66 | |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | * Return the field with data |
69 | 69 | * @return mixed |
70 | 70 | */ |
71 | - public function getDataField(){ |
|
71 | + public function getDataField() { |
|
72 | 72 | return $this->content["field"]; |
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | 76 | * puts the label before or behind |
77 | 77 | */ |
78 | - public function swapLabel(){ |
|
78 | + public function swapLabel() { |
|
79 | 79 | $label=$this->getLabel(); |
80 | 80 | unset($this->content["label"]); |
81 | 81 | $this->content["label"]=$label; |
@@ -86,31 +86,31 @@ discard block |
||
86 | 86 | * @param int $width |
87 | 87 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
88 | 88 | */ |
89 | - public function setWidth($width){ |
|
90 | - if(\is_int($width)){ |
|
89 | + public function setWidth($width) { |
|
90 | + if (\is_int($width)) { |
|
91 | 91 | $width=Wide::getConstants()["W".$width]; |
92 | 92 | } |
93 | 93 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
94 | - if(isset($this->_container)){ |
|
94 | + if (isset($this->_container)) { |
|
95 | 95 | $this->_container->setEqualWidth(false); |
96 | 96 | } |
97 | - return $this->addToPropertyCtrl("class", "wide",array("wide")); |
|
97 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Field displays an error state |
102 | 102 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
103 | 103 | */ |
104 | - public function setError(){ |
|
104 | + public function setError() { |
|
105 | 105 | return $this->addToProperty("class", "error"); |
106 | 106 | } |
107 | 107 | |
108 | - public function setInline(){ |
|
108 | + public function setInline() { |
|
109 | 109 | return $this->addToProperty("class", "inline"); |
110 | 110 | } |
111 | 111 | |
112 | - public function jsState($state){ |
|
113 | - return $this->jsDoJquery("addClass",$state); |
|
112 | + public function jsState($state) { |
|
113 | + return $this->jsDoJquery("addClass", $state); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | public function setContainer($_container) { |
@@ -118,49 +118,49 @@ discard block |
||
118 | 118 | return $this; |
119 | 119 | } |
120 | 120 | |
121 | - public function setReadonly(){ |
|
121 | + public function setReadonly() { |
|
122 | 122 | $this->getDataField()->setProperty("readonly", ""); |
123 | 123 | } |
124 | 124 | |
125 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
125 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
126 | 126 | $field=$this->getDataField(); |
127 | - if(isset($field)){ |
|
128 | - if(!isset($this->_validation)){ |
|
127 | + if (isset($field)) { |
|
128 | + if (!isset($this->_validation)) { |
|
129 | 129 | $this->_validation=new FieldValidation($field->getIdentifier()); |
130 | 130 | } |
131 | - if($type==="empty"){ |
|
132 | - $this->addToProperty("class","required"); |
|
131 | + if ($type==="empty") { |
|
132 | + $this->addToProperty("class", "required"); |
|
133 | 133 | } |
134 | - $this->_validation->addRule($type,$prompt,$value); |
|
134 | + $this->_validation->addRule($type, $prompt, $value); |
|
135 | 135 | } |
136 | 136 | return $this; |
137 | 137 | } |
138 | 138 | |
139 | - public function setOptional($optional=true){ |
|
139 | + public function setOptional($optional=true) { |
|
140 | 140 | $field=$this->getDataField(); |
141 | - if(isset($field)){ |
|
142 | - if(!isset($this->_validation)){ |
|
141 | + if (isset($field)) { |
|
142 | + if (!isset($this->_validation)) { |
|
143 | 143 | $this->_validation=new FieldValidation($field->getIdentifier()); |
144 | 144 | } |
145 | 145 | $this->_validation->setOptional($optional); |
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - public function addRules(array $rules){ |
|
150 | - foreach ($rules as $rule){ |
|
149 | + public function addRules(array $rules) { |
|
150 | + foreach ($rules as $rule) { |
|
151 | 151 | $this->addRule($rule); |
152 | 152 | } |
153 | 153 | return $this; |
154 | 154 | } |
155 | 155 | |
156 | - public function setRules(array $rules){ |
|
156 | + public function setRules(array $rules) { |
|
157 | 157 | $this->_validation=null; |
158 | 158 | return $this->addRules($rules); |
159 | 159 | } |
160 | 160 | |
161 | - public function addIcon($icon,$direction=Direction::LEFT){ |
|
161 | + public function addIcon($icon, $direction=Direction::LEFT) { |
|
162 | 162 | $field=$this->getField(); |
163 | - return $field->addIcon($icon,$direction); |
|
163 | + return $field->addIcon($icon, $direction); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | public function getValidation() { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | public function run(JsUtils $js) { |
175 | - if(isset($this->_validation)){ |
|
175 | + if (isset($this->_validation)) { |
|
176 | 176 | $this->_validation->compile($js); |
177 | 177 | } |
178 | 178 | return parent::run($js); |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | class HtmlTableContent extends HtmlSemCollection { |
17 | 17 | protected $_focusable=false; |
18 | 18 | |
19 | - protected $_tdTagNames = [ |
|
19 | + protected $_tdTagNames=[ |
|
20 | 20 | "thead" => "th", |
21 | 21 | "tbody" => "td", |
22 | 22 | "tfoot" => "th" |
23 | 23 | ]; |
24 | 24 | |
25 | - protected $_merged = false; |
|
25 | + protected $_merged=false; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param int $rowCount |
32 | 32 | * @param int $colCount |
33 | 33 | */ |
34 | - public function __construct($identifier, $tagName = "tbody", $rowCount = NULL, $colCount = NULL) { |
|
34 | + public function __construct($identifier, $tagName="tbody", $rowCount=NULL, $colCount=NULL) { |
|
35 | 35 | parent::__construct($identifier, $tagName, ""); |
36 | 36 | if (isset($rowCount) && isset($colCount)) |
37 | 37 | $this->setRowCount($rowCount, $colCount); |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * @return HtmlTableContent |
45 | 45 | */ |
46 | 46 | public function setRowCount($rowCount, $colCount) { |
47 | - $count = $this->count(); |
|
48 | - for ($i = $count; $i < $rowCount; $i ++) { |
|
47 | + $count=$this->count(); |
|
48 | + for ($i=$count; $i<$rowCount; $i++) { |
|
49 | 49 | $this->addItem($colCount); |
50 | 50 | } |
51 | 51 | return $this; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | public function refreshTR() { |
59 | - $this->_template = "%wrapContentBefore%%content%%wrapContentAfter%"; |
|
59 | + $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | * @return HtmlTR |
68 | 68 | */ |
69 | 69 | protected function createItem($value) { |
70 | - $count = $this->count(); |
|
71 | - $tr = new HtmlTR(""); |
|
70 | + $count=$this->count(); |
|
71 | + $tr=new HtmlTR(""); |
|
72 | 72 | $tr->setContainer($this, $count); |
73 | - if($this->_focusable) { |
|
73 | + if ($this->_focusable) { |
|
74 | 74 | $tr->setProperty('tabindex', $count); |
75 | 75 | } |
76 | 76 | $tr->setTdTagName($this->_tdTagNames[$this->tagName]); |
77 | - if (isset($value) === true) { |
|
77 | + if (isset($value)===true) { |
|
78 | 78 | $tr->setColCount($value); |
79 | 79 | } |
80 | 80 | return $tr; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | return $this->addItem($row); |
103 | 103 | } |
104 | 104 | |
105 | - public function addMergeRow($colCount, $value = null) { |
|
106 | - $row = $this->addRow($colCount); |
|
105 | + public function addMergeRow($colCount, $value=null) { |
|
106 | + $row=$this->addRow($colCount); |
|
107 | 107 | $row->mergeCol(); |
108 | 108 | if (isset($value)) { |
109 | 109 | $row->setValues([ |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | * @return HtmlTD|HtmlDoubleElement |
130 | 130 | */ |
131 | 131 | public function getCell($row, $col) { |
132 | - $row = $this->getItem($row); |
|
132 | + $row=$this->getItem($row); |
|
133 | 133 | if (isset($row) && $row instanceof HtmlCollection) { |
134 | - $col = $row->getItem($col); |
|
134 | + $col=$row->getItem($col); |
|
135 | 135 | } else { |
136 | - $col = $row; |
|
136 | + $col=$row; |
|
137 | 137 | } |
138 | 138 | return $col; |
139 | 139 | } |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | * @param mixed $value |
155 | 155 | * @return HtmlTableContent |
156 | 156 | */ |
157 | - public function setCellValue($row, $col, $value = "") { |
|
158 | - $cell = $this->getCell($row, $col); |
|
159 | - if (isset($cell) === true) { |
|
157 | + public function setCellValue($row, $col, $value="") { |
|
158 | + $cell=$this->getCell($row, $col); |
|
159 | + if (isset($cell)===true) { |
|
160 | 160 | $cell->setValue($value); |
161 | 161 | } |
162 | 162 | return $this; |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @param mixed $values |
169 | 169 | */ |
170 | - public function setValues($values = array()) { |
|
171 | - return $this->_addOrSetValues($values, function (HtmlTR $row, $_values) { |
|
170 | + public function setValues($values=array()) { |
|
171 | + return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) { |
|
172 | 172 | $row->setValues($_values); |
173 | 173 | }); |
174 | 174 | } |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @param mixed $values |
180 | 180 | */ |
181 | - public function addValues($values = array()) { |
|
182 | - return $this->_addOrSetValues($values, function (HtmlTR $row, $_values) { |
|
181 | + public function addValues($values=array()) { |
|
182 | + return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) { |
|
183 | 183 | $row->addValues($_values); |
184 | 184 | }); |
185 | 185 | } |
@@ -191,42 +191,42 @@ discard block |
||
191 | 191 | * @param callable $callback |
192 | 192 | */ |
193 | 193 | protected function _addOrSetValues($values, $callback) { |
194 | - $count = $this->count(); |
|
195 | - $isArray = true; |
|
196 | - if (! \is_array($values)) { |
|
197 | - $values = \array_fill(0, $count, $values); |
|
198 | - $isArray = false; |
|
194 | + $count=$this->count(); |
|
195 | + $isArray=true; |
|
196 | + if (!\is_array($values)) { |
|
197 | + $values=\array_fill(0, $count, $values); |
|
198 | + $isArray=false; |
|
199 | 199 | } |
200 | - if (JArray::dimension($values) == 1 && $isArray) |
|
201 | - $values = [ |
|
200 | + if (JArray::dimension($values)==1 && $isArray) |
|
201 | + $values=[ |
|
202 | 202 | $values |
203 | 203 | ]; |
204 | 204 | |
205 | - $count = \min(\sizeof($values), $count); |
|
205 | + $count=\min(\sizeof($values), $count); |
|
206 | 206 | |
207 | - for ($i = 0; $i < $count; $i ++) { |
|
208 | - $row = $this->content[$i]; |
|
207 | + for ($i=0; $i<$count; $i++) { |
|
208 | + $row=$this->content[$i]; |
|
209 | 209 | $callback($row, $values[$i]); |
210 | 210 | } |
211 | 211 | return $this; |
212 | 212 | } |
213 | 213 | |
214 | - public function setColValues($colIndex, $values = array()) { |
|
215 | - $count = $this->count(); |
|
216 | - if (! \is_array($values)) { |
|
217 | - $values = \array_fill(0, $count, $values); |
|
214 | + public function setColValues($colIndex, $values=array()) { |
|
215 | + $count=$this->count(); |
|
216 | + if (!\is_array($values)) { |
|
217 | + $values=\array_fill(0, $count, $values); |
|
218 | 218 | } |
219 | - $count = \min(\sizeof($values), $count); |
|
220 | - for ($i = 0; $i < $count; $i ++) { |
|
219 | + $count=\min(\sizeof($values), $count); |
|
220 | + for ($i=0; $i<$count; $i++) { |
|
221 | 221 | $this->getCell($i, $colIndex)->setValue($values[$i]); |
222 | 222 | } |
223 | 223 | return $this; |
224 | 224 | } |
225 | 225 | |
226 | - public function addColVariations($colIndex, $variations = array()) { |
|
227 | - $count = $this->count(); |
|
228 | - for ($i = 0; $i < $count; $i ++) { |
|
229 | - $cell = $this->getCell($i, $colIndex); |
|
226 | + public function addColVariations($colIndex, $variations=array()) { |
|
227 | + $count=$this->count(); |
|
228 | + for ($i=0; $i<$count; $i++) { |
|
229 | + $cell=$this->getCell($i, $colIndex); |
|
230 | 230 | if ($cell instanceof BaseTrait) |
231 | 231 | $cell->addVariations($variations); |
232 | 232 | } |
@@ -234,41 +234,41 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | public function addPropertyCol($colIndex, $name, $value) { |
237 | - $count = $this->count(); |
|
238 | - for ($i = 0; $i < $count; $i ++) { |
|
239 | - $cell = $this->getCell($i, $colIndex); |
|
237 | + $count=$this->count(); |
|
238 | + for ($i=0; $i<$count; $i++) { |
|
239 | + $cell=$this->getCell($i, $colIndex); |
|
240 | 240 | if (isset($cell)) |
241 | 241 | $cell->addToProperty($name, $value); |
242 | 242 | } |
243 | 243 | return $this; |
244 | 244 | } |
245 | 245 | |
246 | - public function setRowValues($rowIndex, $values = array()) { |
|
247 | - $count = $this->count(); |
|
248 | - if (! \is_array($values)) { |
|
249 | - $values = \array_fill(0, $count, $values); |
|
246 | + public function setRowValues($rowIndex, $values=array()) { |
|
247 | + $count=$this->count(); |
|
248 | + if (!\is_array($values)) { |
|
249 | + $values=\array_fill(0, $count, $values); |
|
250 | 250 | } |
251 | 251 | $this->getItem($rowIndex)->setValues($values); |
252 | 252 | return $this; |
253 | 253 | } |
254 | 254 | |
255 | 255 | private function colAlign($colIndex, $function) { |
256 | - $count = $this->count(); |
|
257 | - for ($i = 0; $i < $count; $i ++) { |
|
258 | - $index = $this->content[$i]->getColPosition($colIndex); |
|
259 | - if ($index !== NULL) |
|
256 | + $count=$this->count(); |
|
257 | + for ($i=0; $i<$count; $i++) { |
|
258 | + $index=$this->content[$i]->getColPosition($colIndex); |
|
259 | + if ($index!==NULL) |
|
260 | 260 | $this->getCell($i, $index)->$function(); |
261 | 261 | } |
262 | 262 | return $this; |
263 | 263 | } |
264 | 264 | |
265 | 265 | private function colAlignFromRight($colIndex, $function) { |
266 | - $count = $this->count(); |
|
267 | - for ($i = 0; $i < $count; $i ++) { |
|
268 | - $maxRow = $this->content[$i]->count(); |
|
269 | - $index = $maxRow - $colIndex - 1; |
|
270 | - if (($cell = $this->getCell($i, $index)) !== NULL) { |
|
271 | - if ($cell->getColspan() == 1) |
|
266 | + $count=$this->count(); |
|
267 | + for ($i=0; $i<$count; $i++) { |
|
268 | + $maxRow=$this->content[$i]->count(); |
|
269 | + $index=$maxRow-$colIndex-1; |
|
270 | + if (($cell=$this->getCell($i, $index))!==NULL) { |
|
271 | + if ($cell->getColspan()==1) |
|
272 | 272 | $cell->$function(); |
273 | 273 | } |
274 | 274 | } |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | * @return int |
315 | 315 | */ |
316 | 316 | public function getColCount() { |
317 | - $result = 0; |
|
318 | - if ($this->count() > 0) |
|
319 | - $result = $this->getItem(0)->count(); |
|
317 | + $result=0; |
|
318 | + if ($this->count()>0) |
|
319 | + $result=$this->getItem(0)->count(); |
|
320 | 320 | return $result; |
321 | 321 | } |
322 | 322 | |
@@ -327,10 +327,10 @@ discard block |
||
327 | 327 | * @param int $colIndex |
328 | 328 | * @return HtmlTableContent |
329 | 329 | */ |
330 | - public function delete($rowIndex, $colIndex = NULL) { |
|
330 | + public function delete($rowIndex, $colIndex=NULL) { |
|
331 | 331 | if (isset($colIndex)) { |
332 | - $row = $this->getItem($rowIndex); |
|
333 | - if (isset($row) === true) { |
|
332 | + $row=$this->getItem($rowIndex); |
|
333 | + if (isset($row)===true) { |
|
334 | 334 | $row->delete($colIndex); |
335 | 335 | } |
336 | 336 | } else { |
@@ -340,24 +340,24 @@ discard block |
||
340 | 340 | } |
341 | 341 | |
342 | 342 | public function toDelete($rowIndex, $colIndex) { |
343 | - $row = $this->getItem($rowIndex); |
|
344 | - if (isset($row) === true) |
|
343 | + $row=$this->getItem($rowIndex); |
|
344 | + if (isset($row)===true) |
|
345 | 345 | $row->toDelete($colIndex); |
346 | 346 | return $this; |
347 | 347 | } |
348 | 348 | |
349 | 349 | public function toRowspanned($rowIndex, $colIndex) { |
350 | - $row = $this->getItem($rowIndex); |
|
351 | - if (isset($row) === true) |
|
350 | + $row=$this->getItem($rowIndex); |
|
351 | + if (isset($row)===true) |
|
352 | 352 | $row->toRowspanned($colIndex); |
353 | 353 | return $this; |
354 | 354 | } |
355 | 355 | |
356 | - public function mergeCol($rowIndex = 0, $colIndex = 0) { |
|
356 | + public function mergeCol($rowIndex=0, $colIndex=0) { |
|
357 | 357 | return $this->getItem($rowIndex)->mergeCol($colIndex); |
358 | 358 | } |
359 | 359 | |
360 | - public function mergeRow($rowIndex = 0, $colIndex = 0) { |
|
360 | + public function mergeRow($rowIndex=0, $colIndex=0) { |
|
361 | 361 | return $this->getItem($rowIndex)->mergeRow($colIndex); |
362 | 362 | } |
363 | 363 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * @return HtmlTableContent |
378 | 378 | */ |
379 | 379 | public function conditionalCellFormat($callback, $format) { |
380 | - $rows = $this->content; |
|
380 | + $rows=$this->content; |
|
381 | 381 | foreach ($rows as $row) { |
382 | 382 | $row->conditionalCellFormat($callback, $format); |
383 | 383 | } |
@@ -385,9 +385,9 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | public function conditionalColFormat($colIndex, $callback, $format) { |
388 | - $rows = $this->content; |
|
388 | + $rows=$this->content; |
|
389 | 389 | foreach ($rows as $row) { |
390 | - $cell = $row->getItem($colIndex); |
|
390 | + $cell=$row->getItem($colIndex); |
|
391 | 391 | $cell->conditionnalCellFormat($callback, $format); |
392 | 392 | } |
393 | 393 | return $this; |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @return HtmlTableContent |
401 | 401 | */ |
402 | 402 | public function conditionalRowFormat($callback, $format) { |
403 | - $rows = $this->content; |
|
403 | + $rows=$this->content; |
|
404 | 404 | foreach ($rows as $row) { |
405 | 405 | $row->conditionalRowFormat($callback, $format); |
406 | 406 | } |
@@ -408,9 +408,9 @@ discard block |
||
408 | 408 | } |
409 | 409 | |
410 | 410 | public function hideColumn($colIndex) { |
411 | - $rows = $this->content; |
|
411 | + $rows=$this->content; |
|
412 | 412 | foreach ($rows as $row) { |
413 | - $cell = $row->getItem($colIndex); |
|
413 | + $cell=$row->getItem($colIndex); |
|
414 | 414 | $cell->addToProperty("style", "display:none;"); |
415 | 415 | } |
416 | 416 | return $this; |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @return HtmlTableContent |
423 | 423 | */ |
424 | 424 | public function applyCells($callback) { |
425 | - $rows = $this->content; |
|
425 | + $rows=$this->content; |
|
426 | 426 | foreach ($rows as $row) { |
427 | 427 | $row->applyCells($callback); |
428 | 428 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @return HtmlTableContent |
436 | 436 | */ |
437 | 437 | public function applyRows($callback) { |
438 | - $rows = $this->content; |
|
438 | + $rows=$this->content; |
|
439 | 439 | foreach ($rows as $row) { |
440 | 440 | $row->apply($callback); |
441 | 441 | } |
@@ -450,28 +450,28 @@ discard block |
||
450 | 450 | * @see https://fomantic-ui.com/collections/table.html#definition needs rowspanned class |
451 | 451 | * @since fomantic-ui 2.4.8 |
452 | 452 | */ |
453 | - public function mergeIdentiqualValues($colIndex, $function = "strip_tags") { |
|
454 | - $rows = $this->content; |
|
455 | - $identiqual = null; |
|
456 | - $counter = 0; |
|
457 | - $cellToMerge = null; |
|
458 | - $functionExists = \function_exists($function); |
|
453 | + public function mergeIdentiqualValues($colIndex, $function="strip_tags") { |
|
454 | + $rows=$this->content; |
|
455 | + $identiqual=null; |
|
456 | + $counter=0; |
|
457 | + $cellToMerge=null; |
|
458 | + $functionExists=\function_exists($function); |
|
459 | 459 | foreach ($rows as $row) { |
460 | - $cell = $row->getItem($colIndex); |
|
461 | - $value = $cell->getContent(); |
|
460 | + $cell=$row->getItem($colIndex); |
|
461 | + $value=$cell->getContent(); |
|
462 | 462 | if ($functionExists) |
463 | - $value = \call_user_func($function, $value); |
|
464 | - if ($value !== $identiqual) { |
|
465 | - if ($counter > 0 && isset($cellToMerge)) { |
|
463 | + $value=\call_user_func($function, $value); |
|
464 | + if ($value!==$identiqual) { |
|
465 | + if ($counter>0 && isset($cellToMerge)) { |
|
466 | 466 | $cellToMerge->setRowspanned($counter); |
467 | 467 | } |
468 | - $counter = 0; |
|
469 | - $cellToMerge = $cell; |
|
470 | - $identiqual = $value; |
|
468 | + $counter=0; |
|
469 | + $cellToMerge=$cell; |
|
470 | + $identiqual=$value; |
|
471 | 471 | } |
472 | - $counter ++; |
|
472 | + $counter++; |
|
473 | 473 | } |
474 | - if ($counter > 0 && isset($cellToMerge)) { |
|
474 | + if ($counter>0 && isset($cellToMerge)) { |
|
475 | 475 | $cellToMerge->setRowspanned($counter); |
476 | 476 | } |
477 | 477 | return $this; |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | } |
483 | 483 | |
484 | 484 | public function _setMerged($value) { |
485 | - $this->_merged = $value; |
|
485 | + $this->_merged=$value; |
|
486 | 486 | return $this; |
487 | 487 | } |
488 | 488 | |
@@ -490,6 +490,6 @@ discard block |
||
490 | 490 | * @param bool $focusable |
491 | 491 | */ |
492 | 492 | public function setFocusable(bool $focusable): void { |
493 | - $this->_focusable = $focusable; |
|
493 | + $this->_focusable=$focusable; |
|
494 | 494 | } |
495 | 495 | } |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | */ |
11 | 11 | trait TableTrait { |
12 | 12 | |
13 | - abstract public function addEvent($event, $jsCode, $stopPropagation = false, $preventDefault = false); |
|
13 | + abstract public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false); |
|
14 | 14 | |
15 | - abstract public function getOn($event, $url, $responseElement = "", $parameters = array()); |
|
15 | + abstract public function getOn($event, $url, $responseElement="", $parameters=array()); |
|
16 | 16 | |
17 | 17 | protected function addToPropertyTable($property, $value) { |
18 | 18 | return $this->_self->addToProperty($property, $value); |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | return $this->addToPropertyTable("class", "celled"); |
23 | 23 | } |
24 | 24 | |
25 | - public function setBasic($very = false) { |
|
26 | - $table = $this->_self; |
|
25 | + public function setBasic($very=false) { |
|
26 | + $table=$this->_self; |
|
27 | 27 | if ($very) |
28 | 28 | $table->addToPropertyCtrl("class", "very", array( |
29 | 29 | "very" |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | )); |
34 | 34 | } |
35 | 35 | |
36 | - public function setCompact($very = false) { |
|
37 | - $table = $this->_self; |
|
36 | + public function setCompact($very=false) { |
|
37 | + $table=$this->_self; |
|
38 | 38 | if ($very) |
39 | 39 | $table->addToPropertyCtrl("class", "very", array( |
40 | 40 | "very" |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | return $this->addToPropertyTable("class", "structured"); |
57 | 57 | } |
58 | 58 | |
59 | - public function setSortable($colIndex = NULL) { |
|
60 | - $table = $this->_self; |
|
59 | + public function setSortable($colIndex=NULL) { |
|
60 | + $table=$this->_self; |
|
61 | 61 | if (isset($colIndex) && $table->hasPart("thead")) { |
62 | 62 | $table->getHeader()->sort($colIndex); |
63 | 63 | } |
@@ -80,29 +80,29 @@ discard block |
||
80 | 80 | return $this->addToPropertyTable("class", "striped"); |
81 | 81 | } |
82 | 82 | |
83 | - public function onRowClick($jsCode, $stopPropagation = false, $preventDefault = false) { |
|
83 | + public function onRowClick($jsCode, $stopPropagation=false, $preventDefault=false) { |
|
84 | 84 | return $this->onRow("click", $jsCode, $stopPropagation, $preventDefault); |
85 | 85 | } |
86 | 86 | |
87 | - public function onRow($event, $jsCode, $stopPropagation = false, $preventDefault = false) { |
|
88 | - return $this->_self->addEvent($event . "{{tbody tr}}", $jsCode, $stopPropagation, $preventDefault); |
|
87 | + public function onRow($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
|
88 | + return $this->_self->addEvent($event."{{tbody tr}}", $jsCode, $stopPropagation, $preventDefault); |
|
89 | 89 | } |
90 | 90 | |
91 | - public function getOnRow($event, $url, $responseElement = "", $parameters = array()) { |
|
92 | - $jsCondition = '!$(this).closest("tr").is(":focus")'; |
|
91 | + public function getOnRow($event, $url, $responseElement="", $parameters=array()) { |
|
92 | + $jsCondition='!$(this).closest("tr").is(":focus")'; |
|
93 | 93 | if (isset($parameters['jsCondition'])) { |
94 | - $jsCondition = '(' . $parameters['jsCondition'] . ' && ' . $jsCondition . ')'; |
|
94 | + $jsCondition='('.$parameters['jsCondition'].' && '.$jsCondition.')'; |
|
95 | 95 | } |
96 | - $parameters = \array_merge($parameters, [ |
|
96 | + $parameters=\array_merge($parameters, [ |
|
97 | 97 | "stopPropagation" => false, |
98 | 98 | "preventDefault" => false, |
99 | 99 | "jsCondition" => $jsCondition |
100 | 100 | ]); |
101 | - $selector = "tbody tr"; |
|
101 | + $selector="tbody tr"; |
|
102 | 102 | if (isset($parameters["selector"])) { |
103 | - $selector = $parameters["selector"]; |
|
103 | + $selector=$parameters["selector"]; |
|
104 | 104 | } |
105 | - return $this->_self->getOn($event . "{{" . $selector . "}}", $url, $responseElement, $parameters); |
|
105 | + return $this->_self->getOn($event."{{".$selector."}}", $url, $responseElement, $parameters); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | public function onPageChange($jsCode) { |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | return $this->_self->getBsComponent()->getScript(); |
120 | 120 | } |
121 | 121 | |
122 | - public function addEventsOnRun(JsUtils $js = NULL) { |
|
123 | - $script = parent::addEventsOnRun($js); |
|
124 | - $innerScript = $this->_self->getInnerScript(); |
|
125 | - if (! isset($innerScript)) { |
|
122 | + public function addEventsOnRun(JsUtils $js=NULL) { |
|
123 | + $script=parent::addEventsOnRun($js); |
|
124 | + $innerScript=$this->_self->getInnerScript(); |
|
125 | + if (!isset($innerScript)) { |
|
126 | 126 | $this->_self->setInnerScript($script); |
127 | 127 | } |
128 | 128 | return $script; |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | |
41 | 41 | public function __construct($identifier, $rowCount, $colCount) { |
42 | 42 | parent::__construct($identifier, "table", "ui table"); |
43 | - $this->content=array (); |
|
43 | + $this->content=array(); |
|
44 | 44 | $this->setRowCount($rowCount, $colCount); |
45 | - $this->_variations=[ Variation::CELLED,Variation::PADDED,Variation::COMPACT ]; |
|
46 | - $this->_compileParts=["thead","tbody","tfoot"]; |
|
45 | + $this->_variations=[Variation::CELLED, Variation::PADDED, Variation::COMPACT]; |
|
46 | + $this->_compileParts=["thead", "tbody", "tfoot"]; |
|
47 | 47 | $this->_afterCompileEvents=[]; |
48 | 48 | } |
49 | 49 | |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | * @return HtmlTableContent |
54 | 54 | */ |
55 | 55 | public function getPart($key) { |
56 | - if (\array_key_exists($key, $this->content) === false) { |
|
56 | + if (\array_key_exists($key, $this->content)===false) { |
|
57 | 57 | $this->content[$key]=new HtmlTableContent("", $key); |
58 | - if ($key !== "tbody") { |
|
58 | + if ($key!=="tbody") { |
|
59 | 59 | $this->content[$key]->setRowCount(1, $this->_colCount); |
60 | 60 | } |
61 | 61 | } |
62 | 62 | return $this->content[$key]; |
63 | 63 | } |
64 | 64 | |
65 | - protected function _getFirstPart(){ |
|
66 | - if(isset($this->content["thead"])){ |
|
65 | + protected function _getFirstPart() { |
|
66 | + if (isset($this->content["thead"])) { |
|
67 | 67 | return $this->content["thead"]; |
68 | 68 | } |
69 | 69 | return $this->content["tbody"]; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @return boolean |
109 | 109 | */ |
110 | 110 | public function hasPart($key) { |
111 | - return \array_key_exists($key, $this->content) === true; |
|
111 | + return \array_key_exists($key, $this->content)===true; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | return $this->colAlign($colIndex, "colLeftFromRight"); |
269 | 269 | } |
270 | 270 | |
271 | - public function setColAlignment($colIndex,$alignment){ |
|
272 | - switch ($alignment){ |
|
271 | + public function setColAlignment($colIndex, $alignment) { |
|
272 | + switch ($alignment) { |
|
273 | 273 | case TextAlignment::LEFT: |
274 | 274 | $function="colLeft"; |
275 | 275 | break; |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | return $this; |
290 | 290 | } |
291 | 291 | |
292 | - public function setColAlignmentFromRight($colIndex,$alignment){ |
|
293 | - switch ($alignment){ |
|
292 | + public function setColAlignmentFromRight($colIndex, $alignment) { |
|
293 | + switch ($alignment) { |
|
294 | 294 | case TextAlignment::LEFT: |
295 | 295 | $function="colLeftFromRight"; |
296 | 296 | break; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | |
313 | 313 | private function colAlign($colIndex, $function) { |
314 | 314 | if (\is_array($colIndex)) { |
315 | - foreach ( $colIndex as $cIndex ) { |
|
315 | + foreach ($colIndex as $cIndex) { |
|
316 | 316 | $this->colAlign($cIndex, $function); |
317 | 317 | } |
318 | 318 | } else { |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * @see HtmlSemDoubleElement::compile() |
374 | 374 | */ |
375 | 375 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
376 | - if(\sizeof($this->_compileParts)<3){ |
|
376 | + if (\sizeof($this->_compileParts)<3) { |
|
377 | 377 | $this->_template="%content%"; |
378 | 378 | $this->refresh($js); |
379 | 379 | } |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | } |
383 | 383 | |
384 | 384 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
385 | - parent::compile_once($js,$view); |
|
385 | + parent::compile_once($js, $view); |
|
386 | 386 | if ($this->propertyContains("class", "sortable")) { |
387 | - $this->addEvent("execute", "$('#" . $this->identifier . "').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
387 | + $this->addEvent("execute", "$('#".$this->identifier."').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
@@ -397,13 +397,13 @@ discard block |
||
397 | 397 | public function fromDatabaseObject($object, $function) { |
398 | 398 | $result=$function($object); |
399 | 399 | if (\is_array($result)) { |
400 | - $result= $this->addRow($function($object)); |
|
400 | + $result=$this->addRow($function($object)); |
|
401 | 401 | } else { |
402 | - $result= $this->getBody()->_addRow($result); |
|
402 | + $result=$this->getBody()->_addRow($result); |
|
403 | 403 | } |
404 | - if(isset($this->_afterCompileEvents["onNewRow"])){ |
|
405 | - if(\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
406 | - $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
404 | + if (isset($this->_afterCompileEvents["onNewRow"])) { |
|
405 | + if (\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
406 | + $this->_afterCompileEvents["onNewRow"]($result, $object); |
|
407 | 407 | } |
408 | 408 | return $result; |
409 | 409 | } |
@@ -418,26 +418,26 @@ discard block |
||
418 | 418 | return $this; |
419 | 419 | } |
420 | 420 | |
421 | - public function refreshTR(){ |
|
421 | + public function refreshTR() { |
|
422 | 422 | $this->setCompileParts(); |
423 | 423 | $this->getPart("tbody")->refreshTR(); |
424 | 424 | } |
425 | 425 | |
426 | - public function refresh($js){ |
|
426 | + public function refresh($js) { |
|
427 | 427 | $this->_footer=$this->getFooter(); |
428 | - if(isset($js)){ |
|
429 | - $js->exec('$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");',true); |
|
428 | + if (isset($js)) { |
|
429 | + $js->exec('$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");', true); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
433 | - public function run(JsUtils $js){ |
|
434 | - if(!$this->_runned){ |
|
435 | - if(isset($this->_activeRowSelector)){ |
|
433 | + public function run(JsUtils $js) { |
|
434 | + if (!$this->_runned) { |
|
435 | + if (isset($this->_activeRowSelector)) { |
|
436 | 436 | $this->_activeRowSelector->run(); |
437 | 437 | } |
438 | 438 | } |
439 | - $result= parent::run($js); |
|
440 | - if(isset($this->_footer)) |
|
439 | + $result=parent::run($js); |
|
440 | + if (isset($this->_footer)) |
|
441 | 441 | $this->_footer->run($js); |
442 | 442 | $this->_runned=true; |
443 | 443 | return $result; |
@@ -461,51 +461,51 @@ discard block |
||
461 | 461 | * @param boolean $multiple |
462 | 462 | * @return HtmlTable |
463 | 463 | */ |
464 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
465 | - $this->_activeRowSelector=new ActiveRow($this,$class,$event,$multiple); |
|
464 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
465 | + $this->_activeRowSelector=new ActiveRow($this, $class, $event, $multiple); |
|
466 | 466 | return $this; |
467 | 467 | } |
468 | 468 | |
469 | - public function hasActiveRowSelector(){ |
|
469 | + public function hasActiveRowSelector() { |
|
470 | 470 | return isset($this->_activeRowSelector); |
471 | 471 | } |
472 | 472 | |
473 | - public function hideColumn($colIndex){ |
|
474 | - if(isset($this->content["thead"])){ |
|
473 | + public function hideColumn($colIndex) { |
|
474 | + if (isset($this->content["thead"])) { |
|
475 | 475 | $this->content["thead"]->hideColumn($colIndex); |
476 | 476 | } |
477 | 477 | $this->content["tbody"]->hideColumn($colIndex); |
478 | - if(isset($this->content["tfoot"])){ |
|
478 | + if (isset($this->content["tfoot"])) { |
|
479 | 479 | $this->content["tfoot"]->hideColumn($colIndex); |
480 | 480 | } |
481 | 481 | return $this; |
482 | 482 | } |
483 | 483 | |
484 | - public function setColWidth($colIndex,$width){ |
|
484 | + public function setColWidth($colIndex, $width) { |
|
485 | 485 | $part=$this->_getFirstPart(); |
486 | - if($part!==null && $part->count()>0) |
|
486 | + if ($part!==null && $part->count()>0) |
|
487 | 487 | $part->getCell(0, $colIndex)->setWidth($width); |
488 | 488 | return $this; |
489 | 489 | } |
490 | 490 | |
491 | - public function setColWidths($widths){ |
|
491 | + public function setColWidths($widths) { |
|
492 | 492 | $part=$this->_getFirstPart(); |
493 | - if($part!==null && $part->count()>0){ |
|
493 | + if ($part!==null && $part->count()>0) { |
|
494 | 494 | $count=$part->getColCount(); |
495 | - if(!\is_array($widths)){ |
|
495 | + if (!\is_array($widths)) { |
|
496 | 496 | $widths=\array_fill(0, $count, $widths); |
497 | 497 | } |
498 | - $max=\min(\sizeof($widths),$count); |
|
499 | - for($i=0;$i<$max;$i++){ |
|
498 | + $max=\min(\sizeof($widths), $count); |
|
499 | + for ($i=0; $i<$max; $i++) { |
|
500 | 500 | $part->getCell(0, $i)->setWidth($widths[$i]); |
501 | 501 | } |
502 | 502 | } |
503 | 503 | return $this; |
504 | 504 | } |
505 | 505 | |
506 | - public function mergeIdentiqualValues($colIndex,$function="strip_tags"){ |
|
506 | + public function mergeIdentiqualValues($colIndex, $function="strip_tags") { |
|
507 | 507 | $body=$this->getBody(); |
508 | - $body->mergeIdentiqualValues($colIndex,$function); |
|
508 | + $body->mergeIdentiqualValues($colIndex, $function); |
|
509 | 509 | return $this; |
510 | 510 | } |
511 | 511 | /** |
@@ -519,16 +519,16 @@ discard block |
||
519 | 519 | * @param mixed $_innerScript |
520 | 520 | */ |
521 | 521 | public function setInnerScript($_innerScript) { |
522 | - $this->_innerScript = $_innerScript; |
|
522 | + $this->_innerScript=$_innerScript; |
|
523 | 523 | } |
524 | 524 | |
525 | - public function onActiveRowChange($jsCode){ |
|
526 | - $this->on("activeRowChange",$jsCode); |
|
525 | + public function onActiveRowChange($jsCode) { |
|
526 | + $this->on("activeRowChange", $jsCode); |
|
527 | 527 | return $this; |
528 | 528 | } |
529 | 529 | |
530 | - public function addMergeRow($colCount,$value=null){ |
|
531 | - return $this->getBody()->addMergeRow($colCount,$value); |
|
530 | + public function addMergeRow($colCount, $value=null) { |
|
531 | + return $this->getBody()->addMergeRow($colCount, $value); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | /** |
@@ -10,7 +10,7 @@ |
||
10 | 10 | */ |
11 | 11 | class HtmlRail extends HtmlSemDoubleElement { |
12 | 12 | |
13 | - public function __construct($identifier, $content = NULL) { |
|
13 | + public function __construct($identifier, $content=NULL) { |
|
14 | 14 | parent::__construct($identifier, 'div', 'ui rail', $content); |
15 | 15 | } |
16 | 16 |