Completed
Push — master ( 2db7b1...a4369d )
by Jean-Christophe
03:00
created
Ajax/semantic/html/collections/table/HtmlTable.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 
29 29
 	public function __construct($identifier, $rowCount, $colCount) {
30 30
 		parent::__construct($identifier, "table", "ui table");
31
-		$this->content=array ();
31
+		$this->content=array();
32 32
 		$this->setRowCount($rowCount, $colCount);
33
-		$this->_variations=[ Variation::CELLED,Variation::PADDED,Variation::COMPACT ];
34
-		$this->_compileParts=["thead","tbody","tfoot"];
33
+		$this->_variations=[Variation::CELLED, Variation::PADDED, Variation::COMPACT];
34
+		$this->_compileParts=["thead", "tbody", "tfoot"];
35 35
 		$this->_afterCompileEvents=[];
36 36
 	}
37 37
 
@@ -41,17 +41,17 @@  discard block
 block discarded – undo
41 41
 	 * @return HtmlTableContent
42 42
 	 */
43 43
 	public function getPart($key) {
44
-		if (\array_key_exists($key, $this->content) === false) {
44
+		if (\array_key_exists($key, $this->content)===false) {
45 45
 			$this->content[$key]=new HtmlTableContent("", $key);
46
-			if ($key !== "tbody") {
46
+			if ($key!=="tbody") {
47 47
 				$this->content[$key]->setRowCount(1, $this->_colCount);
48 48
 			}
49 49
 		}
50 50
 		return $this->content[$key];
51 51
 	}
52 52
 
53
-	protected function _getFirstPart(){
54
-		if(isset($this->content["thead"])){
53
+	protected function _getFirstPart() {
54
+		if (isset($this->content["thead"])) {
55 55
 			return $this->content["thead"];
56 56
 		}
57 57
 		return $this->content["tbody"];
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * @return boolean
97 97
 	 */
98 98
 	public function hasPart($key) {
99
-		return \array_key_exists($key, $this->content) === true;
99
+		return \array_key_exists($key, $this->content)===true;
100 100
 	}
101 101
 
102 102
 	/**
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 		return $this->colAlign($colIndex, "colLeft");
230 230
 	}
231 231
 
232
-	public function setColAlignment($colIndex,$alignment){
233
-		switch ($alignment){
232
+	public function setColAlignment($colIndex, $alignment) {
233
+		switch ($alignment) {
234 234
 			case TextAlignment::LEFT:
235 235
 				$function="colLeft";
236 236
 				break;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
 	private function colAlign($colIndex, $function) {
250 250
 		if (\is_array($colIndex)) {
251
-			foreach ( $colIndex as $cIndex ) {
251
+			foreach ($colIndex as $cIndex) {
252 252
 				$this->colAlign($cIndex, $function);
253 253
 			}
254 254
 		} else {
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 * @see HtmlSemDoubleElement::compile()
310 310
 	 */
311 311
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
312
-		if(\sizeof($this->_compileParts)<3){
312
+		if (\sizeof($this->_compileParts)<3) {
313 313
 			$this->_template="%content%";
314 314
 			$this->refresh();
315 315
 		}
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
 	}
319 319
 
320 320
 	protected function compile_once(JsUtils $js=NULL, &$view=NULL) {
321
-		parent::compile_once($js,$view);
321
+		parent::compile_once($js, $view);
322 322
 		if ($this->propertyContains("class", "sortable")) {
323
-			$this->addEvent("execute", "$('#" . $this->identifier . "').tablesort().data('tablesort').sort($('th.default-sort'));");
323
+			$this->addEvent("execute", "$('#".$this->identifier."').tablesort().data('tablesort').sort($('th.default-sort'));");
324 324
 		}
325
-		if(isset($this->_activeRowSelector)){
325
+		if (isset($this->_activeRowSelector)) {
326 326
 			$this->_activeRowSelector->compile();
327 327
 		}
328 328
 	}
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 	public function fromDatabaseObject($object, $function) {
337 337
 		$result=$function($object);
338 338
 		if (\is_array($result)) {
339
-			$result= $this->addRow($function($object));
339
+			$result=$this->addRow($function($object));
340 340
 		} else {
341
-			$result= $this->getBody()->_addRow($result);
341
+			$result=$this->getBody()->_addRow($result);
342 342
 		}
343
-		if(isset($this->_afterCompileEvents["onNewRow"])){
344
-			if(\is_callable($this->_afterCompileEvents["onNewRow"]))
345
-				$this->_afterCompileEvents["onNewRow"]($result,$object);
343
+		if (isset($this->_afterCompileEvents["onNewRow"])) {
344
+			if (\is_callable($this->_afterCompileEvents["onNewRow"]))
345
+				$this->_afterCompileEvents["onNewRow"]($result, $object);
346 346
 		}
347 347
 		return $result;
348 348
 	}
@@ -357,14 +357,14 @@  discard block
 block discarded – undo
357 357
 		return $this;
358 358
 	}
359 359
 
360
-	public function refresh(){
360
+	public function refresh() {
361 361
 		$this->_footer=$this->getFooter();
362 362
 		$this->addEvent("execute", '$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");');
363 363
 	}
364 364
 
365
-	public function run(JsUtils $js){
366
-		$result= parent::run($js);
367
-		if(isset($this->_footer))
365
+	public function run(JsUtils $js) {
366
+		$result=parent::run($js);
367
+		if (isset($this->_footer))
368 368
 			$this->_footer->run($js);
369 369
 		return $result;
370 370
 	}
@@ -387,38 +387,38 @@  discard block
 block discarded – undo
387 387
 	 * @param boolean $multiple
388 388
 	 * @return HtmlTable
389 389
 	 */
390
-	public function setActiveRowSelector($class="active",$event="click",$multiple=false){
391
-		$this->_activeRowSelector=new ActiveRow($this,$class,$event,$multiple);
390
+	public function setActiveRowSelector($class="active", $event="click", $multiple=false) {
391
+		$this->_activeRowSelector=new ActiveRow($this, $class, $event, $multiple);
392 392
 		return $this;
393 393
 	}
394 394
 
395
-	public function hideColumn($colIndex){
396
-		if(isset($this->content["thead"])){
395
+	public function hideColumn($colIndex) {
396
+		if (isset($this->content["thead"])) {
397 397
 			$this->content["thead"]->hideColumn($colIndex);
398 398
 		}
399 399
 		$this->content["tbody"]->hideColumn($colIndex);
400
-		if(isset($this->content["tfoot"])){
400
+		if (isset($this->content["tfoot"])) {
401 401
 			$this->content["tfoot"]->hideColumn($colIndex);
402 402
 		}
403 403
 		return $this;
404 404
 	}
405 405
 
406
-	public function setColWidth($colIndex,$width){
406
+	public function setColWidth($colIndex, $width) {
407 407
 		$part=$this->_getFirstPart();
408
-		if($part!==null && $part->count()>0)
408
+		if ($part!==null && $part->count()>0)
409 409
 			$part->getCell(0, $colIndex)->setWidth($width);
410 410
 		return $this;
411 411
 	}
412 412
 
413
-	public function setColWidths($widths){
413
+	public function setColWidths($widths) {
414 414
 		$part=$this->_getFirstPart();
415
-		if($part!==null && $part->count()>0){
415
+		if ($part!==null && $part->count()>0) {
416 416
 			$count=$part->getColCount();
417
-			if(!\is_array($widths)){
417
+			if (!\is_array($widths)) {
418 418
 				$widths=\array_fill(0, $count, $widths);
419 419
 			}
420
-			$max=\min(\sizeof($widths),$count);
421
-			for($i=0;$i<$max;$i++){
420
+			$max=\min(\sizeof($widths), $count);
421
+			for ($i=0; $i<$max; $i++) {
422 422
 				$part->getCell(0, $i)->setWidth($widths[$i]);
423 423
 			}
424 424
 		}
Please login to merge, or discard this patch.
Ajax/common/html/BaseHtml.php 1 patch
Spacing   +39 added lines, -39 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();
204 204
 			}
@@ -207,25 +207,25 @@  discard block
 block discarded – undo
207 207
 	}
208 208
 
209 209
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
210
-		$this->compile_once($js,$view);
210
+		$this->compile_once($js, $view);
211 211
 		$result=$this->getTemplate($js);
212
-		foreach ( $this as $key => $value ) {
213
-			if (JString::startswith($key, "_") === false && $key !== "events") {
212
+		foreach ($this as $key => $value) {
213
+			if (JString::startswith($key, "_")===false && $key!=="events") {
214 214
 				if (\is_array($value)) {
215 215
 					$v=PropertyWrapper::wrap($value, $js);
216 216
 				} else {
217 217
 					$v=$value;
218 218
 				}
219
-				$result=str_ireplace("%" . $key . "%", $v, $result);
219
+				$result=str_ireplace("%".$key."%", $v, $result);
220 220
 			}
221 221
 		}
222 222
 		if (isset($js)===true) {
223 223
 			$this->run($js);
224
-			if (isset($view) === true) {
224
+			if (isset($view)===true) {
225 225
 				$js->addViewElement($this->_identifier, $result, $view);
226 226
 			}
227 227
 		}
228
-		if(\is_callable($this->_postCompile)){
228
+		if (\is_callable($this->_postCompile)) {
229 229
 			$pc=$this->_postCompile;
230 230
 			$pc();
231 231
 		}
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
 		return $this->compile();
237 237
 	}
238 238
 
239
-	public function onPostCompile($callback){
239
+	public function onPostCompile($callback) {
240 240
 		$this->_postCompile=$callback;
241 241
 	}
242 242
 
243
-	public function onPreCompile($callback){
243
+	public function onPreCompile($callback) {
244 244
 		$this->_preCompile=$callback;
245 245
 	}
246 246
 }
Please login to merge, or discard this patch.