@@ -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 | |
@@ -65,26 +65,26 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | protected $_namePrefix; |
| 67 | 67 | |
| 68 | - public function __construct($identifier, $model, $modelInstance = NULL) { |
|
| 68 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 69 | 69 | parent::__construct($identifier, $model, $modelInstance); |
| 70 | 70 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
| 71 | - $this->_urls = []; |
|
| 72 | - $this->_emptyMessage = new HtmlMessage("", "nothing to display"); |
|
| 71 | + $this->_urls=[]; |
|
| 72 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
| 73 | 73 | $this->_emptyMessage->setIcon("info circle"); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | public function run(JsUtils $js) { |
| 77 | - if ($this->_runned !== true) { |
|
| 78 | - $offset = $js->scriptCount(); |
|
| 77 | + if ($this->_runned!==true) { |
|
| 78 | + $offset=$js->scriptCount(); |
|
| 79 | 79 | if ($this->_hasCheckboxes && isset($js)) { |
| 80 | 80 | $this->_runCheckboxes($js); |
| 81 | 81 | } |
| 82 | 82 | if ($this->_visibleHover) { |
| 83 | - $js->execOn("mouseover", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [ |
|
| 83 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'visible');", [ |
|
| 84 | 84 | "preventDefault" => false, |
| 85 | 85 | "stopPropagation" => true |
| 86 | 86 | ]); |
| 87 | - $js->execOn("mouseout", "#" . $this->identifier . " tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [ |
|
| 87 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.currentTarget).closest('tr').find('.visibleover').css('visibility', 'hidden');$(event.currentTarget).trigger('visibleoverOut');", [ |
|
| 88 | 88 | "preventDefault" => false, |
| 89 | 89 | "stopPropagation" => true |
| 90 | 90 | ]); |
@@ -101,16 +101,16 @@ discard block |
||
| 101 | 101 | $this->_associatePaginationBehavior($js, $offset); |
| 102 | 102 | } |
| 103 | 103 | $this->_associateSearchFieldBehavior($js, $offset); |
| 104 | - $this->_runned = true; |
|
| 104 | + $this->_runned=true; |
|
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | protected function _generateBehavior($op, $params, JsUtils $js) { |
| 109 | 109 | if (isset($this->_urls[$op])) { |
| 110 | - $params = \array_merge($params, [ |
|
| 110 | + $params=\array_merge($params, [ |
|
| 111 | 111 | "attr" => "data-ajax" |
| 112 | 112 | ]); |
| 113 | - $js->ajaxOnClick("#" . $this->identifier . " ._" . $op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
| 113 | + $js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
@@ -129,21 +129,21 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | public function refreshTD($fieldName, $jquery, $view) { |
| 132 | - $index = $this->_getIndex($fieldName); |
|
| 132 | + $index=$this->_getIndex($fieldName); |
|
| 133 | 133 | $this->compile($jquery, $view); |
| 134 | 134 | return $this->refreshTR() |
| 135 | 135 | ->getTable() |
| 136 | 136 | ->getCell(0, $index); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public function compile(JsUtils $js = NULL, &$view = NULL) { |
|
| 140 | - if (! $this->_generated) { |
|
| 139 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 140 | + if (!$this->_generated) { |
|
| 141 | 141 | if (isset($this->_buttonsColumn)) { |
| 142 | 142 | $this->_instanceViewer->sortColumnContent($this->_buttonsColumn, $this->_buttons); |
| 143 | 143 | } |
| 144 | 144 | $this->_instanceViewer->setInstance($this->_model); |
| 145 | - $captions = $this->_instanceViewer->getCaptions(); |
|
| 146 | - $table = $this->content["table"]; |
|
| 145 | + $captions=$this->_instanceViewer->getCaptions(); |
|
| 146 | + $table=$this->content["table"]; |
|
| 147 | 147 | if ($this->_hasCheckboxes) { |
| 148 | 148 | $this->_generateMainCheckbox($captions); |
| 149 | 149 | } |
@@ -158,17 +158,17 @@ discard block |
||
| 158 | 158 | $this->compileExtraElements($table, $captions); |
| 159 | 159 | $this->_compileSearchFieldBehavior($js); |
| 160 | 160 | |
| 161 | - $this->content = JArray::sortAssociative($this->content, [ |
|
| 161 | + $this->content=JArray::sortAssociative($this->content, [ |
|
| 162 | 162 | PositionInTable::BEFORETABLE, |
| 163 | 163 | "table", |
| 164 | 164 | PositionInTable::AFTERTABLE |
| 165 | 165 | ]); |
| 166 | - if($this->_caption!=null){ |
|
| 167 | - $this->wrap("<div class='field'><label>{$this->_caption}</label>","</div>"); |
|
| 166 | + if ($this->_caption!=null) { |
|
| 167 | + $this->wrap("<div class='field'><label>{$this->_caption}</label>", "</div>"); |
|
| 168 | 168 | } |
| 169 | 169 | $this->_compileForm(); |
| 170 | 170 | $this->_applyStyleAttributes($table); |
| 171 | - $this->_generated = true; |
|
| 171 | + $this->_generated=true; |
|
| 172 | 172 | } |
| 173 | 173 | return parent::compile($js, $view); |
| 174 | 174 | } |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | protected function _generateHeader(HtmlTable $table, $captions) { |
| 209 | - $gbFields = $this->_instanceViewer->getGroupByFields(); |
|
| 209 | + $gbFields=$this->_instanceViewer->getGroupByFields(); |
|
| 210 | 210 | if (\is_array($gbFields)) { |
| 211 | - $captions = \array_values(JArray::removeByKeys($captions, $gbFields)); |
|
| 211 | + $captions=\array_values(JArray::removeByKeys($captions, $gbFields)); |
|
| 212 | 212 | } |
| 213 | 213 | $table->setHeaderValues($captions); |
| 214 | 214 | if (isset($this->_sortable)) { |
@@ -217,22 +217,22 @@ discard block |
||
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | protected function _generateContent($table) { |
| 220 | - $objects = $this->_modelInstance; |
|
| 220 | + $objects=$this->_modelInstance; |
|
| 221 | 221 | if (isset($this->_pagination)) { |
| 222 | - $objects = $this->_pagination->getObjects($this->_modelInstance); |
|
| 222 | + $objects=$this->_pagination->getObjects($this->_modelInstance); |
|
| 223 | 223 | } |
| 224 | 224 | InstanceViewer::setIndex(0); |
| 225 | - $fields = $this->_instanceViewer->getSimpleProperties(); |
|
| 226 | - $groupByFields = $this->_instanceViewer->getGroupByFields(); |
|
| 227 | - if (! is_array($groupByFields)) { |
|
| 228 | - $table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields) { |
|
| 225 | + $fields=$this->_instanceViewer->getSimpleProperties(); |
|
| 226 | + $groupByFields=$this->_instanceViewer->getGroupByFields(); |
|
| 227 | + if (!is_array($groupByFields)) { |
|
| 228 | + $table->fromDatabaseObjects($objects, function($instance) use ($table, $fields) { |
|
| 229 | 229 | return $this->_generateRow($instance, $fields, $table); |
| 230 | 230 | }); |
| 231 | 231 | } else { |
| 232 | - $diffFields = \array_values(JArray::removeByKeys($fields, $groupByFields)); |
|
| 233 | - $activeValues = \array_combine($groupByFields, \array_fill(0, \count($groupByFields), null)); |
|
| 234 | - $uuids = []; |
|
| 235 | - $table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids, $diffFields) { |
|
| 232 | + $diffFields=\array_values(JArray::removeByKeys($fields, $groupByFields)); |
|
| 233 | + $activeValues=\array_combine($groupByFields, \array_fill(0, \count($groupByFields), null)); |
|
| 234 | + $uuids=[]; |
|
| 235 | + $table->fromDatabaseObjects($objects, function($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids, $diffFields) { |
|
| 236 | 236 | $this->_instanceViewer->setInstance($instance); |
| 237 | 237 | foreach ($groupByFields as $index => $gbField) { |
| 238 | 238 | $this->_generateGroupByRow($index, $gbField, $table, $fields, $activeValues, $uuids); |
@@ -240,8 +240,8 @@ discard block |
||
| 240 | 240 | return $this->_generateRow($instance, $diffFields, $table, null, $uuids); |
| 241 | 241 | }); |
| 242 | 242 | } |
| 243 | - if ($table->getRowCount() == 0) { |
|
| 244 | - $result = $table->addRow(); |
|
| 243 | + if ($table->getRowCount()==0) { |
|
| 244 | + $result=$table->addRow(); |
|
| 245 | 245 | $result->mergeRow(); |
| 246 | 246 | $result->setValues([ |
| 247 | 247 | $this->_emptyMessage |
@@ -250,20 +250,20 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | protected function _generateGroupByRow($index, $gbField, $table, $fields, &$activeValues, &$uuids) { |
| 253 | - $newValue = $this->_instanceViewer->getValue($gbField); |
|
| 254 | - if ($this->getElementContent($activeValues[$gbField]) !== $this->getElementContent($newValue)) { |
|
| 255 | - if ($index == 0) { |
|
| 256 | - $uuids = []; |
|
| 253 | + $newValue=$this->_instanceViewer->getValue($gbField); |
|
| 254 | + if ($this->getElementContent($activeValues[$gbField])!==$this->getElementContent($newValue)) { |
|
| 255 | + if ($index==0) { |
|
| 256 | + $uuids=[]; |
|
| 257 | 257 | } |
| 258 | - $uuid = uniqid("grp"); |
|
| 259 | - $uuids[$gbField] = $uuid; |
|
| 260 | - $id = $this->_instanceViewer->getIdentifier(); |
|
| 261 | - $result = $table->addMergeRow(sizeof($fields) + 1, $newValue); |
|
| 262 | - $result->setIdentifier($this->identifier . "-tr-gb-" . $id); |
|
| 258 | + $uuid=uniqid("grp"); |
|
| 259 | + $uuids[$gbField]=$uuid; |
|
| 260 | + $id=$this->_instanceViewer->getIdentifier(); |
|
| 261 | + $result=$table->addMergeRow(sizeof($fields)+1, $newValue); |
|
| 262 | + $result->setIdentifier($this->identifier."-tr-gb-".$id); |
|
| 263 | 263 | $result->setProperty("data-ajax", $id); |
| 264 | 264 | $result->setProperty("data-group", $uuid); |
| 265 | 265 | $result->addToProperty("class", $this->_rowClass); |
| 266 | - $activeValues[$gbField] = $newValue; |
|
| 266 | + $activeValues[$gbField]=$newValue; |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | public function getFieldValue($index) { |
| 278 | - $index = $this->_getIndex($index); |
|
| 278 | + $index=$this->_getIndex($index); |
|
| 279 | 279 | if (is_numeric($index)) { |
| 280 | - $values = $this->_instanceViewer->getValues(); |
|
| 280 | + $values=$this->_instanceViewer->getValues(); |
|
| 281 | 281 | if (isset($values[$index])) { |
| 282 | 282 | return $values[$index]; |
| 283 | 283 | } |
@@ -285,30 +285,30 @@ discard block |
||
| 285 | 285 | return null; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - protected function _generateRow($instance, $fields, &$table, $checkedClass = null, $uuids = null) { |
|
| 288 | + protected function _generateRow($instance, $fields, &$table, $checkedClass=null, $uuids=null) { |
|
| 289 | 289 | $this->_instanceViewer->setInstance($instance); |
| 290 | - InstanceViewer::$index ++; |
|
| 291 | - $values = $this->_instanceViewer->getValues(); |
|
| 292 | - $id = $this->_instanceViewer->getIdentifier(); |
|
| 293 | - $dataAjax = $id; |
|
| 294 | - $id = $this->cleanIdentifier($id); |
|
| 290 | + InstanceViewer::$index++; |
|
| 291 | + $values=$this->_instanceViewer->getValues(); |
|
| 292 | + $id=$this->_instanceViewer->getIdentifier(); |
|
| 293 | + $dataAjax=$id; |
|
| 294 | + $id=$this->cleanIdentifier($id); |
|
| 295 | 295 | if ($this->_hasCheckboxes) { |
| 296 | - $ck = new HtmlCheckbox("ck-" . $this->identifier . "-" . $id, ""); |
|
| 297 | - $checked = false; |
|
| 296 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
| 297 | + $checked=false; |
|
| 298 | 298 | if (isset($this->_checkedCallback)) { |
| 299 | - $func = $this->_checkedCallback; |
|
| 300 | - $checked = $func($instance); |
|
| 299 | + $func=$this->_checkedCallback; |
|
| 300 | + $checked=$func($instance); |
|
| 301 | 301 | } |
| 302 | 302 | $ck->setChecked($checked); |
| 303 | - $field = $ck->getField(); |
|
| 303 | + $field=$ck->getField(); |
|
| 304 | 304 | $field->setProperty("value", $dataAjax); |
| 305 | 305 | $field->setProperty("name", "selection[]"); |
| 306 | 306 | if (isset($checkedClass)) |
| 307 | 307 | $field->setClass($checkedClass); |
| 308 | 308 | \array_unshift($values, $ck); |
| 309 | 309 | } |
| 310 | - $result = $table->newRow(); |
|
| 311 | - $result->setIdentifier($this->identifier . "-tr-" . $id); |
|
| 310 | + $result=$table->newRow(); |
|
| 311 | + $result->setIdentifier($this->identifier."-tr-".$id); |
|
| 312 | 312 | $result->setProperty("data-ajax", $dataAjax); |
| 313 | 313 | $result->setValues($values); |
| 314 | 314 | $result->addToProperty("class", $this->_rowClass); |
@@ -321,66 +321,66 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | protected function _generatePagination($table) { |
| 323 | 323 | if (isset($this->_toolbar)) { |
| 324 | - if ($this->_toolbarPosition == PositionInTable::FOOTER) |
|
| 324 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
| 325 | 325 | $this->_toolbar->setFloated("left"); |
| 326 | 326 | } |
| 327 | - $footer = $table->getFooter(); |
|
| 327 | + $footer=$table->getFooter(); |
|
| 328 | 328 | $footer->mergeCol(); |
| 329 | - $this->_paginationToolbar = $this->_pagination->generateMenu($this->identifier); |
|
| 329 | + $this->_paginationToolbar=$this->_pagination->generateMenu($this->identifier); |
|
| 330 | 330 | $footer->addValues($this->_paginationToolbar); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - protected function _associatePaginationBehavior(JsUtils $js = NULL, $offset = null) { |
|
| 333 | + protected function _associatePaginationBehavior(JsUtils $js=NULL, $offset=null) { |
|
| 334 | 334 | if (isset($this->_urls["refresh"])) { |
| 335 | - $menu = $this->_pagination->getMenu(); |
|
| 335 | + $menu=$this->_pagination->getMenu(); |
|
| 336 | 336 | if (isset($menu) && isset($js)) { |
| 337 | - $js->postOnClick("#" . $menu->getIdentifier() . " .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", $this->getRefreshSelector(), [ |
|
| 337 | + $js->postOnClick("#".$menu->getIdentifier()." .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}", $this->getRefreshSelector(), [ |
|
| 338 | 338 | "preventDefault" => false, |
| 339 | 339 | "jqueryDone" => "replaceWith", |
| 340 | 340 | "hasLoader" => false, |
| 341 | - "jsCallback" => '$("#' . $this->identifier . '").trigger("pageChange");$("#' . $this->identifier . '").trigger("activeRowChange");' |
|
| 341 | + "jsCallback" => '$("#'.$this->identifier.'").trigger("pageChange");$("#'.$this->identifier.'").trigger("activeRowChange");' |
|
| 342 | 342 | ]); |
| 343 | - $page = $_POST["p"] ?? null; |
|
| 343 | + $page=$_POST["p"] ?? null; |
|
| 344 | 344 | if (isset($page)) { |
| 345 | - $js->execAtLast('$("#' . $this->getIdentifier() . ' .pagination").children("a.item").removeClass("active");$("#' . $this->getIdentifier() . ' .pagination").children("a.item[data-page=' . $page . ']:not(.no-active)").addClass("active");'); |
|
| 345 | + $js->execAtLast('$("#'.$this->getIdentifier().' .pagination").children("a.item").removeClass("active");$("#'.$this->getIdentifier().' .pagination").children("a.item[data-page='.$page.']:not(.no-active)").addClass("active");'); |
|
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - protected function _compileSearchFieldBehavior(JsUtils $js = NULL) { |
|
| 351 | + protected function _compileSearchFieldBehavior(JsUtils $js=NULL) { |
|
| 352 | 352 | if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) { |
| 353 | - $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", "#" . $this->identifier . " tbody", [ |
|
| 353 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'".JString::doubleBackSlashes($this->_model)."'}", "#".$this->identifier." tbody", [ |
|
| 354 | 354 | "preventDefault" => false, |
| 355 | 355 | "jqueryDone" => "replaceWith", |
| 356 | 356 | "hasLoader" => "internal", |
| 357 | - "jsCallback" => '$("#' . $this->identifier . '").trigger("searchTerminate",[$(self).val()]);' |
|
| 357 | + "jsCallback" => '$("#'.$this->identifier.'").trigger("searchTerminate",[$(self).val()]);' |
|
| 358 | 358 | ]); |
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - protected function _associateSearchFieldBehavior(JsUtils $js = NULL, $offset = null) {} |
|
| 362 | + protected function _associateSearchFieldBehavior(JsUtils $js=NULL, $offset=null) {} |
|
| 363 | 363 | |
| 364 | 364 | protected function _getFieldName($index) { |
| 365 | - $fieldName = parent::_getFieldName($index); |
|
| 365 | + $fieldName=parent::_getFieldName($index); |
|
| 366 | 366 | if (\is_object($fieldName)) |
| 367 | - $fieldName = "field-" . $index; |
|
| 368 | - if($this->_namePrefix!=null){ |
|
| 367 | + $fieldName="field-".$index; |
|
| 368 | + if ($this->_namePrefix!=null) { |
|
| 369 | 369 | $fieldName=$this->_namePrefix.'.'.$fieldName; |
| 370 | 370 | } |
| 371 | - return $fieldName . "[]"; |
|
| 371 | + return $fieldName."[]"; |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | protected function _getFieldCaption($index) { |
| 375 | 375 | return null; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - protected function applyToolbarPosition(string $position, $table, $captions = NULL) { |
|
| 378 | + protected function applyToolbarPosition(string $position, $table, $captions=NULL) { |
|
| 379 | 379 | switch ($position) { |
| 380 | 380 | case PositionInTable::BEFORETABLE: |
| 381 | 381 | case PositionInTable::AFTERTABLE: |
| 382 | - if (isset($this->_compileParts) === false) { |
|
| 383 | - $this->content[$position] = $this->_toolbar; |
|
| 382 | + if (isset($this->_compileParts)===false) { |
|
| 383 | + $this->content[$position]=$this->_toolbar; |
|
| 384 | 384 | } |
| 385 | 385 | break; |
| 386 | 386 | case PositionInTable::HEADER: |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - protected function _setToolbarPosition($table, $captions = NULL) { |
|
| 394 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
| 395 | 395 | if (\is_array($this->_toolbarPosition)) { |
| 396 | 396 | foreach ($this->_toolbarPosition as $tbp) { |
| 397 | 397 | $this->applyToolbarPosition($tbp, $table, $captions); |
@@ -417,11 +417,11 @@ discard block |
||
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | private function addToolbarRow($part, $table, $captions) { |
| 420 | - $hasPart = $table->hasPart($part); |
|
| 420 | + $hasPart=$table->hasPart($part); |
|
| 421 | 421 | if ($hasPart) { |
| 422 | - $row = $table->getPart($part)->addRow(\sizeof($captions)); |
|
| 422 | + $row=$table->getPart($part)->addRow(\sizeof($captions)); |
|
| 423 | 423 | } else { |
| 424 | - $row = $table->getPart($part)->getRow(0); |
|
| 424 | + $row=$table->getPart($part)->getRow(0); |
|
| 425 | 425 | } |
| 426 | 426 | $row->mergeCol(); |
| 427 | 427 | $row->setValues([ |
@@ -453,12 +453,12 @@ discard block |
||
| 453 | 453 | */ |
| 454 | 454 | public function setUrls($urls) { |
| 455 | 455 | if (\is_array($urls)) { |
| 456 | - $this->_urls["refresh"] = JArray::getValue($urls, "refresh", 0); |
|
| 457 | - $this->_urls["edit"] = JArray::getValue($urls, "edit", 1); |
|
| 458 | - $this->_urls["delete"] = JArray::getValue($urls, "delete", 2); |
|
| 459 | - $this->_urls["display"] = JArray::getValue($urls, "display", 3); |
|
| 456 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
| 457 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
| 458 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
| 459 | + $this->_urls["display"]=JArray::getValue($urls, "display", 3); |
|
| 460 | 460 | } else { |
| 461 | - $this->_urls = [ |
|
| 461 | + $this->_urls=[ |
|
| 462 | 462 | "refresh" => $urls, |
| 463 | 463 | "edit" => $urls, |
| 464 | 464 | "delete" => $urls, |
@@ -481,8 +481,8 @@ discard block |
||
| 481 | 481 | * The number of visible pages in the Pagination component |
| 482 | 482 | * @return DataTable |
| 483 | 483 | */ |
| 484 | - public function paginate($page, $total_rowcount, $items_per_page = 10, $pages_visibles = null) { |
|
| 485 | - $this->_pagination = new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
| 484 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
| 485 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
| 486 | 486 | return $this; |
| 487 | 487 | } |
| 488 | 488 | |
@@ -497,8 +497,8 @@ discard block |
||
| 497 | 497 | * The number of visible pages in the Pagination component |
| 498 | 498 | * @return DataTable |
| 499 | 499 | */ |
| 500 | - public function autoPaginate($page = 1, $items_per_page = 10, $pages_visibles = 4) { |
|
| 501 | - $this->_pagination = new Pagination($items_per_page, $pages_visibles, $page); |
|
| 500 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
| 501 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
| 502 | 502 | return $this; |
| 503 | 503 | } |
| 504 | 504 | |
@@ -507,10 +507,10 @@ discard block |
||
| 507 | 507 | * @param array $compileParts |
| 508 | 508 | * @return DataTable |
| 509 | 509 | */ |
| 510 | - public function refresh($compileParts = [ |
|
| 510 | + public function refresh($compileParts=[ |
|
| 511 | 511 | 'tbody' |
| 512 | 512 | ]) { |
| 513 | - $this->_compileParts = $compileParts; |
|
| 513 | + $this->_compileParts=$compileParts; |
|
| 514 | 514 | return $this; |
| 515 | 515 | } |
| 516 | 516 | |
@@ -520,14 +520,14 @@ discard block |
||
| 520 | 520 | * @param string $position |
| 521 | 521 | * @return \Ajax\common\html\HtmlDoubleElement |
| 522 | 522 | */ |
| 523 | - public function addSearchInToolbar($position = Direction::RIGHT) { |
|
| 523 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
| 524 | 524 | return $this->addInToolbar($this->getSearchField()) |
| 525 | 525 | ->setPosition($position); |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | public function getSearchField() { |
| 529 | - if (isset($this->_searchField) === false) { |
|
| 530 | - $this->_searchField = new HtmlInput("search-" . $this->identifier, "search", "", "Search..."); |
|
| 529 | + if (isset($this->_searchField)===false) { |
|
| 530 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
| 531 | 531 | $this->_searchField->addIcon("search", Direction::RIGHT); |
| 532 | 532 | } |
| 533 | 533 | return $this->_searchField; |
@@ -555,9 +555,9 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | protected function getTargetSelector($op) { |
| 558 | - $result = $this->_targetSelector; |
|
| 559 | - if (! isset($result[$op])) |
|
| 560 | - $result = "#" . $this->identifier; |
|
| 558 | + $result=$this->_targetSelector; |
|
| 559 | + if (!isset($result[$op])) |
|
| 560 | + $result="#".$this->identifier; |
|
| 561 | 561 | return $result[$op]; |
| 562 | 562 | } |
| 563 | 563 | |
@@ -569,20 +569,20 @@ discard block |
||
| 569 | 569 | * @return DataTable |
| 570 | 570 | */ |
| 571 | 571 | public function setTargetSelector($_targetSelector) { |
| 572 | - if (! \is_array($_targetSelector)) { |
|
| 573 | - $_targetSelector = [ |
|
| 572 | + if (!\is_array($_targetSelector)) { |
|
| 573 | + $_targetSelector=[ |
|
| 574 | 574 | "edit" => $_targetSelector, |
| 575 | 575 | "delete" => $_targetSelector |
| 576 | 576 | ]; |
| 577 | 577 | } |
| 578 | - $this->_targetSelector = $_targetSelector; |
|
| 578 | + $this->_targetSelector=$_targetSelector; |
|
| 579 | 579 | return $this; |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | public function getRefreshSelector() { |
| 583 | 583 | if (isset($this->_refreshSelector)) |
| 584 | 584 | return $this->_refreshSelector; |
| 585 | - return "#" . $this->identifier . " tbody"; |
|
| 585 | + return "#".$this->identifier." tbody"; |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | * @return DataTable |
| 592 | 592 | */ |
| 593 | 593 | public function setRefreshSelector($_refreshSelector) { |
| 594 | - $this->_refreshSelector = $_refreshSelector; |
|
| 594 | + $this->_refreshSelector=$_refreshSelector; |
|
| 595 | 595 | return $this; |
| 596 | 596 | } |
| 597 | 597 | |
@@ -603,9 +603,9 @@ discard block |
||
| 603 | 603 | public function show($modelInstance) { |
| 604 | 604 | if (\is_array($modelInstance)) { |
| 605 | 605 | if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
| 606 | - $modelInstance = \json_decode(\json_encode($modelInstance), FALSE); |
|
| 606 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
| 607 | 607 | } |
| 608 | - $this->_modelInstance = $modelInstance; |
|
| 608 | + $this->_modelInstance=$modelInstance; |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | public function getRowClass() { |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | * @return DataTable |
| 620 | 620 | */ |
| 621 | 621 | public function setRowClass($_rowClass) { |
| 622 | - $this->_rowClass = $_rowClass; |
|
| 622 | + $this->_rowClass=$_rowClass; |
|
| 623 | 623 | return $this; |
| 624 | 624 | } |
| 625 | 625 | |
@@ -630,16 +630,16 @@ discard block |
||
| 630 | 630 | * @return DataTable |
| 631 | 631 | */ |
| 632 | 632 | public function setEmptyMessage($_emptyMessage) { |
| 633 | - $this->_emptyMessage = $_emptyMessage; |
|
| 633 | + $this->_emptyMessage=$_emptyMessage; |
|
| 634 | 634 | return $this; |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | - public function setSortable($colIndex = NULL) { |
|
| 638 | - $this->_sortable = $colIndex; |
|
| 637 | + public function setSortable($colIndex=NULL) { |
|
| 638 | + $this->_sortable=$colIndex; |
|
| 639 | 639 | return $this; |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - public function setActiveRowSelector($class = "active", $event = "click", $multiple = false) { |
|
| 642 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
| 643 | 643 | $this->_self->setActiveRowSelector($class, $event, $multiple); |
| 644 | 644 | return $this; |
| 645 | 645 | } |
@@ -649,19 +649,19 @@ discard block |
||
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | public function hideColumn($colIndex) { |
| 652 | - if (! \is_array($this->_hiddenColumns)) |
|
| 653 | - $this->_hiddenColumns = []; |
|
| 654 | - $this->_hiddenColumns[] = $colIndex; |
|
| 652 | + if (!\is_array($this->_hiddenColumns)) |
|
| 653 | + $this->_hiddenColumns=[]; |
|
| 654 | + $this->_hiddenColumns[]=$colIndex; |
|
| 655 | 655 | return $this; |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | public function setColWidth($colIndex, $width) { |
| 659 | - $this->_colWidths[$colIndex] = $width; |
|
| 659 | + $this->_colWidths[$colIndex]=$width; |
|
| 660 | 660 | return $this; |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | public function setColWidths($_colWidths) { |
| 664 | - $this->_colWidths = $_colWidths; |
|
| 664 | + $this->_colWidths=$_colWidths; |
|
| 665 | 665 | return $this; |
| 666 | 666 | } |
| 667 | 667 | |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | return $this; |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - public function trigger($event, $params = "[]") { |
|
| 673 | + public function trigger($event, $params="[]") { |
|
| 674 | 674 | return $this->getHtmlComponent()->trigger($event, $params); |
| 675 | 675 | } |
| 676 | 676 | |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | * @param mixed $_displayBehavior |
| 709 | 709 | */ |
| 710 | 710 | public function setDisplayBehavior($_displayBehavior) { |
| 711 | - $this->_displayBehavior = $_displayBehavior; |
|
| 711 | + $this->_displayBehavior=$_displayBehavior; |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | /** |
@@ -728,8 +728,8 @@ discard block |
||
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | public function addGroupBy($index) { |
| 731 | - $index = $this->_getIndex($index); |
|
| 732 | - if ($index !== false) { |
|
| 731 | + $index=$this->_getIndex($index); |
|
| 732 | + if ($index!==false) { |
|
| 733 | 733 | $this->_instanceViewer->addGroupBy($index); |
| 734 | 734 | } |
| 735 | 735 | } |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | * @param boolean $_visibleHover |
| 740 | 740 | */ |
| 741 | 741 | public function setVisibleHover($_visibleHover) { |
| 742 | - $this->_visibleHover = $_visibleHover; |
|
| 742 | + $this->_visibleHover=$_visibleHover; |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | /** |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | return $this->_paginationToolbar; |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | - public function setInverted($recursive = true) { |
|
| 753 | + public function setInverted($recursive=true) { |
|
| 754 | 754 | $this->getHtmlComponent()->setInverted($recursive); |
| 755 | 755 | if ($this->_emptyMessage instanceof HtmlSemDoubleElement) { |
| 756 | 756 | $this->_emptyMessage->setInverted($recursive); |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | $this->content["table"]->setFocusable($focusable); |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | - public function setFormCaption($caption){ |
|
| 764 | + public function setFormCaption($caption) { |
|
| 765 | 765 | $this->_caption=$caption; |
| 766 | 766 | } |
| 767 | 767 | |
@@ -776,6 +776,6 @@ discard block |
||
| 776 | 776 | * @param mixed $namePrefix |
| 777 | 777 | */ |
| 778 | 778 | public function setNamePrefix($namePrefix): void { |
| 779 | - $this->_namePrefix = $namePrefix; |
|
| 779 | + $this->_namePrefix=$namePrefix; |
|
| 780 | 780 | } |
| 781 | 781 | } |
@@ -89,10 +89,12 @@ discard block |
||
| 89 | 89 | "stopPropagation" => true |
| 90 | 90 | ]); |
| 91 | 91 | } |
| 92 | - if (\is_array($this->_deleteBehavior)) |
|
| 93 | - $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
| 94 | - if (\is_array($this->_editBehavior)) |
|
| 95 | - $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
| 92 | + if (\is_array($this->_deleteBehavior)) { |
|
| 93 | + $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
| 94 | + } |
|
| 95 | + if (\is_array($this->_editBehavior)) { |
|
| 96 | + $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
| 97 | + } |
|
| 96 | 98 | if (\is_array($this->_displayBehavior)) { |
| 97 | 99 | $this->_generateBehavior("display", $this->_displayBehavior, $js); |
| 98 | 100 | } |
@@ -150,8 +152,9 @@ discard block |
||
| 150 | 152 | $table->setRowCount(0, \count($captions)); |
| 151 | 153 | $this->_generateHeader($table, $captions); |
| 152 | 154 | |
| 153 | - if (isset($this->_compileParts)) |
|
| 154 | - $table->setCompileParts($this->_compileParts); |
|
| 155 | + if (isset($this->_compileParts)) { |
|
| 156 | + $table->setCompileParts($this->_compileParts); |
|
| 157 | + } |
|
| 155 | 158 | |
| 156 | 159 | $this->_generateContent($table); |
| 157 | 160 | |
@@ -189,8 +192,9 @@ discard block |
||
| 189 | 192 | } |
| 190 | 193 | |
| 191 | 194 | protected function _applyStyleAttributes($table) { |
| 192 | - if (isset($this->_hiddenColumns)) |
|
| 193 | - $this->_hideColumns(); |
|
| 195 | + if (isset($this->_hiddenColumns)) { |
|
| 196 | + $this->_hideColumns(); |
|
| 197 | + } |
|
| 194 | 198 | if (isset($this->_colWidths)) { |
| 195 | 199 | foreach ($this->_colWidths as $colIndex => $width) { |
| 196 | 200 | $table->setColWidth($colIndex, $width); |
@@ -303,8 +307,9 @@ discard block |
||
| 303 | 307 | $field = $ck->getField(); |
| 304 | 308 | $field->setProperty("value", $dataAjax); |
| 305 | 309 | $field->setProperty("name", "selection[]"); |
| 306 | - if (isset($checkedClass)) |
|
| 307 | - $field->setClass($checkedClass); |
|
| 310 | + if (isset($checkedClass)) { |
|
| 311 | + $field->setClass($checkedClass); |
|
| 312 | + } |
|
| 308 | 313 | \array_unshift($values, $ck); |
| 309 | 314 | } |
| 310 | 315 | $result = $table->newRow(); |
@@ -321,8 +326,9 @@ discard block |
||
| 321 | 326 | |
| 322 | 327 | protected function _generatePagination($table) { |
| 323 | 328 | if (isset($this->_toolbar)) { |
| 324 | - if ($this->_toolbarPosition == PositionInTable::FOOTER) |
|
| 325 | - $this->_toolbar->setFloated("left"); |
|
| 329 | + if ($this->_toolbarPosition == PositionInTable::FOOTER) { |
|
| 330 | + $this->_toolbar->setFloated("left"); |
|
| 331 | + } |
|
| 326 | 332 | } |
| 327 | 333 | $footer = $table->getFooter(); |
| 328 | 334 | $footer->mergeCol(); |
@@ -363,8 +369,9 @@ discard block |
||
| 363 | 369 | |
| 364 | 370 | protected function _getFieldName($index) { |
| 365 | 371 | $fieldName = parent::_getFieldName($index); |
| 366 | - if (\is_object($fieldName)) |
|
| 367 | - $fieldName = "field-" . $index; |
|
| 372 | + if (\is_object($fieldName)) { |
|
| 373 | + $fieldName = "field-" . $index; |
|
| 374 | + } |
|
| 368 | 375 | if($this->_namePrefix!=null){ |
| 369 | 376 | $fieldName=$this->_namePrefix.'.'.$fieldName; |
| 370 | 377 | } |
@@ -556,8 +563,9 @@ discard block |
||
| 556 | 563 | |
| 557 | 564 | protected function getTargetSelector($op) { |
| 558 | 565 | $result = $this->_targetSelector; |
| 559 | - if (! isset($result[$op])) |
|
| 560 | - $result = "#" . $this->identifier; |
|
| 566 | + if (! isset($result[$op])) { |
|
| 567 | + $result = "#" . $this->identifier; |
|
| 568 | + } |
|
| 561 | 569 | return $result[$op]; |
| 562 | 570 | } |
| 563 | 571 | |
@@ -580,8 +588,9 @@ discard block |
||
| 580 | 588 | } |
| 581 | 589 | |
| 582 | 590 | public function getRefreshSelector() { |
| 583 | - if (isset($this->_refreshSelector)) |
|
| 584 | - return $this->_refreshSelector; |
|
| 591 | + if (isset($this->_refreshSelector)) { |
|
| 592 | + return $this->_refreshSelector; |
|
| 593 | + } |
|
| 585 | 594 | return "#" . $this->identifier . " tbody"; |
| 586 | 595 | } |
| 587 | 596 | |
@@ -602,8 +611,9 @@ discard block |
||
| 602 | 611 | */ |
| 603 | 612 | public function show($modelInstance) { |
| 604 | 613 | if (\is_array($modelInstance)) { |
| 605 | - if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
|
| 606 | - $modelInstance = \json_decode(\json_encode($modelInstance), FALSE); |
|
| 614 | + if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) { |
|
| 615 | + $modelInstance = \json_decode(\json_encode($modelInstance), FALSE); |
|
| 616 | + } |
|
| 607 | 617 | } |
| 608 | 618 | $this->_modelInstance = $modelInstance; |
| 609 | 619 | } |
@@ -649,8 +659,9 @@ discard block |
||
| 649 | 659 | } |
| 650 | 660 | |
| 651 | 661 | public function hideColumn($colIndex) { |
| 652 | - if (! \is_array($this->_hiddenColumns)) |
|
| 653 | - $this->_hiddenColumns = []; |
|
| 662 | + if (! \is_array($this->_hiddenColumns)) { |
|
| 663 | + $this->_hiddenColumns = []; |
|
| 664 | + } |
|
| 654 | 665 | $this->_hiddenColumns[] = $colIndex; |
| 655 | 666 | return $this; |
| 656 | 667 | } |
@@ -14,15 +14,15 @@ discard block |
||
| 14 | 14 | * @property boolean $_visibleHover |
| 15 | 15 | * @property InstanceViewer $_instanceViewer |
| 16 | 16 | */ |
| 17 | -trait DataTableFieldAsTrait{ |
|
| 18 | - protected $_buttons=["display","edit","delete"]; |
|
| 17 | +trait DataTableFieldAsTrait { |
|
| 18 | + protected $_buttons=["display", "edit", "delete"]; |
|
| 19 | 19 | protected $_buttonsColumn; |
| 20 | - abstract public function addField($field,$key=null); |
|
| 21 | - abstract public function insertField($index,$field,$key=null); |
|
| 22 | - abstract public function insertInField($index,$field,$key=null); |
|
| 23 | - abstract public function fieldAs($index,$type,$attributes=NULL); |
|
| 20 | + abstract public function addField($field, $key=null); |
|
| 21 | + abstract public function insertField($index, $field, $key=null); |
|
| 22 | + abstract public function insertInField($index, $field, $key=null); |
|
| 23 | + abstract public function fieldAs($index, $type, $attributes=NULL); |
|
| 24 | 24 | abstract protected function cleanIdentifier($id); |
| 25 | - abstract protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null); |
|
| 25 | + abstract protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @param string $caption |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | * @param boolean $visibleHover |
| 31 | 31 | * @return callable |
| 32 | 32 | */ |
| 33 | - private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
|
| 34 | - return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
|
| 33 | + private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) { |
|
| 34 | + return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -40,20 +40,20 @@ discard block |
||
| 40 | 40 | * @param callable $callback |
| 41 | 41 | * @return callable |
| 42 | 42 | */ |
| 43 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
| 44 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
| 45 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
| 46 | - if(isset($callback)){ |
|
| 47 | - if(\is_callable($callback)){ |
|
| 48 | - $callback($object,$instance,$this->_instanceViewer->count()+1); |
|
| 43 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
| 44 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
| 45 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
| 46 | + if (isset($callback)) { |
|
| 47 | + if (\is_callable($callback)) { |
|
| 48 | + $callback($object, $instance, $this->_instanceViewer->count()+1); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | - if($object instanceof HtmlSemDoubleElement){ |
|
| 51 | + if ($object instanceof HtmlSemDoubleElement) { |
|
| 52 | 52 | $id=$this->_instanceViewer->getIdentifier(); |
| 53 | - $object->setProperty("data-ajax",$id); |
|
| 54 | - if($object->propertyContains("class","visibleover")){ |
|
| 53 | + $object->setProperty("data-ajax", $id); |
|
| 54 | + if ($object->propertyContains("class", "visibleover")) { |
|
| 55 | 55 | $this->_visibleHover=true; |
| 56 | - $object->setProperty("style","visibility:hidden;"); |
|
| 56 | + $object->setProperty("style", "visibility:hidden;"); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | return $object; |
@@ -65,17 +65,17 @@ discard block |
||
| 65 | 65 | * @param string $caption |
| 66 | 66 | * @return HtmlButton |
| 67 | 67 | */ |
| 68 | - private function getFieldButton($caption,$visibleHover=true,$icon=null){ |
|
| 68 | + private function getFieldButton($caption, $visibleHover=true, $icon=null) { |
|
| 69 | 69 | $id=$this->_instanceViewer->getIdentifier(); |
| 70 | - $bt= new HtmlButton($this->cleanIdentifier($icon??$caption).'-'.$id,$caption); |
|
| 71 | - if($visibleHover) |
|
| 70 | + $bt=new HtmlButton($this->cleanIdentifier($icon ?? $caption).'-'.$id, $caption); |
|
| 71 | + if ($visibleHover) |
|
| 72 | 72 | $this->_visibleOver($bt); |
| 73 | 73 | return $bt; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - private function getFieldButtons($buttons,$visibleHover=true){ |
|
| 77 | - $bts=new HtmlButtonGroups("",$buttons); |
|
| 78 | - if($visibleHover) |
|
| 76 | + private function getFieldButtons($buttons, $visibleHover=true) { |
|
| 77 | + $bts=new HtmlButtonGroups("", $buttons); |
|
| 78 | + if ($visibleHover) |
|
| 79 | 79 | $this->_visibleOver($bts); |
| 80 | 80 | return $bts; |
| 81 | 81 | } |
@@ -89,19 +89,19 @@ discard block |
||
| 89 | 89 | * @param array $attributes associative array (<b>ajax</b> key is for ajax post) |
| 90 | 90 | * @return DataTable |
| 91 | 91 | */ |
| 92 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
| 93 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
| 94 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 95 | - $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
|
| 96 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 92 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
| 93 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
| 94 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 95 | + $button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]); |
|
| 96 | + if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 97 | 97 | $this->_visibleOver($button); |
| 98 | 98 | return $button; |
| 99 | - }, $index,$attributes); |
|
| 99 | + }, $index, $attributes); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - protected function _visibleOver(BaseHtml $element){ |
|
| 102 | + protected function _visibleOver(BaseHtml $element) { |
|
| 103 | 103 | $this->_visibleHover=true; |
| 104 | - return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
|
| 104 | + return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;"); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | * @param boolean $visibleHover |
| 112 | 112 | * @return DataTable |
| 113 | 113 | */ |
| 114 | - public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
|
| 115 | - $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
|
| 114 | + public function addFieldButton($caption, $visibleHover=true, $callback=null) { |
|
| 115 | + $this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback)); |
|
| 116 | 116 | return $this; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | * @param boolean $visibleHover |
| 124 | 124 | * @return DataTable |
| 125 | 125 | */ |
| 126 | - public function addFieldButtons($buttons,$visibleHover=true,$callback=null){ |
|
| 127 | - $this->addField($this->getCallable("getFieldButtons",[$buttons,$visibleHover],$callback)); |
|
| 126 | + public function addFieldButtons($buttons, $visibleHover=true, $callback=null) { |
|
| 127 | + $this->addField($this->getCallable("getFieldButtons", [$buttons, $visibleHover], $callback)); |
|
| 128 | 128 | return $this; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | * @param callable $callback |
| 136 | 136 | * @return DataTable |
| 137 | 137 | */ |
| 138 | - public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
| 139 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
| 138 | + public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
| 139 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
| 140 | 140 | return $this; |
| 141 | 141 | } |
| 142 | 142 | |
@@ -147,25 +147,25 @@ discard block |
||
| 147 | 147 | * @param callable $callback |
| 148 | 148 | * @return DataTable |
| 149 | 149 | */ |
| 150 | - public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null,$key=null){ |
|
| 151 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback),$key); |
|
| 150 | + public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null, $key=null) { |
|
| 151 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback), $key); |
|
| 152 | 152 | return $this; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - public function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null,$key=null){ |
|
| 156 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback),$key); |
|
| 155 | + public function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null, $key=null) { |
|
| 156 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback), $key); |
|
| 157 | 157 | return $this; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null,$key=null){ |
|
| 161 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback),$key); |
|
| 160 | + public function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null, $key=null) { |
|
| 161 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback), $key); |
|
| 162 | 162 | return $this; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
|
| 166 | - $bt=$this->getFieldButton("",$visibleHover,$icon); |
|
| 165 | + private function getDefaultButton($icon, $class=null, $visibleHover=true) { |
|
| 166 | + $bt=$this->getFieldButton("", $visibleHover, $icon); |
|
| 167 | 167 | $bt->asIcon($icon); |
| 168 | - if(isset($class)) |
|
| 168 | + if (isset($class)) |
|
| 169 | 169 | $bt->addClass($class); |
| 170 | 170 | return $bt; |
| 171 | 171 | } |
@@ -177,9 +177,9 @@ discard block |
||
| 177 | 177 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 178 | 178 | * @return DataTable |
| 179 | 179 | */ |
| 180 | - public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
| 180 | + public function addDeleteButton($visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
| 181 | 181 | $this->_deleteBehavior=$deleteBehavior; |
| 182 | - return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback,"delete"); |
|
| 182 | + return $this->addDefaultButton("remove", "_delete red basic", $visibleHover, $callback, "delete"); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -189,9 +189,9 @@ discard block |
||
| 189 | 189 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 190 | 190 | * @return DataTable |
| 191 | 191 | */ |
| 192 | - public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){ |
|
| 192 | + public function addEditButton($visibleHover=true, $editBehavior=[], $callback=null) { |
|
| 193 | 193 | $this->_editBehavior=$editBehavior; |
| 194 | - return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback,"edit"); |
|
| 194 | + return $this->addDefaultButton("edit", "_edit basic", $visibleHover, $callback, "edit"); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -201,9 +201,9 @@ discard block |
||
| 201 | 201 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 202 | 202 | * @return DataTable |
| 203 | 203 | */ |
| 204 | - public function addDisplayButton($visibleHover=true,$displayBehavior=[],$callback=null){ |
|
| 204 | + public function addDisplayButton($visibleHover=true, $displayBehavior=[], $callback=null) { |
|
| 205 | 205 | $this->_displayBehavior=$displayBehavior; |
| 206 | - return $this->addDefaultButton("eye","_display basic",$visibleHover,$callback,"display"); |
|
| 206 | + return $this->addDefaultButton("eye", "_display basic", $visibleHover, $callback, "display"); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -214,10 +214,10 @@ discard block |
||
| 214 | 214 | * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 215 | 215 | * @return DataTable |
| 216 | 216 | */ |
| 217 | - public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){ |
|
| 218 | - $this->addEditButton($visibleHover,$behavior,$callbackEdit); |
|
| 217 | + public function addEditDeleteButtons($visibleHover=true, $behavior=[], $callbackEdit=null, $callbackDelete=null) { |
|
| 218 | + $this->addEditButton($visibleHover, $behavior, $callbackEdit); |
|
| 219 | 219 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
| 220 | - $this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete); |
|
| 220 | + $this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete); |
|
| 221 | 221 | return $this; |
| 222 | 222 | } |
| 223 | 223 | |
@@ -230,28 +230,28 @@ discard block |
||
| 230 | 230 | * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 231 | 231 | * @return DataTable |
| 232 | 232 | */ |
| 233 | - public function addAllButtons($visibleHover=true,$behavior=[],$callbackDisplay=null,$callbackEdit=null,$callbackDelete=null){ |
|
| 234 | - $this->addDisplayButton($visibleHover,$behavior,$callbackDisplay); |
|
| 233 | + public function addAllButtons($visibleHover=true, $behavior=[], $callbackDisplay=null, $callbackEdit=null, $callbackDelete=null) { |
|
| 234 | + $this->addDisplayButton($visibleHover, $behavior, $callbackDisplay); |
|
| 235 | 235 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
| 236 | 236 | $this->_buttonsColumn=$index; |
| 237 | - $this->insertEditButtonIn($index,$visibleHover,$behavior,$callbackEdit); |
|
| 238 | - $this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete); |
|
| 237 | + $this->insertEditButtonIn($index, $visibleHover, $behavior, $callbackEdit); |
|
| 238 | + $this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete); |
|
| 239 | 239 | return $this; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
| 242 | + public function insertDeleteButtonIn($index, $visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
| 243 | 243 | $this->_deleteBehavior=$deleteBehavior; |
| 244 | - return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback,"delete"); |
|
| 244 | + return $this->insertDefaultButtonIn($index, "remove", "_delete red basic", $visibleHover, $callback, "delete"); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - public function insertEditButtonIn($index,$visibleHover=true,$editBehavior=[],$callback=null){ |
|
| 247 | + public function insertEditButtonIn($index, $visibleHover=true, $editBehavior=[], $callback=null) { |
|
| 248 | 248 | $this->_editBehavior=$editBehavior; |
| 249 | - return $this->insertDefaultButtonIn($index,"edit","_edit basic",$visibleHover,$callback,"edit"); |
|
| 249 | + return $this->insertDefaultButtonIn($index, "edit", "_edit basic", $visibleHover, $callback, "edit"); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - public function insertDisplayButtonIn($index,$visibleHover=true,$displayBehavior=[],$callback=null){ |
|
| 252 | + public function insertDisplayButtonIn($index, $visibleHover=true, $displayBehavior=[], $callback=null) { |
|
| 253 | 253 | $this->_displayBehavior=$displayBehavior; |
| 254 | - return $this->insertDefaultButtonIn($index,"eye","_display basic",$visibleHover,$callback,"display"); |
|
| 254 | + return $this->insertDefaultButtonIn($index, "eye", "_display basic", $visibleHover, $callback, "display"); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * @param array $_buttons |
| 266 | 266 | */ |
| 267 | 267 | public function setButtons($_buttons) { |
| 268 | - $this->_buttons = $_buttons; |
|
| 268 | + $this->_buttons=$_buttons; |
|
| 269 | 269 | return $this; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -68,15 +68,17 @@ discard block |
||
| 68 | 68 | private function getFieldButton($caption,$visibleHover=true,$icon=null){ |
| 69 | 69 | $id=$this->_instanceViewer->getIdentifier(); |
| 70 | 70 | $bt= new HtmlButton($this->cleanIdentifier($icon??$caption).'-'.$id,$caption); |
| 71 | - if($visibleHover) |
|
| 72 | - $this->_visibleOver($bt); |
|
| 71 | + if($visibleHover) { |
|
| 72 | + $this->_visibleOver($bt); |
|
| 73 | + } |
|
| 73 | 74 | return $bt; |
| 74 | 75 | } |
| 75 | 76 | |
| 76 | 77 | private function getFieldButtons($buttons,$visibleHover=true){ |
| 77 | 78 | $bts=new HtmlButtonGroups("",$buttons); |
| 78 | - if($visibleHover) |
|
| 79 | - $this->_visibleOver($bts); |
|
| 79 | + if($visibleHover) { |
|
| 80 | + $this->_visibleOver($bts); |
|
| 81 | + } |
|
| 80 | 82 | return $bts; |
| 81 | 83 | } |
| 82 | 84 | |
@@ -93,8 +95,9 @@ discard block |
||
| 93 | 95 | return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
| 94 | 96 | $button=new HtmlButton($id,$value,$cssStyle); |
| 95 | 97 | $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
| 96 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 97 | - $this->_visibleOver($button); |
|
| 98 | + if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) { |
|
| 99 | + $this->_visibleOver($button); |
|
| 100 | + } |
|
| 98 | 101 | return $button; |
| 99 | 102 | }, $index,$attributes); |
| 100 | 103 | } |
@@ -165,8 +168,9 @@ discard block |
||
| 165 | 168 | private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
| 166 | 169 | $bt=$this->getFieldButton("",$visibleHover,$icon); |
| 167 | 170 | $bt->asIcon($icon); |
| 168 | - if(isset($class)) |
|
| 169 | - $bt->addClass($class); |
|
| 171 | + if(isset($class)) { |
|
| 172 | + $bt->addClass($class); |
|
| 173 | + } |
|
| 170 | 174 | return $bt; |
| 171 | 175 | } |
| 172 | 176 | |
@@ -29,17 +29,17 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | protected $groupByFields; |
| 31 | 31 | |
| 32 | - public static $index = 0; |
|
| 32 | + public static $index=0; |
|
| 33 | 33 | |
| 34 | - public function __construct($identifier, $instance = NULL, $captions = NULL) { |
|
| 35 | - $this->widgetIdentifier = $identifier; |
|
| 36 | - $this->values = []; |
|
| 37 | - $this->afterCompile = []; |
|
| 34 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
| 35 | + $this->widgetIdentifier=$identifier; |
|
| 36 | + $this->values=[]; |
|
| 37 | + $this->afterCompile=[]; |
|
| 38 | 38 | if (isset($instance)) |
| 39 | 39 | $this->setInstance($instance); |
| 40 | 40 | $this->setCaptions($captions); |
| 41 | - $this->captionCallback = NULL; |
|
| 42 | - $this->defaultValueFunction = function ($name, $value) { |
|
| 41 | + $this->captionCallback=NULL; |
|
| 42 | + $this->defaultValueFunction=function($name, $value) { |
|
| 43 | 43 | return $value; |
| 44 | 44 | }; |
| 45 | 45 | } |
@@ -66,47 +66,47 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | public function getValues() { |
| 69 | - $values = []; |
|
| 70 | - $index = 0; |
|
| 71 | - $count = $this->count(); |
|
| 72 | - $hasGroupby = is_array($this->groupByFields); |
|
| 73 | - if (! $hasGroupby) { |
|
| 74 | - while ($index < $count) { |
|
| 75 | - $values[] = $this->getValue($index ++); |
|
| 69 | + $values=[]; |
|
| 70 | + $index=0; |
|
| 71 | + $count=$this->count(); |
|
| 72 | + $hasGroupby=is_array($this->groupByFields); |
|
| 73 | + if (!$hasGroupby) { |
|
| 74 | + while ($index<$count) { |
|
| 75 | + $values[]=$this->getValue($index++); |
|
| 76 | 76 | } |
| 77 | 77 | } else { |
| 78 | - while ($index < $count) { |
|
| 79 | - if (array_search($index, $this->groupByFields) === false) { |
|
| 80 | - $values[] = $this->getValue($index); |
|
| 78 | + while ($index<$count) { |
|
| 79 | + if (array_search($index, $this->groupByFields)===false) { |
|
| 80 | + $values[]=$this->getValue($index); |
|
| 81 | 81 | } |
| 82 | - $index ++; |
|
| 82 | + $index++; |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | return $values; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function getIdentifier($index = NULL) { |
|
| 89 | - if (! isset($index)) |
|
| 90 | - $index = self::$index; |
|
| 91 | - $value = $index; |
|
| 88 | + public function getIdentifier($index=NULL) { |
|
| 89 | + if (!isset($index)) |
|
| 90 | + $index=self::$index; |
|
| 91 | + $value=$index; |
|
| 92 | 92 | if (isset($this->values["identifier"])) { |
| 93 | 93 | if (\is_string($this->values["identifier"])) |
| 94 | - $value = JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
| 94 | + $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
| 95 | 95 | else |
| 96 | - $value = $this->values["identifier"]($index, $this->instance); |
|
| 96 | + $value=$this->values["identifier"]($index, $this->instance); |
|
| 97 | 97 | } |
| 98 | 98 | return $value; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | public function getValue($index) { |
| 102 | - $property = $this->properties[$index]; |
|
| 102 | + $property=$this->properties[$index]; |
|
| 103 | 103 | return $this->_getValue($property, $index); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | protected function _beforeAddProperty($index, &$field) {} |
| 107 | 107 | |
| 108 | 108 | protected function _getDefaultValue($name, $value, $index) { |
| 109 | - $func = $this->defaultValueFunction; |
|
| 109 | + $func=$this->defaultValueFunction; |
|
| 110 | 110 | return $func($name, $value, $index, $this->instance); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -116,27 +116,27 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | protected function _getValue($property, $index) { |
| 119 | - $value = null; |
|
| 120 | - $propertyName = $property; |
|
| 119 | + $value=null; |
|
| 120 | + $propertyName=$property; |
|
| 121 | 121 | if ($property instanceof \ReflectionProperty) { |
| 122 | - $value = $this->_getPropertyValue($property); |
|
| 123 | - $propertyName = $property->getName(); |
|
| 124 | - } elseif (\is_callable($property) && \array_search($property, ['system','date']) === false){ |
|
| 125 | - try{ |
|
| 126 | - $value = $property($this->instance); |
|
| 127 | - }catch(\Error $e){} |
|
| 122 | + $value=$this->_getPropertyValue($property); |
|
| 123 | + $propertyName=$property->getName(); |
|
| 124 | + } elseif (\is_callable($property) && \array_search($property, ['system', 'date'])===false) { |
|
| 125 | + try { |
|
| 126 | + $value=$property($this->instance); |
|
| 127 | + }catch (\Error $e) {} |
|
| 128 | 128 | } |
| 129 | 129 | elseif (\is_array($property)) { |
| 130 | - $values = \array_map(function ($v) use ($index) { |
|
| 130 | + $values=\array_map(function($v) use ($index) { |
|
| 131 | 131 | return $this->_getValue($v, $index); |
| 132 | 132 | }, $property); |
| 133 | - $value = \implode('', $values); |
|
| 133 | + $value=\implode('', $values); |
|
| 134 | 134 | } elseif (\is_string($property)) { |
| 135 | - $value = ''; |
|
| 135 | + $value=''; |
|
| 136 | 136 | if (isset($this->instance->{$property})) { |
| 137 | - $value = $this->instance->{$property}; |
|
| 138 | - } elseif (\method_exists($this->instance, $getter = JReflection::getterName($property))) { |
|
| 139 | - $value = JReflection::callMethod($this->instance, $getter, []); |
|
| 137 | + $value=$this->instance->{$property}; |
|
| 138 | + } elseif (\method_exists($this->instance, $getter=JReflection::getterName($property))) { |
|
| 139 | + $value=JReflection::callMethod($this->instance, $getter, []); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
@@ -145,9 +145,9 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | protected function _postGetValue($index, $propertyName, $value) { |
| 147 | 147 | if (isset($this->values[$index])) { |
| 148 | - $value = $this->values[$index]($value, $this->instance, $index, self::$index); |
|
| 148 | + $value=$this->values[$index]($value, $this->instance, $index, self::$index); |
|
| 149 | 149 | } else { |
| 150 | - $value = $this->_getDefaultValue($propertyName, $value, $index); |
|
| 150 | + $value=$this->_getDefaultValue($propertyName, $value, $index); |
|
| 151 | 151 | } |
| 152 | 152 | if (isset($this->afterCompile[$index])) { |
| 153 | 153 | if (\is_callable($this->afterCompile[$index])) { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | return $value; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function insertField($index, $field, $key = null) { |
|
| 160 | + public function insertField($index, $field, $key=null) { |
|
| 161 | 161 | if (isset($key)) { |
| 162 | 162 | array_splice($this->visibleProperties, $index, 0, [ |
| 163 | 163 | $key => $field |
@@ -171,29 +171,29 @@ discard block |
||
| 171 | 171 | public function sortColumnContent($index, $array) { |
| 172 | 172 | if (isset($this->visibleProperties[$index])) { |
| 173 | 173 | if (is_array($this->visibleProperties[$index])) { |
| 174 | - $this->visibleProperties[$index] = JArray::sortAssociative($this->visibleProperties[$index], $array); |
|
| 174 | + $this->visibleProperties[$index]=JArray::sortAssociative($this->visibleProperties[$index], $array); |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | return $this; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - public function insertInField($index, $field, $key = null) { |
|
| 181 | - $vb = $this->visibleProperties; |
|
| 180 | + public function insertInField($index, $field, $key=null) { |
|
| 181 | + $vb=$this->visibleProperties; |
|
| 182 | 182 | if (isset($vb[$index])) { |
| 183 | 183 | if (isset($key)) { |
| 184 | 184 | if (\is_array($vb[$index])) { |
| 185 | - $this->visibleProperties[$index][$key] = $field; |
|
| 185 | + $this->visibleProperties[$index][$key]=$field; |
|
| 186 | 186 | } else { |
| 187 | - $this->visibleProperties[$index] = [ |
|
| 187 | + $this->visibleProperties[$index]=[ |
|
| 188 | 188 | $vb[$index], |
| 189 | 189 | $key => $field |
| 190 | 190 | ]; |
| 191 | 191 | } |
| 192 | 192 | } else { |
| 193 | 193 | if (\is_array($vb[$index])) { |
| 194 | - $this->visibleProperties[$index][] = $field; |
|
| 194 | + $this->visibleProperties[$index][]=$field; |
|
| 195 | 195 | } else { |
| 196 | - $this->visibleProperties[$index] = [ |
|
| 196 | + $this->visibleProperties[$index]=[ |
|
| 197 | 197 | $vb[$index], |
| 198 | 198 | $field |
| 199 | 199 | ]; |
@@ -205,19 +205,19 @@ discard block |
||
| 205 | 205 | return $this; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - public function addField($field, $key = null) { |
|
| 208 | + public function addField($field, $key=null) { |
|
| 209 | 209 | if (isset($key)) { |
| 210 | - $this->visibleProperties[] = [ |
|
| 210 | + $this->visibleProperties[]=[ |
|
| 211 | 211 | $key => $field |
| 212 | 212 | ]; |
| 213 | 213 | } else { |
| 214 | - $this->visibleProperties[] = $field; |
|
| 214 | + $this->visibleProperties[]=$field; |
|
| 215 | 215 | } |
| 216 | 216 | return $this; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | public function addFields($fields) { |
| 220 | - $this->visibleProperties = \array_merge($this->visibleProperties, $fields); |
|
| 220 | + $this->visibleProperties=\array_merge($this->visibleProperties, $fields); |
|
| 221 | 221 | return $this; |
| 222 | 222 | } |
| 223 | 223 | |
@@ -234,37 +234,37 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | public function getFieldName($index) { |
| 237 | - $property = $this->getProperty($index); |
|
| 237 | + $property=$this->getProperty($index); |
|
| 238 | 238 | if ($property instanceof \ReflectionProperty) { |
| 239 | - $result = $property->getName(); |
|
| 239 | + $result=$property->getName(); |
|
| 240 | 240 | } elseif (\is_callable($property)) { |
| 241 | - $result = $this->visibleProperties[$index]; |
|
| 241 | + $result=$this->visibleProperties[$index]; |
|
| 242 | 242 | } else { |
| 243 | - $result = $property; |
|
| 243 | + $result=$property; |
|
| 244 | 244 | } |
| 245 | 245 | return $result; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | protected function showableProperty(\ReflectionProperty $rProperty) { |
| 249 | - return JString::startswith($rProperty->getName(), "_") === false; |
|
| 249 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | public function setInstance($instance) { |
| 253 | 253 | if (\is_string($instance) && \class_exists($instance)) { |
| 254 | - $instance = new $instance(); |
|
| 254 | + $instance=new $instance(); |
|
| 255 | 255 | } |
| 256 | - $this->instance = $instance; |
|
| 257 | - $this->properties = []; |
|
| 258 | - try{ |
|
| 259 | - $this->reflect = new \ReflectionClass($instance); |
|
| 260 | - if (JArray::count($this->visibleProperties) === 0) { |
|
| 261 | - $this->properties = $this->getDefaultProperties(); |
|
| 256 | + $this->instance=$instance; |
|
| 257 | + $this->properties=[]; |
|
| 258 | + try { |
|
| 259 | + $this->reflect=new \ReflectionClass($instance); |
|
| 260 | + if (JArray::count($this->visibleProperties)===0) { |
|
| 261 | + $this->properties=$this->getDefaultProperties(); |
|
| 262 | 262 | } else { |
| 263 | 263 | foreach ($this->visibleProperties as $property) { |
| 264 | 264 | $this->setInstanceProperty($property); |
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | - }catch (\Throwable $th){ |
|
| 267 | + }catch (\Throwable $th) { |
|
| 268 | 268 | |
| 269 | 269 | } |
| 270 | 270 | return $this; |
@@ -272,56 +272,56 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | private function setInstanceProperty($property) { |
| 274 | 274 | if (\is_callable($property)) { |
| 275 | - $this->properties[] = $property; |
|
| 275 | + $this->properties[]=$property; |
|
| 276 | 276 | } elseif (\is_string($property)) { |
| 277 | 277 | try { |
| 278 | 278 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 279 | - $rProperty = $this->reflect->getProperty($property); |
|
| 280 | - $this->properties[] = $rProperty; |
|
| 281 | - } catch (\Exception $e) { |
|
| 279 | + $rProperty=$this->reflect->getProperty($property); |
|
| 280 | + $this->properties[]=$rProperty; |
|
| 281 | + }catch (\Exception $e) { |
|
| 282 | 282 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 283 | - $this->properties[] = $property; |
|
| 283 | + $this->properties[]=$property; |
|
| 284 | 284 | } |
| 285 | 285 | } elseif (\is_int($property)) { |
| 286 | - $props = $this->getDefaultProperties(); |
|
| 286 | + $props=$this->getDefaultProperties(); |
|
| 287 | 287 | if (isset($props[$property])) |
| 288 | - $this->properties[] = $props[$property]; |
|
| 288 | + $this->properties[]=$props[$property]; |
|
| 289 | 289 | else |
| 290 | - $this->properties[] = $property; |
|
| 290 | + $this->properties[]=$property; |
|
| 291 | 291 | } else { |
| 292 | - $this->properties[] = $property; |
|
| 292 | + $this->properties[]=$property; |
|
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | protected function getDefaultProperties() { |
| 297 | - $result = []; |
|
| 298 | - $properties = $this->reflect->getProperties(); |
|
| 297 | + $result=[]; |
|
| 298 | + $properties=$this->reflect->getProperties(); |
|
| 299 | 299 | foreach ($properties as $property) { |
| 300 | - $showable = $this->showableProperty($property); |
|
| 301 | - if ($showable !== false) { |
|
| 302 | - $result[] = $property; |
|
| 300 | + $showable=$this->showableProperty($property); |
|
| 301 | + if ($showable!==false) { |
|
| 302 | + $result[]=$property; |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | return $result; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | public function setVisibleProperties($visibleProperties) { |
| 309 | - $this->visibleProperties = $visibleProperties; |
|
| 309 | + $this->visibleProperties=$visibleProperties; |
|
| 310 | 310 | return $this; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | public function setValueFunction($index, $callback) { |
| 314 | - $this->values[$index] = $callback; |
|
| 314 | + $this->values[$index]=$callback; |
|
| 315 | 315 | return $this; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | public function setIdentifierFunction($callback) { |
| 319 | - $this->values["identifier"] = $callback; |
|
| 319 | + $this->values["identifier"]=$callback; |
|
| 320 | 320 | return $this; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | public static function setIndex($index) { |
| 324 | - self::$index = $index; |
|
| 324 | + self::$index=$index; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | public function getProperties() { |
@@ -341,43 +341,43 @@ discard block |
||
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | public function getCaptions() { |
| 344 | - $hasGroupby = is_array($this->groupByFields); |
|
| 345 | - $count = $this->count(); |
|
| 346 | - $moreAdded = false; |
|
| 344 | + $hasGroupby=is_array($this->groupByFields); |
|
| 345 | + $count=$this->count(); |
|
| 346 | + $moreAdded=false; |
|
| 347 | 347 | if (isset($this->captions)) { |
| 348 | - $captions = \array_values($this->captions); |
|
| 349 | - $gbSize = $hasGroupby ? sizeof($this->groupByFields) : 0; |
|
| 350 | - $captionsSize = \sizeof($captions); |
|
| 351 | - for ($i = $captionsSize; $i < $count - $gbSize; $i ++) { |
|
| 352 | - $captions[] = ""; |
|
| 353 | - $moreAdded = true; |
|
| 348 | + $captions=\array_values($this->captions); |
|
| 349 | + $gbSize=$hasGroupby ? sizeof($this->groupByFields) : 0; |
|
| 350 | + $captionsSize=\sizeof($captions); |
|
| 351 | + for ($i=$captionsSize; $i<$count-$gbSize; $i++) { |
|
| 352 | + $captions[]=""; |
|
| 353 | + $moreAdded=true; |
|
| 354 | 354 | } |
| 355 | 355 | } else { |
| 356 | - $captions = []; |
|
| 357 | - $index = 0; |
|
| 358 | - while ($index < $count) { |
|
| 359 | - $captions[] = $this->getCaption($index ++); |
|
| 356 | + $captions=[]; |
|
| 357 | + $index=0; |
|
| 358 | + while ($index<$count) { |
|
| 359 | + $captions[]=$this->getCaption($index++); |
|
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | - if ($hasGroupby && sizeof($captions) >= $count && ! $moreAdded) { |
|
| 363 | - $captions = JArray::removeByKeys($captions, $this->groupByFields); |
|
| 362 | + if ($hasGroupby && sizeof($captions)>=$count && !$moreAdded) { |
|
| 363 | + $captions=JArray::removeByKeys($captions, $this->groupByFields); |
|
| 364 | 364 | } |
| 365 | 365 | if (isset($this->captionCallback) && \is_callable($this->captionCallback)) { |
| 366 | - $callback = $this->captionCallback; |
|
| 366 | + $callback=$this->captionCallback; |
|
| 367 | 367 | $callback($captions, $this->instance); |
| 368 | 368 | } |
| 369 | 369 | return $captions; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | public function setCaption($index, $caption) { |
| 373 | - if (isset($this->captions) === false) |
|
| 374 | - $this->captions = []; |
|
| 375 | - $this->captions[$index] = $caption; |
|
| 373 | + if (isset($this->captions)===false) |
|
| 374 | + $this->captions=[]; |
|
| 375 | + $this->captions[$index]=$caption; |
|
| 376 | 376 | return $this; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | public function setCaptions($captions) { |
| 380 | - $this->captions = $captions; |
|
| 380 | + $this->captions=$captions; |
|
| 381 | 381 | return $this; |
| 382 | 382 | } |
| 383 | 383 | |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | * @return InstanceViewer |
| 393 | 393 | */ |
| 394 | 394 | public function afterCompile($index, $callback) { |
| 395 | - $this->afterCompile[$index] = $callback; |
|
| 395 | + $this->afterCompile[$index]=$callback; |
|
| 396 | 396 | return $this; |
| 397 | 397 | } |
| 398 | 398 | |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | * @return \Ajax\semantic\widgets\base\InstanceViewer |
| 405 | 405 | */ |
| 406 | 406 | public function setCaptionCallback($captionCallback) { |
| 407 | - $this->captionCallback = $captionCallback; |
|
| 407 | + $this->captionCallback=$captionCallback; |
|
| 408 | 408 | return $this; |
| 409 | 409 | } |
| 410 | 410 | |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | * @return \Ajax\semantic\widgets\base\InstanceViewer |
| 417 | 417 | */ |
| 418 | 418 | public function setDefaultValueFunction($defaultValueFunction) { |
| 419 | - $this->defaultValueFunction = $defaultValueFunction; |
|
| 419 | + $this->defaultValueFunction=$defaultValueFunction; |
|
| 420 | 420 | return $this; |
| 421 | 421 | } |
| 422 | 422 | |
@@ -425,8 +425,8 @@ discard block |
||
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | public function getSimpleProperties() { |
| 428 | - return array_filter($this->visibleProperties, function ($item) { |
|
| 429 | - return ! (is_array($item) || is_object($item)); |
|
| 428 | + return array_filter($this->visibleProperties, function($item) { |
|
| 429 | + return !(is_array($item) || is_object($item)); |
|
| 430 | 430 | }); |
| 431 | 431 | } |
| 432 | 432 | |
@@ -451,10 +451,10 @@ discard block |
||
| 451 | 451 | * @param mixed $groupByFields |
| 452 | 452 | */ |
| 453 | 453 | public function setGroupByFields($groupByFields) { |
| 454 | - $this->groupByFields = $groupByFields; |
|
| 454 | + $this->groupByFields=$groupByFields; |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - public function addGroupBy($groupByField){ |
|
| 457 | + public function addGroupBy($groupByField) { |
|
| 458 | 458 | $this->groupByFields[]=$groupByField; |
| 459 | 459 | } |
| 460 | 460 | |
@@ -35,8 +35,9 @@ discard block |
||
| 35 | 35 | $this->widgetIdentifier = $identifier; |
| 36 | 36 | $this->values = []; |
| 37 | 37 | $this->afterCompile = []; |
| 38 | - if (isset($instance)) |
|
| 39 | - $this->setInstance($instance); |
|
| 38 | + if (isset($instance)) { |
|
| 39 | + $this->setInstance($instance); |
|
| 40 | + } |
|
| 40 | 41 | $this->setCaptions($captions); |
| 41 | 42 | $this->captionCallback = NULL; |
| 42 | 43 | $this->defaultValueFunction = function ($name, $value) { |
@@ -86,14 +87,16 @@ discard block |
||
| 86 | 87 | } |
| 87 | 88 | |
| 88 | 89 | public function getIdentifier($index = NULL) { |
| 89 | - if (! isset($index)) |
|
| 90 | - $index = self::$index; |
|
| 90 | + if (! isset($index)) { |
|
| 91 | + $index = self::$index; |
|
| 92 | + } |
|
| 91 | 93 | $value = $index; |
| 92 | 94 | if (isset($this->values["identifier"])) { |
| 93 | - if (\is_string($this->values["identifier"])) |
|
| 94 | - $value = JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
| 95 | - else |
|
| 96 | - $value = $this->values["identifier"]($index, $this->instance); |
|
| 95 | + if (\is_string($this->values["identifier"])) { |
|
| 96 | + $value = JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
| 97 | + } else { |
|
| 98 | + $value = $this->values["identifier"]($index, $this->instance); |
|
| 99 | + } |
|
| 97 | 100 | } |
| 98 | 101 | return $value; |
| 99 | 102 | } |
@@ -124,9 +127,8 @@ discard block |
||
| 124 | 127 | } elseif (\is_callable($property) && \array_search($property, ['system','date']) === false){ |
| 125 | 128 | try{ |
| 126 | 129 | $value = $property($this->instance); |
| 127 | - }catch(\Error $e){} |
|
| 128 | - } |
|
| 129 | - elseif (\is_array($property)) { |
|
| 130 | + } catch(\Error $e){} |
|
| 131 | + } elseif (\is_array($property)) { |
|
| 130 | 132 | $values = \array_map(function ($v) use ($index) { |
| 131 | 133 | return $this->_getValue($v, $index); |
| 132 | 134 | }, $property); |
@@ -264,7 +266,7 @@ discard block |
||
| 264 | 266 | $this->setInstanceProperty($property); |
| 265 | 267 | } |
| 266 | 268 | } |
| 267 | - }catch (\Throwable $th){ |
|
| 269 | + } catch (\Throwable $th){ |
|
| 268 | 270 | |
| 269 | 271 | } |
| 270 | 272 | return $this; |
@@ -284,10 +286,11 @@ discard block |
||
| 284 | 286 | } |
| 285 | 287 | } elseif (\is_int($property)) { |
| 286 | 288 | $props = $this->getDefaultProperties(); |
| 287 | - if (isset($props[$property])) |
|
| 288 | - $this->properties[] = $props[$property]; |
|
| 289 | - else |
|
| 290 | - $this->properties[] = $property; |
|
| 289 | + if (isset($props[$property])) { |
|
| 290 | + $this->properties[] = $props[$property]; |
|
| 291 | + } else { |
|
| 292 | + $this->properties[] = $property; |
|
| 293 | + } |
|
| 291 | 294 | } else { |
| 292 | 295 | $this->properties[] = $property; |
| 293 | 296 | } |
@@ -332,12 +335,13 @@ discard block |
||
| 332 | 335 | if (isset($this->captions[$index])) { |
| 333 | 336 | return $this->captions[$index]; |
| 334 | 337 | } |
| 335 | - if ($this->properties[$index] instanceof \ReflectionProperty) |
|
| 336 | - return $this->properties[$index]->getName(); |
|
| 337 | - elseif (\is_callable($this->properties[$index])) |
|
| 338 | - return ""; |
|
| 339 | - else |
|
| 340 | - return $this->properties[$index]; |
|
| 338 | + if ($this->properties[$index] instanceof \ReflectionProperty) { |
|
| 339 | + return $this->properties[$index]->getName(); |
|
| 340 | + } elseif (\is_callable($this->properties[$index])) { |
|
| 341 | + return ""; |
|
| 342 | + } else { |
|
| 343 | + return $this->properties[$index]; |
|
| 344 | + } |
|
| 341 | 345 | } |
| 342 | 346 | |
| 343 | 347 | public function getCaptions() { |
@@ -370,8 +374,9 @@ discard block |
||
| 370 | 374 | } |
| 371 | 375 | |
| 372 | 376 | public function setCaption($index, $caption) { |
| 373 | - if (isset($this->captions) === false) |
|
| 374 | - $this->captions = []; |
|
| 377 | + if (isset($this->captions) === false) { |
|
| 378 | + $this->captions = []; |
|
| 379 | + } |
|
| 375 | 380 | $this->captions[$index] = $caption; |
| 376 | 381 | return $this; |
| 377 | 382 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | trait FieldAsTrait { |
| 39 | 39 | |
| 40 | - abstract protected function _getFieldIdentifier($prefix, $name = ""); |
|
| 40 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
| 41 | 41 | |
| 42 | 42 | abstract public function setValueFunction($index, $callback); |
| 43 | 43 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | abstract protected function _getFieldCaption($index); |
| 47 | 47 | |
| 48 | - abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement = NULL, $parameters = NULL); |
|
| 48 | + abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
| 49 | 49 | |
| 50 | 50 | private $_speProperties; |
| 51 | 51 | |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | * @param HtmlFormField $element |
| 55 | 55 | * @param array $attributes |
| 56 | 56 | */ |
| 57 | - protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance = null) { |
|
| 57 | + protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance=null) { |
|
| 58 | 58 | if (isset($attributes["jsCallback"])) { |
| 59 | - $callback = $attributes["jsCallback"]; |
|
| 59 | + $callback=$attributes["jsCallback"]; |
|
| 60 | 60 | if (\is_callable($callback)) { |
| 61 | 61 | $callback($element, $instance, $index, InstanceViewer::$index); |
| 62 | 62 | } |
@@ -67,15 +67,15 @@ discard block |
||
| 67 | 67 | $element->fromArray($attributes); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - private function _getLabelField($caption, $icon = NULL) { |
|
| 71 | - $label = new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
| 70 | + private function _getLabelField($caption, $icon=NULL) { |
|
| 71 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
| 72 | 72 | return $label; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | protected function _addRules(HtmlFormField $element, &$attributes) { |
| 76 | 76 | if (isset($attributes["rules"])) { |
| 77 | - $this->_hasRules = true; |
|
| 78 | - $rules = $attributes["rules"]; |
|
| 77 | + $this->_hasRules=true; |
|
| 78 | + $rules=$attributes["rules"]; |
|
| 79 | 79 | if (\is_array($rules)) { |
| 80 | 80 | $element->addRules($rules); |
| 81 | 81 | } else { |
@@ -91,24 +91,24 @@ discard block |
||
| 91 | 91 | return $field; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - protected function _fieldAs($elementCallback, &$index, $attributes = NULL, $prefix = null) { |
|
| 95 | - $this->setValueFunction($index, function ($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) { |
|
| 96 | - $caption = $this->_getFieldCaption($index); |
|
| 97 | - $name = $this->_getFieldName($index); |
|
| 98 | - $id = $this->_getFieldIdentifier($prefix, $name); |
|
| 94 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
| 95 | + $this->setValueFunction($index, function($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) { |
|
| 96 | + $caption=$this->_getFieldCaption($index); |
|
| 97 | + $name=$this->_getFieldName($index); |
|
| 98 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
| 99 | 99 | if (isset($attributes["name"])) { |
| 100 | - $name = $attributes["name"]; |
|
| 100 | + $name=$attributes["name"]; |
|
| 101 | 101 | unset($attributes["name"]); |
| 102 | 102 | } |
| 103 | - $element = $elementCallback($id, $name, $value, $caption); |
|
| 103 | + $element=$elementCallback($id, $name, $value, $caption); |
|
| 104 | 104 | if (isset($this->_speProperties[$index])) { |
| 105 | 105 | $attributes ??= []; |
| 106 | - $attributes += $this->_speProperties[$index]; |
|
| 106 | + $attributes+=$this->_speProperties[$index]; |
|
| 107 | 107 | } |
| 108 | 108 | if (\is_array($attributes)) { |
| 109 | 109 | $this->_applyAttributes($element, $attributes, $index, $instance); |
| 110 | 110 | } |
| 111 | - $element->setDisabled(! $this->_edition); |
|
| 111 | + $element->setDisabled(!$this->_edition); |
|
| 112 | 112 | return $element; |
| 113 | 113 | }); |
| 114 | 114 | return $this; |
@@ -124,48 +124,48 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function setPropertyValues($property, $indexValues) { |
| 126 | 126 | foreach ($indexValues as $index => $value) { |
| 127 | - $ind = $this->_getIndex($index); |
|
| 128 | - $this->_speProperties[$ind][$property] = $value; |
|
| 127 | + $ind=$this->_getIndex($index); |
|
| 128 | + $this->_speProperties[$ind][$property]=$value; |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - public function fieldAsProgress($index, $label = NULL, $attributes = array()) { |
|
| 133 | - $this->setValueFunction($index, function ($value) use ($label, $attributes) { |
|
| 134 | - $pb = new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
| 132 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
| 133 | + $this->setValueFunction($index, function($value) use ($label, $attributes) { |
|
| 134 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
| 135 | 135 | return $pb; |
| 136 | 136 | }); |
| 137 | 137 | return $this; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - public function fieldAsRating($index, $max = 5, $icon = "") { |
|
| 141 | - $this->setValueFunction($index, function ($value) use ($max, $icon) { |
|
| 142 | - $rating = new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
| 140 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
| 141 | + $this->setValueFunction($index, function($value) use ($max, $icon) { |
|
| 142 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
| 143 | 143 | return $rating; |
| 144 | 144 | }); |
| 145 | 145 | return $this; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - public function fieldAsLabel($index, $icon = NULL, $attributes = NULL) { |
|
| 149 | - return $this->_fieldAs(function ($id, $name, $value) use ($icon) { |
|
| 150 | - $lbl = new HtmlLabel($id, $value); |
|
| 148 | + public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) { |
|
| 149 | + return $this->_fieldAs(function($id, $name, $value) use ($icon) { |
|
| 150 | + $lbl=new HtmlLabel($id, $value); |
|
| 151 | 151 | if (isset($icon)) |
| 152 | 152 | $lbl->addIcon($icon); |
| 153 | 153 | return $lbl; |
| 154 | 154 | }, $index, $attributes, "label"); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - public function fieldAsHeader($index, $niveau = 1, $icon = NULL, $attributes = NULL) { |
|
| 158 | - return $this->_fieldAs(function ($id, $name, $value) use ($niveau, $icon) { |
|
| 159 | - $header = new HtmlHeader($id, $niveau, $value); |
|
| 157 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
| 158 | + return $this->_fieldAs(function($id, $name, $value) use ($niveau, $icon) { |
|
| 159 | + $header=new HtmlHeader($id, $niveau, $value); |
|
| 160 | 160 | if (isset($icon)) |
| 161 | 161 | $header->asIcon($icon, $value); |
| 162 | 162 | return $header; |
| 163 | 163 | }, $index, $attributes, "header"); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - public function fieldAsImage($index, $size = Size::MINI, $circular = false) { |
|
| 167 | - $this->setValueFunction($index, function ($img) use ($size, $circular) { |
|
| 168 | - $image = new HtmlImage($this->_getFieldIdentifier("image"), $img); |
|
| 166 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
| 167 | + $this->setValueFunction($index, function($img) use ($size, $circular) { |
|
| 168 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); |
|
| 169 | 169 | $image->setSize($size); |
| 170 | 170 | if ($circular) |
| 171 | 171 | $image->setCircular(); |
@@ -175,65 +175,65 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | public function fieldAsFlag($index) { |
| 178 | - $this->setValueFunction($index, function ($flag) { |
|
| 179 | - $flag = new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
| 178 | + $this->setValueFunction($index, function($flag) { |
|
| 179 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
| 180 | 180 | return $flag; |
| 181 | 181 | }); |
| 182 | 182 | return $this; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | public function fieldAsIcon($index) { |
| 186 | - $this->setValueFunction($index, function ($icon) { |
|
| 187 | - $icon = new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
| 186 | + $this->setValueFunction($index, function($icon) { |
|
| 187 | + $icon=new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
| 188 | 188 | return $icon; |
| 189 | 189 | }); |
| 190 | 190 | return $this; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - public function fieldAsAvatar($index, $attributes = NULL) { |
|
| 194 | - return $this->_fieldAs(function ($id, $name, $value) { |
|
| 195 | - $img = new HtmlImage($id, $value); |
|
| 193 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
| 194 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 195 | + $img=new HtmlImage($id, $value); |
|
| 196 | 196 | $img->asAvatar(); |
| 197 | 197 | return $img; |
| 198 | 198 | }, $index, $attributes, "avatar"); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - public function fieldAsRadio($index, $attributes = NULL) { |
|
| 202 | - return $this->_fieldAs(function ($id, $name, $value) use ($attributes) { |
|
| 203 | - $input = new HtmlFormRadio($id, $name, $value, $value); |
|
| 201 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
| 202 | + return $this->_fieldAs(function($id, $name, $value) use ($attributes) { |
|
| 203 | + $input=new HtmlFormRadio($id, $name, $value, $value); |
|
| 204 | 204 | return $this->_prepareFormFields($input, $name, $attributes); |
| 205 | 205 | }, $index, $attributes, "radio"); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - public function fieldAsRadios($index, $elements = [], $attributes = NULL) { |
|
| 209 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements) { |
|
| 208 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
| 209 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements) { |
|
| 210 | 210 | return HtmlFormFields::radios($name, $elements, $caption, $value); |
| 211 | 211 | }, $index, $attributes, "radios"); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - public function fieldAsList($index, $classNames = "", $attributes = NULL) { |
|
| 215 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($classNames) { |
|
| 216 | - $result = new HtmlList($name, $value); |
|
| 214 | + public function fieldAsList($index, $classNames="", $attributes=NULL) { |
|
| 215 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($classNames) { |
|
| 216 | + $result=new HtmlList($name, $value); |
|
| 217 | 217 | $result->addClass($classNames); |
| 218 | 218 | return $result; |
| 219 | 219 | }, $index, $attributes, "list"); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - public function fieldAsInput($index, $attributes = NULL) { |
|
| 223 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
| 224 | - $input = new HtmlFormInput($id, $caption, "text", $value); |
|
| 222 | + public function fieldAsInput($index, $attributes=NULL) { |
|
| 223 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
| 224 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
| 225 | 225 | return $this->_prepareFormFields($input, $name, $attributes); |
| 226 | 226 | }, $index, $attributes, "input"); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - public function fieldAsLabeledInput($index, $attributes = NULL) { |
|
| 230 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
| 231 | - $input = new HtmlFormInput($id, '', 'text', $value, $caption); |
|
| 232 | - $required = ''; |
|
| 229 | + public function fieldAsLabeledInput($index, $attributes=NULL) { |
|
| 230 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
| 231 | + $input=new HtmlFormInput($id, '', 'text', $value, $caption); |
|
| 232 | + $required=''; |
|
| 233 | 233 | if (isset($attributes['rules'])) { |
| 234 | - $rules = json_encode($attributes['rules']); |
|
| 235 | - if (strpos($rules, 'empty') !== false) { |
|
| 236 | - $required = 'required'; |
|
| 234 | + $rules=json_encode($attributes['rules']); |
|
| 235 | + if (strpos($rules, 'empty')!==false) { |
|
| 236 | + $required='required'; |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | $input->getField() |
@@ -244,80 +244,80 @@ discard block |
||
| 244 | 244 | }, $index, $attributes, 'input'); |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - public function fieldAsDataList($index, ?array $items = [], $attributes = NULL) { |
|
| 248 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $items) { |
|
| 249 | - $input = new HtmlFormInput($id, $caption, "text", $value); |
|
| 247 | + public function fieldAsDataList($index, ?array $items=[], $attributes=NULL) { |
|
| 248 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $items) { |
|
| 249 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
| 250 | 250 | $input->getField() |
| 251 | 251 | ->addDataList($items); |
| 252 | 252 | return $this->_prepareFormFields($input, $name, $attributes); |
| 253 | 253 | }, $index, $attributes, "input"); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - public function fieldAsFile($index, $attributes = NULL) { |
|
| 256 | + public function fieldAsFile($index, $attributes=NULL) { |
|
| 257 | 257 | if (isset($this->_form)) { |
| 258 | 258 | $this->_form->setProperty('enctype', 'multipart/form-data'); |
| 259 | 259 | } |
| 260 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
| 261 | - $input = new HtmlFormInput($id, $caption); |
|
| 260 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
| 261 | + $input=new HtmlFormInput($id, $caption); |
|
| 262 | 262 | $input->asFile(); |
| 263 | 263 | return $this->_prepareFormFields($input, $name, $attributes); |
| 264 | 264 | }, $index, $attributes, "input"); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - public function fieldAsTextarea($index, $attributes = NULL) { |
|
| 268 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
| 269 | - $textarea = new HtmlFormTextarea($id, $caption, $value); |
|
| 267 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
| 268 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
| 269 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
| 270 | 270 | return $this->_prepareFormFields($textarea, $name, $attributes); |
| 271 | 271 | }, $index, $attributes, "textarea"); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - public function fieldAsElement($index, $tagName = "div", $baseClass = "", $attributes = NULL) { |
|
| 275 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) { |
|
| 276 | - $div = new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
| 274 | + public function fieldAsElement($index, $tagName="div", $baseClass="", $attributes=NULL) { |
|
| 275 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) { |
|
| 276 | + $div=new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
| 277 | 277 | $div->setContent(\htmlentities($value)); |
| 278 | - $textarea = new HtmlFormField("field-" . $id, $div, $caption); |
|
| 278 | + $textarea=new HtmlFormField("field-".$id, $div, $caption); |
|
| 279 | 279 | return $this->_prepareFormFields($textarea, $name, $attributes); |
| 280 | 280 | }, $index, $attributes, "element"); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - public function fieldAsHidden($index, $attributes = NULL) { |
|
| 284 | - if (! \is_array($attributes)) { |
|
| 285 | - $attributes = []; |
|
| 283 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
| 284 | + if (!\is_array($attributes)) { |
|
| 285 | + $attributes=[]; |
|
| 286 | 286 | } |
| 287 | - $attributes["inputType"] = "hidden"; |
|
| 288 | - $attributes["style"] = "display:none;"; |
|
| 287 | + $attributes["inputType"]="hidden"; |
|
| 288 | + $attributes["style"]="display:none;"; |
|
| 289 | 289 | return $this->fieldAsInput($index, $attributes); |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - public function fieldAsCheckbox($index, $attributes = NULL) { |
|
| 293 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
| 294 | - if ($caption === null || $caption === "") |
|
| 295 | - $caption = ""; |
|
| 296 | - $input = new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
| 292 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
| 293 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
| 294 | + if ($caption===null || $caption==="") |
|
| 295 | + $caption=""; |
|
| 296 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
| 297 | 297 | $input->setChecked(JString::isBooleanTrue($value)); |
| 298 | 298 | return $this->_prepareFormFields($input, $name, $attributes); |
| 299 | 299 | }, $index, $attributes, "ck"); |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - public function fieldAsDropDown($index, $elements = [], $multiple = false, $attributes = NULL) { |
|
| 303 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements, $multiple, $attributes) { |
|
| 304 | - $dd = new HtmlFormDropdown($id, $elements, $caption, $value ?? ''); |
|
| 302 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
| 303 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple, $attributes) { |
|
| 304 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value ?? ''); |
|
| 305 | 305 | $dd->asSelect($name, $multiple); |
| 306 | 306 | return $this->_prepareFormFields($dd, $name, $attributes); |
| 307 | 307 | }, $index, $attributes, "dd"); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - public function fieldAsMessage($index, $attributes = NULL) { |
|
| 311 | - return $this->_fieldAs(function ($id, $name, $value, $caption) { |
|
| 312 | - $mess = new HtmlMessage("message-" . $id, $caption); |
|
| 310 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
| 311 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 312 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
| 313 | 313 | $mess->addHeader($value); |
| 314 | 314 | return $mess; |
| 315 | 315 | }, $index, $attributes, "message"); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - public function fieldAsLink($index, $attributes = NULL) { |
|
| 319 | - return $this->_fieldAs(function ($id, $name, $value, $caption) { |
|
| 320 | - $lnk = new HtmlLink("message-" . $id, "#", $caption); |
|
| 318 | + public function fieldAsLink($index, $attributes=NULL) { |
|
| 319 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 320 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
| 321 | 321 | return $lnk; |
| 322 | 322 | }, $index, $attributes, "link"); |
| 323 | 323 | } |
@@ -329,28 +329,28 @@ discard block |
||
| 329 | 329 | * an array or associative array $type=>$attributes |
| 330 | 330 | */ |
| 331 | 331 | public function fieldsAs(array $types) { |
| 332 | - $i = 0; |
|
| 332 | + $i=0; |
|
| 333 | 333 | if (JArray::isAssociative($types)) { |
| 334 | 334 | foreach ($types as $type => $attributes) { |
| 335 | 335 | if (\is_int($type)) |
| 336 | - $this->fieldAs($i ++, $attributes, []); |
|
| 336 | + $this->fieldAs($i++, $attributes, []); |
|
| 337 | 337 | else { |
| 338 | - $type = preg_replace('/\d/', '', $type); |
|
| 339 | - $this->fieldAs($i ++, $type, $attributes); |
|
| 338 | + $type=preg_replace('/\d/', '', $type); |
|
| 339 | + $this->fieldAs($i++, $type, $attributes); |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | } else { |
| 343 | 343 | foreach ($types as $type) { |
| 344 | - $this->fieldAs($i ++, $type); |
|
| 344 | + $this->fieldAs($i++, $type); |
|
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - public function fieldAs($index, $type, $attributes = NULL) { |
|
| 350 | - $method = "fieldAs" . \ucfirst($type); |
|
| 349 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
| 350 | + $method="fieldAs".\ucfirst($type); |
|
| 351 | 351 | if (\method_exists($this, $method)) { |
| 352 | - if (! \is_array($attributes)) { |
|
| 353 | - $attributes = [ |
|
| 352 | + if (!\is_array($attributes)) { |
|
| 353 | + $attributes=[ |
|
| 354 | 354 | $index |
| 355 | 355 | ]; |
| 356 | 356 | } else { |
@@ -363,39 +363,39 @@ discard block |
||
| 363 | 363 | } |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - public function fieldAsSubmit($index, $cssStyle = NULL, $url = NULL, $responseElement = NULL, $attributes = NULL) { |
|
| 367 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) { |
|
| 368 | - $button = new HtmlButton($id, $caption, $cssStyle); |
|
| 366 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
| 367 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) { |
|
| 368 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
| 369 | 369 | $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
| 370 | 370 | return $button; |
| 371 | 371 | }, $index, $attributes, "submit"); |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - public function fieldAsButton($index, $cssStyle = NULL, $attributes = NULL) { |
|
| 375 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($cssStyle) { |
|
| 376 | - $button = new HtmlButton($id, $value, $cssStyle); |
|
| 374 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 375 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle) { |
|
| 376 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 377 | 377 | return $button; |
| 378 | 378 | }, $index, $attributes, "button"); |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - public function fieldAsDataTable($index, $model, $instances = null, $fields = [], $attributes = NULL) { |
|
| 382 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($model, $instances, $fields, $index) { |
|
| 383 | - $dt = new DataTable($id, $model, $instances); |
|
| 381 | + public function fieldAsDataTable($index, $model, $instances=null, $fields=[], $attributes=NULL) { |
|
| 382 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($model, $instances, $fields, $index) { |
|
| 383 | + $dt=new DataTable($id, $model, $instances); |
|
| 384 | 384 | $dt->setNamePrefix($index); |
| 385 | 385 | $dt->setFields($fields); |
| 386 | 386 | $dt->setEdition(true); |
| 387 | - $dt->addDeleteButton(false, [], function ($bt) use ($index) { |
|
| 387 | + $dt->addDeleteButton(false, [], function($bt) use ($index) { |
|
| 388 | 388 | $bt->addClass('mini circular') |
| 389 | - ->wrap('<input value="" class="_status" type="hidden" name="' . $index . '._status[]">'); |
|
| 389 | + ->wrap('<input value="" class="_status" type="hidden" name="'.$index.'._status[]">'); |
|
| 390 | 390 | }); |
| 391 | - if ($caption != null) { |
|
| 391 | + if ($caption!=null) { |
|
| 392 | 392 | $dt->setFormCaption($caption); |
| 393 | 393 | } |
| 394 | - $dt->onPreCompile(function () use (&$dt) { |
|
| 394 | + $dt->onPreCompile(function() use (&$dt) { |
|
| 395 | 395 | $dt->getHtmlComponent() |
| 396 | 396 | ->colRightFromRight(0); |
| 397 | 397 | }); |
| 398 | - $dt->wrap('<input type="hidden" name="' . $index . '">'); |
|
| 398 | + $dt->wrap('<input type="hidden" name="'.$index.'">'); |
|
| 399 | 399 | return $dt; |
| 400 | 400 | }, $index, $attributes, "dataTable"); |
| 401 | 401 | } |