@@ -56,8 +56,9 @@ discard block |
||
| 56 | 56 | $name=$attributes["name"]; |
| 57 | 57 | } |
| 58 | 58 | $element=$elementCallback($this->_getFieldIdentifier($prefix),$name,$value,""); |
| 59 | - if(\is_array($attributes)) |
|
| 60 | - $this->_applyAttributes($element, $attributes,$index); |
|
| 59 | + if(\is_array($attributes)) { |
|
| 60 | + $this->_applyAttributes($element, $attributes,$index); |
|
| 61 | + } |
|
| 61 | 62 | $element->setDisabled(!$this->_edition); |
| 62 | 63 | return $element; |
| 63 | 64 | }); |
@@ -92,8 +93,9 @@ discard block |
||
| 92 | 93 | public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
| 93 | 94 | return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
| 94 | 95 | $header=new HtmlHeader($id,$niveau,$value); |
| 95 | - if(isset($icon)) |
|
| 96 | - $header->asIcon($icon, $value); |
|
| 96 | + if(isset($icon)) { |
|
| 97 | + $header->asIcon($icon, $value); |
|
| 98 | + } |
|
| 97 | 99 | return $header; |
| 98 | 100 | }, $index,$attributes,"header"); |
| 99 | 101 | } |
@@ -101,7 +103,9 @@ discard block |
||
| 101 | 103 | |
| 102 | 104 | public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
| 103 | 105 | $this->setValueFunction($index,function($img) use($size,$circular){ |
| 104 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
| 106 | + $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) { |
|
| 107 | + $image->setCircular(); |
|
| 108 | + } |
|
| 105 | 109 | return $image; |
| 106 | 110 | }); |
| 107 | 111 | return $this; |
@@ -22,6 +22,10 @@ discard block |
||
| 22 | 22 | trait FieldAsTrait{ |
| 23 | 23 | |
| 24 | 24 | abstract protected function _getFieldIdentifier($prefix); |
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @param \Closure $callback |
|
| 28 | + */ |
|
| 25 | 29 | abstract public function setValueFunction($index,$callback); |
| 26 | 30 | |
| 27 | 31 | /** |
@@ -47,6 +51,10 @@ discard block |
||
| 47 | 51 | |
| 48 | 52 | protected function _addRules($element,&$attributes){} |
| 49 | 53 | |
| 54 | + /** |
|
| 55 | + * @param \Closure $elementCallback |
|
| 56 | + * @param string $prefix |
|
| 57 | + */ |
|
| 50 | 58 | protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
| 51 | 59 | $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
| 52 | 60 | $name=$this->_instanceViewer->getFieldName($index)."[]"; |
@@ -19,43 +19,43 @@ discard block |
||
| 19 | 19 | * @property boolean $_edition |
| 20 | 20 | * @property mixed _modelInstance |
| 21 | 21 | */ |
| 22 | -trait FieldAsTrait{ |
|
| 22 | +trait FieldAsTrait { |
|
| 23 | 23 | |
| 24 | 24 | abstract protected function _getFieldIdentifier($prefix); |
| 25 | - abstract public function setValueFunction($index,$callback); |
|
| 25 | + abstract public function setValueFunction($index, $callback); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @param HtmlFormField $element |
| 29 | 29 | * @param array $attributes |
| 30 | 30 | */ |
| 31 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
| 31 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
| 32 | 32 | $this->_addRules($element, $attributes); |
| 33 | - if(isset($attributes["callback"])){ |
|
| 33 | + if (isset($attributes["callback"])) { |
|
| 34 | 34 | $callback=$attributes["callback"]; |
| 35 | - if(\is_callable($callback)){ |
|
| 36 | - $callback($element,$this->_modelInstance,$index); |
|
| 35 | + if (\is_callable($callback)) { |
|
| 36 | + $callback($element, $this->_modelInstance, $index); |
|
| 37 | 37 | unset($attributes["callback"]); |
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | $element->fromArray($attributes); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - private function _getLabelField($caption,$icon=NULL){ |
|
| 44 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
| 43 | + private function _getLabelField($caption, $icon=NULL) { |
|
| 44 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
| 45 | 45 | return $label; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - protected function _addRules($element,&$attributes){} |
|
| 48 | + protected function _addRules($element, &$attributes) {} |
|
| 49 | 49 | |
| 50 | - protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
|
| 51 | - $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
|
| 50 | + protected function _fieldAs($elementCallback, $index, $attributes=NULL, $prefix=null) { |
|
| 51 | + $this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback, $prefix){ |
|
| 52 | 52 | $name=$this->_instanceViewer->getFieldName($index)."[]"; |
| 53 | - if(isset($attributes["name"])){ |
|
| 53 | + if (isset($attributes["name"])) { |
|
| 54 | 54 | $name=$attributes["name"]; |
| 55 | 55 | } |
| 56 | - $element=$elementCallback($this->_getFieldIdentifier($prefix),$name,$value,""); |
|
| 57 | - if(\is_array($attributes)) |
|
| 58 | - $this->_applyAttributes($element, $attributes,$index); |
|
| 56 | + $element=$elementCallback($this->_getFieldIdentifier($prefix), $name, $value, ""); |
|
| 57 | + if (\is_array($attributes)) |
|
| 58 | + $this->_applyAttributes($element, $attributes, $index); |
|
| 59 | 59 | $element->setDisabled(!$this->_edition); |
| 60 | 60 | return $element; |
| 61 | 61 | }); |
@@ -63,102 +63,102 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
| 66 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
| 67 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
| 68 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
| 66 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
| 67 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
| 68 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
| 69 | 69 | return $pb; |
| 70 | 70 | }); |
| 71 | 71 | return $this; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
| 75 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
| 76 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
| 74 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
| 75 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
| 76 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
| 77 | 77 | return $rating; |
| 78 | 78 | }); |
| 79 | 79 | return $this; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - public function fieldAsLabel($index,$icon=NULL){ |
|
| 83 | - $this->setValueFunction($index,function($caption) use($icon){ |
|
| 84 | - $lbl=$this->_getLabelField($caption,$icon); |
|
| 82 | + public function fieldAsLabel($index, $icon=NULL) { |
|
| 83 | + $this->setValueFunction($index, function($caption) use($icon){ |
|
| 84 | + $lbl=$this->_getLabelField($caption, $icon); |
|
| 85 | 85 | return $lbl; |
| 86 | 86 | }); |
| 87 | 87 | return $this; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
| 91 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
| 92 | - $header=new HtmlHeader($id,$niveau,$value); |
|
| 93 | - if(isset($icon)) |
|
| 90 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
| 91 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
| 92 | + $header=new HtmlHeader($id, $niveau, $value); |
|
| 93 | + if (isset($icon)) |
|
| 94 | 94 | $header->asIcon($icon, $value); |
| 95 | 95 | return $header; |
| 96 | - }, $index,$attributes,"header"); |
|
| 96 | + }, $index, $attributes, "header"); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | |
| 100 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
| 101 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
| 102 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
| 100 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
| 101 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
| 102 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
| 103 | 103 | return $image; |
| 104 | 104 | }); |
| 105 | 105 | return $this; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
| 109 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 110 | - $img=new HtmlImage($id,$value); |
|
| 108 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
| 109 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 110 | + $img=new HtmlImage($id, $value); |
|
| 111 | 111 | $img->asAvatar(); |
| 112 | 112 | return $img; |
| 113 | - }, $index,$attributes,"avatar"); |
|
| 113 | + }, $index, $attributes, "avatar"); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
| 117 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 118 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
| 116 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
| 117 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 118 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
| 119 | 119 | return $input; |
| 120 | - }, $index,$attributes,"radio"); |
|
| 120 | + }, $index, $attributes, "radio"); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public function fieldAsInput($index,$attributes=NULL){ |
|
| 124 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 125 | - $input= new HtmlFormInput($id,"","text",$value); |
|
| 123 | + public function fieldAsInput($index, $attributes=NULL) { |
|
| 124 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 125 | + $input=new HtmlFormInput($id, "", "text", $value); |
|
| 126 | 126 | $input->setName($name); |
| 127 | 127 | return $input; |
| 128 | - }, $index,$attributes,"input"); |
|
| 128 | + }, $index, $attributes, "input"); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
| 132 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 133 | - $textarea=new HtmlFormTextarea($id,null,$value); |
|
| 131 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
| 132 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 133 | + $textarea=new HtmlFormTextarea($id, null, $value); |
|
| 134 | 134 | $textarea->setName($name); |
| 135 | 135 | return $textarea; |
| 136 | - }, $index,$attributes,"textarea"); |
|
| 136 | + }, $index, $attributes, "textarea"); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
| 140 | - if(!\is_array($attributes)){ |
|
| 139 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
| 140 | + if (!\is_array($attributes)) { |
|
| 141 | 141 | $attributes=[]; |
| 142 | 142 | } |
| 143 | 143 | $attributes["imputType"]="hidden"; |
| 144 | - return $this->fieldAsInput($index,$attributes); |
|
| 144 | + return $this->fieldAsInput($index, $attributes); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
| 148 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 149 | - $input=new HtmlFormCheckbox($id,NULL,$this->_instanceViewer->getIdentifier()); |
|
| 147 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
| 148 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 149 | + $input=new HtmlFormCheckbox($id, NULL, $this->_instanceViewer->getIdentifier()); |
|
| 150 | 150 | $input->setChecked(JString::isBooleanTrue($value)); |
| 151 | 151 | $input->getField()->setProperty("name", $name); |
| 152 | 152 | return $input; |
| 153 | - }, $index,$attributes,"ck"); |
|
| 153 | + }, $index, $attributes, "ck"); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
| 157 | - return $this->_fieldAs(function($id,$name,$value) use($elements,$multiple){ |
|
| 156 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
| 157 | + return $this->_fieldAs(function($id, $name, $value) use($elements, $multiple){ |
|
| 158 | 158 | //$dd=new HtmlDropdown($id,$value,$elements); |
| 159 | - $dd=new HtmlFormDropdown($id,$elements,NULL,$value); |
|
| 160 | - $dd->asSelect($name,$multiple); |
|
| 159 | + $dd=new HtmlFormDropdown($id, $elements, NULL, $value); |
|
| 160 | + $dd->asSelect($name, $multiple); |
|
| 161 | 161 | return $dd; |
| 162 | - }, $index,$attributes,"dd"); |
|
| 162 | + }, $index, $attributes, "dd"); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | \ No newline at end of file |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | * @param string $tagName |
| 159 | 159 | * @return HtmlLabel |
| 160 | 160 | */ |
| 161 | - public function htmlLabel($identifier, $content="", $icon=NULL,$tagName="div") { |
|
| 162 | - return $this->addHtmlComponent(new HtmlLabel($identifier, $content,$icon, $tagName)); |
|
| 161 | + public function htmlLabel($identifier, $content="", $icon=NULL, $tagName="div") { |
|
| 162 | + return $this->addHtmlComponent(new HtmlLabel($identifier, $content, $icon, $tagName)); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -168,8 +168,8 @@ discard block |
||
| 168 | 168 | * @param array $attributes |
| 169 | 169 | * @return HtmlLabelGroups |
| 170 | 170 | */ |
| 171 | - public function htmlLabelGroups($identifier,$labels=array(),$attributes=array()){ |
|
| 172 | - return $this->addHtmlComponent(new HtmlLabelGroups($identifier,$labels,$attributes)); |
|
| 171 | + public function htmlLabelGroups($identifier, $labels=array(), $attributes=array()) { |
|
| 172 | + return $this->addHtmlComponent(new HtmlLabelGroups($identifier, $labels, $attributes)); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | abstract public function addToProperty($name, $value, $separator=" "); |
| 18 | 18 | abstract public function addLabel($caption, $style="label-default", $leftSeparator=" "); |
| 19 | - abstract public function addContent($content,$before=false); |
|
| 19 | + abstract public function addContent($content, $before=false); |
|
| 20 | 20 | abstract public function getField(); |
| 21 | 21 | abstract public function getDataField(); |
| 22 | 22 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function addLoading() { |
| 28 | - if ($this->_hasIcon === false) { |
|
| 28 | + if ($this->_hasIcon===false) { |
|
| 29 | 29 | throw new \Exception("Input must have an icon for showing a loader, use addIcon before"); |
| 30 | 30 | } |
| 31 | 31 | return $this->addToProperty("class", State::LOADING); |
@@ -33,56 +33,56 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function labeled($label, $direction=Direction::LEFT, $icon=NULL) { |
| 35 | 35 | $field=$this->getField(); |
| 36 | - $labelO=$field->addLabel($label,$direction===Direction::LEFT,$icon); |
|
| 37 | - $field->addToProperty("class", $direction . " labeled"); |
|
| 36 | + $labelO=$field->addLabel($label, $direction===Direction::LEFT, $icon); |
|
| 37 | + $field->addToProperty("class", $direction." labeled"); |
|
| 38 | 38 | return $labelO; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function labeledToCorner($icon, $direction=Direction::LEFT) { |
| 42 | - return $this->labeled("", $direction . " corner", $icon)->toCorner($direction); |
|
| 42 | + return $this->labeled("", $direction." corner", $icon)->toCorner($direction); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function addAction($action, $direction=Direction::RIGHT, $icon=NULL, $labeled=false) { |
| 46 | 46 | $field=$this->getField(); |
| 47 | 47 | $actionO=$action; |
| 48 | - if (\is_object($action) === false) { |
|
| 49 | - $actionO=new HtmlButton("action-" . $this->identifier, $action); |
|
| 48 | + if (\is_object($action)===false) { |
|
| 49 | + $actionO=new HtmlButton("action-".$this->identifier, $action); |
|
| 50 | 50 | if (isset($icon)) |
| 51 | 51 | $actionO->addIcon($icon, true, $labeled); |
| 52 | 52 | } |
| 53 | - $field->addToProperty("class", $direction . " action"); |
|
| 54 | - $field->addContent($actionO, \strstr($direction, Direction::LEFT) !== false); |
|
| 53 | + $field->addToProperty("class", $direction." action"); |
|
| 54 | + $field->addContent($actionO, \strstr($direction, Direction::LEFT)!==false); |
|
| 55 | 55 | return $actionO; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function addDropdown($label="", $items=array(),$direction=Direction::RIGHT){ |
|
| 59 | - $labelO=new HtmlDropdown("dd-".$this->identifier,$label,$items); |
|
| 60 | - $labelO->asSelect("select-".$this->identifier,false,true); |
|
| 61 | - return $this->labeled($labelO,$direction); |
|
| 58 | + public function addDropdown($label="", $items=array(), $direction=Direction::RIGHT) { |
|
| 59 | + $labelO=new HtmlDropdown("dd-".$this->identifier, $label, $items); |
|
| 60 | + $labelO->asSelect("select-".$this->identifier, false, true); |
|
| 61 | + return $this->labeled($labelO, $direction); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public function setTransparent() { |
| 65 | 65 | return $this->getField()->addToProperty("class", "transparent"); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function setReadonly(){ |
|
| 68 | + public function setReadonly() { |
|
| 69 | 69 | $this->getDataField()->setProperty("readonly", ""); |
| 70 | 70 | return $this; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function setName($name){ |
|
| 74 | - $this->getDataField()->setProperty("name",$name); |
|
| 73 | + public function setName($name) { |
|
| 74 | + $this->getDataField()->setProperty("name", $name); |
|
| 75 | 75 | return $this; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public function setFluid(){ |
|
| 79 | - $this->getField()->addToProperty("class","fluid"); |
|
| 78 | + public function setFluid() { |
|
| 79 | + $this->getField()->addToProperty("class", "fluid"); |
|
| 80 | 80 | return $this; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | public function setDisabled($disable=true) { |
| 84 | 84 | $field=$this->getField(); |
| 85 | - if($disable) |
|
| 85 | + if ($disable) |
|
| 86 | 86 | $field->addToProperty("class", "disabled"); |
| 87 | 87 | return $this; |
| 88 | 88 | } |
@@ -47,8 +47,9 @@ discard block |
||
| 47 | 47 | $actionO=$action; |
| 48 | 48 | if (\is_object($action) === false) { |
| 49 | 49 | $actionO=new HtmlButton("action-" . $this->identifier, $action); |
| 50 | - if (isset($icon)) |
|
| 51 | - $actionO->addIcon($icon, true, $labeled); |
|
| 50 | + if (isset($icon)) { |
|
| 51 | + $actionO->addIcon($icon, true, $labeled); |
|
| 52 | + } |
|
| 52 | 53 | } |
| 53 | 54 | $field->addToProperty("class", $direction . " action"); |
| 54 | 55 | $field->addContent($actionO, \strstr($direction, Direction::LEFT) !== false); |
@@ -82,8 +83,9 @@ discard block |
||
| 82 | 83 | |
| 83 | 84 | public function setDisabled($disable=true) { |
| 84 | 85 | $field=$this->getField(); |
| 85 | - if($disable) |
|
| 86 | - $field->addToProperty("class", "disabled"); |
|
| 86 | + if($disable) { |
|
| 87 | + $field->addToProperty("class", "disabled"); |
|
| 88 | + } |
|
| 87 | 89 | return $this; |
| 88 | 90 | } |
| 89 | 91 | } |
| 90 | 92 | \ No newline at end of file |
@@ -38,18 +38,18 @@ discard block |
||
| 38 | 38 | return $this->getHtmlCk()->attachEvents($events); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function getField(){ |
|
| 41 | + public function getField() { |
|
| 42 | 42 | //TODO check getField() ? |
| 43 | 43 | return $this->content["field"]; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public function getHtmlCk(){ |
|
| 46 | + public function getHtmlCk() { |
|
| 47 | 47 | return $this->content["field"]; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function getDataField(){ |
|
| 51 | - $field= $this->getField(); |
|
| 52 | - if($field instanceof AbstractCheckbox) |
|
| 50 | + public function getDataField() { |
|
| 51 | + $field=$this->getField(); |
|
| 52 | + if ($field instanceof AbstractCheckbox) |
|
| 53 | 53 | $field=$field->getField(); |
| 54 | 54 | return $field; |
| 55 | 55 | } |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | * @param boolean $value |
| 60 | 60 | * @return HtmlFormField |
| 61 | 61 | */ |
| 62 | - public function setChecked($value=true){ |
|
| 63 | - if($value===true){ |
|
| 62 | + public function setChecked($value=true) { |
|
| 63 | + if ($value===true) { |
|
| 64 | 64 | $this->getDataField()->setProperty("checked", "checked"); |
| 65 | - }else{ |
|
| 65 | + } else { |
|
| 66 | 66 | $this->getDataField()->removeProperty("checked"); |
| 67 | 67 | } |
| 68 | 68 | return $this; |
@@ -49,8 +49,9 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | public function getDataField(){ |
| 51 | 51 | $field= $this->getField(); |
| 52 | - if($field instanceof AbstractCheckbox) |
|
| 53 | - $field=$field->getField(); |
|
| 52 | + if($field instanceof AbstractCheckbox) { |
|
| 53 | + $field=$field->getField(); |
|
| 54 | + } |
|
| 54 | 55 | return $field; |
| 55 | 56 | } |
| 56 | 57 | |
@@ -62,7 +63,7 @@ discard block |
||
| 62 | 63 | public function setChecked($value=true){ |
| 63 | 64 | if($value===true){ |
| 64 | 65 | $this->getDataField()->setProperty("checked", "checked"); |
| 65 | - }else{ |
|
| 66 | + } else{ |
|
| 66 | 67 | $this->getDataField()->removeProperty("checked"); |
| 67 | 68 | } |
| 68 | 69 | return $this; |
@@ -14,34 +14,34 @@ discard block |
||
| 14 | 14 | use FieldTrait; |
| 15 | 15 | protected $_container; |
| 16 | 16 | protected $_validation; |
| 17 | - public function __construct($identifier, $field,$label=NULL) { |
|
| 18 | - parent::__construct($identifier, "div","field"); |
|
| 17 | + public function __construct($identifier, $field, $label=NULL) { |
|
| 18 | + parent::__construct($identifier, "div", "field"); |
|
| 19 | 19 | $this->content=array(); |
| 20 | - $this->_states=[State::ERROR,State::DISABLED]; |
|
| 21 | - if(isset($label)) |
|
| 20 | + $this->_states=[State::ERROR, State::DISABLED]; |
|
| 21 | + if (isset($label)) |
|
| 22 | 22 | $this->setLabel($label); |
| 23 | 23 | $this->setField($field); |
| 24 | 24 | $this->_validation=NULL; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function addPointingLabel($label,$pointing=Direction::NONE){ |
|
| 28 | - $labelO=new HtmlLabel("",$label); |
|
| 27 | + public function addPointingLabel($label, $pointing=Direction::NONE) { |
|
| 28 | + $labelO=new HtmlLabel("", $label); |
|
| 29 | 29 | $labelO->setPointing($pointing); |
| 30 | - $this->addContent($labelO,$pointing==="below" || $pointing==="right"); |
|
| 30 | + $this->addContent($labelO, $pointing==="below" || $pointing==="right"); |
|
| 31 | 31 | return $labelO; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function setLabel($label){ |
|
| 34 | + public function setLabel($label) { |
|
| 35 | 35 | $labelO=$label; |
| 36 | - if(\is_string($label)){ |
|
| 37 | - $labelO=new HtmlSemDoubleElement("","label",""); |
|
| 36 | + if (\is_string($label)) { |
|
| 37 | + $labelO=new HtmlSemDoubleElement("", "label", ""); |
|
| 38 | 38 | $labelO->setContent($label); |
| 39 | - $labelO->setProperty("for", \str_replace("field-", "",$this->identifier)); |
|
| 39 | + $labelO->setProperty("for", \str_replace("field-", "", $this->identifier)); |
|
| 40 | 40 | } |
| 41 | 41 | $this->content["label"]=$labelO; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function setField($field){ |
|
| 44 | + public function setField($field) { |
|
| 45 | 45 | $this->content["field"]=$field; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | * Returns the label or null |
| 50 | 50 | * @return mixed |
| 51 | 51 | */ |
| 52 | - public function getLabel(){ |
|
| 53 | - if(\array_key_exists("label", $this->content)) |
|
| 52 | + public function getLabel() { |
|
| 53 | + if (\array_key_exists("label", $this->content)) |
|
| 54 | 54 | return $this->content["label"]; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * Return the field |
| 59 | 59 | * @return mixed |
| 60 | 60 | */ |
| 61 | - public function getField(){ |
|
| 61 | + public function getField() { |
|
| 62 | 62 | return $this->content["field"]; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | * Return the field with data |
| 67 | 67 | * @return mixed |
| 68 | 68 | */ |
| 69 | - public function getDataField(){ |
|
| 69 | + public function getDataField() { |
|
| 70 | 70 | return $this->content["field"]; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * puts the label before or behind |
| 75 | 75 | */ |
| 76 | - public function swapLabel(){ |
|
| 76 | + public function swapLabel() { |
|
| 77 | 77 | $label=$this->getLabel(); |
| 78 | 78 | unset($this->content["label"]); |
| 79 | 79 | $this->content["label"]=$label; |
@@ -84,31 +84,31 @@ discard block |
||
| 84 | 84 | * @param int $width |
| 85 | 85 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
| 86 | 86 | */ |
| 87 | - public function setWidth($width){ |
|
| 88 | - if(\is_int($width)){ |
|
| 87 | + public function setWidth($width) { |
|
| 88 | + if (\is_int($width)) { |
|
| 89 | 89 | $width=Wide::getConstants()["W".$width]; |
| 90 | 90 | } |
| 91 | 91 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
| 92 | - if(isset($this->_container)){ |
|
| 92 | + if (isset($this->_container)) { |
|
| 93 | 93 | $this->_container->setEqualWidth(false); |
| 94 | 94 | } |
| 95 | - return $this->addToPropertyCtrl("class", "wide",array("wide")); |
|
| 95 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * Field displays an error state |
| 100 | 100 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
| 101 | 101 | */ |
| 102 | - public function setError(){ |
|
| 102 | + public function setError() { |
|
| 103 | 103 | return $this->addToProperty("class", "error"); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - public function setInline(){ |
|
| 106 | + public function setInline() { |
|
| 107 | 107 | return $this->addToProperty("class", "inline"); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public function jsState($state){ |
|
| 111 | - return $this->jsDoJquery("addClass",$state); |
|
| 110 | + public function jsState($state) { |
|
| 111 | + return $this->jsDoJquery("addClass", $state); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | public function setContainer($_container) { |
@@ -116,34 +116,34 @@ discard block |
||
| 116 | 116 | return $this; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - public function setReadonly(){ |
|
| 119 | + public function setReadonly() { |
|
| 120 | 120 | $this->getField()->setProperty("readonly", ""); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
| 123 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
| 124 | 124 | $field=$this->getDataField(); |
| 125 | - if(isset($field)){ |
|
| 126 | - if(!isset($this->_validation)){ |
|
| 125 | + if (isset($field)) { |
|
| 126 | + if (!isset($this->_validation)) { |
|
| 127 | 127 | $this->_validation=new FieldValidation($field->getIdentifier()); |
| 128 | 128 | } |
| 129 | - if($type==="empty"){ |
|
| 130 | - $this->addToProperty("class","required"); |
|
| 129 | + if ($type==="empty") { |
|
| 130 | + $this->addToProperty("class", "required"); |
|
| 131 | 131 | } |
| 132 | - $this->_validation->addRule($type,$prompt,$value); |
|
| 132 | + $this->_validation->addRule($type, $prompt, $value); |
|
| 133 | 133 | } |
| 134 | 134 | return $this; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - public function addRules(array $rules){ |
|
| 138 | - foreach ($rules as $rule){ |
|
| 137 | + public function addRules(array $rules) { |
|
| 138 | + foreach ($rules as $rule) { |
|
| 139 | 139 | $this->addRule($rule); |
| 140 | 140 | } |
| 141 | 141 | return $this; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - public function addIcon($icon,$direction=Direction::LEFT){ |
|
| 144 | + public function addIcon($icon, $direction=Direction::LEFT) { |
|
| 145 | 145 | $field=$this->getField(); |
| 146 | - return $field->addIcon($icon,$direction); |
|
| 146 | + return $field->addIcon($icon, $direction); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | public function getValidation() { |
@@ -18,8 +18,9 @@ discard block |
||
| 18 | 18 | parent::__construct($identifier, "div","field"); |
| 19 | 19 | $this->content=array(); |
| 20 | 20 | $this->_states=[State::ERROR,State::DISABLED]; |
| 21 | - if(isset($label)) |
|
| 22 | - $this->setLabel($label); |
|
| 21 | + if(isset($label)) { |
|
| 22 | + $this->setLabel($label); |
|
| 23 | + } |
|
| 23 | 24 | $this->setField($field); |
| 24 | 25 | $this->_validation=NULL; |
| 25 | 26 | } |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | * @return mixed |
| 51 | 52 | */ |
| 52 | 53 | public function getLabel(){ |
| 53 | - if(\array_key_exists("label", $this->content)) |
|
| 54 | - return $this->content["label"]; |
|
| 54 | + if(\array_key_exists("label", $this->content)) { |
|
| 55 | + return $this->content["label"]; |
|
| 56 | + } |
|
| 55 | 57 | } |
| 56 | 58 | |
| 57 | 59 | /** |
@@ -7,25 +7,25 @@ |
||
| 7 | 7 | |
| 8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
| 9 | 9 | |
| 10 | - public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false,$associative=true) { |
|
| 11 | - parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label); |
|
| 10 | + public function __construct($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false, $associative=true) { |
|
| 11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public function setItems($items){ |
|
| 14 | + public function setItems($items) { |
|
| 15 | 15 | return $this->getField()->setItems($items); |
| 16 | 16 | } |
| 17 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
| 18 | - return $this->getField()->addItem($item,$value,$image); |
|
| 17 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
| 18 | + return $this->getField()->addItem($item, $value, $image); |
|
| 19 | 19 | } |
| 20 | - public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$associative=true){ |
|
| 21 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative); |
|
| 20 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $associative=true) { |
|
| 21 | + return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function getDataField(){ |
|
| 24 | + public function getDataField() { |
|
| 25 | 25 | return $this->getField()->getInput(); |
| 26 | 26 | } |
| 27 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
| 28 | - $this->getField()->asSelect($name,$multiple,$selection); |
|
| 27 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
| 28 | + $this->getField()->asSelect($name, $multiple, $selection); |
|
| 29 | 29 | return $this; |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class HtmlPopup extends HtmlSemDoubleElement { |
| 13 | 13 | private $_container; |
| 14 | - public function __construct(BaseHtml $container,$identifier, $content="") { |
|
| 14 | + public function __construct(BaseHtml $container, $identifier, $content="") { |
|
| 15 | 15 | parent::__construct($identifier, "div"); |
| 16 | 16 | $this->_container=$container; |
| 17 | 17 | $this->setClass("ui popup"); |
@@ -19,9 +19,9 @@ discard block |
||
| 19 | 19 | $this->_params=array("on"=>"hover"); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function addList($items=array(),$header=NULL){ |
|
| 23 | - if(!$this->content instanceof HtmlGrid){ |
|
| 24 | - $this->content=new HtmlGrid("Grid-".$this->identifier,0); |
|
| 22 | + public function addList($items=array(), $header=NULL) { |
|
| 23 | + if (!$this->content instanceof HtmlGrid) { |
|
| 24 | + $this->content=new HtmlGrid("Grid-".$this->identifier, 0); |
|
| 25 | 25 | } |
| 26 | 26 | $grid=$this->content; |
| 27 | 27 | |
@@ -29,12 +29,12 @@ discard block |
||
| 29 | 29 | $colCount++; |
| 30 | 30 | $grid->setColsCount($colCount); |
| 31 | 31 | |
| 32 | - $list=new HtmlList("",$items); |
|
| 32 | + $list=new HtmlList("", $items); |
|
| 33 | 33 | $list->asLink(); |
| 34 | - if(isset($header)){ |
|
| 35 | - $list->addHeader(4,$header); |
|
| 34 | + if (isset($header)) { |
|
| 35 | + $list->addHeader(4, $header); |
|
| 36 | 36 | } |
| 37 | - $grid->getCell(0,$colCount-1)->setContent($list); |
|
| 37 | + $grid->getCell(0, $colCount-1)->setContent($list); |
|
| 38 | 38 | $grid->setDivided()->setRelaxed(true); |
| 39 | 39 | return $list; |
| 40 | 40 | } |
@@ -42,14 +42,14 @@ discard block |
||
| 42 | 42 | /** |
| 43 | 43 | * A popup can have no maximum width and continue to flow to fit its content |
| 44 | 44 | */ |
| 45 | - public function setFlowing(){ |
|
| 45 | + public function setFlowing() { |
|
| 46 | 46 | return $this->addToProperty("class", "flowing"); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * A popup can provide more basic formatting |
| 51 | 51 | */ |
| 52 | - public function setBasic(){ |
|
| 52 | + public function setBasic() { |
|
| 53 | 53 | return $this->addToProperty("class", "basic"); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -57,22 +57,22 @@ discard block |
||
| 57 | 57 | * {@inheritDoc} |
| 58 | 58 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
| 59 | 59 | */ |
| 60 | - public function run(JsUtils $js){ |
|
| 60 | + public function run(JsUtils $js) { |
|
| 61 | 61 | $this->_params["popup"]="#".$this->identifier; |
| 62 | - $js->semantic()->popup("#".$this->_container->getIdentifier(),$this->_params); |
|
| 62 | + $js->semantic()->popup("#".$this->_container->getIdentifier(), $this->_params); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public function setOn($event="click"){ |
|
| 65 | + public function setOn($event="click") { |
|
| 66 | 66 | $this->_params["on"]=$event; |
| 67 | 67 | return $this; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function setInline($value=true){ |
|
| 70 | + public function setInline($value=true) { |
|
| 71 | 71 | $this->_params["inline"]=$value; |
| 72 | 72 | return $this; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public function setPosition($position){ |
|
| 75 | + public function setPosition($position) { |
|
| 76 | 76 | $this->_params["position"]=$position; |
| 77 | 77 | return $this; |
| 78 | 78 | } |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | * @property string $identifier |
| 13 | 13 | */ |
| 14 | 14 | trait BaseTrait { |
| 15 | - protected $_variations=[ ]; |
|
| 16 | - protected $_states=[ ]; |
|
| 15 | + protected $_variations=[]; |
|
| 16 | + protected $_states=[]; |
|
| 17 | 17 | protected $_baseClass; |
| 18 | 18 | |
| 19 | 19 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | abstract public function setProperty($name, $value); |
| 28 | 28 | |
| 29 | - abstract public function addContent($content,$before=false); |
|
| 29 | + abstract public function addContent($content, $before=false); |
|
| 30 | 30 | |
| 31 | 31 | abstract public function onCreate($jsCode); |
| 32 | 32 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $this->setProperty("class", $this->_baseClass); |
| 48 | 48 | if (\is_string($variations)) |
| 49 | 49 | $variations=\explode(" ", $variations); |
| 50 | - foreach ( $variations as $variation ) { |
|
| 50 | + foreach ($variations as $variation) { |
|
| 51 | 51 | $this->addVariation($variation); |
| 52 | 52 | } |
| 53 | 53 | return $this; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public function addVariations($variations=array()) { |
| 62 | 62 | if (\is_string($variations)) |
| 63 | 63 | $variations=\explode(" ", $variations); |
| 64 | - foreach ( $variations as $variation ) { |
|
| 64 | + foreach ($variations as $variation) { |
|
| 65 | 65 | $this->addVariation($variation); |
| 66 | 66 | } |
| 67 | 67 | return $this; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | public function addStates($states=array()) { |
| 71 | 71 | if (\is_string($states)) |
| 72 | 72 | $states=\explode(" ", $states); |
| 73 | - foreach ( $states as $state ) { |
|
| 73 | + foreach ($states as $state) { |
|
| 74 | 74 | $this->addState($state); |
| 75 | 75 | } |
| 76 | 76 | return $this; |
@@ -80,17 +80,17 @@ discard block |
||
| 80 | 80 | $this->setProperty("class", $this->_baseClass); |
| 81 | 81 | if (\is_string($states)) |
| 82 | 82 | $states=\explode(" ", $states); |
| 83 | - foreach ( $states as $state ) { |
|
| 83 | + foreach ($states as $state) { |
|
| 84 | 84 | $this->addState($state); |
| 85 | 85 | } |
| 86 | 86 | return $this; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function addIcon($icon, $before=true) { |
| 90 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
| 90 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function addSticky($context="body"){ |
|
| 93 | + public function addSticky($context="body") { |
|
| 94 | 94 | $this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});"); |
| 95 | 95 | return $this; |
| 96 | 96 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
| 112 | 112 | */ |
| 113 | 113 | public function setDisabled($disable=true) { |
| 114 | - if($disable) |
|
| 114 | + if ($disable) |
|
| 115 | 115 | $this->addToProperty("class", "disabled"); |
| 116 | 116 | return $this; |
| 117 | 117 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
| 139 | 139 | */ |
| 140 | - public function asHeader(){ |
|
| 140 | + public function asHeader() { |
|
| 141 | 141 | return $this->addToProperty("class", "header"); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | * show it is currently the active user selection |
| 146 | 146 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
| 147 | 147 | */ |
| 148 | - public function setActive($value=true){ |
|
| 149 | - if($value) |
|
| 148 | + public function setActive($value=true) { |
|
| 149 | + if ($value) |
|
| 150 | 150 | $this->addToProperty("class", "active"); |
| 151 | 151 | return $this; |
| 152 | 152 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public function setFloated($direction="right") { |
| 166 | - return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
| 166 | + return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | public function floatRight() { |
@@ -45,8 +45,9 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public function setVariations($variations) { |
| 47 | 47 | $this->setProperty("class", $this->_baseClass); |
| 48 | - if (\is_string($variations)) |
|
| 49 | - $variations=\explode(" ", $variations); |
|
| 48 | + if (\is_string($variations)) { |
|
| 49 | + $variations=\explode(" ", $variations); |
|
| 50 | + } |
|
| 50 | 51 | foreach ( $variations as $variation ) { |
| 51 | 52 | $this->addVariation($variation); |
| 52 | 53 | } |
@@ -59,8 +60,9 @@ discard block |
||
| 59 | 60 | } |
| 60 | 61 | |
| 61 | 62 | public function addVariations($variations=array()) { |
| 62 | - if (\is_string($variations)) |
|
| 63 | - $variations=\explode(" ", $variations); |
|
| 63 | + if (\is_string($variations)) { |
|
| 64 | + $variations=\explode(" ", $variations); |
|
| 65 | + } |
|
| 64 | 66 | foreach ( $variations as $variation ) { |
| 65 | 67 | $this->addVariation($variation); |
| 66 | 68 | } |
@@ -68,8 +70,9 @@ discard block |
||
| 68 | 70 | } |
| 69 | 71 | |
| 70 | 72 | public function addStates($states=array()) { |
| 71 | - if (\is_string($states)) |
|
| 72 | - $states=\explode(" ", $states); |
|
| 73 | + if (\is_string($states)) { |
|
| 74 | + $states=\explode(" ", $states); |
|
| 75 | + } |
|
| 73 | 76 | foreach ( $states as $state ) { |
| 74 | 77 | $this->addState($state); |
| 75 | 78 | } |
@@ -78,8 +81,9 @@ discard block |
||
| 78 | 81 | |
| 79 | 82 | public function setStates($states) { |
| 80 | 83 | $this->setProperty("class", $this->_baseClass); |
| 81 | - if (\is_string($states)) |
|
| 82 | - $states=\explode(" ", $states); |
|
| 84 | + if (\is_string($states)) { |
|
| 85 | + $states=\explode(" ", $states); |
|
| 86 | + } |
|
| 83 | 87 | foreach ( $states as $state ) { |
| 84 | 88 | $this->addState($state); |
| 85 | 89 | } |
@@ -111,8 +115,9 @@ discard block |
||
| 111 | 115 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
| 112 | 116 | */ |
| 113 | 117 | public function setDisabled($disable=true) { |
| 114 | - if($disable) |
|
| 115 | - $this->addToProperty("class", "disabled"); |
|
| 118 | + if($disable) { |
|
| 119 | + $this->addToProperty("class", "disabled"); |
|
| 120 | + } |
|
| 116 | 121 | return $this; |
| 117 | 122 | } |
| 118 | 123 | |
@@ -146,8 +151,9 @@ discard block |
||
| 146 | 151 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
| 147 | 152 | */ |
| 148 | 153 | public function setActive($value=true){ |
| 149 | - if($value) |
|
| 150 | - $this->addToProperty("class", "active"); |
|
| 154 | + if($value) { |
|
| 155 | + $this->addToProperty("class", "active"); |
|
| 156 | + } |
|
| 151 | 157 | return $this; |
| 152 | 158 | } |
| 153 | 159 | |
@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | use Ajax\semantic\traits\SemanticWidgetsTrait; |
| 12 | 12 | |
| 13 | 13 | class Semantic extends BaseGui { |
| 14 | - use SemanticComponentsTrait,SemanticHtmlElementsTrait,SemanticHtmlCollectionsTrait, |
|
| 15 | - SemanticHtmlModulesTrait,SemanticHtmlViewsTrait,SemanticWidgetsTrait; |
|
| 14 | + use SemanticComponentsTrait, SemanticHtmlElementsTrait, SemanticHtmlCollectionsTrait, |
|
| 15 | + SemanticHtmlModulesTrait, SemanticHtmlViewsTrait, SemanticWidgetsTrait; |
|
| 16 | 16 | |
| 17 | 17 | private $language; |
| 18 | 18 | |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
| 24 | - public function setLanguage($language){ |
|
| 25 | - if($language!==$this->language){ |
|
| 24 | + public function setLanguage($language) { |
|
| 25 | + if ($language!==$this->language) { |
|
| 26 | 26 | $file=\realpath(dirname(__FILE__)."/semantic/components/validation/languages/".$language.".js"); |
| 27 | - if(\file_exists($file)){ |
|
| 27 | + if (\file_exists($file)) { |
|
| 28 | 28 | $script=\file_get_contents($file); |
| 29 | - $this->js->exec($script,true); |
|
| 29 | + $this->js->exec($script, true); |
|
| 30 | 30 | $this->language=$language; |
| 31 | 31 | } |
| 32 | 32 | } |