@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | protected $attr; |
| 20 | 20 | |
| 21 | 21 | |
| 22 | - public function __construct($identifier,$tagName){ |
|
| 23 | - parent::__construct($identifier,$tagName); |
|
| 22 | + public function __construct($identifier, $tagName) { |
|
| 23 | + parent::__construct($identifier, $tagName); |
|
| 24 | 24 | $this->root=""; |
| 25 | 25 | $this->attr="data-ajax"; |
| 26 | 26 | } |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | * @param string $targetSelector the target of the get |
| 32 | 32 | * @return HtmlNavElement |
| 33 | 33 | */ |
| 34 | - public function autoGetOnClick($targetSelector){ |
|
| 35 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
| 34 | + public function autoGetOnClick($targetSelector) { |
|
| 35 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function contentAsString(){ |
|
| 38 | + public function contentAsString() { |
|
| 39 | 39 | return implode("", $this->content); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -43,15 +43,15 @@ discard block |
||
| 43 | 43 | * Generate the jquery script to set the elements to the HtmlNavElement |
| 44 | 44 | * @param JsUtils $jsUtils |
| 45 | 45 | */ |
| 46 | - public function jsSetContent(JsUtils $jsUtils){ |
|
| 47 | - $jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true); |
|
| 46 | + public function jsSetContent(JsUtils $jsUtils) { |
|
| 47 | + $jsUtils->html("#".$this->identifier, str_replace("\"", "'", $this->contentAsString()), true); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function getRoot() { |
| 51 | 51 | return $this->root; |
| 52 | 52 | } |
| 53 | 53 | public function setRoot($root) { |
| 54 | - $this->root = $root; |
|
| 54 | + $this->root=$root; |
|
| 55 | 55 | return $this; |
| 56 | 56 | } |
| 57 | 57 | public function getAttr() { |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | * @return HtmlNavElement |
| 65 | 65 | */ |
| 66 | 66 | public function setAttr($attr) { |
| 67 | - $this->attr = $attr; |
|
| 67 | + $this->attr=$attr; |
|
| 68 | 68 | return $this; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | public function __call($method, $args) { |
| 72 | - if(isset($this->$method) && is_callable($this->$method)) { |
|
| 72 | + if (isset($this->$method) && is_callable($this->$method)) { |
|
| 73 | 73 | return call_user_func_array( |
| 74 | 74 | $this->$method, |
| 75 | 75 | $args |
@@ -77,6 +77,6 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - abstract public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0); |
|
| 80 | + abstract public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0); |
|
| 81 | 81 | |
| 82 | 82 | } |
| 83 | 83 | \ No newline at end of file |
@@ -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,28 +116,28 @@ 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: |
| 132 | 132 | case PositionInTable::AFTERTABLE: |
| 133 | - if(isset($this->_compileParts)===false){ |
|
| 133 | + if (isset($this->_compileParts)===false) { |
|
| 134 | 134 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 135 | 135 | } |
| 136 | 136 | break; |
| 137 | 137 | case PositionInTable::HEADER: |
| 138 | 138 | case PositionInTable::FOOTER: |
| 139 | 139 | case PositionInTable::BODY: |
| 140 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
| 140 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
| 141 | 141 | break; |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -149,18 +149,18 @@ discard block |
||
| 149 | 149 | * @param callable $callback function called after the field compilation |
| 150 | 150 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 151 | 151 | */ |
| 152 | - public function afterCompile($index,$callback){ |
|
| 153 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
| 152 | + public function afterCompile($index, $callback) { |
|
| 153 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
| 154 | 154 | return $this; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - private function addToolbarRow($part,$table,$captions){ |
|
| 157 | + private function addToolbarRow($part, $table, $captions) { |
|
| 158 | 158 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 159 | 159 | $row->mergeCol(); |
| 160 | 160 | $row->setValues([$this->_toolbar]); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - public function getHtmlComponent(){ |
|
| 163 | + public function getHtmlComponent() { |
|
| 164 | 164 | return $this->content["table"]; |
| 165 | 165 | } |
| 166 | 166 | |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | return $this; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - public function paginate($items_per_page=10,$page=1){ |
|
| 177 | - $this->_pagination=new Pagination($items_per_page,4,$page); |
|
| 176 | + public function paginate($items_per_page=10, $page=1) { |
|
| 177 | + $this->_pagination=new Pagination($items_per_page, 4, $page); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | public function getHasCheckboxes() { |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | return $this; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - public function refresh($compileParts=["tbody"]){ |
|
| 189 | + public function refresh($compileParts=["tbody"]) { |
|
| 190 | 190 | $this->_compileParts=$compileParts; |
| 191 | 191 | return $this; |
| 192 | 192 | } |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | * @param callable $callback |
| 196 | 196 | * @return callable |
| 197 | 197 | */ |
| 198 | - private function getFieldButtonCallable($caption,$callback=null){ |
|
| 199 | - return $this->getCallable("getFieldButton",[$caption],$callback); |
|
| 198 | + private function getFieldButtonCallable($caption, $callback=null) { |
|
| 199 | + return $this->getCallable("getFieldButton", [$caption], $callback); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -205,16 +205,16 @@ discard block |
||
| 205 | 205 | * @param callable $callback |
| 206 | 206 | * @return callable |
| 207 | 207 | */ |
| 208 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
| 209 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
| 210 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
| 211 | - if(isset($callback)){ |
|
| 212 | - if(\is_callable($callback)){ |
|
| 213 | - $callback($object,$instance); |
|
| 208 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
| 209 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
| 210 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
| 211 | + if (isset($callback)) { |
|
| 212 | + if (\is_callable($callback)) { |
|
| 213 | + $callback($object, $instance); |
|
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | - if($object instanceof HtmlSemDoubleElement){ |
|
| 217 | - $object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier()); |
|
| 216 | + if ($object instanceof HtmlSemDoubleElement) { |
|
| 217 | + $object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier()); |
|
| 218 | 218 | } |
| 219 | 219 | return $object; |
| 220 | 220 | }; |
@@ -225,8 +225,8 @@ discard block |
||
| 225 | 225 | * @param string $caption |
| 226 | 226 | * @return HtmlButton |
| 227 | 227 | */ |
| 228 | - private function getFieldButton($caption){ |
|
| 229 | - return new HtmlButton("",$caption); |
|
| 228 | + private function getFieldButton($caption) { |
|
| 229 | + return new HtmlButton("", $caption); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -235,8 +235,8 @@ discard block |
||
| 235 | 235 | * @param callable $callback |
| 236 | 236 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 237 | 237 | */ |
| 238 | - public function addFieldButton($caption,$callback=null){ |
|
| 239 | - $this->addField($this->getCallable("getFieldButton",[$caption],$callback)); |
|
| 238 | + public function addFieldButton($caption, $callback=null) { |
|
| 239 | + $this->addField($this->getCallable("getFieldButton", [$caption], $callback)); |
|
| 240 | 240 | return $this; |
| 241 | 241 | } |
| 242 | 242 | |
@@ -247,8 +247,8 @@ discard block |
||
| 247 | 247 | * @param callable $callback |
| 248 | 248 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 249 | 249 | */ |
| 250 | - public function insertFieldButton($index,$caption,$callback=null){ |
|
| 251 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
| 250 | + public function insertFieldButton($index, $caption, $callback=null) { |
|
| 251 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
| 252 | 252 | return $this; |
| 253 | 253 | } |
| 254 | 254 | |
@@ -259,60 +259,60 @@ discard block |
||
| 259 | 259 | * @param callable $callback |
| 260 | 260 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 261 | 261 | */ |
| 262 | - public function insertInFieldButton($index,$caption,$callback=null){ |
|
| 263 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
| 262 | + public function insertInFieldButton($index, $caption, $callback=null) { |
|
| 263 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
| 264 | 264 | return $this; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - private function addDefaultButton($icon,$class=null,$callback=null){ |
|
| 268 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
|
| 267 | + private function addDefaultButton($icon, $class=null, $callback=null) { |
|
| 268 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class], $callback)); |
|
| 269 | 269 | return $this; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){ |
|
| 273 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
|
| 272 | + private function insertDefaultButtonIn($index, $icon, $class=null, $callback=null) { |
|
| 273 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class], $callback)); |
|
| 274 | 274 | return $this; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - private function getDefaultButton($icon,$class=null){ |
|
| 277 | + private function getDefaultButton($icon, $class=null) { |
|
| 278 | 278 | $bt=$this->getFieldButton(""); |
| 279 | 279 | $bt->asIcon($icon); |
| 280 | - if(isset($class)) |
|
| 280 | + if (isset($class)) |
|
| 281 | 281 | $bt->addToProperty("class", $class); |
| 282 | 282 | return $bt; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - public function addDeleteButton($callback=null){ |
|
| 286 | - return $this->addDefaultButton("remove","delete red basic",$callback); |
|
| 285 | + public function addDeleteButton($callback=null) { |
|
| 286 | + return $this->addDefaultButton("remove", "delete red basic", $callback); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - public function addEditButton($callback=null){ |
|
| 290 | - return $this->addDefaultButton("edit","edit basic",$callback); |
|
| 289 | + public function addEditButton($callback=null) { |
|
| 290 | + return $this->addDefaultButton("edit", "edit basic", $callback); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - public function addEditDeleteButtons($callbackEdit=null,$callbackDelete=null){ |
|
| 293 | + public function addEditDeleteButtons($callbackEdit=null, $callbackDelete=null) { |
|
| 294 | 294 | $this->addEditButton($callbackEdit); |
| 295 | 295 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
| 296 | - $this->insertDeleteButtonIn($index,$callbackDelete); |
|
| 296 | + $this->insertDeleteButtonIn($index, $callbackDelete); |
|
| 297 | 297 | return $this; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - public function insertDeleteButtonIn($index,$callback=null){ |
|
| 301 | - return $this->insertDefaultButtonIn($index,"remove","delete red basic",$callback); |
|
| 300 | + public function insertDeleteButtonIn($index, $callback=null) { |
|
| 301 | + return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $callback); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - public function insertEditButtonIn($index,$callback=null){ |
|
| 305 | - return $this->insertDefaultButtonIn($index,"edit","edit basic",$callback); |
|
| 304 | + public function insertEditButtonIn($index, $callback=null) { |
|
| 305 | + return $this->insertDefaultButtonIn($index, "edit", "edit basic", $callback); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
| 308 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
| 309 | 309 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - public function getSearchField(){ |
|
| 313 | - if(isset($this->_searchField)===false){ |
|
| 314 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
| 315 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
| 312 | + public function getSearchField() { |
|
| 313 | + if (isset($this->_searchField)===false) { |
|
| 314 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
| 315 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
| 316 | 316 | } |
| 317 | 317 | return $this->_searchField; |
| 318 | 318 | } |
@@ -21,43 +21,43 @@ discard block |
||
| 21 | 21 | * @property mixed _modelInstance |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | -trait FieldAsTrait{ |
|
| 24 | +trait FieldAsTrait { |
|
| 25 | 25 | |
| 26 | 26 | abstract protected function _getFieldIdentifier($prefix); |
| 27 | - abstract public function setValueFunction($index,$callback); |
|
| 27 | + abstract public function setValueFunction($index, $callback); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * @param HtmlFormField $element |
| 31 | 31 | * @param array $attributes |
| 32 | 32 | */ |
| 33 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
| 33 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
| 34 | 34 | $this->_addRules($element, $attributes); |
| 35 | - if(isset($attributes["callback"])){ |
|
| 35 | + if (isset($attributes["callback"])) { |
|
| 36 | 36 | $callback=$attributes["callback"]; |
| 37 | - if(\is_callable($callback)){ |
|
| 38 | - $callback($element,$this->_modelInstance,$index); |
|
| 37 | + if (\is_callable($callback)) { |
|
| 38 | + $callback($element, $this->_modelInstance, $index); |
|
| 39 | 39 | unset($attributes["callback"]); |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | $element->fromArray($attributes); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - private function _getLabelField($caption,$icon=NULL){ |
|
| 46 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
| 45 | + private function _getLabelField($caption, $icon=NULL) { |
|
| 46 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
| 47 | 47 | return $label; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - protected function _addRules($element,&$attributes){} |
|
| 50 | + protected function _addRules($element, &$attributes) {} |
|
| 51 | 51 | |
| 52 | - protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
|
| 53 | - $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
|
| 52 | + protected function _fieldAs($elementCallback, $index, $attributes=NULL, $prefix=null) { |
|
| 53 | + $this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback, $prefix){ |
|
| 54 | 54 | $name=$this->_instanceViewer->getCaption($index)."[]"; |
| 55 | - if(isset($attributes["name"])){ |
|
| 55 | + if (isset($attributes["name"])) { |
|
| 56 | 56 | $name=$attributes["name"]; |
| 57 | 57 | } |
| 58 | - $element=$elementCallback($this->_getFieldIdentifier($prefix),$name,$value,""); |
|
| 59 | - if(\is_array($attributes)) |
|
| 60 | - $this->_applyAttributes($element, $attributes,$index); |
|
| 58 | + $element=$elementCallback($this->_getFieldIdentifier($prefix), $name, $value, ""); |
|
| 59 | + if (\is_array($attributes)) |
|
| 60 | + $this->_applyAttributes($element, $attributes, $index); |
|
| 61 | 61 | $element->setDisabled(!$this->_edition); |
| 62 | 62 | return $element; |
| 63 | 63 | }); |
@@ -65,94 +65,94 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | |
| 68 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
| 69 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
| 70 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
| 68 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
| 69 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
| 70 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
| 71 | 71 | return $pb; |
| 72 | 72 | }); |
| 73 | 73 | return $this; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
| 77 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
| 78 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
| 76 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
| 77 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
| 78 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
| 79 | 79 | return $rating; |
| 80 | 80 | }); |
| 81 | 81 | return $this; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - public function fieldAsLabel($index,$icon=NULL){ |
|
| 85 | - $this->setValueFunction($index,function($caption) use($icon){ |
|
| 86 | - $lbl=$this->_getLabelField($caption,$icon); |
|
| 84 | + public function fieldAsLabel($index, $icon=NULL) { |
|
| 85 | + $this->setValueFunction($index, function($caption) use($icon){ |
|
| 86 | + $lbl=$this->_getLabelField($caption, $icon); |
|
| 87 | 87 | return $lbl; |
| 88 | 88 | }); |
| 89 | 89 | return $this; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
| 93 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
| 94 | - $header=new HtmlHeader($id,$niveau,$value); |
|
| 95 | - if(isset($icon)) |
|
| 92 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
| 93 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
| 94 | + $header=new HtmlHeader($id, $niveau, $value); |
|
| 95 | + if (isset($icon)) |
|
| 96 | 96 | $header->asIcon($icon, $value); |
| 97 | 97 | return $header; |
| 98 | - }, $index,$attributes,"header"); |
|
| 98 | + }, $index, $attributes, "header"); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
| 102 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
| 103 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
| 104 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
| 102 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
| 103 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
| 104 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
| 105 | 105 | return $image; |
| 106 | 106 | }); |
| 107 | 107 | return $this; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
| 111 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 112 | - $img=new HtmlImage($id,$value); |
|
| 110 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
| 111 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 112 | + $img=new HtmlImage($id, $value); |
|
| 113 | 113 | $img->asAvatar(); |
| 114 | 114 | return $img; |
| 115 | - }, $index,$attributes,"avatar"); |
|
| 115 | + }, $index, $attributes, "avatar"); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
| 119 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 120 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
| 118 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
| 119 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 120 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
| 121 | 121 | return $input; |
| 122 | - }, $index,$attributes,"radio"); |
|
| 122 | + }, $index, $attributes, "radio"); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - public function fieldAsInput($index,$attributes=NULL){ |
|
| 126 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 127 | - $input= new HtmlFormInput($id,"","text",$value); |
|
| 125 | + public function fieldAsInput($index, $attributes=NULL) { |
|
| 126 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 127 | + $input=new HtmlFormInput($id, "", "text", $value); |
|
| 128 | 128 | $input->setName($name); |
| 129 | 129 | return $input; |
| 130 | - }, $index,$attributes,"input"); |
|
| 130 | + }, $index, $attributes, "input"); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
| 134 | - if(!\is_array($attributes)){ |
|
| 133 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
| 134 | + if (!\is_array($attributes)) { |
|
| 135 | 135 | $attributes=[]; |
| 136 | 136 | } |
| 137 | 137 | $attributes["imputType"]="hidden"; |
| 138 | - return $this->fieldAsInput($index,$attributes); |
|
| 138 | + return $this->fieldAsInput($index, $attributes); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
| 142 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 143 | - $input=new HtmlFormCheckbox($id,NULL,$this->_instanceViewer->getIdentifier()); |
|
| 141 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
| 142 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 143 | + $input=new HtmlFormCheckbox($id, NULL, $this->_instanceViewer->getIdentifier()); |
|
| 144 | 144 | $input->setChecked(JString::isBooleanTrue($value)); |
| 145 | 145 | $input->getField()->setProperty("name", $name); |
| 146 | 146 | return $input; |
| 147 | - }, $index,$attributes,"ck"); |
|
| 147 | + }, $index, $attributes, "ck"); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
| 151 | - return $this->_fieldAs(function($id,$name,$value) use($elements,$multiple){ |
|
| 150 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
| 151 | + return $this->_fieldAs(function($id, $name, $value) use($elements, $multiple){ |
|
| 152 | 152 | //$dd=new HtmlDropdown($id,$value,$elements); |
| 153 | - $dd=new HtmlFormDropdown($id,$elements,NULL,$value); |
|
| 154 | - $dd->asSelect($name,$multiple); |
|
| 153 | + $dd=new HtmlFormDropdown($id, $elements, NULL, $value); |
|
| 154 | + $dd->asSelect($name, $multiple); |
|
| 155 | 155 | return $dd; |
| 156 | - }, $index,$attributes,"dd"); |
|
| 156 | + }, $index, $attributes, "dd"); |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | \ No newline at end of file |
@@ -56,8 +56,9 @@ discard block |
||
| 56 | 56 | $name=$attributes["name"]; |
| 57 | 57 | } |
| 58 | 58 | $element=$elementCallback($this->_getFieldIdentifier($prefix),$name,$value,""); |
| 59 | - if(\is_array($attributes)) |
|
| 60 | - $this->_applyAttributes($element, $attributes,$index); |
|
| 59 | + if(\is_array($attributes)) { |
|
| 60 | + $this->_applyAttributes($element, $attributes,$index); |
|
| 61 | + } |
|
| 61 | 62 | $element->setDisabled(!$this->_edition); |
| 62 | 63 | return $element; |
| 63 | 64 | }); |
@@ -92,8 +93,9 @@ discard block |
||
| 92 | 93 | public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
| 93 | 94 | return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
| 94 | 95 | $header=new HtmlHeader($id,$niveau,$value); |
| 95 | - if(isset($icon)) |
|
| 96 | - $header->asIcon($icon, $value); |
|
| 96 | + if(isset($icon)) { |
|
| 97 | + $header->asIcon($icon, $value); |
|
| 98 | + } |
|
| 97 | 99 | return $header; |
| 98 | 100 | }, $index,$attributes,"header"); |
| 99 | 101 | } |
@@ -101,7 +103,9 @@ discard block |
||
| 101 | 103 | |
| 102 | 104 | public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
| 103 | 105 | $this->setValueFunction($index,function($img) use($size,$circular){ |
| 104 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
| 106 | + $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) { |
|
| 107 | + $image->setCircular(); |
|
| 108 | + } |
|
| 105 | 109 | return $image; |
| 106 | 110 | }); |
| 107 | 111 | return $this; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | abstract public function addToProperty($name, $value, $separator=" "); |
| 18 | 18 | abstract public function addLabel($caption, $style="label-default", $leftSeparator=" "); |
| 19 | - abstract public function addContent($content,$before=false); |
|
| 19 | + abstract public function addContent($content, $before=false); |
|
| 20 | 20 | abstract public function getField(); |
| 21 | 21 | abstract public function getDataField(); |
| 22 | 22 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function addLoading() { |
| 28 | - if ($this->_hasIcon === false) { |
|
| 28 | + if ($this->_hasIcon===false) { |
|
| 29 | 29 | throw new \Exception("Input must have an icon for showing a loader, use addIcon before"); |
| 30 | 30 | } |
| 31 | 31 | return $this->addToProperty("class", State::LOADING); |
@@ -33,56 +33,56 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function labeled($label, $direction=Direction::LEFT, $icon=NULL) { |
| 35 | 35 | $field=$this->getField(); |
| 36 | - $labelO=$field->addLabel($label,$direction===Direction::LEFT,$icon); |
|
| 37 | - $field->addToProperty("class", $direction . " labeled"); |
|
| 36 | + $labelO=$field->addLabel($label, $direction===Direction::LEFT, $icon); |
|
| 37 | + $field->addToProperty("class", $direction." labeled"); |
|
| 38 | 38 | return $labelO; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function labeledToCorner($icon, $direction=Direction::LEFT) { |
| 42 | - return $this->labeled("", $direction . " corner", $icon)->toCorner($direction); |
|
| 42 | + return $this->labeled("", $direction." corner", $icon)->toCorner($direction); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function addAction($action, $direction=Direction::RIGHT, $icon=NULL, $labeled=false) { |
| 46 | 46 | $field=$this->getField(); |
| 47 | 47 | $actionO=$action; |
| 48 | - if (\is_object($action) === false) { |
|
| 49 | - $actionO=new HtmlButton("action-" . $this->identifier, $action); |
|
| 48 | + if (\is_object($action)===false) { |
|
| 49 | + $actionO=new HtmlButton("action-".$this->identifier, $action); |
|
| 50 | 50 | if (isset($icon)) |
| 51 | 51 | $actionO->addIcon($icon, true, $labeled); |
| 52 | 52 | } |
| 53 | - $field->addToProperty("class", $direction . " action"); |
|
| 54 | - $field->addContent($actionO, \strstr($direction, Direction::LEFT) !== false); |
|
| 53 | + $field->addToProperty("class", $direction." action"); |
|
| 54 | + $field->addContent($actionO, \strstr($direction, Direction::LEFT)!==false); |
|
| 55 | 55 | return $actionO; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function addDropdown($label="", $items=array(),$direction=Direction::RIGHT){ |
|
| 59 | - $labelO=new HtmlDropdown("dd-".$this->identifier,$label,$items); |
|
| 60 | - $labelO->asSelect("select-".$this->identifier,false,true); |
|
| 61 | - return $this->labeled($labelO,$direction); |
|
| 58 | + public function addDropdown($label="", $items=array(), $direction=Direction::RIGHT) { |
|
| 59 | + $labelO=new HtmlDropdown("dd-".$this->identifier, $label, $items); |
|
| 60 | + $labelO->asSelect("select-".$this->identifier, false, true); |
|
| 61 | + return $this->labeled($labelO, $direction); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public function setTransparent() { |
| 65 | 65 | return $this->getField()->addToProperty("class", "transparent"); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function setReadonly(){ |
|
| 68 | + public function setReadonly() { |
|
| 69 | 69 | $this->getDataField()->setProperty("readonly", ""); |
| 70 | 70 | return $this; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function setName($name){ |
|
| 74 | - $this->getDataField()->setProperty("name",$name); |
|
| 73 | + public function setName($name) { |
|
| 74 | + $this->getDataField()->setProperty("name", $name); |
|
| 75 | 75 | return $this; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public function setFluid(){ |
|
| 79 | - $this->getField()->addToProperty("class","fluid"); |
|
| 78 | + public function setFluid() { |
|
| 79 | + $this->getField()->addToProperty("class", "fluid"); |
|
| 80 | 80 | return $this; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | public function setDisabled($disable=true) { |
| 84 | 84 | $field=$this->getField(); |
| 85 | - if($disable) |
|
| 85 | + if ($disable) |
|
| 86 | 86 | $field->addToProperty("class", "disabled"); |
| 87 | 87 | return $this; |
| 88 | 88 | } |
@@ -47,8 +47,9 @@ discard block |
||
| 47 | 47 | $actionO=$action; |
| 48 | 48 | if (\is_object($action) === false) { |
| 49 | 49 | $actionO=new HtmlButton("action-" . $this->identifier, $action); |
| 50 | - if (isset($icon)) |
|
| 51 | - $actionO->addIcon($icon, true, $labeled); |
|
| 50 | + if (isset($icon)) { |
|
| 51 | + $actionO->addIcon($icon, true, $labeled); |
|
| 52 | + } |
|
| 52 | 53 | } |
| 53 | 54 | $field->addToProperty("class", $direction . " action"); |
| 54 | 55 | $field->addContent($actionO, \strstr($direction, Direction::LEFT) !== false); |
@@ -82,8 +83,9 @@ discard block |
||
| 82 | 83 | |
| 83 | 84 | public function setDisabled($disable=true) { |
| 84 | 85 | $field=$this->getField(); |
| 85 | - if($disable) |
|
| 86 | - $field->addToProperty("class", "disabled"); |
|
| 86 | + if($disable) { |
|
| 87 | + $field->addToProperty("class", "disabled"); |
|
| 88 | + } |
|
| 87 | 89 | return $this; |
| 88 | 90 | } |
| 89 | 91 | } |
| 90 | 92 | \ No newline at end of file |
@@ -38,18 +38,18 @@ discard block |
||
| 38 | 38 | return $this->getHtmlCk()->attachEvents($events); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function getField(){ |
|
| 41 | + public function getField() { |
|
| 42 | 42 | //TODO check getField() ? |
| 43 | 43 | return $this->content["field"]; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public function getHtmlCk(){ |
|
| 46 | + public function getHtmlCk() { |
|
| 47 | 47 | return $this->content["field"]; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function getDataField(){ |
|
| 51 | - $field= $this->getField(); |
|
| 52 | - if($field instanceof AbstractCheckbox) |
|
| 50 | + public function getDataField() { |
|
| 51 | + $field=$this->getField(); |
|
| 52 | + if ($field instanceof AbstractCheckbox) |
|
| 53 | 53 | $field=$field->getField(); |
| 54 | 54 | return $field; |
| 55 | 55 | } |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | * @param boolean $value |
| 60 | 60 | * @return HtmlFormField |
| 61 | 61 | */ |
| 62 | - public function setChecked($value=true){ |
|
| 63 | - if($value===true){ |
|
| 62 | + public function setChecked($value=true) { |
|
| 63 | + if ($value===true) { |
|
| 64 | 64 | $this->getDataField()->setProperty("checked", "checked"); |
| 65 | - }else{ |
|
| 65 | + } else { |
|
| 66 | 66 | $this->getDataField()->removeProperty("checked"); |
| 67 | 67 | } |
| 68 | 68 | return $this; |
@@ -49,8 +49,9 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | public function getDataField(){ |
| 51 | 51 | $field= $this->getField(); |
| 52 | - if($field instanceof AbstractCheckbox) |
|
| 53 | - $field=$field->getField(); |
|
| 52 | + if($field instanceof AbstractCheckbox) { |
|
| 53 | + $field=$field->getField(); |
|
| 54 | + } |
|
| 54 | 55 | return $field; |
| 55 | 56 | } |
| 56 | 57 | |
@@ -62,7 +63,7 @@ discard block |
||
| 62 | 63 | public function setChecked($value=true){ |
| 63 | 64 | if($value===true){ |
| 64 | 65 | $this->getDataField()->setProperty("checked", "checked"); |
| 65 | - }else{ |
|
| 66 | + } else{ |
|
| 66 | 67 | $this->getDataField()->removeProperty("checked"); |
| 67 | 68 | } |
| 68 | 69 | return $this; |
@@ -14,34 +14,34 @@ discard block |
||
| 14 | 14 | use FieldTrait; |
| 15 | 15 | protected $_container; |
| 16 | 16 | protected $_validation; |
| 17 | - public function __construct($identifier, $field,$label=NULL) { |
|
| 18 | - parent::__construct($identifier, "div","field"); |
|
| 17 | + public function __construct($identifier, $field, $label=NULL) { |
|
| 18 | + parent::__construct($identifier, "div", "field"); |
|
| 19 | 19 | $this->content=array(); |
| 20 | - $this->_states=[State::ERROR,State::DISABLED]; |
|
| 21 | - if(isset($label)) |
|
| 20 | + $this->_states=[State::ERROR, State::DISABLED]; |
|
| 21 | + if (isset($label)) |
|
| 22 | 22 | $this->setLabel($label); |
| 23 | 23 | $this->setField($field); |
| 24 | 24 | $this->_validation=NULL; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function addPointingLabel($label,$pointing=Direction::NONE){ |
|
| 28 | - $labelO=new HtmlLabel("",$label); |
|
| 27 | + public function addPointingLabel($label, $pointing=Direction::NONE) { |
|
| 28 | + $labelO=new HtmlLabel("", $label); |
|
| 29 | 29 | $labelO->setPointing($pointing); |
| 30 | - $this->addContent($labelO,$pointing==="below" || $pointing==="right"); |
|
| 30 | + $this->addContent($labelO, $pointing==="below" || $pointing==="right"); |
|
| 31 | 31 | return $labelO; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function setLabel($label){ |
|
| 34 | + public function setLabel($label) { |
|
| 35 | 35 | $labelO=$label; |
| 36 | - if(\is_string($label)){ |
|
| 37 | - $labelO=new HtmlSemDoubleElement("","label",""); |
|
| 36 | + if (\is_string($label)) { |
|
| 37 | + $labelO=new HtmlSemDoubleElement("", "label", ""); |
|
| 38 | 38 | $labelO->setContent($label); |
| 39 | - $labelO->setProperty("for", \str_replace("field-", "",$this->identifier)); |
|
| 39 | + $labelO->setProperty("for", \str_replace("field-", "", $this->identifier)); |
|
| 40 | 40 | } |
| 41 | 41 | $this->content["label"]=$labelO; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function setField($field){ |
|
| 44 | + public function setField($field) { |
|
| 45 | 45 | $this->content["field"]=$field; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | * Returns the label or null |
| 50 | 50 | * @return mixed |
| 51 | 51 | */ |
| 52 | - public function getLabel(){ |
|
| 53 | - if(\array_key_exists("label", $this->content)) |
|
| 52 | + public function getLabel() { |
|
| 53 | + if (\array_key_exists("label", $this->content)) |
|
| 54 | 54 | return $this->content["label"]; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * Return the field |
| 59 | 59 | * @return mixed |
| 60 | 60 | */ |
| 61 | - public function getField(){ |
|
| 61 | + public function getField() { |
|
| 62 | 62 | return $this->content["field"]; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | * Return the field with data |
| 67 | 67 | * @return mixed |
| 68 | 68 | */ |
| 69 | - public function getDataField(){ |
|
| 69 | + public function getDataField() { |
|
| 70 | 70 | return $this->content["field"]; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * puts the label before or behind |
| 75 | 75 | */ |
| 76 | - public function swapLabel(){ |
|
| 76 | + public function swapLabel() { |
|
| 77 | 77 | $label=$this->getLabel(); |
| 78 | 78 | unset($this->content["label"]); |
| 79 | 79 | $this->content["label"]=$label; |
@@ -84,31 +84,31 @@ discard block |
||
| 84 | 84 | * @param int $width |
| 85 | 85 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
| 86 | 86 | */ |
| 87 | - public function setWidth($width){ |
|
| 88 | - if(\is_int($width)){ |
|
| 87 | + public function setWidth($width) { |
|
| 88 | + if (\is_int($width)) { |
|
| 89 | 89 | $width=Wide::getConstants()["W".$width]; |
| 90 | 90 | } |
| 91 | 91 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
| 92 | - if(isset($this->_container)){ |
|
| 92 | + if (isset($this->_container)) { |
|
| 93 | 93 | $this->_container->setEqualWidth(false); |
| 94 | 94 | } |
| 95 | - return $this->addToPropertyCtrl("class", "wide",array("wide")); |
|
| 95 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * Field displays an error state |
| 100 | 100 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
| 101 | 101 | */ |
| 102 | - public function setError(){ |
|
| 102 | + public function setError() { |
|
| 103 | 103 | return $this->addToProperty("class", "error"); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - public function setInline(){ |
|
| 106 | + public function setInline() { |
|
| 107 | 107 | return $this->addToProperty("class", "inline"); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public function jsState($state){ |
|
| 111 | - return $this->jsDoJquery("addClass",$state); |
|
| 110 | + public function jsState($state) { |
|
| 111 | + return $this->jsDoJquery("addClass", $state); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | public function setContainer($_container) { |
@@ -116,34 +116,34 @@ discard block |
||
| 116 | 116 | return $this; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - public function setReadonly(){ |
|
| 119 | + public function setReadonly() { |
|
| 120 | 120 | $this->getField()->setProperty("readonly", ""); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
| 123 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
| 124 | 124 | $field=$this->getDataField(); |
| 125 | - if(isset($field)){ |
|
| 126 | - if(!isset($this->_validation)){ |
|
| 125 | + if (isset($field)) { |
|
| 126 | + if (!isset($this->_validation)) { |
|
| 127 | 127 | $this->_validation=new FieldValidation($field->getIdentifier()); |
| 128 | 128 | } |
| 129 | - if($type==="empty"){ |
|
| 130 | - $this->addToProperty("class","required"); |
|
| 129 | + if ($type==="empty") { |
|
| 130 | + $this->addToProperty("class", "required"); |
|
| 131 | 131 | } |
| 132 | - $this->_validation->addRule($type,$prompt,$value); |
|
| 132 | + $this->_validation->addRule($type, $prompt, $value); |
|
| 133 | 133 | } |
| 134 | 134 | return $this; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - public function addRules(array $rules){ |
|
| 138 | - foreach ($rules as $rule){ |
|
| 137 | + public function addRules(array $rules) { |
|
| 138 | + foreach ($rules as $rule) { |
|
| 139 | 139 | $this->addRule($rule); |
| 140 | 140 | } |
| 141 | 141 | return $this; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - public function addIcon($icon,$direction=Direction::LEFT){ |
|
| 144 | + public function addIcon($icon, $direction=Direction::LEFT) { |
|
| 145 | 145 | $field=$this->getField(); |
| 146 | - return $field->addIcon($icon,$direction); |
|
| 146 | + return $field->addIcon($icon, $direction); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | public function getValidation() { |
@@ -18,8 +18,9 @@ discard block |
||
| 18 | 18 | parent::__construct($identifier, "div","field"); |
| 19 | 19 | $this->content=array(); |
| 20 | 20 | $this->_states=[State::ERROR,State::DISABLED]; |
| 21 | - if(isset($label)) |
|
| 22 | - $this->setLabel($label); |
|
| 21 | + if(isset($label)) { |
|
| 22 | + $this->setLabel($label); |
|
| 23 | + } |
|
| 23 | 24 | $this->setField($field); |
| 24 | 25 | $this->_validation=NULL; |
| 25 | 26 | } |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | * @return mixed |
| 51 | 52 | */ |
| 52 | 53 | public function getLabel(){ |
| 53 | - if(\array_key_exists("label", $this->content)) |
|
| 54 | - return $this->content["label"]; |
|
| 54 | + if(\array_key_exists("label", $this->content)) { |
|
| 55 | + return $this->content["label"]; |
|
| 56 | + } |
|
| 55 | 57 | } |
| 56 | 58 | |
| 57 | 59 | /** |
@@ -7,25 +7,25 @@ |
||
| 7 | 7 | |
| 8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
| 9 | 9 | |
| 10 | - public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false,$associative=true) { |
|
| 11 | - parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label); |
|
| 10 | + public function __construct($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false, $associative=true) { |
|
| 11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public function setItems($items){ |
|
| 14 | + public function setItems($items) { |
|
| 15 | 15 | return $this->getField()->setItems($items); |
| 16 | 16 | } |
| 17 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
| 18 | - return $this->getField()->addItem($item,$value,$image); |
|
| 17 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
| 18 | + return $this->getField()->addItem($item, $value, $image); |
|
| 19 | 19 | } |
| 20 | - public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$associative=true){ |
|
| 21 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative); |
|
| 20 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $associative=true) { |
|
| 21 | + return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function getDataField(){ |
|
| 24 | + public function getDataField() { |
|
| 25 | 25 | return $this->getField()->getInput(); |
| 26 | 26 | } |
| 27 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
| 28 | - $this->getField()->asSelect($name,$multiple,$selection); |
|
| 27 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
| 28 | + $this->getField()->asSelect($name, $multiple, $selection); |
|
| 29 | 29 | return $this; |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | * @property string $identifier |
| 13 | 13 | */ |
| 14 | 14 | trait BaseTrait { |
| 15 | - protected $_variations=[ ]; |
|
| 16 | - protected $_states=[ ]; |
|
| 15 | + protected $_variations=[]; |
|
| 16 | + protected $_states=[]; |
|
| 17 | 17 | protected $_baseClass; |
| 18 | 18 | |
| 19 | 19 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | abstract public function setProperty($name, $value); |
| 28 | 28 | |
| 29 | - abstract public function addContent($content,$before=false); |
|
| 29 | + abstract public function addContent($content, $before=false); |
|
| 30 | 30 | |
| 31 | 31 | abstract public function onCreate($jsCode); |
| 32 | 32 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $this->setProperty("class", $this->_baseClass); |
| 48 | 48 | if (\is_string($variations)) |
| 49 | 49 | $variations=\explode(" ", $variations); |
| 50 | - foreach ( $variations as $variation ) { |
|
| 50 | + foreach ($variations as $variation) { |
|
| 51 | 51 | $this->addVariation($variation); |
| 52 | 52 | } |
| 53 | 53 | return $this; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public function addVariations($variations=array()) { |
| 62 | 62 | if (\is_string($variations)) |
| 63 | 63 | $variations=\explode(" ", $variations); |
| 64 | - foreach ( $variations as $variation ) { |
|
| 64 | + foreach ($variations as $variation) { |
|
| 65 | 65 | $this->addVariation($variation); |
| 66 | 66 | } |
| 67 | 67 | return $this; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | public function addStates($states=array()) { |
| 71 | 71 | if (\is_string($states)) |
| 72 | 72 | $states=\explode(" ", $states); |
| 73 | - foreach ( $states as $state ) { |
|
| 73 | + foreach ($states as $state) { |
|
| 74 | 74 | $this->addState($state); |
| 75 | 75 | } |
| 76 | 76 | return $this; |
@@ -80,17 +80,17 @@ discard block |
||
| 80 | 80 | $this->setProperty("class", $this->_baseClass); |
| 81 | 81 | if (\is_string($states)) |
| 82 | 82 | $states=\explode(" ", $states); |
| 83 | - foreach ( $states as $state ) { |
|
| 83 | + foreach ($states as $state) { |
|
| 84 | 84 | $this->addState($state); |
| 85 | 85 | } |
| 86 | 86 | return $this; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function addIcon($icon, $before=true) { |
| 90 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
| 90 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function addSticky($context="body"){ |
|
| 93 | + public function addSticky($context="body") { |
|
| 94 | 94 | $this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});"); |
| 95 | 95 | return $this; |
| 96 | 96 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
| 112 | 112 | */ |
| 113 | 113 | public function setDisabled($disable=true) { |
| 114 | - if($disable) |
|
| 114 | + if ($disable) |
|
| 115 | 115 | $this->addToProperty("class", "disabled"); |
| 116 | 116 | return $this; |
| 117 | 117 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
| 139 | 139 | */ |
| 140 | - public function asHeader(){ |
|
| 140 | + public function asHeader() { |
|
| 141 | 141 | return $this->addToProperty("class", "header"); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | * show it is currently the active user selection |
| 146 | 146 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
| 147 | 147 | */ |
| 148 | - public function setActive($value=true){ |
|
| 149 | - if($value) |
|
| 148 | + public function setActive($value=true) { |
|
| 149 | + if ($value) |
|
| 150 | 150 | $this->addToProperty("class", "active"); |
| 151 | 151 | return $this; |
| 152 | 152 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public function setFloated($direction="right") { |
| 166 | - return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
| 166 | + return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | public function floatRight() { |
@@ -45,8 +45,9 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public function setVariations($variations) { |
| 47 | 47 | $this->setProperty("class", $this->_baseClass); |
| 48 | - if (\is_string($variations)) |
|
| 49 | - $variations=\explode(" ", $variations); |
|
| 48 | + if (\is_string($variations)) { |
|
| 49 | + $variations=\explode(" ", $variations); |
|
| 50 | + } |
|
| 50 | 51 | foreach ( $variations as $variation ) { |
| 51 | 52 | $this->addVariation($variation); |
| 52 | 53 | } |
@@ -59,8 +60,9 @@ discard block |
||
| 59 | 60 | } |
| 60 | 61 | |
| 61 | 62 | public function addVariations($variations=array()) { |
| 62 | - if (\is_string($variations)) |
|
| 63 | - $variations=\explode(" ", $variations); |
|
| 63 | + if (\is_string($variations)) { |
|
| 64 | + $variations=\explode(" ", $variations); |
|
| 65 | + } |
|
| 64 | 66 | foreach ( $variations as $variation ) { |
| 65 | 67 | $this->addVariation($variation); |
| 66 | 68 | } |
@@ -68,8 +70,9 @@ discard block |
||
| 68 | 70 | } |
| 69 | 71 | |
| 70 | 72 | public function addStates($states=array()) { |
| 71 | - if (\is_string($states)) |
|
| 72 | - $states=\explode(" ", $states); |
|
| 73 | + if (\is_string($states)) { |
|
| 74 | + $states=\explode(" ", $states); |
|
| 75 | + } |
|
| 73 | 76 | foreach ( $states as $state ) { |
| 74 | 77 | $this->addState($state); |
| 75 | 78 | } |
@@ -78,8 +81,9 @@ discard block |
||
| 78 | 81 | |
| 79 | 82 | public function setStates($states) { |
| 80 | 83 | $this->setProperty("class", $this->_baseClass); |
| 81 | - if (\is_string($states)) |
|
| 82 | - $states=\explode(" ", $states); |
|
| 84 | + if (\is_string($states)) { |
|
| 85 | + $states=\explode(" ", $states); |
|
| 86 | + } |
|
| 83 | 87 | foreach ( $states as $state ) { |
| 84 | 88 | $this->addState($state); |
| 85 | 89 | } |
@@ -111,8 +115,9 @@ discard block |
||
| 111 | 115 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
| 112 | 116 | */ |
| 113 | 117 | public function setDisabled($disable=true) { |
| 114 | - if($disable) |
|
| 115 | - $this->addToProperty("class", "disabled"); |
|
| 118 | + if($disable) { |
|
| 119 | + $this->addToProperty("class", "disabled"); |
|
| 120 | + } |
|
| 116 | 121 | return $this; |
| 117 | 122 | } |
| 118 | 123 | |
@@ -146,8 +151,9 @@ discard block |
||
| 146 | 151 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
| 147 | 152 | */ |
| 148 | 153 | public function setActive($value=true){ |
| 149 | - if($value) |
|
| 150 | - $this->addToProperty("class", "active"); |
|
| 154 | + if($value) { |
|
| 155 | + $this->addToProperty("class", "active"); |
|
| 156 | + } |
|
| 151 | 157 | return $this; |
| 152 | 158 | } |
| 153 | 159 | |
@@ -37,28 +37,28 @@ discard block |
||
| 37 | 37 | protected $_edition; |
| 38 | 38 | |
| 39 | 39 | |
| 40 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 40 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 41 | 41 | parent::__construct($identifier); |
| 42 | 42 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
| 43 | 43 | $this->setModel($model); |
| 44 | - if(isset($modelInstance)); |
|
| 44 | + if (isset($modelInstance)); |
|
| 45 | 45 | $this->show($modelInstance); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - protected function _init($instanceViewer,$contentKey,$content,$edition){ |
|
| 48 | + protected function _init($instanceViewer, $contentKey, $content, $edition) { |
|
| 49 | 49 | $this->_instanceViewer=$instanceViewer; |
| 50 | 50 | $this->content=[$contentKey=>$content]; |
| 51 | 51 | $this->_toolbarPosition=PositionInTable::BEFORETABLE; |
| 52 | 52 | $this->_edition=$edition; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - protected function _getFieldIdentifier($prefix){ |
|
| 55 | + protected function _getFieldIdentifier($prefix) { |
|
| 56 | 56 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
| 59 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
| 60 | 60 | |
| 61 | - public function show($modelInstance){ |
|
| 61 | + public function show($modelInstance) { |
|
| 62 | 62 | $this->_modelInstance=$modelInstance; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -82,42 +82,42 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | abstract public function getHtmlComponent(); |
| 84 | 84 | |
| 85 | - public function setColor($color){ |
|
| 85 | + public function setColor($color) { |
|
| 86 | 86 | return $this->getHtmlComponent()->setColor($color); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | |
| 90 | - public function setCaptions($captions){ |
|
| 90 | + public function setCaptions($captions) { |
|
| 91 | 91 | $this->_instanceViewer->setCaptions($captions); |
| 92 | 92 | return $this; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function setFields($fields){ |
|
| 95 | + public function setFields($fields) { |
|
| 96 | 96 | $this->_instanceViewer->setVisibleProperties($fields); |
| 97 | 97 | return $this; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function addField($field){ |
|
| 100 | + public function addField($field) { |
|
| 101 | 101 | $this->_instanceViewer->addField($field); |
| 102 | 102 | return $this; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - public function insertField($index,$field){ |
|
| 105 | + public function insertField($index, $field) { |
|
| 106 | 106 | $this->_instanceViewer->insertField($index, $field); |
| 107 | 107 | return $this; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public function insertInField($index,$field){ |
|
| 110 | + public function insertInField($index, $field) { |
|
| 111 | 111 | $this->_instanceViewer->insertInField($index, $field); |
| 112 | 112 | return $this; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - public function setValueFunction($index,$callback){ |
|
| 115 | + public function setValueFunction($index, $callback) { |
|
| 116 | 116 | $this->_instanceViewer->setValueFunction($index, $callback); |
| 117 | 117 | return $this; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - public function setIdentifierFunction($callback){ |
|
| 120 | + public function setIdentifierFunction($callback) { |
|
| 121 | 121 | $this->_instanceViewer->setIdentifierFunction($callback); |
| 122 | 122 | return $this; |
| 123 | 123 | } |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | /** |
| 126 | 126 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
| 127 | 127 | */ |
| 128 | - public function getToolbar(){ |
|
| 129 | - if(isset($this->_toolbar)===false){ |
|
| 128 | + public function getToolbar() { |
|
| 129 | + if (isset($this->_toolbar)===false) { |
|
| 130 | 130 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
| 131 | 131 | //$this->_toolbar->setSecondary(); |
| 132 | 132 | } |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | * @param callable $callback function to call on $element |
| 140 | 140 | * @return \Ajax\common\html\HtmlDoubleElement |
| 141 | 141 | */ |
| 142 | - public function addInToolbar($element,$callback=NULL){ |
|
| 142 | + public function addInToolbar($element, $callback=NULL) { |
|
| 143 | 143 | $tb=$this->getToolbar(); |
| 144 | - if(isset($callback)){ |
|
| 145 | - if(\is_callable($callback)){ |
|
| 144 | + if (isset($callback)) { |
|
| 145 | + if (\is_callable($callback)) { |
|
| 146 | 146 | $callback($element); |
| 147 | 147 | } |
| 148 | 148 | } |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | * @param callable $callback function($element) |
| 156 | 156 | * @return \Ajax\common\html\HtmlDoubleElement |
| 157 | 157 | */ |
| 158 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
| 159 | - $result=$this->addInToolbar($caption,$callback); |
|
| 160 | - if(isset($icon)) |
|
| 158 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
| 159 | + $result=$this->addInToolbar($caption, $callback); |
|
| 160 | + if (isset($icon)) |
|
| 161 | 161 | $result->addIcon($icon); |
| 162 | 162 | return $result; |
| 163 | 163 | } |
@@ -167,14 +167,14 @@ discard block |
||
| 167 | 167 | * @param callable $callback function($element) |
| 168 | 168 | * @return \Ajax\common\Widget |
| 169 | 169 | */ |
| 170 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
| 171 | - if(JArray::isAssociative($items)){ |
|
| 172 | - foreach ($items as $icon=>$item){ |
|
| 173 | - $this->addItemInToolbar($item,$icon,$callback); |
|
| 170 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
| 171 | + if (JArray::isAssociative($items)) { |
|
| 172 | + foreach ($items as $icon=>$item) { |
|
| 173 | + $this->addItemInToolbar($item, $icon, $callback); |
|
| 174 | 174 | } |
| 175 | - }else{ |
|
| 176 | - foreach ($items as $item){ |
|
| 177 | - $this->addItemInToolbar($item,null,$callback); |
|
| 175 | + } else { |
|
| 176 | + foreach ($items as $item) { |
|
| 177 | + $this->addItemInToolbar($item, null, $callback); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | return $this; |
@@ -186,12 +186,12 @@ discard block |
||
| 186 | 186 | * @param callable $callback function($element) |
| 187 | 187 | * @return \Ajax\common\html\HtmlDoubleElement |
| 188 | 188 | */ |
| 189 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
| 189 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
| 190 | 190 | $dd=$value; |
| 191 | 191 | if (\is_string($value)) { |
| 192 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
| 192 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
| 193 | 193 | } |
| 194 | - return $this->addInToolbar($dd,$callback); |
|
| 194 | + return $this->addInToolbar($dd, $callback); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | * @param callable $callback function($element) |
| 200 | 200 | * @return \Ajax\common\html\HtmlDoubleElement |
| 201 | 201 | */ |
| 202 | - public function addButtonInToolbar($caption,$callback=NULL){ |
|
| 203 | - $bt=new HtmlButton("",$caption); |
|
| 204 | - return $this->addInToolbar($bt,$callback); |
|
| 202 | + public function addButtonInToolbar($caption, $callback=NULL) { |
|
| 203 | + $bt=new HtmlButton("", $caption); |
|
| 204 | + return $this->addInToolbar($bt, $callback); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -210,9 +210,9 @@ discard block |
||
| 210 | 210 | * @param callable $callback function($element) |
| 211 | 211 | * @return \Ajax\common\html\HtmlDoubleElement |
| 212 | 212 | */ |
| 213 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
| 214 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
| 215 | - return $this->addInToolbar($bts,$callback); |
|
| 213 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
| 214 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
| 215 | + return $this->addInToolbar($bts, $callback); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | * @param boolean $labeled |
| 223 | 223 | * @return \Ajax\common\html\HtmlDoubleElement |
| 224 | 224 | */ |
| 225 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
| 226 | - $bt=new HtmlButton("",$caption); |
|
| 227 | - $bt->addIcon($icon,$before,$labeled); |
|
| 225 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
| 226 | + $bt=new HtmlButton("", $caption); |
|
| 227 | + $bt->addIcon($icon, $before, $labeled); |
|
| 228 | 228 | return $this->addInToolbar($bt); |
| 229 | 229 | } |
| 230 | 230 | |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * @param callable $defaultValueFunction |
| 255 | 255 | * @return \Ajax\common\Widget |
| 256 | 256 | */ |
| 257 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
| 257 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
| 258 | 258 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
| 259 | 259 | return $this; |
| 260 | 260 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * @param string|boolean $disable |
| 264 | 264 | * @return string |
| 265 | 265 | */ |
| 266 | - public function jsDisabled($disable=true){ |
|
| 266 | + public function jsDisabled($disable=true) { |
|
| 267 | 267 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
| 268 | 268 | } |
| 269 | 269 | |
@@ -272,12 +272,12 @@ discard block |
||
| 272 | 272 | * @param callable $callback function($element) |
| 273 | 273 | * @return \Ajax\common\html\HtmlDoubleElement |
| 274 | 274 | */ |
| 275 | - public function addEditButtonInToolbar($caption,$callback=NULL){ |
|
| 276 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
| 275 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
| 276 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
| 277 | 277 | $bt->setToggle(); |
| 278 | 278 | $bt->setActive($this->_edition); |
| 279 | 279 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
| 280 | - return $this->addInToolbar($bt,$callback); |
|
| 280 | + return $this->addInToolbar($bt, $callback); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | } |
| 284 | 284 | \ No newline at end of file |
@@ -157,8 +157,9 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
| 159 | 159 | $result=$this->addInToolbar($caption,$callback); |
| 160 | - if(isset($icon)) |
|
| 161 | - $result->addIcon($icon); |
|
| 160 | + if(isset($icon)) { |
|
| 161 | + $result->addIcon($icon); |
|
| 162 | + } |
|
| 162 | 163 | return $result; |
| 163 | 164 | } |
| 164 | 165 | |
@@ -172,7 +173,7 @@ discard block |
||
| 172 | 173 | foreach ($items as $icon=>$item){ |
| 173 | 174 | $this->addItemInToolbar($item,$icon,$callback); |
| 174 | 175 | } |
| 175 | - }else{ |
|
| 176 | + } else{ |
|
| 176 | 177 | foreach ($items as $item){ |
| 177 | 178 | $this->addItemInToolbar($item,null,$callback); |
| 178 | 179 | } |