Completed
Push — master ( a91c54...ab06fe )
by Jean-Christophe
03:07
created
Ajax/common/html/BaseHtml.php 2 patches
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
  * @version 1.3
16 16
  */
17 17
 abstract class BaseHtml extends BaseWidget {
18
-	use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait;
18
+	use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait;
19 19
 	protected $_template;
20 20
 	protected $tagName;
21
-	protected $_wrapBefore=array ();
22
-	protected $_wrapAfter=array ();
21
+	protected $_wrapBefore=array();
22
+	protected $_wrapAfter=array();
23 23
 	protected $_bsComponent;
24 24
 	protected $_compiled=false;
25 25
 	protected $_postCompile;
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	abstract public function run(JsUtils $js);
34 34
 
35
-	private function _callSetter($setter,$key,$value,&$array){
35
+	private function _callSetter($setter, $key, $value, &$array) {
36 36
 		$result=false;
37 37
 		if (method_exists($this, $setter) && !JString::startswith($key, "_")) {
38 38
 			try {
39 39
 				$this->$setter($value);
40 40
 				unset($array[$key]);
41 41
 				$result=true;
42
-			} catch ( \Exception $e ) {
42
+			}catch (\Exception $e) {
43 43
 				$result=false;
44 44
 			}
45 45
 		}
@@ -47,17 +47,17 @@  discard block
 block discarded – undo
47 47
 	}
48 48
 
49 49
 	protected function getTemplate(JsUtils $js=NULL) {
50
-		return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js);
50
+		return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js);
51 51
 	}
52 52
 
53 53
 	protected function ctrl($name, $value, $typeCtrl) {
54 54
 		if (\is_array($typeCtrl)) {
55
-			if (array_search($value, $typeCtrl) === false) {
56
-				throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}");
55
+			if (array_search($value, $typeCtrl)===false) {
56
+				throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
57 57
 			}
58 58
 		} else {
59 59
 			if (!$typeCtrl($value)) {
60
-				throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name);
60
+				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name);
61 61
 			}
62 62
 		}
63 63
 		return true;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
 
68 68
 	protected function setMemberCtrl(&$name, $value, $typeCtrl) {
69
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
69
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
70 70
 			return $name=$value;
71 71
 		}
72 72
 		return $this;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") {
76 76
 		if (\is_array($typeCtrl)) {
77 77
 			$this->removeOldValues($name, $typeCtrl);
78
-			$name.=$separator . $value;
78
+			$name.=$separator.$value;
79 79
 		}
80 80
 		return $this;
81 81
 	}
@@ -83,17 +83,17 @@  discard block
 block discarded – undo
83 83
 
84 84
 
85 85
 	protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") {
86
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
86
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
87 87
 			if (\is_array($typeCtrl)) {
88 88
 				$this->removeOldValues($name, $typeCtrl);
89 89
 			}
90
-			$name.=$separator . $value;
90
+			$name.=$separator.$value;
91 91
 		}
92 92
 		return $this;
93 93
 	}
94 94
 
95 95
 	protected function addToMember(&$name, $value, $separator=" ") {
96
-		$name=str_ireplace($value, "", $name) . $separator . $value;
96
+		$name=str_ireplace($value, "", $name).$separator.$value;
97 97
 		return $this;
98 98
 	}
99 99
 
@@ -104,18 +104,18 @@  discard block
 block discarded – undo
104 104
 		$oldValue=trim($oldValue);
105 105
 	}
106 106
 
