Completed
Push — master ( d9189f...847185 )
by Jean-Christophe
03:54
created
Ajax/common/html/HtmlSingleElement.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	}
14 14
 
15 15
 	public function setClass($classNames) {
16
-		if(\is_array($classNames)){
16
+		if (\is_array($classNames)) {
17 17
 			$classNames=implode(" ", $classNames);
18 18
 		}
19 19
 		$this->setProperty("class", $classNames);
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	}
22 22
 
23 23
 	public function addClass($classNames) {
24
-		if(\is_array($classNames)){
24
+		if (\is_array($classNames)) {
25 25
 			$classNames=implode(" ", $classNames);
26 26
 		}
27 27
 		$this->addToProperty("class", $classNames);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function fromArray($array) {
54 54
 		$array=parent::fromArray($array);
55
-		foreach ( $array as $key => $value ) {
55
+		foreach ($array as $key => $value) {
56 56
 			$this->setProperty($key, $value);
57 57
 		}
58 58
 		return $array;
Please login to merge, or discard this patch.
Ajax/common/html/traits/BaseHtmlPropertiesTrait.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
  * @author jc
9 9
  *
10 10
  */
11
-trait BaseHtmlPropertiesTrait{
11
+trait BaseHtmlPropertiesTrait {
12 12
 
13
-	protected $properties=array ();
13
+	protected $properties=array();
14 14
 	abstract protected function ctrl($name, $value, $typeCtrl);
15 15
 	abstract protected function removeOldValues(&$oldValue, $allValues);
16
-	abstract protected function _getElementBy($callback,$elements);
16
+	abstract protected function _getElementBy($callback, $elements);
17 17
 	public function getProperties() {
18 18
 		return $this->properties;
19 19
 	}
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 
40 40
 	public function addToProperty($name, $value, $separator=" ") {
41 41
 		if (\is_array($value)) {
42
-			foreach ( $value as $v ) {
42
+			foreach ($value as $v) {
43 43
 				$this->addToProperty($name, $v, $separator);
44 44
 			}
45
-		} else if ($value !== "" && $this->propertyContains($name, $value) === false) {
45
+		} else if ($value!=="" && $this->propertyContains($name, $value)===false) {
46 46
 			$v=@$this->properties[$name];
47
-			if (isset($v) && $v !== "")
48
-				$v=$v . $separator . $value;
47
+			if (isset($v) && $v!=="")
48
+				$v=$v.$separator.$value;
49 49
 				else
50 50
 					$v=$value;
51 51
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	}
84 84
 
85 85
 	public function addToPropertyCtrlCheck($name, $value, $typeCtrl) {
86
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
86
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
87 87
 			return $this->addToProperty($name, $value);
88 88
 		}
89 89
 		return $this;
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 
106 106
 	protected function setPropertyCtrl($name, $value, $typeCtrl) {
107
-		if ($this->ctrl($name, $value, $typeCtrl) === true)
107
+		if ($this->ctrl($name, $value, $typeCtrl)===true)
108 108
 			return $this->setProperty($name, $value);
109 109
 			return $this;
110 110
 	}
111 111
 
112
-	protected function getElementByPropertyValue($propertyName,$value, $elements) {
113
-		return $this->_getElementBy(function($element) use ($propertyName,$value){return $element->propertyContains($propertyName, $value) === true;}, $elements);
112
+	protected function getElementByPropertyValue($propertyName, $value, $elements) {
113
+		return $this->_getElementBy(function($element) use ($propertyName, $value){return $element->propertyContains($propertyName, $value)===true; }, $elements);
114 114
 	}
115 115
 }
116 116
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/content/InternalPopup.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,64 +14,64 @@
 block discarded – undo
14 14
 	protected $params;
15 15
 	protected $semElement;
16 16
 
17
-	public function __construct($semElement,$title="",$content="",$variation=NULL,$params=array()){
17
+	public function __construct($semElement, $title="", $content="", $variation=NULL, $params=array()) {
18 18
 		$this->semElement=$semElement;
19 19
 		$this->title=$title;
20 20
 		$this->content=$content;
21
-		$this->setAttributes($variation,$params);
21
+		$this->setAttributes($variation, $params);
22 22
 	}
23 23
 
24 24
 	public function setHtml($html) {
25
-		$this->html= $html;
25
+		$this->html=$html;
26 26
 		return $this;
27 27
 	}
28 28
 
29
-	public function setAttributes($variation=NULL,$params=array()){
29
+	public function setAttributes($variation=NULL, $params=array()) {
30 30
 		$this->variation=$variation;
31 31
 		$this->params=$params;
32 32
 	}
33 33
 
34
-	public function onShow($jsCode){
34
+	public function onShow($jsCode) {
35 35
 		$this->params["onShow"]=$jsCode;
36 36
 	}
37 37
 
38
-	public function compile(JsUtils $js=NULL){
39
-		if(JString::isNotNull($this->title)){
38
+	public function compile(JsUtils $js=NULL) {
39
+		if (JString::isNotNull($this->title)) {
40 40
 			$this->semElement->addToProperty("data-title", $this->title);
41 41
 		}
42
-		if(JString::isNotNull($this->content)){
42
+		if (JString::isNotNull($this->content)) {
43 43
 			$this->semElement->addToProperty("data-content", $this->content);
44 44
 		}
45 45
 		$this->_compileHtml($js);
46
-		if(JString::isNotNull($this->variation)){
46
+		if (JString::isNotNull($this->variation)) {
47 47
 			$this->semElement->addToProperty("data-variation", $this->variation);
48 48
 		}
49 49
 	}
50 50
 
51
-	private function _compileHtml(JsUtils $js=NULL){
52
-		if(JString::isNotNull($this->html)){
51
+	private function _compileHtml(JsUtils $js=NULL) {
52
+		if (JString::isNotNull($this->html)) {
53 53
 			$html=$this->html;
54
-			if(\is_array($html)){
54
+			if (\is_array($html)) {
55 55
 				\array_walk($html, function(&$item) use($js){
56
-					if($item instanceof HtmlSemDoubleElement){
56
+					if ($item instanceof HtmlSemDoubleElement) {
57 57
 						$comp=$item->compile($js);
58
-						if(isset($js)){
58
+						if (isset($js)) {
59 59
 							$bs=$item->run($js);
60
-							if(isset($bs))
60
+							if (isset($bs))
61 61
 								$this->params['onShow']=$bs->getScript();
62 62
 						}
63 63
 						$item=$comp;
64 64
 					}
65 65
 				});
66
-				$html=\implode("",$html);
66
+				$html=\implode("", $html);
67 67
 			}
68 68
 			$html=\str_replace("\"", "'", $html);
69 69
 			$this->semElement->addToProperty("data-html", $html);
70 70
 		}
71 71
 	}
72 72
 
73
-	public function run(JsUtils $js){
74
-		$js->semantic()->popup("#".$this->semElement->getIdentifier(),$this->params);
73
+	public function run(JsUtils $js) {
74
+		$js->semantic()->popup("#".$this->semElement->getIdentifier(), $this->params);
75 75
 	}
76 76
 
77 77
 }
78 78
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/InstanceViewer.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -17,186 +17,186 @@  discard block
 block discarded – undo
17 17
 
18 18
 	public static $index=0;
19 19
 
20
-	public function __construct($identifier,$instance=NULL,$captions=NULL){
20
+	public function __construct($identifier, $instance=NULL, $captions=NULL) {
21 21
 		$this->widgetIdentifier=$identifier;
22 22
 		$this->values=[];
23 23
 		$this->afterCompile=[];
24
-		if(isset($instance))
24
+		if (isset($instance))
25 25
 			$this->setInstance($instance);
26 26
 		$this->setCaptions($captions);
27 27
 		$this->captionCallback=NULL;
28
-		$this->defaultValueFunction=function($name,$value){return $value;};
28
+		$this->defaultValueFunction=function($name, $value) {return $value; };
29 29
 	}
30 30
 
31
-	public function getValues(){
31
+	public function getValues() {
32 32
 		$values=[];
33 33
 		$index=0;
34 34
 		$count=$this->count();
35
-		while($index<$count){
35
+		while ($index<$count) {
36 36
 			$values[]=$this->getValue($index++);
37 37
 		}
38 38
 		return $values;
39 39
 	}
40 40
 
41
-	public function getIdentifier($index=NULL){
42
-		if(!isset($index))
41
+	public function getIdentifier($index=NULL) {
42
+		if (!isset($index))
43 43
 			$index=self::$index;
44 44
 		$value=$index;
45
-		if(isset($this->values["identifier"]))
46
-			$value=$this->values["identifier"]($index,$this->instance);
45
+		if (isset($this->values["identifier"]))
46
+			$value=$this->values["identifier"]($index, $this->instance);
47 47
 		return $value;
48 48
 	}
49 49
 
50
-	public function getValue($index){
50
+	public function getValue($index) {
51 51
 		$property=$this->properties[$index];
52 52
 		return $this->_getValue($property, $index);
53 53
 	}
54 54
 
55
-	protected function _beforeAddProperty($index,&$field){
55
+	protected function _beforeAddProperty($index, &$field) {
56 56
 
57 57
 	}
58 58
 
59
-	protected function _getDefaultValue($name,$value,$index){
59
+	protected function _getDefaultValue($name, $value, $index) {
60 60
 		$func=$this->defaultValueFunction;
61
-		return $func($name,$value,$index,$this->instance);
61
+		return $func($name, $value, $index, $this->instance);
62 62
 	}
63 63
 
64
-	protected function _getPropertyValue(\ReflectionProperty $property,$index){
64
+	protected function _getPropertyValue(\ReflectionProperty $property, $index) {
65 65
 		$property->setAccessible(true);
66 66
 		$value=$property->getValue($this->instance);
67
-		if(isset($this->values[$index])){
68
-			$value= $this->values[$index]($value,$this->instance,$index);
69
-		}else{
70
-			$value=$this->_getDefaultValue($property->getName(),$value, $index);
67
+		if (isset($this->values[$index])) {
68
+			$value=$this->values[$index]($value, $this->instance, $index);
69
+		} else {
70
+			$value=$this->_getDefaultValue($property->getName(), $value, $index);
71 71
 		}
72 72
 		return $value;
73 73
 	}
74 74
 
75
-	protected function _getValue($property,$index){
75
+	protected function _getValue($property, $index) {
76 76
 		$value=null;
77
-		if($property instanceof \ReflectionProperty){
77
+		if ($property instanceof \ReflectionProperty) {
78 78
 			$value=$this->_getPropertyValue($property, $index);
79
-		}else{
80
-			if(\is_callable($property))
79
+		} else {
80
+			if (\is_callable($property))
81 81
 				$value=$property($this->instance);
82
-			elseif(\is_array($property)){
83
-				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
82
+			elseif (\is_array($property)) {
83
+				$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property);
84 84
 				$value=\implode("", $values);
85
-			}else{
86
-				if(isset($this->values[$index])){
87
-					$value= $this->values[$index]($property,$this->instance,$index);
88
-				}elseif(isset($this->instance->{$property})){
85
+			} else {
86
+				if (isset($this->values[$index])) {
87
+					$value=$this->values[$index]($property, $this->instance, $index);
88
+				}elseif (isset($this->instance->{$property})) {
89 89
 					$value=$this->instance->{$property};
90 90
 				}
91 91
 			}
92 92
 		}
93
-		if(isset($this->afterCompile[$index])){
94
-			if(\is_callable($this->afterCompile[$index])){
95
-				$this->afterCompile[$index]($value,$this->instance,$index);
93
+		if (isset($this->afterCompile[$index])) {
94
+			if (\is_callable($this->afterCompile[$index])) {
95
+				$this->afterCompile[$index]($value, $this->instance, $index);
96 96
 			}
97 97
 		}
98 98
 		return $value;
99 99
 	}
100 100
 
101
-	public function insertField($index,$field){
102
-		array_splice( $this->visibleProperties, $index, 0, $field );
101
+	public function insertField($index, $field) {
102
+		array_splice($this->visibleProperties, $index, 0, $field);
103 103
 		return $this;
104 104
 	}
105 105
 
106
-	public function insertInField($index,$field){
106
+	public function insertInField($index, $field) {
107 107
 		$vb=$this->visibleProperties;
108
-		if(isset($vb[$index])){
109
-			if(\is_array($vb[$index])){
108
+		if (isset($vb[$index])) {
109
+			if (\is_array($vb[$index])) {
110 110
 				$this->visibleProperties[$index][]=$field;
111
-			}else{
112
-				$this->visibleProperties[$index]=[$vb[$index],$field];
111
+			} else {
112
+				$this->visibleProperties[$index]=[$vb[$index], $field];
113 113
 			}
114
-		}else{
114
+		} else {
115 115
 			return $this->insertField($index, $field);
116 116
 		}
117 117
 		return $this;
118 118
 	}
119 119
 
120
-	public function addField($field){
120
+	public function addField($field) {
121 121
 		$this->visibleProperties[]=$field;
122 122
 		return $this;
123 123
 	}
124 124
 
125
-	public function count(){
125
+	public function count() {
126 126
 		return \sizeof($this->properties);
127 127
 	}
128 128
 
129
-	public function visiblePropertiesCount(){
129
+	public function visiblePropertiesCount() {
130 130
 		return \sizeof($this->visibleProperties);
131 131
 	}
132 132
 
133
-	public function getProperty($index){
133
+	public function getProperty($index) {
134 134
 		return $this->properties[$index];
135 135
 	}
136 136
 
137
-	public function getFieldName($index){
137
+	public function getFieldName($index) {
138 138
 		$property=$this->getProperty($index);
139
-		if($property instanceof \ReflectionProperty){
139
+		if ($property instanceof \ReflectionProperty) {
140 140
 			$result=$property->getName();
141
-		}elseif(\is_callable($property)){
141
+		}elseif (\is_callable($property)) {
142 142
 			$result=$this->visibleProperties[$index];
143
-		}else{
143
+		} else {
144 144
 			$result=$property;
145 145
 		}
146 146
 		return $result;
147 147
 	}
148 148
 
149 149
 
150
-	protected function showableProperty(\ReflectionProperty $rProperty){
151
-		return JString::startswith($rProperty->getName(),"_")===false;
150
+	protected function showableProperty(\ReflectionProperty $rProperty) {
151
+		return JString::startswith($rProperty->getName(), "_")===false;
152 152
 	}
153 153
 
154 154
 	public function setInstance($instance) {
155
-		if(\is_string($instance)){
155
+		if (\is_string($instance)) {
156 156
 			$instance=new $instance();
157 157
 		}
158 158
 		$this->instance=$instance;
159 159
 		$this->properties=[];
160 160
 		$this->reflect=new \ReflectionClass($instance);
161
-		if(\sizeof($this->visibleProperties)===0){
161
+		if (\sizeof($this->visibleProperties)===0) {
162 162
 			$this->properties=$this->getDefaultProperties();
163
-		}else{
164
-			foreach ($this->visibleProperties as $property){
163
+		} else {
164
+			foreach ($this->visibleProperties as $property) {
165 165
 				$this->setInstanceProperty($property);
166 166
 			}
167 167
 		}
168 168
 		return $this;
169 169
 	}
170 170
 
171
-	private function setInstanceProperty($property){
172
-		if(\is_callable($property)){
171
+	private function setInstanceProperty($property) {
172
+		if (\is_callable($property)) {
173 173
 			$this->properties[]=$property;
174
-		}elseif(\is_string($property)){
175
-			try{
174
+		}elseif (\is_string($property)) {
175
+			try {
176 176
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
177 177
 				$rProperty=$this->reflect->getProperty($property);
178 178
 				$this->properties[]=$rProperty;
179
-			}catch(\Exception $e){
179
+			}catch (\Exception $e) {
180 180
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
181 181
 				$this->properties[]=$property;
182 182
 			}
183
-		}elseif(\is_int($property)){
183
+		}elseif (\is_int($property)) {
184 184
 			$props=$this->getDefaultProperties();
185
-			if(isset($props[$property]))
185
+			if (isset($props[$property]))
186 186
 				$this->properties[]=$props[$property];
187 187
 				else
188 188
 					$this->properties[]=$property;
189
-		}else{
189
+		} else {
190 190
 			$this->properties[]=$property;
191 191
 		}
192 192
 	}
193 193
 
194
-	protected function getDefaultProperties(){
194
+	protected function getDefaultProperties() {
195 195
 		$result=[];
196 196
 		$properties=$this->reflect->getProperties();
197
-		foreach ($properties as $property){
197
+		foreach ($properties as $property) {
198 198
 			$showable=$this->showableProperty($property);
199
-			if($showable!==false){
199
+			if ($showable!==false) {
200 200
 				$result[]=$property;
201 201
 			}
202 202
 		}
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
 		return $this;
209 209
 	}
210 210
 
211
-	public function setValueFunction($index,$callback){
211
+	public function setValueFunction($index, $callback) {
212 212
 		$this->values[$index]=$callback;
213 213
 		return $this;
214 214
 	}
215 215
 
216
-	public function setIdentifierFunction($callback){
216
+	public function setIdentifierFunction($callback) {
217 217
 		$this->values["identifier"]=$callback;
218 218
 		return $this;
219 219
 	}
@@ -226,41 +226,41 @@  discard block
 block discarded – undo
226 226
 		return $this->properties;
227 227
 	}
228 228
 
229
-	public function getCaption($index){
230
-		if(isset($this->captions[$index])){
229
+	public function getCaption($index) {
230
+		if (isset($this->captions[$index])) {
231 231
 			return $this->captions[$index];
232 232
 		}
233
-		if($this->properties[$index] instanceof \ReflectionProperty)
233
+		if ($this->properties[$index] instanceof \ReflectionProperty)
234 234
 			return $this->properties[$index]->getName();
235
-		elseif(\is_callable($this->properties[$index]))
235
+		elseif (\is_callable($this->properties[$index]))
236 236
 			return "";
237 237
 		else
238 238
 			return $this->properties[$index];
239 239
 	}
240 240
 
241
-	public function getCaptions(){
242
-		if(isset($this->captions)){
243
-			$captions= $this->captions;
244
-			for($i=\sizeof($captions);$i<$this->count();$i++){
241
+	public function getCaptions() {
242
+		if (isset($this->captions)) {
243
+			$captions=$this->captions;
244
+			for ($i=\sizeof($captions); $i<$this->count(); $i++) {
245 245
 				$captions[]="";
246 246
 			}
247
-		}else{
247
+		} else {
248 248
 			$captions=[];
249 249
 			$index=0;
250 250
 			$count=$this->count();
251
-			while($index<$count){
251
+			while ($index<$count) {
252 252
 				$captions[]=$this->getCaption($index++);
253 253
 			}
254 254
 		}
255
-		if(isset($this->captionCallback) && \is_callable($this->captionCallback)){
255
+		if (isset($this->captionCallback) && \is_callable($this->captionCallback)) {
256 256
 			$callback=$this->captionCallback;
257
-			$callback($captions,$this->instance);
257
+			$callback($captions, $this->instance);
258 258
 		}
259 259
 		return $captions;
260 260
 	}
261 261
 
262
-	public function setCaption($index,$caption){
263
-		if(isset($this->captions)===false)
262
+	public function setCaption($index, $caption) {
263
+		if (isset($this->captions)===false)
264 264
 			$this->captions=[];
265 265
 		$this->captions[$index]=$caption;
266 266
 		return $this;
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @param callable $callback function called after the field compilation
279 279
 	 * @return \Ajax\semantic\widgets\datatable\InstanceViewer
280 280
 	 */
281
-	public function afterCompile($index,$callback){
281
+	public function afterCompile($index, $callback) {
282 282
 		$this->afterCompile[$index]=$callback;
283 283
 		return $this;
284 284
 	}
Please login to merge, or discard this patch.
Ajax/common/html/BaseHtml.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
  * @version 1.3
16 16
  */
17 17
 abstract class BaseHtml extends BaseWidget {
18
-	use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait;
18
+	use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait;
19 19
 	protected $_template;
20 20
 	protected $tagName;
21
-	protected $_wrapBefore=array ();
22
-	protected $_wrapAfter=array ();
21
+	protected $_wrapBefore=array();
22
+	protected $_wrapAfter=array();
23 23
 	protected $_bsComponent;
24 24
 
25 25
 	/**
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	abstract public function run(JsUtils $js);
31 31
 
32
-	private function _callSetter($setter,$key,$value,&$array){
32
+	private function _callSetter($setter, $key, $value, &$array) {
33 33
 		$result=false;
34 34
 		if (method_exists($this, $setter) && !JString::startswith($key, "_")) {
35 35
 			try {
36 36
 				$this->$setter($value);
37 37
 				unset($array[$key]);
38 38
 				$result=true;
39
-			} catch ( \Exception $e ) {
39
+			}catch (\Exception $e) {
40 40
 				$result=false;
41 41
 			}
42 42
 		}
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
 	}
45 45
 
46 46
 	protected function getTemplate(JsUtils $js=NULL) {
47
-		return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js);
47
+		return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js);
48 48
 	}
49 49
 
50 50
 	protected function ctrl($name, $value, $typeCtrl) {
51 51
 		if (\is_array($typeCtrl)) {
52
-			if (array_search($value, $typeCtrl) === false) {
53
-				throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}");
52
+			if (array_search($value, $typeCtrl)===false) {
53
+				throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
54 54
 			}
55 55
 		} else {
56 56
 			if (!$typeCtrl($value)) {
57
-				throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name);
57
+				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name);
58 58
 			}
59 59
 		}
60 60
 		return true;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
 
65 65
 	protected function setMemberCtrl(&$name, $value, $typeCtrl) {
66
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
66
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
67 67
 			return $name=$value;
68 68
 		}
69 69
 		return $this;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") {
73 73
 		if (\is_array($typeCtrl)) {
74 74
 			$this->removeOldValues($name, $typeCtrl);
75
-			$name.=$separator . $value;
75
+			$name.=$separator.$value;
76 76
 		}
77 77
 		return $this;
78 78
 	}
@@ -80,17 +80,17 @@  discard block
 block discarded – undo
80 80
 
81 81
 
82 82
 	protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") {
83
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
83
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
84 84
 			if (\is_array($typeCtrl)) {
85 85
 				$this->removeOldValues($name, $typeCtrl);
86 86
 			}
87
-			$name.=$separator . $value;
87
+			$name.=$separator.$value;
88 88
 		}
89 89
 		return $this;
90 90
 	}
91 91
 
92 92
 	protected function addToMember(&$name, $value, $separator=" ") {
93
-		$name=str_ireplace($value, "", $name) . $separator . $value;
93
+		$name=str_ireplace($value, "", $name).$separator.$value;
94 94
 		return $this;
95 95
 	}
96 96
 
@@ -101,17 +101,17 @@  discard block
 block discarded – undo
101 101
 		$oldValue=trim($oldValue);
102 102
 	}
103 103
 
104
-	protected function _getElementBy($callback,$elements){
104
+	protected function _getElementBy($callback, $elements) {
105 105
 		if (\is_array($elements)) {
106 106
 			$flag=false;
107 107
 			$index=0;
108
-			while ( !$flag && $index < sizeof($elements) ) {
108
+			while (!$flag && $index<sizeof($elements)) {
109 109
 				if ($elements[$index] instanceof BaseHtml)
110 110
 					$flag=($callback($elements[$index]));
111 111
 					$index++;
112 112
 			}
113
-			if ($flag === true)
114
-				return $elements[$index - 1];
113
+			if ($flag===true)
114
+				return $elements[$index-1];
115 115
 		} elseif ($elements instanceof BaseHtml) {
116 116
 			if ($callback($elements))
117 117
 				return $elements;
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
 	}
140 140
 
141 141
 	public function fromArray($array) {
142
-		foreach ( $this as $key => $value ) {
143
-			if(array_key_exists($key, $array)===true)
144
-				$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
142
+		foreach ($this as $key => $value) {
143
+			if (array_key_exists($key, $array)===true)
144
+				$this->_callSetter("set".ucfirst($key), $key, $array[$key], $array);
145 145
 		}
146
-		foreach ( $array as $key => $value ) {
147
-			if($this->_callSetter($key, $key, $value, $array)===false){
148
-				$this->_callSetter("set" . ucfirst($key), $key, $value, $array);
146
+		foreach ($array as $key => $value) {
147
+			if ($this->_callSetter($key, $key, $value, $array)===false) {
148
+				$this->_callSetter("set".ucfirst($key), $key, $value, $array);
149 149
 			}
150 150
 		}
151 151
 		return $array;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
 	public function fromDatabaseObjects($objects, $function) {
155 155
 		if (isset($objects)) {
156
-			foreach ( $objects as $object ) {
156
+			foreach ($objects as $object) {
157 157
 				$this->fromDatabaseObject($object, $function);
158 158
 			}
159 159
 		}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
 
176 176
 	public function getElementById($identifier, $elements) {
177
-		return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements);
177
+		return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements);
178 178
 	}
179 179
 
180 180
 	public function getBsComponent() {
@@ -188,19 +188,19 @@  discard block
 block discarded – undo
188 188
 
189 189
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
190 190
 		$result=$this->getTemplate($js);
191
-		foreach ( $this as $key => $value ) {
192
-			if (JString::startswith($key, "_") === false && $key !== "events") {
191
+		foreach ($this as $key => $value) {
192
+			if (JString::startswith($key, "_")===false && $key!=="events") {
193 193
 				if (\is_array($value)) {
194 194
 					$v=PropertyWrapper::wrap($value, $js);
195 195
 				} else {
196 196
 					$v=$value;
197 197
 				}
198
-				$result=str_ireplace("%" . $key . "%", $v, $result);
198
+				$result=str_ireplace("%".$key."%", $v, $result);
199 199
 			}
200 200
 		}
201 201
 		if (isset($js)===true) {
202 202
 			$this->run($js);
203
-			if (isset($view) === true) {
203
+			if (isset($view)===true) {
204 204
 				$js->addViewElement($this->identifier, $result, $view);
205 205
 			}
206 206
 		}
Please login to merge, or discard this patch.
Ajax/bootstrap/html/HtmlButtongroups.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @return HtmlButtongroups default : ""
40 40
 	 */
41 41
 	public function setSize($size) {
42
-		foreach ( $this->elements as $element ) {
42
+		foreach ($this->elements as $element) {
43 43
 			$element->setSize($size);
44 44
 		}
45 45
 		if (is_int($size)) {
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	}
50 50
 
51 51
 	public function setStyle($value) {
52
-		foreach ( $this->elements as $element )
52
+		foreach ($this->elements as $element)
53 53
 			$element->setStyle($value);
54 54
 	}
55 55
 
@@ -69,29 +69,29 @@  discard block
 block discarded – undo
69 69
 	public function addElement($element) {
70 70
 		$result=$element;
71 71
 		$iid=sizeof($this->elements)+1;
72
-		if (($element instanceof HtmlDropdown)||($element instanceof HtmlSplitbutton)) {
72
+		if (($element instanceof HtmlDropdown) || ($element instanceof HtmlSplitbutton)) {
73 73
 			$this->addExistingDropDown($element);
74 74
 		} elseif (\is_array($element)) {
75
-			$result=$this->_addArrayElement($element,$iid);
75
+			$result=$this->_addArrayElement($element, $iid);
76 76
 		} elseif (is_string($element)) {
77
-			$result=new HtmlButton($this->identifier."-button-".$iid,$element);
77
+			$result=new HtmlButton($this->identifier."-button-".$iid, $element);
78 78
 		}
79
-		if($result instanceof HtmlButton)
79
+		if ($result instanceof HtmlButton)
80 80
 			$this->elements[]=$result;
81 81
 		return $result;
82 82
 	}
83 83
 
84
-	private function _addArrayElement(array $element,$iid){
84
+	private function _addArrayElement(array $element, $iid) {
85 85
 		if (array_key_exists("glyph", $element))
86 86
 			$bt=new HtmlGlyphButton($this->identifier."-button-".$iid);
87 87
 		elseif (array_key_exists("btnCaption", $element)) {
88 88
 			if (array_key_exists("split", $element))
89 89
 				$bt=new HtmlSplitbutton($this->identifier."-dropdown-".$iid);
90
-			else{
90
+			else {
91 91
 				$bt=new HtmlDropdown($this->identifier."-dropdown-".$iid);
92 92
 				$this->dropdownAsButton($bt);
93 93
 			}
94
-		} else{
94
+		} else {
95 95
 			$bt=new HtmlButton($this->identifier."-button-".$iid);
96 96
 			$bt->fromArray($element);
97 97
 		}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	}
100 100
 
101 101
 	public function addElements($elements) {
102
-		foreach ( $elements as $element ) {
102
+		foreach ($elements as $element) {
103 103
 			$this->addElement($element);
104 104
 		}
105 105
 		return $this;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		} else
120 120
 			$value="btn-group-".$value;
121 121
 		if (strstr($value, "justified")) {
122
-			foreach ( $this->elements as $element ) {
122
+			foreach ($this->elements as $element) {
123 123
 				$element->wrap('<div class="btn-group" role="group">', '</div>');
124 124
 			}
125 125
 		}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @see \Ajax\bootstrap\html\base\BaseHtml::on()
151 151
 	 */
152 152
 	public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
153
-		foreach ( $this->elements as $element ) {
153
+		foreach ($this->elements as $element) {
154 154
 			$element->on($event, $jsCode, $stopPropagation, $preventDefault);
155 155
 		}
156 156
 		return $this;
Please login to merge, or discard this patch.
Ajax/service/JQueryAjaxEffect.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Ajax\service;
3 3
 class JQueryAjaxEffect {
4
-	public static function none($responseElement,$jqueryDone="html"){
4
+	public static function none($responseElement, $jqueryDone="html") {
5 5
 		return "\t$({$responseElement}).{$jqueryDone}( data );\n";
6 6
 	}
7 7
 
8
-	public static function fade($responseElement,$jqueryDone="html"){
8
+	public static function fade($responseElement, $jqueryDone="html") {
9 9
 		return "\t$({$responseElement}).hide().{$jqueryDone}( data ).fadeIn();\n";
10 10
 	}
11 11
 
12
-	public static function slide($responseElement,$jqueryDone="html"){
12
+	public static function slide($responseElement, $jqueryDone="html") {
13 13
 		return "\t$({$responseElement}).hide().{$jqueryDone}( data ).slideDown();\n";
14 14
 	}
15 15
 }
16 16
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/traits/FormTrait.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -6,28 +6,28 @@  discard block
 block discarded – undo
6 6
 use Ajax\service\AjaxCall;
7 7
 use Ajax\JsUtils;
8 8
 
9
-trait FormTrait{
9
+trait FormTrait {
10 10
 
11 11
 	/**
12 12
 	 * @return HtmlForm
13 13
 	 */
14 14
 	abstract protected function getForm();
15 15
 
16
-	protected function addCompoValidation($compo,$field){
16
+	protected function addCompoValidation($compo, $field) {
17 17
 		$validation=$field->getValidation();
18
-		if(isset($validation)){
18
+		if (isset($validation)) {
19 19
 			$validation->setIdentifier($field->getDataField()->getIdentifier());
20 20
 			$compo->addFieldValidation($validation);
21 21
 		}
22 22
 		return $compo;
23 23
 	}
24 24
 
25
-	protected function _runValidationParams(&$compo,JsUtils $js=NULL){
25
+	protected function _runValidationParams(&$compo, JsUtils $js=NULL) {
26 26
 		$form=$this->getForm();
27 27
 		$params=$form->getValidationParams();
28
-		if(isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall){
28
+		if (isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall) {
29 29
 			$compilation=$params["_ajaxSubmit"]->compile($js);
30
-			$compilation=str_ireplace("\"","%quote%", $compilation);
30
+			$compilation=str_ireplace("\"", "%quote%", $compilation);
31 31
 			$this->onSuccess($compilation);
32 32
 			$form->removeValidationParam("_ajaxSubmit");
33 33
 		}
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 		return $this->getForm()->addToProperty("class", "loading");
41 41
 	}
42 42
 
43
-	public function setAttached($value=true){
43
+	public function setAttached($value=true) {
44 44
 		$form=$this->getForm();
45
-		if($value)
46
-			$form->addToPropertyCtrl("class", "attached", array ("attached" ));
45
+		if ($value)
46
+			$form->addToPropertyCtrl("class", "attached", array("attached"));
47 47
 		return $form;
48 48
 	}
49 49
 
50
-	public function addErrorMessage(){
50
+	public function addErrorMessage() {
51 51
 		return $this->getForm()->addContent((new HtmlMessage(""))->setError());
52 52
 	}
53 53
 
@@ -62,38 +62,38 @@  discard block
 block discarded – undo
62 62
 	 * @param string $responseElement
63 63
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
64 64
 	 */
65
-	public function submitOn($event,$identifier,$url,$responseElement){
65
+	public function submitOn($event, $identifier, $url, $responseElement) {
66 66
 		$form=$this->getForm();
67 67
 		$elem=$form->getElementById($identifier, $form->getContent());
68
-		if(isset($elem)){
69
-			$this->_buttonAsSubmit($elem, $event,$url,$responseElement);
68
+		if (isset($elem)) {
69
+			$this->_buttonAsSubmit($elem, $event, $url, $responseElement);
70 70
 		}
71 71
 		return $form;
72 72
 	}
73 73
 
74
-	public function submitOnClick($identifier,$url,$responseElement){
74
+	public function submitOnClick($identifier, $url, $responseElement) {
75 75
 		return $this->submitOn("click", $identifier, $url, $responseElement);
76 76
 	}
77 77
 
78
-	public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){
79
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
80
-		return $this->_buttonAsSubmit($bt, "click",$url,$responseElement);
78
+	public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) {
79
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
80
+		return $this->_buttonAsSubmit($bt, "click", $url, $responseElement);
81 81
 	}
82 82
 
83
-	protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL,$parameters=NULL){
83
+	protected function _buttonAsSubmit(&$button, $event, $url, $responseElement=NULL, $parameters=NULL) {
84 84
 		$form=$this->getForm();
85
-		if(isset($url) && isset($responseElement)){
85
+		if (isset($url) && isset($responseElement)) {
86 86
 			$button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');");
87
-			$params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true];
88
-			if(\is_array($parameters))
89
-				$params=\array_merge($params,$parameters);
87
+			$params=["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url, "stopPropagation"=>true];
88
+			if (\is_array($parameters))
89
+				$params=\array_merge($params, $parameters);
90 90
 			$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params));
91 91
 		}
92 92
 		return $button;
93 93
 	}
94 94
 
95
-	public function addReset($identifier,$value,$cssStyle=NULL){
96
-		$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
95
+	public function addReset($identifier, $value, $cssStyle=NULL) {
96
+		$bt=$this->getForm()->addButton($identifier, $value, $cssStyle);
97 97
 		$bt->setProperty("type", "reset");
98 98
 		return $bt;
99 99
 	}
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @param string $jsCode
104 104
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
105 105
 	 */
106
-	public function onValid($jsCode){
106
+	public function onValid($jsCode) {
107 107
 		$form=$this->getForm();
108 108
 		$form->addValidationParam("onValid", "%function(){".$jsCode."}%");
109 109
 		return $form;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @param string $jsCode can use event and fields parameters
115 115
 	 * @return HtmlForm
116 116
 	 */
117
-	public function onSuccess($jsCode){
117
+	public function onSuccess($jsCode) {
118 118
 		$form=$this->getForm();
119 119
 		$form->addValidationParam("onSuccess", "%function(event,fields){console.log(fields);".$jsCode."}%");
120 120
 		return $form;
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/FieldAsTrait.php 1 patch
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -23,23 +23,23 @@  discard block
 block discarded – undo
23 23
  * @property boolean $_edition
24 24
  * @property mixed _modelInstance
25 25
  */
26
-trait FieldAsTrait{
26
+trait FieldAsTrait {
27 27
 
28
-	abstract protected function _getFieldIdentifier($prefix,$name="");
29
-	abstract public function setValueFunction($index,$callback);
28
+	abstract protected function _getFieldIdentifier($prefix, $name="");
29
+	abstract public function setValueFunction($index, $callback);
30 30
 	abstract protected function _getFieldName($index);
31 31
 	abstract protected function _getFieldCaption($index);
32
-	abstract protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL,$parameters=NULL);
32
+	abstract protected function _buttonAsSubmit(&$button, $event, $url, $responseElement=NULL, $parameters=NULL);
33 33
 
34 34
 	/**
35 35
 	 * @param HtmlFormField $element
36 36
 	 * @param array $attributes
37 37
 	 */
38
-	protected function _applyAttributes($element,&$attributes,$index){
39
-		if(isset($attributes["callback"])){
38
+	protected function _applyAttributes($element, &$attributes, $index) {
39
+		if (isset($attributes["callback"])) {
40 40
 			$callback=$attributes["callback"];
41
-			if(\is_callable($callback)){
42
-				$callback($element,$this->_modelInstance,$index);
41
+			if (\is_callable($callback)) {
42
+				$callback($element, $this->_modelInstance, $index);
43 43
 				unset($attributes["callback"]);
44 44
 			}
45 45
 		}
@@ -49,42 +49,42 @@  discard block
 block discarded – undo
49 49
 		$element->fromArray($attributes);
50 50
 	}
51 51
 
52
-	private function _getLabelField($caption,$icon=NULL){
53
-		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon);
52
+	private function _getLabelField($caption, $icon=NULL) {
53
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
54 54
 		return $label;
55 55
 	}
56 56
 
57
-	protected function _addRules($element,&$attributes){
58
-		if(isset($attributes["rules"])){
57
+	protected function _addRules($element, &$attributes) {
58
+		if (isset($attributes["rules"])) {
59 59
 			$rules=$attributes["rules"];
60
-			if(\is_array($rules)){
60
+			if (\is_array($rules)) {
61 61
 				$element->addRules($rules);
62 62
 			}
63
-			else{
63
+			else {
64 64
 				$element->addRule($rules);
65 65
 			}
66 66
 			unset($attributes["rules"]);
67 67
 		}
68 68
 	}
69 69
 
70
-	protected function _prepareFormFields(&$field,$name,&$attributes){
70
+	protected function _prepareFormFields(&$field, $name, &$attributes) {
71 71
 		$field->setName($name);
72 72
 		$this->_addRules($field, $attributes);
73 73
 		return $field;
74 74
 	}
75 75
 
76
-	protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){
77
-		$this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){
76
+	protected function _fieldAs($elementCallback, $index, $attributes=NULL, $prefix=null) {
77
+		$this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback, $prefix){
78 78
 			$caption=$this->_getFieldCaption($index);
79 79
 			$name=$this->_getFieldName($index);
80
-			$id=$this->_getFieldIdentifier($prefix,$name);
81
-			if(isset($attributes["name"])){
80
+			$id=$this->_getFieldIdentifier($prefix, $name);
81
+			if (isset($attributes["name"])) {
82 82
 				$name=$attributes["name"];
83 83
 				unset($attributes["name"]);
84 84
 			}
85
-			$element=$elementCallback($id,$name,$value,$caption);
86
-			if(\is_array($attributes)){
87
-				$this->_applyAttributes($element, $attributes,$index);
85
+			$element=$elementCallback($id, $name, $value, $caption);
86
+			if (\is_array($attributes)) {
87
+				$this->_applyAttributes($element, $attributes, $index);
88 88
 			}
89 89
 			$element->setDisabled(!$this->_edition);
90 90
 			return $element;
@@ -93,160 +93,160 @@  discard block
 block discarded – undo
93 93
 	}
94 94
 
95 95
 
96
-	public function fieldAsProgress($index,$label=NULL, $attributes=array()){
97
-		$this->setValueFunction($index,function($value) use($label,$attributes){
98
-			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes);
96
+	public function fieldAsProgress($index, $label=NULL, $attributes=array()) {
97
+		$this->setValueFunction($index, function($value) use($label, $attributes){
98
+			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes);
99 99
 			return $pb;
100 100
 		});
101 101
 			return $this;
102 102
 	}
103 103
 
104
-	public function fieldAsRating($index,$max=5, $icon=""){
105
-		$this->setValueFunction($index,function($value) use($max,$icon){
106
-			$rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon);
104
+	public function fieldAsRating($index, $max=5, $icon="") {
105
+		$this->setValueFunction($index, function($value) use($max, $icon){
106
+			$rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon);
107 107
 			return $rating;
108 108
 		});
109 109
 			return $this;
110 110
 	}
111 111
 
112
-	public function fieldAsLabel($index,$icon=NULL){
113
-		$this->setValueFunction($index,function($caption) use($icon){
114
-			$lbl=$this->_getLabelField($caption,$icon);
112
+	public function fieldAsLabel($index, $icon=NULL) {
113
+		$this->setValueFunction($index, function($caption) use($icon){
114
+			$lbl=$this->_getLabelField($caption, $icon);
115 115
 			return $lbl;
116 116
 		});
117 117
 			return $this;
118 118
 	}
119 119
 
120
-	public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){
121
-		return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){
122
-			$header=new HtmlHeader($id,$niveau,$value);
123
-			if(isset($icon))
120
+	public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) {
121
+		return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){
122
+			$header=new HtmlHeader($id, $niveau, $value);
123
+			if (isset($icon))
124 124
 				$header->asIcon($icon, $value);
125 125
 			return $header;
126
-		}, $index,$attributes,"header");
126
+		}, $index, $attributes, "header");
127 127
 	}
128 128
 
129 129
 
130
-	public function fieldAsImage($index,$size=Size::MINI,$circular=false){
131
-		$this->setValueFunction($index,function($img) use($size,$circular){
132
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
130
+	public function fieldAsImage($index, $size=Size::MINI, $circular=false) {
131
+		$this->setValueFunction($index, function($img) use($size, $circular){
132
+			$image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular();
133 133
 			return $image;
134 134
 		});
135 135
 			return $this;
136 136
 	}
137 137
 
138
-	public function fieldAsAvatar($index,$attributes=NULL){
139
-		return $this->_fieldAs(function($id,$name,$value){
140
-			$img=new HtmlImage($id,$value);
138
+	public function fieldAsAvatar($index, $attributes=NULL) {
139
+		return $this->_fieldAs(function($id, $name, $value) {
140
+			$img=new HtmlImage($id, $value);
141 141
 			$img->asAvatar();
142 142
 			return $img;
143
-		}, $index,$attributes,"avatar");
143
+		}, $index, $attributes, "avatar");
144 144
 	}
145 145
 
146
-	public function fieldAsRadio($index,$attributes=NULL){
147
-		return $this->_fieldAs(function($id,$name,$value){
148
-			$input= new HtmlRadio($id,$name,$value,$value);
146
+	public function fieldAsRadio($index, $attributes=NULL) {
147
+		return $this->_fieldAs(function($id, $name, $value) {
148
+			$input=new HtmlRadio($id, $name, $value, $value);
149 149
 			return $input;
150
-		}, $index,$attributes,"radio");
150
+		}, $index, $attributes, "radio");
151 151
 	}
152 152
 
153
-	public function fieldAsRadios($index,$elements=[],$attributes=NULL){
154
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){
155
-			return HtmlFormFields::radios($name,$elements,$caption,$value);
156
-		}, $index,$attributes,"radios");
153
+	public function fieldAsRadios($index, $elements=[], $attributes=NULL) {
154
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){
155
+			return HtmlFormFields::radios($name, $elements, $caption, $value);
156
+		}, $index, $attributes, "radios");
157 157
 	}
158 158
 
159
-	public function fieldAsInput($index,$attributes=NULL){
160
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){
161
-			$input= new HtmlFormInput($id,$caption,"text",$value);
159
+	public function fieldAsInput($index, $attributes=NULL) {
160
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){
161
+			$input=new HtmlFormInput($id, $caption, "text", $value);
162 162
 			return $this->_prepareFormFields($input, $name, $attributes);
163
-		}, $index,$attributes,"input");
163
+		}, $index, $attributes, "input");
164 164
 	}
165 165
 
166
-	public function fieldAsTextarea($index,$attributes=NULL){
167
-		return $this->_fieldAs(function($id,$name,$value,$caption){
168
-			$textarea=new HtmlFormTextarea($id,$caption,$value);
166
+	public function fieldAsTextarea($index, $attributes=NULL) {
167
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
168
+			$textarea=new HtmlFormTextarea($id, $caption, $value);
169 169
 			$textarea->setName($name);
170 170
 			return $textarea;
171
-		}, $index,$attributes,"textarea");
171
+		}, $index, $attributes, "textarea");
172 172
 	}
173 173
 
174
-	public function fieldAsHidden($index,$attributes=NULL){
175
-		if(!\is_array($attributes)){
174
+	public function fieldAsHidden($index, $attributes=NULL) {
175
+		if (!\is_array($attributes)) {
176 176
 			$attributes=[];
177 177
 		}
178 178
 		$attributes["imputType"]="hidden";
179
-		return $this->fieldAsInput($index,$attributes);
179
+		return $this->fieldAsInput($index, $attributes);
180 180
 	}
181 181
 
182
-	public function fieldAsCheckbox($index,$attributes=NULL){
183
-		return $this->_fieldAs(function($id,$name,$value,$caption){
184
-			$input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier());
182
+	public function fieldAsCheckbox($index, $attributes=NULL) {
183
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
184
+			$input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier());
185 185
 			$input->setChecked(JString::isBooleanTrue($value));
186 186
 			$input->setName($name);
187 187
 			return $input;
188
-		}, $index,$attributes,"ck");
188
+		}, $index, $attributes, "ck");
189 189
 	}
190 190
 
191
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
192
-		return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple){
193
-			$dd=new HtmlFormDropdown($id,$elements,$caption,$value);
194
-			$dd->asSelect($name,$multiple);
191
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
192
+		return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple){
193
+			$dd=new HtmlFormDropdown($id, $elements, $caption, $value);
194
+			$dd->asSelect($name, $multiple);
195 195
 			return $dd;
196
-		}, $index,$attributes,"dd");
196
+		}, $index, $attributes, "dd");
197 197
 	}
198 198
 
199
-	public function fieldAsMessage($index,$attributes=NULL){
200
-		return $this->_fieldAs(function($id,$name,$value,$caption){
201
-			$mess= new HtmlMessage("message-".$id,$value);
199
+	public function fieldAsMessage($index, $attributes=NULL) {
200
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
201
+			$mess=new HtmlMessage("message-".$id, $value);
202 202
 			$mess->addHeader($caption);
203 203
 			return $mess;
204
-		}, $index,$attributes,"message");
204
+		}, $index, $attributes, "message");
205 205
 	}
206 206
 
207 207
 	/**Change fields type
208 208
 	 * @param array $types an array or associative array $type=>$attribute
209 209
 	 */
210
-	public function fieldsAs(array $types){
210
+	public function fieldsAs(array $types) {
211 211
 		$i=0;
212
-		if(JArray::isAssociative($types)){
213
-			foreach ($types as $type=>$attributes){
214
-				if(\is_int($type))
215
-					$this->fieldAs($i++,$attributes,[]);
212
+		if (JArray::isAssociative($types)) {
213
+			foreach ($types as $type=>$attributes) {
214
+				if (\is_int($type))
215
+					$this->fieldAs($i++, $attributes, []);
216 216
 				else
217
-					$this->fieldAs($i++,$type,$attributes);
217
+					$this->fieldAs($i++, $type, $attributes);
218 218
 			}
219
-		}else{
220
-			foreach ($types as $type){
221
-				$this->fieldAs($i++,$type);
219
+		} else {
220
+			foreach ($types as $type) {
221
+				$this->fieldAs($i++, $type);
222 222
 			}
223 223
 		}
224 224
 	}
225 225
 
226
-	public function fieldAs($index,$type,$attributes=NULL){
226
+	public function fieldAs($index, $type, $attributes=NULL) {
227 227
 		$method="fieldAs".\ucfirst($type);
228
-		if(\method_exists($this, $method)){
229
-			if(!\is_array($attributes)){
228
+		if (\method_exists($this, $method)) {
229
+			if (!\is_array($attributes)) {
230 230
 				$attributes=[$index];
231
-			}else{
231
+			} else {
232 232
 				\array_unshift($attributes, $index);
233 233
 			}
234
-			\call_user_func_array([$this,$method], $attributes);
234
+			\call_user_func_array([$this, $method], $attributes);
235 235
 		}
236 236
 	}
237 237
 
238
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
239
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){
240
-			$button=new HtmlButton($id,$value,$cssStyle);
241
-			$this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]);
238
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
239
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){
240
+			$button=new HtmlButton($id, $value, $cssStyle);
241
+			$this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]);
242 242
 			return $button;
243
-		}, $index,$attributes,"submit");
243
+		}, $index, $attributes, "submit");
244 244
 	}
245 245
 
246
-	public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){
247
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){
248
-			$button=new HtmlButton($id,$value,$cssStyle);
246
+	public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) {
247
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){
248
+			$button=new HtmlButton($id, $value, $cssStyle);
249 249
 			return $button;
250
-		}, $index,$attributes,"button");
250
+		}, $index, $attributes, "button");
251 251
 	}
252 252
 }
253 253
\ No newline at end of file
Please login to merge, or discard this patch.