@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | */ |
| 26 | 26 | class DataTable extends Widget { |
| 27 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait; |
|
| 27 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait; |
|
| 28 | 28 | protected $_searchField; |
| 29 | 29 | protected $_urls; |
| 30 | 30 | protected $_pagination; |
@@ -42,35 +42,35 @@ discard block |
||
| 42 | 42 | protected $_colWidths; |
| 43 | 43 | |
| 44 | 44 | |
| 45 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 46 | - parent::__construct($identifier, $model,$modelInstance); |
|
| 47 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
| 45 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 46 | + parent::__construct($identifier, $model, $modelInstance); |
|
| 47 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
| 48 | 48 | $this->_urls=[]; |
| 49 | - $this->_emptyMessage=new HtmlMessage("","nothing to display"); |
|
| 49 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
| 50 | 50 | $this->_emptyMessage->setIcon("info circle"); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function run(JsUtils $js){ |
|
| 54 | - if($this->_hasCheckboxes && isset($js)){ |
|
| 53 | + public function run(JsUtils $js) { |
|
| 54 | + if ($this->_hasCheckboxes && isset($js)) { |
|
| 55 | 55 | $this->_runCheckboxes($js); |
| 56 | 56 | } |
| 57 | - if($this->_visibleHover){ |
|
| 58 | - $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
| 59 | - $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
| 57 | + if ($this->_visibleHover) { |
|
| 58 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
| 59 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
| 60 | 60 | } |
| 61 | - if(\is_array($this->_deleteBehavior)) |
|
| 62 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
| 63 | - if(\is_array($this->_editBehavior)) |
|
| 64 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
| 61 | + if (\is_array($this->_deleteBehavior)) |
|
| 62 | + $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
| 63 | + if (\is_array($this->_editBehavior)) |
|
| 64 | + $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
| 65 | 65 | return parent::run($js); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | |
| 70 | - protected function _generateBehavior($op,$params,JsUtils $js){ |
|
| 71 | - if(isset($this->_urls[$op])){ |
|
| 72 | - $params=\array_merge($params,["attr"=>"data-ajax"]); |
|
| 73 | - $js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector($op),$params); |
|
| 70 | + protected function _generateBehavior($op, $params, JsUtils $js) { |
|
| 71 | + if (isset($this->_urls[$op])) { |
|
| 72 | + $params=\array_merge($params, ["attr"=>"data-ajax"]); |
|
| 73 | + $js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
@@ -83,156 +83,156 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | |
| 86 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 87 | - if(!$this->_generated){ |
|
| 86 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 87 | + if (!$this->_generated) { |
|
| 88 | 88 | $this->_instanceViewer->setInstance($this->_model); |
| 89 | 89 | $captions=$this->_instanceViewer->getCaptions(); |
| 90 | 90 | $table=$this->content["table"]; |
| 91 | - if($this->_hasCheckboxes){ |
|
| 91 | + if ($this->_hasCheckboxes) { |
|
| 92 | 92 | $this->_generateMainCheckbox($captions); |
| 93 | 93 | } |
| 94 | 94 | $table->setRowCount(0, \sizeof($captions)); |
| 95 | - $this->_generateHeader($table,$captions); |
|
| 95 | + $this->_generateHeader($table, $captions); |
|
| 96 | 96 | |
| 97 | - if(isset($this->_compileParts)) |
|
| 97 | + if (isset($this->_compileParts)) |
|
| 98 | 98 | $table->setCompileParts($this->_compileParts); |
| 99 | 99 | |
| 100 | 100 | $this->_generateContent($table); |
| 101 | 101 | |
| 102 | - $this->compileExtraElements($table, $captions,$js); |
|
| 102 | + $this->compileExtraElements($table, $captions, $js); |
|
| 103 | 103 | |
| 104 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
| 104 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
| 105 | 105 | $this->_compileForm(); |
| 106 | 106 | $this->_applyStyleAttributes($table); |
| 107 | 107 | $this->_generated=true; |
| 108 | 108 | } |
| 109 | - return parent::compile($js,$view); |
|
| 109 | + return parent::compile($js, $view); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - protected function compileExtraElements($table,$captions,JsUtils $js=NULL){ |
|
| 113 | - if(isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])){ |
|
| 114 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 112 | + protected function compileExtraElements($table, $captions, JsUtils $js=NULL) { |
|
| 113 | + if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) { |
|
| 114 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
| 115 | 115 | } |
| 116 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
| 116 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
| 117 | 117 | $table->getHeader()->getCell(0, 0)->addClass("no-sort"); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if(isset($this->_toolbar)){ |
|
| 120 | + if (isset($this->_toolbar)) { |
|
| 121 | 121 | $this->_setToolbarPosition($table, $captions); |
| 122 | 122 | } |
| 123 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
| 124 | - $this->_generatePagination($table,$js); |
|
| 123 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
| 124 | + $this->_generatePagination($table, $js); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - protected function _applyStyleAttributes($table){ |
|
| 129 | - if(isset($this->_hiddenColumns)) |
|
| 128 | + protected function _applyStyleAttributes($table) { |
|
| 129 | + if (isset($this->_hiddenColumns)) |
|
| 130 | 130 | $this->_hideColumns(); |
| 131 | - if(isset($this->_colWidths)){ |
|
| 132 | - foreach ($this->_colWidths as $colIndex=>$width){ |
|
| 133 | - $table->setColWidth($colIndex,$width); |
|
| 131 | + if (isset($this->_colWidths)) { |
|
| 132 | + foreach ($this->_colWidths as $colIndex=>$width) { |
|
| 133 | + $table->setColWidth($colIndex, $width); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - protected function _hideColumns(){ |
|
| 139 | - foreach ($this->_hiddenColumns as $colIndex){ |
|
| 138 | + protected function _hideColumns() { |
|
| 139 | + foreach ($this->_hiddenColumns as $colIndex) { |
|
| 140 | 140 | $this->_self->hideColumn($colIndex); |
| 141 | 141 | } |
| 142 | 142 | return $this; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - protected function _generateHeader(HtmlTable $table,$captions){ |
|
| 145 | + protected function _generateHeader(HtmlTable $table, $captions) { |
|
| 146 | 146 | $table->setHeaderValues($captions); |
| 147 | - if(isset($this->_sortable)){ |
|
| 147 | + if (isset($this->_sortable)) { |
|
| 148 | 148 | $table->setSortable($this->_sortable); |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | |
| 153 | 153 | |
| 154 | - protected function _generateContent($table){ |
|
| 154 | + protected function _generateContent($table) { |
|
| 155 | 155 | $objects=$this->_modelInstance; |
| 156 | - if(isset($this->_pagination)){ |
|
| 156 | + if (isset($this->_pagination)) { |
|
| 157 | 157 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
| 158 | 158 | } |
| 159 | 159 | InstanceViewer::setIndex(0); |
| 160 | 160 | $table->fromDatabaseObjects($objects, function($instance) use($table){ |
| 161 | 161 | return $this->_generateRow($instance, $table); |
| 162 | 162 | }); |
| 163 | - if($table->getRowCount()==0){ |
|
| 163 | + if ($table->getRowCount()==0) { |
|
| 164 | 164 | $result=$table->addRow(); |
| 165 | 165 | $result->mergeRow(); |
| 166 | 166 | $result->setValues([$this->_emptyMessage]); |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - protected function _generateRow($instance,&$table,$checkedClass=null){ |
|
| 170 | + protected function _generateRow($instance, &$table, $checkedClass=null) { |
|
| 171 | 171 | $this->_instanceViewer->setInstance($instance); |
| 172 | 172 | InstanceViewer::$index++; |
| 173 | - $values= $this->_instanceViewer->getValues(); |
|
| 173 | + $values=$this->_instanceViewer->getValues(); |
|
| 174 | 174 | $id=$this->_instanceViewer->getIdentifier(); |
| 175 | - if($this->_hasCheckboxes){ |
|
| 176 | - $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,""); |
|
| 175 | + if ($this->_hasCheckboxes) { |
|
| 176 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
| 177 | 177 | $ck->setOnChange("event.stopPropagation();"); |
| 178 | 178 | $field=$ck->getField(); |
| 179 | - $field->setProperty("value",$id); |
|
| 179 | + $field->setProperty("value", $id); |
|
| 180 | 180 | $field->setProperty("name", "selection[]"); |
| 181 | - if(isset($checkedClass)) |
|
| 181 | + if (isset($checkedClass)) |
|
| 182 | 182 | $field->setClass($checkedClass); |
| 183 | 183 | \array_unshift($values, $ck); |
| 184 | 184 | } |
| 185 | 185 | $result=$table->newRow(); |
| 186 | 186 | $result->setIdentifier($this->identifier."-tr-".$id); |
| 187 | - $result->setProperty("data-ajax",$id); |
|
| 187 | + $result->setProperty("data-ajax", $id); |
|
| 188 | 188 | $result->setValues($values); |
| 189 | - $result->addToProperty("class",$this->_rowClass); |
|
| 189 | + $result->addToProperty("class", $this->_rowClass); |
|
| 190 | 190 | return $result; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - protected function _generatePagination($table,$js=NULL){ |
|
| 194 | - if(isset($this->_toolbar)){ |
|
| 195 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
| 193 | + protected function _generatePagination($table, $js=NULL) { |
|
| 194 | + if (isset($this->_toolbar)) { |
|
| 195 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
| 196 | 196 | $this->_toolbar->setFloated("left"); |
| 197 | 197 | } |
| 198 | 198 | $footer=$table->getFooter(); |
| 199 | 199 | $footer->mergeCol(); |
| 200 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
| 200 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
| 201 | 201 | $menu->floatRight(); |
| 202 | 202 | $menu->setActiveItem($this->_pagination->getPage()-1); |
| 203 | 203 | $footer->addValues($menu); |
| 204 | - $this->_associatePaginationBehavior($menu,$js); |
|
| 204 | + $this->_associatePaginationBehavior($menu, $js); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){ |
|
| 208 | - if(isset($this->_urls["refresh"])){ |
|
| 209 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>false]); |
|
| 207 | + protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) { |
|
| 208 | + if (isset($this->_urls["refresh"])) { |
|
| 209 | + $menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith", "hasLoader"=>false]); |
|
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - protected function _getFieldName($index){ |
|
| 213 | + protected function _getFieldName($index) { |
|
| 214 | 214 | $fieldName=parent::_getFieldName($index); |
| 215 | - if(\is_object($fieldName)) |
|
| 215 | + if (\is_object($fieldName)) |
|
| 216 | 216 | $fieldName="field-".$index; |
| 217 | 217 | return $fieldName."[]"; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - protected function _getFieldCaption($index){ |
|
| 220 | + protected function _getFieldCaption($index) { |
|
| 221 | 221 | return null; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
| 225 | - switch ($this->_toolbarPosition){ |
|
| 224 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
| 225 | + switch ($this->_toolbarPosition) { |
|
| 226 | 226 | case PositionInTable::BEFORETABLE: |
| 227 | 227 | case PositionInTable::AFTERTABLE: |
| 228 | - if(isset($this->_compileParts)===false){ |
|
| 228 | + if (isset($this->_compileParts)===false) { |
|
| 229 | 229 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 230 | 230 | } |
| 231 | 231 | break; |
| 232 | 232 | case PositionInTable::HEADER: |
| 233 | 233 | case PositionInTable::FOOTER: |
| 234 | 234 | case PositionInTable::BODY: |
| 235 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
| 235 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
| 236 | 236 | break; |
| 237 | 237 | } |
| 238 | 238 | } |
@@ -244,16 +244,16 @@ discard block |
||
| 244 | 244 | * @param callable $callback function called after the field compilation |
| 245 | 245 | * @return DataTable |
| 246 | 246 | */ |
| 247 | - public function afterCompile($index,$callback){ |
|
| 248 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
| 247 | + public function afterCompile($index, $callback) { |
|
| 248 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
| 249 | 249 | return $this; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - private function addToolbarRow($part,$table,$captions){ |
|
| 252 | + private function addToolbarRow($part, $table, $captions) { |
|
| 253 | 253 | $hasPart=$table->hasPart($part); |
| 254 | - if($hasPart){ |
|
| 254 | + if ($hasPart) { |
|
| 255 | 255 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 256 | - }else{ |
|
| 256 | + } else { |
|
| 257 | 257 | $row=$table->getPart($part)->getRow(0); |
| 258 | 258 | } |
| 259 | 259 | $row->mergeCol(); |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * @see Widget::getHtmlComponent() |
| 266 | 266 | * @return HtmlTable |
| 267 | 267 | */ |
| 268 | - public function getHtmlComponent(){ |
|
| 268 | + public function getHtmlComponent() { |
|
| 269 | 269 | return $this->content["table"]; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -279,12 +279,12 @@ discard block |
||
| 279 | 279 | * @return DataTable |
| 280 | 280 | */ |
| 281 | 281 | public function setUrls($urls) { |
| 282 | - if(\is_array($urls)){ |
|
| 283 | - $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
|
| 284 | - $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
|
| 285 | - $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
|
| 286 | - }else{ |
|
| 287 | - $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
|
| 282 | + if (\is_array($urls)) { |
|
| 283 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
| 284 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
| 285 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
| 286 | + } else { |
|
| 287 | + $this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls]; |
|
| 288 | 288 | } |
| 289 | 289 | return $this; |
| 290 | 290 | } |
@@ -297,8 +297,8 @@ discard block |
||
| 297 | 297 | * @param number $pages_visibles The number of visible pages in the Pagination component |
| 298 | 298 | * @return DataTable |
| 299 | 299 | */ |
| 300 | - public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){ |
|
| 301 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount); |
|
| 300 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
| 301 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
| 302 | 302 | return $this; |
| 303 | 303 | } |
| 304 | 304 | |
@@ -309,8 +309,8 @@ discard block |
||
| 309 | 309 | * @param number $pages_visibles The number of visible pages in the Pagination component |
| 310 | 310 | * @return DataTable |
| 311 | 311 | */ |
| 312 | - public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){ |
|
| 313 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page); |
|
| 312 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
| 313 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
| 314 | 314 | return $this; |
| 315 | 315 | } |
| 316 | 316 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | * @param array $compileParts |
| 321 | 321 | * @return DataTable |
| 322 | 322 | */ |
| 323 | - public function refresh($compileParts=["tbody"]){ |
|
| 323 | + public function refresh($compileParts=["tbody"]) { |
|
| 324 | 324 | $this->_compileParts=$compileParts; |
| 325 | 325 | return $this; |
| 326 | 326 | } |
@@ -331,14 +331,14 @@ discard block |
||
| 331 | 331 | * @param string $position |
| 332 | 332 | * @return \Ajax\common\html\HtmlDoubleElement |
| 333 | 333 | */ |
| 334 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
| 334 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
| 335 | 335 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - public function getSearchField(){ |
|
| 339 | - if(isset($this->_searchField)===false){ |
|
| 340 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
| 341 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
| 338 | + public function getSearchField() { |
|
| 339 | + if (isset($this->_searchField)===false) { |
|
| 340 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
| 341 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
| 342 | 342 | } |
| 343 | 343 | return $this->_searchField; |
| 344 | 344 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | return $this; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - public function asForm(){ |
|
| 357 | + public function asForm() { |
|
| 358 | 358 | return $this->getForm(); |
| 359 | 359 | } |
| 360 | 360 | |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | protected function getTargetSelector($op) { |
| 364 | 364 | $result=$this->_targetSelector; |
| 365 | - if(!isset($result[$op])) |
|
| 365 | + if (!isset($result[$op])) |
|
| 366 | 366 | $result="#".$this->identifier; |
| 367 | 367 | return $result[$op]; |
| 368 | 368 | } |
@@ -373,15 +373,15 @@ discard block |
||
| 373 | 373 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 374 | 374 | */ |
| 375 | 375 | public function setTargetSelector($_targetSelector) { |
| 376 | - if(!\is_array($_targetSelector)){ |
|
| 377 | - $_targetSelector=["edit"=>$_targetSelector,"delete"=>$_targetSelector]; |
|
| 376 | + if (!\is_array($_targetSelector)) { |
|
| 377 | + $_targetSelector=["edit"=>$_targetSelector, "delete"=>$_targetSelector]; |
|
| 378 | 378 | } |
| 379 | 379 | $this->_targetSelector=$_targetSelector; |
| 380 | 380 | return $this; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | public function getRefreshSelector() { |
| 384 | - if(isset($this->_refreshSelector)) |
|
| 384 | + if (isset($this->_refreshSelector)) |
|
| 385 | 385 | return $this->_refreshSelector; |
| 386 | 386 | return "#".$this->identifier." tbody"; |
| 387 | 387 | } |
@@ -399,9 +399,9 @@ discard block |
||
| 399 | 399 | * {@inheritDoc} |
| 400 | 400 | * @see \Ajax\common\Widget::show() |
| 401 | 401 | */ |
| 402 | - public function show($modelInstance){ |
|
| 403 | - if(\is_array($modelInstance)){ |
|
| 404 | - if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
|
| 402 | + public function show($modelInstance) { |
|
| 403 | + if (\is_array($modelInstance)) { |
|
| 404 | + if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
|
| 405 | 405 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
| 406 | 406 | } |
| 407 | 407 | $this->_modelInstance=$modelInstance; |
@@ -436,24 +436,24 @@ discard block |
||
| 436 | 436 | return $this; |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
| 440 | - $this->_self->setActiveRowSelector($class,$event,$multiple); |
|
| 439 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
| 440 | + $this->_self->setActiveRowSelector($class, $event, $multiple); |
|
| 441 | 441 | return $this; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - public function hideColumn($colIndex){ |
|
| 445 | - if(!\is_array($this->_hiddenColumns)) |
|
| 444 | + public function hideColumn($colIndex) { |
|
| 445 | + if (!\is_array($this->_hiddenColumns)) |
|
| 446 | 446 | $this->_hiddenColumns=[]; |
| 447 | 447 | $this->_hiddenColumns[]=$colIndex; |
| 448 | 448 | return $this; |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - public function setColWidth($colIndex,$width){ |
|
| 451 | + public function setColWidth($colIndex, $width) { |
|
| 452 | 452 | $this->_colWidths[$colIndex]=$width; |
| 453 | 453 | return $this; |
| 454 | 454 | } |
| 455 | 455 | public function setColWidths($_colWidths) { |
| 456 | - $this->_colWidths = $_colWidths; |
|
| 456 | + $this->_colWidths=$_colWidths; |
|
| 457 | 457 | return $this; |
| 458 | 458 | } |
| 459 | 459 | } |