@@ -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 |
| 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,66 +136,66 @@ 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 addMessage($attributes=NULL,$fieldName="message"){ |
|
| 170 | + public function addMessage($attributes=NULL, $fieldName="message") { |
|
| 171 | 171 | $this->_instanceViewer->addField($fieldName); |
| 172 | 172 | $count=$this->_instanceViewer->visiblePropertiesCount(); |
| 173 | - return $this->fieldAsMessage($count-1,$attributes); |
|
| 173 | + return $this->fieldAsMessage($count-1, $attributes); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - public function addErrorMessage(){ |
|
| 177 | - return $this->addMessage(["error"=>true],"message"); |
|
| 176 | + public function addErrorMessage() { |
|
| 177 | + return $this->addMessage(["error"=>true], "message"); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - public function insertField($index,$field){ |
|
| 180 | + public function insertField($index, $field) { |
|
| 181 | 181 | $index=$this->_getIndex($index); |
| 182 | 182 | $this->_instanceViewer->insertField($index, $field); |
| 183 | 183 | return $this; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - public function insertInField($index,$field){ |
|
| 186 | + public function insertInField($index, $field) { |
|
| 187 | 187 | $index=$this->_getIndex($index); |
| 188 | 188 | $this->_instanceViewer->insertInField($index, $field); |
| 189 | 189 | return $this; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - public function setValueFunction($index,$callback){ |
|
| 192 | + public function setValueFunction($index, $callback) { |
|
| 193 | 193 | $index=$this->_getIndex($index); |
| 194 | 194 | $this->_instanceViewer->setValueFunction($index, $callback); |
| 195 | 195 | return $this; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - public function setIdentifierFunction($callback){ |
|
| 198 | + public function setIdentifierFunction($callback) { |
|
| 199 | 199 | $this->_instanceViewer->setIdentifierFunction($callback); |
| 200 | 200 | return $this; |
| 201 | 201 | } |
@@ -203,8 +203,8 @@ discard block |
||
| 203 | 203 | /** |
| 204 | 204 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
| 205 | 205 | */ |
| 206 | - public function getToolbar(){ |
|
| 207 | - if(isset($this->_toolbar)===false){ |
|
| 206 | + public function getToolbar() { |
|
| 207 | + if (isset($this->_toolbar)===false) { |
|
| 208 | 208 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
| 209 | 209 | } |
| 210 | 210 | return $this->_toolbar; |
@@ -216,15 +216,15 @@ discard block |
||
| 216 | 216 | * @param callable $callback function to call on $element |
| 217 | 217 | * @return \Ajax\common\html\HtmlDoubleElement |
| 218 | 218 | */ |
| 219 | - public function addInToolbar($element,$callback=NULL){ |
|
| 219 | + public function addInToolbar($element, $callback=NULL) { |
|
| 220 | 220 | $tb=$this->getToolbar(); |
| 221 | - if($element instanceof BaseWidget){ |
|
| 222 | - if($element->getIdentifier()===""){ |
|
| 221 | + if ($element instanceof BaseWidget) { |
|
| 222 | + if ($element->getIdentifier()==="") { |
|
| 223 | 223 | $element->setIdentifier("tb-item-".$this->identifier."-".$tb->count()); |
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | - if(isset($callback)){ |
|
| 227 | - if(\is_callable($callback)){ |
|
| 226 | + if (isset($callback)) { |
|
| 227 | + if (\is_callable($callback)) { |
|
| 228 | 228 | $callback($element); |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -237,9 +237,9 @@ discard block |
||
| 237 | 237 | * @param callable $callback function($element) |
| 238 | 238 | * @return \Ajax\common\html\HtmlDoubleElement |
| 239 | 239 | */ |
| 240 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
| 241 | - $result=$this->addInToolbar($caption,$callback); |
|
| 242 | - if(isset($icon)) |
|
| 240 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
| 241 | + $result=$this->addInToolbar($caption, $callback); |
|
| 242 | + if (isset($icon)) |
|
| 243 | 243 | $result->addIcon($icon); |
| 244 | 244 | return $result; |
| 245 | 245 | } |
@@ -249,14 +249,14 @@ discard block |
||
| 249 | 249 | * @param callable $callback function($element) |
| 250 | 250 | * @return \Ajax\common\Widget |
| 251 | 251 | */ |
| 252 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
| 253 | - if(JArray::isAssociative($items)){ |
|
| 254 | - foreach ($items as $icon=>$item){ |
|
| 255 | - $this->addItemInToolbar($item,$icon,$callback); |
|
| 252 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
| 253 | + if (JArray::isAssociative($items)) { |
|
| 254 | + foreach ($items as $icon=>$item) { |
|
| 255 | + $this->addItemInToolbar($item, $icon, $callback); |
|
| 256 | 256 | } |
| 257 | - }else{ |
|
| 258 | - foreach ($items as $item){ |
|
| 259 | - $this->addItemInToolbar($item,null,$callback); |
|
| 257 | + } else { |
|
| 258 | + foreach ($items as $item) { |
|
| 259 | + $this->addItemInToolbar($item, null, $callback); |
|
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | return $this; |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | * @param callable $callback function($element) |
| 269 | 269 | * @return \Ajax\common\html\HtmlDoubleElement |
| 270 | 270 | */ |
| 271 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
| 271 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
| 272 | 272 | $dd=$value; |
| 273 | 273 | if (\is_string($value)) { |
| 274 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
| 274 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
| 275 | 275 | } |
| 276 | - return $this->addInToolbar($dd,$callback); |
|
| 276 | + return $this->addInToolbar($dd, $callback); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | * @param callable $callback function($element) |
| 283 | 283 | * @return \Ajax\common\html\HtmlDoubleElement |
| 284 | 284 | */ |
| 285 | - public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){ |
|
| 286 | - $bt=new HtmlButton("bt-".$caption,$caption,$cssStyle); |
|
| 287 | - return $this->addInToolbar($bt,$callback); |
|
| 285 | + public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) { |
|
| 286 | + $bt=new HtmlButton("bt-".$caption, $caption, $cssStyle); |
|
| 287 | + return $this->addInToolbar($bt, $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 addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
| 297 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
| 298 | - return $this->addInToolbar($bts,$callback); |
|
| 296 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
| 297 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
| 298 | + return $this->addInToolbar($bts, $callback); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -305,15 +305,15 @@ discard block |
||
| 305 | 305 | * @param boolean $labeled |
| 306 | 306 | * @return \Ajax\common\html\HtmlDoubleElement |
| 307 | 307 | */ |
| 308 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
| 309 | - $bt=new HtmlButton("",$caption); |
|
| 310 | - $bt->addIcon($icon,$before,$labeled); |
|
| 308 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
| 309 | + $bt=new HtmlButton("", $caption); |
|
| 310 | + $bt->addIcon($icon, $before, $labeled); |
|
| 311 | 311 | return $this->addInToolbar($bt); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
| 315 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
| 316 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters); |
|
| 314 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
| 315 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
| 316 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters); |
|
| 317 | 317 | return $this->addInToolbar($button); |
| 318 | 318 | } |
| 319 | 319 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model |
| 344 | 344 | * @return \Ajax\common\Widget |
| 345 | 345 | */ |
| 346 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
| 346 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
| 347 | 347 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
| 348 | 348 | return $this; |
| 349 | 349 | } |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | * @param string|boolean $disable |
| 353 | 353 | * @return string |
| 354 | 354 | */ |
| 355 | - public function jsDisabled($disable=true){ |
|
| 355 | + public function jsDisabled($disable=true) { |
|
| 356 | 356 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
| 357 | 357 | } |
| 358 | 358 | |
@@ -361,12 +361,12 @@ discard block |
||
| 361 | 361 | * @param callable $callback function($element) |
| 362 | 362 | * @return \Ajax\common\html\HtmlDoubleElement |
| 363 | 363 | */ |
| 364 | - public function addEditButtonInToolbar($caption,$callback=NULL){ |
|
| 365 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
| 364 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
| 365 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
| 366 | 366 | $bt->setToggle(); |
| 367 | 367 | $bt->setActive($this->_edition); |
| 368 | 368 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
| 369 | - return $this->addInToolbar($bt,$callback); |
|
| 369 | + return $this->addInToolbar($bt, $callback); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | public function setToolbar(HtmlMenu $_toolbar) { |
@@ -380,35 +380,35 @@ discard block |
||
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | public function getForm() { |
| 383 | - if(!isset($this->_form)){ |
|
| 383 | + if (!isset($this->_form)) { |
|
| 384 | 384 | $this->_form=new HtmlForm("frm-".$this->identifier); |
| 385 | 385 | $this->setEdition(true); |
| 386 | 386 | } |
| 387 | 387 | return $this->_form; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - public function run(JsUtils $js){ |
|
| 390 | + public function run(JsUtils $js) { |
|
| 391 | 391 | $result=parent::run($js); |
| 392 | - if(isset($this->_form)){ |
|
| 392 | + if (isset($this->_form)) { |
|
| 393 | 393 | $result=$this->runForm($js); |
| 394 | 394 | } |
| 395 | 395 | return $result; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - protected function runForm(JsUtils $js){ |
|
| 398 | + protected function runForm(JsUtils $js) { |
|
| 399 | 399 | $fields=$this->getContentInstances(HtmlFormField::class); |
| 400 | - foreach ($fields as $field){ |
|
| 400 | + foreach ($fields as $field) { |
|
| 401 | 401 | $this->_form->addField($field); |
| 402 | 402 | } |
| 403 | 403 | return $this->_form->run($js); |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - protected function _compileForm(){ |
|
| 407 | - if(isset($this->_form)){ |
|
| 406 | + protected function _compileForm() { |
|
| 407 | + if (isset($this->_form)) { |
|
| 408 | 408 | $noValidate=""; |
| 409 | - if(\sizeof($this->_form->getValidationParams())>0) |
|
| 409 | + if (\sizeof($this->_form->getValidationParams())>0) |
|
| 410 | 410 | $noValidate="novalidate"; |
| 411 | - $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>"); |
|
| 411 | + $this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>"); |
|
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | |
@@ -417,32 +417,32 @@ discard block |
||
| 417 | 417 | return $this; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - public function moveFieldTo($from,$to){ |
|
| 420 | + public function moveFieldTo($from, $to) { |
|
| 421 | 421 | return $this->_instanceViewer->moveFieldTo($from, $to); |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - public function swapFields($index1,$index2){ |
|
| 424 | + public function swapFields($index1, $index2) { |
|
| 425 | 425 | $index1=$this->_getIndex($index1); |
| 426 | 426 | $index2=$this->_getIndex($index2); |
| 427 | 427 | return $this->_instanceViewer->swapFields($index1, $index2); |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - public function removeField($index){ |
|
| 430 | + public function removeField($index) { |
|
| 431 | 431 | $index=$this->_getIndex($index); |
| 432 | 432 | $this->_instanceViewer->removeField($index); |
| 433 | 433 | return $this; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - public function asModal($header=null){ |
|
| 437 | - $modal=new HtmlModal("modal-".$this->identifier,$header); |
|
| 436 | + public function asModal($header=null) { |
|
| 437 | + $modal=new HtmlModal("modal-".$this->identifier, $header); |
|
| 438 | 438 | $modal->setContent($this); |
| 439 | - if(isset($this->_form)){ |
|
| 439 | + if (isset($this->_form)) { |
|
| 440 | 440 | $this->_form->onSuccess($modal->jsHide()); |
| 441 | 441 | } |
| 442 | 442 | return $modal; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | public function addToProperty($name, $value, $separator=" ") { |
| 446 | - return $this->getHtmlComponent()->addToProperty($name,$value,$separator); |
|
| 446 | + return $this->getHtmlComponent()->addToProperty($name, $value, $separator); |
|
| 447 | 447 | } |
| 448 | 448 | } |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | * @version 1.001 |
| 11 | 11 | */ |
| 12 | 12 | abstract class BaseComponent { |
| 13 | - public $jquery_code_for_compile=array (); |
|
| 14 | - protected $params=array (); |
|
| 13 | + public $jquery_code_for_compile=array(); |
|
| 14 | + protected $params=array(); |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | public function setParams($params) { |
| 71 | - foreach ( $params as $k => $v ) { |
|
| 71 | + foreach ($params as $k => $v) { |
|
| 72 | 72 | $method="set".ucfirst($k); |
| 73 | 73 | if (method_exists($this, $method)) |
| 74 | 74 | $this->$method($v); |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | return $this; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - public function addParams($params){ |
|
| 85 | - foreach ($params as $k=>$v){ |
|
| 84 | + public function addParams($params) { |
|
| 85 | + foreach ($params as $k=>$v) { |
|
| 86 | 86 | $this->setParam($k, $v); |
| 87 | 87 | } |
| 88 | 88 | return $this; |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | abstract public function getScript(); |
| 92 | 92 | |
| 93 | - public function setDebug($value){ |
|
| 93 | + public function setDebug($value) { |
|
| 94 | 94 | return $this->setParam("debug", $value); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function setVerbose($value){ |
|
| 97 | + public function setVerbose($value) { |
|
| 98 | 98 | return $this->setParam("verbose", $value); |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | protected $attr; |
| 22 | 22 | |
| 23 | 23 | |
| 24 | - public function __construct($identifier,$tagName){ |
|
| 25 | - parent::__construct($identifier,$tagName); |
|
| 24 | + public function __construct($identifier, $tagName) { |
|
| 25 | + parent::__construct($identifier, $tagName); |
|
| 26 | 26 | $this->root=""; |
| 27 | 27 | $this->attr="data-ajax"; |
| 28 | 28 | } |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | * @param string $targetSelector the target of the get |
| 34 | 34 | * @return HtmlNavElement |
| 35 | 35 | */ |
| 36 | - public function autoGetOnClick($targetSelector){ |
|
| 37 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
| 36 | + public function autoGetOnClick($targetSelector) { |
|
| 37 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function contentAsString(){ |
|
| 40 | + public function contentAsString() { |
|
| 41 | 41 | return implode("", $this->content); |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -23,19 +23,19 @@ |
||
| 23 | 23 | return $this; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function addGlyph($glyphicon,$before=true){ |
|
| 26 | + public function addGlyph($glyphicon, $before=true) { |
|
| 27 | 27 | $glyph=new HtmlGlyphicon(""); |
| 28 | 28 | $glyph->setGlyphicon($glyphicon); |
| 29 | - $this->addContent($glyph,$before); |
|
| 29 | + $this->addContent($glyph, $before); |
|
| 30 | 30 | return $this; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function wrapContentWithGlyph($glyphBefore,$glyphAfter=""){ |
|
| 33 | + public function wrapContentWithGlyph($glyphBefore, $glyphAfter="") { |
|
| 34 | 34 | $before=HtmlGlyphicon::getGlyphicon($glyphBefore)." "; |
| 35 | 35 | $after=""; |
| 36 | - if($glyphAfter!==""){ |
|
| 36 | + if ($glyphAfter!=="") { |
|
| 37 | 37 | $after=" ".HtmlGlyphicon::getGlyphicon($glyphAfter); |
| 38 | 38 | } |
| 39 | - return $this->wrapContent($before,$after); |
|
| 39 | + return $this->wrapContent($before, $after); |
|
| 40 | 40 | } |
| 41 | 41 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | parent::__construct($identifier); |
| 28 | 28 | $this->tagName="ul"; |
| 29 | 29 | $this->_template='<%tagName% id="%identifier%" class="nav navbar-nav %class%">%elements%</%tagName%>'; |
| 30 | - $this->elements=array (); |
|
| 30 | + $this->elements=array(); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function setClass($value) { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function addElement($element) { |
| 42 | - if($element instanceof HtmlLink){ |
|
| 42 | + if ($element instanceof HtmlLink) { |
|
| 43 | 43 | $this->addLink($element); |
| 44 | 44 | } else if (is_object($element)) { |
| 45 | 45 | $this->elements []=$element; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | public function addElements($elements) { |
| 61 | 61 | if (\is_array($elements)) { |
| 62 | - foreach ( $elements as $key => $element ) { |
|
| 62 | + foreach ($elements as $key => $element) { |
|
| 63 | 63 | $iid=$this->getElementsCount()+1; |
| 64 | 64 | if ($element instanceof HtmlDropdownItem) |
| 65 | 65 | $this->elements []=$element; |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | public function addLink($caption, $href="#") { |
| 88 | 88 | $iid=$this->getElementsCount()+1; |
| 89 | 89 | $li=new HtmlBsDoubleElement($this->identifier."-li-".$iid, "li"); |
| 90 | - if($caption instanceof HtmlLink){ |
|
| 90 | + if ($caption instanceof HtmlLink) { |
|
| 91 | 91 | $link=$caption; |
| 92 | - }else{ |
|
| 92 | + } else { |
|
| 93 | 93 | $link=new HtmlLink($this->identifier."-link-".$iid, $href, $caption); |
| 94 | 94 | } |
| 95 | 95 | $li->setContent($link); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | public function run(JsUtils $js) { |
| 125 | - foreach ( $this->elements as $element ) { |
|
| 125 | + foreach ($this->elements as $element) { |
|
| 126 | 126 | $element->run($js); |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @param int $index |
| 144 | 144 | * @return BaseHtml |
| 145 | 145 | */ |
| 146 | - public function getElement($index){ |
|
| 146 | + public function getElement($index) { |
|
| 147 | 147 | return $this->elements[$index]; |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -62,15 +62,15 @@ |
||
| 62 | 62 | */ |
| 63 | 63 | public function setIdentifier($identifier) { |
| 64 | 64 | parent::setIdentifier($identifier); |
| 65 | - if($this->content instanceof HtmlLink){ |
|
| 65 | + if ($this->content instanceof HtmlLink) { |
|
| 66 | 66 | $this->content->setIdentifier("link-".$identifier); |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | - public function setActive($value=true){ |
|
| 70 | - $this->setProperty("class", ($value)?"active":""); |
|
| 69 | + public function setActive($value=true) { |
|
| 70 | + $this->setProperty("class", ($value) ? "active" : ""); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function disable(){ |
|
| 73 | + public function disable() { |
|
| 74 | 74 | $this->setProperty("class", "disabled"); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -4,34 +4,34 @@ |
||
| 4 | 4 | |
| 5 | 5 | use micro\controllers\Startup; |
| 6 | 6 | use micro\utils\RequestUtils; |
| 7 | -class JsUtils extends \Ajax\JsUtils{ |
|
| 7 | +class JsUtils extends \Ajax\JsUtils { |
|
| 8 | 8 | |
| 9 | - public function getUrl($url){ |
|
| 9 | + public function getUrl($url) { |
|
| 10 | 10 | return RequestUtils::getUrl($url); |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - public function addViewElement($identifier,$content,&$view){ |
|
| 13 | + public function addViewElement($identifier, $content, &$view) { |
|
| 14 | 14 | $controls=$view->getVar("q"); |
| 15 | - if (isset($controls) === false) { |
|
| 16 | - $controls=array (); |
|
| 15 | + if (isset($controls)===false) { |
|
| 16 | + $controls=array(); |
|
| 17 | 17 | } |
| 18 | 18 | $controls[$identifier]=$content; |
| 19 | 19 | $view->setVar("q", $controls); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
| 23 | - $view->setVar($view_var,$output); |
|
| 22 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
| 23 | + $view->setVar($view_var, $output); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function forward($initialController,$controller,$action,$params=array()){ |
|
| 27 | - return $initialController->forward($controller,$action,$params,true,true,true); |
|
| 26 | + public function forward($initialController, $controller, $action, $params=array()) { |
|
| 27 | + return $initialController->forward($controller, $action, $params, true, true, true); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
| 31 | - return $initialControllerInstance->loadView($viewName,$params,true); |
|
| 30 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
| 31 | + return $initialControllerInstance->loadView($viewName, $params, true); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function fromDispatcher($dispatcher){ |
|
| 34 | + public function fromDispatcher($dispatcher) { |
|
| 35 | 35 | return Startup::$urlParts; |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -4,24 +4,24 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Support\Facades\App; |
| 6 | 6 | |
| 7 | -class JsUtils extends \Ajax\JsUtils{ |
|
| 8 | - public function getUrl($url){ |
|
| 7 | +class JsUtils extends \Ajax\JsUtils { |
|
| 8 | + public function getUrl($url) { |
|
| 9 | 9 | return \url($url); |
| 10 | 10 | } |
| 11 | - public function addViewElement($identifier,$content,&$view){ |
|
| 11 | + public function addViewElement($identifier, $content, &$view) { |
|
| 12 | 12 | $controls=$view->__get("q"); |
| 13 | - if (isset($controls) === false) { |
|
| 14 | - $controls=array (); |
|
| 13 | + if (isset($controls)===false) { |
|
| 14 | + $controls=array(); |
|
| 15 | 15 | } |
| 16 | 16 | $controls[$identifier]=$content; |
| 17 | 17 | $view->__set("q", $controls); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
| 21 | - $view->__set($view_var,$output); |
|
| 20 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
| 21 | + $view->__set($view_var, $output); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
| 24 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
| 25 | 25 | \ob_start(); |
| 26 | 26 | App::make($controllerName)->{$actionName}($params); |
| 27 | 27 | $result=\ob_get_contents(); |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | return $result; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
| 33 | - return \view()->make($viewName,$params)->render(); |
|
| 32 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
| 33 | + return \view()->make($viewName, $params)->render(); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function fromDispatcher($dispatcher){ |
|
| 36 | + public function fromDispatcher($dispatcher) { |
|
| 37 | 37 | return $dispatcher->segments(); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -8,23 +8,23 @@ discard block |
||
| 8 | 8 | use Cake\Network\Response; |
| 9 | 9 | use Cake\Core\App; |
| 10 | 10 | |
| 11 | -class _JsUtils extends \Ajax\JsUtils{ |
|
| 12 | - public function getUrl($url){ |
|
| 11 | +class _JsUtils extends \Ajax\JsUtils { |
|
| 12 | + public function getUrl($url) { |
|
| 13 | 13 | return Router::url($url); |
| 14 | 14 | } |
| 15 | - public function addViewElement($identifier,$content,&$view){ |
|
| 15 | + public function addViewElement($identifier, $content, &$view) { |
|
| 16 | 16 | $viewVars=$view->viewVars; |
| 17 | - if (isset($viewVars["q"]) === false) { |
|
| 18 | - $controls=array (); |
|
| 19 | - }else{ |
|
| 17 | + if (isset($viewVars["q"])===false) { |
|
| 18 | + $controls=array(); |
|
| 19 | + } else { |
|
| 20 | 20 | $controls=$viewVars["q"]; |
| 21 | 21 | } |
| 22 | 22 | $controls[$identifier]=$content; |
| 23 | 23 | $view->set("q", $controls); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
| 27 | - $view->set($view_var,$output); |
|
| 26 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
| 27 | + $view->set($view_var, $output); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -34,18 +34,18 @@ discard block |
||
| 34 | 34 | * @param array $params |
| 35 | 35 | * @see \Ajax\JsUtils::forward() |
| 36 | 36 | */ |
| 37 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=array()){ |
|
| 37 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=array()) { |
|
| 38 | 38 | \ob_start(); |
| 39 | - if(isset($params) && !\is_array($params)){ |
|
| 39 | + if (isset($params) && !\is_array($params)) { |
|
| 40 | 40 | $params=[$params]; |
| 41 | 41 | } |
| 42 | 42 | $url=h(Router::url(\array_merge([ |
| 43 | 43 | 'controller' => $controllerName, |
| 44 | - 'action' => $actionName],$params),false |
|
| 44 | + 'action' => $actionName], $params), false |
|
| 45 | 45 | )); |
| 46 | 46 | $base=Router::url("/"); |
| 47 | - if (substr($url, 0, strlen($base)) == $base) { |
|
| 48 | - $url = substr($url, strlen($base)); |
|
| 47 | + if (substr($url, 0, strlen($base))==$base) { |
|
| 48 | + $url=substr($url, strlen($base)); |
|
| 49 | 49 | } |
| 50 | 50 | $initialControllerInstance->requestAction($url); |
| 51 | 51 | $result=\ob_get_contents(); |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | return $result; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
| 57 | - $view = new View(Router::getRequest(true), new Response()); |
|
| 58 | - if(\is_array($params)){ |
|
| 59 | - foreach ($params as $k=>$v){ |
|
| 56 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
| 57 | + $view=new View(Router::getRequest(true), new Response()); |
|
| 58 | + if (\is_array($params)) { |
|
| 59 | + foreach ($params as $k=>$v) { |
|
| 60 | 60 | $view->set($k, $v); |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | return $view->render($viewName); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function fromDispatcher($dispatcher){ |
|
| 66 | + public function fromDispatcher($dispatcher) { |
|
| 67 | 67 | return \explode("/", Router::getRequest(true)->url); |
| 68 | 68 | } |
| 69 | 69 | } |