@@ -24,6 +24,10 @@ discard block |
||
| 24 | 24 | trait FieldAsTrait{ |
| 25 | 25 | |
| 26 | 26 | abstract protected function _getFieldIdentifier($prefix); |
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @param \Closure $callback |
|
| 30 | + */ |
|
| 27 | 31 | abstract public function setValueFunction($index,$callback); |
| 28 | 32 | |
| 29 | 33 | /** |
@@ -49,6 +53,10 @@ discard block |
||
| 49 | 53 | |
| 50 | 54 | protected function _addRules($element,&$attributes){} |
| 51 | 55 | |
| 56 | + /** |
|
| 57 | + * @param \Closure $elementCallback |
|
| 58 | + * @param string $prefix |
|
| 59 | + */ |
|
| 52 | 60 | protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
| 53 | 61 | $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
| 54 | 62 | $name=$this->_instanceViewer->getCaption($index)."[]"; |
@@ -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; |
@@ -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 |
@@ -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; |
@@ -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 | /** |
@@ -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 | |
@@ -157,8 +157,9 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
| 159 | 159 | $result=$this->addInToolbar($caption,$callback); |
| 160 | - if(isset($icon)) |
|
| 161 | - $result->addIcon($icon); |
|
| 160 | + if(isset($icon)) { |
|
| 161 | + $result->addIcon($icon); |
|
| 162 | + } |
|
| 162 | 163 | return $result; |
| 163 | 164 | } |
| 164 | 165 | |
@@ -172,7 +173,7 @@ discard block |
||
| 172 | 173 | foreach ($items as $icon=>$item){ |
| 173 | 174 | $this->addItemInToolbar($item,$icon,$callback); |
| 174 | 175 | } |
| 175 | - }else{ |
|
| 176 | + } else{ |
|
| 176 | 177 | foreach ($items as $item){ |
| 177 | 178 | $this->addItemInToolbar($item,null,$callback); |
| 178 | 179 | } |