Completed
Push — master ( a91c54...ab06fe )
by Jean-Christophe
03:07
created
Ajax/semantic/html/collections/form/HtmlFormFields.php 1 patch
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,12 +29,14 @@  discard block
 block discarded – undo
29 29
 				if (\is_string($end)) {
30 30
 					$label=$end;
31 31
 					\array_pop($fields);
32
-				} else
33
-					$label=NULL;
32
+				} else {
33
+									$label=NULL;
34
+				}
34 35
 			}
35 36
 		}
36
-		if (isset($label))
37
-			$this->setLabel($label);
37
+		if (isset($label)) {
38
+					$this->setLabel($label);
39
+		}
38 40
 		foreach ( $fields as $field ) {
39 41
 			$this->addItem($field);
40 42
 		}
@@ -57,8 +59,9 @@  discard block
 block discarded – undo
57 59
 
58 60
 	public function addItem($item) {
59 61
 		$item=parent::addItem($item);
60
-		if($item instanceof HtmlFormField)
61
-			$item->setContainer($this);
62
+		if($item instanceof HtmlFormField) {
63
+					$item->setContainer($this);
64
+		}
62 65
 		return $item;
63 66
 	}
64 67
 
@@ -66,8 +69,9 @@  discard block
 block discarded – undo
66 69
 		if ($this->_equalWidth) {
67 70
 			$count=$this->count();
68 71
 			$this->addToProperty("class", Wide::getConstants()["W".$count]." fields");
69
-		} else
70
-			$this->addToProperty("class", "fields");
72
+		} else {
73
+					$this->addToProperty("class", "fields");
74
+		}
71 75
 		return parent::compile($js, $view);
72 76
 	}
73 77
 
@@ -108,8 +112,9 @@  discard block
 block discarded – undo
108 112
 			$fields[]=$itemO;
109 113
 		}
110 114
 		$radios=new HtmlFormFields("fields-".$name, $fields);
111
-		if (isset($label))
112
-			$radios->setLabel($label)->setProperty("for", $name);
115
+		if (isset($label)) {
116
+					$radios->setLabel($label)->setProperty("for", $name);
117
+		}
113 118
 		return $radios;
114 119
 	}
115 120
 
@@ -124,8 +129,9 @@  discard block
 block discarded – undo
124 129
 			$fields[]=$itemO;
125 130
 		}
126 131
 		$radios=new HtmlFormFields("fields-".$name, $fields);
127
-		if (isset($label))
128
-			$radios->setLabel($label)->setProperty("for", $name);
132
+		if (isset($label)) {
133
+					$radios->setLabel($label)->setProperty("for", $name);
134
+		}
129 135
 		return $radios;
130 136
 	}
131 137
 
Please login to merge, or discard this patch.
Ajax/semantic/html/elements/HtmlButtonGroups.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,18 +17,18 @@  discard block
 block discarded – undo
17 17
 	protected $_dropdown;
18 18
 	public function __construct($identifier, $elements=array(), $asIcons=false) {
19 19
 		parent::__construct($identifier, "div", "ui buttons");
20
-		if ($asIcons === true)
20
+		if ($asIcons===true)
21 21
 			$this->asIcons();
22 22
 		$this->addElements($elements, $asIcons);
23 23
 	}
