@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | * @param array $instances |
| 17 | 17 | * @return DataTable |
| 18 | 18 | */ |
| 19 | - public function dataTable($identifier,$model, $instances){ |
|
| 20 | - return $this->addHtmlComponent(new DataTable($identifier,$model,$instances)); |
|
| 19 | + public function dataTable($identifier, $model, $instances) { |
|
| 20 | + return $this->addHtmlComponent(new DataTable($identifier, $model, $instances)); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | * @param object $instance |
| 26 | 26 | * @return DataElement |
| 27 | 27 | */ |
| 28 | - public function dataElement($identifier, $instance){ |
|
| 29 | - return $this->addHtmlComponent(new DataElement($identifier,$instance)); |
|
| 28 | + public function dataElement($identifier, $instance) { |
|
| 29 | + return $this->addHtmlComponent(new DataElement($identifier, $instance)); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | * @param object $instance |
| 35 | 35 | * @return DataForm |
| 36 | 36 | */ |
| 37 | - public function dataForm($identifier, $instance){ |
|
| 38 | - return $this->addHtmlComponent(new DataForm($identifier,$instance)); |
|
| 37 | + public function dataForm($identifier, $instance) { |
|
| 38 | + return $this->addHtmlComponent(new DataForm($identifier, $instance)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function formLogin($identifier){ |
|
| 41 | + public function formLogin($identifier) { |
|
| 42 | 42 | return $this->addHtmlComponent(new FormLogin($identifier)); |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | \ No newline at end of file |
@@ -25,23 +25,23 @@ discard block |
||
| 25 | 25 | * @property boolean $_edition |
| 26 | 26 | * @property mixed _modelInstance |
| 27 | 27 | */ |
| 28 | -trait FieldAsTrait{ |
|
| 28 | +trait FieldAsTrait { |
|
| 29 | 29 | |
| 30 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
| 31 | - abstract public function setValueFunction($index,$callback); |
|
| 30 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
| 31 | + abstract public function setValueFunction($index, $callback); |
|
| 32 | 32 | abstract protected function _getFieldName($index); |
| 33 | 33 | abstract protected function _getFieldCaption($index); |
| 34 | - abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
|
| 34 | + abstract protected function _buttonAsSubmit(HtmlButton&$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @param HtmlFormField $element |
| 38 | 38 | * @param array $attributes |
| 39 | 39 | */ |
| 40 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
| 41 | - if(isset($attributes["callback"])){ |
|
| 40 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
| 41 | + if (isset($attributes["callback"])) { |
|
| 42 | 42 | $callback=$attributes["callback"]; |
| 43 | - if(\is_callable($callback)){ |
|
| 44 | - $callback($element,$this->_modelInstance,$index); |
|
| 43 | + if (\is_callable($callback)) { |
|
| 44 | + $callback($element, $this->_modelInstance, $index); |
|
| 45 | 45 | unset($attributes["callback"]); |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -51,43 +51,43 @@ discard block |
||
| 51 | 51 | $element->fromArray($attributes); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - private function _getLabelField($caption,$icon=NULL){ |
|
| 55 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
| 54 | + private function _getLabelField($caption, $icon=NULL) { |
|
| 55 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
| 56 | 56 | return $label; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
| 60 | - protected function _addRules($element,&$attributes){ |
|
| 61 | - if(isset($attributes["rules"])){ |
|
| 60 | + protected function _addRules($element, &$attributes) { |
|
| 61 | + if (isset($attributes["rules"])) { |
|
| 62 | 62 | $rules=$attributes["rules"]; |
| 63 | - if(\is_array($rules)){ |
|
| 63 | + if (\is_array($rules)) { |
|
| 64 | 64 | $element->addRules($rules); |
| 65 | 65 | } |
| 66 | - else{ |
|
| 66 | + else { |
|
| 67 | 67 | $element->addRule($rules); |
| 68 | 68 | } |
| 69 | 69 | unset($attributes["rules"]); |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - protected function _prepareFormFields(&$field,$name,&$attributes){ |
|
| 73 | + protected function _prepareFormFields(&$field, $name, &$attributes) { |
|
| 74 | 74 | $field->setName($name); |
| 75 | 75 | $this->_addRules($field, $attributes); |
| 76 | 76 | return $field; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
| 80 | - $this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){ |
|
| 79 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
| 80 | + $this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){ |
|
| 81 | 81 | $caption=$this->_getFieldCaption($index); |
| 82 | 82 | $name=$this->_getFieldName($index); |
| 83 | - $id=$this->_getFieldIdentifier($prefix,$name); |
|
| 84 | - if(isset($attributes["name"])){ |
|
| 83 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
| 84 | + if (isset($attributes["name"])) { |
|
| 85 | 85 | $name=$attributes["name"]; |
| 86 | 86 | unset($attributes["name"]); |
| 87 | 87 | } |
| 88 | - $element=$elementCallback($id,$name,$value,$caption); |
|
| 89 | - if(\is_array($attributes)){ |
|
| 90 | - $this->_applyAttributes($element, $attributes,$index); |
|
| 88 | + $element=$elementCallback($id, $name, $value, $caption); |
|
| 89 | + if (\is_array($attributes)) { |
|
| 90 | + $this->_applyAttributes($element, $attributes, $index); |
|
| 91 | 91 | } |
| 92 | 92 | $element->setDisabled(!$this->_edition); |
| 93 | 93 | return $element; |
@@ -96,169 +96,169 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | |
| 99 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
| 100 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
| 101 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
| 99 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
| 100 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
| 101 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
| 102 | 102 | return $pb; |
| 103 | 103 | }); |
| 104 | 104 | return $this; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
| 108 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
| 109 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
| 107 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
| 108 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
| 109 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
| 110 | 110 | return $rating; |
| 111 | 111 | }); |
| 112 | 112 | return $this; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - public function fieldAsLabel($index,$icon=NULL){ |
|
| 116 | - $this->setValueFunction($index,function($caption) use($icon){ |
|
| 117 | - $lbl=$this->_getLabelField($caption,$icon); |
|
| 115 | + public function fieldAsLabel($index, $icon=NULL) { |
|
| 116 | + $this->setValueFunction($index, function($caption) use($icon){ |
|
| 117 | + $lbl=$this->_getLabelField($caption, $icon); |
|
| 118 | 118 | return $lbl; |
| 119 | 119 | }); |
| 120 | 120 | return $this; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
| 124 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
| 125 | - $header=new HtmlHeader($id,$niveau,$value); |
|
| 126 | - if(isset($icon)) |
|
| 123 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
| 124 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
| 125 | + $header=new HtmlHeader($id, $niveau, $value); |
|
| 126 | + if (isset($icon)) |
|
| 127 | 127 | $header->asIcon($icon, $value); |
| 128 | 128 | return $header; |
| 129 | - }, $index,$attributes,"header"); |
|
| 129 | + }, $index, $attributes, "header"); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | |
| 133 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
| 134 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
| 135 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
| 133 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
| 134 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
| 135 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
| 136 | 136 | return $image; |
| 137 | 137 | }); |
| 138 | 138 | return $this; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
| 142 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 143 | - $img=new HtmlImage($id,$value); |
|
| 141 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
| 142 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 143 | + $img=new HtmlImage($id, $value); |
|
| 144 | 144 | $img->asAvatar(); |
| 145 | 145 | return $img; |
| 146 | - }, $index,$attributes,"avatar"); |
|
| 146 | + }, $index, $attributes, "avatar"); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
| 150 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 151 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
| 149 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
| 150 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 151 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
| 152 | 152 | return $input; |
| 153 | - }, $index,$attributes,"radio"); |
|
| 153 | + }, $index, $attributes, "radio"); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
| 157 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
| 158 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
| 159 | - }, $index,$attributes,"radios"); |
|
| 156 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
| 157 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
| 158 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
| 159 | + }, $index, $attributes, "radios"); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public function fieldAsInput($index,$attributes=NULL){ |
|
| 163 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
| 164 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
| 162 | + public function fieldAsInput($index, $attributes=NULL) { |
|
| 163 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
| 164 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
| 165 | 165 | return $this->_prepareFormFields($input, $name, $attributes); |
| 166 | - }, $index,$attributes,"input"); |
|
| 166 | + }, $index, $attributes, "input"); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
| 170 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 171 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
| 169 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
| 170 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 171 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
| 172 | 172 | $textarea->setName($name); |
| 173 | 173 | return $textarea; |
| 174 | - }, $index,$attributes,"textarea"); |
|
| 174 | + }, $index, $attributes, "textarea"); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
| 178 | - if(!\is_array($attributes)){ |
|
| 177 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
| 178 | + if (!\is_array($attributes)) { |
|
| 179 | 179 | $attributes=[]; |
| 180 | 180 | } |
| 181 | 181 | $attributes["imputType"]="hidden"; |
| 182 | - return $this->fieldAsInput($index,$attributes); |
|
| 182 | + return $this->fieldAsInput($index, $attributes); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
| 186 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 187 | - $input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier()); |
|
| 185 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
| 186 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 187 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
| 188 | 188 | $input->setChecked(JString::isBooleanTrue($value)); |
| 189 | 189 | $input->setName($name); |
| 190 | 190 | return $input; |
| 191 | - }, $index,$attributes,"ck"); |
|
| 191 | + }, $index, $attributes, "ck"); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
| 195 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple){ |
|
| 196 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value); |
|
| 197 | - $dd->asSelect($name,$multiple); |
|
| 194 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
| 195 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple){ |
|
| 196 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value); |
|
| 197 | + $dd->asSelect($name, $multiple); |
|
| 198 | 198 | return $dd; |
| 199 | - }, $index,$attributes,"dd"); |
|
| 199 | + }, $index, $attributes, "dd"); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
| 203 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 204 | - $mess= new HtmlMessage("message-".$id,$caption); |
|
| 202 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
| 203 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 204 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
| 205 | 205 | $mess->addHeader($value); |
| 206 | 206 | return $mess; |
| 207 | - }, $index,$attributes,"message"); |
|
| 207 | + }, $index, $attributes, "message"); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - public function fieldAsLink($index,$attributes=NULL){ |
|
| 211 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 212 | - $lnk= new HtmlLink("message-".$id,"#",$caption); |
|
| 210 | + public function fieldAsLink($index, $attributes=NULL) { |
|
| 211 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 212 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
| 213 | 213 | return $lnk; |
| 214 | - }, $index,$attributes,"link"); |
|
| 214 | + }, $index, $attributes, "link"); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /**Change fields type |
| 218 | 218 | * @param array $types an array or associative array $type=>$attributes |
| 219 | 219 | */ |
| 220 | - public function fieldsAs(array $types){ |
|
| 220 | + public function fieldsAs(array $types) { |
|
| 221 | 221 | $i=0; |
| 222 | - if(JArray::isAssociative($types)){ |
|
| 223 | - foreach ($types as $type=>$attributes){ |
|
| 224 | - if(\is_int($type)) |
|
| 225 | - $this->fieldAs($i++,$attributes,[]); |
|
| 226 | - else{ |
|
| 227 | - $type=preg_replace('/\d/', '', $type ); |
|
| 228 | - $this->fieldAs($i++,$type,[$attributes]); |
|
| 222 | + if (JArray::isAssociative($types)) { |
|
| 223 | + foreach ($types as $type=>$attributes) { |
|
| 224 | + if (\is_int($type)) |
|
| 225 | + $this->fieldAs($i++, $attributes, []); |
|
| 226 | + else { |
|
| 227 | + $type=preg_replace('/\d/', '', $type); |
|
| 228 | + $this->fieldAs($i++, $type, [$attributes]); |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | - }else{ |
|
| 232 | - foreach ($types as $type){ |
|
| 233 | - $this->fieldAs($i++,$type); |
|
| 231 | + } else { |
|
| 232 | + foreach ($types as $type) { |
|
| 233 | + $this->fieldAs($i++, $type); |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - public function fieldAs($index,$type,$attributes=NULL){ |
|
| 238 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
| 239 | 239 | $method="fieldAs".\ucfirst($type); |
| 240 | - if(\method_exists($this, $method)){ |
|
| 241 | - if(!\is_array($attributes)){ |
|
| 240 | + if (\method_exists($this, $method)) { |
|
| 241 | + if (!\is_array($attributes)) { |
|
| 242 | 242 | $attributes=[$index]; |
| 243 | - }else{ |
|
| 243 | + } else { |
|
| 244 | 244 | \array_unshift($attributes, $index); |
| 245 | 245 | } |
| 246 | - \call_user_func_array([$this,$method], $attributes); |
|
| 246 | + \call_user_func_array([$this, $method], $attributes); |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
| 251 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
| 252 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 253 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]); |
|
| 250 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
| 251 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
| 252 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 253 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
|
| 254 | 254 | return $button; |
| 255 | - }, $index,$attributes,"submit"); |
|
| 255 | + }, $index, $attributes, "submit"); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 259 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
| 260 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 258 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 259 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
| 260 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 261 | 261 | return $button; |
| 262 | - }, $index,$attributes,"button"); |
|
| 262 | + }, $index, $attributes, "button"); |
|
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | \ No newline at end of file |
@@ -18,207 +18,207 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | public static $index=0; |
| 20 | 20 | |
| 21 | - public function __construct($identifier,$instance=NULL,$captions=NULL){ |
|
| 21 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
| 22 | 22 | $this->widgetIdentifier=$identifier; |
| 23 | 23 | $this->values=[]; |
| 24 | 24 | $this->afterCompile=[]; |
| 25 | - if(isset($instance)) |
|
| 25 | + if (isset($instance)) |
|
| 26 | 26 | $this->setInstance($instance); |
| 27 | 27 | $this->setCaptions($captions); |
| 28 | 28 | $this->captionCallback=NULL; |
| 29 | - $this->defaultValueFunction=function($name,$value){return $value;}; |
|
| 29 | + $this->defaultValueFunction=function($name, $value) {return $value; }; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function moveFieldTo($from,$to){ |
|
| 33 | - if(JArray::moveElementTo($this->visibleProperties, $from, $to)){ |
|
| 32 | + public function moveFieldTo($from, $to) { |
|
| 33 | + if (JArray::moveElementTo($this->visibleProperties, $from, $to)) { |
|
| 34 | 34 | return JArray::moveElementTo($this->values, $from, $to); |
| 35 | 35 | } |
| 36 | 36 | return false; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function swapFields($index1,$index2){ |
|
| 40 | - if(JArray::swapElements($this->visibleProperties, $index1, $index2)){ |
|
| 39 | + public function swapFields($index1, $index2) { |
|
| 40 | + if (JArray::swapElements($this->visibleProperties, $index1, $index2)) { |
|
| 41 | 41 | return JArray::swapElements($this->values, $index1, $index2); |
| 42 | 42 | } |
| 43 | 43 | return false; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public function removeField($index){ |
|
| 47 | - \array_splice($this->visibleProperties,$index,1); |
|
| 48 | - \array_splice($this->values,$index,1); |
|
| 49 | - \array_splice($this->captions,$index,1); |
|
| 46 | + public function removeField($index) { |
|
| 47 | + \array_splice($this->visibleProperties, $index, 1); |
|
| 48 | + \array_splice($this->values, $index, 1); |
|
| 49 | + \array_splice($this->captions, $index, 1); |
|
| 50 | 50 | return $this; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function getValues(){ |
|
| 53 | + public function getValues() { |
|
| 54 | 54 | $values=[]; |
| 55 | 55 | $index=0; |
| 56 | 56 | $count=$this->count(); |
| 57 | - while($index<$count){ |
|
| 57 | + while ($index<$count) { |
|
| 58 | 58 | $values[]=$this->getValue($index++); |
| 59 | 59 | } |
| 60 | 60 | return $values; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function getIdentifier($index=NULL){ |
|
| 64 | - if(!isset($index)) |
|
| 63 | + public function getIdentifier($index=NULL) { |
|
| 64 | + if (!isset($index)) |
|
| 65 | 65 | $index=self::$index; |
| 66 | 66 | $value=$index; |
| 67 | - if(isset($this->values["identifier"])) |
|
| 68 | - $value=$this->values["identifier"]($index,$this->instance); |
|
| 67 | + if (isset($this->values["identifier"])) |
|
| 68 | + $value=$this->values["identifier"]($index, $this->instance); |
|
| 69 | 69 | return $value; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public function getValue($index){ |
|
| 72 | + public function getValue($index) { |
|
| 73 | 73 | $property=$this->properties[$index]; |
| 74 | 74 | return $this->_getValue($property, $index); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - protected function _beforeAddProperty($index,&$field){ |
|
| 77 | + protected function _beforeAddProperty($index, &$field) { |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - protected function _getDefaultValue($name,$value,$index){ |
|
| 81 | + protected function _getDefaultValue($name, $value, $index) { |
|
| 82 | 82 | $func=$this->defaultValueFunction; |
| 83 | - return $func($name,$value,$index,$this->instance); |
|
| 83 | + return $func($name, $value, $index, $this->instance); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - protected function _getPropertyValue(\ReflectionProperty $property,$index){ |
|
| 86 | + protected function _getPropertyValue(\ReflectionProperty $property, $index) { |
|
| 87 | 87 | $property->setAccessible(true); |
| 88 | 88 | $value=$property->getValue($this->instance); |
| 89 | - if(isset($this->values[$index])){ |
|
| 90 | - $value= $this->values[$index]($value,$this->instance,$index); |
|
| 91 | - }else{ |
|
| 92 | - $value=$this->_getDefaultValue($property->getName(),$value, $index); |
|
| 89 | + if (isset($this->values[$index])) { |
|
| 90 | + $value=$this->values[$index]($value, $this->instance, $index); |
|
| 91 | + } else { |
|
| 92 | + $value=$this->_getDefaultValue($property->getName(), $value, $index); |
|
| 93 | 93 | } |
| 94 | 94 | return $value; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - protected function _getValue($property,$index){ |
|
| 97 | + protected function _getValue($property, $index) { |
|
| 98 | 98 | $value=null; |
| 99 | - if($property instanceof \ReflectionProperty){ |
|
| 99 | + if ($property instanceof \ReflectionProperty) { |
|
| 100 | 100 | $value=$this->_getPropertyValue($property, $index); |
| 101 | - }else{ |
|
| 102 | - if(\is_callable($property)) |
|
| 101 | + } else { |
|
| 102 | + if (\is_callable($property)) |
|
| 103 | 103 | $value=$property($this->instance); |
| 104 | - elseif(\is_array($property)){ |
|
| 105 | - $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
|
| 104 | + elseif (\is_array($property)) { |
|
| 105 | + $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property); |
|
| 106 | 106 | $value=\implode("", $values); |
| 107 | - }else{ |
|
| 108 | - if(isset($this->values[$index])){ |
|
| 109 | - $value= $this->values[$index]($property,$this->instance,$index); |
|
| 110 | - }elseif(isset($this->instance->{$property})){ |
|
| 107 | + } else { |
|
| 108 | + if (isset($this->values[$index])) { |
|
| 109 | + $value=$this->values[$index]($property, $this->instance, $index); |
|
| 110 | + }elseif (isset($this->instance->{$property})) { |
|
| 111 | 111 | $value=$this->instance->{$property}; |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | - if(isset($this->afterCompile[$index])){ |
|
| 116 | - if(\is_callable($this->afterCompile[$index])){ |
|
| 117 | - $this->afterCompile[$index]($value,$this->instance,$index); |
|
| 115 | + if (isset($this->afterCompile[$index])) { |
|
| 116 | + if (\is_callable($this->afterCompile[$index])) { |
|
| 117 | + $this->afterCompile[$index]($value, $this->instance, $index); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | return $value; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public function insertField($index,$field){ |
|
| 124 | - array_splice( $this->visibleProperties, $index, 0, $field ); |
|
| 123 | + public function insertField($index, $field) { |
|
| 124 | + array_splice($this->visibleProperties, $index, 0, $field); |
|
| 125 | 125 | return $this; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public function insertInField($index,$field){ |
|
| 128 | + public function insertInField($index, $field) { |
|
| 129 | 129 | $vb=$this->visibleProperties; |
| 130 | - if(isset($vb[$index])){ |
|
| 131 | - if(\is_array($vb[$index])){ |
|
| 130 | + if (isset($vb[$index])) { |
|
| 131 | + if (\is_array($vb[$index])) { |
|
| 132 | 132 | $this->visibleProperties[$index][]=$field; |
| 133 | - }else{ |
|
| 134 | - $this->visibleProperties[$index]=[$vb[$index],$field]; |
|
| 133 | + } else { |
|
| 134 | + $this->visibleProperties[$index]=[$vb[$index], $field]; |
|
| 135 | 135 | } |
| 136 | - }else{ |
|
| 136 | + } else { |
|
| 137 | 137 | return $this->insertField($index, $field); |
| 138 | 138 | } |
| 139 | 139 | return $this; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public function addField($field){ |
|
| 142 | + public function addField($field) { |
|
| 143 | 143 | $this->visibleProperties[]=$field; |
| 144 | 144 | return $this; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public function count(){ |
|
| 147 | + public function count() { |
|
| 148 | 148 | return \sizeof($this->properties); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - public function visiblePropertiesCount(){ |
|
| 151 | + public function visiblePropertiesCount() { |
|
| 152 | 152 | return \sizeof($this->visibleProperties); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - public function getProperty($index){ |
|
| 155 | + public function getProperty($index) { |
|
| 156 | 156 | return $this->properties[$index]; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - public function getFieldName($index){ |
|
| 159 | + public function getFieldName($index) { |
|
| 160 | 160 | $property=$this->getProperty($index); |
| 161 | - if($property instanceof \ReflectionProperty){ |
|
| 161 | + if ($property instanceof \ReflectionProperty) { |
|
| 162 | 162 | $result=$property->getName(); |
| 163 | - }elseif(\is_callable($property)){ |
|
| 163 | + }elseif (\is_callable($property)) { |
|
| 164 | 164 | $result=$this->visibleProperties[$index]; |
| 165 | - }else{ |
|
| 165 | + } else { |
|
| 166 | 166 | $result=$property; |
| 167 | 167 | } |
| 168 | 168 | return $result; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | |
| 172 | - protected function showableProperty(\ReflectionProperty $rProperty){ |
|
| 173 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
| 172 | + protected function showableProperty(\ReflectionProperty $rProperty) { |
|
| 173 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | public function setInstance($instance) { |
| 177 | - if(\is_string($instance)){ |
|
| 177 | + if (\is_string($instance)) { |
|
| 178 | 178 | $instance=new $instance(); |
| 179 | 179 | } |
| 180 | 180 | $this->instance=$instance; |
| 181 | 181 | $this->properties=[]; |
| 182 | 182 | $this->reflect=new \ReflectionClass($instance); |
| 183 | - if(\sizeof($this->visibleProperties)===0){ |
|
| 183 | + if (\sizeof($this->visibleProperties)===0) { |
|
| 184 | 184 | $this->properties=$this->getDefaultProperties(); |
| 185 | - }else{ |
|
| 186 | - foreach ($this->visibleProperties as $property){ |
|
| 185 | + } else { |
|
| 186 | + foreach ($this->visibleProperties as $property) { |
|
| 187 | 187 | $this->setInstanceProperty($property); |
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | return $this; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - private function setInstanceProperty($property){ |
|
| 194 | - if(\is_callable($property)){ |
|
| 193 | + private function setInstanceProperty($property) { |
|
| 194 | + if (\is_callable($property)) { |
|
| 195 | 195 | $this->properties[]=$property; |
| 196 | - }elseif(\is_string($property)){ |
|
| 197 | - try{ |
|
| 196 | + }elseif (\is_string($property)) { |
|
| 197 | + try { |
|
| 198 | 198 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 199 | 199 | $rProperty=$this->reflect->getProperty($property); |
| 200 | 200 | $this->properties[]=$rProperty; |
| 201 | - }catch(\Exception $e){ |
|
| 201 | + }catch (\Exception $e) { |
|
| 202 | 202 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 203 | 203 | $this->properties[]=$property; |
| 204 | 204 | } |
| 205 | - }elseif(\is_int($property)){ |
|
| 205 | + }elseif (\is_int($property)) { |
|
| 206 | 206 | $props=$this->getDefaultProperties(); |
| 207 | - if(isset($props[$property])) |
|
| 207 | + if (isset($props[$property])) |
|
| 208 | 208 | $this->properties[]=$props[$property]; |
| 209 | 209 | else |
| 210 | 210 | $this->properties[]=$property; |
| 211 | - }else{ |
|
| 211 | + } else { |
|
| 212 | 212 | $this->properties[]=$property; |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - protected function getDefaultProperties(){ |
|
| 216 | + protected function getDefaultProperties() { |
|
| 217 | 217 | $result=[]; |
| 218 | 218 | $properties=$this->reflect->getProperties(); |
| 219 | - foreach ($properties as $property){ |
|
| 219 | + foreach ($properties as $property) { |
|
| 220 | 220 | $showable=$this->showableProperty($property); |
| 221 | - if($showable!==false){ |
|
| 221 | + if ($showable!==false) { |
|
| 222 | 222 | $result[]=$property; |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -230,12 +230,12 @@ discard block |
||
| 230 | 230 | return $this; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - public function setValueFunction($index,$callback){ |
|
| 233 | + public function setValueFunction($index, $callback) { |
|
| 234 | 234 | $this->values[$index]=$callback; |
| 235 | 235 | return $this; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - public function setIdentifierFunction($callback){ |
|
| 238 | + public function setIdentifierFunction($callback) { |
|
| 239 | 239 | $this->values["identifier"]=$callback; |
| 240 | 240 | return $this; |
| 241 | 241 | } |
@@ -248,41 +248,41 @@ discard block |
||
| 248 | 248 | return $this->properties; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - public function getCaption($index){ |
|
| 252 | - if(isset($this->captions[$index])){ |
|
| 251 | + public function getCaption($index) { |
|
| 252 | + if (isset($this->captions[$index])) { |
|
| 253 | 253 | return $this->captions[$index]; |
| 254 | 254 | } |
| 255 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 255 | + if ($this->properties[$index] instanceof \ReflectionProperty) |
|
| 256 | 256 | return $this->properties[$index]->getName(); |
| 257 | - elseif(\is_callable($this->properties[$index])) |
|
| 257 | + elseif (\is_callable($this->properties[$index])) |
|
| 258 | 258 | return ""; |
| 259 | 259 | else |
| 260 | 260 | return $this->properties[$index]; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - public function getCaptions(){ |
|
| 264 | - if(isset($this->captions)){ |
|
| 265 | - $captions= \array_values($this->captions); |
|
| 266 | - for($i=\sizeof($captions);$i<$this->count();$i++){ |
|
| 263 | + public function getCaptions() { |
|
| 264 | + if (isset($this->captions)) { |
|
| 265 | + $captions=\array_values($this->captions); |
|
| 266 | + for ($i=\sizeof($captions); $i<$this->count(); $i++) { |
|
| 267 | 267 | $captions[]=""; |
| 268 | 268 | } |
| 269 | - }else{ |
|
| 269 | + } else { |
|
| 270 | 270 | $captions=[]; |
| 271 | 271 | $index=0; |
| 272 | 272 | $count=$this->count(); |
| 273 | - while($index<$count){ |
|
| 273 | + while ($index<$count) { |
|
| 274 | 274 | $captions[]=$this->getCaption($index++); |
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | - if(isset($this->captionCallback) && \is_callable($this->captionCallback)){ |
|
| 277 | + if (isset($this->captionCallback) && \is_callable($this->captionCallback)) { |
|
| 278 | 278 | $callback=$this->captionCallback; |
| 279 | - $callback($captions,$this->instance); |
|
| 279 | + $callback($captions, $this->instance); |
|
| 280 | 280 | } |
| 281 | 281 | return $captions; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - public function setCaption($index,$caption){ |
|
| 285 | - if(isset($this->captions)===false) |
|
| 284 | + public function setCaption($index, $caption) { |
|
| 285 | + if (isset($this->captions)===false) |
|
| 286 | 286 | $this->captions=[]; |
| 287 | 287 | $this->captions[$index]=$caption; |
| 288 | 288 | return $this; |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * @param callable $callback function called after the field compilation |
| 301 | 301 | * @return \Ajax\semantic\widgets\datatable\InstanceViewer |
| 302 | 302 | */ |
| 303 | - public function afterCompile($index,$callback){ |
|
| 303 | + public function afterCompile($index, $callback) { |
|
| 304 | 304 | $this->afterCompile[$index]=$callback; |
| 305 | 305 | return $this; |
| 306 | 306 | } |
@@ -17,34 +17,34 @@ |
||
| 17 | 17 | * |
| 18 | 18 | * @see \Ajax\semantic\widgets\dataform\DataForm::__construct() |
| 19 | 19 | */ |
| 20 | - public function __construct($identifier,$modelInstance=null,$fields=[],$captions=[],$separators=[]) { |
|
| 21 | - parent::__construct($identifier,$modelInstance); |
|
| 20 | + public function __construct($identifier, $modelInstance=null, $fields=[], $captions=[], $separators=[]) { |
|
| 21 | + parent::__construct($identifier, $modelInstance); |
|
| 22 | 22 | $this->setFields($fields); |
| 23 | 23 | $this->setSeparators($separators); |
| 24 | 24 | $this->fieldsAs($this->_fieldsDefinition); |
| 25 | 25 | $this->setCaptions($captions); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - protected function _getIndex($fieldName){ |
|
| 28 | + protected function _getIndex($fieldName) { |
|
| 29 | 29 | $index=$fieldName; |
| 30 | - if(\is_string($fieldName)){ |
|
| 30 | + if (\is_string($fieldName)) { |
|
| 31 | 31 | $index=\array_search($fieldName, $this->_fieldsOrder); |
| 32 | 32 | } |
| 33 | 33 | return $index; |
| 34 | 34 | } |
| 35 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
| 35 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
| 36 | 36 | $index=$this->_getIndex($index); |
| 37 | - return parent::_fieldAs($elementCallback, $index,$attributes,$prefix); |
|
| 37 | + return parent::_fieldAs($elementCallback, $index, $attributes, $prefix); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
| 41 | - public function removeField($fieldName){ |
|
| 41 | + public function removeField($fieldName) { |
|
| 42 | 42 | parent::removeField($fieldName); |
| 43 | - \array_splice($this->_fieldsOrder,$this->_getIndex($fieldName),1); |
|
| 43 | + \array_splice($this->_fieldsOrder, $this->_getIndex($fieldName), 1); |
|
| 44 | 44 | return $this; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 48 | - return parent::compile($js,$view); |
|
| 47 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 48 | + return parent::compile($js, $view); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | \ No newline at end of file |
@@ -13,13 +13,13 @@ |
||
| 13 | 13 | * @param string $identifier |
| 14 | 14 | * @param object $modelInstance |
| 15 | 15 | */ |
| 16 | - public function __construct($identifier,$modelInstance=null) { |
|
| 17 | - if(!isset($modelInstance)) |
|
| 16 | + public function __construct($identifier, $modelInstance=null) { |
|
| 17 | + if (!isset($modelInstance)) |
|
| 18 | 18 | $modelInstance=new UserModel(); |
| 19 | - $this->_fieldsOrder=["message","login","password","remember","forget","submit"]; |
|
| 20 | - $this->_fieldsDefinition=["message"=>["icon"=>"sign in"],"input0"=>["rules"=>"empty"],"input1"=>["inputType"=>"password","rules"=>"empty"],"checkbox","link","submit"=>"green fluid"]; |
|
| 21 | - parent::__construct($identifier,$modelInstance,["Connection","login","password","remember","forget","submit"], |
|
| 22 | - ["Please enter login and password to connect","Login","Password","Remember me.","Forgot your password?","Connection"], |
|
| 23 | - [0,2,4,5]); |
|
| 19 | + $this->_fieldsOrder=["message", "login", "password", "remember", "forget", "submit"]; |
|
| 20 | + $this->_fieldsDefinition=["message"=>["icon"=>"sign in"], "input0"=>["rules"=>"empty"], "input1"=>["inputType"=>"password", "rules"=>"empty"], "checkbox", "link", "submit"=>"green fluid"]; |
|
| 21 | + parent::__construct($identifier, $modelInstance, ["Connection", "login", "password", "remember", "forget", "submit"], |
|
| 22 | + ["Please enter login and password to connect", "Login", "Password", "Remember me.", "Forgot your password?", "Connection"], |
|
| 23 | + [0, 2, 4, 5]); |
|
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | \ No newline at end of file |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | parent::__construct($identifier, $instance, $captions); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public function getValue($index){ |
|
| 15 | + public function getValue($index) { |
|
| 16 | 16 | $result=parent::getValue($index); |
| 17 | - if($result instanceof HtmlFormField){ |
|
| 18 | - $lbl=new HtmlSemDoubleElement("lbl-".$this->widgetIdentifier."-".$index,"label","",$this->getCaption($index)); |
|
| 17 | + if ($result instanceof HtmlFormField) { |
|
| 18 | + $lbl=new HtmlSemDoubleElement("lbl-".$this->widgetIdentifier."-".$index, "label", "", $this->getCaption($index)); |
|
| 19 | 19 | $lbl->setProperty("for", $result->getDataField()->getIdentifier()); |
| 20 | 20 | $this->captions[$index]=$lbl; |
| 21 | 21 | } |
@@ -18,49 +18,49 @@ discard block |
||
| 18 | 18 | class DataElement extends Widget { |
| 19 | 19 | |
| 20 | 20 | public function __construct($identifier, $modelInstance=NULL) { |
| 21 | - parent::__construct($identifier, null,$modelInstance); |
|
| 22 | - $this->_init(new DeInstanceViewer($identifier), "table", new HtmlTable($identifier, 0,2), false); |
|
| 21 | + parent::__construct($identifier, null, $modelInstance); |
|
| 22 | + $this->_init(new DeInstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 2), false); |
|
| 23 | 23 | $this->content["table"]->setDefinition(); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 27 | - if(!$this->_generated){ |
|
| 26 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 27 | + if (!$this->_generated) { |
|
| 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]); |
|
| 36 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
| 37 | 37 | $this->_compileForm(); |
| 38 | 38 | $this->_generated=true; |
| 39 | 39 | } |
| 40 | - return parent::compile($js,$view); |
|
| 40 | + return parent::compile($js, $view); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * @param HtmlTable $table |
| 45 | 45 | */ |
| 46 | - protected function _generateContent($table){ |
|
| 47 | - $values= $this->_instanceViewer->getValues(); |
|
| 46 | + protected function _generateContent($table) { |
|
| 47 | + $values=$this->_instanceViewer->getValues(); |
|
| 48 | 48 | $captions=$this->_instanceViewer->getCaptions(); |
| 49 | 49 | $count=$this->_instanceViewer->count(); |
| 50 | - for($i=0;$i<$count;$i++){ |
|
| 51 | - $table->addRow([$captions[$i],$values[$i]]); |
|
| 50 | + for ($i=0; $i<$count; $i++) { |
|
| 51 | + $table->addRow([$captions[$i], $values[$i]]); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - protected function _getFieldName($index){ |
|
| 55 | + protected function _getFieldName($index) { |
|
| 56 | 56 | return $this->_instanceViewer->getFieldName($index); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - protected function _getFieldCaption($index){ |
|
| 59 | + protected function _getFieldCaption($index) { |
|
| 60 | 60 | return null; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
| 63 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 64 | 64 | return $this->identifier."-{$prefix}-".$name; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | return $this; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function asForm(){ |
|
| 95 | + public function asForm() { |
|
| 96 | 96 | return $this->getForm(); |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | \ No newline at end of file |
@@ -9,22 +9,22 @@ discard block |
||
| 9 | 9 | class FormInstanceViewer extends InstanceViewer { |
| 10 | 10 | protected $separators; |
| 11 | 11 | |
| 12 | - public function __construct($identifier,$instance=NULL, $captions=NULL) { |
|
| 13 | - parent::__construct($identifier,$instance=NULL, $captions=NULL); |
|
| 12 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
| 13 | + parent::__construct($identifier, $instance=NULL, $captions=NULL); |
|
| 14 | 14 | $this->separators=[-1]; |
| 15 | - $this->defaultValueFunction=function($name,$value,$index){ |
|
| 15 | + $this->defaultValueFunction=function($name, $value, $index) { |
|
| 16 | 16 | $caption=$this->getCaption($index); |
| 17 | - $input=new HtmlFormInput($this->widgetIdentifier."-".$name,$caption,"text",$value); |
|
| 17 | + $input=new HtmlFormInput($this->widgetIdentifier."-".$name, $caption, "text", $value); |
|
| 18 | 18 | $input->setName($name); |
| 19 | 19 | return $input; |
| 20 | 20 | }; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - protected function _beforeAddProperty($index,&$field){ |
|
| 24 | - if(JString::endswith($field, "\n")===true){ |
|
| 23 | + protected function _beforeAddProperty($index, &$field) { |
|
| 24 | + if (JString::endswith($field, "\n")===true) { |
|
| 25 | 25 | $this->addSeparatorAfter($index); |
| 26 | 26 | } |
| 27 | - if($index>1 && JString::startswith($field, "\n")===true){ |
|
| 27 | + if ($index>1 && JString::startswith($field, "\n")===true) { |
|
| 28 | 28 | $this->addSeparatorAfter($index-1); |
| 29 | 29 | } |
| 30 | 30 | $field=\str_replace("\n", "", $field); |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | - public function addSeparatorAfter($fieldNum){ |
|
| 36 | - if(\array_search($fieldNum, $this->separators)===false) |
|
| 35 | + public function addSeparatorAfter($fieldNum) { |
|
| 36 | + if (\array_search($fieldNum, $this->separators)===false) |
|
| 37 | 37 | $this->separators[]=$fieldNum; |
| 38 | 38 | return $this; |
| 39 | 39 | } |
@@ -42,15 +42,15 @@ discard block |
||
| 42 | 42 | return $this->separators; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public function removeSeparator($index){ |
|
| 46 | - \array_splice($this->separators,$index,1); |
|
| 45 | + public function removeSeparator($index) { |
|
| 46 | + \array_splice($this->separators, $index, 1); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public function removeField($index){ |
|
| 49 | + public function removeField($index) { |
|
| 50 | 50 | parent::removeField($index); |
| 51 | 51 | $pos=\array_search($index, $this->separators); |
| 52 | - if($pos!==false){ |
|
| 53 | - for($i=$pos+1;$i<\sizeof($this->separators);$i++){ |
|
| 52 | + if ($pos!==false) { |
|
| 53 | + for ($i=$pos+1; $i<\sizeof($this->separators); $i++) { |
|
| 54 | 54 | $this->separators[$i]--; |
| 55 | 55 | } |
| 56 | 56 | \array_splice($this->separators, $pos, 1); |
@@ -19,49 +19,49 @@ discard block |
||
| 19 | 19 | class DataForm extends Widget { |
| 20 | 20 | |
| 21 | 21 | public function __construct($identifier, $modelInstance=NULL) { |
| 22 | - parent::__construct($identifier, null,$modelInstance); |
|
| 22 | + parent::__construct($identifier, null, $modelInstance); |
|
| 23 | 23 | $this->_form=new HtmlForm($identifier); |
| 24 | 24 | $this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
| 27 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 28 | 28 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 31 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 32 | 32 | $this->_instanceViewer->setInstance($this->_modelInstance); |
| 33 | 33 | |
| 34 | 34 | $form=$this->content["form"]; |
| 35 | 35 | $this->_generateContent($form); |
| 36 | 36 | |
| 37 | - if(isset($this->_toolbar)){ |
|
| 37 | + if (isset($this->_toolbar)) { |
|
| 38 | 38 | $this->_setToolbarPosition($form); |
| 39 | 39 | } |
| 40 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
| 41 | - return parent::compile($js,$view); |
|
| 40 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
| 41 | + return parent::compile($js, $view); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * @param HtmlForm $form |
| 46 | 46 | */ |
| 47 | - protected function _generateContent($form){ |
|
| 48 | - $values= $this->_instanceViewer->getValues(); |
|
| 47 | + protected function _generateContent($form) { |
|
| 48 | + $values=$this->_instanceViewer->getValues(); |
|
| 49 | 49 | $count=$this->_instanceViewer->count(); |
| 50 | 50 | $separators=$this->_instanceViewer->getSeparators(); |
| 51 | 51 | \sort($separators); |
| 52 | 52 | $size=\sizeof($separators); |
| 53 | - if($size===1){ |
|
| 54 | - foreach ($values as $v){ |
|
| 53 | + if ($size===1) { |
|
| 54 | + foreach ($values as $v) { |
|
| 55 | 55 | $form->addField($v); |
| 56 | 56 | } |
| 57 | - }else{ |
|
| 57 | + } else { |
|
| 58 | 58 | $separators[]=$count; |
| 59 | - for($i=0;$i<$size;$i++){ |
|
| 60 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
| 59 | + for ($i=0; $i<$size; $i++) { |
|
| 60 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
| 61 | 61 | //TODO check why $fields is empty |
| 62 | - if(\sizeof($fields)===1){ |
|
| 62 | + if (\sizeof($fields)===1) { |
|
| 63 | 63 | $form->addField($fields[0]); |
| 64 | - }elseif(\sizeof($fields)>1){ |
|
| 64 | + }elseif (\sizeof($fields)>1) { |
|
| 65 | 65 | $form->addFields($fields); |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | * {@inheritDoc} |
| 73 | 73 | * @see \Ajax\common\Widget::getForm() |
| 74 | 74 | */ |
| 75 | - public function getForm(){ |
|
| 75 | + public function getForm() { |
|
| 76 | 76 | return $this->content["form"]; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public function addSeparatorAfter($fieldNum){ |
|
| 79 | + public function addSeparatorAfter($fieldNum) { |
|
| 80 | 80 | $fieldNum=$this->_getIndex($fieldNum); |
| 81 | 81 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
| 82 | 82 | return $this; |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | return $this; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 95 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
| 96 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 94 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 95 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
| 96 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 97 | 97 | $button->setProperty("type", "reset"); |
| 98 | 98 | return $button; |
| 99 | - }, $index,$attributes); |
|
| 99 | + }, $index, $attributes); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - public function run(JsUtils $js){ |
|
| 118 | + public function run(JsUtils $js) { |
|
| 119 | 119 | return parent::run($js); |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | \ No newline at end of file |