@@ -49,8 +49,9 @@ |
||
49 | 49 | $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
50 | 50 | if(\sizeof($fields)===1){ |
51 | 51 | $form->addField($fields[0]); |
52 | - }else |
|
53 | - $form->addFields($fields); |
|
52 | + } else { |
|
53 | + $form->addFields($fields); |
|
54 | + } |
|
54 | 55 | } |
55 | 56 | } |
56 | 57 |
@@ -34,17 +34,18 @@ |
||
34 | 34 | $property=$this->getProperty($index); |
35 | 35 | if($property instanceof \ReflectionProperty){ |
36 | 36 | $result=$property->getName(); |
37 | - }elseif(\is_callable($property)){ |
|
37 | + } elseif(\is_callable($property)){ |
|
38 | 38 | $result=$this->visibleProperties[$index]; |
39 | - }else{ |
|
39 | + } else{ |
|
40 | 40 | $result=\strtolower($this->getCaption($index)); |
41 | 41 | } |
42 | 42 | return $result; |
43 | 43 | } |
44 | 44 | |
45 | 45 | public function addSeparatorAfter($fieldNum){ |
46 | - if(\array_search($fieldNum, $this->separators)===false) |
|
47 | - $this->separators[]=$fieldNum; |
|
46 | + if(\array_search($fieldNum, $this->separators)===false) { |
|
47 | + $this->separators[]=$fieldNum; |
|
48 | + } |
|
48 | 49 | return $this; |
49 | 50 | } |
50 | 51 |
@@ -43,10 +43,11 @@ discard block |
||
43 | 43 | protected function _addRules($element,$attributes){ |
44 | 44 | if(isset($attributes["rules"])){ |
45 | 45 | $rules=$attributes["rules"]; |
46 | - if(\is_array($rules)) |
|
47 | - $element->addRules($rules); |
|
48 | - else |
|
49 | - $element->addRule($rules); |
|
46 | + if(\is_array($rules)) { |
|
47 | + $element->addRules($rules); |
|
48 | + } else { |
|
49 | + $element->addRule($rules); |
|
50 | + } |
|
50 | 51 | unset($attributes["rules"]); |
51 | 52 | } |
52 | 53 | } |
@@ -56,8 +57,9 @@ discard block |
||
56 | 57 | $caption=$this->_instanceViewer->getCaption($index); |
57 | 58 | $name=$this->_instanceViewer->getFieldName($index); |
58 | 59 | $element=$elementCallback($name,$caption,$value); |
59 | - if(\is_array($attributes)) |
|
60 | - $this->_applyAttributes($element, $attributes,$index); |
|
60 | + if(\is_array($attributes)) { |
|
61 | + $this->_applyAttributes($element, $attributes,$index); |
|
62 | + } |
|
61 | 63 | return $element; |
62 | 64 | }); |
63 | 65 | return $this; |
@@ -34,8 +34,9 @@ discard block |
||
34 | 34 | $name=$attributes["name"]; |
35 | 35 | } |
36 | 36 | $element=$elementCallback($this->_getFieldIdentifier($prefix),$value,$name); |
37 | - if(\is_array($attributes)) |
|
38 | - $this->_applyAttributes($element, $attributes,$index); |
|
37 | + if(\is_array($attributes)) { |
|
38 | + $this->_applyAttributes($element, $attributes,$index); |
|
39 | + } |
|
39 | 40 | return $element; |
40 | 41 | }); |
41 | 42 | return $this; |
@@ -68,7 +69,9 @@ discard block |
||
68 | 69 | |
69 | 70 | public function fieldAsImage($index,$size=Size::SMALL,$circular=false){ |
70 | 71 | $this->setValueFunction($index,function($img) use($size,$circular){ |
71 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
72 | + $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) { |
|
73 | + $image->setCircular(); |
|
74 | + } |
|
72 | 75 | return $image; |
73 | 76 | }); |
74 | 77 | return $this; |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | public function __construct($instance=NULL,$captions=NULL){ |
18 | 18 | $this->values=[]; |
19 | 19 | $this->afterCompile=[]; |
20 | - if(isset($instance)) |
|
21 | - $this->setInstance($instance); |
|
20 | + if(isset($instance)) { |
|
21 | + $this->setInstance($instance); |
|
22 | + } |
|
22 | 23 | $this->setCaptions($captions); |
23 | 24 | } |
24 | 25 | |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | public function getIdentifier(){ |
36 | 37 | $value=self::$index; |
37 | - if(isset($this->values["identifier"])) |
|
38 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
38 | + if(isset($this->values["identifier"])) { |
|
39 | + $value=$this->values["identifier"](self::$index,$this->instance); |
|
40 | + } |
|
39 | 41 | return $value; |
40 | 42 | } |
41 | 43 | |
@@ -58,19 +60,19 @@ discard block |
||
58 | 60 | $value=$property->getValue($this->instance); |
59 | 61 | if(isset($this->values[$index])){ |
60 | 62 | $value= $this->values[$index]($value,$this->instance,$index); |
61 | - }else{ |
|
63 | + } else{ |
|
62 | 64 | $value=$this->_getDefaultValue($property->getName(),$value, $index); |
63 | 65 | } |
64 | - }else{ |
|
65 | - if(\is_callable($property)) |
|
66 | - $value=$property($this->instance); |
|
67 | - elseif(\is_array($property)){ |
|
66 | + } else{ |
|
67 | + if(\is_callable($property)) { |
|
68 | + $value=$property($this->instance); |
|
69 | + } elseif(\is_array($property)){ |
|
68 | 70 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
69 | 71 | $value=\implode("", $values); |
70 | - }else{ |
|
72 | + } else{ |
|
71 | 73 | if(isset($this->values[$index])){ |
72 | 74 | $value= $this->values[$index]($property,$this->instance,$index); |
73 | - }else{ |
|
75 | + } else{ |
|
74 | 76 | $value=$property; |
75 | 77 | } |
76 | 78 | } |
@@ -93,10 +95,10 @@ discard block |
||
93 | 95 | if(isset($vb[$index])){ |
94 | 96 | if(\is_array($vb[$index])){ |
95 | 97 | $this->visibleProperties[$index][]=$field; |
96 | - }else{ |
|
98 | + } else{ |
|
97 | 99 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
98 | 100 | } |
99 | - }else{ |
|
101 | + } else{ |
|
100 | 102 | return $this->insertField($index, $field); |
101 | 103 | } |
102 | 104 | return $this; |
@@ -132,26 +134,27 @@ discard block |
||
132 | 134 | $this->reflect=new \ReflectionClass($instance); |
133 | 135 | if(\sizeof($this->visibleProperties)===0){ |
134 | 136 | $this->properties=$this->getDefaultProperties(); |
135 | - }else{ |
|
137 | + } else{ |
|
136 | 138 | foreach ($this->visibleProperties as $property){ |
137 | 139 | if(\is_callable($property)){ |
138 | 140 | $this->properties[]=$property; |
139 | - }elseif(\is_string($property)){ |
|
141 | + } elseif(\is_string($property)){ |
|
140 | 142 | try{ |
141 | 143 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
142 | 144 | $rProperty=$this->reflect->getProperty($property); |
143 | 145 | $this->properties[]=$rProperty; |
144 | - }catch(\Exception $e){ |
|
146 | + } catch(\Exception $e){ |
|
145 | 147 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
146 | 148 | $this->properties[]=$property; |
147 | 149 | } |
148 | - }elseif(\is_int($property)){ |
|
150 | + } elseif(\is_int($property)){ |
|
149 | 151 | $props=$this->getDefaultProperties(); |
150 | - if(isset($props[$property])) |
|
151 | - $this->properties[]=$props[$property]; |
|
152 | - else |
|
153 | - $this->properties[]=$property; |
|
154 | - }else{ |
|
152 | + if(isset($props[$property])) { |
|
153 | + $this->properties[]=$props[$property]; |
|
154 | + } else { |
|
155 | + $this->properties[]=$property; |
|
156 | + } |
|
157 | + } else{ |
|
155 | 158 | $this->properties[]=$property; |
156 | 159 | } |
157 | 160 | } |
@@ -195,12 +198,13 @@ discard block |
||
195 | 198 | } |
196 | 199 | |
197 | 200 | public function getCaption($index){ |
198 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
199 | - return $this->properties[$index]->getName(); |
|
200 | - elseif(\is_callable($this->properties[$index])) |
|
201 | - return ""; |
|
202 | - else |
|
203 | - return $this->properties[$index]; |
|
201 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
202 | + return $this->properties[$index]->getName(); |
|
203 | + } elseif(\is_callable($this->properties[$index])) { |
|
204 | + return ""; |
|
205 | + } else { |
|
206 | + return $this->properties[$index]; |
|
207 | + } |
|
204 | 208 | } |
205 | 209 | |
206 | 210 | public function getCaptions(){ |