24
-	protected function createItem($value){
24
+	protected function createItem($value) {
25 25
 		return new HtmlButton("", $value);
26 26
 	}
27 27
 
28
-	public function addDropdown($items,$asCombo=false){
29
-		$dd= new HtmlDropdown("dd-".$this->identifier,null,$items);
28
+	public function addDropdown($items, $asCombo=false) {
29
+		$dd=new HtmlDropdown("dd-".$this->identifier, null, $items);
30 30
 		$dd->asButton();
31
-		if($asCombo){
31
+		if ($asCombo) {
32 32
 			$dd->setAction("combo");
33 33
 			$dd->addToProperty("class", "combo");
34 34
 		}
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 
40 40
 	public function addElement($element, $asIcon=false) {
41 41
 		$item=$this->addItem($element);
42
-		if($asIcon)
42
+		if ($asIcon)
43 43
 			$item->asIcon($element);
44 44
 		return $item;
45 45
 	}
46 46
 
47 47
 	public function addElements($elements, $asIcons=false) {
48
-		foreach ( $elements as $element ) {
48
+		foreach ($elements as $element) {
49 49
 			$this->addElement($element, $asIcons);
50 50
 		}
51 51
 		return $this;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	public function insertOr($aferIndex=0, $or="or") {
55 55
 		$orElement=new HtmlSemDoubleElement("", "div", "or");
56 56
 		$orElement->setProperty("data-text", $or);
57
-		array_splice($this->content, $aferIndex + 1, 0, array ($orElement ));
57
+		array_splice($this->content, $aferIndex+1, 0, array($orElement));
58 58
 		return $this;
59 59
 	}
60 60
 
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 	}
68 68
 
69 69
 	public function asIcons() {
70
-		foreach ( $this->content as $item ) {
71
-			if($item instanceof HtmlButton)
70
+		foreach ($this->content as $item) {
71
+			if ($item instanceof HtmlButton)
72 72
 			$item->asIcon($item->getContent());
73 73
 		}
74 74
 		return $this->addToProperty("class", "icons");
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @see \Ajax\bootstrap\html\base\BaseHtml::on()
102 102
 	 */
103 103
 	public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
104
-		foreach ( $this->content as $element ) {
104
+		foreach ($this->content as $element) {
105 105
 			$element->on($event, $jsCode, $stopPropagation, $preventDefault);
106 106
 		}
107 107
 		return $this;
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
 
114 114
 	public function addClasses($classes=array()) {
115 115
 		$i=0;
116
-		if(!\is_array($classes)){
117
-			$classes=array_fill (0,$this->count(),$classes);
116
+		if (!\is_array($classes)) {
117
+			$classes=array_fill(0, $this->count(), $classes);
118 118
 		}
119
-		foreach ( $this->content as $button ) {
119
+		foreach ($this->content as $button) {
120 120
 			$button->addToProperty("class", $classes[$i++]);
121 121
 		}
122 122
 		return $this;
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
 		$this->addElement($function($object));
131 131
 	}
132 132
 
133
-	public function run(JsUtils $js){
134
-		$result= parent::run($js);
133
+	public function run(JsUtils $js) {
134
+		$result=parent::run($js);
135 135
 		return $result->setItemSelector(".ui.button");
136 136
 	}
137 137
 
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/InstanceViewer.php 3 patches
Braces   +42 added lines, -36 removed lines patch added patch discarded remove patch
@@ -23,8 +23,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 	}
@@ -99,16 +102,16 @@  discard block
 block discarded – undo
99 102
 		if($property instanceof \ReflectionProperty){
100 103
 			$value=$this->_getPropertyValue($property, $index);
101 104
 			$propertyName=$property->getName();
102
-		}elseif(\is_callable($property))
103
-			$value=$property($this->instance);
104
-		elseif(\is_array($property)){
105
+		} elseif(\is_callable($property)) {
106
+					$value=$property($this->instance);
107
+		} elseif(\is_array($property)){
105 108
 			$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
106 109
 			$value=\implode("", $values);
107
-		}elseif(\is_string($property)){
110
+		} elseif(\is_string($property)){
108 111
 			$value=$property;
109 112
 			if(isset($this->instance->{$property})){
110 113
 				$value=$this->instance->{$property};
111
-			}elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){
114
+			} elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){
112 115
 				$value=JReflection::callMethod($this->instance, $getter, []);
113 116
 			}
114 117
 		}
@@ -118,7 +121,7 @@  discard block
 block discarded – undo
118 121
 	protected function _postGetValue($index,$propertyName,$value){
119 122
 		if(isset($this->values[$index])){
120 123
 			$value= $this->values[$index]($value,$this->instance,$index);
121
-		}else{
124
+		} else{
122 125
 			$value=$this->_getDefaultValue($propertyName,$value, $index);
123 126
 		}
124 127
 		if(isset($this->afterCompile[$index])){
@@ -139,10 +142,10 @@  discard block
 block discarded – undo
139 142
 		if(isset($vb[$index])){
140 143
 			if(\is_array($vb[$index])){
141 144
 				$this->visibleProperties[$index][]=$field;
142
-			}else{
145
+			} else{
143 146
 				$this->visibleProperties[$index]=[$vb[$index],$field];
144 147
 			}
145
-		}else{
148
+		} else{
146 149
 			return $this->insertField($index, $field);
147 150
 		}
148 151
 		return $this;
@@ -169,9 +172,9 @@  discard block
 block discarded – undo
169 172
 		$property=$this->getProperty($index);
170 173
 		if($property instanceof \ReflectionProperty){
171 174
 			$result=$property->getName();
172
-		}elseif(\is_callable($property)){
175
+		} elseif(\is_callable($property)){
173 176
 			$result=$this->visibleProperties[$index];
174
-		}else{
177
+		} else{
175 178
 			$result=$property;
176 179
 		}
177 180
 		return $result;
@@ -191,7 +194,7 @@  discard block
 block discarded – undo
191 194
 		$this->reflect=new \ReflectionClass($instance);
192 195
 		if(\sizeof($this->visibleProperties)===0){
193 196
 			$this->properties=$this->getDefaultProperties();
194
-		}else{
197
+		} else{
195 198
 			foreach ($this->visibleProperties as $property){
196 199
 				$this->setInstanceProperty($property);
197 200
 			}
@@ -202,22 +205,23 @@  discard block
 block discarded – undo
202 205
 	private function setInstanceProperty($property){
203 206
 		if(\is_callable($property)){
204 207
 			$this->properties[]=$property;
205
-		}elseif(\is_string($property)){
208
+		} elseif(\is_string($property)){
206 209
 			try{
207 210
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
208 211
 				$rProperty=$this->reflect->getProperty($property);
209 212
 				$this->properties[]=$rProperty;
210
-			}catch(\Exception $e){
213
+			} catch(\Exception $e){
211 214
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
212 215
 				$this->properties[]=$property;
213 216
 			}
214
-		}elseif(\is_int($property)){
217
+		} elseif(\is_int($property)){
215 218
 			$props=$this->getDefaultProperties();
216
-			if(isset($props[$property]))
217
-				$this->properties[]=$props[$property];
218
-				else
219
-					$this->properties[]=$property;
220
-		}else{
219
+			if(isset($props[$property])) {
220
+							$this->properties[]=$props[$property];
221
+			} else {
222
+									$this->properties[]=$property;
223
+				}
224
+		} else{
221 225
 			$this->properties[]=$property;
222 226
 		}
223 227
 	}
@@ -261,12 +265,13 @@  discard block
 block discarded – undo
261 265
 		if(isset($this->captions[$index])){
262 266
 			return $this->captions[$index];
263 267
 		}
264
-		if($this->properties[$index] instanceof \ReflectionProperty)
265
-			return $this->properties[$index]->getName();
266
-		elseif(\is_callable($this->properties[$index]))
267
-			return "";
268
-		else
269
-			return $this->properties[$index];
268
+		if($this->properties[$index] instanceof \ReflectionProperty) {
269
+					return $this->properties[$index]->getName();
270
+		} elseif(\is_callable($this->properties[$index])) {
271
+					return "";
272
+		} else {
273
+					return $this->properties[$index];
274
+		}
270 275
 	}
271 276
 
272 277
 	public function getCaptions(){
@@ -277,7 +282,7 @@  discard block
 block discarded – undo
277 282
 			for($i=$captionsSize;$i<$count;$i++){
278 283
 				$captions[]="";
279 284
 			}
280
-		}else{
285
+		} else{
281 286
 			$captions=[];
282 287
 			$index=0;
283 288
 			while($index<$count){
@@ -292,8 +297,9 @@  discard block
 block discarded – undo
292 297
 	}
293 298
 
294 299
 	public function setCaption($index,$caption){
295
-		if(isset($this->captions)===false)
296
-			$this->captions=[];
300
+		if(isset($this->captions)===false) {
301
+					$this->captions=[];
302
+		}
297 303
 		$this->captions[$index]=$caption;
298 304
 		return $this;
299 305
 	}
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -19,220 +19,220 @@  discard block
 block discarded – undo
19 19
 
20 20
 	public static $index=0;
21 21
 
22
-	public function __construct($identifier,$instance=NULL,$captions=NULL){
22
+	public function __construct($identifier, $instance=NULL, $captions=NULL) {
23 23
 		$this->widgetIdentifier=$identifier;
24 24
 		$this->values=[];
25 25
 		$this->afterCompile=[];
26
-		if(isset($instance))
26
+		if (isset($instance))
27 27
 			$this->setInstance($instance);
28 28
 		$this->setCaptions($captions);
29 29
 		$this->captionCallback=NULL;
30
-		$this->defaultValueFunction=function($name,$value){return $value;};
30
+		$this->defaultValueFunction=function($name, $value) {return $value; };
31 31
 	}
32 32
 
33
-	public function moveFieldTo($from,$to){
34
-		if(JArray::moveElementTo($this->visibleProperties, $from, $to)){
33
+	public function moveFieldTo($from, $to) {
34
+		if (JArray::moveElementTo($this->visibleProperties, $from, $to)) {
35 35
 			return JArray::moveElementTo($this->values, $from, $to);
36 36
 		}
37 37
 		return false;
38 38
 	}
39 39
 
40
-	public function swapFields($index1,$index2){
41
-		if(JArray::swapElements($this->visibleProperties, $index1, $index2)){
40
+	public function swapFields($index1, $index2) {
41
+		if (JArray::swapElements($this->visibleProperties, $index1, $index2)) {
42 42
 			return JArray::swapElements($this->values, $index1, $index2);
43 43
 		}
44 44
 		return false;
45 45
 	}
46 46
 
47
-	public function removeField($index){
48
-		\array_splice($this->visibleProperties,$index,1);
49
-		\array_splice($this->values,$index,1);
50
-		\array_splice($this->captions,$index,1);
47
+	public function removeField($index) {
48
+		\array_splice($this->visibleProperties, $index, 1);
49
+		\array_splice($this->values, $index, 1);
50
+		\array_splice($this->captions, $index, 1);
51 51
 		return $this;
52 52
 	}
53 53
 
54
-	public function getValues(){
54
+	public function getValues() {
55 55
 		$values=[];
56 56
 		$index=0;
57 57
 		$count=$this->count();
58
-		while($index<$count){
58
+		while ($index<$count) {
59 59
 			$values[]=$this->getValue($index++);
60 60
 		}
61 61
 		return $values;
62 62
 	}
63 63
 
64
-	public function getIdentifier($index=NULL){
65
-		if(!isset($index))
64
+	public function getIdentifier($index=NULL) {
65
+		if (!isset($index))
66 66
 			$index=self::$index;
67 67
 		$value=$index;
68
-		if(isset($this->values["identifier"])){
69
-			if(\is_string($this->values["identifier"]))
68
+		if (isset($this->values["identifier"])) {
69
+			if (\is_string($this->values["identifier"]))
70 70
 				$value=JReflection::callMethod($this->instance, $this->values["identifier"], []);
71 71
 			else
72
-				$value=$this->values["identifier"]($index,$this->instance);
72
+				$value=$this->values["identifier"]($index, $this->instance);
73 73
 		}
74 74
 		return $value;
75 75
 	}
76 76
 
77
-	public function getValue($index){
77
+	public function getValue($index) {
78 78
 		$property=$this->properties[$index];
79 79
 		return $this->_getValue($property, $index);
80 80
 	}
81 81
 
82
-	protected function _beforeAddProperty($index,&$field){
82
+	protected function _beforeAddProperty($index, &$field) {
83 83
 
84 84
 	}
85 85
 
86
-	protected function _getDefaultValue($name,$value,$index){
86
+	protected function _getDefaultValue($name, $value, $index) {
87 87
 		$func=$this->defaultValueFunction;
88
-		return $func($name,$value,$index,$this->instance);
88
+		return $func($name, $value, $index, $this->instance);
89 89
 	}
90 90
 
91
-	protected function _getPropertyValue(\ReflectionProperty $property,$index){
91
+	protected function _getPropertyValue(\ReflectionProperty $property, $index) {
92 92
 		$property->setAccessible(true);
93 93
 		return $property->getValue($this->instance);
94 94
 	}
95 95
 
96
-	protected function _getValue($property,$index){
96
+	protected function _getValue($property, $index) {
97 97
 		$value=null;
98 98
 		$propertyName=$property;
99
-		if($property instanceof \ReflectionProperty){
99
+		if ($property instanceof \ReflectionProperty) {
100 100
 			$value=$this->_getPropertyValue($property, $index);
101 101
 			$propertyName=$property->getName();
102
-		}elseif(\is_callable($property))
102
+		}elseif (\is_callable($property))
103 103
 			$value=$property($this->instance);
104
-		elseif(\is_array($property)){
105
-			$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property);
104
+		elseif (\is_array($property)) {
105
+			$values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property);
106 106
 			$value=\implode("", $values);
107
-		}elseif(\is_string($property)){
107
+		}elseif (\is_string($property)) {
108 108
 			$value=$property;
109
-			if(isset($this->instance->{$property})){
109
+			if (isset($this->instance->{$property})) {
110 110
 				$value=$this->instance->{$property};
111
-			}elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){
111
+			}elseif (\method_exists($this->instance, $getter=JReflection::getterName($property))) {
112 112
 				$value=JReflection::callMethod($this->instance, $getter, []);
113 113
 			}
114 114
 		}
115 115
 		return $this->_postGetValue($index, $propertyName, $value);
116 116
 	}
117 117
 
118
-	protected function _postGetValue($index,$propertyName,$value){
119
-		if(isset($this->values[$index])){
120
-			$value= $this->values[$index]($value,$this->instance,$index);
121
-		}else{
122
-			$value=$this->_getDefaultValue($propertyName,$value, $index);
118
+	protected function _postGetValue($index, $propertyName, $value) {
119
+		if (isset($this->values[$index])) {
120
+			$value=$this->values[$index]($value, $this->instance, $index);
121
+		} else {
122
+			$value=$this->_getDefaultValue($propertyName, $value, $index);
123 123
 		}
124
-		if(isset($this->afterCompile[$index])){
125
-			if(\is_callable($this->afterCompile[$index])){
126
-				$this->afterCompile[$index]($value,$this->instance,$index);
124
+		if (isset($this->afterCompile[$index])) {
125
+			if (\is_callable($this->afterCompile[$index])) {
126
+				$this->afterCompile[$index]($value, $this->instance, $index);
127 127
 			}
128 128
 		}
129 129
 		return $value;
130 130
 	}
131 131
 
132
-	public function insertField($index,$field){
133
-		array_splice( $this->visibleProperties, $index, 0, $field );
132
+	public function insertField($index, $field) {
133
+		array_splice($this->visibleProperties, $index, 0, $field);
134 134
 		return $this;
135 135
 	}
136 136
 
137
-	public function insertInField($index,$field){
137
+	public function insertInField($index, $field) {
138 138
 		$vb=$this->visibleProperties;
139
-		if(isset($vb[$index])){
140
-			if(\is_array($vb[$index])){
139
+		if (isset($vb[$index])) {
140
+			if (\is_array($vb[$index])) {
141 141
 				$this->visibleProperties[$index][]=$field;
142
-			}else{
143
-				$this->visibleProperties[$index]=[$vb[$index],$field];
142
+			} else {
143
+				$this->visibleProperties[$index]=[$vb[$index], $field];
144 144
 			}
145
-		}else{
145
+		} else {
146 146
 			return $this->insertField($index, $field);
147 147
 		}
148 148
 		return $this;
149 149
 	}
150 150
 
151
-	public function addField($field){
151
+	public function addField($field) {
152 152
 		$this->visibleProperties[]=$field;
153 153
 		return $this;
154 154
 	}
155 155
 
156
-	public function addFields($fields){
157
-		$this->visibleProperties=\array_merge($this->visibleProperties,$fields);
156
+	public function addFields($fields) {
157
+		$this->visibleProperties=\array_merge($this->visibleProperties, $fields);
158 158
 		return $this;
159 159
 	}
160 160
 
161
-	public function count(){
161
+	public function count() {
162 162
 		return \sizeof($this->properties);
163 163
 	}
164 164
 
165
-	public function visiblePropertiesCount(){
165
+	public function visiblePropertiesCount() {
166 166
 		return \sizeof($this->visibleProperties);
167 167
 	}
168 168
 
169
-	public function getProperty($index){
169
+	public function getProperty($index) {
170 170
 		return $this->properties[$index];
171 171
 	}
172 172
 
173
-	public function getFieldName($index){
173
+	public function getFieldName($index) {
174 174
 		$property=$this->getProperty($index);
175
-		if($property instanceof \ReflectionProperty){
175
+		if ($property instanceof \ReflectionProperty) {
176 176
 			$result=$property->getName();
177
-		}elseif(\is_callable($property)){
177
+		}elseif (\is_callable($property)) {
178 178
 			$result=$this->visibleProperties[$index];
179
-		}else{
179
+		} else {
180 180
 			$result=$property;
181 181
 		}
182 182
 		return $result;
183 183
 	}
184 184
 
185 185
 
186
-	protected function showableProperty(\ReflectionProperty $rProperty){
187
-		return JString::startswith($rProperty->getName(),"_")===false;
186
+	protected function showableProperty(\ReflectionProperty $rProperty) {
187
+		return JString::startswith($rProperty->getName(), "_")===false;
188 188
 	}
189 189
 
190 190
 	public function setInstance($instance) {
191
-		if(\is_string($instance)){
191
+		if (\is_string($instance)) {
192 192
 			$instance=new $instance();
193 193
 		}
194 194
 		$this->instance=$instance;
195 195
 		$this->properties=[];
196 196
 		$this->reflect=new \ReflectionClass($instance);
197
-		if(\sizeof($this->visibleProperties)===0){
197
+		if (\sizeof($this->visibleProperties)===0) {
198 198
 			$this->properties=$this->getDefaultProperties();
199
-		}else{
200
-			foreach ($this->visibleProperties as $property){
199
+		} else {
200
+			foreach ($this->visibleProperties as $property) {
201 201
 				$this->setInstanceProperty($property);
202 202
 			}
203 203
 		}
204 204
 		return $this;
205 205
 	}
206 206
 
207
-	private function setInstanceProperty($property){
208
-		if(\is_callable($property)){
207
+	private function setInstanceProperty($property) {
208
+		if (\is_callable($property)) {
209 209
 			$this->properties[]=$property;
210
-		}elseif(\is_string($property)){
211
-			try{
210
+		}elseif (\is_string($property)) {
211
+			try {
212 212
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
213 213
 				$rProperty=$this->reflect->getProperty($property);
214 214
 				$this->properties[]=$rProperty;
215
-			}catch(\Exception $e){
215
+			}catch (\Exception $e) {
216 216
 				$this->_beforeAddProperty(\sizeof($this->properties), $property);
217 217
 				$this->properties[]=$property;
218 218
 			}
219
-		}elseif(\is_int($property)){
219
+		}elseif (\is_int($property)) {
220 220
 			$props=$this->getDefaultProperties();
221
-			if(isset($props[$property]))
221
+			if (isset($props[$property]))
222 222
 				$this->properties[]=$props[$property];
223 223
 				else
224 224
 					$this->properties[]=$property;
225
-		}else{
225
+		} else {
226 226
 			$this->properties[]=$property;
227 227
 		}
228 228
 	}
229 229
 
230
-	protected function getDefaultProperties(){
230
+	protected function getDefaultProperties() {
231 231
 		$result=[];
232 232
 		$properties=$this->reflect->getProperties();
233
-		foreach ($properties as $property){
233
+		foreach ($properties as $property) {
234 234
 			$showable=$this->showableProperty($property);
235
-			if($showable!==false){
235
+			if ($showable!==false) {
236 236
 				$result[]=$property;
237 237
 			}
238 238
 		}
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 		return $this;
245 245
 	}
246 246
 
247
-	public function setValueFunction($index,$callback){
247
+	public function setValueFunction($index, $callback) {
248 248
 		$this->values[$index]=$callback;
249 249
 		return $this;
250 250
 	}
251 251
 
252
-	public function setIdentifierFunction($callback){
252
+	public function setIdentifierFunction($callback) {
253 253
 		$this->values["identifier"]=$callback;
254 254
 		return $this;
255 255
 	}
@@ -262,42 +262,42 @@  discard block
 block discarded – undo
262 262
 		return $this->properties;
263 263
 	}
264 264
 
265
-	public function getCaption($index){
266
-		if(isset($this->captions[$index])){
265
+	public function getCaption($index) {
266
+		if (isset($this->captions[$index])) {
267 267
 			return $this->captions[$index];
268 268
 		}
269
-		if($this->properties[$index] instanceof \ReflectionProperty)
269
+		if ($this->properties[$index] instanceof \ReflectionProperty)
270 270
 			return $this->properties[$index]->getName();
271
-		elseif(\is_callable($this->properties[$index]))
271
+		elseif (\is_callable($this->properties[$index]))
272 272
 			return "";
273 273
 		else
274 274
 			return $this->properties[$index];
275 275
 	}
276 276
 
277
-	public function getCaptions(){
277
+	public function getCaptions() {
278 278
 		$count=$this->count();
279
-		if(isset($this->captions)){
280
-			$captions= \array_values($this->captions);
279
+		if (isset($this->captions)) {
280
+			$captions=\array_values($this->captions);
281 281
 			$captionsSize=\sizeof($captions);
282
-			for($i=$captionsSize;$i<$count;$i++){
282
+			for ($i=$captionsSize; $i<$count; $i++) {
283 283
 				$captions[]="";
284 284
 			}
285
-		}else{
285
+		} else {
286 286
 			$captions=[];
287 287
 			$index=0;
288
-			while($index<$count){
288
+			while ($index<$count) {
289 289
 				$captions[]=$this->getCaption($index++);
290 290
 			}
291 291
 		}
292
-		if(isset($this->captionCallback) && \is_callable($this->captionCallback)){
292
+		if (isset($this->captionCallback) && \is_callable($this->captionCallback)) {
293 293
 			$callback=$this->captionCallback;
294
-			$callback($captions,$this->instance);
294
+			$callback($captions, $this->instance);
295 295
 		}
296 296
 		return $captions;
297 297
 	}
298 298
 
299
-	public function setCaption($index,$caption){
300
-		if(isset($this->captions)===false)
299
+	public function setCaption($index, $caption) {
300
+		if (isset($this->captions)===false)
301 301
 			$this->captions=[];
302 302
 		$this->captions[$index]=$caption;
303 303
 		return $this;
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 * @param callable $callback function called after the field compilation
316 316
 	 * @return \Ajax\semantic\widgets\datatable\InstanceViewer
317 317
 	 */
318
-	public function afterCompile($index,$callback){
318
+	public function afterCompile($index, $callback) {
319 319
 		$this->afterCompile[$index]=$callback;
320 320
 		return $this;
321 321
 	}
Please login to merge, or discard this patch.
Doc Comments   +7 added lines, -1 removed lines patch added patch discarded remove patch
@@ -244,6 +244,9 @@  discard block
 block discarded – undo
244 244
 		return $this;
245 245
 	}
246 246
 
247
+	/**
248
+	 * @param callable $callback
249
+	 */
247 250
 	public function setValueFunction($index,$callback){
248 251
 		$this->values[$index]=$callback;
249 252
 		return $this;
@@ -254,6 +257,9 @@  discard block
 block discarded – undo
254 257
 		return $this;
255 258
 	}
256 259
 
260
+	/**
261
+	 * @param integer $index
262
+	 */
257 263
 	public static function setIndex($index) {
258 264
 		self::$index=$index;
259 265
 	}
@@ -313,7 +319,7 @@  discard block
 block discarded – undo
313 319
 	 * The $callback function can take the following arguments : $field=>the compiled field, $instance : the active instance of the object, $index: the field position
314 320
 	 * @param int $index postion of the compiled field
315 321
 	 * @param callable $callback function called after the field compilation
316
-	 * @return \Ajax\semantic\widgets\datatable\InstanceViewer
322
+	 * @return InstanceViewer
317 323
 	 */
318 324
 	public function afterCompile($index,$callback){
319 325
 		$this->afterCompile[$index]=$callback;
Please login to merge, or discard this patch.
Ajax/service/AjaxCall.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,27 +25,27 @@
 block discarded – undo
25 25
 		$this->parameters["immediatly"]=false;
26 26
 		extract($this->parameters);
27 27
 		$result=$this->_eventPreparing($preventDefault, $stopPropagation);
28
-		switch($this->method) {
28
+		switch ($this->method) {
29 29
 			case "get":
30 30
 				$result.=$js->getDeferred($url, $responseElement, $this->parameters);
31 31
 				break;
32 32
 			case "post":
33
-				$result.=$js->postDeferred($url, $params,$responseElement, $this->parameters);
33
+				$result.=$js->postDeferred($url, $params, $responseElement, $this->parameters);
34 34
 				break;
35 35
 			case "postForm":
36 36
 				$result.=$js->postFormDeferred($url, $form, $responseElement, $this->parameters);
37 37
 				break;
38 38
 			case "json":
39
-				$result.=$js->jsonDeferred($url,$method,$params,$jsCallback);
39
+				$result.=$js->jsonDeferred($url, $method, $params, $jsCallback);
40 40
 				break;
41 41
 			case "jsonArray":
42
-				$result.=$js->jsonArrayDeferred($modelSelector, $url,$method,$params,$jsCallback,$rowClass);
42
+				$result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $params, $jsCallback, $rowClass);
43 43
 				break;
44 44
 		}
45 45
 		return $result;
46 46
 	}
47 47
 
48
-	protected function _eventPreparing($preventDefault,$stopPropagation){
48
+	protected function _eventPreparing($preventDefault, $stopPropagation) {
49 49
 		$result="";
50 50
 		if ($preventDefault===true) {
51 51
 			$result.=Javascript::$preventDefault;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function compile(JsUtils $js=null) {
17
-		if ($js===null)
18
-			return;
17
+		if ($js===null) {
18
+					return;
19
+		}
19 20
 		$params="{}";
20 21
 		$jsCallback=NULL;
21 22
 		$stopPropagation=true;
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php 2 patches
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@  discard block
 block discarded – undo
14 14
  * @property boolean $_visibleHover
15 15
  * @property InstanceViewer $_instanceViewer
16 16
  */
17
-trait DataTableFieldAsTrait{
17
+trait DataTableFieldAsTrait {
18 18
 	abstract public function addField($field);
19
-	abstract public function insertField($index,$field);
20
-	abstract public function insertInField($index,$field);
21
-	abstract public function fieldAs($index,$type,$attributes=NULL);
19
+	abstract public function insertField($index, $field);
20
+	abstract public function insertInField($index, $field);
21
+	abstract public function fieldAs($index, $type, $attributes=NULL);
22 22
 	/**
23 23
 	 * @param string $caption
24 24
 	 * @param callable $callback
25 25
 	 * @param boolean $visibleHover
26 26
 	 * @return callable
27 27
 	 */
28
-	private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){
29
-		return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback);
28
+	private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) {
29
+		return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback);
30 30
 	}
31 31
 
32 32
 	/**
@@ -35,20 +35,20 @@  discard block
 block discarded – undo
35 35
 	 * @param callable $callback
36 36
 	 * @return callable
37 37
 	 */
38
-	private function getCallable($thisCallback,$parameters,$callback=null){
39
-		$result=function($instance) use($thisCallback,$parameters,$callback){
40
-			$object=call_user_func_array(array($this,$thisCallback), $parameters);
41
-			if(isset($callback)){
42
-				if(\is_callable($callback)){
43
-					$callback($object,$instance,$this->_instanceViewer->count()+1);
38
+	private function getCallable($thisCallback, $parameters, $callback=null) {
39
+		$result=function($instance) use($thisCallback, $parameters, $callback){
40
+			$object=call_user_func_array(array($this, $thisCallback), $parameters);
41
+			if (isset($callback)) {
42
+				if (\is_callable($callback)) {
43
+					$callback($object, $instance, $this->_instanceViewer->count()+1);
44 44
 				}
45 45
 			}
46
-			if($object instanceof HtmlSemDoubleElement){
46
+			if ($object instanceof HtmlSemDoubleElement) {
47 47
 				$id=$this->_instanceViewer->getIdentifier();
48
-				$object->setProperty("data-ajax",$id);
49
-				if($object->propertyContains("class","visibleover")){
48
+				$object->setProperty("data-ajax", $id);
49
+				if ($object->propertyContains("class", "visibleover")) {
50 50
 					$this->_visibleHover=true;
51
-					$object->setProperty("style","visibility:hidden;");
51
+					$object->setProperty("style", "visibility:hidden;");
52 52
 				}
53 53
 			}
54 54
 			return $object;
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 	 * @param string $caption
61 61
 	 * @return HtmlButton
62 62
 	 */
63
-	private function getFieldButton($caption,$visibleHover=true){
64
-		$bt= new HtmlButton($this->cleanIdentifier($caption),$caption);
65
-		if($visibleHover)
63
+	private function getFieldButton($caption, $visibleHover=true) {
64
+		$bt=new HtmlButton($this->cleanIdentifier($caption), $caption);
65
+		if ($visibleHover)
66 66
 			$this->_visibleOver($bt);
67 67
 		return $bt;
68 68
 	}
69 69
 
70
-	private function getFieldButtons($buttons,$visibleHover=true){
71
-		$bts=new HtmlButtonGroups("",$buttons);
72
-		if($visibleHover)
70
+	private function getFieldButtons($buttons, $visibleHover=true) {
71
+		$bts=new HtmlButtonGroups("", $buttons);
72
+		if ($visibleHover)
73 73
 			$this->_visibleOver($bts);
74 74
 		return $bts;
75 75
 	}
@@ -83,19 +83,19 @@  discard block
 block discarded – undo
83 83
 	 * @param array $attributes associative array (<b>ajax</b> key is for ajax post)
84 84
 	 * @return DataTable
85 85
 	 */
86
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
87
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){
88
-			$button=new HtmlButton($id,$value,$cssStyle);
89
-			$button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]);
90
-			if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
86
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
87
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $index, $attributes){
88
+			$button=new HtmlButton($id, $value, $cssStyle);
89
+			$button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]);
90
+			if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
91 91
 				$this->_visibleOver($button);
92 92
 				return $button;
93
-		}, $index,$attributes);
93
+		}, $index, $attributes);
94 94
 	}
95 95
 
96
-	protected function _visibleOver(BaseHtml $element){
96
+	protected function _visibleOver(BaseHtml $element) {
97 97
 		$this->_visibleHover=true;
98
-		return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;");
98
+		return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;");
99 99
 	}
100 100
 
101 101
 	/**
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 * @param boolean $visibleHover
106 106
 	 * @return DataTable
107 107
 	 */
108
-	public function addFieldButton($caption,$visibleHover=true,$callback=null){
109
-		$this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback));
108
+	public function addFieldButton($caption, $visibleHover=true, $callback=null) {
109
+		$this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback));
110 110
 		return $this;
111 111
 	}
112 112
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	 * @param boolean $visibleHover
118 118
 	 * @return DataTable
119 119
 	 */
120
-	public function addFieldButtons($buttons,$visibleHover=true,$callback=null){
121
-		$this->addField($this->getCallable("getFieldButtons",[$buttons,$visibleHover],$callback));
120
+	public function addFieldButtons($buttons, $visibleHover=true, $callback=null) {
121
+		$this->addField($this->getCallable("getFieldButtons", [$buttons, $visibleHover], $callback));
122 122
 		return $this;
123 123
 	}
124 124
 
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 	 * @param callable $callback
130 130
 	 * @return DataTable
131 131
 	 */
132
-	public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){
133
-		$this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
132
+	public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) {
133
+		$this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback));
134 134
 		return $this;
135 135
 	}
136 136
 
@@ -141,25 +141,25 @@  discard block
 block discarded – undo
141 141
 	 * @param callable $callback
142 142
 	 * @return DataTable
143 143
 	 */
144
-	public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){
145
-		$this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback));
144
+	public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null) {
145
+		$this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback));
146 146
 		return $this;
147 147
 	}
148 148
 
149
-	private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){
150
-		$this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
149
+	private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null) {
150
+		$this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback));
151 151
 		return $this;
152 152
 	}
153 153
 
154
-	private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){
155
-		$this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback));
154
+	private function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null) {
155
+		$this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback));
156 156
 		return $this;
157 157
 	}
158 158
 
159
-	private function getDefaultButton($icon,$class=null,$visibleHover=true){
160
-		$bt=$this->getFieldButton("",$visibleHover);
159
+	private function getDefaultButton($icon, $class=null, $visibleHover=true) {
160
+		$bt=$this->getFieldButton("", $visibleHover);
161 161
 		$bt->asIcon($icon);
162
-		if(isset($class))
162
+		if (isset($class))
163 163
 			$bt->addClass($class);
164 164
 		return $bt;
165 165
 	}
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 	 * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
172 172
 	 * @return DataTable
173 173
 	 */
174
-	public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){
174
+	public function addDeleteButton($visibleHover=true, $deleteBehavior=[], $callback=null) {
175 175
 		$this->_deleteBehavior=$deleteBehavior;
176
-		return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback);
176
+		return $this->addDefaultButton("remove", "_delete red basic", $visibleHover, $callback);
177 177
 	}
178 178
 
179 179
 	/**
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	 * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
184 184
 	 * @return DataTable
185 185
 	 */
186
-	public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){
186
+	public function addEditButton($visibleHover=true, $editBehavior=[], $callback=null) {
187 187
 		$this->_editBehavior=$editBehavior;
188
-		return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback);
188
+		return $this->addDefaultButton("edit", "_edit basic", $visibleHover, $callback);
189 189
 	}
190 190
 
191 191
 	/**
@@ -196,20 +196,20 @@  discard block
 block discarded – undo
196 196
 	 * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
197 197
 	 * @return DataTable
198 198
 	 */
199
-	public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){
200
-		$this->addEditButton($visibleHover,$behavior,$callbackEdit);
199
+	public function addEditDeleteButtons($visibleHover=true, $behavior=[], $callbackEdit=null, $callbackDelete=null) {
200
+		$this->addEditButton($visibleHover, $behavior, $callbackEdit);
201 201
 		$index=$this->_instanceViewer->visiblePropertiesCount()-1;
202
-		$this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete);
202
+		$this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete);
203 203
 		return $this;
204 204
 	}
205 205
 
206
-	public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){
206
+	public function insertDeleteButtonIn($index, $visibleHover=true, $deleteBehavior=[], $callback=null) {
207 207
 		$this->_deleteBehavior=$deleteBehavior;
208
-		return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback);
208
+		return $this->insertDefaultButtonIn($index, "remove", "_delete red basic", $visibleHover, $callback);
209 209
 	}
210 210
 
211
-	public function insertEditButtonIn($index,$visibleHover=true,$editBehavior=[],$callback=null){
211
+	public function insertEditButtonIn($index, $visibleHover=true, $editBehavior=[], $callback=null) {
212 212
 		$this->_editBehavior=$editBehavior;
213
-		return $this->insertDefaultButtonIn($index,"edit","_edit basic",$visibleHover,$callback);
213
+		return $this->insertDefaultButtonIn($index, "edit", "_edit basic", $visibleHover, $callback);
214 214
 	}
215 215
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -62,15 +62,17 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	private function getFieldButton($caption,$visibleHover=true){
64 64
 		$bt= new HtmlButton($this->cleanIdentifier($caption),$caption);
65
-		if($visibleHover)
66
-			$this->_visibleOver($bt);
65
+		if($visibleHover) {
66
+					$this->_visibleOver($bt);
67
+		}
67 68
 		return $bt;
68 69
 	}
69 70
 
70 71
 	private function getFieldButtons($buttons,$visibleHover=true){
71 72
 		$bts=new HtmlButtonGroups("",$buttons);
72
-		if($visibleHover)
73
-			$this->_visibleOver($bts);
73
+		if($visibleHover) {
74
+					$this->_visibleOver($bts);
75
+		}
74 76
 		return $bts;
75 77
 	}
76 78
 
@@ -87,8 +89,9 @@  discard block
 block discarded – undo
87 89
 		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){
88 90
 			$button=new HtmlButton($id,$value,$cssStyle);
89 91
 			$button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]);
90
-			if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"])
91
-				$this->_visibleOver($button);
92
+			if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) {
93
+							$this->_visibleOver($button);
94
+			}
92 95
 				return $button;
93 96
 		}, $index,$attributes);
94 97
 	}
@@ -159,8 +162,9 @@  discard block
 block discarded – undo
159 162
 	private function getDefaultButton($icon,$class=null,$visibleHover=true){
160 163
 		$bt=$this->getFieldButton("",$visibleHover);
161 164
 		$bt->asIcon($icon);
162
-		if(isset($class))
163
-			$bt->addClass($class);
165
+		if(isset($class)) {
166
+					$bt->addClass($class);
167
+		}
164 168
 		return $bt;
165 169
 	}
166 170
 
Please login to merge, or discard this patch.
Ajax/semantic/widgets/datatable/DataTable.php 2 patches
Spacing   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *
25 25
  */
26 26
 class DataTable extends Widget {
27
-	use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait;
27
+	use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait;
28 28
 	protected $_searchField;
29 29
 	protected $_urls;
30 30
 	protected $_pagination;
@@ -42,35 +42,35 @@  discard block
 block discarded – undo
42 42
 	protected $_colWidths;
43 43
 
44 44
 
45
-	public function __construct($identifier,$model,$modelInstance=NULL) {
46
-		parent::__construct($identifier, $model,$modelInstance);
47
-		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false);
45
+	public function __construct($identifier, $model, $modelInstance=NULL) {
46
+		parent::__construct($identifier, $model, $modelInstance);
47
+		$this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false);
48 48
 		$this->_urls=[];
49
-		$this->_emptyMessage=new HtmlMessage("","nothing to display");
49
+		$this->_emptyMessage=new HtmlMessage("", "nothing to display");
50 50
 		$this->_emptyMessage->setIcon("info circle");
51 51
 	}
52 52
 
53
-	public function run(JsUtils $js){
54
-		if($this->_hasCheckboxes && isset($js)){
53
+	public function run(JsUtils $js) {
54
+		if ($this->_hasCheckboxes && isset($js)) {
55 55
 			$this->_runCheckboxes($js);
56 56
 		}
57
-		if($this->_visibleHover){
58
-			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
59
-			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
57
+		if ($this->_visibleHover) {
58
+			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]);
59
+			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]);
60 60
 		}
61
-		if(\is_array($this->_deleteBehavior))
62
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
63
-		if(\is_array($this->_editBehavior))
64
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
61
+		if (\is_array($this->_deleteBehavior))
62
+			$this->_generateBehavior("delete", $this->_deleteBehavior, $js);
63
+		if (\is_array($this->_editBehavior))
64
+			$this->_generateBehavior("edit", $this->_editBehavior, $js);
65 65
 		return parent::run($js);
66 66
 	}
67 67
 
68 68
 
69 69
 
70
-	protected function _generateBehavior($op,$params,JsUtils $js){
71
-		if(isset($this->_urls[$op])){
72
-			$params=\array_merge($params,["attr"=>"data-ajax"]);
73
-			$js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector($op),$params);
70
+	protected function _generateBehavior($op, $params, JsUtils $js) {
71
+		if (isset($this->_urls[$op])) {
72
+			$params=\array_merge($params, ["attr"=>"data-ajax"]);
73
+			$js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params);
74 74
 		}
75 75
 	}
76 76
 
@@ -83,158 +83,158 @@  discard block
 block discarded – undo
83 83
 	}
84 84
 
85 85
 
86
-	public function compile(JsUtils $js=NULL,&$view=NULL){
87
-		if(!$this->_generated){
86
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
87
+		if (!$this->_generated) {
88 88
 			$this->_instanceViewer->setInstance($this->_model);
89 89
 			$captions=$this->_instanceViewer->getCaptions();
90 90
 			$table=$this->content["table"];
91
-			if($this->_hasCheckboxes){
91
+			if ($this->_hasCheckboxes) {
92 92
 				$this->_generateMainCheckbox($captions);
93 93
 			}
94 94
 			$table->setRowCount(0, \sizeof($captions));
95
-			$this->_generateHeader($table,$captions);
95
+			$this->_generateHeader($table, $captions);
96 96
 
97
-			if(isset($this->_compileParts))
97
+			if (isset($this->_compileParts))
98 98
 				$table->setCompileParts($this->_compileParts);
99 99
 
100 100
 			$this->_generateContent($table);
101 101
 
102
-			$this->compileExtraElements($table, $captions,$js);
102
+			$this->compileExtraElements($table, $captions, $js);
103 103
 
104
-			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]);
104
+			$this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]);
105 105
 			$this->_compileForm();
106 106
 			$this->_applyStyleAttributes($table);
107 107
 			$this->_generated=true;
108 108
 		}
109
-		return parent::compile($js,$view);
109
+		return parent::compile($js, $view);
110 110
 	}
111 111
 
112
-	protected function compileExtraElements($table,$captions,JsUtils $js=NULL){
113
-		if(isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])){
114
-				$this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]);
112
+	protected function compileExtraElements($table, $captions, JsUtils $js=NULL) {
113
+		if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) {
114
+				$this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]);
115 115
 		}
116
-		if($this->_hasCheckboxes && $table->hasPart("thead")){
116
+		if ($this->_hasCheckboxes && $table->hasPart("thead")) {
117 117
 			$table->getHeader()->getCell(0, 0)->addClass("no-sort");
118 118
 		}
119 119
 
120
-		if(isset($this->_toolbar)){
120
+		if (isset($this->_toolbar)) {
121 121
 			$this->_setToolbarPosition($table, $captions);
122 122
 		}
123
-		if(isset($this->_pagination) && $this->_pagination->getVisible()){
124
-			$this->_generatePagination($table,$js);
123
+		if (isset($this->_pagination) && $this->_pagination->getVisible()) {
124
+			$this->_generatePagination($table, $js);
125 125
 		}
126 126
 	}
127 127
 
128
-	protected function _applyStyleAttributes($table){
129
-		if(isset($this->_hiddenColumns))
128
+	protected function _applyStyleAttributes($table) {
129
+		if (isset($this->_hiddenColumns))
130 130
 			$this->_hideColumns();
131
-			if(isset($this->_colWidths)){
132
-				foreach ($this->_colWidths as $colIndex=>$width){
133
-					$table->setColWidth($colIndex,$width);
131
+			if (isset($this->_colWidths)) {
132
+				foreach ($this->_colWidths as $colIndex=>$width) {
133
+					$table->setColWidth($colIndex, $width);
134 134
 				}
135 135
 			}
136 136
 	}
137 137
 
138
-	protected function _hideColumns(){
139
-		foreach ($this->_hiddenColumns as $colIndex){
138
+	protected function _hideColumns() {
139
+		foreach ($this->_hiddenColumns as $colIndex) {
140 140
 			$this->_self->hideColumn($colIndex);
141 141
 		}
142 142
 		return $this;
143 143
 	}
144 144
 
145
-	protected function _generateHeader(HtmlTable $table,$captions){
145
+	protected function _generateHeader(HtmlTable $table, $captions) {
146 146
 		$table->setHeaderValues($captions);
147
-		if(isset($this->_sortable)){
147
+		if (isset($this->_sortable)) {
148 148
 			$table->setSortable($this->_sortable);
149 149
 		}
150 150
 	}
151 151
 
152 152
 
153 153
 
154
-	protected function _generateContent($table){
154
+	protected function _generateContent($table) {
155 155
 		$objects=$this->_modelInstance;
156
-		if(isset($this->_pagination)){
156
+		if (isset($this->_pagination)) {
157 157
 			$objects=$this->_pagination->getObjects($this->_modelInstance);
158 158
 		}
159 159
 			InstanceViewer::setIndex(0);
160 160
 			$table->fromDatabaseObjects($objects, function($instance) use($table){
161 161
 				return $this->_generateRow($instance, $table);
162 162
 			});
163
-		if($table->getRowCount()==0){
163
+		if ($table->getRowCount()==0) {
164 164
 			$result=$table->addRow();
165 165
 			$result->mergeRow();
166 166
 			$result->setValues([$this->_emptyMessage]);
167 167
 		}
168 168
 	}
169 169
 
170
-	protected function _generateRow($instance,&$table,$checkedClass=null){
170
+	protected function _generateRow($instance, &$table, $checkedClass=null) {
171 171
 		$this->_instanceViewer->setInstance($instance);
172 172
 		InstanceViewer::$index++;
173
-		$values= $this->_instanceViewer->getValues();
173
+		$values=$this->_instanceViewer->getValues();
174 174
 		$id=$this->_instanceViewer->getIdentifier();
175 175
 		$dataAjax=$id;
176 176
 		$id=$this->cleanIdentifier($id);
177
-		if($this->_hasCheckboxes){
178
-			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,"");
177
+		if ($this->_hasCheckboxes) {
178
+			$ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, "");
179 179
 			$ck->setOnChange("event.stopPropagation();");
180 180
 			$field=$ck->getField();
181
-			$field->setProperty("value",$dataAjax);
181
+			$field->setProperty("value", $dataAjax);
182 182
 			$field->setProperty("name", "selection[]");
183
-			if(isset($checkedClass))
183
+			if (isset($checkedClass))
184 184
 				$field->setClass($checkedClass);
185 185
 			\array_unshift($values, $ck);
186 186
 		}
187 187
 		$result=$table->newRow();
188 188
 		$result->setIdentifier($this->identifier."-tr-".$id);
189
-		$result->setProperty("data-ajax",$dataAjax);
189
+		$result->setProperty("data-ajax", $dataAjax);
190 190
 		$result->setValues($values);
191
-		$result->addToProperty("class",$this->_rowClass);
191
+		$result->addToProperty("class", $this->_rowClass);
192 192
 		return $result;
193 193
 	}
194 194
 
195
-	protected function _generatePagination($table,$js=NULL){
196
-		if(isset($this->_toolbar)){
197
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
195
+	protected function _generatePagination($table, $js=NULL) {
196
+		if (isset($this->_toolbar)) {
197
+			if ($this->_toolbarPosition==PositionInTable::FOOTER)
198 198
 				$this->_toolbar->setFloated("left");
199 199
 		}
200 200
 		$footer=$table->getFooter();
201 201
 		$footer->mergeCol();
202
-		$menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers());
202
+		$menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers());
203 203
 		$menu->floatRight();
204 204
 		$menu->setActiveItem($this->_pagination->getPage()-1);
205 205
 		$footer->addValues($menu);
206
-		$this->_associatePaginationBehavior($menu,$js);
206
+		$this->_associatePaginationBehavior($menu, $js);
207 207
 	}
208 208
 
209
-	protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){
210
-		if(isset($this->_urls["refresh"])){
211
-			$menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith","hasLoader"=>false]);
209
+	protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) {
210
+		if (isset($this->_urls["refresh"])) {
211
+			$menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith", "hasLoader"=>false]);
212 212
 		}
213 213
 	}
214 214
 
215
-	protected function _getFieldName($index){
215
+	protected function _getFieldName($index) {
216 216
 		$fieldName=parent::_getFieldName($index);
217
-		if(\is_object($fieldName))
217
+		if (\is_object($fieldName))
218 218
 			$fieldName="field-".$index;
219 219
 		return $fieldName."[]";
220 220
 	}
221 221
 
222
-	protected function _getFieldCaption($index){
222
+	protected function _getFieldCaption($index) {
223 223
 		return null;
224 224
 	}
225 225
 
226
-	protected function _setToolbarPosition($table,$captions=NULL){
227
-		switch ($this->_toolbarPosition){
226
+	protected function _setToolbarPosition($table, $captions=NULL) {
227
+		switch ($this->_toolbarPosition) {
228 228
 			case PositionInTable::BEFORETABLE:
229 229
 			case PositionInTable::AFTERTABLE:
230
-				if(isset($this->_compileParts)===false){
230
+				if (isset($this->_compileParts)===false) {
231 231
 					$this->content[$this->_toolbarPosition]=$this->_toolbar;
232 232
 				}
233 233
 				break;
234 234
 			case PositionInTable::HEADER:
235 235
 			case PositionInTable::FOOTER:
236 236
 			case PositionInTable::BODY:
237
-				$this->addToolbarRow($this->_toolbarPosition,$table, $captions);
237
+				$this->addToolbarRow($this->_toolbarPosition, $table, $captions);
238 238
 				break;
239 239
 		}
240 240
 	}
@@ -246,16 +246,16 @@  discard block
 block discarded – undo
246 246
 	 * @param callable $callback function called after the field compilation
247 247
 	 * @return DataTable
248 248
 	 */
249
-	public function afterCompile($index,$callback){
250
-		$this->_instanceViewer->afterCompile($index,$callback);
249
+	public function afterCompile($index, $callback) {
250
+		$this->_instanceViewer->afterCompile($index, $callback);
251 251
 		return $this;
252 252
 	}
253 253
 
254
-	private function addToolbarRow($part,$table,$captions){
254
+	private function addToolbarRow($part, $table, $captions) {
255 255
 		$hasPart=$table->hasPart($part);
256
-		if($hasPart){
256
+		if ($hasPart) {
257 257
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
258
-		}else{
258
+		} else {
259 259
 			$row=$table->getPart($part)->getRow(0);
260 260
 		}
261 261
 		$row->mergeCol();
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 * @see Widget::getHtmlComponent()
268 268
 	 * @return HtmlTable
269 269
 	 */
270
-	public function getHtmlComponent(){
270
+	public function getHtmlComponent() {
271 271
 		return $this->content["table"];
272 272
 	}
273 273
 
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
 	 * @return DataTable
283 283
 	 */
284 284
 	public function setUrls($urls) {
285
-		if(\is_array($urls)){
286
-			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
287
-			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
288
-			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
289
-		}else{
290
-			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
285
+		if (\is_array($urls)) {
286
+			$this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0);
287
+			$this->_urls["edit"]=JArray::getValue($urls, "edit", 1);
288
+			$this->_urls["delete"]=JArray::getValue($urls, "delete", 2);
289
+		} else {
290
+			$this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls];
291 291
 		}
292 292
 		return $this;
293 293
 	}
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
301 301
 	 * @return DataTable
302 302
 	 */
303
-	public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){
304
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount);
303
+	public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) {
304
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount);
305 305
 		return $this;
306 306
 	}
307 307
 
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
 	 * @param number $pages_visibles The number of visible pages in the Pagination component
313 313
 	 * @return DataTable
314 314
 	 */
315
-	public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
316
-		$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page);
315
+	public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) {
316
+		$this->_pagination=new Pagination($items_per_page, $pages_visibles, $page);
317 317
 		return $this;
318 318
 	}
319 319
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	 * @param array $compileParts
324 324
 	 * @return DataTable
325 325
 	 */
326
-	public function refresh($compileParts=["tbody"]){
326
+	public function refresh($compileParts=["tbody"]) {
327 327
 		$this->_compileParts=$compileParts;
328 328
 		return $this;
329 329
 	}
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
 	 * @param string $position
335 335
 	 * @return \Ajax\common\html\HtmlDoubleElement
336 336
 	 */
337
-	public function addSearchInToolbar($position=Direction::RIGHT){
337
+	public function addSearchInToolbar($position=Direction::RIGHT) {
338 338
 		return $this->addInToolbar($this->getSearchField())->setPosition($position);
339 339
 	}
340 340
 
341
-	public function getSearchField(){
342
-		if(isset($this->_searchField)===false){
343
-			$this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search...");
344
-			$this->_searchField->addIcon("search",Direction::RIGHT);
341
+	public function getSearchField() {
342
+		if (isset($this->_searchField)===false) {
343
+			$this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search...");
344
+			$this->_searchField->addIcon("search", Direction::RIGHT);
345 345
 		}
346 346
 		return $this->_searchField;
347 347
 	}
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	 * Returns a form corresponding to the Datatable
362 362
 	 * @return \Ajax\semantic\html\collections\form\HtmlForm
363 363
 	 */
364
-	public function asForm(){
364
+	public function asForm() {
365 365
 		return $this->getForm();
366 366
 	}
367 367
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
 	protected function getTargetSelector($op) {
371 371
 		$result=$this->_targetSelector;
372
-		if(!isset($result[$op]))
372
+		if (!isset($result[$op]))
373 373
 			$result="#".$this->identifier;
374 374
 		return $result[$op];
375 375
 	}
@@ -380,15 +380,15 @@  discard block
 block discarded – undo
380 380
 	 * @return DataTable
381 381
 	 */
382 382
 	public function setTargetSelector($_targetSelector) {
383
-		if(!\is_array($_targetSelector)){
384
-			$_targetSelector=["edit"=>$_targetSelector,"delete"=>$_targetSelector];
383
+		if (!\is_array($_targetSelector)) {
384
+			$_targetSelector=["edit"=>$_targetSelector, "delete"=>$_targetSelector];
385 385
 		}
386 386
 		$this->_targetSelector=$_targetSelector;
387 387
 		return $this;
388 388
 	}
389 389
 
390 390
 	public function getRefreshSelector() {
391
-		if(isset($this->_refreshSelector))
391
+		if (isset($this->_refreshSelector))
392 392
 			return $this->_refreshSelector;
393 393
 		return "#".$this->identifier." tbody";
394 394
 	}
@@ -406,9 +406,9 @@  discard block
 block discarded – undo
406 406
 	 * {@inheritDoc}
407 407
 	 * @see \Ajax\common\Widget::show()
408 408
 	 */
409
-	public function show($modelInstance){
410
-		if(\is_array($modelInstance)){
411
-			if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
409
+	public function show($modelInstance) {
410
+		if (\is_array($modelInstance)) {
411
+			if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
412 412
 				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
413 413
 		}
414 414
 		$this->_modelInstance=$modelInstance;
@@ -443,29 +443,29 @@  discard block
 block discarded – undo
443 443
 		return $this;
444 444
 	}
445 445
 
446
-	public function setActiveRowSelector($class="active",$event="click",$multiple=false){
447
-		$this->_self->setActiveRowSelector($class,$event,$multiple);
446
+	public function setActiveRowSelector($class="active", $event="click", $multiple=false) {
447
+		$this->_self->setActiveRowSelector($class, $event, $multiple);
448 448
 		return $this;
449 449
 	}
450 450
 
451
-	public function hideColumn($colIndex){
452
-		if(!\is_array($this->_hiddenColumns))
451
+	public function hideColumn($colIndex) {
452
+		if (!\is_array($this->_hiddenColumns))
453 453
 			$this->_hiddenColumns=[];
454 454
 		$this->_hiddenColumns[]=$colIndex;
455 455
 		return $this;
456 456
 	}
457 457
 
458
-	public function setColWidth($colIndex,$width){
458
+	public function setColWidth($colIndex, $width) {
459 459
 		$this->_colWidths[$colIndex]=$width;
460 460
 		return $this;
461 461
 	}
462 462
 	public function setColWidths($_colWidths) {
463
-		$this->_colWidths = $_colWidths;
463
+		$this->_colWidths=$_colWidths;
464 464
 		return $this;
465 465
 	}
466 466
 
467
-	public function setColAlignment($colIndex,$alignment){
468
-		$this->content["table"]->setColAlignment($colIndex,$alignment);
467
+	public function setColAlignment($colIndex, $alignment) {
468
+		$this->content["table"]->setColAlignment($colIndex, $alignment);
469 469
 		return $this;
470 470
 	}
471 471
 }
Please login to merge, or discard this patch.
Braces   +35 added lines, -24 removed lines patch added patch discarded remove patch
@@ -58,10 +58,12 @@  discard block
 block discarded – undo
58 58
 			$js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]);
59 59
 			$js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]);
60 60
 		}
61
-		if(\is_array($this->_deleteBehavior))
62
-			$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
63
-		if(\is_array($this->_editBehavior))
64
-			$this->_generateBehavior("edit",$this->_editBehavior,$js);
61
+		if(\is_array($this->_deleteBehavior)) {
62
+					$this->_generateBehavior("delete",$this->_deleteBehavior, $js);
63
+		}
64
+		if(\is_array($this->_editBehavior)) {
65
+					$this->_generateBehavior("edit",$this->_editBehavior,$js);
66
+		}
65 67
 		return parent::run($js);
66 68
 	}
67 69
 
@@ -94,8 +96,9 @@  discard block
 block discarded – undo
94 96
 			$table->setRowCount(0, \sizeof($captions));
95 97
 			$this->_generateHeader($table,$captions);
96 98
 
97
-			if(isset($this->_compileParts))
98
-				$table->setCompileParts($this->_compileParts);
99
+			if(isset($this->_compileParts)) {
100
+							$table->setCompileParts($this->_compileParts);
101
+			}
99 102
 
100 103
 			$this->_generateContent($table);
101 104
 
@@ -126,8 +129,9 @@  discard block
 block discarded – undo
126 129
 	}
127 130
 
128 131
 	protected function _applyStyleAttributes($table){
129
-		if(isset($this->_hiddenColumns))
130
-			$this->_hideColumns();
132
+		if(isset($this->_hiddenColumns)) {
133
+					$this->_hideColumns();
134
+		}
131 135
 			if(isset($this->_colWidths)){
132 136
 				foreach ($this->_colWidths as $colIndex=>$width){
133 137
 					$table->setColWidth($colIndex,$width);
@@ -180,8 +184,9 @@  discard block
 block discarded – undo
180 184
 			$field=$ck->getField();
181 185
 			$field->setProperty("value",$dataAjax);
182 186
 			$field->setProperty("name", "selection[]");
183
-			if(isset($checkedClass))
184
-				$field->setClass($checkedClass);
187
+			if(isset($checkedClass)) {
188
+							$field->setClass($checkedClass);
189
+			}
185 190
 			\array_unshift($values, $ck);
186 191
 		}
187 192
 		$result=$table->newRow();
@@ -194,8 +199,9 @@  discard block
 block discarded – undo
194 199
 
195 200
 	protected function _generatePagination($table,$js=NULL){
196 201
 		if(isset($this->_toolbar)){
197
-			if($this->_toolbarPosition==PositionInTable::FOOTER)
198
-				$this->_toolbar->setFloated("left");
202
+			if($this->_toolbarPosition==PositionInTable::FOOTER) {
203
+							$this->_toolbar->setFloated("left");
204
+			}
199 205
 		}
200 206
 		$footer=$table->getFooter();
201 207
 		$footer->mergeCol();
@@ -214,8 +220,9 @@  discard block
 block discarded – undo
214 220
 
215 221
 	protected function _getFieldName($index){
216 222
 		$fieldName=parent::_getFieldName($index);
217
-		if(\is_object($fieldName))
218
-			$fieldName="field-".$index;
223
+		if(\is_object($fieldName)) {
224
+					$fieldName="field-".$index;
225
+		}
219 226
 		return $fieldName."[]";
220 227
 	}
221 228
 
@@ -255,7 +262,7 @@  discard block
 block discarded – undo
255 262
 		$hasPart=$table->hasPart($part);
256 263
 		if($hasPart){
257 264
 			$row=$table->getPart($part)->addRow(\sizeof($captions));
258
-		}else{
265
+		} else{
259 266
 			$row=$table->getPart($part)->getRow(0);
260 267
 		}
261 268
 		$row->mergeCol();
@@ -286,7 +293,7 @@  discard block
 block discarded – undo
286 293
 			$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
287 294
 			$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
288 295
 			$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
289
-		}else{
296
+		} else{
290 297
 			$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls];
291 298
 		}
292 299
 		return $this;
@@ -369,8 +376,9 @@  discard block
 block discarded – undo
369 376
 
370 377
 	protected function getTargetSelector($op) {
371 378
 		$result=$this->_targetSelector;
372
-		if(!isset($result[$op]))
373
-			$result="#".$this->identifier;
379
+		if(!isset($result[$op])) {
380
+					$result="#".$this->identifier;
381
+		}
374 382
 		return $result[$op];
375 383
 	}
376 384
 
@@ -388,8 +396,9 @@  discard block
 block discarded – undo
388 396
 	}
389 397
 
390 398
 	public function getRefreshSelector() {
391
-		if(isset($this->_refreshSelector))
392
-			return $this->_refreshSelector;
399
+		if(isset($this->_refreshSelector)) {
400
+					return $this->_refreshSelector;
401
+		}
393 402
 		return "#".$this->identifier." tbody";
394 403
 	}
395 404
 
@@ -408,8 +417,9 @@  discard block
 block discarded – undo
408 417
 	 */
409 418
 	public function show($modelInstance){
410 419
 		if(\is_array($modelInstance)){
411
-			if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0]))
412
-				$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
420
+			if(isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) {
421
+							$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
422
+			}
413 423
 		}
414 424
 		$this->_modelInstance=$modelInstance;
415 425
 	}
@@ -449,8 +459,9 @@  discard block
 block discarded – undo
449 459
 	}
450 460
 
451 461
 	public function hideColumn($colIndex){
452
-		if(!\is_array($this->_hiddenColumns))
453
-			$this->_hiddenColumns=[];
462
+		if(!\is_array($this->_hiddenColumns)) {
463
+					$this->_hiddenColumns=[];
464
+		}
454 465
 		$this->_hiddenColumns[]=$colIndex;
455 466
 		return $this;
456 467
 	}
Please login to merge, or discard this patch.
Ajax/semantic/widgets/base/FieldAsTrait.php 1 patch
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -29,23 +29,23 @@  discard block
 block discarded – undo
29 29
  * @property boolean $_edition
30 30
  * @property mixed _modelInstance
31 31
  */
32
-trait FieldAsTrait{
32
+trait FieldAsTrait {
33 33
 
34
-	abstract protected function _getFieldIdentifier($prefix,$name="");
35
-	abstract public function setValueFunction($index,$callback);
34
+	abstract protected function _getFieldIdentifier($prefix, $name="");
35
+	abstract public function setValueFunction($index, $callback);
36 36
 	abstract protected function _getFieldName($index);
37 37
 	abstract protected function _getFieldCaption($index);
38
-	abstract protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL);
38
+	abstract protected function _buttonAsSubmit(BaseHtml&$button, $event, $url, $responseElement=NULL, $parameters=NULL);
39 39
 
40 40
 	/**
41 41
 	 * @param HtmlFormField $element
42 42
 	 * @param array $attributes
43 43
 	 */
44
-	protected function _applyAttributes(BaseHtml $element,&$attributes,$index){
45
-		if(isset($attributes["jsCallback"])){
44
+	protected function _applyAttributes(BaseHtml $element, &$attributes, $index) {
45
+		if (isset($attributes["jsCallback"])) {
46 46
 			$callback=$attributes["jsCallback"];
47
-			if(\is_callable($callback)){
48
-				$callback($element,$this->_modelInstance,$index);
47
+			if (\is_callable($callback)) {
48
+				$callback($element, $this->_modelInstance, $index);
49 49
 				//unset($attributes["jsCallback"]);
50 50
 			}
51 51
 		}
@@ -55,43 +55,43 @@  discard block
 block discarded – undo
55 55
 		$element->fromArray($attributes);
56 56
 	}
57 57
 
58
-	private function _getLabelField($caption,$icon=NULL){
59
-		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon);
58
+	private function _getLabelField($caption, $icon=NULL) {
59
+		$label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon);
60 60
 		return $label;
61 61
 	}
62 62
 
63 63
 
64
-	protected function _addRules(HtmlFormField $element,&$attributes){
65
-		if(isset($attributes["rules"])){
64
+	protected function _addRules(HtmlFormField $element, &$attributes) {
65
+		if (isset($attributes["rules"])) {
66 66
 			$rules=$attributes["rules"];
67
-			if(\is_array($rules)){
67
+			if (\is_array($rules)) {
68 68
 				$element->addRules($rules);
69 69
 			}
70
-			else{
70
+			else {
71 71
 				$element->addRule($rules);
72 72
 			}
73 73
 			unset($attributes["rules"]);
74 74
 		}
75 75
 	}
76 76
 
77
-	protected function _prepareFormFields(HtmlFormField &$field,$name,&$attributes){
77
+	protected function _prepareFormFields(HtmlFormField&$field, $name, &$attributes) {
78 78
 		$field->setName($name);
79 79
 		$this->_addRules($field, $attributes);
80 80
 		return $field;
81 81
 	}
82 82
 
83
-	protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){
84
-		$this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){
83
+	protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) {
84
+		$this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){
85 85
 			$caption=$this->_getFieldCaption($index);
86 86
 			$name=$this->_getFieldName($index);
87
-			$id=$this->_getFieldIdentifier($prefix,$name);
88
-			if(isset($attributes["name"])){
87
+			$id=$this->_getFieldIdentifier($prefix, $name);
88
+			if (isset($attributes["name"])) {
89 89
 				$name=$attributes["name"];
90 90
 				unset($attributes["name"]);
91 91
 			}
92
-			$element=$elementCallback($id,$name,$value,$caption);
93
-			if(\is_array($attributes)){
94
-				$this->_applyAttributes($element, $attributes,$index);
92
+			$element=$elementCallback($id, $name, $value, $caption);
93
+			if (\is_array($attributes)) {
94
+				$this->_applyAttributes($element, $attributes, $index);
95 95
 			}
96 96
 			$element->setDisabled(!$this->_edition);
97 97
 			return $element;
@@ -100,188 +100,188 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 
103
-	public function fieldAsProgress($index,$label=NULL, $attributes=array()){
104
-		$this->setValueFunction($index,function($value) use($label,$attributes){
105
-			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes);
103
+	public function fieldAsProgress($index, $label=NULL, $attributes=array()) {
104
+		$this->setValueFunction($index, function($value) use($label, $attributes){
105
+			$pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes);
106 106
 			return $pb;
107 107
 		});
108 108
 			return $this;
109 109
 	}
110 110
 
111
-	public function fieldAsRating($index,$max=5, $icon=""){
112
-		$this->setValueFunction($index,function($value) use($max,$icon){
113
-			$rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon);
111
+	public function fieldAsRating($index, $max=5, $icon="") {
112
+		$this->setValueFunction($index, function($value) use($max, $icon){
113
+			$rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon);
114 114
 			return $rating;
115 115
 		});
116 116
 			return $this;
117 117
 	}
118 118
 
119
-	public function fieldAsLabel($index,$icon=NULL,$attributes=NULL){
120
-		return $this->_fieldAs(function($id,$name,$value) use($icon){
121
-			$lbl=new HtmlLabel($id,$value);
122
-			if(isset($icon))
119
+	public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) {
120
+		return $this->_fieldAs(function($id, $name, $value) use($icon){
121
+			$lbl=new HtmlLabel($id, $value);
122
+			if (isset($icon))
123 123
 				$lbl->addIcon($icon);
124 124
 				return $lbl;
125
-		}, $index,$attributes,"label");
125
+		}, $index, $attributes, "label");
126 126
 	}
127 127
 
128
-	public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){
129
-		return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){
130
-			$header=new HtmlHeader($id,$niveau,$value);
131
-			if(isset($icon))
128
+	public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) {
129
+		return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){
130
+			$header=new HtmlHeader($id, $niveau, $value);
131
+			if (isset($icon))
132 132
 				$header->asIcon($icon, $value);
133 133
 			return $header;
134
-		}, $index,$attributes,"header");
134
+		}, $index, $attributes, "header");
135 135
 	}
136 136
 
137 137
 
138
-	public function fieldAsImage($index,$size=Size::MINI,$circular=false){
139
-		$this->setValueFunction($index,function($img) use($size,$circular){
140
-			$image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular();
138
+	public function fieldAsImage($index, $size=Size::MINI, $circular=false) {
139
+		$this->setValueFunction($index, function($img) use($size, $circular){
140
+			$image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular();
141 141
 			return $image;
142 142
 		});
143 143
 			return $this;
144 144
 	}
145 145
 
146
-	public function fieldAsFlag($index){
147
-		$this->setValueFunction($index,function($flag){
148
-			$flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag);
146
+	public function fieldAsFlag($index) {
147
+		$this->setValueFunction($index, function($flag) {
148
+			$flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag);
149 149
 			return $flag;
150 150
 		});
151 151
 			return $this;
152 152
 	}
153 153
 
154
-	public function fieldAsAvatar($index,$attributes=NULL){
155
-		return $this->_fieldAs(function($id,$name,$value){
156
-			$img=new HtmlImage($id,$value);
154
+	public function fieldAsAvatar($index, $attributes=NULL) {
155
+		return $this->_fieldAs(function($id, $name, $value) {
156
+			$img=new HtmlImage($id, $value);
157 157
 			$img->asAvatar();
158 158
 			return $img;
159
-		}, $index,$attributes,"avatar");
159
+		}, $index, $attributes, "avatar");
160 160
 	}
161 161
 
162
-	public function fieldAsRadio($index,$attributes=NULL){
163
-		return $this->_fieldAs(function($id,$name,$value) use($attributes){
164
-			$input= new HtmlFormRadio($id,$name,$value,$value);
162
+	public function fieldAsRadio($index, $attributes=NULL) {
163
+		return $this->_fieldAs(function($id, $name, $value) use($attributes){
164
+			$input=new HtmlFormRadio($id, $name, $value, $value);
165 165
 			return $this->_prepareFormFields($input, $name, $attributes);
166
-		}, $index,$attributes,"radio");
166
+		}, $index, $attributes, "radio");
167 167
 	}
168 168
 
169
-	public function fieldAsRadios($index,$elements=[],$attributes=NULL){
170
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){
171
-			return HtmlFormFields::radios($name,$elements,$caption,$value);
172
-		}, $index,$attributes,"radios");
169
+	public function fieldAsRadios($index, $elements=[], $attributes=NULL) {
170
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){
171
+			return HtmlFormFields::radios($name, $elements, $caption, $value);
172
+		}, $index, $attributes, "radios");
173 173
 	}
174 174
 
175
-	public function fieldAsInput($index,$attributes=NULL){
176
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){
177
-			$input= new HtmlFormInput($id,$caption,"text",$value);
175
+	public function fieldAsInput($index, $attributes=NULL) {
176
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){
177
+			$input=new HtmlFormInput($id, $caption, "text", $value);
178 178
 			return $this->_prepareFormFields($input, $name, $attributes);
179
-		}, $index,$attributes,"input");
179
+		}, $index, $attributes, "input");
180 180
 	}
181 181
 
182
-	public function fieldAsTextarea($index,$attributes=NULL){
183
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){
184
-			$textarea=new HtmlFormTextarea($id,$caption,$value);
182
+	public function fieldAsTextarea($index, $attributes=NULL) {
183
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){
184
+			$textarea=new HtmlFormTextarea($id, $caption, $value);
185 185
 			return $this->_prepareFormFields($textarea, $name, $attributes);
186
-		}, $index,$attributes,"textarea");
186
+		}, $index, $attributes, "textarea");
187 187
 	}
188 188
 
189
-	public function fieldAsElement($index,$tagName="div",$baseClass="",$attributes=NULL){
190
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes,$tagName,$baseClass){
191
-			$div=new HtmlSemDoubleElement($id,$tagName,$baseClass);
189
+	public function fieldAsElement($index, $tagName="div", $baseClass="", $attributes=NULL) {
190
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass){
191
+			$div=new HtmlSemDoubleElement($id, $tagName, $baseClass);
192 192
 			$div->setContent(\htmlentities($value));
193
-			$textarea=new HtmlFormField("field-".$id, $div,$caption);
193
+			$textarea=new HtmlFormField("field-".$id, $div, $caption);
194 194
 			return $this->_prepareFormFields($textarea, $name, $attributes);
195
-		}, $index,$attributes,"element");
195
+		}, $index, $attributes, "element");
196 196
 	}
197 197
 
198 198
 
199
-	public function fieldAsHidden($index,$attributes=NULL){
200
-		if(!\is_array($attributes)){
199
+	public function fieldAsHidden($index, $attributes=NULL) {
200
+		if (!\is_array($attributes)) {
201 201
 			$attributes=[];
202 202
 		}
203 203
 		$attributes["inputType"]="hidden";
204
-		return $this->fieldAsInput($index,$attributes);
204
+		return $this->fieldAsInput($index, $attributes);
205 205
 	}
206 206
 
207
-	public function fieldAsCheckbox($index,$attributes=NULL){
208
-		return $this->_fieldAs(function($id,$name,$value,$caption) use($attributes){
209
-			if($caption===null || $caption==="")
207
+	public function fieldAsCheckbox($index, $attributes=NULL) {
208
+		return $this->_fieldAs(function($id, $name, $value, $caption) use($attributes){
209
+			if ($caption===null || $caption==="")
210 210
 				$caption="";
211
-			$input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier());
211
+			$input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier());
212 212
 			$input->setChecked(JString::isBooleanTrue($value));
213 213
 			return $this->_prepareFormFields($input, $name, $attributes);
214
-		}, $index,$attributes,"ck");
214
+		}, $index, $attributes, "ck");
215 215
 	}
216 216
 
217
-	public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
218
-		return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple,$attributes){
219
-			$dd=new HtmlFormDropdown($id,$elements,$caption,$value);
220
-			$dd->asSelect($name,$multiple);
217
+	public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) {
218
+		return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple, $attributes){
219
+			$dd=new HtmlFormDropdown($id, $elements, $caption, $value);
220
+			$dd->asSelect($name, $multiple);
221 221
 			return $this->_prepareFormFields($dd, $name, $attributes);
222
-		}, $index,$attributes,"dd");
222
+		}, $index, $attributes, "dd");
223 223
 	}
224 224
 
225
-	public function fieldAsMessage($index,$attributes=NULL){
226
-		return $this->_fieldAs(function($id,$name,$value,$caption){
227
-			$mess= new HtmlMessage("message-".$id,$caption);
225
+	public function fieldAsMessage($index, $attributes=NULL) {
226
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
227
+			$mess=new HtmlMessage("message-".$id, $caption);
228 228
 			$mess->addHeader($value);
229 229
 			return $mess;
230
-		}, $index,$attributes,"message");
230
+		}, $index, $attributes, "message");
231 231
 	}
232 232
 
233
-	public function fieldAsLink($index,$attributes=NULL){
234
-		return $this->_fieldAs(function($id,$name,$value,$caption){
235
-			$lnk= new HtmlLink("message-".$id,"#",$caption);
233
+	public function fieldAsLink($index, $attributes=NULL) {
234
+		return $this->_fieldAs(function($id, $name, $value, $caption) {
235
+			$lnk=new HtmlLink("message-".$id, "#", $caption);
236 236
 			return $lnk;
237
-		}, $index,$attributes,"link");
237
+		}, $index, $attributes, "link");
238 238
 	}
239 239
 
240 240
 	/**Change fields type
241 241
 	 * @param array $types an array or associative array $type=>$attributes
242 242
 	 */
243
-	public function fieldsAs(array $types){
243
+	public function fieldsAs(array $types) {
244 244
 		$i=0;
245
-		if(JArray::isAssociative($types)){
246
-			foreach ($types as $type=>$attributes){
247
-				if(\is_int($type))
248
-					$this->fieldAs($i++,$attributes,[]);
249
-				else{
250
-					$type=preg_replace('/\d/', '', $type );
251
-					$this->fieldAs($i++,$type,$attributes);
245
+		if (JArray::isAssociative($types)) {
246
+			foreach ($types as $type=>$attributes) {
247
+				if (\is_int($type))
248
+					$this->fieldAs($i++, $attributes, []);
249
+				else {
250
+					$type=preg_replace('/\d/', '', $type);
251
+					$this->fieldAs($i++, $type, $attributes);
252 252
 				}
253 253
 			}
254
-		}else{
255
-			foreach ($types as $type){
256
-				$this->fieldAs($i++,$type);
254
+		} else {
255
+			foreach ($types as $type) {
256
+				$this->fieldAs($i++, $type);
257 257
 			}
258 258
 		}
259 259
 	}
260 260
 
261
-	public function fieldAs($index,$type,$attributes=NULL){
261
+	public function fieldAs($index, $type, $attributes=NULL) {
262 262
 		$method="fieldAs".\ucfirst($type);
263
-		if(\method_exists($this, $method)){
264
-			if(!\is_array($attributes)){
263
+		if (\method_exists($this, $method)) {
264
+			if (!\is_array($attributes)) {
265 265
 				$attributes=[$index];
266
-			}else{
266
+			} else {
267 267
 				\array_unshift($attributes, $index);
268 268
 			}
269
-			\call_user_func_array([$this,$method], $attributes);
269
+			\call_user_func_array([$this, $method], $attributes);
270 270
 		}
271 271
 	}
272 272
 
273
-	public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
274
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){
275
-			$button=new HtmlButton($id,$caption,$cssStyle);
276
-			$this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]);
273
+	public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) {
274
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){
275
+			$button=new HtmlButton($id, $caption, $cssStyle);
276
+			$this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]);
277 277
 			return $button;
278
-		}, $index,$attributes,"submit");
278
+		}, $index, $attributes, "submit");
279 279
 	}
280 280
 
281
-	public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){
282
-		return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){
283
-			$button=new HtmlButton($id,$value,$cssStyle);
281
+	public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) {
282
+		return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){
283
+			$button=new HtmlButton($id, $value, $cssStyle);
284 284
 			return $button;
285
-		}, $index,$attributes,"button");
285
+		}, $index, $attributes, "button");
286 286
 	}
287 287
 }
Please login to merge, or discard this patch.
Ajax/semantic/html/base/HtmlSemDoubleElement.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	use BaseTrait;
23 23
 	protected $_popup=NULL;
24 24
 	protected $_dimmer=NULL;
25
-	protected $_params=array ();
25
+	protected $_params=array();
26 26
 
27 27
 
28 28
 	public function __construct($identifier, $tagName="p", $baseClass="ui", $content=NULL) {
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @return HtmlDimmer
79 79
 	 */
80 80
 	public function addDimmer($params=array(), $content=NULL) {
81
-		$dimmer=new HtmlDimmer("dimmer-" . $this->identifier, $content);
81
+		$dimmer=new HtmlDimmer("dimmer-".$this->identifier, $content);
82 82
 		$dimmer->setParams($params);
83 83
 		$dimmer->setContainer($this);
84 84
 		$this->addContent($dimmer);
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	public function addLabel($label, $before=false, $icon=NULL) {
96 96
 		$labelO=$label;
97
-		if (\is_object($label) === false) {
98
-			$labelO=new HtmlLabel("label-" . $this->identifier, $label);
97
+		if (\is_object($label)===false) {
98
+			$labelO=new HtmlLabel("label-".$this->identifier, $label);
99 99
 			if (isset($icon))
100 100
 				$labelO->addIcon($icon);
101 101
 		} else {
102
-			$labelO->addToPropertyCtrl("class", "label", array ("label" ));
102
+			$labelO->addToPropertyCtrl("class", "label", array("label"));
103 103
 		}
104 104
 		$this->addContent($labelO, $before);
105 105
 		return $labelO;
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 	 * @param string $icon
114 114
 	 * @return HtmlSemDoubleElement
115 115
 	 */
116
-	public function attachLabel($label,$side=Side::TOP,$direction=Direction::NONE,$icon=NULL){
117
-		$label=$this->addLabel($label,true,$icon);
118
-		$label->setAttached($side,$direction);
116
+	public function attachLabel($label, $side=Side::TOP, $direction=Direction::NONE, $icon=NULL) {
117
+		$label=$this->addLabel($label, true, $icon);
118
+		$label->setAttached($side, $direction);
119 119
 		return $this;
120 120
 	}
121 121
 
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 	 * Transforms the element into a link
124 124
 	 * @return HtmlSemDoubleElement
125 125
 	 */
126
-	public function asLink($href=NULL,$target=NULL) {
126
+	public function asLink($href=NULL, $target=NULL) {
127 127
 		if (isset($href))
128 128
 			$this->setProperty("href", $href);
129
-		if(isset($target))
129
+		if (isset($target))
130 130
 			$this->setProperty("target", $target);
131 131
 		return $this->setTagName("a");
132 132
 	}
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public function jsShowDimmer($show=true) {
140 140
 		$status="hide";
141
-		if ($show === true)
141
+		if ($show===true)
142 142
 			$status="show";
143
-		return '$("#.' . $this->identifier . ').dimmer("' . $status . '");';
143
+		return '$("#.'.$this->identifier.').dimmer("'.$status.'");';
144 144
 	}
145 145
 
146 146
 	/**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @see HtmlDoubleElement::run()
159 159
 	 */
160 160
 	public function run(JsUtils $js) {
161
-		$this->_bsComponent=$js->semantic()->generic("#" . $this->identifier);
161
+		$this->_bsComponent=$js->semantic()->generic("#".$this->identifier);
162 162
 		parent::run($js);
163 163
 		$this->addEventsOnRun($js);
164 164
 		if (isset($this->_popup)) {
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 		return $this->_bsComponent;
168 168
 	}
169 169
 
170
-	public function addList($items,$ordered=false){
171
-		$list=new HtmlList("list-".$this->identifier,$items);
170
+	public function addList($items, $ordered=false) {
171
+		$list=new HtmlList("list-".$this->identifier, $items);
172 172
 		$list->setOrdered($ordered);
173 173
 		$list->setClass("ui list");
174 174
 		$this->addContent($list);
Please login to merge, or discard this patch.
Ajax/semantic/html/modules/HtmlModal.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -15,36 +15,36 @@  discard block
 block discarded – undo
15 15
 	protected $_paramParts=array();
16 16
 
17 17
 	public function __construct($identifier, $header="", $content="", $actions=null) {
18
-		parent::__construct($identifier, "div","ui modal");
19
-		if(isset($header)){
18
+		parent::__construct($identifier, "div", "ui modal");
19
+		if (isset($header)) {
20 20
 			$this->setHeader($header);
21 21
 		}
22
-		if(isset($content)){
22
+		if (isset($content)) {
23 23
 			$this->setContent($content);
24 24
 		}
25
-		if(isset($actions)){
25
+		if (isset($actions)) {
26 26
 			$this->setActions($actions);
27 27
 		}
28 28
 	}
29 29
 
30 30
 	public function setHeader($value) {
31
-		$this->content["header"]=new HtmlSemDoubleElement("header-" . $this->identifier, "a", "header", $value);
31
+		$this->content["header"]=new HtmlSemDoubleElement("header-".$this->identifier, "a", "header", $value);
32 32
 		return $this;
33 33
 	}
34 34
 
35 35
 	public function setContent($value) {
36
-		$this->content["content"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", $value);
36
+		$this->content["content"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", $value);
37 37
 		return $this;
38 38
 	}
39 39
 
40 40
 	public function setActions($actions) {
41
-		$this->content["actions"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "actions");
42
-		if(\is_array($actions)){
43
-			foreach ($actions as $action){
41
+		$this->content["actions"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "actions");
42
+		if (\is_array($actions)) {
43
+			foreach ($actions as $action) {
44 44
 				$this->addAction($action);
45 45
 			}
46 46
 		}
47
-		else{
47
+		else {
48 48
 			$this->addAction($actions);
49 49
 		}
50 50
 		return $this;
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
 	 * @param string|BaseHtml $action
55 55
 	 * @return HtmlButton
56 56
 	 */
57
-	public function addAction($action){
58
-		if(!$action instanceof BaseHtml){
57
+	public function addAction($action) {
58
+		if (!$action instanceof BaseHtml) {
59 59
 			$class="";
60
-			if(\array_search($action, ["Okay","Yes","Validate"])!==false){
60
+			if (\array_search($action, ["Okay", "Yes", "Validate"])!==false) {
61 61
 				$class="approve";
62 62
 			}
63
-			if(\array_search($action, ["Close","Cancel","No"])!==false){
63
+			if (\array_search($action, ["Close", "Cancel", "No"])!==false) {
64 64
 				$class="cancel";
65 65
 			}
66
-			$action=new HtmlButton("action-".$this->identifier."-".\sizeof($this->content["actions"]->getContent()),$action);
67
-			if($class!=="")
66
+			$action=new HtmlButton("action-".$this->identifier."-".\sizeof($this->content["actions"]->getContent()), $action);
67
+			if ($class!=="")
68 68
 				$action->addToProperty("class", $class);
69 69
 		}
70 70
 		return $this->addElementInPart($action, "actions");
@@ -74,66 +74,66 @@  discard block
 block discarded – undo
74 74
 	 * @param int $index
75 75
 	 * @return HtmlButton
76 76
 	 */
77
-	public function getAction($index){
77
+	public function getAction($index) {
78 78
 		return $this->content["actions"]->getContent()[$index];
79 79
 	}
80 80
 
81
-	public function addContent($content,$before=false){
82
-		$this->content["content"]->addContent($content,$before);
81
+	public function addContent($content, $before=false) {
82
+		$this->content["content"]->addContent($content, $before);
83 83
 		return $this;
84 84
 	}
85 85
 
86
-	public function addImageContent($image,$description=NULL){
86
+	public function addImageContent($image, $description=NULL) {
87 87
 		$content=$this->content["content"];
88
-		if(isset($description)){
89
-			$description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description);
90
-			$content->addContent($description,true);
88
+		if (isset($description)) {
89
+			$description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description);
90
+			$content->addContent($description, true);
91 91
 		}
92
-		if($image!==""){
93
-			$img=new HtmlImage("image-".$this->identifier,$image,"","medium");
94
-			$content->addContent($img,true);
95
-			$content->addToProperty("class","image");
92
+		if ($image!=="") {
93
+			$img=new HtmlImage("image-".$this->identifier, $image, "", "medium");
94
+			$content->addContent($img, true);
95
+			$content->addToProperty("class", "image");
96 96
 		}
97 97
 		return $this;
98 98
 	}
99 99
 
100
-	public function addIconContent($icon,$description=NULL){
100
+	public function addIconContent($icon, $description=NULL) {
101 101
 		$content=$this->content["content"];
102
-		if(isset($description)){
103
-			$description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description);
104
-			$content->addContent($description,true);
102
+		if (isset($description)) {
103
+			$description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description);
104
+			$content->addContent($description, true);
105 105
 		}
106
-		if($icon!==""){
107
-			$img=new HtmlIcon("image-".$this->identifier,$icon);
108
-			$content->addContent($img,true);
109
-			$content->addToProperty("class","image");
106
+		if ($icon!=="") {
107
+			$img=new HtmlIcon("image-".$this->identifier, $icon);
108
+			$content->addContent($img, true);
109
+			$content->addToProperty("class", "image");
110 110
 		}
111 111
 		return $this;
112 112
 	}
113 113
 
114
-	private function addElementInPart($element,$part) {
114
+	private function addElementInPart($element, $part) {
115 115
 		$this->content[$part]->addContent($element);
116 116
 		return $element;
117 117
 	}
118 118
 
119
-	public function showDimmer($value){
120
-		$value=$value?"show":"hide";
119
+	public function showDimmer($value) {
120
+		$value=$value ? "show" : "hide";
121 121
 		$this->_paramParts[]=["'".$value." dimmer'"];
122 122
 		return $this;
123 123
 	}
124 124
 
125
-	public function setInverted($recursive=true){
125
+	public function setInverted($recursive=true) {
126 126
 		$this->_params["inverted"]=true;
127 127
 		return $this;
128 128
 	}
129 129
 
130
-	public function setBasic(){
130
+	public function setBasic() {
131 131
 		return $this->addToProperty("class", "basic");
132 132
 	}
133 133
 
134 134
 
135
-	public function setTransition($value){
136
-		$this->_paramParts[]=["'setting'","'transition'","'".$value."'"];
135
+	public function setTransition($value) {
136
+		$this->_paramParts[]=["'setting'", "'transition'", "'".$value."'"];
137 137
 	}
138 138
 
139 139
 	/**
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
 	 * @param string $viewName
144 144
 	 * @param $params The parameters to pass to the view
145 145
 	 */
146
-	public function renderView(JsUtils $js,$initialController,$viewName, $params=array()) {
147
-		return $this->setContent($js->renderContent($initialController, $viewName,$params));
146
+	public function renderView(JsUtils $js, $initialController, $viewName, $params=array()) {
147
+		return $this->setContent($js->renderContent($initialController, $viewName, $params));
148 148
 	}
149 149
 
150 150
 	/**
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 	 * @param string $actionName the action name
156 156
 	 * @param array $params
157 157
 	 */
158
-	public function forward(JsUtils $js,$initialControllerInstance,$controllerName,$actionName,$params=NULL){
159
-		return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName,$params));
158
+	public function forward(JsUtils $js, $initialControllerInstance, $controllerName, $actionName, $params=NULL) {
159
+		return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName, $params));
160 160
 	}
161 161
 
162 162
 	/**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile()
167 167
 	 */
168 168
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
169
-		$this->content=JArray::sortAssociative($this->content, ["header","content","actions" ]);
169
+		$this->content=JArray::sortAssociative($this->content, ["header", "content", "actions"]);
170 170
 		return parent::compile($js, $view);
171 171
 	}
172 172
 	/*
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 * @see BaseHtml::run()
175 175
 	 */
176 176
 	public function run(JsUtils $js) {
177
-		if(isset($this->_bsComponent)===false)
178
-			$this->_bsComponent=$js->semantic()->modal("#".$this->identifier,$this->_params,$this->_paramParts);
177
+		if (isset($this->_bsComponent)===false)
178
+			$this->_bsComponent=$js->semantic()->modal("#".$this->identifier, $this->_params, $this->_paramParts);
179 179
 		$this->addEventsOnRun($js);
180 180
 		return $this->_bsComponent;
181 181
 	}
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		return $this->jsDo("hide");
189 189
 	}
190 190
 
191
-	public function onHidden($js){
191
+	public function onHidden($js) {
192 192
 		$this->_params["onHidden"]=$js;
193 193
 	}
194 194
 }
Please login to merge, or discard this patch.