@@ -84,15 +84,17 @@ discard block |
||
84 | 84 | |
85 | 85 | public function getColspan() { |
86 | 86 | $colspan=1; |
87 | - if (\array_key_exists("colspan", $this->properties)) |
|
88 | - $colspan=$this->getProperty("colspan"); |
|
87 | + if (\array_key_exists("colspan", $this->properties)) { |
|
88 | + $colspan=$this->getProperty("colspan"); |
|
89 | + } |
|
89 | 90 | return $colspan; |
90 | 91 | } |
91 | 92 | |
92 | 93 | public function getRowspan() { |
93 | 94 | $rowspan=1; |
94 | - if (\array_key_exists("rowspan", $this->properties)) |
|
95 | - $rowspan=$this->getProperty("rowspan"); |
|
95 | + if (\array_key_exists("rowspan", $this->properties)) { |
|
96 | + $rowspan=$this->getProperty("rowspan"); |
|
97 | + } |
|
96 | 98 | return $rowspan; |
97 | 99 | } |
98 | 100 | |
@@ -129,7 +131,8 @@ discard block |
||
129 | 131 | } |
130 | 132 | |
131 | 133 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
132 | - if(!$this->_deleted) |
|
133 | - return parent::compile(); |
|
134 | + if(!$this->_deleted) { |
|
135 | + return parent::compile(); |
|
136 | + } |
|
134 | 137 | } |
135 | 138 | } |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | $this->widgetIdentifier=$identifier; |
24 | 24 | $this->values=[]; |
25 | 25 | $this->afterCompile=[]; |
26 | - if(isset($instance)) |
|
27 | - $this->setInstance($instance); |
|
26 | + if(isset($instance)) { |
|
27 | + $this->setInstance($instance); |
|
28 | + } |
|
28 | 29 | $this->setCaptions($captions); |
29 | 30 | $this->captionCallback=NULL; |
30 | 31 | $this->defaultValueFunction=function($name,$value){return $value;}; |
@@ -62,14 +63,16 @@ discard block |
||
62 | 63 | } |
63 | 64 | |
64 | 65 | public function getIdentifier($index=NULL){ |
65 | - if(!isset($index)) |
|
66 | - $index=self::$index; |
|
66 | + if(!isset($index)) { |
|
67 | + $index=self::$index; |
|
68 | + } |
|
67 | 69 | $value=$index; |
68 | 70 | if(isset($this->values["identifier"])){ |
69 | - if(\is_string($this->values["identifier"])) |
|
70 | - $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
71 | - else |
|
72 | - $value=$this->values["identifier"]($index,$this->instance); |
|
71 | + if(\is_string($this->values["identifier"])) { |
|
72 | + $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
73 | + } else { |
|
74 | + $value=$this->values["identifier"]($index,$this->instance); |
|
75 | + } |
|
73 | 76 | } |
74 | 77 | return $value; |
75 | 78 | } |
@@ -100,16 +103,16 @@ discard block |
||
100 | 103 | if($property instanceof \ReflectionProperty){ |
101 | 104 | $value=$this->_getPropertyValue($property, $index); |
102 | 105 | $propertyName=$property->getName(); |
103 | - }elseif(\is_callable($property)) |
|
104 | - $value=$property($this->instance); |
|
105 | - elseif(\is_array($property)){ |
|
106 | + } elseif(\is_callable($property)) { |
|
107 | + $value=$property($this->instance); |
|
108 | + } elseif(\is_array($property)){ |
|
106 | 109 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
107 | 110 | $value=\implode("", $values); |
108 | - }elseif(\is_string($property)){ |
|
111 | + } elseif(\is_string($property)){ |
|
109 | 112 | $value=$property; |
110 | 113 | if(isset($this->instance->{$property})){ |
111 | 114 | $value=$this->instance->{$property}; |
112 | - }elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){ |
|
115 | + } elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){ |
|
113 | 116 | $value=JReflection::callMethod($this->instance, $getter, []); |
114 | 117 | } |
115 | 118 | } |
@@ -119,7 +122,7 @@ discard block |
||
119 | 122 | protected function _postGetValue($index,$propertyName,$value){ |
120 | 123 | if(isset($this->values[$index])){ |
121 | 124 | $value= $this->values[$index]($value,$this->instance,$index,self::$index); |
122 | - }else{ |
|
125 | + } else{ |
|
123 | 126 | $value=$this->_getDefaultValue($propertyName,$value, $index,self::$index); |
124 | 127 | } |
125 | 128 | if(isset($this->afterCompile[$index])){ |
@@ -140,10 +143,10 @@ discard block |
||
140 | 143 | if(isset($vb[$index])){ |
141 | 144 | if(\is_array($vb[$index])){ |
142 | 145 | $this->visibleProperties[$index][]=$field; |
143 | - }else{ |
|
146 | + } else{ |
|
144 | 147 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
145 | 148 | } |
146 | - }else{ |
|
149 | + } else{ |
|
147 | 150 | return $this->insertField($index, $field); |
148 | 151 | } |
149 | 152 | return $this; |
@@ -175,9 +178,9 @@ discard block |
||
175 | 178 | $property=$this->getProperty($index); |
176 | 179 | if($property instanceof \ReflectionProperty){ |
177 | 180 | $result=$property->getName(); |
178 | - }elseif(\is_callable($property)){ |
|
181 | + } elseif(\is_callable($property)){ |
|
179 | 182 | $result=$this->visibleProperties[$index]; |
180 | - }else{ |
|
183 | + } else{ |
|
181 | 184 | $result=$property; |
182 | 185 | } |
183 | 186 | return $result; |
@@ -197,7 +200,7 @@ discard block |
||
197 | 200 | $this->reflect=new \ReflectionClass($instance); |
198 | 201 | if(JArray::count($this->visibleProperties)===0){ |
199 | 202 | $this->properties=$this->getDefaultProperties(); |
200 | - }else{ |
|
203 | + } else{ |
|
201 | 204 | foreach ($this->visibleProperties as $property){ |
202 | 205 | $this->setInstanceProperty($property); |
203 | 206 | } |
@@ -208,22 +211,23 @@ discard block |
||
208 | 211 | private function setInstanceProperty($property){ |
209 | 212 | if(\is_callable($property)){ |
210 | 213 | $this->properties[]=$property; |
211 | - }elseif(\is_string($property)){ |
|
214 | + } elseif(\is_string($property)){ |
|
212 | 215 | try{ |
213 | 216 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
214 | 217 | $rProperty=$this->reflect->getProperty($property); |
215 | 218 | $this->properties[]=$rProperty; |
216 | - }catch(\Exception $e){ |
|
219 | + } catch(\Exception $e){ |
|
217 | 220 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
218 | 221 | $this->properties[]=$property; |
219 | 222 | } |
220 | - }elseif(\is_int($property)){ |
|
223 | + } elseif(\is_int($property)){ |
|
221 | 224 | $props=$this->getDefaultProperties(); |
222 | - if(isset($props[$property])) |
|
223 | - $this->properties[]=$props[$property]; |
|
224 | - else |
|
225 | - $this->properties[]=$property; |
|
226 | - }else{ |
|
225 | + if(isset($props[$property])) { |
|
226 | + $this->properties[]=$props[$property]; |
|
227 | + } else { |
|
228 | + $this->properties[]=$property; |
|
229 | + } |
|
230 | + } else{ |
|
227 | 231 | $this->properties[]=$property; |
228 | 232 | } |
229 | 233 | } |
@@ -267,12 +271,13 @@ discard block |
||
267 | 271 | if(isset($this->captions[$index])){ |
268 | 272 | return $this->captions[$index]; |
269 | 273 | } |
270 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
271 | - return $this->properties[$index]->getName(); |
|
272 | - elseif(\is_callable($this->properties[$index])) |
|
273 | - return ""; |
|
274 | - else |
|
275 | - return $this->properties[$index]; |
|
274 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
275 | + return $this->properties[$index]->getName(); |
|
276 | + } elseif(\is_callable($this->properties[$index])) { |
|
277 | + return ""; |
|
278 | + } else { |
|
279 | + return $this->properties[$index]; |
|
280 | + } |
|
276 | 281 | } |
277 | 282 | |
278 | 283 | public function getCaptions(){ |
@@ -283,7 +288,7 @@ discard block |
||
283 | 288 | for($i=$captionsSize;$i<$count;$i++){ |
284 | 289 | $captions[]=""; |
285 | 290 | } |
286 | - }else{ |
|
291 | + } else{ |
|
287 | 292 | $captions=[]; |
288 | 293 | $index=0; |
289 | 294 | while($index<$count){ |
@@ -298,8 +303,9 @@ discard block |
||
298 | 303 | } |
299 | 304 | |
300 | 305 | public function setCaption($index,$caption){ |
301 | - if(isset($this->captions)===false) |
|
302 | - $this->captions=[]; |
|
306 | + if(isset($this->captions)===false) { |
|
307 | + $this->captions=[]; |
|
308 | + } |
|
303 | 309 | $this->captions[$index]=$caption; |
304 | 310 | return $this; |
305 | 311 | } |
@@ -18,8 +18,9 @@ discard block |
||
18 | 18 | protected $_dropdown; |
19 | 19 | public function __construct($identifier, $elements=array(), $asIcons=false) { |
20 | 20 | parent::__construct($identifier, "div", "ui buttons"); |
21 | - if ($asIcons === true) |
|
22 | - $this->asIcons(); |
|
21 | + if ($asIcons === true) { |
|
22 | + $this->asIcons(); |
|
23 | + } |
|
23 | 24 | $this->addElements($elements, $asIcons); |
24 | 25 | } |
25 | 26 | protected function createItem($value){ |
@@ -50,8 +51,9 @@ discard block |
||
50 | 51 | */ |
51 | 52 | public function addElement($element, $asIcon=false) { |
52 | 53 | $item=$this->addItem($element); |
53 | - if($asIcon) |
|
54 | - $item->asIcon($element); |
|
54 | + if($asIcon) { |
|
55 | + $item->asIcon($element); |
|
56 | + } |
|
55 | 57 | return $item; |
56 | 58 | } |
57 | 59 | |
@@ -79,8 +81,9 @@ discard block |
||
79 | 81 | |
80 | 82 | public function asIcons() { |
81 | 83 | foreach ( $this->content as $item ) { |
82 | - if($item instanceof HtmlButton) |
|
83 | - $item->asIcon($item->getContent()); |
|
84 | + if($item instanceof HtmlButton) { |
|
85 | + $item->asIcon($item->getContent()); |
|
86 | + } |
|
84 | 87 | } |
85 | 88 | return $this->addToProperty("class", "icons"); |
86 | 89 | } |
@@ -92,8 +95,9 @@ discard block |
||
92 | 95 | */ |
93 | 96 | public function addIcons($icons){ |
94 | 97 | foreach ( $this->content as $index=>$item ) { |
95 | - if($item instanceof HtmlButton && isset($icons[$index])) |
|
96 | - $item->addIcon($icons[$index]); |
|
98 | + if($item instanceof HtmlButton && isset($icons[$index])) { |
|
99 | + $item->addIcon($icons[$index]); |
|
100 | + } |
|
97 | 101 | } |
98 | 102 | return $this; |
99 | 103 | } |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | public function __construct($identifier, $caption="", $icon=NULL, $tagName="div") { |
24 | 24 | parent::__construct($identifier, $tagName, "ui label"); |
25 | 25 | $this->content=$caption; |
26 | - if (isset($icon)) |
|
27 | - $this->addIcon($icon); |
|
26 | + if (isset($icon)) { |
|
27 | + $this->addIcon($icon); |
|
28 | + } |
|
28 | 29 | } |
29 | 30 | |
30 | 31 | /** |
@@ -33,10 +34,11 @@ discard block |
||
33 | 34 | * @return HtmlLabel |
34 | 35 | */ |
35 | 36 | public function setPointing($value=Direction::NONE) { |
36 | - if($value==="left" || $value==="right") |
|
37 | - return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
38 | - else |
|
39 | - return $this->addToPropertyCtrl("class", "pointing ".$value, Direction::getConstantValues("pointing",true)); |
|
37 | + if($value==="left" || $value==="right") { |
|
38 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
39 | + } else { |
|
40 | + return $this->addToPropertyCtrl("class", "pointing ".$value, Direction::getConstantValues("pointing",true)); |
|
41 | + } |
|
40 | 42 | } |
41 | 43 | |
42 | 44 | /** |
@@ -134,10 +136,11 @@ discard block |
||
134 | 136 | } |
135 | 137 | |
136 | 138 | public function setAttached($side=Side::TOP,$direction=Direction::NONE){ |
137 | - if($direction!==Direction::NONE) |
|
138 | - return $this->addToPropertyCtrl("class", $side." ".$direction." attached",Side::getConstantValues($direction." attached")); |
|
139 | - else |
|
140 | - return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached")); |
|
139 | + if($direction!==Direction::NONE) { |
|
140 | + return $this->addToPropertyCtrl("class", $side." ".$direction." attached",Side::getConstantValues($direction." attached")); |
|
141 | + } else { |
|
142 | + return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached")); |
|
143 | + } |
|
141 | 144 | } |
142 | 145 | |
143 | 146 | /** |
@@ -29,15 +29,17 @@ discard block |
||
29 | 29 | |
30 | 30 | public function addContent($content,$before=false) { |
31 | 31 | if (!\is_array($this->content)) { |
32 | - if(isset($this->content)) |
|
33 | - $this->content=array ($this->content); |
|
34 | - else |
|
35 | - $this->content=array(); |
|
32 | + if(isset($this->content)) { |
|
33 | + $this->content=array ($this->content); |
|
34 | + } else { |
|
35 | + $this->content=array(); |
|
36 | + } |
|
37 | + } |
|
38 | + if($before) { |
|
39 | + array_unshift($this->content,$content); |
|
40 | + } else { |
|
41 | + $this->content []=$content; |
|
36 | 42 | } |
37 | - if($before) |
|
38 | - array_unshift($this->content,$content); |
|
39 | - else |
|
40 | - $this->content []=$content; |
|
41 | 43 | return $this; |
42 | 44 | } |
43 | 45 | |
@@ -75,9 +77,9 @@ discard block |
||
75 | 77 | $instances=[]; |
76 | 78 | if($content instanceof $class){ |
77 | 79 | $instances[]=$content; |
78 | - }elseif($content instanceof HtmlDoubleElement){ |
|
80 | + } elseif($content instanceof HtmlDoubleElement){ |
|
79 | 81 | $instances=\array_merge($instances,$content->getContentInstances($class)); |
80 | - }elseif (\is_array($content)){ |
|
82 | + } elseif (\is_array($content)){ |
|
81 | 83 | foreach ($content as $element){ |
82 | 84 | $instances=\array_merge($instances,$this->_getContentInstances($class, $element)); |
83 | 85 | } |
@@ -90,10 +92,12 @@ discard block |
||
90 | 92 | * @return HtmlDoubleElement |
91 | 93 | */ |
92 | 94 | public function asLink($href=NULL,$target=NULL) { |
93 | - if (isset($href)) |
|
94 | - $this->setProperty("href", $href); |
|
95 | - if(isset($target)) |
|
96 | - $this->setProperty("target", $target); |
|
95 | + if (isset($href)) { |
|
96 | + $this->setProperty("href", $href); |
|
97 | + } |
|
98 | + if(isset($target)) { |
|
99 | + $this->setProperty("target", $target); |
|
100 | + } |
|
97 | 101 | return $this->setTagName("a"); |
98 | 102 | } |
99 | 103 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | foreach ($items as $k=>$v){ |
25 | 25 | $this->addItem([$k,$v]); |
26 | 26 | } |
27 | - }else{ |
|
27 | + } else{ |
|
28 | 28 | foreach ($items as $item){ |
29 | 29 | $this->addItem($item); |
30 | 30 | } |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * @return \Ajax\common\html\HtmlDoubleElement |
81 | 81 | */ |
82 | 82 | public function getItem($index) { |
83 | - if (is_int($index)) |
|
84 | - return $this->content[$index]; |
|
85 | - else { |
|
83 | + if (is_int($index)) { |
|
84 | + return $this->content[$index]; |
|
85 | + } else { |
|
86 | 86 | $elm=$this->getElementById($index, $this->content); |
87 | 87 | return $elm; |
88 | 88 | } |
@@ -144,10 +144,11 @@ discard block |
||
144 | 144 | $i=0; |
145 | 145 | foreach ($properties as $k=>$v){ |
146 | 146 | $c=$this->content[$i++]; |
147 | - if(isset($c)) |
|
148 | - $c->setProperty($k,$v); |
|
149 | - else |
|
150 | - return $this; |
|
147 | + if(isset($c)) { |
|
148 | + $c->setProperty($k,$v); |
|
149 | + } else { |
|
150 | + return $this; |
|
151 | + } |
|
151 | 152 | } |
152 | 153 | return $this; |
153 | 154 | } |
@@ -167,8 +168,7 @@ discard block |
||
167 | 168 | $c=$this->content[$i++]; |
168 | 169 | if(isset($c)){ |
169 | 170 | $c->setProperty($property,$value); |
170 | - } |
|
171 | - else{ |
|
171 | + } else{ |
|
172 | 172 | return $this; |
173 | 173 | } |
174 | 174 | } |
@@ -197,8 +197,9 @@ discard block |
||
197 | 197 | foreach ( $this->content as $index=>$item ) { |
198 | 198 | if($item instanceof HtmlDoubleElement){ |
199 | 199 | $href=""; |
200 | - if(isset($hrefs[$index])) |
|
201 | - $href=$hrefs[$index]; |
|
200 | + if(isset($hrefs[$index])) { |
|
201 | + $href=$hrefs[$index]; |
|
202 | + } |
|
202 | 203 | $item->asLink($href,$target); |
203 | 204 | } |
204 | 205 | } |
@@ -28,11 +28,12 @@ discard block |
||
28 | 28 | if(\is_array($value)){ |
29 | 29 | $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
30 | 30 | return $itemO; |
31 | - }elseif(\is_object($value)){ |
|
31 | + } elseif(\is_object($value)){ |
|
32 | 32 | $itemO=new HtmlFormField("field-".$this->identifier, $value); |
33 | 33 | return $itemO; |
34 | - }else |
|
35 | - return new HtmlFormInput($value); |
|
34 | + } else { |
|
35 | + return new HtmlFormInput($value); |
|
36 | + } |
|
36 | 37 | } |
37 | 38 | |
38 | 39 | protected function createCondition($value){ |
@@ -66,8 +67,7 @@ discard block |
||
66 | 67 | if(isset($c)){ |
67 | 68 | $df=$c->getDataField(); |
68 | 69 | $df->setProperty($property,$value); |
69 | - } |
|
70 | - else{ |
|
70 | + } else{ |
|
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | } |