@@ -37,36 +37,36 @@ 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,$name=""){ |
|
| 55 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 56 | 56 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - protected function _getFieldName($index){ |
|
| 59 | + protected function _getFieldName($index) { |
|
| 60 | 60 | return $this->_instanceViewer->getFieldName($index); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - protected function _getFieldCaption($index){ |
|
| 63 | + protected function _getFieldCaption($index) { |
|
| 64 | 64 | return $this->_instanceViewer->getCaption($index); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
| 67 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
| 68 | 68 | |
| 69 | - public function show($modelInstance){ |
|
| 69 | + public function show($modelInstance) { |
|
| 70 | 70 | $this->_modelInstance=$modelInstance; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -90,42 +90,42 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | abstract public function getHtmlComponent(); |
| 92 | 92 | |
| 93 | - public function setColor($color){ |
|
| 93 | + public function setColor($color) { |
|
| 94 | 94 | return $this->getHtmlComponent()->setColor($color); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | |
| 98 | - public function setCaptions($captions){ |
|
| 98 | + public function setCaptions($captions) { |
|
| 99 | 99 | $this->_instanceViewer->setCaptions($captions); |
| 100 | 100 | return $this; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public function setFields($fields){ |
|
| 103 | + public function setFields($fields) { |
|
| 104 | 104 | $this->_instanceViewer->setVisibleProperties($fields); |
| 105 | 105 | return $this; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function addField($field){ |
|
| 108 | + public function addField($field) { |
|
| 109 | 109 | $this->_instanceViewer->addField($field); |
| 110 | 110 | return $this; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public function insertField($index,$field){ |
|
| 113 | + public function insertField($index, $field) { |
|
| 114 | 114 | $this->_instanceViewer->insertField($index, $field); |
| 115 | 115 | return $this; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - public function insertInField($index,$field){ |
|
| 118 | + public function insertInField($index, $field) { |
|
| 119 | 119 | $this->_instanceViewer->insertInField($index, $field); |
| 120 | 120 | return $this; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public function setValueFunction($index,$callback){ |
|
| 123 | + public function setValueFunction($index, $callback) { |
|
| 124 | 124 | $this->_instanceViewer->setValueFunction($index, $callback); |
| 125 | 125 | return $this; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public function setIdentifierFunction($callback){ |
|
| 128 | + public function setIdentifierFunction($callback) { |
|
| 129 | 129 | $this->_instanceViewer->setIdentifierFunction($callback); |
| 130 | 130 | return $this; |
| 131 | 131 | } |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | /** |
| 134 | 134 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
| 135 | 135 | */ |
| 136 | - public function getToolbar(){ |
|
| 137 | - if(isset($this->_toolbar)===false){ |
|
| 136 | + public function getToolbar() { |
|
| 137 | + if (isset($this->_toolbar)===false) { |
|
| 138 | 138 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
| 139 | 139 | } |
| 140 | 140 | return $this->_toolbar; |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | * @param callable $callback function to call on $element |
| 147 | 147 | * @return \Ajax\common\html\HtmlDoubleElement |
| 148 | 148 | */ |
| 149 | - public function addInToolbar($element,$callback=NULL){ |
|
| 149 | + public function addInToolbar($element, $callback=NULL) { |
|
| 150 | 150 | $tb=$this->getToolbar(); |
| 151 | - if(isset($callback)){ |
|
| 152 | - if(\is_callable($callback)){ |
|
| 151 | + if (isset($callback)) { |
|
| 152 | + if (\is_callable($callback)) { |
|
| 153 | 153 | $callback($element); |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -162,9 +162,9 @@ discard block |
||
| 162 | 162 | * @param callable $callback function($element) |
| 163 | 163 | * @return \Ajax\common\html\HtmlDoubleElement |
| 164 | 164 | */ |
| 165 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
| 166 | - $result=$this->addInToolbar($caption,$callback); |
|
| 167 | - if(isset($icon)) |
|
| 165 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
| 166 | + $result=$this->addInToolbar($caption, $callback); |
|
| 167 | + if (isset($icon)) |
|
| 168 | 168 | $result->addIcon($icon); |
| 169 | 169 | return $result; |
| 170 | 170 | } |
@@ -174,14 +174,14 @@ discard block |
||
| 174 | 174 | * @param callable $callback function($element) |
| 175 | 175 | * @return \Ajax\common\Widget |
| 176 | 176 | */ |
| 177 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
| 178 | - if(JArray::isAssociative($items)){ |
|
| 179 | - foreach ($items as $icon=>$item){ |
|
| 180 | - $this->addItemInToolbar($item,$icon,$callback); |
|
| 177 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
| 178 | + if (JArray::isAssociative($items)) { |
|
| 179 | + foreach ($items as $icon=>$item) { |
|
| 180 | + $this->addItemInToolbar($item, $icon, $callback); |
|
| 181 | 181 | } |
| 182 | - }else{ |
|
| 183 | - foreach ($items as $item){ |
|
| 184 | - $this->addItemInToolbar($item,null,$callback); |
|
| 182 | + } else { |
|
| 183 | + foreach ($items as $item) { |
|
| 184 | + $this->addItemInToolbar($item, null, $callback); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | return $this; |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | * @param callable $callback function($element) |
| 194 | 194 | * @return \Ajax\common\html\HtmlDoubleElement |
| 195 | 195 | */ |
| 196 | - public function addDropdownInToolbar($value,$items,$callback=NULL){ |
|
| 196 | + public function addDropdownInToolbar($value, $items, $callback=NULL) { |
|
| 197 | 197 | $dd=$value; |
| 198 | 198 | if (\is_string($value)) { |
| 199 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
| 199 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
| 200 | 200 | } |
| 201 | - return $this->addInToolbar($dd,$callback); |
|
| 201 | + return $this->addInToolbar($dd, $callback); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | * @param callable $callback function($element) |
| 207 | 207 | * @return \Ajax\common\html\HtmlDoubleElement |
| 208 | 208 | */ |
| 209 | - public function addButtonInToolbar($caption,$callback=NULL){ |
|
| 210 | - $bt=new HtmlButton("",$caption); |
|
| 211 | - return $this->addInToolbar($bt,$callback); |
|
| 209 | + public function addButtonInToolbar($caption, $callback=NULL) { |
|
| 210 | + $bt=new HtmlButton("", $caption); |
|
| 211 | + return $this->addInToolbar($bt, $callback); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
@@ -217,9 +217,9 @@ discard block |
||
| 217 | 217 | * @param callable $callback function($element) |
| 218 | 218 | * @return \Ajax\common\html\HtmlDoubleElement |
| 219 | 219 | */ |
| 220 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
| 221 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
| 222 | - return $this->addInToolbar($bts,$callback); |
|
| 220 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
| 221 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
| 222 | + return $this->addInToolbar($bts, $callback); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -229,9 +229,9 @@ discard block |
||
| 229 | 229 | * @param boolean $labeled |
| 230 | 230 | * @return \Ajax\common\html\HtmlDoubleElement |
| 231 | 231 | */ |
| 232 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
| 233 | - $bt=new HtmlButton("",$caption); |
|
| 234 | - $bt->addIcon($icon,$before,$labeled); |
|
| 232 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
| 233 | + $bt=new HtmlButton("", $caption); |
|
| 234 | + $bt->addIcon($icon, $before, $labeled); |
|
| 235 | 235 | return $this->addInToolbar($bt); |
| 236 | 236 | } |
| 237 | 237 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model |
| 262 | 262 | * @return \Ajax\common\Widget |
| 263 | 263 | */ |
| 264 | - public function setDefaultValueFunction($defaultValueFunction){ |
|
| 264 | + public function setDefaultValueFunction($defaultValueFunction) { |
|
| 265 | 265 | $this->_instanceViewer->setDefaultValueFunction($defaultValueFunction); |
| 266 | 266 | return $this; |
| 267 | 267 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @param string|boolean $disable |
| 271 | 271 | * @return string |
| 272 | 272 | */ |
| 273 | - public function jsDisabled($disable=true){ |
|
| 273 | + public function jsDisabled($disable=true) { |
|
| 274 | 274 | return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");"; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -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 addEditButtonInToolbar($caption,$callback=NULL){ |
|
| 283 | - $bt=new HtmlButton($this->identifier."-editBtn",$caption); |
|
| 282 | + public function addEditButtonInToolbar($caption, $callback=NULL) { |
|
| 283 | + $bt=new HtmlButton($this->identifier."-editBtn", $caption); |
|
| 284 | 284 | $bt->setToggle(); |
| 285 | 285 | $bt->setActive($this->_edition); |
| 286 | 286 | $bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')"))); |
| 287 | - return $this->addInToolbar($bt,$callback); |
|
| 287 | + return $this->addInToolbar($bt, $callback); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | public function setToolbar(HtmlMenu $_toolbar) { |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | class HtmlForm extends HtmlSemCollection { |
| 21 | 21 | |
| 22 | - use FieldsTrait,FormTrait; |
|
| 22 | + use FieldsTrait, FormTrait; |
|
| 23 | 23 | /** |
| 24 | 24 | * @var array |
| 25 | 25 | */ |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public function __construct($identifier, $elements=array()) { |
| 34 | 34 | parent::__construct($identifier, "form", "ui form"); |
| 35 | - $this->_states=[ State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED ]; |
|
| 35 | + $this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED]; |
|
| 36 | 36 | $this->setProperty("name", $this->identifier); |
| 37 | - $this->_fields=array (); |
|
| 37 | + $this->_fields=array(); |
|
| 38 | 38 | $this->addItems($elements); |
| 39 | 39 | $this->_validationParams=[]; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - protected function getForm(){ |
|
| 42 | + protected function getForm() { |
|
| 43 | 43 | return $this; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | * @param string $caption |
| 61 | 61 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
| 62 | 62 | */ |
| 63 | - public function addDivider($caption=NULL){ |
|
| 64 | - return $this->addContent(new HtmlDivider("",$caption)); |
|
| 63 | + public function addDivider($caption=NULL) { |
|
| 64 | + return $this->addContent(new HtmlDivider("", $caption)); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public function addFields($fields=NULL, $label=NULL) { |
@@ -77,12 +77,12 @@ discard block |
||
| 77 | 77 | $label=NULL; |
| 78 | 78 | } |
| 79 | 79 | $this->_fields=\array_merge($this->_fields, $fields); |
| 80 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
|
| 80 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields); |
|
| 81 | 81 | } |
| 82 | 82 | if (isset($label)) |
| 83 | 83 | $fields=new HtmlFormField("", $fields, $label); |
| 84 | 84 | } else { |
| 85 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
|
| 85 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count()); |
|
| 86 | 86 | } |
| 87 | 87 | $this->addItem($fields); |
| 88 | 88 | return $fields; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | public function addItem($item) { |
| 92 | 92 | $item=parent::addItem($item); |
| 93 | - if (\is_subclass_of($item, HtmlFormField::class) === true) { |
|
| 93 | + if (\is_subclass_of($item, HtmlFormField::class)===true) { |
|
| 94 | 94 | $this->_fields[]=$item; |
| 95 | 95 | } |
| 96 | 96 | return $item; |
@@ -144,35 +144,35 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | |
| 146 | 146 | |
| 147 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 148 | - if(\sizeof($this->_validationParams)>0) |
|
| 147 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 148 | + if (\sizeof($this->_validationParams)>0) |
|
| 149 | 149 | $this->setProperty("novalidate", ""); |
| 150 | - return parent::compile($js,$view); |
|
| 150 | + return parent::compile($js, $view); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | public function run(JsUtils $js) { |
| 154 | 154 | $compo=NULL; |
| 155 | - foreach ($this->_fields as $field){ |
|
| 156 | - if($field instanceof HtmlFormField) |
|
| 155 | + foreach ($this->_fields as $field) { |
|
| 156 | + if ($field instanceof HtmlFormField) |
|
| 157 | 157 | $compo=$this->addCompoValidation($js, $compo, $field); |
| 158 | 158 | } |
| 159 | - foreach ($this->content as $field){ |
|
| 160 | - if($field instanceof HtmlFormFields){ |
|
| 159 | + foreach ($this->content as $field) { |
|
| 160 | + if ($field instanceof HtmlFormFields) { |
|
| 161 | 161 | $items=$field->getItems(); |
| 162 | - foreach ($items as $_field){ |
|
| 163 | - if($_field instanceof HtmlFormField) |
|
| 162 | + foreach ($items as $_field) { |
|
| 163 | + if ($_field instanceof HtmlFormField) |
|
| 164 | 164 | $compo=$this->addCompoValidation($js, $compo, $_field); |
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | - if(isset($compo)===false){ |
|
| 168 | + if (isset($compo)===false) { |
|
| 169 | 169 | return parent::run($js); |
| 170 | 170 | } |
| 171 | - $this->_runValidationParams($compo,$js); |
|
| 171 | + $this->_runValidationParams($compo, $js); |
|
| 172 | 172 | return $this->_bsComponent; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - public function addValidationParam($paramName,$paramValue){ |
|
| 175 | + public function addValidationParam($paramName, $paramValue) { |
|
| 176 | 176 | $this->_validationParams[$paramName]=$paramValue; |
| 177 | 177 | return $this; |
| 178 | 178 | } |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | * @property boolean $_edition |
| 22 | 22 | * @property mixed _modelInstance |
| 23 | 23 | */ |
| 24 | -trait FieldAsTrait{ |
|
| 24 | +trait FieldAsTrait { |
|
| 25 | 25 | |
| 26 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
| 27 | - abstract public function setValueFunction($index,$callback); |
|
| 26 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
| 27 | + abstract public function setValueFunction($index, $callback); |
|
| 28 | 28 | abstract protected function _getFieldName($index); |
| 29 | 29 | abstract protected function _getFieldCaption($index); |
| 30 | 30 | |
@@ -32,27 +32,27 @@ discard block |
||
| 32 | 32 | * @param HtmlFormField $element |
| 33 | 33 | * @param array $attributes |
| 34 | 34 | */ |
| 35 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
| 35 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
| 36 | 36 | $this->_addRules($element, $attributes); |
| 37 | - if(isset($attributes["callback"])){ |
|
| 37 | + if (isset($attributes["callback"])) { |
|
| 38 | 38 | $callback=$attributes["callback"]; |
| 39 | - if(\is_callable($callback)){ |
|
| 40 | - $callback($element,$this->_modelInstance,$index); |
|
| 39 | + if (\is_callable($callback)) { |
|
| 40 | + $callback($element, $this->_modelInstance, $index); |
|
| 41 | 41 | unset($attributes["callback"]); |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | $element->fromArray($attributes); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - private function _getLabelField($caption,$icon=NULL){ |
|
| 48 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
| 47 | + private function _getLabelField($caption, $icon=NULL) { |
|
| 48 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
| 49 | 49 | return $label; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - protected function _addRules($element,&$attributes){ |
|
| 53 | - if(isset($attributes["rules"])){ |
|
| 52 | + protected function _addRules($element, &$attributes) { |
|
| 53 | + if (isset($attributes["rules"])) { |
|
| 54 | 54 | $rules=$attributes["rules"]; |
| 55 | - if(\is_array($rules)){ |
|
| 55 | + if (\is_array($rules)) { |
|
| 56 | 56 | $element->addRules($rules); |
| 57 | 57 | } |
| 58 | 58 | else |
@@ -61,18 +61,18 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
|
| 65 | - $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
|
| 64 | + protected function _fieldAs($elementCallback, $index, $attributes=NULL, $prefix=null) { |
|
| 65 | + $this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback, $prefix){ |
|
| 66 | 66 | $caption=$this->_getFieldCaption($index); |
| 67 | 67 | $name=$this->_getFieldName($index); |
| 68 | - $id=$this->_getFieldIdentifier($prefix,$name); |
|
| 69 | - if(isset($attributes["name"])){ |
|
| 68 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
| 69 | + if (isset($attributes["name"])) { |
|
| 70 | 70 | $name=$attributes["name"]; |
| 71 | 71 | unset($attributes["name"]); |
| 72 | 72 | } |
| 73 | - $element=$elementCallback($id,$name,$value,$caption); |
|
| 74 | - if(\is_array($attributes)){ |
|
| 75 | - $this->_applyAttributes($element, $attributes,$index); |
|
| 73 | + $element=$elementCallback($id, $name, $value, $caption); |
|
| 74 | + if (\is_array($attributes)) { |
|
| 75 | + $this->_applyAttributes($element, $attributes, $index); |
|
| 76 | 76 | } |
| 77 | 77 | $element->setDisabled(!$this->_edition); |
| 78 | 78 | return $element; |
@@ -81,115 +81,115 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
| 84 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
| 85 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
| 86 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
| 84 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
| 85 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
| 86 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
| 87 | 87 | return $pb; |
| 88 | 88 | }); |
| 89 | 89 | return $this; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
| 93 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
| 94 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
| 92 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
| 93 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
| 94 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
| 95 | 95 | return $rating; |
| 96 | 96 | }); |
| 97 | 97 | return $this; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function fieldAsLabel($index,$icon=NULL){ |
|
| 101 | - $this->setValueFunction($index,function($caption) use($icon){ |
|
| 102 | - $lbl=$this->_getLabelField($caption,$icon); |
|
| 100 | + public function fieldAsLabel($index, $icon=NULL) { |
|
| 101 | + $this->setValueFunction($index, function($caption) use($icon){ |
|
| 102 | + $lbl=$this->_getLabelField($caption, $icon); |
|
| 103 | 103 | return $lbl; |
| 104 | 104 | }); |
| 105 | 105 | return $this; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
| 109 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
| 110 | - $header=new HtmlHeader($id,$niveau,$value); |
|
| 111 | - if(isset($icon)) |
|
| 108 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
| 109 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
| 110 | + $header=new HtmlHeader($id, $niveau, $value); |
|
| 111 | + if (isset($icon)) |
|
| 112 | 112 | $header->asIcon($icon, $value); |
| 113 | 113 | return $header; |
| 114 | - }, $index,$attributes,"header"); |
|
| 114 | + }, $index, $attributes, "header"); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
| 118 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
| 119 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
| 120 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
| 118 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
| 119 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
| 120 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
| 121 | 121 | return $image; |
| 122 | 122 | }); |
| 123 | 123 | return $this; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
| 127 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 128 | - $img=new HtmlImage($id,$value); |
|
| 126 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
| 127 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 128 | + $img=new HtmlImage($id, $value); |
|
| 129 | 129 | $img->asAvatar(); |
| 130 | 130 | return $img; |
| 131 | - }, $index,$attributes,"avatar"); |
|
| 131 | + }, $index, $attributes, "avatar"); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
| 135 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 136 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
| 134 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
| 135 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 136 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
| 137 | 137 | return $input; |
| 138 | - }, $index,$attributes,"radio"); |
|
| 138 | + }, $index, $attributes, "radio"); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
| 142 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
| 143 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
| 144 | - }, $index,$attributes,"radios"); |
|
| 141 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
| 142 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
| 143 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
| 144 | + }, $index, $attributes, "radios"); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public function fieldAsInput($index,$attributes=NULL){ |
|
| 148 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 149 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
| 147 | + public function fieldAsInput($index, $attributes=NULL) { |
|
| 148 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 149 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
| 150 | 150 | $input->setName($name); |
| 151 | 151 | return $input; |
| 152 | - }, $index,$attributes,"input"); |
|
| 152 | + }, $index, $attributes, "input"); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
| 156 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 157 | - $textarea=new HtmlFormTextarea($id,null,$value); |
|
| 155 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
| 156 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 157 | + $textarea=new HtmlFormTextarea($id, null, $value); |
|
| 158 | 158 | $textarea->setName($name); |
| 159 | 159 | return $textarea; |
| 160 | - }, $index,$attributes,"textarea"); |
|
| 160 | + }, $index, $attributes, "textarea"); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
| 164 | - if(!\is_array($attributes)){ |
|
| 163 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
| 164 | + if (!\is_array($attributes)) { |
|
| 165 | 165 | $attributes=[]; |
| 166 | 166 | } |
| 167 | 167 | $attributes["imputType"]="hidden"; |
| 168 | - return $this->fieldAsInput($index,$attributes); |
|
| 168 | + return $this->fieldAsInput($index, $attributes); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
| 172 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 173 | - $input=new HtmlFormCheckbox($id,NULL,$this->_instanceViewer->getIdentifier()); |
|
| 171 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
| 172 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 173 | + $input=new HtmlFormCheckbox($id, NULL, $this->_instanceViewer->getIdentifier()); |
|
| 174 | 174 | $input->setChecked(JString::isBooleanTrue($value)); |
| 175 | 175 | $input->setName($name); |
| 176 | 176 | return $input; |
| 177 | - }, $index,$attributes,"ck"); |
|
| 177 | + }, $index, $attributes, "ck"); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
| 181 | - return $this->_fieldAs(function($id,$name,$value) use($elements,$multiple){ |
|
| 182 | - $dd=new HtmlFormDropdown($id,$elements,NULL,$value); |
|
| 183 | - $dd->asSelect($name,$multiple); |
|
| 180 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
| 181 | + return $this->_fieldAs(function($id, $name, $value) use($elements, $multiple){ |
|
| 182 | + $dd=new HtmlFormDropdown($id, $elements, NULL, $value); |
|
| 183 | + $dd->asSelect($name, $multiple); |
|
| 184 | 184 | return $dd; |
| 185 | - }, $index,$attributes,"dd"); |
|
| 185 | + }, $index, $attributes, "dd"); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
| 189 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 190 | - $mess= new HtmlMessage("message-".$id,$value); |
|
| 188 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
| 189 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 190 | + $mess=new HtmlMessage("message-".$id, $value); |
|
| 191 | 191 | $mess->addHeader($caption); |
| 192 | 192 | return $mess; |
| 193 | - }, $index,$attributes,"message"); |
|
| 193 | + }, $index, $attributes, "message"); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | \ No newline at end of file |
@@ -21,48 +21,48 @@ discard block |
||
| 21 | 21 | use FormTrait; |
| 22 | 22 | |
| 23 | 23 | public function __construct($identifier, $modelInstance=NULL) { |
| 24 | - parent::__construct($identifier, null,$modelInstance); |
|
| 24 | + parent::__construct($identifier, null, $modelInstance); |
|
| 25 | 25 | $this->_init(new FormInstanceViewer($identifier), "form", new HtmlForm($identifier), true); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
| 28 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 29 | 29 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 32 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 33 | 33 | $this->_instanceViewer->setInstance($this->_modelInstance); |
| 34 | 34 | |
| 35 | 35 | $form=$this->content["form"]; |
| 36 | 36 | $this->_generateContent($form); |
| 37 | 37 | |
| 38 | - if(isset($this->_toolbar)){ |
|
| 38 | + if (isset($this->_toolbar)) { |
|
| 39 | 39 | $this->_setToolbarPosition($form); |
| 40 | 40 | } |
| 41 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
| 42 | - return parent::compile($js,$view); |
|
| 41 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
| 42 | + return parent::compile($js, $view); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * @param HtmlForm $form |
| 47 | 47 | */ |
| 48 | - protected function _generateContent($form){ |
|
| 49 | - $values= $this->_instanceViewer->getValues(); |
|
| 48 | + protected function _generateContent($form) { |
|
| 49 | + $values=$this->_instanceViewer->getValues(); |
|
| 50 | 50 | $count=$this->_instanceViewer->count(); |
| 51 | 51 | |
| 52 | 52 | $separators=$this->_instanceViewer->getSeparators(); |
| 53 | 53 | $size=\sizeof($separators); |
| 54 | - if($size===1){ |
|
| 55 | - foreach ($values as $v){ |
|
| 54 | + if ($size===1) { |
|
| 55 | + foreach ($values as $v) { |
|
| 56 | 56 | $form->addField($v); |
| 57 | 57 | } |
| 58 | - }else{ |
|
| 58 | + } else { |
|
| 59 | 59 | $separators[]=$count; |
| 60 | - for($i=0;$i<$size;$i++){ |
|
| 61 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
| 60 | + for ($i=0; $i<$size; $i++) { |
|
| 61 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
| 62 | 62 | //TODO check why $fields is empty |
| 63 | - if(\sizeof($fields)===1){ |
|
| 63 | + if (\sizeof($fields)===1) { |
|
| 64 | 64 | $form->addField($fields[0]); |
| 65 | - }elseif(\sizeof($fields)>1){ |
|
| 65 | + }elseif (\sizeof($fields)>1) { |
|
| 66 | 66 | $form->addFields($fields); |
| 67 | 67 | $i+=\sizeof($fields)-1; |
| 68 | 68 | } |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | /** |
| 74 | 74 | * @return HtmlForm |
| 75 | 75 | */ |
| 76 | - protected function getForm(){ |
|
| 76 | + protected function getForm() { |
|
| 77 | 77 | return $this->content["form"]; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function addSeparatorAfter($fieldNum){ |
|
| 80 | + public function addSeparatorAfter($fieldNum) { |
|
| 81 | 81 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
| 82 | 82 | return $this; |
| 83 | 83 | } |
@@ -91,26 +91,26 @@ discard block |
||
| 91 | 91 | return $this; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){ |
|
| 95 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
| 96 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement); |
|
| 94 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) { |
|
| 95 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
| 96 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement); |
|
| 97 | 97 | return $this->addInToolbar($button); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
| 101 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle){ |
|
| 102 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 103 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement); |
|
| 100 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
| 101 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle){ |
|
| 102 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 103 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement); |
|
| 104 | 104 | return $button; |
| 105 | - }, $index,$attributes); |
|
| 105 | + }, $index, $attributes); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 109 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
| 110 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 108 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 109 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
| 110 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 111 | 111 | $button->setProperty("type", "reset"); |
| 112 | 112 | return $button; |
| 113 | - }, $index,$attributes); |
|
| 113 | + }, $index, $attributes); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -15,22 +15,22 @@ discard block |
||
| 15 | 15 | * @property object $_modelInstance |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -trait FormFieldAsTrait{ |
|
| 18 | +trait FormFieldAsTrait { |
|
| 19 | 19 | |
| 20 | 20 | abstract protected function _getFieldIdentifier($prefix); |
| 21 | - abstract public function setValueFunction($index,$callback); |
|
| 22 | - abstract protected function _applyAttributes($element,&$attributes,$index); |
|
| 21 | + abstract public function setValueFunction($index, $callback); |
|
| 22 | + abstract protected function _applyAttributes($element, &$attributes, $index); |
|
| 23 | 23 | abstract public function getIdentifier(); |
| 24 | 24 | |
| 25 | - private function _getLabelField($caption,$icon=NULL){ |
|
| 26 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
| 25 | + private function _getLabelField($caption, $icon=NULL) { |
|
| 26 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
| 27 | 27 | return $label; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - protected function _addRules($element,&$attributes){ |
|
| 31 | - if(isset($attributes["rules"])){ |
|
| 30 | + protected function _addRules($element, &$attributes) { |
|
| 31 | + if (isset($attributes["rules"])) { |
|
| 32 | 32 | $rules=$attributes["rules"]; |
| 33 | - if(\is_array($rules)){ |
|
| 33 | + if (\is_array($rules)) { |
|
| 34 | 34 | $element->addRules($rules); |
| 35 | 35 | } |
| 36 | 36 | else |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
|
| 43 | - $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback){ |
|
| 42 | + protected function _fieldAs($elementCallback, $index, $attributes=NULL, $prefix=null) { |
|
| 43 | + $this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback){ |
|
| 44 | 44 | $caption=$this->_instanceViewer->getCaption($index); |
| 45 | 45 | $name=$this->_instanceViewer->getFieldName($index); |
| 46 | - $element=$elementCallback($this->getIdentifier()."-".$name,$name,$value,$caption); |
|
| 47 | - if(\is_array($attributes)){ |
|
| 48 | - $this->_applyAttributes($element, $attributes,$index); |
|
| 46 | + $element=$elementCallback($this->getIdentifier()."-".$name, $name, $value, $caption); |
|
| 47 | + if (\is_array($attributes)) { |
|
| 48 | + $this->_applyAttributes($element, $attributes, $index); |
|
| 49 | 49 | } |
| 50 | 50 | return $element; |
| 51 | 51 | }); |
@@ -53,53 +53,53 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
| 57 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 58 | - return new HtmlFormRadio($id,$name,$caption,$value); |
|
| 59 | - }, $index,$attributes); |
|
| 56 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
| 57 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 58 | + return new HtmlFormRadio($id, $name, $caption, $value); |
|
| 59 | + }, $index, $attributes); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
| 63 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
| 64 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
| 65 | - }, $index,$attributes); |
|
| 62 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
| 63 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
| 64 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
| 65 | + }, $index, $attributes); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
| 69 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 70 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
| 68 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
| 69 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 70 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
| 71 | 71 | $textarea->setName($name); |
| 72 | 72 | return $textarea; |
| 73 | - }, $index,$attributes); |
|
| 73 | + }, $index, $attributes); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function fieldAsInput($index,$attributes=NULL){ |
|
| 77 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 78 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
| 76 | + public function fieldAsInput($index, $attributes=NULL) { |
|
| 77 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 78 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
| 79 | 79 | $input->setName($name); |
| 80 | 80 | return $input; |
| 81 | - }, $index,$attributes); |
|
| 81 | + }, $index, $attributes); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
| 85 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 86 | - return new HtmlFormCheckbox($id,$caption,$value); |
|
| 87 | - }, $index,$attributes); |
|
| 84 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
| 85 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 86 | + return new HtmlFormCheckbox($id, $caption, $value); |
|
| 87 | + }, $index, $attributes); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
| 91 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements,$multiple){ |
|
| 92 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value,$multiple); |
|
| 90 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
| 91 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple){ |
|
| 92 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value, $multiple); |
|
| 93 | 93 | $dd->setName($name); |
| 94 | 94 | return $dd; |
| 95 | - }, $index,$attributes); |
|
| 95 | + }, $index, $attributes); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
| 99 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 100 | - $mess= new HtmlMessage("message-".$id,$value); |
|
| 98 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
| 99 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 100 | + $mess=new HtmlMessage("message-".$id, $value); |
|
| 101 | 101 | $mess->addHeader($caption); |
| 102 | 102 | return $mess; |
| 103 | - }, $index,$attributes,"message"); |
|
| 103 | + }, $index, $attributes, "message"); |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | \ 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,"jqueryDone"=>"replaceWith"]); |
|
| 71 | + if (isset($this->_searchField) && isset($js)) { |
|
| 72 | + $this->_searchField->postOn("change", $this->_urls, "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
| 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,36 +116,36 @@ 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,"jqueryDone"=>"replaceWith"]); |
|
| 126 | + $menu->postOnClick($this->_urls, "{'p':$(this).attr('data-page')}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - protected function _getFieldName($index){ |
|
| 129 | + protected function _getFieldName($index) { |
|
| 130 | 130 | return parent::_getFieldName($index)."[]"; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - protected function _getFieldCaption($index){ |
|
| 133 | + protected function _getFieldCaption($index) { |
|
| 134 | 134 | return null; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
| 138 | - switch ($this->_toolbarPosition){ |
|
| 137 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
| 138 | + switch ($this->_toolbarPosition) { |
|
| 139 | 139 | case PositionInTable::BEFORETABLE: |
| 140 | 140 | case PositionInTable::AFTERTABLE: |
| 141 | - if(isset($this->_compileParts)===false){ |
|
| 141 | + if (isset($this->_compileParts)===false) { |
|
| 142 | 142 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 143 | 143 | } |
| 144 | 144 | break; |
| 145 | 145 | case PositionInTable::HEADER: |
| 146 | 146 | case PositionInTable::FOOTER: |
| 147 | 147 | case PositionInTable::BODY: |
| 148 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
| 148 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
| 149 | 149 | break; |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -157,23 +157,23 @@ discard block |
||
| 157 | 157 | * @param callable $callback function called after the field compilation |
| 158 | 158 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 159 | 159 | */ |
| 160 | - public function afterCompile($index,$callback){ |
|
| 161 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
| 160 | + public function afterCompile($index, $callback) { |
|
| 161 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
| 162 | 162 | return $this; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - private function addToolbarRow($part,$table,$captions){ |
|
| 165 | + private function addToolbarRow($part, $table, $captions) { |
|
| 166 | 166 | $hasPart=$table->hasPart($part); |
| 167 | - if($hasPart){ |
|
| 167 | + if ($hasPart) { |
|
| 168 | 168 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 169 | - }else{ |
|
| 169 | + } else { |
|
| 170 | 170 | $row=$table->getPart($part)->getRow(0); |
| 171 | 171 | } |
| 172 | 172 | $row->mergeCol(); |
| 173 | 173 | $row->setValues([$this->_toolbar]); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - public function getHtmlComponent(){ |
|
| 176 | + public function getHtmlComponent() { |
|
| 177 | 177 | return $this->content["table"]; |
| 178 | 178 | } |
| 179 | 179 | |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | return $this; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - public function paginate($items_per_page=10,$page=1){ |
|
| 190 | - $this->_pagination=new Pagination($items_per_page,4,$page); |
|
| 189 | + public function paginate($items_per_page=10, $page=1) { |
|
| 190 | + $this->_pagination=new Pagination($items_per_page, 4, $page); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | public function getHasCheckboxes() { |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | return $this; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - public function refresh($compileParts=["tbody"]){ |
|
| 202 | + public function refresh($compileParts=["tbody"]) { |
|
| 203 | 203 | $this->_compileParts=$compileParts; |
| 204 | 204 | return $this; |
| 205 | 205 | } |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | * @param callable $callback |
| 209 | 209 | * @return callable |
| 210 | 210 | */ |
| 211 | - private function getFieldButtonCallable($caption,$callback=null){ |
|
| 212 | - return $this->getCallable("getFieldButton",[$caption],$callback); |
|
| 211 | + private function getFieldButtonCallable($caption, $callback=null) { |
|
| 212 | + return $this->getCallable("getFieldButton", [$caption], $callback); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -218,16 +218,16 @@ discard block |
||
| 218 | 218 | * @param callable $callback |
| 219 | 219 | * @return callable |
| 220 | 220 | */ |
| 221 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
| 222 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
| 223 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
| 224 | - if(isset($callback)){ |
|
| 225 | - if(\is_callable($callback)){ |
|
| 226 | - $callback($object,$instance); |
|
| 221 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
| 222 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
| 223 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
| 224 | + if (isset($callback)) { |
|
| 225 | + if (\is_callable($callback)) { |
|
| 226 | + $callback($object, $instance); |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | - if($object instanceof HtmlSemDoubleElement){ |
|
| 230 | - $object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier()); |
|
| 229 | + if ($object instanceof HtmlSemDoubleElement) { |
|
| 230 | + $object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier()); |
|
| 231 | 231 | } |
| 232 | 232 | return $object; |
| 233 | 233 | }; |
@@ -238,8 +238,8 @@ discard block |
||
| 238 | 238 | * @param string $caption |
| 239 | 239 | * @return HtmlButton |
| 240 | 240 | */ |
| 241 | - private function getFieldButton($caption){ |
|
| 242 | - return new HtmlButton("",$caption); |
|
| 241 | + private function getFieldButton($caption) { |
|
| 242 | + return new HtmlButton("", $caption); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -248,8 +248,8 @@ discard block |
||
| 248 | 248 | * @param callable $callback |
| 249 | 249 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 250 | 250 | */ |
| 251 | - public function addFieldButton($caption,$callback=null){ |
|
| 252 | - $this->addField($this->getCallable("getFieldButton",[$caption],$callback)); |
|
| 251 | + public function addFieldButton($caption, $callback=null) { |
|
| 252 | + $this->addField($this->getCallable("getFieldButton", [$caption], $callback)); |
|
| 253 | 253 | return $this; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -260,8 +260,8 @@ discard block |
||
| 260 | 260 | * @param callable $callback |
| 261 | 261 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 262 | 262 | */ |
| 263 | - public function insertFieldButton($index,$caption,$callback=null){ |
|
| 264 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
| 263 | + public function insertFieldButton($index, $caption, $callback=null) { |
|
| 264 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
| 265 | 265 | return $this; |
| 266 | 266 | } |
| 267 | 267 | |
@@ -272,60 +272,60 @@ discard block |
||
| 272 | 272 | * @param callable $callback |
| 273 | 273 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 274 | 274 | */ |
| 275 | - public function insertInFieldButton($index,$caption,$callback=null){ |
|
| 276 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
| 275 | + public function insertInFieldButton($index, $caption, $callback=null) { |
|
| 276 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
| 277 | 277 | return $this; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - private function addDefaultButton($icon,$class=null,$callback=null){ |
|
| 281 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
|
| 280 | + private function addDefaultButton($icon, $class=null, $callback=null) { |
|
| 281 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class], $callback)); |
|
| 282 | 282 | return $this; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){ |
|
| 286 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
|
| 285 | + private function insertDefaultButtonIn($index, $icon, $class=null, $callback=null) { |
|
| 286 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class], $callback)); |
|
| 287 | 287 | return $this; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - private function getDefaultButton($icon,$class=null){ |
|
| 290 | + private function getDefaultButton($icon, $class=null) { |
|
| 291 | 291 | $bt=$this->getFieldButton(""); |
| 292 | 292 | $bt->asIcon($icon); |
| 293 | - if(isset($class)) |
|
| 293 | + if (isset($class)) |
|
| 294 | 294 | $bt->addToProperty("class", $class); |
| 295 | 295 | return $bt; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - public function addDeleteButton($callback=null){ |
|
| 299 | - return $this->addDefaultButton("remove","delete red basic",$callback); |
|
| 298 | + public function addDeleteButton($callback=null) { |
|
| 299 | + return $this->addDefaultButton("remove", "delete red basic", $callback); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - public function addEditButton($callback=null){ |
|
| 303 | - return $this->addDefaultButton("edit","edit basic",$callback); |
|
| 302 | + public function addEditButton($callback=null) { |
|
| 303 | + return $this->addDefaultButton("edit", "edit basic", $callback); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - public function addEditDeleteButtons($callbackEdit=null,$callbackDelete=null){ |
|
| 306 | + public function addEditDeleteButtons($callbackEdit=null, $callbackDelete=null) { |
|
| 307 | 307 | $this->addEditButton($callbackEdit); |
| 308 | 308 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
| 309 | - $this->insertDeleteButtonIn($index,$callbackDelete); |
|
| 309 | + $this->insertDeleteButtonIn($index, $callbackDelete); |
|
| 310 | 310 | return $this; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - public function insertDeleteButtonIn($index,$callback=null){ |
|
| 314 | - return $this->insertDefaultButtonIn($index,"remove","delete red basic",$callback); |
|
| 313 | + public function insertDeleteButtonIn($index, $callback=null) { |
|
| 314 | + return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $callback); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - public function insertEditButtonIn($index,$callback=null){ |
|
| 318 | - return $this->insertDefaultButtonIn($index,"edit","edit basic",$callback); |
|
| 317 | + public function insertEditButtonIn($index, $callback=null) { |
|
| 318 | + return $this->insertDefaultButtonIn($index, "edit", "edit basic", $callback); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
| 321 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
| 322 | 322 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - public function getSearchField(){ |
|
| 326 | - if(isset($this->_searchField)===false){ |
|
| 327 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
| 328 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
| 325 | + public function getSearchField() { |
|
| 326 | + if (isset($this->_searchField)===false) { |
|
| 327 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
| 328 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
| 329 | 329 | } |
| 330 | 330 | return $this->_searchField; |
| 331 | 331 | } |
@@ -19,41 +19,41 @@ |
||
| 19 | 19 | class DataElement extends Widget { |
| 20 | 20 | |
| 21 | 21 | public function __construct($identifier, $modelInstance=NULL) { |
| 22 | - parent::__construct($identifier, null,$modelInstance); |
|
| 23 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,2), false); |
|
| 22 | + parent::__construct($identifier, null, $modelInstance); |
|
| 23 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 2), false); |
|
| 24 | 24 | $this->content["table"]->setDefinition(); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 27 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 28 | 28 | $this->_instanceViewer->setInstance($this->_modelInstance); |
| 29 | 29 | |
| 30 | 30 | $table=$this->content["table"]; |
| 31 | 31 | $this->_generateContent($table); |
| 32 | 32 | |
| 33 | - if(isset($this->_toolbar)){ |
|
| 33 | + if (isset($this->_toolbar)) { |
|
| 34 | 34 | $this->_setToolbarPosition($table); |
| 35 | 35 | } |
| 36 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
| 37 | - return parent::compile($js,$view); |
|
| 36 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
| 37 | + return parent::compile($js, $view); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * @param HtmlTable $table |
| 42 | 42 | */ |
| 43 | - protected function _generateContent($table){ |
|
| 43 | + protected function _generateContent($table) { |
|
| 44 | 44 | $captions=$this->_instanceViewer->getCaptions(); |
| 45 | - $values= $this->_instanceViewer->getValues(); |
|
| 45 | + $values=$this->_instanceViewer->getValues(); |
|
| 46 | 46 | $count=$this->_instanceViewer->count(); |
| 47 | - for($i=0;$i<$count;$i++){ |
|
| 48 | - $table->addRow([$captions[$i],$values[$i]]); |
|
| 47 | + for ($i=0; $i<$count; $i++) { |
|
| 48 | + $table->addRow([$captions[$i], $values[$i]]); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - protected function _getFieldName($index){ |
|
| 52 | + protected function _getFieldName($index) { |
|
| 53 | 53 | return $this->_instanceViewer->getFieldName($index); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - protected function _getFieldCaption($index){ |
|
| 56 | + protected function _getFieldCaption($index) { |
|
| 57 | 57 | return null; |
| 58 | 58 | } |
| 59 | 59 | |