@@ -12,19 +12,19 @@ discard block |
||
| 12 | 12 | * @property boolean $_visibleHover |
| 13 | 13 | * @property InstanceViewer $_instanceViewer |
| 14 | 14 | */ |
| 15 | -trait DataTableFieldAsTrait{ |
|
| 15 | +trait DataTableFieldAsTrait { |
|
| 16 | 16 | abstract public function addField($field); |
| 17 | - abstract public function insertField($index,$field); |
|
| 18 | - abstract public function insertInField($index,$field); |
|
| 19 | - abstract public function fieldAs($index,$type,$attributes=NULL); |
|
| 17 | + abstract public function insertField($index, $field); |
|
| 18 | + abstract public function insertInField($index, $field); |
|
| 19 | + abstract public function fieldAs($index, $type, $attributes=NULL); |
|
| 20 | 20 | /** |
| 21 | 21 | * @param string $caption |
| 22 | 22 | * @param callable $callback |
| 23 | 23 | * @param boolean $visibleHover |
| 24 | 24 | * @return callable |
| 25 | 25 | */ |
| 26 | - private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
|
| 27 | - return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
|
| 26 | + private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) { |
|
| 27 | + return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -33,19 +33,19 @@ discard block |
||
| 33 | 33 | * @param callable $callback |
| 34 | 34 | * @return callable |
| 35 | 35 | */ |
| 36 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
| 37 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
| 38 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
| 39 | - if(isset($callback)){ |
|
| 40 | - if(\is_callable($callback)){ |
|
| 41 | - $callback($object,$instance); |
|
| 36 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
| 37 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
| 38 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
| 39 | + if (isset($callback)) { |
|
| 40 | + if (\is_callable($callback)) { |
|
| 41 | + $callback($object, $instance); |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | - if($object instanceof HtmlSemDoubleElement){ |
|
| 45 | - $object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier()); |
|
| 46 | - if($object->propertyContains("class","visibleover")){ |
|
| 44 | + if ($object instanceof HtmlSemDoubleElement) { |
|
| 45 | + $object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier()); |
|
| 46 | + if ($object->propertyContains("class", "visibleover")) { |
|
| 47 | 47 | $this->_visibleHover=true; |
| 48 | - $object->setProperty("style","visibility:hidden;"); |
|
| 48 | + $object->setProperty("style", "visibility:hidden;"); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | return $object; |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | * @param string $caption |
| 58 | 58 | * @return HtmlButton |
| 59 | 59 | */ |
| 60 | - private function getFieldButton($caption,$visibleHover=true){ |
|
| 61 | - $bt= new HtmlButton("",$caption); |
|
| 62 | - if($visibleHover) |
|
| 60 | + private function getFieldButton($caption, $visibleHover=true) { |
|
| 61 | + $bt=new HtmlButton("", $caption); |
|
| 62 | + if ($visibleHover) |
|
| 63 | 63 | $this->_visibleOver($bt); |
| 64 | 64 | return $bt; |
| 65 | 65 | } |
@@ -73,19 +73,19 @@ discard block |
||
| 73 | 73 | * @param array $attributes associative array (<b>ajax</b> key is for ajax post) |
| 74 | 74 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 75 | 75 | */ |
| 76 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
| 77 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
|
| 78 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 79 | - $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
|
| 80 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 76 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
| 77 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $index, $attributes){ |
|
| 78 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 79 | + $button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]); |
|
| 80 | + if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 81 | 81 | $this->_visibleOver($button); |
| 82 | 82 | return $button; |
| 83 | - }, $index,$attributes); |
|
| 83 | + }, $index, $attributes); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - protected function _visibleOver($element){ |
|
| 86 | + protected function _visibleOver($element) { |
|
| 87 | 87 | $this->_visibleHover=true; |
| 88 | - return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
|
| 88 | + return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;"); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | * @param boolean $visibleHover |
| 96 | 96 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 97 | 97 | */ |
| 98 | - public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
|
| 99 | - $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
|
| 98 | + public function addFieldButton($caption, $visibleHover=true, $callback=null) { |
|
| 99 | + $this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback)); |
|
| 100 | 100 | return $this; |
| 101 | 101 | } |
| 102 | 102 | |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | * @param callable $callback |
| 108 | 108 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 109 | 109 | */ |
| 110 | - public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
| 111 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
| 110 | + public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
| 111 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
| 112 | 112 | return $this; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -119,25 +119,25 @@ discard block |
||
| 119 | 119 | * @param callable $callback |
| 120 | 120 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 121 | 121 | */ |
| 122 | - public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
| 123 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
| 122 | + public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
| 123 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
| 124 | 124 | return $this; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
|
| 128 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
| 127 | + private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null) { |
|
| 128 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
| 129 | 129 | return $this; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
|
| 133 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
| 132 | + private function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null) { |
|
| 133 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
| 134 | 134 | return $this; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
|
| 138 | - $bt=$this->getFieldButton("",$visibleHover); |
|
| 137 | + private function getDefaultButton($icon, $class=null, $visibleHover=true) { |
|
| 138 | + $bt=$this->getFieldButton("", $visibleHover); |
|
| 139 | 139 | $bt->asIcon($icon); |
| 140 | - if(isset($class)) |
|
| 140 | + if (isset($class)) |
|
| 141 | 141 | $bt->addClass($class); |
| 142 | 142 | return $bt; |
| 143 | 143 | } |
@@ -148,30 +148,30 @@ discard block |
||
| 148 | 148 | * @param callable $callback |
| 149 | 149 | * @return DataTable |
| 150 | 150 | */ |
| 151 | - public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
| 151 | + public function addDeleteButton($visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
| 152 | 152 | $this->_deleteBehavior=$deleteBehavior; |
| 153 | - return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback); |
|
| 153 | + return $this->addDefaultButton("remove", "_delete red basic", $visibleHover, $callback); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){ |
|
| 156 | + public function addEditButton($visibleHover=true, $editBehavior=[], $callback=null) { |
|
| 157 | 157 | $this->_editBehavior=$editBehavior; |
| 158 | - return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback); |
|
| 158 | + return $this->addDefaultButton("edit", "_edit basic", $visibleHover, $callback); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){ |
|
| 162 | - $this->addEditButton($visibleHover,$behavior,$callbackEdit); |
|
| 161 | + public function addEditDeleteButtons($visibleHover=true, $behavior=[], $callbackEdit=null, $callbackDelete=null) { |
|
| 162 | + $this->addEditButton($visibleHover, $behavior, $callbackEdit); |
|
| 163 | 163 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
| 164 | - $this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete); |
|
| 164 | + $this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete); |
|
| 165 | 165 | return $this; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
| 168 | + public function insertDeleteButtonIn($index, $visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
| 169 | 169 | $this->_deleteBehavior=$deleteBehavior; |
| 170 | - return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback); |
|
| 170 | + return $this->insertDefaultButtonIn($index, "remove", "_delete red basic", $visibleHover, $callback); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - public function insertEditButtonIn($index,$visibleHover=true,$editBehavior=[],$callback=null){ |
|
| 173 | + public function insertEditButtonIn($index, $visibleHover=true, $editBehavior=[], $callback=null) { |
|
| 174 | 174 | $this->_editBehavior=$editBehavior; |
| 175 | - return $this->insertDefaultButtonIn($index,"edit","_edit basic",$visibleHover,$callback); |
|
| 175 | + return $this->insertDefaultButtonIn($index, "edit", "_edit basic", $visibleHover, $callback); |
|
| 176 | 176 | } |
| 177 | 177 | } |
@@ -27,23 +27,23 @@ discard block |
||
| 27 | 27 | * @property boolean $_edition |
| 28 | 28 | * @property mixed _modelInstance |
| 29 | 29 | */ |
| 30 | -trait FieldAsTrait{ |
|
| 30 | +trait FieldAsTrait { |
|
| 31 | 31 | |
| 32 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
| 33 | - abstract public function setValueFunction($index,$callback); |
|
| 32 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
| 33 | + abstract public function setValueFunction($index, $callback); |
|
| 34 | 34 | abstract protected function _getFieldName($index); |
| 35 | 35 | abstract protected function _getFieldCaption($index); |
| 36 | - abstract protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
|
| 36 | + abstract protected function _buttonAsSubmit(BaseHtml&$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * @param HtmlFormField $element |
| 40 | 40 | * @param array $attributes |
| 41 | 41 | */ |
| 42 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
| 43 | - if(isset($attributes["jsCallback"])){ |
|
| 42 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
| 43 | + if (isset($attributes["jsCallback"])) { |
|
| 44 | 44 | $callback=$attributes["jsCallback"]; |
| 45 | - if(\is_callable($callback)){ |
|
| 46 | - $callback($element,$this->_modelInstance,$index); |
|
| 45 | + if (\is_callable($callback)) { |
|
| 46 | + $callback($element, $this->_modelInstance, $index); |
|
| 47 | 47 | unset($attributes["jsCallback"]); |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -53,43 +53,43 @@ discard block |
||
| 53 | 53 | $element->fromArray($attributes); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - private function _getLabelField($caption,$icon=NULL){ |
|
| 57 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
| 56 | + private function _getLabelField($caption, $icon=NULL) { |
|
| 57 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
| 58 | 58 | return $label; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
| 62 | - protected function _addRules($element,&$attributes){ |
|
| 63 | - if(isset($attributes["rules"])){ |
|
| 62 | + protected function _addRules($element, &$attributes) { |
|
| 63 | + if (isset($attributes["rules"])) { |
|
| 64 | 64 | $rules=$attributes["rules"]; |
| 65 | - if(\is_array($rules)){ |
|
| 65 | + if (\is_array($rules)) { |
|
| 66 | 66 | $element->addRules($rules); |
| 67 | 67 | } |
| 68 | - else{ |
|
| 68 | + else { |
|
| 69 | 69 | $element->addRule($rules); |
| 70 | 70 | } |
| 71 | 71 | unset($attributes["rules"]); |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - protected function _prepareFormFields(&$field,$name,&$attributes){ |
|
| 75 | + protected function _prepareFormFields(&$field, $name, &$attributes) { |
|
| 76 | 76 | $field->setName($name); |
| 77 | 77 | $this->_addRules($field, $attributes); |
| 78 | 78 | return $field; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
| 82 | - $this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){ |
|
| 81 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
| 82 | + $this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){ |
|
| 83 | 83 | $caption=$this->_getFieldCaption($index); |
| 84 | 84 | $name=$this->_getFieldName($index); |
| 85 | - $id=$this->_getFieldIdentifier($prefix,$name); |
|
| 86 | - if(isset($attributes["name"])){ |
|
| 85 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
| 86 | + if (isset($attributes["name"])) { |
|
| 87 | 87 | $name=$attributes["name"]; |
| 88 | 88 | unset($attributes["name"]); |
| 89 | 89 | } |
| 90 | - $element=$elementCallback($id,$name,$value,$caption); |
|
| 91 | - if(\is_array($attributes)){ |
|
| 92 | - $this->_applyAttributes($element, $attributes,$index); |
|
| 90 | + $element=$elementCallback($id, $name, $value, $caption); |
|
| 91 | + if (\is_array($attributes)) { |
|
| 92 | + $this->_applyAttributes($element, $attributes, $index); |
|
| 93 | 93 | } |
| 94 | 94 | $element->setDisabled(!$this->_edition); |
| 95 | 95 | return $element; |
@@ -98,178 +98,178 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
| 101 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
| 102 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
| 103 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
| 101 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
| 102 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
| 103 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
| 104 | 104 | return $pb; |
| 105 | 105 | }); |
| 106 | 106 | return $this; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
| 110 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
| 111 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
| 109 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
| 110 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
| 111 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
| 112 | 112 | return $rating; |
| 113 | 113 | }); |
| 114 | 114 | return $this; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - public function fieldAsLabel($index,$icon=NULL,$attributes=NULL){ |
|
| 118 | - return $this->_fieldAs(function($id,$name,$value) use($icon){ |
|
| 119 | - $lbl=new HtmlLabel($id,$value); |
|
| 120 | - if(isset($icon)) |
|
| 117 | + public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) { |
|
| 118 | + return $this->_fieldAs(function($id, $name, $value) use($icon){ |
|
| 119 | + $lbl=new HtmlLabel($id, $value); |
|
| 120 | + if (isset($icon)) |
|
| 121 | 121 | $lbl->addIcon($icon); |
| 122 | 122 | return $lbl; |
| 123 | - }, $index,$attributes,"label"); |
|
| 123 | + }, $index, $attributes, "label"); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
| 127 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
| 128 | - $header=new HtmlHeader($id,$niveau,$value); |
|
| 129 | - if(isset($icon)) |
|
| 126 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
| 127 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
| 128 | + $header=new HtmlHeader($id, $niveau, $value); |
|
| 129 | + if (isset($icon)) |
|
| 130 | 130 | $header->asIcon($icon, $value); |
| 131 | 131 | return $header; |
| 132 | - }, $index,$attributes,"header"); |
|
| 132 | + }, $index, $attributes, "header"); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | |
| 136 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
| 137 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
| 138 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
| 136 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
| 137 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
| 138 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
| 139 | 139 | return $image; |
| 140 | 140 | }); |
| 141 | 141 | return $this; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - public function fieldAsFlag($index){ |
|
| 145 | - $this->setValueFunction($index,function($flag){ |
|
| 146 | - $flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag); |
|
| 144 | + public function fieldAsFlag($index) { |
|
| 145 | + $this->setValueFunction($index, function($flag) { |
|
| 146 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
| 147 | 147 | return $flag; |
| 148 | 148 | }); |
| 149 | 149 | return $this; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
| 153 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 154 | - $img=new HtmlImage($id,$value); |
|
| 152 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
| 153 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 154 | + $img=new HtmlImage($id, $value); |
|
| 155 | 155 | $img->asAvatar(); |
| 156 | 156 | return $img; |
| 157 | - }, $index,$attributes,"avatar"); |
|
| 157 | + }, $index, $attributes, "avatar"); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
| 161 | - return $this->_fieldAs(function($id,$name,$value) use($attributes){ |
|
| 162 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
| 160 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
| 161 | + return $this->_fieldAs(function($id, $name, $value) use($attributes){ |
|
| 162 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
| 163 | 163 | return $this->_prepareFormFields($input, $name, $attributes); |
| 164 | - }, $index,$attributes,"radio"); |
|
| 164 | + }, $index, $attributes, "radio"); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
| 168 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
| 169 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
| 170 | - }, $index,$attributes,"radios"); |
|
| 167 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
| 168 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
| 169 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
| 170 | + }, $index, $attributes, "radios"); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - public function fieldAsInput($index,$attributes=NULL){ |
|
| 174 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
| 175 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
| 173 | + public function fieldAsInput($index, $attributes=NULL) { |
|
| 174 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
| 175 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
| 176 | 176 | return $this->_prepareFormFields($input, $name, $attributes); |
| 177 | - }, $index,$attributes,"input"); |
|
| 177 | + }, $index, $attributes, "input"); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
| 181 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
| 182 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
| 180 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
| 181 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
| 182 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
| 183 | 183 | return $this->_prepareFormFields($textarea, $name, $attributes); |
| 184 | - }, $index,$attributes,"textarea"); |
|
| 184 | + }, $index, $attributes, "textarea"); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
| 188 | - if(!\is_array($attributes)){ |
|
| 187 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
| 188 | + if (!\is_array($attributes)) { |
|
| 189 | 189 | $attributes=[]; |
| 190 | 190 | } |
| 191 | 191 | $attributes["inputType"]="hidden"; |
| 192 | - return $this->fieldAsInput($index,$attributes); |
|
| 192 | + return $this->fieldAsInput($index, $attributes); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
| 196 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($attributes){ |
|
| 197 | - if($caption===null || $caption==="") |
|
| 195 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
| 196 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($attributes){ |
|
| 197 | + if ($caption===null || $caption==="") |
|
| 198 | 198 | $caption=""; |
| 199 | - $input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier()); |
|
| 199 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
| 200 | 200 | $input->setChecked(JString::isBooleanTrue($value)); |
| 201 | 201 | return $this->_prepareFormFields($input, $name, $attributes); |
| 202 | - }, $index,$attributes,"ck"); |
|
| 202 | + }, $index, $attributes, "ck"); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
| 206 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple,$attributes){ |
|
| 207 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value); |
|
| 208 | - $dd->asSelect($name,$multiple); |
|
| 205 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
| 206 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple, $attributes){ |
|
| 207 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value); |
|
| 208 | + $dd->asSelect($name, $multiple); |
|
| 209 | 209 | return $this->_prepareFormFields($dd, $name, $attributes); |
| 210 | - }, $index,$attributes,"dd"); |
|
| 210 | + }, $index, $attributes, "dd"); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
| 214 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 215 | - $mess= new HtmlMessage("message-".$id,$caption); |
|
| 213 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
| 214 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 215 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
| 216 | 216 | $mess->addHeader($value); |
| 217 | 217 | return $mess; |
| 218 | - }, $index,$attributes,"message"); |
|
| 218 | + }, $index, $attributes, "message"); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - public function fieldAsLink($index,$attributes=NULL){ |
|
| 222 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 223 | - $lnk= new HtmlLink("message-".$id,"#",$caption); |
|
| 221 | + public function fieldAsLink($index, $attributes=NULL) { |
|
| 222 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 223 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
| 224 | 224 | return $lnk; |
| 225 | - }, $index,$attributes,"link"); |
|
| 225 | + }, $index, $attributes, "link"); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /**Change fields type |
| 229 | 229 | * @param array $types an array or associative array $type=>$attributes |
| 230 | 230 | */ |
| 231 | - public function fieldsAs(array $types){ |
|
| 231 | + public function fieldsAs(array $types) { |
|
| 232 | 232 | $i=0; |
| 233 | - if(JArray::isAssociative($types)){ |
|
| 234 | - foreach ($types as $type=>$attributes){ |
|
| 235 | - if(\is_int($type)) |
|
| 236 | - $this->fieldAs($i++,$attributes,[]); |
|
| 237 | - else{ |
|
| 238 | - $type=preg_replace('/\d/', '', $type ); |
|
| 239 | - $this->fieldAs($i++,$type,$attributes); |
|
| 233 | + if (JArray::isAssociative($types)) { |
|
| 234 | + foreach ($types as $type=>$attributes) { |
|
| 235 | + if (\is_int($type)) |
|
| 236 | + $this->fieldAs($i++, $attributes, []); |
|
| 237 | + else { |
|
| 238 | + $type=preg_replace('/\d/', '', $type); |
|
| 239 | + $this->fieldAs($i++, $type, $attributes); |
|
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | - }else{ |
|
| 243 | - foreach ($types as $type){ |
|
| 244 | - $this->fieldAs($i++,$type); |
|
| 242 | + } else { |
|
| 243 | + foreach ($types as $type) { |
|
| 244 | + $this->fieldAs($i++, $type); |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - public function fieldAs($index,$type,$attributes=NULL){ |
|
| 249 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
| 250 | 250 | $method="fieldAs".\ucfirst($type); |
| 251 | - if(\method_exists($this, $method)){ |
|
| 252 | - if(!\is_array($attributes)){ |
|
| 251 | + if (\method_exists($this, $method)) { |
|
| 252 | + if (!\is_array($attributes)) { |
|
| 253 | 253 | $attributes=[$index]; |
| 254 | - }else{ |
|
| 254 | + } else { |
|
| 255 | 255 | \array_unshift($attributes, $index); |
| 256 | 256 | } |
| 257 | - \call_user_func_array([$this,$method], $attributes); |
|
| 257 | + \call_user_func_array([$this, $method], $attributes); |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
| 262 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
| 263 | - $button=new HtmlButton($id,$caption,$cssStyle); |
|
| 264 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]); |
|
| 261 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
| 262 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
| 263 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
| 264 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
|
| 265 | 265 | return $button; |
| 266 | - }, $index,$attributes,"submit"); |
|
| 266 | + }, $index, $attributes, "submit"); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 270 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
| 271 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 269 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 270 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
| 271 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 272 | 272 | return $button; |
| 273 | - }, $index,$attributes,"button"); |
|
| 273 | + }, $index, $attributes, "button"); |
|
| 274 | 274 | } |
| 275 | 275 | } |
@@ -21,83 +21,83 @@ discard block |
||
| 21 | 21 | use BaseTrait; |
| 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->_form=new HtmlForm($identifier); |
| 26 | 26 | $this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
| 29 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 30 | 30 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 34 | - if(!$this->_generated){ |
|
| 33 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 34 | + if (!$this->_generated) { |
|
| 35 | 35 | $this->_instanceViewer->setInstance($this->_modelInstance); |
| 36 | 36 | |
| 37 | 37 | $form=$this->content["form"]; |
| 38 | 38 | $this->_generateContent($form); |
| 39 | 39 | |
| 40 | - if(isset($this->_toolbar)){ |
|
| 40 | + if (isset($this->_toolbar)) { |
|
| 41 | 41 | $this->_setToolbarPosition($form); |
| 42 | 42 | } |
| 43 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
| 43 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
| 44 | 44 | $this->_generated=true; |
| 45 | 45 | } |
| 46 | - return parent::compile($js,$view); |
|
| 46 | + return parent::compile($js, $view); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @param HtmlForm $form |
| 51 | 51 | */ |
| 52 | - protected function _generateContent($form){ |
|
| 53 | - $values= $this->_instanceViewer->getValues(); |
|
| 52 | + protected function _generateContent($form) { |
|
| 53 | + $values=$this->_instanceViewer->getValues(); |
|
| 54 | 54 | $count=$this->_instanceViewer->count(); |
| 55 | 55 | $separators=$this->_instanceViewer->getSeparators(); |
| 56 | 56 | $headers=$this->_instanceViewer->getHeaders(); |
| 57 | 57 | $wrappers=$this->_instanceViewer->getWrappers(); |
| 58 | 58 | \sort($separators); |
| 59 | 59 | $size=\sizeof($separators); |
| 60 | - if($size===1){ |
|
| 60 | + if ($size===1) { |
|
| 61 | 61 | $i=-1; |
| 62 | - foreach ($values as $v){ |
|
| 62 | + foreach ($values as $v) { |
|
| 63 | 63 | $this->_generateFields($form, [$v], $headers, $i, $wrappers); |
| 64 | 64 | $i++; |
| 65 | 65 | } |
| 66 | - }else{ |
|
| 66 | + } else { |
|
| 67 | 67 | $separators[]=$count; |
| 68 | - for($i=0;$i<$size;$i++){ |
|
| 69 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
| 68 | + for ($i=0; $i<$size; $i++) { |
|
| 69 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
| 70 | 70 | $this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers); |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - protected function _generateFields($form,$values,$headers,$sepFirst,$wrappers){ |
|
| 75 | + protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers) { |
|
| 76 | 76 | $wrapper=null; |
| 77 | - if(isset($headers[$sepFirst+1])) |
|
| 78 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 79 | - if(isset($wrappers[$sepFirst+1])){ |
|
| 77 | + if (isset($headers[$sepFirst+1])) |
|
| 78 | + $form->addHeader($headers[$sepFirst+1], 4, true); |
|
| 79 | + if (isset($wrappers[$sepFirst+1])) { |
|
| 80 | 80 | $wrapper=$wrappers[$sepFirst+1]; |
| 81 | 81 | } |
| 82 | - if(\sizeof($values)===1){ |
|
| 82 | + if (\sizeof($values)===1) { |
|
| 83 | 83 | $added=$form->addField($values[0]); |
| 84 | - }elseif(\sizeof($values)>1){ |
|
| 84 | + }elseif (\sizeof($values)>1) { |
|
| 85 | 85 | $added=$form->addFields($values); |
| 86 | - }else |
|
| 86 | + } else |
|
| 87 | 87 | return; |
| 88 | - if(isset($wrapper)){ |
|
| 89 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
| 88 | + if (isset($wrapper)) { |
|
| 89 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * @return HtmlForm |
| 95 | 95 | */ |
| 96 | - public function getForm(){ |
|
| 96 | + public function getForm() { |
|
| 97 | 97 | return $this->content["form"]; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function addSeparatorAfter($fieldNum){ |
|
| 100 | + public function addSeparatorAfter($fieldNum) { |
|
| 101 | 101 | $fieldNum=$this->_getIndex($fieldNum); |
| 102 | 102 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
| 103 | 103 | return $this; |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | return $this; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 116 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
| 117 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 115 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 116 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
| 117 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 118 | 118 | $button->setProperty("type", "reset"); |
| 119 | 119 | return $button; |
| 120 | - }, $index,$attributes); |
|
| 120 | + }, $index, $attributes); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -136,19 +136,19 @@ discard block |
||
| 136 | 136 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public function addDividerBefore($index,$title){ |
|
| 139 | + public function addDividerBefore($index, $title) { |
|
| 140 | 140 | $index=$this->_getIndex($index); |
| 141 | 141 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
| 142 | 142 | return $this; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
| 145 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
| 146 | 146 | $index=$this->_getIndex($index); |
| 147 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
| 147 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
| 148 | 148 | return $this; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - public function run(JsUtils $js){ |
|
| 151 | + public function run(JsUtils $js) { |
|
| 152 | 152 | return parent::run($js); |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -16,17 +16,17 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @see \Ajax\semantic\widgets\dataform\DataForm::__construct() |
| 18 | 18 | */ |
| 19 | - public function __construct($identifier,$modelInstance=null,$fieldsOrder,$fieldsDefinition,$fields=[],$captions=[],$separators=[]) { |
|
| 20 | - if(!isset($modelInstance)){ |
|
| 19 | + public function __construct($identifier, $modelInstance=null, $fieldsOrder, $fieldsDefinition, $fields=[], $captions=[], $separators=[]) { |
|
| 20 | + if (!isset($modelInstance)) { |
|
| 21 | 21 | $modelInstance=$this->getDefaultModelInstance(); |
| 22 | 22 | } |
| 23 | - parent::__construct($identifier,$modelInstance); |
|
| 24 | - $this->_initForm($fieldsOrder, $fieldsDefinition,$fields,$captions,$separators); |
|
| 23 | + parent::__construct($identifier, $modelInstance); |
|
| 24 | + $this->_initForm($fieldsOrder, $fieldsDefinition, $fields, $captions, $separators); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | abstract protected function getDefaultModelInstance(); |
| 28 | 28 | |
| 29 | - protected function _initForm($fieldsOrder,$fieldsDefinition,$fields=[],$captions=[],$separators=[]){ |
|
| 29 | + protected function _initForm($fieldsOrder, $fieldsDefinition, $fields=[], $captions=[], $separators=[]) { |
|
| 30 | 30 | $this->_fieldsOrder=$fieldsOrder; |
| 31 | 31 | $this->setFields($fields); |
| 32 | 32 | $this->setSeparators($separators); |
@@ -34,26 +34,26 @@ discard block |
||
| 34 | 34 | $this->setCaptions($captions); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - protected function _getIndex($fieldName){ |
|
| 37 | + protected function _getIndex($fieldName) { |
|
| 38 | 38 | $index=$fieldName; |
| 39 | - if(\is_string($fieldName)){ |
|
| 39 | + if (\is_string($fieldName)) { |
|
| 40 | 40 | $index=\array_search($fieldName, $this->_fieldsOrder); |
| 41 | 41 | } |
| 42 | 42 | return $index; |
| 43 | 43 | } |
| 44 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
| 44 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
| 45 | 45 | $index=$this->_getIndex($index); |
| 46 | - return parent::_fieldAs($elementCallback, $index,$attributes,$prefix); |
|
| 46 | + return parent::_fieldAs($elementCallback, $index, $attributes, $prefix); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
| 50 | - public function removeField($fieldName){ |
|
| 50 | + public function removeField($fieldName) { |
|
| 51 | 51 | parent::removeField($fieldName); |
| 52 | - \array_splice($this->_fieldsOrder,$this->_getIndex($fieldName),1); |
|
| 52 | + \array_splice($this->_fieldsOrder, $this->_getIndex($fieldName), 1); |
|
| 53 | 53 | return $this; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 57 | - return parent::compile($js,$view); |
|
| 56 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 57 | + return parent::compile($js, $view); |
|
| 58 | 58 | } |
| 59 | 59 | } |
@@ -10,50 +10,50 @@ |
||
| 10 | 10 | * @param string $identifier |
| 11 | 11 | * @param object $modelInstance |
| 12 | 12 | */ |
| 13 | - public function __construct($identifier,$modelInstance=null,$fieldsOrder=[],$fieldsDefinition=[],$fields=[],$captions=[],$separators=[]) { |
|
| 14 | - parent::__construct($identifier,$modelInstance,$fieldsOrder,$fieldsDefinition,$fields,$captions,$separators); |
|
| 13 | + public function __construct($identifier, $modelInstance=null, $fieldsOrder=[], $fieldsDefinition=[], $fields=[], $captions=[], $separators=[]) { |
|
| 14 | + parent::__construct($identifier, $modelInstance, $fieldsOrder, $fieldsDefinition, $fields, $captions, $separators); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - protected function getDefaultModelInstance(){ |
|
| 17 | + protected function getDefaultModelInstance() { |
|
| 18 | 18 | return new UserModel(); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public static function regular($identifier,$modelInstance=null){ |
|
| 22 | - return new FormLogin($identifier,$modelInstance, |
|
| 23 | - ["message","login","password","remember","forget","submit","error"], |
|
| 24 | - ["message"=>[["icon"=>"sign in"]],"input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"checkbox","link","submit"=>["green fluid"],"message2"=>[["error"=>true]]], |
|
| 25 | - ["Connection","login","password","remember","forget","submit","error"], |
|
| 26 | - ["Please enter login and password to connect","Login","Password","Remember me.","Forgot your password?","Connection"], |
|
| 27 | - [0,2,4,5,6]); |
|
| 21 | + public static function regular($identifier, $modelInstance=null) { |
|
| 22 | + return new FormLogin($identifier, $modelInstance, |
|
| 23 | + ["message", "login", "password", "remember", "forget", "submit", "error"], |
|
| 24 | + ["message"=>[["icon"=>"sign in"]], "input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "checkbox", "link", "submit"=>["green fluid"], "message2"=>[["error"=>true]]], |
|
| 25 | + ["Connection", "login", "password", "remember", "forget", "submit", "error"], |
|
| 26 | + ["Please enter login and password to connect", "Login", "Password", "Remember me.", "Forgot your password?", "Connection"], |
|
| 27 | + [0, 2, 4, 5, 6]); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public static function smallInline($identifier,$modelInstance=null){ |
|
| 31 | - $result=new FormLogin($identifier,$modelInstance, |
|
| 32 | - ["login","password","submit"], |
|
| 33 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
| 34 | - ["login","password","submit"], |
|
| 35 | - ["","","Connection"], |
|
| 30 | + public static function smallInline($identifier, $modelInstance=null) { |
|
| 31 | + $result=new FormLogin($identifier, $modelInstance, |
|
| 32 | + ["login", "password", "submit"], |
|
| 33 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
| 34 | + ["login", "password", "submit"], |
|
| 35 | + ["", "", "Connection"], |
|
| 36 | 36 | [2]); |
| 37 | 37 | $result->addDividerBefore(0, "Connection"); |
| 38 | 38 | return $result; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public static function small($identifier,$modelInstance=null){ |
|
| 42 | - $result=new FormLogin($identifier,$modelInstance, |
|
| 43 | - ["login","password","submit"], |
|
| 44 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
| 45 | - ["login","password","submit"], |
|
| 46 | - ["Login","Password","Connection"], |
|
| 47 | - [1,2]); |
|
| 41 | + public static function small($identifier, $modelInstance=null) { |
|
| 42 | + $result=new FormLogin($identifier, $modelInstance, |
|
| 43 | + ["login", "password", "submit"], |
|
| 44 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
| 45 | + ["login", "password", "submit"], |
|
| 46 | + ["Login", "Password", "Connection"], |
|
| 47 | + [1, 2]); |
|
| 48 | 48 | $result->addDividerBefore(0, "Connection"); |
| 49 | 49 | return $result; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public static function attachedSegment($identifier,$modelInstance=null){ |
|
| 53 | - $result=self::regular($identifier,$modelInstance); |
|
| 54 | - $result->fieldAsMessage("message",["icon"=>"sign in","attached"=>true]); |
|
| 55 | - $result->addWrapper("message",null,"<div class='ui attached segment'>"); |
|
| 56 | - $result->addWrapper("error", null,"</div>"); |
|
| 52 | + public static function attachedSegment($identifier, $modelInstance=null) { |
|
| 53 | + $result=self::regular($identifier, $modelInstance); |
|
| 54 | + $result->fieldAsMessage("message", ["icon"=>"sign in", "attached"=>true]); |
|
| 55 | + $result->addWrapper("message", null, "<div class='ui attached segment'>"); |
|
| 56 | + $result->addWrapper("error", null, "</div>"); |
|
| 57 | 57 | return $result; |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -20,15 +20,15 @@ discard block |
||
| 20 | 20 | $this->params["fields"]=[]; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function addField($identifier){ |
|
| 23 | + public function addField($identifier) { |
|
| 24 | 24 | $this->params["fields"][$identifier]=new FieldValidation($identifier); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function setInline($value){ |
|
| 27 | + public function setInline($value) { |
|
| 28 | 28 | return $this->setParam("inline", true); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function setOn($value){ |
|
| 31 | + public function setOn($value) { |
|
| 32 | 32 | return $this->setParam("on", $value); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -40,33 +40,33 @@ discard block |
||
| 40 | 40 | * @param mixed $value |
| 41 | 41 | * @param string|NULL $prompt |
| 42 | 42 | */ |
| 43 | - public function addFieldRule($identifier,$type,$prompt=NULL,$value=NULL){ |
|
| 44 | - if(isset($this->params["fields"][$identifier])===false){ |
|
| 43 | + public function addFieldRule($identifier, $type, $prompt=NULL, $value=NULL) { |
|
| 44 | + if (isset($this->params["fields"][$identifier])===false) { |
|
| 45 | 45 | $this->addField($identifier); |
| 46 | 46 | } |
| 47 | - $this->params["fields"][$identifier]->addRule($type,$prompt,$value); |
|
| 47 | + $this->params["fields"][$identifier]->addRule($type, $prompt, $value); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * @param FieldValidation $fieldValidation |
| 52 | 52 | */ |
| 53 | - public function addFieldValidation($fieldValidation){ |
|
| 53 | + public function addFieldValidation($fieldValidation) { |
|
| 54 | 54 | $this->params["fields"][$fieldValidation->getIdentifier()]=$fieldValidation; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function setJs(JsUtils $js){ |
|
| 57 | + public function setJs(JsUtils $js) { |
|
| 58 | 58 | $this->js=$js; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | public function getScript() { |
| 62 | 62 | $allParams=$this->params; |
| 63 | - $this->jquery_code_for_compile=array (); |
|
| 63 | + $this->jquery_code_for_compile=array(); |
|
| 64 | 64 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).");"; |
| 65 | 65 | $this->compileEvents(); |
| 66 | 66 | return $this->compileJQueryCode(); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function onValid($jsCode){ |
|
| 69 | + public function onValid($jsCode) { |
|
| 70 | 70 | $this->addComponentEvent("onValid", $jsCode); |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | * @param string $action one of "select","auto","activate","combo","nothing","hide" |
| 18 | 18 | * @return \Ajax\semantic\components\Dropdown |
| 19 | 19 | */ |
| 20 | - public function setAction($action){ |
|
| 21 | - return $this->setParamCtrl("action", $action,array("select","auto","activate","combo","nothing","hide")); |
|
| 20 | + public function setAction($action) { |
|
| 21 | + return $this->setParamCtrl("action", $action, array("select", "auto", "activate", "combo", "nothing", "hide")); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | * @param string $event Event used to trigger dropdown (Hover, Click, Custom Event) |
| 27 | 27 | * @return \Ajax\semantic\components\Dropdown |
| 28 | 28 | */ |
| 29 | - public function setOn($event){ |
|
| 29 | + public function setOn($event) { |
|
| 30 | 30 | return $this->setParam("on", $event); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function setFullTextSearch($value){ |
|
| 33 | + public function setFullTextSearch($value) { |
|
| 34 | 34 | return $this->setParam("fullTextSearch", $value); |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function fromArray($array) { |
| 70 | - foreach ( $array as $key => $value ) { |
|
| 70 | + foreach ($array as $key => $value) { |
|
| 71 | 71 | $this->{$key}=$value; |
| 72 | 72 | } |
| 73 | 73 | return $this; |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public function JsonSerialize() { |
| 81 | 81 | $vars=get_object_vars($this); |
| 82 | - $result=array (); |
|
| 83 | - foreach ( $vars as $k => $v ) { |
|
| 82 | + $result=array(); |
|
| 83 | + foreach ($vars as $k => $v) { |
|
| 84 | 84 | if (isset($v)) |
| 85 | 85 | $result[$k]=$v; |
| 86 | 86 | } |
@@ -89,6 +89,6 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | public function search($query, $field="title") { |
| 91 | 91 | $value=$this->$field; |
| 92 | - return \stripos($value, $query) !== false; |
|
| 92 | + return \stripos($value, $query)!==false; |
|
| 93 | 93 | } |
| 94 | 94 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * @version 1.001 |
| 6 | 6 | * Generates a JSON Rule for the validation of a field |
| 7 | 7 | */ |
| 8 | -class Rule implements \JsonSerializable{ |
|
| 8 | +class Rule implements \JsonSerializable { |
|
| 9 | 9 | /** |
| 10 | 10 | * @var string |
| 11 | 11 | */ |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | private $value; |
| 22 | 22 | |
| 23 | - public function __construct($type,$prompt=NULL,$value=NULL){ |
|
| 23 | + public function __construct($type, $prompt=NULL, $value=NULL) { |
|
| 24 | 24 | $this->type=$type; |
| 25 | 25 | $this->prompt=$prompt; |
| 26 | 26 | $this->value=$value; |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | public function jsonSerialize() { |
| 57 | - $result= ["type"=>$this->type]; |
|
| 58 | - if(isset($this->prompt)) |
|
| 57 | + $result=["type"=>$this->type]; |
|
| 58 | + if (isset($this->prompt)) |
|
| 59 | 59 | $result["prompt"]=$this->prompt; |
| 60 | - if(isset($this->value)) |
|
| 60 | + if (isset($this->value)) |
|
| 61 | 61 | $result["value"]=$this->value; |
| 62 | 62 | return $result; |
| 63 | 63 | } |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | * @param string $prompt |
| 69 | 69 | * @return \Ajax\semantic\components\validation\Rule |
| 70 | 70 | */ |
| 71 | - public static function match($name,$prompt=NULL){ |
|
| 72 | - return new Rule("match[".$name."]",$prompt); |
|
| 71 | + public static function match($name, $prompt=NULL) { |
|
| 72 | + return new Rule("match[".$name."]", $prompt); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | * @param string $prompt |
| 79 | 79 | * @return \Ajax\semantic\components\validation\Rule |
| 80 | 80 | */ |
| 81 | - public static function different($name,$prompt=NULL){ |
|
| 82 | - return new Rule("different[".$name."]",$prompt); |
|
| 81 | + public static function different($name, $prompt=NULL) { |
|
| 82 | + return new Rule("different[".$name."]", $prompt); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -89,78 +89,78 @@ discard block |
||
| 89 | 89 | * @param string $prompt |
| 90 | 90 | * @return \Ajax\semantic\components\validation\Rule |
| 91 | 91 | */ |
| 92 | - public static function integer($min=NULL,$max=NULL,$prompt=NULL){ |
|
| 93 | - if(\is_int($min) && \is_int($max)) |
|
| 94 | - return new Rule("integer[{$min}..{$max}]",$prompt); |
|
| 95 | - return new Rule("integer",$prompt); |
|
| 92 | + public static function integer($min=NULL, $max=NULL, $prompt=NULL) { |
|
| 93 | + if (\is_int($min) && \is_int($max)) |
|
| 94 | + return new Rule("integer[{$min}..{$max}]", $prompt); |
|
| 95 | + return new Rule("integer", $prompt); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public static function decimal($prompt=NULL){ |
|
| 99 | - return new Rule("decimal",$prompt); |
|
| 98 | + public static function decimal($prompt=NULL) { |
|
| 99 | + return new Rule("decimal", $prompt); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public static function number($prompt=NULL){ |
|
| 103 | - return new Rule("number",$prompt); |
|
| 102 | + public static function number($prompt=NULL) { |
|
| 103 | + return new Rule("number", $prompt); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - public static function is($value,$prompt=NULL){ |
|
| 107 | - return new Rule("is[".$value."]",$prompt); |
|
| 106 | + public static function is($value, $prompt=NULL) { |
|
| 107 | + return new Rule("is[".$value."]", $prompt); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public static function isExactly($value,$prompt=NULL){ |
|
| 111 | - return new Rule("isExactly[".$value."]",$prompt); |
|
| 110 | + public static function isExactly($value, $prompt=NULL) { |
|
| 111 | + return new Rule("isExactly[".$value."]", $prompt); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - public static function not($value,$prompt=NULL){ |
|
| 115 | - return new Rule("not[".$value."]",$prompt); |
|
| 114 | + public static function not($value, $prompt=NULL) { |
|
| 115 | + return new Rule("not[".$value."]", $prompt); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - public static function notExactly($value,$prompt=NULL){ |
|
| 119 | - return new Rule("notExactly[".$value."]",$prompt); |
|
| 118 | + public static function notExactly($value, $prompt=NULL) { |
|
| 119 | + return new Rule("notExactly[".$value."]", $prompt); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public static function contains($value,$prompt=NULL){ |
|
| 123 | - return new Rule("contains[".$value."]",$prompt); |
|
| 122 | + public static function contains($value, $prompt=NULL) { |
|
| 123 | + return new Rule("contains[".$value."]", $prompt); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public static function containsExactly($value,$prompt=NULL){ |
|
| 127 | - return new Rule("containsExactly[".$value."]",$prompt); |
|
| 126 | + public static function containsExactly($value, $prompt=NULL) { |
|
| 127 | + return new Rule("containsExactly[".$value."]", $prompt); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public static function doesntContain($value,$prompt=NULL){ |
|
| 131 | - return new Rule("doesntContain[".$value."]",$prompt); |
|
| 130 | + public static function doesntContain($value, $prompt=NULL) { |
|
| 131 | + return new Rule("doesntContain[".$value."]", $prompt); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - public static function doesntContainExactly($value,$prompt=NULL){ |
|
| 135 | - return new Rule("doesntContainExactly[".$value."]",$prompt); |
|
| 134 | + public static function doesntContainExactly($value, $prompt=NULL) { |
|
| 135 | + return new Rule("doesntContainExactly[".$value."]", $prompt); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - public static function minCount($value,$prompt=NULL){ |
|
| 139 | - return new Rule("minCount[".$value."]",$prompt); |
|
| 138 | + public static function minCount($value, $prompt=NULL) { |
|
| 139 | + return new Rule("minCount[".$value."]", $prompt); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public static function maxCount($value,$prompt=NULL){ |
|
| 143 | - return new Rule("maxCount[".$value."]",$prompt); |
|
| 142 | + public static function maxCount($value, $prompt=NULL) { |
|
| 143 | + return new Rule("maxCount[".$value."]", $prompt); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - public static function exactCount($value,$prompt=NULL){ |
|
| 147 | - return new Rule("exactCount[".$value."]",$prompt); |
|
| 146 | + public static function exactCount($value, $prompt=NULL) { |
|
| 147 | + return new Rule("exactCount[".$value."]", $prompt); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - public static function email($prompt=NULL){ |
|
| 151 | - return new Rule("email",$prompt); |
|
| 150 | + public static function email($prompt=NULL) { |
|
| 151 | + return new Rule("email", $prompt); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public static function url($prompt=NULL){ |
|
| 155 | - return new Rule("url",$prompt); |
|
| 154 | + public static function url($prompt=NULL) { |
|
| 155 | + return new Rule("url", $prompt); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - public static function regExp($value,$prompt=NULL){ |
|
| 159 | - return new Rule("regExp",$prompt,$value); |
|
| 158 | + public static function regExp($value, $prompt=NULL) { |
|
| 159 | + return new Rule("regExp", $prompt, $value); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public static function custom($name,$jsFunction){ |
|
| 163 | - return "$.fn.form.settings.rules.".$name." =".$jsFunction ; |
|
| 162 | + public static function custom($name, $jsFunction) { |
|
| 163 | + return "$.fn.form.settings.rules.".$name." =".$jsFunction; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | } |