@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | * @property string $identifier |
| 15 | 15 | */ |
| 16 | 16 | trait BaseTrait { |
| 17 | - protected $_variations=[ ]; |
|
| 18 | - protected $_states=[ ]; |
|
| 17 | + protected $_variations=[]; |
|
| 18 | + protected $_states=[]; |
|
| 19 | 19 | protected $_baseClass; |
| 20 | 20 | |
| 21 | 21 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | abstract public function setProperty($name, $value); |
| 30 | 30 | |
| 31 | - abstract public function addContent($content,$before=false); |
|
| 31 | + abstract public function addContent($content, $before=false); |
|
| 32 | 32 | |
| 33 | 33 | abstract public function onCreate($jsCode); |
| 34 | 34 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $this->setProperty("class", $this->_baseClass); |
| 50 | 50 | if (\is_string($variations)) |
| 51 | 51 | $variations=\explode(" ", $variations); |
| 52 | - foreach ( $variations as $variation ) { |
|
| 52 | + foreach ($variations as $variation) { |
|
| 53 | 53 | $this->addVariation($variation); |
| 54 | 54 | } |
| 55 | 55 | return $this; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | public function addVariations($variations=array()) { |
| 64 | 64 | if (\is_string($variations)) |
| 65 | 65 | $variations=\explode(" ", $variations); |
| 66 | - foreach ( $variations as $variation ) { |
|
| 66 | + foreach ($variations as $variation) { |
|
| 67 | 67 | $this->addVariation($variation); |
| 68 | 68 | } |
| 69 | 69 | return $this; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | public function addStates($states=array()) { |
| 73 | 73 | if (\is_string($states)) |
| 74 | 74 | $states=\explode(" ", $states); |
| 75 | - foreach ( $states as $state ) { |
|
| 75 | + foreach ($states as $state) { |
|
| 76 | 76 | $this->addState($state); |
| 77 | 77 | } |
| 78 | 78 | return $this; |
@@ -82,17 +82,17 @@ discard block |
||
| 82 | 82 | $this->setProperty("class", $this->_baseClass); |
| 83 | 83 | if (\is_string($states)) |
| 84 | 84 | $states=\explode(" ", $states); |
| 85 | - foreach ( $states as $state ) { |
|
| 85 | + foreach ($states as $state) { |
|
| 86 | 86 | $this->addState($state); |
| 87 | 87 | } |
| 88 | 88 | return $this; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function addIcon($icon, $before=true) { |
| 92 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
| 92 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function addSticky($context="body"){ |
|
| 95 | + public function addSticky($context="body") { |
|
| 96 | 96 | $this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});"); |
| 97 | 97 | return $this; |
| 98 | 98 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @return HtmlSemDoubleElement |
| 114 | 114 | */ |
| 115 | 115 | public function setDisabled($disable=true) { |
| 116 | - if($disable) |
|
| 116 | + if ($disable) |
|
| 117 | 117 | $this->addToProperty("class", "disabled"); |
| 118 | 118 | return $this; |
| 119 | 119 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @return HtmlSemDoubleElement |
| 141 | 141 | */ |
| 142 | - public function asHeader(){ |
|
| 142 | + public function asHeader() { |
|
| 143 | 143 | return $this->addToProperty("class", "header"); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -147,15 +147,15 @@ discard block |
||
| 147 | 147 | * show it is currently the active user selection |
| 148 | 148 | * @return HtmlSemDoubleElement |
| 149 | 149 | */ |
| 150 | - public function setActive($value=true){ |
|
| 151 | - if($value) |
|
| 150 | + public function setActive($value=true) { |
|
| 151 | + if ($value) |
|
| 152 | 152 | $this->addToProperty("class", "active"); |
| 153 | 153 | return $this; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function setAttached($value=true){ |
|
| 157 | - if($value) |
|
| 158 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 156 | + public function setAttached($value=true) { |
|
| 157 | + if ($value) |
|
| 158 | + $this->addToPropertyCtrl("class", "attached", array("attached")); |
|
| 159 | 159 | return $this; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | public function setFloated($direction="right") { |
| 174 | - return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
| 174 | + return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | public function floatRight() { |
@@ -186,14 +186,14 @@ discard block |
||
| 186 | 186 | return $this->_baseClass; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - protected function addBehavior(&$array,$key,$value,$before="",$after=""){ |
|
| 190 | - if(\is_string($value)){ |
|
| 191 | - if(isset($array[$key])){ |
|
| 189 | + protected function addBehavior(&$array, $key, $value, $before="", $after="") { |
|
| 190 | + if (\is_string($value)) { |
|
| 191 | + if (isset($array[$key])) { |
|
| 192 | 192 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
| 193 | 193 | $array[$key]=$before.$p.$value.$after; |
| 194 | - }else |
|
| 194 | + } else |
|
| 195 | 195 | $array[$key]=$before.$value.$after; |
| 196 | - }else |
|
| 196 | + } else |
|
| 197 | 197 | $array[$key]=$value; |
| 198 | 198 | return $this; |
| 199 | 199 | } |
@@ -47,8 +47,9 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | public function setVariations($variations) { |
| 49 | 49 | $this->setProperty("class", $this->_baseClass); |
| 50 | - if (\is_string($variations)) |
|
| 51 | - $variations=\explode(" ", $variations); |
|
| 50 | + if (\is_string($variations)) { |
|
| 51 | + $variations=\explode(" ", $variations); |
|
| 52 | + } |
|
| 52 | 53 | foreach ( $variations as $variation ) { |
| 53 | 54 | $this->addVariation($variation); |
| 54 | 55 | } |
@@ -61,8 +62,9 @@ discard block |
||
| 61 | 62 | } |
| 62 | 63 | |
| 63 | 64 | public function addVariations($variations=array()) { |
| 64 | - if (\is_string($variations)) |
|
| 65 | - $variations=\explode(" ", $variations); |
|
| 65 | + if (\is_string($variations)) { |
|
| 66 | + $variations=\explode(" ", $variations); |
|
| 67 | + } |
|
| 66 | 68 | foreach ( $variations as $variation ) { |
| 67 | 69 | $this->addVariation($variation); |
| 68 | 70 | } |
@@ -70,8 +72,9 @@ discard block |
||
| 70 | 72 | } |
| 71 | 73 | |
| 72 | 74 | public function addStates($states=array()) { |
| 73 | - if (\is_string($states)) |
|
| 74 | - $states=\explode(" ", $states); |
|
| 75 | + if (\is_string($states)) { |
|
| 76 | + $states=\explode(" ", $states); |
|
| 77 | + } |
|
| 75 | 78 | foreach ( $states as $state ) { |
| 76 | 79 | $this->addState($state); |
| 77 | 80 | } |
@@ -80,8 +83,9 @@ discard block |
||
| 80 | 83 | |
| 81 | 84 | public function setStates($states) { |
| 82 | 85 | $this->setProperty("class", $this->_baseClass); |
| 83 | - if (\is_string($states)) |
|
| 84 | - $states=\explode(" ", $states); |
|
| 86 | + if (\is_string($states)) { |
|
| 87 | + $states=\explode(" ", $states); |
|
| 88 | + } |
|
| 85 | 89 | foreach ( $states as $state ) { |
| 86 | 90 | $this->addState($state); |
| 87 | 91 | } |
@@ -113,8 +117,9 @@ discard block |
||
| 113 | 117 | * @return HtmlSemDoubleElement |
| 114 | 118 | */ |
| 115 | 119 | public function setDisabled($disable=true) { |
| 116 | - if($disable) |
|
| 117 | - $this->addToProperty("class", "disabled"); |
|
| 120 | + if($disable) { |
|
| 121 | + $this->addToProperty("class", "disabled"); |
|
| 122 | + } |
|
| 118 | 123 | return $this; |
| 119 | 124 | } |
| 120 | 125 | |
@@ -148,14 +153,16 @@ discard block |
||
| 148 | 153 | * @return HtmlSemDoubleElement |
| 149 | 154 | */ |
| 150 | 155 | public function setActive($value=true){ |
| 151 | - if($value) |
|
| 152 | - $this->addToProperty("class", "active"); |
|
| 156 | + if($value) { |
|
| 157 | + $this->addToProperty("class", "active"); |
|
| 158 | + } |
|
| 153 | 159 | return $this; |
| 154 | 160 | } |
| 155 | 161 | |
| 156 | 162 | public function setAttached($value=true){ |
| 157 | - if($value) |
|
| 158 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 163 | + if($value) { |
|
| 164 | + $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 165 | + } |
|
| 159 | 166 | return $this; |
| 160 | 167 | } |
| 161 | 168 | |
@@ -191,10 +198,12 @@ discard block |
||
| 191 | 198 | if(isset($array[$key])){ |
| 192 | 199 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
| 193 | 200 | $array[$key]=$before.$p.$value.$after; |
| 194 | - }else |
|
| 195 | - $array[$key]=$before.$value.$after; |
|
| 196 | - }else |
|
| 197 | - $array[$key]=$value; |
|
| 201 | + } else { |
|
| 202 | + $array[$key]=$before.$value.$after; |
|
| 203 | + } |
|
| 204 | + } else { |
|
| 205 | + $array[$key]=$value; |
|
| 206 | + } |
|
| 198 | 207 | return $this; |
| 199 | 208 | } |
| 200 | 209 | } |
| 201 | 210 | \ No newline at end of file |
@@ -19,16 +19,16 @@ discard block |
||
| 19 | 19 | abstract public function setClass($classNames); |
| 20 | 20 | abstract public function addIcon($icon, $before=true); |
| 21 | 21 | |
| 22 | - public function setContent($content){ |
|
| 23 | - if($content==="-"){ |
|
| 22 | + public function setContent($content) { |
|
| 23 | + if ($content==="-") { |
|
| 24 | 24 | $this->asDivider(); |
| 25 | - }elseif($content==="-search-"){ |
|
| 26 | - $values=\explode(",",$content,-1); |
|
| 27 | - $this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."),JArray::getDefaultValue($values, 1, "search")); |
|
| 28 | - }elseif(JString::startswith($content, "-")){ |
|
| 29 | - $content=\ltrim($content,"-"); |
|
| 25 | + }elseif ($content==="-search-") { |
|
| 26 | + $values=\explode(",", $content, -1); |
|
| 27 | + $this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."), JArray::getDefaultValue($values, 1, "search")); |
|
| 28 | + }elseif (JString::startswith($content, "-")) { |
|
| 29 | + $content=\ltrim($content, "-"); |
|
| 30 | 30 | $this->asHeader($content); |
| 31 | - }else |
|
| 31 | + } else |
|
| 32 | 32 | parent::setContent($content); |
| 33 | 33 | return $this; |
| 34 | 34 | } |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | * @param string $icon |
| 39 | 39 | * @return HtmlDropdownItem|HtmlMenuItem |
| 40 | 40 | */ |
| 41 | - public function asSearchInput($placeholder=NULL,$icon=NULL){ |
|
| 41 | + public function asSearchInput($placeholder=NULL, $icon=NULL) { |
|
| 42 | 42 | $this->setClass("ui icon search input"); |
| 43 | 43 | $input=new HtmlInput("search-".$this->identifier); |
| 44 | - if(isset($placeholder)) |
|
| 44 | + if (isset($placeholder)) |
|
| 45 | 45 | $input->setProperty("placeholder", $placeholder); |
| 46 | 46 | $this->content=$input; |
| 47 | - if(isset($icon)) |
|
| 47 | + if (isset($icon)) |
|
| 48 | 48 | $this->addIcon($icon); |
| 49 | 49 | return $this; |
| 50 | 50 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * @return HtmlDropdownItem|HtmlMenuItem |
| 54 | 54 | */ |
| 55 | - public function asDivider(){ |
|
| 55 | + public function asDivider() { |
|
| 56 | 56 | $this->content=NULL; |
| 57 | 57 | $this->tagName="div"; |
| 58 | 58 | $this->setClass("divider"); |
@@ -64,16 +64,16 @@ discard block |
||
| 64 | 64 | * @param string $icon |
| 65 | 65 | * @return HtmlDropdownItem|HtmlMenuItem |
| 66 | 66 | */ |
| 67 | - public function asHeader($caption=NULL,$icon=NULL){ |
|
| 67 | + public function asHeader($caption=NULL, $icon=NULL) { |
|
| 68 | 68 | $this->setClass("header"); |
| 69 | 69 | $this->tagName="div"; |
| 70 | 70 | $this->content=$caption; |
| 71 | - if(isset($icon)) |
|
| 72 | - $this->addIcon($icon,Direction::LEFT); |
|
| 71 | + if (isset($icon)) |
|
| 72 | + $this->addIcon($icon, Direction::LEFT); |
|
| 73 | 73 | return $this; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function setPosition($direction){ |
|
| 77 | - $this->addToProperty("class",$direction); |
|
| 76 | + public function setPosition($direction) { |
|
| 77 | + $this->addToProperty("class", $direction); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | \ No newline at end of file |