@@ -68,8 +68,9 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | $table->setRowCount(0, \sizeof($captions)); |
| 70 | 70 | $table->setHeaderValues($captions); |
| 71 | - if(isset($this->_compileParts)) |
|
| 72 | - $table->setCompileParts($this->_compileParts); |
|
| 71 | + if(isset($this->_compileParts)) { |
|
| 72 | + $table->setCompileParts($this->_compileParts); |
|
| 73 | + } |
|
| 73 | 74 | if(isset($this->_searchField) && isset($js)){ |
| 74 | 75 | $this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
| 75 | 76 | } |
@@ -275,8 +276,9 @@ discard block |
||
| 275 | 276 | private function getDefaultButton($icon,$class=null){ |
| 276 | 277 | $bt=$this->getFieldButton(""); |
| 277 | 278 | $bt->asIcon($icon); |
| 278 | - if(isset($class)) |
|
| 279 | - $bt->addToProperty("class", $class); |
|
| 279 | + if(isset($class)) { |
|
| 280 | + $bt->addToProperty("class", $class); |
|
| 281 | + } |
|
| 280 | 282 | return $bt; |
| 281 | 283 | } |
| 282 | 284 | |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | protected $_hasCheckboxes; |
| 31 | 31 | protected $_compileParts; |
| 32 | 32 | |
| 33 | - public function run(JsUtils $js){ |
|
| 34 | - if($this->_hasCheckboxes && isset($js)){ |
|
| 33 | + public function run(JsUtils $js) { |
|
| 34 | + if ($this->_hasCheckboxes && isset($js)) { |
|
| 35 | 35 | $js->execOn("change", "#".$this->identifier." [name='selection[]']", " |
| 36 | 36 | var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true; |
| 37 | 37 | \$checkbox.each(function() {if($(this).prop('checked')){allUnchecked = false;}else{allChecked = false;}}); |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | parent::run($js); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 44 | - parent::__construct($identifier, $model,$modelInstance); |
|
| 45 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
| 43 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 44 | + parent::__construct($identifier, $model, $modelInstance); |
|
| 45 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -54,61 +54,61 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 57 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 58 | 58 | $this->_instanceViewer->setInstance($this->_model); |
| 59 | 59 | $captions=$this->_instanceViewer->getCaptions(); |
| 60 | 60 | |
| 61 | 61 | $table=$this->content["table"]; |
| 62 | 62 | |
| 63 | - if($this->_hasCheckboxes){ |
|
| 63 | + if ($this->_hasCheckboxes) { |
|
| 64 | 64 | $this->_generateMainCheckbox($captions); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $table->setRowCount(0, \sizeof($captions)); |
| 68 | 68 | $table->setHeaderValues($captions); |
| 69 | - if(isset($this->_compileParts)) |
|
| 69 | + if (isset($this->_compileParts)) |
|
| 70 | 70 | $table->setCompileParts($this->_compileParts); |
| 71 | - if(isset($this->_searchField) && isset($js)){ |
|
| 72 | - $this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
| 71 | + if (isset($this->_searchField) && isset($js)) { |
|
| 72 | + $this->_searchField->postOn("change", $this->_urls, "{'s':$(this).val()}", "-#".$this->identifier." tbody", ["preventDefault"=>false]); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $this->_generateContent($table); |
| 76 | 76 | |
| 77 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
| 78 | - $table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort"); |
|
| 77 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
| 78 | + $table->getHeader()->getCell(0, 0)->addToProperty("class", "no-sort"); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
| 81 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
| 82 | 82 | $this->_generatePagination($table); |
| 83 | 83 | } |
| 84 | - if(isset($this->_toolbar)){ |
|
| 84 | + if (isset($this->_toolbar)) { |
|
| 85 | 85 | $this->_setToolbarPosition($table, $captions); |
| 86 | 86 | } |
| 87 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
| 88 | - return parent::compile($js,$view); |
|
| 87 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
| 88 | + return parent::compile($js, $view); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - private function _generateMainCheckbox(&$captions){ |
|
| 92 | - $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
|
| 91 | + private function _generateMainCheckbox(&$captions) { |
|
| 92 | + $ck=new HtmlCheckbox("main-ck-".$this->identifier, ""); |
|
| 93 | 93 | $ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);"); |
| 94 | 94 | $ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);"); |
| 95 | 95 | \array_unshift($captions, $ck); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - protected function _generateContent($table){ |
|
| 98 | + protected function _generateContent($table) { |
|
| 99 | 99 | $objects=$this->_modelInstance; |
| 100 | - if(isset($this->_pagination)){ |
|
| 100 | + if (isset($this->_pagination)) { |
|
| 101 | 101 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
| 102 | 102 | } |
| 103 | 103 | InstanceViewer::setIndex(0); |
| 104 | - $table->fromDatabaseObjects($objects, function($instance){ |
|
| 104 | + $table->fromDatabaseObjects($objects, function($instance) { |
|
| 105 | 105 | $this->_instanceViewer->setInstance($instance); |
| 106 | 106 | InstanceViewer::$index++; |
| 107 | - $result= $this->_instanceViewer->getValues(); |
|
| 108 | - if($this->_hasCheckboxes){ |
|
| 109 | - $ck=new HtmlCheckbox("ck-".$this->identifier,""); |
|
| 107 | + $result=$this->_instanceViewer->getValues(); |
|
| 108 | + if ($this->_hasCheckboxes) { |
|
| 109 | + $ck=new HtmlCheckbox("ck-".$this->identifier, ""); |
|
| 110 | 110 | $field=$ck->getField(); |
| 111 | - $field->setProperty("value",$this->_instanceViewer->getIdentifier()); |
|
| 111 | + $field->setProperty("value", $this->_instanceViewer->getIdentifier()); |
|
| 112 | 112 | $field->setProperty("name", "selection[]"); |
| 113 | 113 | \array_unshift($result, $ck); |
| 114 | 114 | } |
@@ -116,25 +116,25 @@ discard block |
||
| 116 | 116 | }); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - private function _generatePagination($table){ |
|
| 119 | + private function _generatePagination($table) { |
|
| 120 | 120 | $footer=$table->getFooter(); |
| 121 | 121 | $footer->mergeCol(); |
| 122 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
| 122 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
| 123 | 123 | $menu->floatRight(); |
| 124 | 124 | $menu->setActiveItem($this->_pagination->getPage()-1); |
| 125 | 125 | $footer->setValues($menu); |
| 126 | - $menu->postOnClick($this->_urls,"{'p':$(this).attr('data-page')}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
| 126 | + $menu->postOnClick($this->_urls, "{'p':$(this).attr('data-page')}", "-#".$this->identifier." tbody", ["preventDefault"=>false]); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
| 130 | - switch ($this->_toolbarPosition){ |
|
| 129 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
| 130 | + switch ($this->_toolbarPosition) { |
|
| 131 | 131 | case PositionInTable::BEFORETABLE:case PositionInTable::AFTERTABLE: |
| 132 | - if(isset($this->_compileParts)===false){ |
|
| 132 | + if (isset($this->_compileParts)===false) { |
|
| 133 | 133 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 134 | 134 | } |
| 135 | 135 | break; |
| 136 | 136 | case PositionInTable::HEADER:case PositionInTable::FOOTER: case PositionInTable::BODY: |
| 137 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
| 137 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
| 138 | 138 | break; |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -146,18 +146,18 @@ discard block |
||
| 146 | 146 | * @param callable $callback function called after the field compilation |
| 147 | 147 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 148 | 148 | */ |
| 149 | - public function afterCompile($index,$callback){ |
|
| 150 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
| 149 | + public function afterCompile($index, $callback) { |
|
| 150 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
| 151 | 151 | return $this; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - private function addToolbarRow($part,$table,$captions){ |
|
| 154 | + private function addToolbarRow($part, $table, $captions) { |
|
| 155 | 155 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 156 | 156 | $row->mergeCol(); |
| 157 | 157 | $row->setValues([$this->_toolbar]); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function getHtmlComponent(){ |
|
| 160 | + public function getHtmlComponent() { |
|
| 161 | 161 | return $this->content["table"]; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | return $this; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - public function paginate($items_per_page=10,$page=1){ |
|
| 174 | - $this->_pagination=new Pagination($items_per_page,4,$page); |
|
| 173 | + public function paginate($items_per_page=10, $page=1) { |
|
| 174 | + $this->_pagination=new Pagination($items_per_page, 4, $page); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | public function getHasCheckboxes() { |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | return $this; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - public function refresh($compileParts=["tbody"]){ |
|
| 186 | + public function refresh($compileParts=["tbody"]) { |
|
| 187 | 187 | $this->_compileParts=$compileParts; |
| 188 | 188 | return $this; |
| 189 | 189 | } |
@@ -192,8 +192,8 @@ discard block |
||
| 192 | 192 | * @param callable $callback |
| 193 | 193 | * @return callable |
| 194 | 194 | */ |
| 195 | - private function getFieldButtonCallable($caption,$callback=null){ |
|
| 196 | - return $this->getCallable("getFieldButton",[$caption],$callback); |
|
| 195 | + private function getFieldButtonCallable($caption, $callback=null) { |
|
| 196 | + return $this->getCallable("getFieldButton", [$caption], $callback); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -201,16 +201,16 @@ discard block |
||
| 201 | 201 | * @param callable $callback |
| 202 | 202 | * @return callable |
| 203 | 203 | */ |
| 204 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
| 205 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
| 206 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
| 207 | - if(isset($callback)){ |
|
| 208 | - if(\is_callable($callback)){ |
|
| 209 | - $callback($object,$instance); |
|
| 204 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
| 205 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
| 206 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
| 207 | + if (isset($callback)) { |
|
| 208 | + if (\is_callable($callback)) { |
|
| 209 | + $callback($object, $instance); |
|
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | - if($object instanceof HtmlSemDoubleElement){ |
|
| 213 | - $object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier()); |
|
| 212 | + if ($object instanceof HtmlSemDoubleElement) { |
|
| 213 | + $object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier()); |
|
| 214 | 214 | } |
| 215 | 215 | return $object; |
| 216 | 216 | }; |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | * @param string $caption |
| 222 | 222 | * @return HtmlButton |
| 223 | 223 | */ |
| 224 | - private function getFieldButton($caption){ |
|
| 225 | - return new HtmlButton("",$caption); |
|
| 224 | + private function getFieldButton($caption) { |
|
| 225 | + return new HtmlButton("", $caption); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -231,8 +231,8 @@ discard block |
||
| 231 | 231 | * @param callable $callback |
| 232 | 232 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 233 | 233 | */ |
| 234 | - public function addFieldButton($caption,$callback=null){ |
|
| 235 | - $this->addField($this->getCallable("getFieldButton",[$caption],$callback)); |
|
| 234 | + public function addFieldButton($caption, $callback=null) { |
|
| 235 | + $this->addField($this->getCallable("getFieldButton", [$caption], $callback)); |
|
| 236 | 236 | return $this; |
| 237 | 237 | } |
| 238 | 238 | |
@@ -243,8 +243,8 @@ discard block |
||
| 243 | 243 | * @param callable $callback |
| 244 | 244 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 245 | 245 | */ |
| 246 | - public function insertFieldButton($index,$caption,$callback=null){ |
|
| 247 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
| 246 | + public function insertFieldButton($index, $caption, $callback=null) { |
|
| 247 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
| 248 | 248 | return $this; |
| 249 | 249 | } |
| 250 | 250 | |
@@ -255,60 +255,60 @@ discard block |
||
| 255 | 255 | * @param callable $callback |
| 256 | 256 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 257 | 257 | */ |
| 258 | - public function insertInFieldButton($index,$caption,$callback=null){ |
|
| 259 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
| 258 | + public function insertInFieldButton($index, $caption, $callback=null) { |
|
| 259 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
| 260 | 260 | return $this; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - private function addDefaultButton($icon,$class=null,$callback=null){ |
|
| 264 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
|
| 263 | + private function addDefaultButton($icon, $class=null, $callback=null) { |
|
| 264 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class], $callback)); |
|
| 265 | 265 | return $this; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){ |
|
| 269 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
|
| 268 | + private function insertDefaultButtonIn($index, $icon, $class=null, $callback=null) { |
|
| 269 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class], $callback)); |
|
| 270 | 270 | return $this; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - private function getDefaultButton($icon,$class=null){ |
|
| 273 | + private function getDefaultButton($icon, $class=null) { |
|
| 274 | 274 | $bt=$this->getFieldButton(""); |
| 275 | 275 | $bt->asIcon($icon); |
| 276 | - if(isset($class)) |
|
| 276 | + if (isset($class)) |
|
| 277 | 277 | $bt->addToProperty("class", $class); |
| 278 | 278 | return $bt; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - public function addDeleteButton($callback=null){ |
|
| 282 | - return $this->addDefaultButton("remove","delete red basic",$callback); |
|
| 281 | + public function addDeleteButton($callback=null) { |
|
| 282 | + return $this->addDefaultButton("remove", "delete red basic", $callback); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - public function addEditButton($callback=null){ |
|
| 286 | - return $this->addDefaultButton("edit","edit basic",$callback); |
|
| 285 | + public function addEditButton($callback=null) { |
|
| 286 | + return $this->addDefaultButton("edit", "edit basic", $callback); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - public function addEditDeleteButtons($callbackEdit=null,$callbackDelete=null){ |
|
| 289 | + public function addEditDeleteButtons($callbackEdit=null, $callbackDelete=null) { |
|
| 290 | 290 | $this->addEditButton($callbackEdit); |
| 291 | 291 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
| 292 | - $this->insertDeleteButtonIn($index,$callbackDelete); |
|
| 292 | + $this->insertDeleteButtonIn($index, $callbackDelete); |
|
| 293 | 293 | return $this; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - public function insertDeleteButtonIn($index,$callback=null){ |
|
| 297 | - return $this->insertDefaultButtonIn($index,"remove","delete red basic",$callback); |
|
| 296 | + public function insertDeleteButtonIn($index, $callback=null) { |
|
| 297 | + return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $callback); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - public function insertEditButtonIn($index,$callback=null){ |
|
| 301 | - return $this->insertDefaultButtonIn($index,"edit","edit basic",$callback); |
|
| 300 | + public function insertEditButtonIn($index, $callback=null) { |
|
| 301 | + return $this->insertDefaultButtonIn($index, "edit", "edit basic", $callback); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
| 304 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
| 305 | 305 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - public function getSearchField(){ |
|
| 309 | - if(isset($this->_searchField)===false){ |
|
| 310 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
| 311 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
| 308 | + public function getSearchField() { |
|
| 309 | + if (isset($this->_searchField)===false) { |
|
| 310 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
| 311 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
| 312 | 312 | } |
| 313 | 313 | return $this->_searchField; |
| 314 | 314 | } |
@@ -40,6 +40,10 @@ discard block |
||
| 40 | 40 | parent::run($js); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | + /** |
|
| 44 | + * @param string $identifier |
|
| 45 | + * @param string $model |
|
| 46 | + */ |
|
| 43 | 47 | public function __construct($identifier,$model,$modelInstance=NULL) { |
| 44 | 48 | parent::__construct($identifier, $model,$modelInstance); |
| 45 | 49 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
@@ -151,6 +155,9 @@ discard block |
||
| 151 | 155 | return $this; |
| 152 | 156 | } |
| 153 | 157 | |
| 158 | + /** |
|
| 159 | + * @param PositionInTable $part |
|
| 160 | + */ |
|
| 154 | 161 | private function addToolbarRow($part,$table,$captions){ |
| 155 | 162 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 156 | 163 | $row->mergeCol(); |
@@ -190,7 +197,7 @@ discard block |
||
| 190 | 197 | /** |
| 191 | 198 | * @param string $caption |
| 192 | 199 | * @param callable $callback |
| 193 | - * @return callable |
|
| 200 | + * @return \Closure |
|
| 194 | 201 | */ |
| 195 | 202 | private function getFieldButtonCallable($caption,$callback=null){ |
| 196 | 203 | return $this->getCallable("getFieldButton",[$caption],$callback); |
@@ -198,9 +205,9 @@ discard block |
||
| 198 | 205 | |
| 199 | 206 | /** |
| 200 | 207 | * @param callable $thisCallback |
| 201 | - * @param array $parameters |
|
| 208 | + * @param string[] $parameters |
|
| 202 | 209 | * @param callable $callback |
| 203 | - * @return callable |
|
| 210 | + * @return \Closure |
|
| 204 | 211 | */ |
| 205 | 212 | private function getCallable($thisCallback,$parameters,$callback=null){ |
| 206 | 213 | $result=function($instance) use($thisCallback,$parameters,$callback){ |
@@ -261,11 +268,19 @@ discard block |
||
| 261 | 268 | return $this; |
| 262 | 269 | } |
| 263 | 270 | |
| 271 | + /** |
|
| 272 | + * @param string $icon |
|
| 273 | + * @param string $class |
|
| 274 | + */ |
|
| 264 | 275 | private function addDefaultButton($icon,$class=null,$callback=null){ |
| 265 | 276 | $this->addField($this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
| 266 | 277 | return $this; |
| 267 | 278 | } |
| 268 | 279 | |
| 280 | + /** |
|
| 281 | + * @param string $icon |
|
| 282 | + * @param string $class |
|
| 283 | + */ |
|
| 269 | 284 | private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){ |
| 270 | 285 | $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
| 271 | 286 | return $this; |
@@ -10,16 +10,16 @@ discard block |
||
| 10 | 10 | * @property SimpleExtComponent $_bsComponent |
| 11 | 11 | * @property string identifier |
| 12 | 12 | */ |
| 13 | -trait BaseHtmlEventsTrait{ |
|
| 13 | +trait BaseHtmlEventsTrait { |
|
| 14 | 14 | |
| 15 | - protected $_events=array (); |
|
| 15 | + protected $_events=array(); |
|
| 16 | 16 | |
| 17 | 17 | public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
| 18 | - if ($stopPropagation === true) { |
|
| 19 | - $jsCode="event.stopPropagation();" . $jsCode; |
|
| 18 | + if ($stopPropagation===true) { |
|
| 19 | + $jsCode="event.stopPropagation();".$jsCode; |
|
| 20 | 20 | } |
| 21 | - if ($preventDefault === true) { |
|
| 22 | - $jsCode="event.preventDefault();" . $jsCode; |
|
| 21 | + if ($preventDefault===true) { |
|
| 22 | + $jsCode="event.preventDefault();".$jsCode; |
|
| 23 | 23 | } |
| 24 | 24 | return $this->_addEvent($event, $jsCode); |
| 25 | 25 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | if (is_array($this->_events[$event])) { |
| 30 | 30 | $this->_events[$event][]=$jsCode; |
| 31 | 31 | } else { |
| 32 | - $this->_events[$event]=array ($this->_events[$event],$jsCode ); |
|
| 32 | + $this->_events[$event]=array($this->_events[$event], $jsCode); |
|
| 33 | 33 | } |
| 34 | 34 | } else { |
| 35 | 35 | $this->_events[$event]=$jsCode; |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | return $this->onClick($jsCode); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function onCreate($jsCode){ |
|
| 53 | - if(isset($this->_events["_create"])){ |
|
| 52 | + public function onCreate($jsCode) { |
|
| 53 | + if (isset($this->_events["_create"])) { |
|
| 54 | 54 | $this->_events["_create"][]=$jsCode; |
| 55 | - }else{ |
|
| 55 | + } else { |
|
| 56 | 56 | $this->_events["_create"]=[$jsCode]; |
| 57 | 57 | } |
| 58 | 58 | return $this; |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | public function addEventsOnRun(JsUtils $js=NULL) { |
| 62 | 62 | $this->_eventsOnCreate($js); |
| 63 | 63 | if (isset($this->_bsComponent)) { |
| 64 | - foreach ( $this->_events as $event => $jsCode ) { |
|
| 64 | + foreach ($this->_events as $event => $jsCode) { |
|
| 65 | 65 | $code=$jsCode; |
| 66 | 66 | if (is_array($jsCode)) { |
| 67 | 67 | $code=""; |
| 68 | - foreach ( $jsCode as $jsC ) { |
|
| 68 | + foreach ($jsCode as $jsC) { |
|
| 69 | 69 | if ($jsC instanceof AjaxCall) { |
| 70 | - $code.="\n" . $jsC->compile($js); |
|
| 70 | + $code.="\n".$jsC->compile($js); |
|
| 71 | 71 | } else { |
| 72 | - $code.="\n" . $jsC; |
|
| 72 | + $code.="\n".$jsC; |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | } elseif ($jsCode instanceof AjaxCall) { |
@@ -77,24 +77,24 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | $this->_bsComponent->addEvent($event, $code); |
| 79 | 79 | } |
| 80 | - $this->_events=array (); |
|
| 80 | + $this->_events=array(); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - protected function _eventsOnCreate(JsUtils $js=NULL){ |
|
| 85 | - if(isset($this->_events["_create"])){ |
|
| 84 | + protected function _eventsOnCreate(JsUtils $js=NULL) { |
|
| 85 | + if (isset($this->_events["_create"])) { |
|
| 86 | 86 | $create=$this->_events["_create"]; |
| 87 | - if(\is_array($create)){ |
|
| 87 | + if (\is_array($create)) { |
|
| 88 | 88 | $create=\implode("", $create); |
| 89 | 89 | } |
| 90 | - if(isset($js) && $create!=="") |
|
| 91 | - $js->exec($create,true); |
|
| 90 | + if (isset($js) && $create!=="") |
|
| 91 | + $js->exec($create, true); |
|
| 92 | 92 | unset($this->_events["_create"]); |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
| 97 | - $params=array ("url" => $url,"responseElement" => $responseElement ); |
|
| 97 | + $params=array("url" => $url, "responseElement" => $responseElement); |
|
| 98 | 98 | $params=array_merge($params, $parameters); |
| 99 | 99 | $this->_addEvent($event, new AjaxCall($operation, $params)); |
| 100 | 100 | return $this; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | public function jsDoJquery($jqueryCall, $param="") { |
| 130 | - return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . Javascript::prep_value($param) . ");"; |
|
| 130 | + return "$('#".$this->identifier."').".$jqueryCall."(".Javascript::prep_value($param).");"; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public function executeOnRun($jsCode) { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | public function onCreate($jsCode){ |
| 53 | 53 | if(isset($this->_events["_create"])){ |
| 54 | 54 | $this->_events["_create"][]=$jsCode; |
| 55 | - }else{ |
|
| 55 | + } else{ |
|
| 56 | 56 | $this->_events["_create"]=[$jsCode]; |
| 57 | 57 | } |
| 58 | 58 | return $this; |
@@ -87,8 +87,9 @@ discard block |
||
| 87 | 87 | if(\is_array($create)){ |
| 88 | 88 | $create=\implode("", $create); |
| 89 | 89 | } |
| 90 | - if(isset($js) && $create!=="") |
|
| 91 | - $js->exec($create,true); |
|
| 90 | + if(isset($js) && $create!=="") { |
|
| 91 | + $js->exec($create,true); |
|
| 92 | + } |
|
| 92 | 93 | unset($this->_events["_create"]); |
| 93 | 94 | } |
| 94 | 95 | } |
@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | $this->widgetIdentifier=$identifier; |
| 21 | 21 | $this->values=[]; |
| 22 | 22 | $this->afterCompile=[]; |
| 23 | - if(isset($instance)) |
|
| 24 | - $this->setInstance($instance); |
|
| 23 | + if(isset($instance)) { |
|
| 24 | + $this->setInstance($instance); |
|
| 25 | + } |
|
| 25 | 26 | $this->setCaptions($captions); |
| 26 | 27 | $this->captionCallback=NULL; |
| 27 | 28 | } |
@@ -38,8 +39,9 @@ discard block |
||
| 38 | 39 | |
| 39 | 40 | public function getIdentifier(){ |
| 40 | 41 | $value=self::$index; |
| 41 | - if(isset($this->values["identifier"])) |
|
| 42 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 42 | + if(isset($this->values["identifier"])) { |
|
| 43 | + $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 44 | + } |
|
| 43 | 45 | return $value; |
| 44 | 46 | } |
| 45 | 47 | |
@@ -62,19 +64,19 @@ discard block |
||
| 62 | 64 | $value=$property->getValue($this->instance); |
| 63 | 65 | if(isset($this->values[$index])){ |
| 64 | 66 | $value= $this->values[$index]($value,$this->instance,$index); |
| 65 | - }else{ |
|
| 67 | + } else{ |
|
| 66 | 68 | $value=$this->_getDefaultValue($property->getName(),$value, $index); |
| 67 | 69 | } |
| 68 | - }else{ |
|
| 69 | - if(\is_callable($property)) |
|
| 70 | - $value=$property($this->instance); |
|
| 71 | - elseif(\is_array($property)){ |
|
| 70 | + } else{ |
|
| 71 | + if(\is_callable($property)) { |
|
| 72 | + $value=$property($this->instance); |
|
| 73 | + } elseif(\is_array($property)){ |
|
| 72 | 74 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
| 73 | 75 | $value=\implode("", $values); |
| 74 | - }else{ |
|
| 76 | + } else{ |
|
| 75 | 77 | if(isset($this->values[$index])){ |
| 76 | 78 | $value= $this->values[$index]($property,$this->instance,$index); |
| 77 | - }else{ |
|
| 79 | + } else{ |
|
| 78 | 80 | $value=$property; |
| 79 | 81 | } |
| 80 | 82 | } |
@@ -97,10 +99,10 @@ discard block |
||
| 97 | 99 | if(isset($vb[$index])){ |
| 98 | 100 | if(\is_array($vb[$index])){ |
| 99 | 101 | $this->visibleProperties[$index][]=$field; |
| 100 | - }else{ |
|
| 102 | + } else{ |
|
| 101 | 103 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
| 102 | 104 | } |
| 103 | - }else{ |
|
| 105 | + } else{ |
|
| 104 | 106 | return $this->insertField($index, $field); |
| 105 | 107 | } |
| 106 | 108 | return $this; |
@@ -136,7 +138,7 @@ discard block |
||
| 136 | 138 | $this->reflect=new \ReflectionClass($instance); |
| 137 | 139 | if(\sizeof($this->visibleProperties)===0){ |
| 138 | 140 | $this->properties=$this->getDefaultProperties(); |
| 139 | - }else{ |
|
| 141 | + } else{ |
|
| 140 | 142 | foreach ($this->visibleProperties as $property){ |
| 141 | 143 | $this->setInstanceProperty($property); |
| 142 | 144 | } |
@@ -147,22 +149,23 @@ discard block |
||
| 147 | 149 | private function setInstanceProperty($property){ |
| 148 | 150 | if(\is_callable($property)){ |
| 149 | 151 | $this->properties[]=$property; |
| 150 | - }elseif(\is_string($property)){ |
|
| 152 | + } elseif(\is_string($property)){ |
|
| 151 | 153 | try{ |
| 152 | 154 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 153 | 155 | $rProperty=$this->reflect->getProperty($property); |
| 154 | 156 | $this->properties[]=$rProperty; |
| 155 | - }catch(\Exception $e){ |
|
| 157 | + } catch(\Exception $e){ |
|
| 156 | 158 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 157 | 159 | $this->properties[]=$property; |
| 158 | 160 | } |
| 159 | - }elseif(\is_int($property)){ |
|
| 161 | + } elseif(\is_int($property)){ |
|
| 160 | 162 | $props=$this->getDefaultProperties(); |
| 161 | - if(isset($props[$property])) |
|
| 162 | - $this->properties[]=$props[$property]; |
|
| 163 | - else |
|
| 164 | - $this->properties[]=$property; |
|
| 165 | - }else{ |
|
| 163 | + if(isset($props[$property])) { |
|
| 164 | + $this->properties[]=$props[$property]; |
|
| 165 | + } else { |
|
| 166 | + $this->properties[]=$property; |
|
| 167 | + } |
|
| 168 | + } else{ |
|
| 166 | 169 | $this->properties[]=$property; |
| 167 | 170 | } |
| 168 | 171 | } |
@@ -206,12 +209,13 @@ discard block |
||
| 206 | 209 | if(isset($this->captions[$index])){ |
| 207 | 210 | return $this->captions[$index]; |
| 208 | 211 | } |
| 209 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 210 | - return $this->properties[$index]->getName(); |
|
| 211 | - elseif(\is_callable($this->properties[$index])) |
|
| 212 | - return ""; |
|
| 213 | - else |
|
| 214 | - return $this->properties[$index]; |
|
| 212 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
| 213 | + return $this->properties[$index]->getName(); |
|
| 214 | + } elseif(\is_callable($this->properties[$index])) { |
|
| 215 | + return ""; |
|
| 216 | + } else { |
|
| 217 | + return $this->properties[$index]; |
|
| 218 | + } |
|
| 215 | 219 | } |
| 216 | 220 | |
| 217 | 221 | public function getCaptions(){ |
@@ -220,7 +224,7 @@ discard block |
||
| 220 | 224 | for($i=\sizeof($captions);$i<$this->count();$i++){ |
| 221 | 225 | $captions[]=""; |
| 222 | 226 | } |
| 223 | - }else{ |
|
| 227 | + } else{ |
|
| 224 | 228 | $captions=[]; |
| 225 | 229 | $index=0; |
| 226 | 230 | $count=$this->count(); |
@@ -236,8 +240,9 @@ discard block |
||
| 236 | 240 | } |
| 237 | 241 | |
| 238 | 242 | public function setCaption($index,$caption){ |
| 239 | - if(isset($this->captions)===false) |
|
| 240 | - $this->captions=[]; |
|
| 243 | + if(isset($this->captions)===false) { |
|
| 244 | + $this->captions=[]; |
|
| 245 | + } |
|
| 241 | 246 | $this->captions[$index]=$caption; |
| 242 | 247 | return $this; |
| 243 | 248 | } |
@@ -17,165 +17,165 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public static $index=0; |
| 19 | 19 | |
| 20 | - public function __construct($identifier,$instance=NULL,$captions=NULL){ |
|
| 20 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
| 21 | 21 | $this->widgetIdentifier=$identifier; |
| 22 | 22 | $this->values=[]; |
| 23 | 23 | $this->afterCompile=[]; |
| 24 | - if(isset($instance)) |
|
| 24 | + if (isset($instance)) |
|
| 25 | 25 | $this->setInstance($instance); |
| 26 | 26 | $this->setCaptions($captions); |
| 27 | 27 | $this->captionCallback=NULL; |
| 28 | - $this->defaultValueFunction=function($name,$value){return $value;}; |
|
| 28 | + $this->defaultValueFunction=function($name, $value) {return $value; }; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function getValues(){ |
|
| 31 | + public function getValues() { |
|
| 32 | 32 | $values=[]; |
| 33 | 33 | $index=0; |
| 34 | 34 | $count=$this->count(); |
| 35 | - while($index<$count){ |
|
| 35 | + while ($index<$count) { |
|
| 36 | 36 | $values[]=$this->getValue($index++); |
| 37 | 37 | } |
| 38 | 38 | return $values; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function getIdentifier(){ |
|
| 41 | + public function getIdentifier() { |
|
| 42 | 42 | $value=self::$index; |
| 43 | - if(isset($this->values["identifier"])) |
|
| 44 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 43 | + if (isset($this->values["identifier"])) |
|
| 44 | + $value=$this->values["identifier"](self::$index, $this->instance); |
|
| 45 | 45 | return $value; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public function getValue($index){ |
|
| 48 | + public function getValue($index) { |
|
| 49 | 49 | $property=$this->properties[$index]; |
| 50 | 50 | return $this->_getValue($property, $index); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - protected function _beforeAddProperty($index,&$field){ |
|
| 53 | + protected function _beforeAddProperty($index, &$field) { |
|
| 54 | 54 | |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - protected function _getDefaultValue($name,$value,$index){ |
|
| 57 | + protected function _getDefaultValue($name, $value, $index) { |
|
| 58 | 58 | $func=$this->defaultValueFunction; |
| 59 | - return $func($name,$value,$index); |
|
| 59 | + return $func($name, $value, $index); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - protected function _getValue($property,$index){ |
|
| 63 | - if($property instanceof \ReflectionProperty){ |
|
| 62 | + protected function _getValue($property, $index) { |
|
| 63 | + if ($property instanceof \ReflectionProperty) { |
|
| 64 | 64 | $property->setAccessible(true); |
| 65 | 65 | $value=$property->getValue($this->instance); |
| 66 | - if(isset($this->values[$index])){ |
|
| 67 | - $value= $this->values[$index]($value,$this->instance,$index); |
|
| 68 | - }else{ |
|
| 69 | - $value=$this->_getDefaultValue($property->getName(),$value, $index); |
|
| 66 | + if (isset($this->values[$index])) { |
|
| 67 | + $value=$this->values[$index]($value, $this->instance, $index); |
|
| 68 | + } else { |
|
| 69 | + $value=$this->_getDefaultValue($property->getName(), $value, $index); |
|
| 70 | 70 | } |
| 71 | - }else{ |
|
| 72 | - if(\is_callable($property)) |
|
| 71 | + } else { |
|
| 72 | + if (\is_callable($property)) |
|
| 73 | 73 | $value=$property($this->instance); |
| 74 | - elseif(\is_array($property)){ |
|
| 75 | - $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
|
| 74 | + elseif (\is_array($property)) { |
|
| 75 | + $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property); |
|
| 76 | 76 | $value=\implode("", $values); |
| 77 | - }else{ |
|
| 78 | - if(isset($this->values[$index])){ |
|
| 79 | - $value= $this->values[$index]($property,$this->instance,$index); |
|
| 80 | - }else{ |
|
| 77 | + } else { |
|
| 78 | + if (isset($this->values[$index])) { |
|
| 79 | + $value=$this->values[$index]($property, $this->instance, $index); |
|
| 80 | + } else { |
|
| 81 | 81 | $value=$property; |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | - if(isset($this->afterCompile[$index])){ |
|
| 86 | - if(\is_callable($this->afterCompile[$index])){ |
|
| 87 | - $this->afterCompile[$index]($value,$this->instance,$index); |
|
| 85 | + if (isset($this->afterCompile[$index])) { |
|
| 86 | + if (\is_callable($this->afterCompile[$index])) { |
|
| 87 | + $this->afterCompile[$index]($value, $this->instance, $index); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | return $value; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function insertField($index,$field){ |
|
| 94 | - array_splice( $this->visibleProperties, $index, 0, $field ); |
|
| 93 | + public function insertField($index, $field) { |
|
| 94 | + array_splice($this->visibleProperties, $index, 0, $field); |
|
| 95 | 95 | return $this; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public function insertInField($index,$field){ |
|
| 98 | + public function insertInField($index, $field) { |
|
| 99 | 99 | $vb=$this->visibleProperties; |
| 100 | - if(isset($vb[$index])){ |
|
| 101 | - if(\is_array($vb[$index])){ |
|
| 100 | + if (isset($vb[$index])) { |
|
| 101 | + if (\is_array($vb[$index])) { |
|
| 102 | 102 | $this->visibleProperties[$index][]=$field; |
| 103 | - }else{ |
|
| 104 | - $this->visibleProperties[$index]=[$vb[$index],$field]; |
|
| 103 | + } else { |
|
| 104 | + $this->visibleProperties[$index]=[$vb[$index], $field]; |
|
| 105 | 105 | } |
| 106 | - }else{ |
|
| 106 | + } else { |
|
| 107 | 107 | return $this->insertField($index, $field); |
| 108 | 108 | } |
| 109 | 109 | return $this; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - public function addField($field){ |
|
| 112 | + public function addField($field) { |
|
| 113 | 113 | $this->visibleProperties[]=$field; |
| 114 | 114 | return $this; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - public function count(){ |
|
| 117 | + public function count() { |
|
| 118 | 118 | return \sizeof($this->properties); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function visiblePropertiesCount(){ |
|
| 121 | + public function visiblePropertiesCount() { |
|
| 122 | 122 | return \sizeof($this->visibleProperties); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - public function getProperty($index){ |
|
| 125 | + public function getProperty($index) { |
|
| 126 | 126 | return $this->properties[$index]; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - protected function showableProperty(\ReflectionProperty $rProperty){ |
|
| 130 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
| 129 | + protected function showableProperty(\ReflectionProperty $rProperty) { |
|
| 130 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public function setInstance($instance) { |
| 134 | - if(\is_string($instance)){ |
|
| 134 | + if (\is_string($instance)) { |
|
| 135 | 135 | $instance=new $instance(); |
| 136 | 136 | } |
| 137 | 137 | $this->instance=$instance; |
| 138 | 138 | $this->properties=[]; |
| 139 | 139 | $this->reflect=new \ReflectionClass($instance); |
| 140 | - if(\sizeof($this->visibleProperties)===0){ |
|
| 140 | + if (\sizeof($this->visibleProperties)===0) { |
|
| 141 | 141 | $this->properties=$this->getDefaultProperties(); |
| 142 | - }else{ |
|
| 143 | - foreach ($this->visibleProperties as $property){ |
|
| 142 | + } else { |
|
| 143 | + foreach ($this->visibleProperties as $property) { |
|
| 144 | 144 | $this->setInstanceProperty($property); |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | return $this; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - private function setInstanceProperty($property){ |
|
| 151 | - if(\is_callable($property)){ |
|
| 150 | + private function setInstanceProperty($property) { |
|
| 151 | + if (\is_callable($property)) { |
|
| 152 | 152 | $this->properties[]=$property; |
| 153 | - }elseif(\is_string($property)){ |
|
| 154 | - try{ |
|
| 153 | + }elseif (\is_string($property)) { |
|
| 154 | + try { |
|
| 155 | 155 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 156 | 156 | $rProperty=$this->reflect->getProperty($property); |
| 157 | 157 | $this->properties[]=$rProperty; |
| 158 | - }catch(\Exception $e){ |
|
| 158 | + }catch (\Exception $e) { |
|
| 159 | 159 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 160 | 160 | $this->properties[]=$property; |
| 161 | 161 | } |
| 162 | - }elseif(\is_int($property)){ |
|
| 162 | + }elseif (\is_int($property)) { |
|
| 163 | 163 | $props=$this->getDefaultProperties(); |
| 164 | - if(isset($props[$property])) |
|
| 164 | + if (isset($props[$property])) |
|
| 165 | 165 | $this->properties[]=$props[$property]; |
| 166 | 166 | else |
| 167 | 167 | $this->properties[]=$property; |
| 168 | - }else{ |
|
| 168 | + } else { |
|
| 169 | 169 | $this->properties[]=$property; |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - protected function getDefaultProperties(){ |
|
| 173 | + protected function getDefaultProperties() { |
|
| 174 | 174 | $result=[]; |
| 175 | 175 | $properties=$this->reflect->getProperties(); |
| 176 | - foreach ($properties as $property){ |
|
| 176 | + foreach ($properties as $property) { |
|
| 177 | 177 | $showable=$this->showableProperty($property); |
| 178 | - if($showable!==false){ |
|
| 178 | + if ($showable!==false) { |
|
| 179 | 179 | $result[]=$property; |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -187,12 +187,12 @@ discard block |
||
| 187 | 187 | return $this; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - public function setValueFunction($index,$callback){ |
|
| 190 | + public function setValueFunction($index, $callback) { |
|
| 191 | 191 | $this->values[$index]=$callback; |
| 192 | 192 | return $this; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - public function setIdentifierFunction($callback){ |
|
| 195 | + public function setIdentifierFunction($callback) { |
|
| 196 | 196 | $this->values["identifier"]=$callback; |
| 197 | 197 | return $this; |
| 198 | 198 | } |
@@ -205,41 +205,41 @@ discard block |
||
| 205 | 205 | return $this->properties; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - public function getCaption($index){ |
|
| 209 | - if(isset($this->captions[$index])){ |
|
| 208 | + public function getCaption($index) { |
|
| 209 | + if (isset($this->captions[$index])) { |
|
| 210 | 210 | return $this->captions[$index]; |
| 211 | 211 | } |
| 212 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 212 | + if ($this->properties[$index] instanceof \ReflectionProperty) |
|
| 213 | 213 | return $this->properties[$index]->getName(); |
| 214 | - elseif(\is_callable($this->properties[$index])) |
|
| 214 | + elseif (\is_callable($this->properties[$index])) |
|
| 215 | 215 | return ""; |
| 216 | 216 | else |
| 217 | 217 | return $this->properties[$index]; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - public function getCaptions(){ |
|
| 221 | - if(isset($this->captions)){ |
|
| 222 | - $captions= $this->captions; |
|
| 223 | - for($i=\sizeof($captions);$i<$this->count();$i++){ |
|
| 220 | + public function getCaptions() { |
|
| 221 | + if (isset($this->captions)) { |
|
| 222 | + $captions=$this->captions; |
|
| 223 | + for ($i=\sizeof($captions); $i<$this->count(); $i++) { |
|
| 224 | 224 | $captions[]=""; |
| 225 | 225 | } |
| 226 | - }else{ |
|
| 226 | + } else { |
|
| 227 | 227 | $captions=[]; |
| 228 | 228 | $index=0; |
| 229 | 229 | $count=$this->count(); |
| 230 | - while($index<$count){ |
|
| 230 | + while ($index<$count) { |
|
| 231 | 231 | $captions[]=$this->getCaption($index++); |
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | - if(isset($this->captionCallback) && \is_callable($this->captionCallback)){ |
|
| 234 | + if (isset($this->captionCallback) && \is_callable($this->captionCallback)) { |
|
| 235 | 235 | $callback=$this->captionCallback; |
| 236 | - $callback($captions,$this->instance); |
|
| 236 | + $callback($captions, $this->instance); |
|
| 237 | 237 | } |
| 238 | 238 | return $captions; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - public function setCaption($index,$caption){ |
|
| 242 | - if(isset($this->captions)===false) |
|
| 241 | + public function setCaption($index, $caption) { |
|
| 242 | + if (isset($this->captions)===false) |
|
| 243 | 243 | $this->captions=[]; |
| 244 | 244 | $this->captions[$index]=$caption; |
| 245 | 245 | return $this; |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * @param callable $callback function called after the field compilation |
| 258 | 258 | * @return \Ajax\semantic\widgets\datatable\InstanceViewer |
| 259 | 259 | */ |
| 260 | - public function afterCompile($index,$callback){ |
|
| 260 | + public function afterCompile($index, $callback) { |
|
| 261 | 261 | $this->afterCompile[$index]=$callback; |
| 262 | 262 | return $this; |
| 263 | 263 | } |
@@ -13,6 +13,9 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class HtmlIconGroups extends HtmlSemCollection { |
| 15 | 15 | |
| 16 | + /** |
|
| 17 | + * @param string $identifier |
|
| 18 | + */ |
|
| 16 | 19 | public function __construct($identifier, $icons=array(), $size="") { |
| 17 | 20 | parent::__construct($identifier, "i", "icons"); |
| 18 | 21 | $this->addItems($icons); |
@@ -14,8 +14,9 @@ |
||
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | public function asAvatar($caption=NULL) { |
| 17 | - if (isset($caption)) |
|
| 18 | - $this->wrap("", $caption); |
|
| 17 | + if (isset($caption)) { |
|
| 18 | + $this->wrap("", $caption); |
|
| 19 | + } |
|
| 19 | 20 | return $this->addToProperty("class", "avatar"); |
| 20 | 21 | } |
| 21 | 22 | |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | trait HtmlLinkTrait { |
| 6 | 6 | |
| 7 | - abstract public function setProperty($name,$value); |
|
| 7 | + abstract public function setProperty($name, $value); |
|
| 8 | 8 | abstract public function getProperty($name); |
| 9 | 9 | |
| 10 | 10 | public function setHref($value) { |
@@ -14,8 +14,8 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | public function setAttachment($toElement, $side=Side::BOTH) { |
| 16 | 16 | if (isset($toElement)) { |
| 17 | - $toElement->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 17 | + $toElement->addToPropertyCtrl("class", "attached", array("attached")); |
|
| 18 | 18 | } |
| 19 | - return $this->addToPropertyCtrl("class", $side . " attached", Side::getConstantValues("attached")); |
|
| 19 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | trait LabeledIconTrait { |
| 14 | 14 | |
| 15 | 15 | abstract public function addToProperty($name, $value, $separator=" "); |
| 16 | - abstract public function addContent($content,$before=false); |
|
| 16 | + abstract public function addContent($content, $before=false); |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Adds an icon before or after |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | * @param boolean $labeled |
| 23 | 23 | * @return \Ajax\semantic\html\elements\HtmlIcon |
| 24 | 24 | */ |
| 25 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
| 25 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
| 26 | 26 | $iconO=$icon; |
| 27 | - if(\is_string($icon)){ |
|
| 27 | + if (\is_string($icon)) { |
|
| 28 | 28 | $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
| 29 | 29 | } |
| 30 | - if($labeled!==false){ |
|
| 31 | - $direction=($before===true)?Direction::LEFT:Direction::RIGHT; |
|
| 30 | + if ($labeled!==false) { |
|
| 31 | + $direction=($before===true) ? Direction::LEFT : Direction::RIGHT; |
|
| 32 | 32 | $this->addToProperty("class", $direction." labeled icon"); |
| 33 | 33 | $this->tagName="div"; |
| 34 | 34 | } |
| 35 | - $this->addContent($iconO,$before); |
|
| 35 | + $this->addContent($iconO, $before); |
|
| 36 | 36 | return $iconO; |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function setContent($content) { |
| 21 | - $this->content=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
| 21 | + $this->content=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
| 22 | 22 | return $this; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function asIcon($icon, $title, $subHeader=NULL) { |
| 26 | - $header=new HtmlHeader("header-" . $this->identifier); |
|
| 26 | + $header=new HtmlHeader("header-".$this->identifier); |
|
| 27 | 27 | $header->asIcon($icon, $title, $subHeader); |
| 28 | - if ($this->_inverted === false) |
|
| 28 | + if ($this->_inverted===false) |
|
| 29 | 29 | $header->setInverted(); |
| 30 | 30 | return $this->setContent($header); |
| 31 | 31 | } |
@@ -42,13 +42,13 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function run(JsUtils $js) { |
| 44 | 44 | if ($this->_container instanceof HtmlSingleElement) |
| 45 | - $this->_bsComponent=$js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params); |
|
| 45 | + $this->_bsComponent=$js->semantic()->dimmer("#".$this->_container->getIdentifier(), $this->_params); |
|
| 46 | 46 | return parent::run($js); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function jsShow() { |
| 50 | 50 | if (isset($this->_container)) |
| 51 | - return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");'; |
|
| 51 | + return '$("#.'.$this->_container->getIdentifier().').dimmer("show");'; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function setBlurring() { |
@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | public function asIcon($icon, $title, $subHeader=NULL) { |
| 26 | 26 | $header=new HtmlHeader("header-" . $this->identifier); |
| 27 | 27 | $header->asIcon($icon, $title, $subHeader); |
| 28 | - if ($this->_inverted === false) |
|
| 29 | - $header->setInverted(); |
|
| 28 | + if ($this->_inverted === false) { |
|
| 29 | + $header->setInverted(); |
|
| 30 | + } |
|
| 30 | 31 | return $this->setContent($header); |
| 31 | 32 | } |
| 32 | 33 | |
@@ -41,14 +42,16 @@ discard block |
||
| 41 | 42 | } |
| 42 | 43 | |
| 43 | 44 | public function run(JsUtils $js) { |
| 44 | - if ($this->_container instanceof HtmlSingleElement) |
|
| 45 | - $this->_bsComponent=$js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params); |
|
| 45 | + if ($this->_container instanceof HtmlSingleElement) { |
|
| 46 | + $this->_bsComponent=$js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params); |
|
| 47 | + } |
|
| 46 | 48 | return parent::run($js); |
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | public function jsShow() { |
| 50 | - if (isset($this->_container)) |
|
| 51 | - return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");'; |
|
| 52 | + if (isset($this->_container)) { |
|
| 53 | + return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");'; |
|
| 54 | + } |
|
| 52 | 55 | } |
| 53 | 56 | |
| 54 | 57 | public function setBlurring() { |
@@ -8,12 +8,12 @@ discard block |
||
| 8 | 8 | use Ajax\semantic\html\base\constants\Direction; |
| 9 | 9 | |
| 10 | 10 | class HtmlSearch extends HtmlSemDoubleElement { |
| 11 | - private $_elements=array (); |
|
| 12 | - private $_searchFields=array ("title" ); |
|
| 11 | + private $_elements=array(); |
|
| 12 | + private $_searchFields=array("title"); |
|
| 13 | 13 | private $_local=false; |
| 14 | 14 | |
| 15 | 15 | public function __construct($identifier, $placeholder=NULL, $icon=NULL) { |
| 16 | - parent::__construct("search-" . $identifier, "div", "ui search", array ()); |
|
| 16 | + parent::__construct("search-".$identifier, "div", "ui search", array()); |
|
| 17 | 17 | $this->createField($placeholder, $icon); |
| 18 | 18 | $this->createResult(); |
| 19 | 19 | $this->_params["type"]="standard"; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | private function createResult() { |
| 35 | - $this->content["result"]=new HtmlSemDoubleElement("results-" . $this->identifier, "div", "results"); |
|
| 35 | + $this->content["result"]=new HtmlSemDoubleElement("results-".$this->identifier, "div", "results"); |
|
| 36 | 36 | return $this->content["result"]; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | public function setUrl($url) { |
| 52 | - $this->_params["apiSettings"]="%{url: %quote%" . $url . "%quote%}%"; |
|
| 52 | + $this->_params["apiSettings"]="%{url: %quote%".$url."%quote%}%"; |
|
| 53 | 53 | return $this; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -72,16 +72,16 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public function run(JsUtils $js) { |
| 75 | - $this->_params["onSelect"]='%function(result,response){$(%quote%#' . $this->identifier . '%quote%).trigger(%quote%onSelect%quote%, {%quote%result%quote%: result, %quote%response%quote%:response} );}%'; |
|
| 75 | + $this->_params["onSelect"]='%function(result,response){$(%quote%#'.$this->identifier.'%quote%).trigger(%quote%onSelect%quote%, {%quote%result%quote%: result, %quote%response%quote%:response} );}%'; |
|
| 76 | 76 | $searchFields=\json_encode($this->_searchFields); |
| 77 | 77 | $searchFields=str_ireplace("\"", "%quote%", $searchFields); |
| 78 | - $this->_params["searchFields"]="%" . $searchFields . "%"; |
|
| 79 | - if ($this->_local === true) { |
|
| 78 | + $this->_params["searchFields"]="%".$searchFields."%"; |
|
| 79 | + if ($this->_local===true) { |
|
| 80 | 80 | $this->_params["source"]="%content%"; |
| 81 | - $this->addEvent("beforeExecute", "var content=" . $this->resultsToJson() . ";"); |
|
| 81 | + $this->addEvent("beforeExecute", "var content=".$this->resultsToJson().";"); |
|
| 82 | 82 | } |
| 83 | - if (isset($this->_bsComponent) === false) { |
|
| 84 | - $this->_bsComponent=$js->semantic()->search("#" . $this->identifier, $this->_params); |
|
| 83 | + if (isset($this->_bsComponent)===false) { |
|
| 84 | + $this->_bsComponent=$js->semantic()->search("#".$this->identifier, $this->_params); |
|
| 85 | 85 | } |
| 86 | 86 | $this->addEventsOnRun($js); |
| 87 | 87 | return $this->_bsComponent; |
@@ -21,10 +21,12 @@ |
||
| 21 | 21 | |
| 22 | 22 | private function createField($placeholder=NULL, $icon=NULL) { |
| 23 | 23 | $field=new HtmlInput($this->identifier); |
| 24 | - if (isset($placeholder)) |
|
| 25 | - $field->setPlaceholder($placeholder); |
|
| 26 | - if (isset($icon)) |
|
| 27 | - $field->addIcon($icon, Direction::RIGHT); |
|
| 24 | + if (isset($placeholder)) { |
|
| 25 | + $field->setPlaceholder($placeholder); |
|
| 26 | + } |
|
| 27 | + if (isset($icon)) { |
|
| 28 | + $field->addIcon($icon, Direction::RIGHT); |
|
| 29 | + } |
|
| 28 | 30 | //TODO check getField |
| 29 | 31 | $field->getDataField()->setClass("prompt"); |
| 30 | 32 | $this->content["field"]=$field; |