107
-	protected function _getElementBy($callback,$elements){
107
+	protected function _getElementBy($callback, $elements) {
108 108
 		if (\is_array($elements)) {
109 109
 			$elements=\array_values($elements);
110 110
 			$flag=false;
111 111
 			$index=0;
112
-			while ( !$flag && $index < sizeof($elements) ) {
112
+			while (!$flag && $index<sizeof($elements)) {
113 113
 				if ($elements[$index] instanceof BaseHtml)
114 114
 					$flag=($callback($elements[$index]));
115 115
 					$index++;
116 116
 			}
117
-			if ($flag === true)
118
-				return $elements[$index - 1];
117
+			if ($flag===true)
118
+				return $elements[$index-1];
119 119
 		} elseif ($elements instanceof BaseHtml) {
120 120
 			if ($callback($elements))
121 121
 				return $elements;
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
 	}
144 144
 
145 145
 	public function fromArray($array) {
146
-		foreach ( $this as $key => $value ) {
147
-			if(array_key_exists($key, $array)===true)
148
-				$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
146
+		foreach ($this as $key => $value) {
147
+			if (array_key_exists($key, $array)===true)
148
+				$this->_callSetter("set".ucfirst($key), $key, $array[$key], $array);
149 149
 		}
150
-		foreach ( $array as $key => $value ) {
151
-			if($this->_callSetter($key, $key, $value, $array)===false){
152
-				$this->_callSetter("set" . ucfirst($key), $key, $value, $array);
150
+		foreach ($array as $key => $value) {
151
+			if ($this->_callSetter($key, $key, $value, $array)===false) {
152
+				$this->_callSetter("set".ucfirst($key), $key, $value, $array);
153 153
 			}
154 154
 		}
155 155
 		return $array;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
 	public function fromDatabaseObjects($objects, $function) {
159 159
 		if (isset($objects)) {
160
-			foreach ( $objects as $object ) {
160
+			foreach ($objects as $object) {
161 161
 				$this->fromDatabaseObject($object, $function);
162 162
 			}
163 163
 		}
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 
179 179
 
180 180
 	public function getElementById($identifier, $elements) {
181
-		return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements);
181
+		return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements);
182 182
 	}
183 183
 
184 184
 	public function getBsComponent() {
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
 	}
192 192
 
193 193
 	protected function compile_once(JsUtils $js=NULL, &$view=NULL) {
194
-		if(!$this->_compiled){
195
-			if(isset($js)){
194
+		if (!$this->_compiled) {
195
+			if (isset($js)) {
196 196
 				$beforeCompile=$js->getParam("beforeCompileHtml");
197
-				if(\is_callable($beforeCompile)){
198
-					$beforeCompile($this,$js,$view);
197
+				if (\is_callable($beforeCompile)) {
198
+					$beforeCompile($this, $js, $view);
199 199
 				}
200 200
 			}
201
-			if(\is_callable($this->_preCompile)){
201
+			if (\is_callable($this->_preCompile)) {
202 202
 				$pc=$this->_preCompile;
203 203
 				$pc($this);
204 204
 			}
@@ -208,29 +208,29 @@  discard block
 block discarded – undo
208 208
 	}
209 209
 
210 210
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
211
-		$this->compile_once($js,$view);
211
+		$this->compile_once($js, $view);
212 212
 		$result=$this->getTemplate($js);
213
-		foreach ( $this as $key => $value ) {
214
-			if (JString::startswith($key, "_") === false && $key !== "events") {
213
+		foreach ($this as $key => $value) {
214
+			if (JString::startswith($key, "_")===false && $key!=="events") {
215 215
 				if (\is_array($value)) {
216 216
 					$v=PropertyWrapper::wrap($value, $js);
217 217
 				} else {
218
-					if($value instanceof \stdClass)
219
-						$v=\print_r($value,true);
218
+					if ($value instanceof \stdClass)
219
+						$v=\print_r($value, true);
220 220
 					else
221 221
 						$v=$value;
222 222
 				}
223
-				$result=str_ireplace("%" . $key . "%", $v, $result);
223
+				$result=str_ireplace("%".$key."%", $v, $result);
224 224
 			}
225 225
 		}
226 226
 		if (isset($js)===true) {
227 227
 			$this->run($js);
228
-			if (isset($view) === true) {
228
+			if (isset($view)===true) {
229 229
 				$js->addViewElement($this->_identifier, $result, $view);
230 230
 			}
231 231
 		}
232 232
 
233
-		if(\is_callable($this->_postCompile)){
233
+		if (\is_callable($this->_postCompile)) {
234 234
 			$pc=$this->_postCompile;
235 235
 			$pc($this);
236 236
 		}
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 		return $this->compile();
242 242
 	}
243 243
 
244
-	public function onPostCompile($callback){
244
+	public function onPostCompile($callback) {
245 245
 		$this->_postCompile=$callback;
246 246
 	}
247 247
 
248
-	public function onPreCompile($callback){
248
+	public function onPreCompile($callback) {
249 249
 		$this->_preCompile=$callback;
250 250
 	}
251 251
 }
Please login to merge, or discard this patch.
Braces   +17 added lines, -12 removed lines patch added patch discarded remove patch
@@ -110,15 +110,18 @@  discard block
 block discarded – undo
110 110
 			$flag=false;
111 111
 			$index=0;
112 112
 			while ( !$flag && $index < sizeof($elements) ) {
113
-				if ($elements[$index] instanceof BaseHtml)
114
-					$flag=($callback($elements[$index]));
113
+				if ($elements[$index] instanceof BaseHtml) {
114
+									$flag=($callback($elements[$index]));
115
+				}
115 116
 					$index++;
116 117
 			}
117
-			if ($flag === true)
118
-				return $elements[$index - 1];
118
+			if ($flag === true) {
119
+							return $elements[$index - 1];
120
+			}
119 121
 		} elseif ($elements instanceof BaseHtml) {
120
-			if ($callback($elements))
121
-				return $elements;
122
+			if ($callback($elements)) {
123
+							return $elements;
124
+			}
122 125
 		}
123 126
 		return null;
124 127
 	}
@@ -144,8 +147,9 @@  discard block
 block discarded – undo
144 147
 
145 148
 	public function fromArray($array) {
146 149
 		foreach ( $this as $key => $value ) {
147
-			if(array_key_exists($key, $array)===true)
148
-				$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
150
+			if(array_key_exists($key, $array)===true) {
151
+							$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
152
+			}
149 153
 		}
150 154
 		foreach ( $array as $key => $value ) {
151 155
 			if($this->_callSetter($key, $key, $value, $array)===false){
@@ -215,10 +219,11 @@  discard block
 block discarded – undo
215 219
 				if (\is_array($value)) {
216 220
 					$v=PropertyWrapper::wrap($value, $js);
217 221
 				} else {
218
-					if($value instanceof \stdClass)
219
-						$v=\print_r($value,true);
220
-					else
221
-						$v=$value;
222
+					if($value instanceof \stdClass) {
223
+											$v=\print_r($value,true);
224
+					} else {
225
+											$v=$value;
226
+					}
222 227
 				}
223 228
 				$result=str_ireplace("%" . $key . "%", $v, $result);
224 229
 			}
Please login to merge, or discard this patch.
Ajax/common/Widget.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 use Ajax\semantic\html\modules\HtmlModal;
21 21
 
22 22
 abstract class Widget extends HtmlDoubleElement {
23
-	use FieldAsTrait,FormTrait;
23
+	use FieldAsTrait, FormTrait;
24 24
 
25 25
 	/**
26 26
 	 * @var string classname
@@ -53,17 +53,17 @@  discard block
 block discarded – undo
53 53
 	protected $_generated;
54 54
 
55 55
 
56
-	public function __construct($identifier,$model,$modelInstance=NULL) {
56
+	public function __construct($identifier, $model, $modelInstance=NULL) {
57 57
 		parent::__construct($identifier);
58 58
 		$this->_template="%wrapContentBefore%%content%%wrapContentAfter%";
59 59
 		$this->setModel($model);
60
-		if(isset($modelInstance)){
60
+		if (isset($modelInstance)) {
61 61
 			$this->show($modelInstance);
62 62
 		}
63 63
 		$this->_generated=false;
64 64
 	}
65 65
 
66
-	protected function _init($instanceViewer,$contentKey,$content,$edition){
66
+	protected function _init($instanceViewer, $contentKey, $content, $edition) {
67 67
 		$this->_instanceViewer=$instanceViewer;
68 68
 		$this->content=[$contentKey=>$content];
69 69
 		$this->_self=$content;
@@ -75,31 +75,31 @@  discard block
 block discarded – undo
75 75
 	 * @param int|string $fieldName
76 76
 	 * @return int|string
77 77
 	 */
78
-	protected function _getIndex($fieldName){
78
+	protected function _getIndex($fieldName) {
79 79
 		$index=$fieldName;
80
-		if(\is_string($fieldName)){
80
+		if (\is_string($fieldName)) {
81 81
 			$fields=$this->_instanceViewer->getVisibleProperties();
82 82
 			$index=\array_search($fieldName, $fields);
83 83
 		}
84 84
 		return $index;
85 85
 	}
86 86
 
87
-	protected function _getFieldIdentifier($prefix,$name=""){
87
+	protected function _getFieldIdentifier($prefix, $name="") {
88 88
 		return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier();
89 89
 	}
90 90
 
91
-	protected function _getFieldName($index){
91
+	protected function _getFieldName($index) {
92 92
 		return $this->_instanceViewer->getFieldName($index);
93 93
 	}
94 94
 
95
-	protected function _getFieldCaption($index){
95
+	protected function _getFieldCaption($index) {
96 96
 		return $this->_instanceViewer->getCaption($index);
97 97
 	}
98 98
 
99
-	abstract protected  function _setToolbarPosition($table,$captions=NULL);
99
+	abstract protected  function _setToolbarPosition($table, $captions=NULL);
100 100
 
101
-	public function show($modelInstance){
102
-		if(\is_array($modelInstance)){
101
+	public function show($modelInstance) {
102
+		if (\is_array($modelInstance)) {
103 103
 			$modelInstance=\json_decode(\json_encode($modelInstance), FALSE);
104 104
 		}
105 105
 		$this->_modelInstance=$modelInstance;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
 	abstract public function getHtmlComponent();
127 127
 
128
-	public function setAttached($value=true){
128
+	public function setAttached($value=true) {
129 129
 		return $this->getHtmlComponent()->setAttached($value);
130 130
 	}
131 131
 
@@ -136,59 +136,59 @@  discard block
 block discarded – undo
136 136
 	 * @param callable $callback function called after the field compilation
137 137
 	 * @return Widget
138 138
 	 */
139
-	public function afterCompile($index,$callback){
139
+	public function afterCompile($index, $callback) {
140 140
 		$index=$this->_getIndex($index);
141 141
 		$this->_instanceViewer->afterCompile($index, $callback);
142 142
 		return $this;
143 143
 	}
144 144
 
145
-	public function setColor($color){
145
+	public function setColor($color) {
146 146
 		return $this->getHtmlComponent()->setColor($color);
147 147
 	}
148 148
 
149 149
 
150
-	public function setCaptions($captions){
150
+	public function setCaptions($captions) {
151 151
 		$this->_instanceViewer->setCaptions($captions);
152 152
 		return $this;
153 153
 	}
154 154
 
155
-	public function setCaption($index,$caption){
155
+	public function setCaption($index, $caption) {
156 156
 		$this->_instanceViewer->setCaption($this->_getIndex($index), $caption);
157 157
 		return $this;
158 158
 	}
159 159
 
160
-	public function setFields($fields){
160
+	public function setFields($fields) {
161 161
 		$this->_instanceViewer->setVisibleProperties($fields);
162 162
 		return $this;
163 163
 	}
164 164
 
165
-	public function addField($field){
165
+	public function addField($field) {
166 166
 		$this->_instanceViewer->addField($field);
167 167
 		return $this;
168 168
 	}
169 169
 
170
-	public function addFields($fields){
170
+	public function addFields($fields) {
171 171
 		$this->_instanceViewer->addFields($fields);
172 172
 		return $this;
173 173
 	}
174 174
 
175
-	public function addMessage($attributes=NULL,$fieldName="message"){
175
+	public function addMessage($attributes=NULL, $fieldName="message") {
176 176
 		$this->_instanceViewer->addField($fieldName);
177 177
 		$count=$this->_instanceViewer->visiblePropertiesCount();
178
-		return $this->fieldAsMessage($count-1,$attributes);
178
+		return $this->fieldAsMessage($count-1, $attributes);
179 179
 	}
180 180
 
181
-	public function addErrorMessage(){
182
-		return $this->addMessage(["error"=>true],"message");
181
+	public function addErrorMessage() {
182
+		return $this->addMessage(["error"=>true], "message");
183 183
 	}
184 184
 
185
-	public function insertField($index,$field){
185
+	public function insertField($index, $field) {
186 186
 		$index=$this->_getIndex($index);
187 187
 		$this->_instanceViewer->insertField($index, $field);
188 188
 		return $this;
189 189
 	}
190 190
 
191
-	public function insertInField($index,$field){
191
+	public function insertInField($index, $field) {
192 192
 		$index=$this->_getIndex($index);
193 193
 		$this->_instanceViewer->insertInField($index, $field);
194 194
 		return $this;
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
 	 * @param callable $callback function parameters are : $value : the field value ,$index : the field index, $instance : the active instance of model
201 201
 	 * @return Widget
202 202
 	 */
203
-	public function setValueFunction($index,$callback){
203
+	public function setValueFunction($index, $callback) {
204 204
 		$index=$this->_getIndex($index);
205 205
 		$this->_instanceViewer->setValueFunction($index, $callback);
206 206
 		return $this;
207 207
 	}
208 208
 
209
-	public function setIdentifierFunction($callback){
209
+	public function setIdentifierFunction($callback) {
210 210
 		$this->_instanceViewer->setIdentifierFunction($callback);
211 211
 		return $this;
212 212
 	}
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	/**
215 215
 	 * @return \Ajax\semantic\html\collections\menus\HtmlMenu
216 216
 	 */
217
-	public function getToolbar(){
218
-		if(isset($this->_toolbar)===false){
217
+	public function getToolbar() {
218
+		if (isset($this->_toolbar)===false) {
219 219
 			$this->_toolbar=new HtmlMenu("toolbar-".$this->identifier);
220 220
 		}
221 221
 		return $this->_toolbar;
@@ -227,15 +227,15 @@  discard block
 block discarded – undo
227 227
 	 * @param callable $callback function to call on $element
228 228
 	 * @return \Ajax\common\html\HtmlDoubleElement
229 229
 	 */
230
-	public function addInToolbar($element,$callback=NULL){
230
+	public function addInToolbar($element, $callback=NULL) {
231 231
 		$tb=$this->getToolbar();
232
-		if($element instanceof BaseWidget){
233
-			if($element->getIdentifier()===""){
232
+		if ($element instanceof BaseWidget) {
233
+			if ($element->getIdentifier()==="") {
234 234
 				$element->setIdentifier("tb-item-".$this->identifier."-".$tb->count());
235 235
 			}
236 236
 		}
237
-		if(isset($callback)){
238
-			if(\is_callable($callback)){
237
+		if (isset($callback)) {
238
+			if (\is_callable($callback)) {
239 239
 				$callback($element);
240 240
 			}
241 241
 		}
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 	 * @param callable $callback function($element)
249 249
 	 * @return \Ajax\common\html\HtmlDoubleElement
250 250
 	 */
251
-	public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){
252
-		$result=$this->addInToolbar($caption,$callback);
253
-		if(isset($icon))
251
+	public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) {
252
+		$result=$this->addInToolbar($caption, $callback);
253
+		if (isset($icon))
254 254
 			$result->addIcon($icon);
255 255
 		return $result;
256 256
 	}
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
 	 * @param callable $callback function($element)
261 261
 	 * @return \Ajax\common\Widget
262 262
 	 */
263
-	public function addItemsInToolbar(array $items,$callback=NULL){
264
-		if(JArray::isAssociative($items)){
265
-			foreach ($items as $icon=>$item){
266
-				$this->addItemInToolbar($item,$icon,$callback);
263
+	public function addItemsInToolbar(array $items, $callback=NULL) {
264
+		if (JArray::isAssociative($items)) {
265
+			foreach ($items as $icon=>$item) {
266
+				$this->addItemInToolbar($item, $icon, $callback);
267 267
 			}
268
-		}else{
269
-			foreach ($items as $item){
270
-				$this->addItemInToolbar($item,null,$callback);
268
+		} else {
269
+			foreach ($items as $item) {
270
+				$this->addItemInToolbar($item, null, $callback);
271 271
 			}
272 272
 		}
273 273
 		return $this;
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
 	 * @param callable $callback function($element)
280 280
 	 * @return \Ajax\common\html\HtmlDoubleElement
281 281
 	 */
282
-	public function addDropdownInToolbar($value,$items,$callback=NULL){
282
+	public function addDropdownInToolbar($value, $items, $callback=NULL) {
283 283
 		$dd=$value;
284 284
 		if (\is_string($value)) {
285
-			$dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items);
285
+			$dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items);
286 286
 		}
287
-		return $this->addInToolbar($dd,$callback);
287
+		return $this->addInToolbar($dd, $callback);
288 288
 	}
289 289
 
290 290
 	/**
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
 	 * @param callable $callback function($element)
294 294
 	 * @return \Ajax\common\html\HtmlDoubleElement
295 295
 	 */
296
-	public function addButtonInToolbar($caption,$cssStyle=null,$callback=NULL){
297
-		$bt=new HtmlButton("bt-".$caption,$caption,$cssStyle);
298
-		return $this->addInToolbar($bt,$callback);
296
+	public function addButtonInToolbar($caption, $cssStyle=null, $callback=NULL) {
297
+		$bt=new HtmlButton("bt-".$caption, $caption, $cssStyle);
298
+		return $this->addInToolbar($bt, $callback);
299 299
 	}
300 300
 
301 301
 	/**
@@ -304,9 +304,9 @@  discard block
 block discarded – undo
304 304
 	 * @param callable $callback function($element)
305 305
 	 * @return \Ajax\common\html\HtmlDoubleElement
306 306
 	 */
307
-	public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){
308
-		$bts=new HtmlButtonGroups("",$captions,$asIcon);
309
-		return $this->addInToolbar($bts,$callback);
307
+	public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) {
308
+		$bts=new HtmlButtonGroups("", $captions, $asIcon);
309
+		return $this->addInToolbar($bts, $callback);
310 310
 	}
311 311
 
312 312
 	/**
@@ -316,15 +316,15 @@  discard block
 block discarded – undo
316 316
 	 * @param boolean $labeled
317 317
 	 * @return \Ajax\common\html\HtmlDoubleElement
318 318
 	 */
319
-	public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){
320
-		$bt=new HtmlButton("",$caption);
321
-		$bt->addIcon($icon,$before,$labeled);
319
+	public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) {
320
+		$bt=new HtmlButton("", $caption);
321
+		$bt->addIcon($icon, $before, $labeled);
322 322
 		return $this->addInToolbar($bt);
323 323
 	}
324 324
 
325
-	public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){
326
-		$button=new HtmlButton($identifier,$value,$cssStyle);
327
-		$this->_buttonAsSubmit($button,"click",$url,$responseElement,$parameters);
325
+	public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) {
326
+		$button=new HtmlButton($identifier, $value, $cssStyle);
327
+		$this->_buttonAsSubmit($button, "click", $url, $responseElement, $parameters);
328 328
 		return $this->addInToolbar($button);
329 329
 	}
330 330
 
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 	 * @param callable $defaultValueFunction function parameters are : $name : the field name, $value : the field value ,$index : the field index, $instance : the active instance of model
355 355
 	 * @return \Ajax\common\Widget
356 356
 	 */
357
-	public function setDefaultValueFunction($defaultValueFunction){
357
+	public function setDefaultValueFunction($defaultValueFunction) {
358 358
 		$this->_instanceViewer->setDefaultValueFunction($defaultValueFunction);
359 359
 		return $this;
360 360
 	}
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 * @param string|boolean $disable
364 364
 	 * @return string
365 365
 	 */
366
-	public function jsDisabled($disable=true){
366
+	public function jsDisabled($disable=true) {
367 367
 		return "$('#".$this->identifier." .ui.input,#".$this->identifier." .ui.dropdown,#".$this->identifier." .ui.checkbox').toggleClass('disabled',".$disable.");";
368 368
 	}
369 369
 
@@ -372,12 +372,12 @@  discard block
 block discarded – undo
372 372
 	 * @param callable $callback function($element)
373 373
 	 * @return \Ajax\common\html\HtmlDoubleElement
374 374
 	 */
375
-	public function addEditButtonInToolbar($caption,$callback=NULL){
376
-		$bt=new HtmlButton($this->identifier."-editBtn",$caption);
375
+	public function addEditButtonInToolbar($caption, $callback=NULL) {
376
+		$bt=new HtmlButton($this->identifier."-editBtn", $caption);
377 377
 		$bt->setToggle();
378 378
 		$bt->setActive($this->_edition);
379 379
 		$bt->onClick($this->jsDisabled(Javascript::prep_value("!$(event.target).hasClass('active')")));
380
-		return $this->addInToolbar($bt,$callback);
380
+		return $this->addInToolbar($bt, $callback);
381 381
 	}
382 382
 
383 383
 	public function setToolbar(HtmlMenu $_toolbar) {
@@ -391,35 +391,35 @@  discard block
 block discarded – undo
391 391
 	}
392 392
 
393 393
 	public function getForm() {
394
-		if(!isset($this->_form)){
394
+		if (!isset($this->_form)) {
395 395
 			$this->_form=new HtmlForm("frm-".$this->identifier);
396 396
 			$this->setEdition(true);
397 397
 		}
398 398
 		return $this->_form;
399 399
 	}
400 400
 
401
-	public function run(JsUtils $js){
401
+	public function run(JsUtils $js) {
402 402
 		$result=parent::run($js);
403
-		if(isset($this->_form)){
403
+		if (isset($this->_form)) {
404 404
 			$result=$this->runForm($js);
405 405
 		}
406 406
 		return $result;
407 407
 	}
408 408
 
409
-	protected function runForm(JsUtils $js){
409
+	protected function runForm(JsUtils $js) {
410 410
 		$fields=$this->getContentInstances(HtmlFormField::class);
411
-		foreach ($fields as $field){
411
+		foreach ($fields as $field) {
412 412
 			$this->_form->addField($field);
413 413
 		}
414 414
 		return $this->_form->run($js);
415 415
 	}
416 416
 
417
-	protected function _compileForm(){
418
-		if(isset($this->_form)){
417
+	protected function _compileForm() {
418
+		if (isset($this->_form)) {
419 419
 			$noValidate="";
420
-			if(\sizeof($this->_form->getValidationParams())>0)
420
+			if (\sizeof($this->_form->getValidationParams())>0)
421 421
 				$noValidate="novalidate";
422
-			$this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">","</form>");
422
+			$this->wrapContent("<form class='ui form' id='frm-".$this->identifier."' name='frm-".$this->identifier."' ".$noValidate.">", "</form>");
423 423
 		}
424 424
 	}
425 425
 
@@ -428,32 +428,32 @@  discard block
 block discarded – undo
428 428
 		return $this;
429 429
 	}
430 430
 
431
-	public function moveFieldTo($from,$to){
431
+	public function moveFieldTo($from, $to) {
432 432
 		return $this->_instanceViewer->moveFieldTo($from, $to);
433 433
 	}
434 434
 
435
-	public function swapFields($index1,$index2){
435
+	public function swapFields($index1, $index2) {
436 436
 		$index1=$this->_getIndex($index1);
437 437
 		$index2=$this->_getIndex($index2);
438 438
 		return $this->_instanceViewer->swapFields($index1, $index2);
439 439
 	}
440 440
 
441
-	public function removeField($index){
441
+	public function removeField($index) {
442 442
 		$index=$this->_getIndex($index);
443 443
 		$this->_instanceViewer->removeField($index);
444 444
 		return $this;
445 445
 	}
446 446
 
447
-	public function asModal($header=null){
448
-		$modal=new HtmlModal("modal-".$this->identifier,$header);
447
+	public function asModal($header=null) {
448
+		$modal=new HtmlModal("modal-".$this->identifier, $header);
449 449
 		$modal->setContent($this);
450
-		if(isset($this->_form)){
450
+		if (isset($this->_form)) {
451 451
 			$this->_form->onSuccess($modal->jsHide());
452 452
 		}
453 453
 		return $modal;
454 454
 	}
455 455
 
456 456
 	public function addToProperty($name, $value, $separator=" ") {
457
-		return $this->getHtmlComponent()->addToProperty($name,$value,$separator);
457
+		return $this->getHtmlComponent()->addToProperty($name, $value, $separator);
458 458
 	}
459 459
 }
Please login to merge, or discard this patch.
Ajax/ui/components/DialogButton.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 	private function addFunction($jsCode) {
18 18
 		if (!Text::startsWith($jsCode, "function"))
19
-			$jsCode="%function(){" . $jsCode . "}%";
19
+			$jsCode="%function(){".$jsCode."}%";
20 20
 		return $jsCode;
21 21
 	}
22 22
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null)
52 52
 	 * @return DialogButton
53 53
 	 */
54
-	public static function submitButton(JsUtils $js, $url, $form, $responseElement, $caption="Okay",$parameters=[]) {
55
-		return new DialogButton($caption, $js->postFormDeferred($url, $form, $responseElement,$parameters) . ";$( this ).dialog( 'close' );");
54
+	public static function submitButton(JsUtils $js, $url, $form, $responseElement, $caption="Okay", $parameters=[]) {
55
+		return new DialogButton($caption, $js->postFormDeferred($url, $form, $responseElement, $parameters).";$( this ).dialog( 'close' );");
56 56
 	}
57 57
 }
Please login to merge, or discard this patch.