@@ -41,6 +41,10 @@ discard block |
||
| 41 | 41 | parent::run($js); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | + /** |
|
| 45 | + * @param string $identifier |
|
| 46 | + * @param string $model |
|
| 47 | + */ |
|
| 44 | 48 | public function __construct($identifier,$model,$modelInstance=NULL) { |
| 45 | 49 | parent::__construct($identifier, $model,$modelInstance); |
| 46 | 50 | $this->_instanceViewer=new InstanceViewerCaption(); |
@@ -143,6 +147,9 @@ discard block |
||
| 143 | 147 | return $this; |
| 144 | 148 | } |
| 145 | 149 | |
| 150 | + /** |
|
| 151 | + * @param PositionInTable $part |
|
| 152 | + */ |
|
| 146 | 153 | private function addToolbarRow($part,$table,$captions){ |
| 147 | 154 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 148 | 155 | $row->mergeCol(); |
@@ -168,16 +175,26 @@ discard block |
||
| 168 | 175 | return $this; |
| 169 | 176 | } |
| 170 | 177 | |
| 178 | + /** |
|
| 179 | + * @param \Closure $field |
|
| 180 | + */ |
|
| 171 | 181 | public function addField($field){ |
| 172 | 182 | $this->_instanceViewer->addField($field); |
| 173 | 183 | return $this; |
| 174 | 184 | } |
| 175 | 185 | |
| 186 | + /** |
|
| 187 | + * @param integer $index |
|
| 188 | + * @param \Closure $field |
|
| 189 | + */ |
|
| 176 | 190 | public function insertField($index,$field){ |
| 177 | 191 | $this->_instanceViewer->insertField($index, $field); |
| 178 | 192 | return $this; |
| 179 | 193 | } |
| 180 | 194 | |
| 195 | + /** |
|
| 196 | + * @param \Closure $field |
|
| 197 | + */ |
|
| 181 | 198 | public function insertInField($index,$field){ |
| 182 | 199 | $this->_instanceViewer->insertInField($index, $field); |
| 183 | 200 | return $this; |
@@ -226,16 +243,17 @@ discard block |
||
| 226 | 243 | /** |
| 227 | 244 | * @param string $caption |
| 228 | 245 | * @param callable $callback |
| 229 | - * @return callable |
|
| 246 | + * @return \Closure |
|
| 230 | 247 | */ |
| 231 | 248 | private function getFieldButtonCallable($caption,$callback=null){ |
| 232 | 249 | return $this->getCallable("getFieldButton",[$caption],$callback); |
| 233 | 250 | } |
| 234 | 251 | |
| 235 | 252 | /** |
| 236 | - * @param mixed $object |
|
| 237 | 253 | * @param callable $callback |
| 238 | - * @return callable |
|
| 254 | + * @param string $thisCallback |
|
| 255 | + * @param string[] $parameters |
|
| 256 | + * @return \Closure |
|
| 239 | 257 | */ |
| 240 | 258 | private function getCallable($thisCallback,$parameters,$callback=null){ |
| 241 | 259 | $result=function($instance) use($thisCallback,$parameters,$callback){ |
@@ -296,11 +314,19 @@ discard block |
||
| 296 | 314 | return $this; |
| 297 | 315 | } |
| 298 | 316 | |
| 317 | + /** |
|
| 318 | + * @param string $icon |
|
| 319 | + * @param string $class |
|
| 320 | + */ |
|
| 299 | 321 | private function addDefaultButton($icon,$class=null,$callback=null){ |
| 300 | 322 | $this->addField($this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
| 301 | 323 | return $this; |
| 302 | 324 | } |
| 303 | 325 | |
| 326 | + /** |
|
| 327 | + * @param string $icon |
|
| 328 | + * @param string $class |
|
| 329 | + */ |
|
| 304 | 330 | private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){ |
| 305 | 331 | $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
| 306 | 332 | return $this; |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | protected $_hasCheckboxes; |
| 32 | 32 | protected $_compileParts; |
| 33 | 33 | |
| 34 | - public function run(JsUtils $js){ |
|
| 35 | - if($this->_hasCheckboxes && isset($js)){ |
|
| 34 | + public function run(JsUtils $js) { |
|
| 35 | + if ($this->_hasCheckboxes && isset($js)) { |
|
| 36 | 36 | $js->execOn("change", "#".$this->identifier." [name='selection[]']", " |
| 37 | 37 | var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true; |
| 38 | 38 | \$checkbox.each(function() {if($(this).prop('checked')){allUnchecked = false;}else{allChecked = false;}}); |
@@ -41,21 +41,21 @@ discard block |
||
| 41 | 41 | parent::run($js); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 45 | - parent::__construct($identifier, $model,$modelInstance); |
|
| 44 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 45 | + parent::__construct($identifier, $model, $modelInstance); |
|
| 46 | 46 | $this->_instanceViewer=new InstanceViewerCaption(); |
| 47 | - $this->content=["table"=>new HtmlTable($identifier, 0,0)]; |
|
| 47 | + $this->content=["table"=>new HtmlTable($identifier, 0, 0)]; |
|
| 48 | 48 | $this->_toolbarPosition=PositionInTable::BEFORETABLE; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 51 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 52 | 52 | $this->_instanceViewer->setInstance($this->_model); |
| 53 | 53 | $captions=$this->_instanceViewer->getCaptions(); |
| 54 | 54 | |
| 55 | 55 | $table=$this->content["table"]; |
| 56 | 56 | |
| 57 | - if($this->_hasCheckboxes){ |
|
| 58 | - $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
|
| 57 | + if ($this->_hasCheckboxes) { |
|
| 58 | + $ck=new HtmlCheckbox("main-ck-".$this->identifier, ""); |
|
| 59 | 59 | $ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);"); |
| 60 | 60 | $ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);"); |
| 61 | 61 | \array_unshift($captions, $ck); |
@@ -63,44 +63,44 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $table->setRowCount(0, \sizeof($captions)); |
| 65 | 65 | $table->setHeaderValues($captions); |
| 66 | - if(isset($this->_compileParts)) |
|
| 66 | + if (isset($this->_compileParts)) |
|
| 67 | 67 | $table->setCompileParts($this->_compileParts); |
| 68 | - if(isset($this->_searchField)){ |
|
| 69 | - if(isset($js)) |
|
| 70 | - $this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
| 68 | + if (isset($this->_searchField)) { |
|
| 69 | + if (isset($js)) |
|
| 70 | + $this->_searchField->postOn("change", $this->_urls, "{'s':$(this).val()}", "-#".$this->identifier." tbody", ["preventDefault"=>false]); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $this->_generateContent($table); |
| 74 | 74 | |
| 75 | - if($this->_hasCheckboxes){ |
|
| 76 | - if($table->hasPart("thead")) |
|
| 77 | - $table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort"); |
|
| 75 | + if ($this->_hasCheckboxes) { |
|
| 76 | + if ($table->hasPart("thead")) |
|
| 77 | + $table->getHeader()->getCell(0, 0)->addToProperty("class", "no-sort"); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
| 80 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
| 81 | 81 | $this->_generatePagination($table); |
| 82 | 82 | } |
| 83 | - if(isset($this->_toolbar)){ |
|
| 83 | + if (isset($this->_toolbar)) { |
|
| 84 | 84 | $this->_setToolbarPosition($table, $captions); |
| 85 | 85 | } |
| 86 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
| 87 | - return parent::compile($js,$view); |
|
| 86 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
| 87 | + return parent::compile($js, $view); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - private function _generateContent($table){ |
|
| 90 | + private function _generateContent($table) { |
|
| 91 | 91 | $objects=$this->_modelInstance; |
| 92 | - if(isset($this->_pagination)){ |
|
| 92 | + if (isset($this->_pagination)) { |
|
| 93 | 93 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
| 94 | 94 | } |
| 95 | 95 | InstanceViewerCaption::setIndex(0); |
| 96 | - $table->fromDatabaseObjects($objects, function($instance){ |
|
| 96 | + $table->fromDatabaseObjects($objects, function($instance) { |
|
| 97 | 97 | $this->_instanceViewer->setInstance($instance); |
| 98 | 98 | InstanceViewerCaption::$index++; |
| 99 | - $result= $this->_instanceViewer->getValues(); |
|
| 100 | - if($this->_hasCheckboxes){ |
|
| 101 | - $ck=new HtmlCheckbox("ck-".$this->identifier,""); |
|
| 99 | + $result=$this->_instanceViewer->getValues(); |
|
| 100 | + if ($this->_hasCheckboxes) { |
|
| 101 | + $ck=new HtmlCheckbox("ck-".$this->identifier, ""); |
|
| 102 | 102 | $field=$ck->getField(); |
| 103 | - $field->setProperty("value",$this->_instanceViewer->getIdentifier()); |
|
| 103 | + $field->setProperty("value", $this->_instanceViewer->getIdentifier()); |
|
| 104 | 104 | $field->setProperty("name", "selection[]"); |
| 105 | 105 | \array_unshift($result, $ck); |
| 106 | 106 | } |
@@ -108,25 +108,25 @@ discard block |
||
| 108 | 108 | }); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - private function _generatePagination($table){ |
|
| 111 | + private function _generatePagination($table) { |
|
| 112 | 112 | $footer=$table->getFooter(); |
| 113 | 113 | $footer->mergeCol(); |
| 114 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
| 114 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
| 115 | 115 | $menu->floatRight(); |
| 116 | 116 | $menu->setActiveItem($this->_pagination->getPage()-1); |
| 117 | 117 | $footer->setValues($menu); |
| 118 | - $menu->postOnClick($this->_urls,"{'p':$(this).attr('data-page')}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
| 118 | + $menu->postOnClick($this->_urls, "{'p':$(this).attr('data-page')}", "-#".$this->identifier." tbody", ["preventDefault"=>false]); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - private function _setToolbarPosition($table,$captions){ |
|
| 122 | - switch ($this->_toolbarPosition){ |
|
| 121 | + private function _setToolbarPosition($table, $captions) { |
|
| 122 | + switch ($this->_toolbarPosition) { |
|
| 123 | 123 | case PositionInTable::BEFORETABLE:case PositionInTable::AFTERTABLE: |
| 124 | - if(isset($this->_compileParts)===false){ |
|
| 124 | + if (isset($this->_compileParts)===false) { |
|
| 125 | 125 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 126 | 126 | } |
| 127 | 127 | break; |
| 128 | 128 | case PositionInTable::HEADER:case PositionInTable::FOOTER: case PositionInTable::BODY: |
| 129 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
| 129 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
| 130 | 130 | break; |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -138,12 +138,12 @@ discard block |
||
| 138 | 138 | * @param callable $callback function called after the field compilation |
| 139 | 139 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 140 | 140 | */ |
| 141 | - public function afterCompile($index,$callback){ |
|
| 142 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
| 141 | + public function afterCompile($index, $callback) { |
|
| 142 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
| 143 | 143 | return $this; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - private function addToolbarRow($part,$table,$captions){ |
|
| 146 | + private function addToolbarRow($part, $table, $captions) { |
|
| 147 | 147 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 148 | 148 | $row->mergeCol(); |
| 149 | 149 | $row->setValues([$this->_toolbar]); |
@@ -158,42 +158,42 @@ discard block |
||
| 158 | 158 | return $this; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public function setCaptions($captions){ |
|
| 161 | + public function setCaptions($captions) { |
|
| 162 | 162 | $this->_instanceViewer->setCaptions($captions); |
| 163 | 163 | return $this; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - public function setFields($fields){ |
|
| 166 | + public function setFields($fields) { |
|
| 167 | 167 | $this->_instanceViewer->setVisibleProperties($fields); |
| 168 | 168 | return $this; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - public function addField($field){ |
|
| 171 | + public function addField($field) { |
|
| 172 | 172 | $this->_instanceViewer->addField($field); |
| 173 | 173 | return $this; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - public function insertField($index,$field){ |
|
| 176 | + public function insertField($index, $field) { |
|
| 177 | 177 | $this->_instanceViewer->insertField($index, $field); |
| 178 | 178 | return $this; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - public function insertInField($index,$field){ |
|
| 181 | + public function insertInField($index, $field) { |
|
| 182 | 182 | $this->_instanceViewer->insertInField($index, $field); |
| 183 | 183 | return $this; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - public function setValueFunction($index,$callback){ |
|
| 186 | + public function setValueFunction($index, $callback) { |
|
| 187 | 187 | $this->_instanceViewer->setValueFunction($index, $callback); |
| 188 | 188 | return $this; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - public function setIdentifierFunction($callback){ |
|
| 191 | + public function setIdentifierFunction($callback) { |
|
| 192 | 192 | $this->_instanceViewer->setIdentifierFunction($callback); |
| 193 | 193 | return $this; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - public function getHtmlComponent(){ |
|
| 196 | + public function getHtmlComponent() { |
|
| 197 | 197 | return $this->content["table"]; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -206,8 +206,8 @@ discard block |
||
| 206 | 206 | return $this; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - public function paginate($items_per_page=10,$page=1){ |
|
| 210 | - $this->_pagination=new Pagination($items_per_page,4,$page); |
|
| 209 | + public function paginate($items_per_page=10, $page=1) { |
|
| 210 | + $this->_pagination=new Pagination($items_per_page, 4, $page); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | public function getHasCheckboxes() { |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | return $this; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - public function refresh($compileParts=["tbody"]){ |
|
| 222 | + public function refresh($compileParts=["tbody"]) { |
|
| 223 | 223 | $this->_compileParts=$compileParts; |
| 224 | 224 | return $this; |
| 225 | 225 | } |
@@ -228,8 +228,8 @@ discard block |
||
| 228 | 228 | * @param callable $callback |
| 229 | 229 | * @return callable |
| 230 | 230 | */ |
| 231 | - private function getFieldButtonCallable($caption,$callback=null){ |
|
| 232 | - return $this->getCallable("getFieldButton",[$caption],$callback); |
|
| 231 | + private function getFieldButtonCallable($caption, $callback=null) { |
|
| 232 | + return $this->getCallable("getFieldButton", [$caption], $callback); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -237,16 +237,16 @@ discard block |
||
| 237 | 237 | * @param callable $callback |
| 238 | 238 | * @return callable |
| 239 | 239 | */ |
| 240 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
| 241 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
| 242 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
| 243 | - if(isset($callback)){ |
|
| 244 | - if(\is_callable($callback)){ |
|
| 245 | - $callback($object,$instance); |
|
| 240 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
| 241 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
| 242 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
| 243 | + if (isset($callback)) { |
|
| 244 | + if (\is_callable($callback)) { |
|
| 245 | + $callback($object, $instance); |
|
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | - if($object instanceof HtmlSemDoubleElement){ |
|
| 249 | - $object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier()); |
|
| 248 | + if ($object instanceof HtmlSemDoubleElement) { |
|
| 249 | + $object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier()); |
|
| 250 | 250 | } |
| 251 | 251 | return $object; |
| 252 | 252 | }; |
@@ -257,8 +257,8 @@ discard block |
||
| 257 | 257 | * @param string $caption |
| 258 | 258 | * @return HtmlButton |
| 259 | 259 | */ |
| 260 | - private function getFieldButton($caption){ |
|
| 261 | - return new HtmlButton("",$caption); |
|
| 260 | + private function getFieldButton($caption) { |
|
| 261 | + return new HtmlButton("", $caption); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -267,8 +267,8 @@ discard block |
||
| 267 | 267 | * @param callable $callback |
| 268 | 268 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 269 | 269 | */ |
| 270 | - public function addFieldButton($caption,$callback=null){ |
|
| 271 | - $this->addField($this->getCallable("getFieldButton",[$caption],$callback)); |
|
| 270 | + public function addFieldButton($caption, $callback=null) { |
|
| 271 | + $this->addField($this->getCallable("getFieldButton", [$caption], $callback)); |
|
| 272 | 272 | return $this; |
| 273 | 273 | } |
| 274 | 274 | |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | * @param callable $callback |
| 280 | 280 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 281 | 281 | */ |
| 282 | - public function insertFieldButton($index,$caption,$callback=null){ |
|
| 283 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
| 282 | + public function insertFieldButton($index, $caption, $callback=null) { |
|
| 283 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
| 284 | 284 | return $this; |
| 285 | 285 | } |
| 286 | 286 | |
@@ -291,65 +291,65 @@ discard block |
||
| 291 | 291 | * @param callable $callback |
| 292 | 292 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 293 | 293 | */ |
| 294 | - public function insertInFieldButton($index,$caption,$callback=null){ |
|
| 295 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
| 294 | + public function insertInFieldButton($index, $caption, $callback=null) { |
|
| 295 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
| 296 | 296 | return $this; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - private function addDefaultButton($icon,$class=null,$callback=null){ |
|
| 300 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
|
| 299 | + private function addDefaultButton($icon, $class=null, $callback=null) { |
|
| 300 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class], $callback)); |
|
| 301 | 301 | return $this; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){ |
|
| 305 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
|
| 304 | + private function insertDefaultButtonIn($index, $icon, $class=null, $callback=null) { |
|
| 305 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class], $callback)); |
|
| 306 | 306 | return $this; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - private function getDefaultButton($icon,$class=null){ |
|
| 309 | + private function getDefaultButton($icon, $class=null) { |
|
| 310 | 310 | $bt=$this->getFieldButton(""); |
| 311 | 311 | $bt->asIcon($icon); |
| 312 | - if(isset($class)) |
|
| 312 | + if (isset($class)) |
|
| 313 | 313 | $bt->addToProperty("class", $class); |
| 314 | 314 | return $bt; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - public function addDeleteButton($callback=null){ |
|
| 318 | - return $this->addDefaultButton("remove","delete red basic",$callback); |
|
| 317 | + public function addDeleteButton($callback=null) { |
|
| 318 | + return $this->addDefaultButton("remove", "delete red basic", $callback); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - public function addEditButton($callback=null){ |
|
| 322 | - return $this->addDefaultButton("edit","edit basic",$callback); |
|
| 321 | + public function addEditButton($callback=null) { |
|
| 322 | + return $this->addDefaultButton("edit", "edit basic", $callback); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - public function addEditDeleteButtons($callbackEdit=null,$callbackDelete=null){ |
|
| 325 | + public function addEditDeleteButtons($callbackEdit=null, $callbackDelete=null) { |
|
| 326 | 326 | $this->addEditButton($callbackEdit); |
| 327 | 327 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
| 328 | - $this->insertDeleteButtonIn($index,$callbackDelete); |
|
| 328 | + $this->insertDeleteButtonIn($index, $callbackDelete); |
|
| 329 | 329 | return $this; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - public function insertDeleteButtonIn($index,$callback=null){ |
|
| 333 | - return $this->insertDefaultButtonIn($index,"remove","delete red basic",$callback); |
|
| 332 | + public function insertDeleteButtonIn($index, $callback=null) { |
|
| 333 | + return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $callback); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - public function insertEditButtonIn($index,$callback=null){ |
|
| 337 | - return $this->insertDefaultButtonIn($index,"edit","edit basic",$callback); |
|
| 336 | + public function insertEditButtonIn($index, $callback=null) { |
|
| 337 | + return $this->insertDefaultButtonIn($index, "edit", "edit basic", $callback); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - public function setSelectable(){ |
|
| 340 | + public function setSelectable() { |
|
| 341 | 341 | $this->content["table"]->setSelectable(); |
| 342 | 342 | return $this; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - public function addSearchInToolbar(){ |
|
| 345 | + public function addSearchInToolbar() { |
|
| 346 | 346 | return $this->addInToolbar($this->getSearchField())->setPosition("right"); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - public function getSearchField(){ |
|
| 350 | - if(isset($this->_searchField)===false){ |
|
| 351 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
| 352 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
| 349 | + public function getSearchField() { |
|
| 350 | + if (isset($this->_searchField)===false) { |
|
| 351 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
| 352 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
| 353 | 353 | } |
| 354 | 354 | return $this->_searchField; |
| 355 | 355 | } |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | return $this; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - protected function _getFieldIdentifier($prefix){ |
|
| 362 | + protected function _getFieldIdentifier($prefix) { |
|
| 363 | 363 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
| 364 | 364 | } |
| 365 | 365 | |
@@ -28,15 +28,15 @@ discard block |
||
| 28 | 28 | protected $_toolbarPosition; |
| 29 | 29 | |
| 30 | 30 | |
| 31 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 31 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 32 | 32 | parent::__construct($identifier); |
| 33 | 33 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
| 34 | 34 | $this->setModel($model); |
| 35 | - if(isset($modelInstance)); |
|
| 35 | + if (isset($modelInstance)); |
|
| 36 | 36 | $this->show($modelInstance); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function show($modelInstance){ |
|
| 39 | + public function show($modelInstance) { |
|
| 40 | 40 | $this->_modelInstance=$modelInstance; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -60,15 +60,15 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | public abstract function getHtmlComponent(); |
| 62 | 62 | |
| 63 | - public function setColor($color){ |
|
| 63 | + public function setColor($color) { |
|
| 64 | 64 | return $this->getHtmlComponent()->setColor($color); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
| 69 | 69 | */ |
| 70 | - public function getToolbar(){ |
|
| 71 | - if(isset($this->_toolbar)===false){ |
|
| 70 | + public function getToolbar() { |
|
| 71 | + if (isset($this->_toolbar)===false) { |
|
| 72 | 72 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
| 73 | 73 | $this->_toolbar->setSecondary(); |
| 74 | 74 | } |
@@ -80,25 +80,25 @@ discard block |
||
| 80 | 80 | * @param mixed $element |
| 81 | 81 | * @return \Ajax\common\html\HtmlDoubleElement |
| 82 | 82 | */ |
| 83 | - public function addInToolbar($element){ |
|
| 83 | + public function addInToolbar($element) { |
|
| 84 | 84 | $tb=$this->getToolbar(); |
| 85 | 85 | return $tb->addItem($element); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function addItemInToolbar($caption,$icon=NULL){ |
|
| 88 | + public function addItemInToolbar($caption, $icon=NULL) { |
|
| 89 | 89 | $result=$this->addInToolbar($caption); |
| 90 | 90 | $result->addIcon($icon); |
| 91 | 91 | return $result; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - public function addButtonInToolbar($caption){ |
|
| 95 | - $bt=new HtmlButton("",$caption); |
|
| 94 | + public function addButtonInToolbar($caption) { |
|
| 95 | + $bt=new HtmlButton("", $caption); |
|
| 96 | 96 | return $this->addInToolbar($bt); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
| 100 | - $bt=new HtmlButton("",$caption); |
|
| 101 | - $bt->addIcon($icon,$before,$labeled); |
|
| 99 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
| 100 | + $bt=new HtmlButton("", $caption); |
|
| 101 | + $bt->addIcon($icon, $before, $labeled); |
|
| 102 | 102 | return $this->addInToolbar($bt); |
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | \ No newline at end of file |
@@ -11,122 +11,122 @@ discard block |
||
| 11 | 11 | protected $afterCompile; |
| 12 | 12 | public static $index=0; |
| 13 | 13 | |
| 14 | - public function __construct($instance=NULL){ |
|
| 14 | + public function __construct($instance=NULL) { |
|
| 15 | 15 | $this->values=[]; |
| 16 | 16 | $this->afterCompile=[]; |
| 17 | - if(isset($instance)) |
|
| 17 | + if (isset($instance)) |
|
| 18 | 18 | $this->setInstance($instance); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function getValues(){ |
|
| 21 | + public function getValues() { |
|
| 22 | 22 | $values=[]; |
| 23 | 23 | $index=0; |
| 24 | 24 | $count=$this->count(); |
| 25 | - while($index<$count){ |
|
| 25 | + while ($index<$count) { |
|
| 26 | 26 | $values[]=$this->getValue($index++); |
| 27 | 27 | } |
| 28 | 28 | return $values; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function getIdentifier(){ |
|
| 31 | + public function getIdentifier() { |
|
| 32 | 32 | $value=self::$index; |
| 33 | - if(isset($this->values["identifier"])) |
|
| 34 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 33 | + if (isset($this->values["identifier"])) |
|
| 34 | + $value=$this->values["identifier"](self::$index, $this->instance); |
|
| 35 | 35 | return $value; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function getValue($index){ |
|
| 38 | + public function getValue($index) { |
|
| 39 | 39 | $property=$this->properties[$index]; |
| 40 | 40 | return $this->_getValue($property, $index); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - private function _getValue($property,$index){ |
|
| 44 | - if($property instanceof \ReflectionProperty){ |
|
| 43 | + private function _getValue($property, $index) { |
|
| 44 | + if ($property instanceof \ReflectionProperty) { |
|
| 45 | 45 | $property->setAccessible(true); |
| 46 | 46 | $value=$property->getValue($this->instance); |
| 47 | - if(isset($this->values[$index])){ |
|
| 48 | - $value= $this->values[$index]($value); |
|
| 47 | + if (isset($this->values[$index])) { |
|
| 48 | + $value=$this->values[$index]($value); |
|
| 49 | 49 | } |
| 50 | - }else{ |
|
| 51 | - if(\is_callable($property)) |
|
| 50 | + } else { |
|
| 51 | + if (\is_callable($property)) |
|
| 52 | 52 | $value=$property($this->instance); |
| 53 | - elseif(\is_array($property)){ |
|
| 54 | - $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
|
| 53 | + elseif (\is_array($property)) { |
|
| 54 | + $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property); |
|
| 55 | 55 | $value=\implode("", $values); |
| 56 | - }else |
|
| 56 | + } else |
|
| 57 | 57 | $value=$property; |
| 58 | 58 | } |
| 59 | - if(isset($this->afterCompile[$index])){ |
|
| 60 | - if(\is_callable($this->afterCompile[$index])){ |
|
| 61 | - $this->afterCompile[$index]($value,$this->instance,$index); |
|
| 59 | + if (isset($this->afterCompile[$index])) { |
|
| 60 | + if (\is_callable($this->afterCompile[$index])) { |
|
| 61 | + $this->afterCompile[$index]($value, $this->instance, $index); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | return $value; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - public function insertField($index,$field){ |
|
| 68 | - array_splice( $this->visibleProperties, $index, 0, $field ); |
|
| 67 | + public function insertField($index, $field) { |
|
| 68 | + array_splice($this->visibleProperties, $index, 0, $field); |
|
| 69 | 69 | return $this; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public function insertInField($index,$field){ |
|
| 72 | + public function insertInField($index, $field) { |
|
| 73 | 73 | $vb=$this->visibleProperties; |
| 74 | - if(isset($vb[$index])){ |
|
| 75 | - if(\is_array($vb[$index])){ |
|
| 74 | + if (isset($vb[$index])) { |
|
| 75 | + if (\is_array($vb[$index])) { |
|
| 76 | 76 | $this->visibleProperties[$index][]=$field; |
| 77 | - }else{ |
|
| 78 | - $this->visibleProperties[$index]=[$vb[$index],$field]; |
|
| 77 | + } else { |
|
| 78 | + $this->visibleProperties[$index]=[$vb[$index], $field]; |
|
| 79 | 79 | } |
| 80 | - }else{ |
|
| 80 | + } else { |
|
| 81 | 81 | return $this->insertField($index, $field); |
| 82 | 82 | } |
| 83 | 83 | return $this; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function addField($field){ |
|
| 86 | + public function addField($field) { |
|
| 87 | 87 | $this->visibleProperties[]=$field; |
| 88 | 88 | return $this; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - public function count(){ |
|
| 91 | + public function count() { |
|
| 92 | 92 | return \sizeof($this->properties); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function visiblePropertiesCount(){ |
|
| 95 | + public function visiblePropertiesCount() { |
|
| 96 | 96 | return \sizeof($this->visibleProperties); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - private function showableProperty(\ReflectionProperty $rProperty){ |
|
| 100 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
| 99 | + private function showableProperty(\ReflectionProperty $rProperty) { |
|
| 100 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | public function setInstance($instance) { |
| 104 | - if(\is_string($instance)){ |
|
| 104 | + if (\is_string($instance)) { |
|
| 105 | 105 | $instance=new $instance(); |
| 106 | 106 | } |
| 107 | 107 | $this->instance=$instance; |
| 108 | 108 | $this->properties=[]; |
| 109 | 109 | $this->reflect=new \ReflectionClass($instance); |
| 110 | - if(\sizeof($this->visibleProperties)===0){ |
|
| 110 | + if (\sizeof($this->visibleProperties)===0) { |
|
| 111 | 111 | $this->properties=$this->getDefaultProperties(); |
| 112 | - }else{ |
|
| 113 | - foreach ($this->visibleProperties as $property){ |
|
| 114 | - if(\is_callable($property)){ |
|
| 112 | + } else { |
|
| 113 | + foreach ($this->visibleProperties as $property) { |
|
| 114 | + if (\is_callable($property)) { |
|
| 115 | 115 | $this->properties[]=$property; |
| 116 | - }elseif(\is_string($property)){ |
|
| 117 | - try{ |
|
| 116 | + }elseif (\is_string($property)) { |
|
| 117 | + try { |
|
| 118 | 118 | $rProperty=$this->reflect->getProperty($property); |
| 119 | 119 | $this->properties[]=$rProperty; |
| 120 | - }catch(\Exception $e){ |
|
| 120 | + }catch (\Exception $e) { |
|
| 121 | 121 | $this->properties[]=$property; |
| 122 | 122 | } |
| 123 | - }elseif(\is_int($property)){ |
|
| 123 | + }elseif (\is_int($property)) { |
|
| 124 | 124 | $props=$this->getDefaultProperties(); |
| 125 | - if(isset($props[$property])) |
|
| 125 | + if (isset($props[$property])) |
|
| 126 | 126 | $this->properties[]=$props[$property]; |
| 127 | 127 | else |
| 128 | 128 | $this->properties[]=$property; |
| 129 | - }else{ |
|
| 129 | + } else { |
|
| 130 | 130 | $this->properties[]=$property; |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -134,12 +134,12 @@ discard block |
||
| 134 | 134 | return $this; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - private function getDefaultProperties(){ |
|
| 137 | + private function getDefaultProperties() { |
|
| 138 | 138 | $result=[]; |
| 139 | 139 | $properties=$this->reflect->getProperties(); |
| 140 | - foreach ($properties as $property){ |
|
| 140 | + foreach ($properties as $property) { |
|
| 141 | 141 | $showable=$this->showableProperty($property); |
| 142 | - if($showable!==false){ |
|
| 142 | + if ($showable!==false) { |
|
| 143 | 143 | $result[]=$property; |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | return $this; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public function setValueFunction($index,$callback){ |
|
| 154 | + public function setValueFunction($index, $callback) { |
|
| 155 | 155 | $this->values[$index]=$callback; |
| 156 | 156 | return $this; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - public function setIdentifierFunction($callback){ |
|
| 159 | + public function setIdentifierFunction($callback) { |
|
| 160 | 160 | $this->values["identifier"]=$callback; |
| 161 | 161 | return $this; |
| 162 | 162 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * @param callable $callback function called after the field compilation |
| 177 | 177 | * @return \Ajax\semantic\widgets\datatable\InstanceViewer |
| 178 | 178 | */ |
| 179 | - public function afterCompile($index,$callback){ |
|
| 179 | + public function afterCompile($index, $callback) { |
|
| 180 | 180 | $this->afterCompile[$index]=$callback; |
| 181 | 181 | return $this; |
| 182 | 182 | } |
@@ -5,24 +5,24 @@ discard block |
||
| 5 | 5 | class InstanceViewerCaption extends InstanceViewer { |
| 6 | 6 | protected $captions; |
| 7 | 7 | |
| 8 | - public function __construct($instance=NULL,$captions=NULL){ |
|
| 8 | + public function __construct($instance=NULL, $captions=NULL) { |
|
| 9 | 9 | parent::__construct($instance); |
| 10 | 10 | $this->setCaptions($captions); |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - public function getCaption($index){ |
|
| 14 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 13 | + public function getCaption($index) { |
|
| 14 | + if ($this->properties[$index] instanceof \ReflectionProperty) |
|
| 15 | 15 | return $this->properties[$index]->getName(); |
| 16 | - elseif(\is_callable($this->properties[$index])) |
|
| 16 | + elseif (\is_callable($this->properties[$index])) |
|
| 17 | 17 | return ""; |
| 18 | 18 | else |
| 19 | 19 | return $this->properties[$index]; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function getCaptions(){ |
|
| 23 | - if(isset($this->captions)){ |
|
| 24 | - $result= $this->captions; |
|
| 25 | - for($i=\sizeof($result);$i<$this->count();$i++){ |
|
| 22 | + public function getCaptions() { |
|
| 23 | + if (isset($this->captions)) { |
|
| 24 | + $result=$this->captions; |
|
| 25 | + for ($i=\sizeof($result); $i<$this->count(); $i++) { |
|
| 26 | 26 | $result[]=""; |
| 27 | 27 | } |
| 28 | 28 | return $result; |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $captions=[]; |
| 31 | 31 | $index=0; |
| 32 | 32 | $count=$this->count(); |
| 33 | - while($index<$count){ |
|
| 33 | + while ($index<$count) { |
|
| 34 | 34 | $captions[]=$this->getCaption($index++); |
| 35 | 35 | } |
| 36 | 36 | return $captions; |