@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $this->startIndex=$startIndex; |
| 53 | 53 | $this->autoActive=$autoActive; |
| 54 | 54 | $this->_contentSeparator="<div class='divider'> / </div>"; |
| 55 | - $this->_hrefFunction=function (HtmlSemDoubleElement $e) { |
|
| 55 | + $this->_hrefFunction=function(HtmlSemDoubleElement $e) { |
|
| 56 | 56 | return $e->getContent(); |
| 57 | 57 | }; |
| 58 | 58 | if (isset($hrefFunction)) { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return HtmlBreadcrumb |
| 69 | 69 | */ |
| 70 | 70 | public function autoGetOnClick($targetSelector) { |
| 71 | - return $this->getOnClick($this->root, $targetSelector, array ("attr" => $this->attr )); |
|
| 71 | + return $this->getOnClick($this->root, $targetSelector, array("attr" => $this->attr)); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public function contentAsString() { |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function setActive($index=null) { |
| 85 | 85 | if (!isset($index)) { |
| 86 | - $index=sizeof($this->content) - 1; |
|
| 86 | + $index=sizeof($this->content)-1; |
|
| 87 | 87 | } |
| 88 | 88 | $activeItem=$this->content[$index]; |
| 89 | 89 | $activeItem->addToProperty("class", "active"); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @param object $dispatcher the request dispatcher |
| 97 | 97 | * @return HtmlBreadcrumb |
| 98 | 98 | */ |
| 99 | - public function fromDispatcher(JsUtils $js,$dispatcher, $startIndex=0) { |
|
| 99 | + public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0) { |
|
| 100 | 100 | $this->startIndex=$startIndex; |
| 101 | 101 | return $this->addItems($js->fromDispatcher($dispatcher)); |
| 102 | 102 | } |
@@ -111,12 +111,12 @@ discard block |
||
| 111 | 111 | if (!isset($index)) { |
| 112 | 112 | $index=sizeof($this->content); |
| 113 | 113 | } |
| 114 | - if ($this->absolutePaths === true) { |
|
| 114 | + if ($this->absolutePaths===true) { |
|
| 115 | 115 | return $this->_hrefFunction($this->content[$index]); |
| 116 | 116 | } else { |
| 117 | - return $this->root . implode($separator, array_slice(array_map(function ($e) { |
|
| 117 | + return $this->root.implode($separator, array_slice(array_map(function($e) { |
|
| 118 | 118 | return $this->_hrefFunction($e); |
| 119 | - }, $this->content), $this->startIndex, $index + 1)); |
|
| 119 | + }, $this->content), $this->startIndex, $index+1)); |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
@@ -150,8 +150,8 @@ discard block |
||
| 150 | 150 | $this->setActive(); |
| 151 | 151 | } |
| 152 | 152 | $count=$this->count(); |
| 153 | - for($i=1; $i < $count; $i++) { |
|
| 154 | - $this->content[$i]->wrap($this->getContentDivider($i - 1)); |
|
| 153 | + for ($i=1; $i<$count; $i++) { |
|
| 154 | + $this->content[$i]->wrap($this->getContentDivider($i-1)); |
|
| 155 | 155 | } |
| 156 | 156 | return parent::compile($js, $view); |
| 157 | 157 | } |
@@ -161,15 +161,15 @@ discard block |
||
| 161 | 161 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
| 162 | 162 | */ |
| 163 | 163 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
| 164 | - foreach ( $this->content as $element ) { |
|
| 164 | + foreach ($this->content as $element) { |
|
| 165 | 165 | $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
| 166 | 166 | } |
| 167 | 167 | return $this; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
| 171 | - foreach ( $this->content as $element ) { |
|
| 172 | - if ($element->getProperty($this->attr) != NULL){ |
|
| 171 | + foreach ($this->content as $element) { |
|
| 172 | + if ($element->getProperty($this->attr)!=NULL) { |
|
| 173 | 173 | $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters); |
| 174 | 174 | } |
| 175 | 175 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function createItem($value) { |
| 186 | 186 | $count=$this->count(); |
| 187 | - $itemO=new HtmlSemDoubleElement("item-" . $this->identifier . "-" . $count, "a", "section"); |
|
| 187 | + $itemO=new HtmlSemDoubleElement("item-".$this->identifier."-".$count, "a", "section"); |
|
| 188 | 188 | if (\is_array($value)) |
| 189 | 189 | $itemO->fromArray($value); |
| 190 | 190 | else { |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | public function addIconAt($icon, $index) { |
| 197 | 197 | $item=$this->getItem($index); |
| 198 | 198 | if (isset($item)) { |
| 199 | - $icon=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
| 199 | + $icon=new HtmlIcon("icon-".$this->identifier, $icon); |
|
| 200 | 200 | $item->wrapContent($icon); |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | public function addItem($item) { |
| 205 | 205 | $count=$this->count(); |
| 206 | 206 | $itemO=parent::addItem($item); |
| 207 | - $this->addToPropertyCtrl("class", "section", array ("section" )); |
|
| 207 | + $this->addToPropertyCtrl("class", "section", array("section")); |
|
| 208 | 208 | $itemO->setProperty($this->attr, $this->getHref($count)); |
| 209 | 209 | return $itemO; |
| 210 | 210 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | public function setAbsolutePaths($absolutePaths) { |
| 221 | 221 | $this->absolutePaths=$absolutePaths; |
| 222 | 222 | $size=\sizeof($this->content); |
| 223 | - for($i=0;$i<$size;$i++){ |
|
| 223 | + for ($i=0; $i<$size; $i++) { |
|
| 224 | 224 | $this->content[$i]->setProperty($this->attr, $this->getHref($i)); |
| 225 | 225 | } |
| 226 | 226 | return $this; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | use Ajax\semantic\html\modules\HtmlModal; |
| 21 | 21 | |
| 22 | 22 | abstract class Widget extends HtmlDoubleElement { |
| 23 | - use FieldAsTrait,FormTrait; |
|
| 23 | + use FieldAsTrait, FormTrait; |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @var string classname |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | protected $_generated; |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 56 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 57 | 57 | parent::__construct($identifier); |
| 58 | 58 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
| 59 | 59 | $this->setModel($model); |
| 60 | - if(isset($modelInstance)){ |
|
| 60 | + if (isset($modelInstance)) { |
|
| 61 | 61 | $this->show($modelInstance); |
| 62 | 62 | } |
| 63 | 63 | $this->_generated=false; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - protected function _init($instanceViewer,$contentKey,$content,$edition){ |
|
| 66 | + protected function _init($instanceViewer, $contentKey, $content, $edition) { |
|
| 67 | 67 | $this->_instanceViewer=$instanceViewer; |
| 68 | 68 | $this->content=[$contentKey=>$content]; |
| 69 | 69 | $this->_self=$content; |
@@ -75,31 +75,31 @@ discard block |
||
| 75 | 75 | * @param int|string $fieldName |
| 76 | 76 | * @return int|string|boolean |
| 77 | 77 | */ |
| 78 | - protected function _getIndex($fieldName){ |
|
| 78 | + protected function _getIndex($fieldName) { |
|
| 79 | 79 | $index=$fieldName; |
| 80 | - if(\is_string($fieldName)){ |
|
| 80 | + if (\is_string($fieldName)) { |
|
| 81 | 81 | $fields=$this->_instanceViewer->getVisibleProperties(); |
| 82 | 82 | $index=\array_search($fieldName, $fields); |
| 83 | 83 | } |
| 84 | 84 | return $index; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
| 87 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 88 | 88 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - protected function _getFieldName($index){ |
|
| 91 | + protected function _getFieldName($index) { |
|
| 92 | 92 | return $this->_instanceViewer->getFieldName($index); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - protected function _getFieldCaption($index){ |
|
| 95 | + protected function _getFieldCaption($index) { |
|
| 96 | 96 | return $this->_instanceViewer->getCaption($index); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
| 99 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
| 100 | 100 | |
| 101 | - public function show($modelInstance){ |
|
| 102 | - if(\is_array($modelInstance)){ |
|
| 101 | + public function show($modelInstance) { |
|
| 102 | + if (\is_array($modelInstance)) { |
|
| 103 | 103 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
| 104 | 104 | } |
| 105 | 105 | $this->_modelInstance=$modelInstance; |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | abstract public function getHtmlComponent(); |
| 127 | 127 | |
| 128 | - public function setAttached($value=true){ |
|
| 128 | + public function setAttached($value=true) { |
|
| 129 | 129 | return $this->getHtmlComponent()->setAttached($value); |
| 130 | 130 | } |
| 131 | 131 | |
@@ -136,59 +136,59 @@ discard block |
||
| 136 | 136 | * @param callable $callback function called after the field compilation |
| 137 | 137 | * @return Widget |
| 138 | 138 | */ |
| 139 | - public function afterCompile($index,$callback){ |
|
| 139 | + public function afterCompile($index, $callback) { |
|
| 140 | 140 | $index=$this->_getIndex($index); |
| 141 | 141 | $this->_instanceViewer->afterCompile($index, $callback); |
| 142 | 142 | return $this; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - public function setColor($color){ |
|
| 145 | + public function setColor($color) { |
|
| 146 | 146 | return $this->getHtmlComponent()->setColor($color); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
| 150 | - public function setCaptions($captions){ |
|
| 150 | + public function setCaptions($captions) { |
|
| 151 | 151 | $this->_instanceViewer->setCaptions($captions); |
| 152 | 152 | return $this; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - public function setCaption($index,$caption){ |
|
| 155 | + public function setCaption($index, $caption) { |
|
| 156 | 156 | $this->_instanceViewer->setCaption($this->_getIndex($index), $caption); |
| 157 | 157 | return $this; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function setFields($fields){ |
|
| 160 | + public function setFields($fields) { |
|
| 161 | 161 | $this->_instanceViewer->setVisibleProperties($fields); |
| 162 | 162 | return $this; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - public function addField($field){ |
|
| 165 | + public function addField($field) { |
|
| 166 | 166 | $this->_instanceViewer->addField($field); |
| 167 | 167 | return $this; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - public function addFields($fields){ |
|
| 170 | + public function addFields($fields) { |
|
| 171 | 171 | $this->_instanceViewer->addFields($fields); |
| 172 | 172 | return $this; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - public function addMessage($attributes=NULL,$fieldName="message"){ |
|
| 175 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
| 176 | 176 | $this->_instanceViewer->addField($fieldName); |
| 177 | 177 | $count=$this->_instanceViewer->visiblePropertiesCount(); |
| 178 | - return $this->fieldAsMessage($count-1,$attributes); |
|
| 178 | + return $this->fieldAsMessage($count-1, $attributes); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - public function addErrorMessage(){ |
|
| 182 | - return $this->addMessage(["error"=>true],"message"); |
|
| 181 | + public function addErrorMessage() { |
|
| 182 | + return $this->addMessage(["error"=>true], "message"); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - public function insertField($index,$field){ |
|
| 185 | + public function insertField($index, $field) { |
|
| 186 | 186 | $index=$this->_getIndex($index); |
| 187 | 187 | $this->_instanceViewer->insertField($index, $field); |
| 188 | 188 | return $this; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - public function insertInField($index,$field){ |
|
| 191 | + public function insertInField($index, $field) { |
|
| 192 | 192 | $index=$this->_getIndex($index); |
| 193 | 193 | $this->_instanceViewer->insertInField($index, $field); |
| 194 | 194 | return $this; |
@@ -200,13 +200,13 @@ discard block |
||
| 200 | 200 | * @param callable $callback function parameters are : $value : the field value, $instance : the active instance of model, $fieldIndex : the field index, $rowIndex : the row index |
| 201 | 201 | * @return Widget |
| 202 | 202 | */ |
| 203 | - public function setValueFunction($index,$callback){ |
|
| 203 | + public function setValueFunction($index, $callback) { |
|
| 204 | 204 | $index=$this->_getIndex($index); |
| 205 | 205 | $this->_instanceViewer->setValueFunction($index, $callback); |
| 206 | 206 | return $this; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - public function setIdentifierFunction($callback){ |
|
| 209 | + public function setIdentifierFunction($callback) { |
|
| 210 | 210 | $this->_instanceViewer->setIdentifierFunction($callback); |
| 211 | 211 | return $this; |
| 212 | 212 | } |
@@ -214,8 +214,8 @@ discard block |
||
| 214 | 214 | /** |
| 215 | 215 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
| 216 | 216 | */ |
| 217 | - public function getToolbar(){ |
|
| 218 | - if(isset($this->_toolbar)===false){ |
|
| 217 | + public function getToolbar() { |
|
| 218 | + if (isset($this->_toolbar)===false) { |
|
| 219 | 219 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
| 220 | 220 | } |
| 221 | 221 | return $this->_toolbar; |
@@ -227,15 +227,15 @@ discard block |
||
| 227 | 227 | * @param callable $callback function to call on $element |
| 228 | 228 | * @return \Ajax\common\html\HtmlDoubleElement |
| 229 | 229 | */ |
| 230 | - public function addInToolbar($element,$callback=NULL){ |
|
| 230 | + public function addInToolbar($element, $callback=NULL) { |
|
| 231 | 231 | $tb=$this->getToolbar(); |
| 232 | - if($element instanceof BaseWidget){ |
|
| 233 | - if($element->getIdentifier()===""){ |
|
| 232 | + if ($element instanceof BaseWidget) { |
|
| 233 | + if ($element->getIdentifier()==="") { |
|
| 234 | 234 | $element->setIdentifier("tb-item-".$this->identifier."-".$tb->count()); |
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | - if(isset($callback)){ |
|
| 238 | - if(\is_callable($callback)){ |
|
| 237 | + if (isset($callback)) { |
|
| 238 | + if (\is_callable($callback)) { |
|
| 239 | 239 | $callback($element); |
| 240 | 240 | } |
| 241 | 241 | } |
@@ -248,9 +248,9 @@ discard block |
||
| 248 | 248 | * @param callable $callback function($element) |
| 249 | 249 | * @return \Ajax\common\html\HtmlDoubleElement |
| 250 | 250 | */ |
| 251 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
| 252 | - $result=$this->addInToolbar($caption,$callback); |
|
| 253 | - if(isset($icon) && method_exists($result, "addIcon")) |
|
| 251 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
| 252 | + $result=$this->addInToolbar($caption, $callback); |
|
| 253 | + if (isset($icon) && method_exists($result, "addIcon")) |
|
| 254 | 254 | $result->addIcon($icon); |
| 255 | 255 | return $result; |
| 256 | 256 | } |
@@ -260,14 +260,14 @@ discard block |
||
| 260 | 260 | * @param callable $callback function($element) |
| 261 | 261 | * @return \Ajax\common\Widget |
| 262 | 262 | */ |
| 263 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
| 264 | - if(JArray::isAssociative($items)){ |
|
| 265 | - foreach ($items as $icon=>$item){ |
|
| 266 | - $this->addItemInToolbar($item,$icon,$callback); |
|
| 263 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
| 264 | + if (JArray::isAssociative($items)) { |
|
| 265 | + foreach ($items as $icon=>$item) { |
|
| 266 | + $this->addItemInToolbar($item, $icon, $callback); |
|
| 267 | 267 | } |
| 268 | - }else{ |
|
| 269 | - foreach ($items as $item){ |
|
| 270 | - $this->addItemInToolbar($item,null,$callback); |
|
| 268 | + } else { |
|
| 269 | + foreach ($items as $item) { |
|
| 270 | + $this->addItemInToolbar($item, null, $callback); |
|
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | return $this; |
@@ -279,12 +279,12 @@ discard block |
||
| 279 | 279 | * @param callable $callback function($element) |
| 280 | 280 | * @return \Ajax\common\html\HtmlDoubleElement |
| 281 | 281 | */ |
| 282 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
| 282 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
| 283 | 283 | $dd=$value; |
| 284 | 284 | if (\is_string($value)) { |
| 285 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
| 285 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
| 286 | 286 | } |
| 287 | - return $this->addInToolbar($dd,$callback); |
|
| 287 | + return $this->addInToolbar($dd, $callback); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -293,9 +293,9 @@ discard block |
||
| 293 | 293 | * @param callable $callback function($element) |
| 294 | 294 | * @return \Ajax\common\html\HtmlDoubleElement |
| 295 | 295 | */ |
| 296 | - public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){ |
|
| 297 | - $bt=new HtmlButton("bt-".$caption,$caption,$cssStyle); |
|
| 298 | - return $this->addInToolbar($bt,$callback); |
|
| 296 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
| 297 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
| 298 | + return $this->addInToolbar($bt, $callback); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -304,9 +304,9 @@ discard block |
||
| 304 | 304 | * @param callable $callback function($element) |
| 305 | 305 | * @return \Ajax\common\html\HtmlDoubleElement |
| 306 | 306 | */ |
| 307 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
| 308 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
| 309 | - return $this->addInToolbar($bts,$callback); |
|
| 307 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
| 308 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
| 309 | + return $this->addInToolbar($bts, $callback); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /** |
@@ -316,15 +316,15 @@ discard block |
||
| 316 | 316 | * @param boolean $labeled |
| 317 | 317 | * @return \Ajax\common\html\HtmlDoubleElement |
| 318 | 318 | */ |
| 319 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
| 320 | - $bt=new HtmlButton("",$caption); |
|
| 321 | - $bt->addIcon($icon,$before,$labeled); |
|
| 319 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
| 320 | + $bt=new HtmlButton("", $caption); |
|
| 321 | + $bt->addIcon($icon, $before, $labeled); |
|
| 322 | 322 | return $this->addInToolbar($bt); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
| 326 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
| 327 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters); |
|
| 325 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
| 326 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
| 327 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
|
| 328 | 328 | return $this->addInToolbar($button); |
| 329 | 329 | } |
| 330 | 330 | |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model |
| 355 | 355 | * @return \Ajax\common\Widget |
| 356 | 356 | */ |
| 357 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
| 357 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
| 358 | 358 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
| 359 | 359 | return $this; |
| 360 | 360 | } |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * @param string|boolean $disable |
| 364 | 364 | * @return string |
| 365 | 365 | */ |
| 366 | - public function jsDisabled($disable=true){ |
|
| 366 | + public function jsDisabled($disable=true) { |
|
| 367 | 367 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
| 368 | 368 | } |
| 369 | 369 | |
@@ -372,12 +372,12 @@ discard block |
||
| 372 | 372 | * @param callable $callback function($element) |
| 373 | 373 | * @return \Ajax\common\html\HtmlDoubleElement |
| 374 | 374 | */ |
| 375 | - public function addEditButtonInToolbar($caption,$callback=NULL){ |
|
| 376 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
| 375 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
| 376 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
| 377 | 377 | $bt->setToggle(); |
| 378 | 378 | $bt->setActive($this->_edition); |
| 379 | 379 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
| 380 | - return $this->addInToolbar($bt,$callback); |
|
| 380 | + return $this->addInToolbar($bt, $callback); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | public function setToolbar(HtmlMenu $_toolbar) { |
@@ -391,34 +391,34 @@ discard block |
||
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | public function getForm() { |
| 394 | - if(!isset($this->_form)){ |
|
| 394 | + if (!isset($this->_form)) { |
|
| 395 | 395 | $this->_form=new HtmlForm("frm-".$this->identifier); |
| 396 | 396 | $this->setEdition(true); |
| 397 | 397 | } |
| 398 | 398 | return $this->_form; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - public function run(JsUtils $js){ |
|
| 401 | + public function run(JsUtils $js) { |
|
| 402 | 402 | parent::run($js); |
| 403 | - if(isset($this->_form)){ |
|
| 403 | + if (isset($this->_form)) { |
|
| 404 | 404 | $this->runForm($js); |
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - protected function runForm(JsUtils $js){ |
|
| 408 | + protected function runForm(JsUtils $js) { |
|
| 409 | 409 | $fields=$this->getContentInstances(HtmlFormField::class); |
| 410 | - foreach ($fields as $field){ |
|
| 410 | + foreach ($fields as $field) { |
|
| 411 | 411 | $this->_form->addField($field); |
| 412 | 412 | } |
| 413 | 413 | return $this->_form->run($js); |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - protected function _compileForm(){ |
|
| 417 | - if(isset($this->_form)){ |
|
| 416 | + protected function _compileForm() { |
|
| 417 | + if (isset($this->_form)) { |
|
| 418 | 418 | $noValidate=""; |
| 419 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
| 419 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
| 420 | 420 | $noValidate="novalidate"; |
| 421 | - $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
|
| 421 | + $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
@@ -433,32 +433,32 @@ discard block |
||
| 433 | 433 | return $this; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - public function moveFieldTo($from,$to){ |
|
| 436 | + public function moveFieldTo($from, $to) { |
|
| 437 | 437 | return $this->_instanceViewer->moveFieldTo($from, $to); |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - public function swapFields($index1,$index2){ |
|
| 440 | + public function swapFields($index1, $index2) { |
|
| 441 | 441 | $index1=$this->_getIndex($index1); |
| 442 | 442 | $index2=$this->_getIndex($index2); |
| 443 | 443 | return $this->_instanceViewer->swapFields($index1, $index2); |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - public function removeField($index){ |
|
| 446 | + public function removeField($index) { |
|
| 447 | 447 | $index=$this->_getIndex($index); |
| 448 | 448 | $this->_instanceViewer->removeField($index); |
| 449 | 449 | return $this; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - public function asModal($header=null){ |
|
| 453 | - $modal=new HtmlModal("modal-".$this->identifier,$header); |
|
| 452 | + public function asModal($header=null) { |
|
| 453 | + $modal=new HtmlModal("modal-".$this->identifier, $header); |
|
| 454 | 454 | $modal->setContent($this); |
| 455 | - if(isset($this->_form)){ |
|
| 455 | + if (isset($this->_form)) { |
|
| 456 | 456 | $this->_form->onSuccess($modal->jsHide()); |
| 457 | 457 | } |
| 458 | 458 | return $modal; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | public function addToProperty($name, $value, $separator=" ") { |
| 462 | - return $this->getHtmlComponent()->addToProperty($name,$value,$separator); |
|
| 462 | + return $this->getHtmlComponent()->addToProperty($name, $value, $separator); |
|
| 463 | 463 | } |
| 464 | 464 | } |
@@ -250,8 +250,9 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
| 252 | 252 | $result=$this->addInToolbar($caption,$callback); |
| 253 | - if(isset($icon) && method_exists($result, "addIcon")) |
|
| 254 | - $result->addIcon($icon); |
|
| 253 | + if(isset($icon) && method_exists($result, "addIcon")) { |
|
| 254 | + $result->addIcon($icon); |
|
| 255 | + } |
|
| 255 | 256 | return $result; |
| 256 | 257 | } |
| 257 | 258 | |
@@ -265,7 +266,7 @@ discard block |
||
| 265 | 266 | foreach ($items as $icon=>$item){ |
| 266 | 267 | $this->addItemInToolbar($item,$icon,$callback); |
| 267 | 268 | } |
| 268 | - }else{ |
|
| 269 | + } else{ |
|
| 269 | 270 | foreach ($items as $item){ |
| 270 | 271 | $this->addItemInToolbar($item,null,$callback); |
| 271 | 272 | } |
@@ -416,8 +417,9 @@ discard block |
||
| 416 | 417 | protected function _compileForm(){ |
| 417 | 418 | if(isset($this->_form)){ |
| 418 | 419 | $noValidate=""; |
| 419 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
| 420 | - $noValidate="novalidate"; |
|
| 420 | + if(\sizeof($this->_form->getValidationParams())>0) { |
|
| 421 | + $noValidate="novalidate"; |
|
| 422 | + } |
|
| 421 | 423 | $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
| 422 | 424 | } |
| 423 | 425 | } |