Completed
Push — master ( 2aad8b...141d55 )
by Jean-Christophe
03:21
created
Ajax/common/html/BaseHtml.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
 abstract class BaseHtml extends BaseWidget {
17 17
 	protected $_template;
18 18
 	protected $tagName;
19
-	protected $properties=array ();
20
-	protected $_events=array ();
21
-	protected $_wrapBefore=array ();
22
-	protected $_wrapAfter=array ();
19
+	protected $properties=array();
20
+	protected $_events=array();
21
+	protected $_wrapBefore=array();
22
+	protected $_wrapAfter=array();
23 23
 	protected $_bsComponent;
24 24
 
25 25
 	public function getBsComponent() {
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	}
33 33
 
34 34
 	protected function getTemplate(JsUtils $js=NULL) {
35
-		return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js);
35
+		return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js);
36 36
 	}
37 37
 
38 38
 	public function getProperties() {
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 
57 57
 	public function addToProperty($name, $value, $separator=" ") {
58 58
 		if (\is_array($value)) {
59
-			foreach ( $value as $v ) {
59
+			foreach ($value as $v) {
60 60
 				$this->addToProperty($name, $v, $separator);
61 61
 			}
62
-		} else if ($value !== "" && $this->propertyContains($name, $value) === false) {
62
+		} else if ($value!=="" && $this->propertyContains($name, $value)===false) {
63 63
 			$v=@$this->properties[$name];
64
-			if (isset($v) && $v !== "")
65
-				$v=$v . $separator . $value;
64
+			if (isset($v) && $v!=="")
65
+				$v=$v.$separator.$value;
66 66
 			else
67 67
 				$v=$value;
68 68
 
@@ -78,19 +78,19 @@  discard block
 block discarded – undo
78 78
 
79 79
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
80 80
 		$result=$this->getTemplate($js);
81
-		foreach ( $this as $key => $value ) {
82
-			if (JString::startswith($key, "_") === false && $key !== "events") {
81
+		foreach ($this as $key => $value) {
82
+			if (JString::startswith($key, "_")===false && $key!=="events") {
83 83
 				if (is_array($value)) {
84 84
 					$v=PropertyWrapper::wrap($value, $js);
85 85
 				} else {
86 86
 					$v=$value;
87 87
 				}
88
-				$result=str_ireplace("%" . $key . "%", $v, $result);
88
+				$result=str_ireplace("%".$key."%", $v, $result);
89 89
 			}
90 90
 		}
91 91
 		if (isset($js)===true) {
92 92
 			$this->run($js);
93
-			if (isset($view) === true) {
93
+			if (isset($view)===true) {
94 94
 				$js->addViewElement($this->identifier, $result, $view);
95 95
 			}
96 96
 		}
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
 
100 100
 	protected function ctrl($name, $value, $typeCtrl) {
101 101
 		if (is_array($typeCtrl)) {
102
-			if (array_search($value, $typeCtrl) === false) {
103
-				throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}");
102
+			if (array_search($value, $typeCtrl)===false) {
103
+				throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
104 104
 			}
105 105
 		} else {
106 106
 			if (!$typeCtrl($value)) {
107
-				throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name);
107
+				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name);
108 108
 			}
109 109
 		}
110 110
 		return true;
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 	}
120 120
 
121 121
 	protected function setPropertyCtrl($name, $value, $typeCtrl) {
122
-		if ($this->ctrl($name, $value, $typeCtrl) === true)
122
+		if ($this->ctrl($name, $value, $typeCtrl)===true)
123 123
 			return $this->setProperty($name, $value);
124 124
 		return $this;
125 125
 	}
126 126
 
127 127
 	protected function setMemberCtrl(&$name, $value, $typeCtrl) {
128
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
128
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
129 129
 			return $name=$value;
130 130
 		}
131 131
 		return $this;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") {
135 135
 		if (is_array($typeCtrl)) {
136 136
 			$this->removeOldValues($name, $typeCtrl);
137
-			$name.=$separator . $value;
137
+			$name.=$separator.$value;
138 138
 		}
139 139
 		return $this;
140 140
 	}
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
 	}
157 157
 
158 158
 	protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") {
159
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
159
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
160 160
 			if (is_array($typeCtrl)) {
161 161
 				$this->removeOldValues($name, $typeCtrl);
162 162
 			}
163
-			$name.=$separator . $value;
163
+			$name.=$separator.$value;
164 164
 		}
165 165
 		return $this;
166 166
 	}
167 167
 
168 168
 	protected function addToMember(&$name, $value, $separator=" ") {
169
-		$name=str_ireplace($value, "", $name) . $separator . $value;
169
+		$name=str_ireplace($value, "", $name).$separator.$value;
170 170
 		return $this;
171 171
 	}
172 172
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	}
185 185
 
186 186
 	public function addToPropertyCtrlCheck($name, $value, $typeCtrl) {
187
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
187
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
188 188
 			return $this->addToProperty($name, $value);
189 189
 		}
190 190
 		return $this;
@@ -212,28 +212,28 @@  discard block
 block discarded – undo
212 212
 	}
213 213
 
214 214
 	public function fromArray($array) {
215
-		foreach ( $this as $key => $value ) {
215
+		foreach ($this as $key => $value) {
216 216
 			if (array_key_exists($key, $array) && !JString::startswith($key, "_")) {
217
-				$setter="set" . ucfirst($key);
217
+				$setter="set".ucfirst($key);
218 218
 				$this->$setter($array[$key]);
219 219
 				unset($array[$key]);
220 220
 			}
221 221
 		}
222
-		foreach ( $array as $key => $value ) {
222
+		foreach ($array as $key => $value) {
223 223
 			if (method_exists($this, $key)) {
224 224
 				try {
225 225
 					$this->$key($value);
226 226
 					unset($array[$key]);
227
-				} catch ( \Exception $e ) {
227
+				}catch (\Exception $e) {
228 228
 					// Nothing to do
229 229
 				}
230 230
 			} else {
231
-				$setter="set" . ucfirst($key);
231
+				$setter="set".ucfirst($key);
232 232
 				if (method_exists($this, $setter)) {
233 233
 					try {
234 234
 						$this->$setter($value);
235 235
 						unset($array[$key]);
236
-					} catch ( \Exception $e ) {
236
+					}catch (\Exception $e) {
237 237
 						// Nothing to do
238 238
 					}
239 239
 				}
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
 	public function fromDatabaseObjects($objects, $function) {
246 246
 		if (isset($objects)) {
247
-			foreach ( $objects as $object ) {
247
+			foreach ($objects as $object) {
248 248
 				$this->fromDatabaseObject($object, $function);
249 249
 			}
250 250
 		}
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
 	}
265 265
 
266 266
 	public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
267
-		if ($stopPropagation === true) {
268
-			$jsCode="event.stopPropagation();" . $jsCode;
267
+		if ($stopPropagation===true) {
268
+			$jsCode="event.stopPropagation();".$jsCode;
269 269
 		}
270
-		if ($preventDefault === true) {
271
-			$jsCode="event.preventDefault();" . $jsCode;
270
+		if ($preventDefault===true) {
271
+			$jsCode="event.preventDefault();".$jsCode;
272 272
 		}
273 273
 		return $this->_addEvent($event, $jsCode);
274 274
 	}
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 			if (is_array($this->_events[$event])) {
279 279
 				$this->_events[$event][]=$jsCode;
280 280
 			} else {
281
-				$this->_events[$event]=array ($this->_events[$event],$jsCode );
281
+				$this->_events[$event]=array($this->_events[$event], $jsCode);
282 282
 			}
283 283
 		} else {
284 284
 			$this->_events[$event]=$jsCode;
@@ -300,15 +300,15 @@  discard block
 block discarded – undo
300 300
 
301 301
 	public function addEventsOnRun(JsUtils $js) {
302 302
 		if (isset($this->_bsComponent)) {
303
-			foreach ( $this->_events as $event => $jsCode ) {
303
+			foreach ($this->_events as $event => $jsCode) {
304 304
 				$code=$jsCode;
305 305
 				if (is_array($jsCode)) {
306 306
 					$code="";
307
-					foreach ( $jsCode as $jsC ) {
307
+					foreach ($jsCode as $jsC) {
308 308
 						if ($jsC instanceof AjaxCall) {
309
-							$code.="\n" . $jsC->compile($js);
309
+							$code.="\n".$jsC->compile($js);
310 310
 						} else {
311
-							$code.="\n" . $jsC;
311
+							$code.="\n".$jsC;
312 312
 						}
313 313
 					}
314 314
 				} elseif ($jsCode instanceof AjaxCall) {
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
 				}
317 317
 				$this->_bsComponent->addEvent($event, $code);
318 318
 			}
319
-			$this->_events=array ();
319
+			$this->_events=array();
320 320
 		}
321 321
 	}
322 322
 
323 323
 	public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) {
324
-		$params=array ("url" => $url,"responseElement" => $responseElement );
324
+		$params=array("url" => $url, "responseElement" => $responseElement);
325 325
 		$params=array_merge($params, $parameters);
326 326
 		$this->_addEvent($event, new AjaxCall($operation, $params));
327 327
 		return $this;
@@ -357,33 +357,33 @@  discard block
 block discarded – undo
357 357
 		if (is_array($elements)) {
358 358
 			$flag=false;
359 359
 			$index=0;
360
-			while ( !$flag && $index < sizeof($elements) ) {
360
+			while (!$flag && $index<sizeof($elements)) {
361 361
 				if ($elements[$index] instanceof BaseHtml)
362
-					$flag=($elements[$index]->getIdentifier() === $identifier);
362
+					$flag=($elements[$index]->getIdentifier()===$identifier);
363 363
 				$index++;
364 364
 			}
365
-			if ($flag === true)
366
-				return $elements[$index - 1];
365
+			if ($flag===true)
366
+				return $elements[$index-1];
367 367
 		} elseif ($elements instanceof BaseHtml) {
368
-			if ($elements->getIdentifier() === $identifier)
368
+			if ($elements->getIdentifier()===$identifier)
369 369
 				return $elements;
370 370
 		}
371 371
 		return null;
372 372
 	}
373 373
 
374
-	protected function getElementByPropertyValue($propertyName,$value, $elements) {
374
+	protected function getElementByPropertyValue($propertyName, $value, $elements) {
375 375
 		if (is_array($elements)) {
376 376
 			$flag=false;
377 377
 			$index=0;
378
-			while ( !$flag && $index < sizeof($elements) ) {
378
+			while (!$flag && $index<sizeof($elements)) {
379 379
 				if ($elements[$index] instanceof BaseHtml)
380
-					$flag=($elements[$index]->propertyContains($propertyName, $value) === true);
380
+					$flag=($elements[$index]->propertyContains($propertyName, $value)===true);
381 381
 					$index++;
382 382
 			}
383
-			if ($flag === true)
384
-				return $elements[$index - 1];
383
+			if ($flag===true)
384
+				return $elements[$index-1];
385 385
 		} elseif ($elements instanceof BaseHtml) {
386
-			if ($elements->propertyContains($propertyName, $value) === true)
386
+			if ($elements->propertyContains($propertyName, $value)===true)
387 387
 				return $elements;
388 388
 		}
389 389
 		return null;
@@ -405,14 +405,14 @@  discard block
 block discarded – undo
405 405
 		if (is_array($value)) {
406 406
 			$value=implode(",", $value);
407 407
 		}
408
-		if (strrpos($value, 'this') === false && strrpos($value, 'event') === false) {
409
-			$value='"' . $value . '"';
408
+		if (strrpos($value, 'this')===false && strrpos($value, 'event')===false) {
409
+			$value='"'.$value.'"';
410 410
 		}
411 411
 		return $value;
412 412
 	}
413 413
 
414 414
 	public function jsDoJquery($jqueryCall, $param="") {
415
-		return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . $this->_prep_value($param) . ");";
415
+		return "$('#".$this->identifier."').".$jqueryCall."(".$this->_prep_value($param).");";
416 416
 	}
417 417
 
418 418
 	public function executeOnRun($jsCode) {
Please login to merge, or discard this patch.
Ajax/common/html/HtmlDoubleElement.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 		return $this->content;
28 28
 	}
29 29
 
30
-	public function addContent($content,$before=false) {
30
+	public function addContent($content, $before=false) {
31 31
 		if (is_array($this->content)===false) {
32
-			if(isset($this->content))
33
-				$this->content=array ($this->content);
32
+			if (isset($this->content))
33
+				$this->content=array($this->content);
34 34
 			else
35 35
 				$this->content=array();
36 36
 		}
37
-		if($before)
38
-			array_unshift($this->content,$content);
37
+		if ($before)
38
+			array_unshift($this->content, $content);
39 39
 		else
40 40
 			$this->content []=$content;
41 41
 		return $this;
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		if ($this->content instanceof HtmlDoubleElement) {
51 51
 			$this->content->run($js);
52 52
 		} else if (is_array($this->content)) {
53
-			foreach ( $this->content as $itemContent ) {
53
+			foreach ($this->content as $itemContent) {
54 54
 				if ($itemContent instanceof HtmlDoubleElement) {
55 55
 					$itemContent->run($js);
56 56
 				}
Please login to merge, or discard this patch.
Ajax/service/JString.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,21 +2,21 @@
 block discarded – undo
2 2
 namespace Ajax\service;
3 3
 class JString {
4 4
 
5
-	public static function contains($hay,$needle){
6
-		return strpos($hay, $needle) !== false;
5
+	public static function contains($hay, $needle) {
6
+		return strpos($hay, $needle)!==false;
7 7
 	}
8 8
 	public static function startswith($hay, $needle) {
9
-		return substr($hay, 0, strlen($needle)) === $needle;
9
+		return substr($hay, 0, strlen($needle))===$needle;
10 10
 	}
11 11
 
12 12
 	public static function endswith($hay, $needle) {
13
-		return substr($hay, -strlen($needle)) === $needle;
13
+		return substr($hay, -strlen($needle))===$needle;
14 14
 	}
15 15
 
16
-	public static function isNull($s){
16
+	public static function isNull($s) {
17 17
 		return (!isset($s) || NULL===$s || ""===$s);
18 18
 	}
19
-	public static function isNotNull($s){
19
+	public static function isNotNull($s) {
20 20
 		return (isset($s) && NULL!==$s && ""!==$s);
21 21
 	}
22 22
 }
23 23
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/service/JArray.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 class JArray {
6 6
 
7 7
 	public static function isAssociative($array) {
8
-		return (array_values($array) !== $array);
8
+		return (array_values($array)!==$array);
9 9
 		// return (array_keys($array)!==range(0, count($array)-1));
10 10
 	}
11 11
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 			return $array[$key];
15 15
 		}
16 16
 		$values=array_values($array);
17
-		if ($pos < sizeof($values))
17
+		if ($pos<sizeof($values))
18 18
 			return $values[$pos];
19 19
 	}
20 20
 
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
 		$result=NULL;
23 23
 		if (array_key_exists($key, $array)) {
24 24
 			$result=$array[$key];
25
-			if ($condition($result) === true)
25
+			if ($condition($result)===true)
26 26
 				return $result;
27 27
 		}
28 28
 		$values=array_values($array);
29
-		foreach ( $values as $val ) {
30
-			if ($condition($val) === true)
29
+		foreach ($values as $val) {
30
+			if ($condition($val)===true)
31 31
 				return $val;
32 32
 		}
33 33
 		return $result;
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 		$result="";
45 45
 		if (\is_array($glue)) {
46 46
 			$size=\sizeof($pieces);
47
-			if ($size > 0) {
48
-				for($i=0; $i < $size - 1; $i++) {
49
-					$result.=$pieces[$i] . @$glue[$i];
47
+			if ($size>0) {
48
+				for ($i=0; $i<$size-1; $i++) {
49
+					$result.=$pieces[$i].@$glue[$i];
50 50
 				}
51
-				$result.=$pieces[$size - 1];
51
+				$result.=$pieces[$size-1];
52 52
 			}
53 53
 		} else {
54 54
 			$result=\implode($glue, $pieces);
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
 	public static function dimension($array) {
60 60
 		if (is_array(reset($array))) {
61
-			$return=self::dimension(reset($array)) + 1;
61
+			$return=self::dimension(reset($array))+1;
62 62
 		} else {
63 63
 			$return=1;
64 64
 		}
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 	}
67 67
 
68 68
 	public static function sortAssociative($array, $sortedKeys=array()) {
69
-		$newArray=array ();
70
-		foreach ( $sortedKeys as $key ) {
69
+		$newArray=array();
70
+		foreach ($sortedKeys as $key) {
71 71
 			if (\array_key_exists($key, $array)) {
72 72
 				$newArray[$key]=$array[$key];
73 73
 			}
Please login to merge, or discard this patch.
Ajax/service/AjaxCall.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 		if ($stopPropagation===true) {
31 31
 			$result.="event.stopPropagation();\n";
32 32
 		}
33
-		switch($this->method) {
33
+		switch ($this->method) {
34 34
 			case "get":
35 35
 				$result.=$js->getDeferred($url, $responseElement, $params, $callback, $attr);
36 36
 				break;
Please login to merge, or discard this patch.
Ajax/php/laravel/JsUtils.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -4,24 +4,24 @@  discard block
 block discarded – undo
4 4
 
5 5
 use Illuminate\Support\Facades\App;
6 6
 
7
-class JsUtils extends \Ajax\JsUtils{
8
-	public function getUrl($url){
7
+class JsUtils extends \Ajax\JsUtils {
8
+	public function getUrl($url) {
9 9
 		return \url($url);
10 10
 	}
11
-	public function addViewElement($identifier,$content,&$view){
11
+	public function addViewElement($identifier, $content, &$view) {
12 12
 		$controls=$view->__get("q");
13
-		if (isset($controls) === false) {
14
-			$controls=array ();
13
+		if (isset($controls)===false) {
14
+			$controls=array();
15 15
 		}
16 16
 		$controls[$identifier]=$content;
17 17
 		$view->__set("q", $controls);
18 18
 	}
19 19
 
20
-	public function createScriptVariable(&$view,$view_var, $output){
21
-		$view->__set($view_var,$output);
20
+	public function createScriptVariable(&$view, $view_var, $output) {
21
+		$view->__set($view_var, $output);
22 22
 	}
23 23
 
24
-	public function forward($initialControllerInstance,$controllerName,$actionName,$params=NULL){
24
+	public function forward($initialControllerInstance, $controllerName, $actionName, $params=NULL) {
25 25
 		\ob_start();
26 26
 		App::make($controllerName)->{$actionName}($params);
27 27
 		$result=\ob_get_contents();
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
 		return $result;
30 30
 	}
31 31
 
32
-	public function renderContent($initialControllerInstance,$viewName, $params=NULL) {
33
-		return \view()->make($viewName,$params)->render();
32
+	public function renderContent($initialControllerInstance, $viewName, $params=NULL) {
33
+		return \view()->make($viewName, $params)->render();
34 34
 	}
35 35
 
36
-	public function fromDispatcher($dispatcher){
36
+	public function fromDispatcher($dispatcher) {
37 37
 		return $dispatcher->segments();
38 38
 	}
39 39
 }
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
Ajax/php/symfony/JsUtils.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@  discard block
 block discarded – undo
6 6
 use Symfony\Component\HttpFoundation\Request;
7 7
 use Symfony\Component\HttpKernel\HttpKernelInterface;
8 8
 use Ajax\service\JString;
9
-class JsUtils extends \Ajax\JsUtils{
10
-	public function getUrl($url){
9
+class JsUtils extends \Ajax\JsUtils {
10
+	public function getUrl($url) {
11 11
 		//$request = Request::createFromGlobals();
12 12
 		$router=$this->getInjected();
13
-		if(isset($router)===true){
13
+		if (isset($router)===true) {
14 14
 			try {
15 15
 			$url=$router->generate($url);
16
-			}catch (\Exception $e){
16
+			}catch (\Exception $e) {
17 17
 				return $router->getContext()->getBaseUrl();
18 18
 			}
19 19
 		}
20 20
 		return $url;
21 21
 	}
22
-	public function addViewElement($identifier,$content,&$view){
23
-		if(\array_key_exists("q", $view)===false){
22
+	public function addViewElement($identifier, $content, &$view) {
23
+		if (\array_key_exists("q", $view)===false) {
24 24
 			$view["q"]=array();
25 25
 		}
26 26
 		$view["q"][$identifier]=$content;
27 27
 	}
28 28
 
29
-	public function createScriptVariable(&$view,$view_var, $output){
29
+	public function createScriptVariable(&$view, $view_var, $output) {
30 30
 		$view[$view_var]=$output;
31 31
 	}
32 32
 
@@ -37,17 +37,17 @@  discard block
 block discarded – undo
37 37
 	 * @param array $params
38 38
 	 * @see \Ajax\JsUtils::forward()
39 39
 	 */
40
-	public function forward($initialControllerInstance,$controllerName,$actionName,$params=array()){
40
+	public function forward($initialControllerInstance, $controllerName, $actionName, $params=array()) {
41 41
 		$path=$params;
42
-		$request = $initialControllerInstance->get('request_stack')->getCurrentRequest();
43
-		$path['_forwarded'] = $request->attributes;
44
-		$path['_controller'] = $controllerName.":".$actionName;
45
-		$subRequest = $request->duplicate([], null, $path);
46
-		$response= $initialControllerInstance->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
42
+		$request=$initialControllerInstance->get('request_stack')->getCurrentRequest();
43
+		$path['_forwarded']=$request->attributes;
44
+		$path['_controller']=$controllerName.":".$actionName;
45
+		$subRequest=$request->duplicate([], null, $path);
46
+		$response=$initialControllerInstance->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
47 47
 		return $response->getContent();
48 48
 	}
49 49
 
50
-	public function renderContent($initialControllerInstance,$viewName, $params=NULL) {
50
+	public function renderContent($initialControllerInstance, $viewName, $params=NULL) {
51 51
         if ($initialControllerInstance->has('templating')) {
52 52
             return $initialControllerInstance->get('templating')->render($viewName, $params);
53 53
         }
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
         return $initialControllerInstance->get('twig')->render($viewName, $params);
60 60
 	}
61 61
 
62
-	public function fromDispatcher($dispatcher){
63
-		$request = $dispatcher->get('request_stack')->getCurrentRequest();
62
+	public function fromDispatcher($dispatcher) {
63
+		$request=$dispatcher->get('request_stack')->getCurrentRequest();
64 64
 		$uri=$request->getPathInfo();
65
-		if(JString::startswith($uri, "/")){
65
+		if (JString::startswith($uri, "/")) {
66 66
 			$uri=\substr($uri, 1);
67 67
 		}
68 68
 		return \explode("/", $uri);
Please login to merge, or discard this patch.
Ajax/php/phalcon/JsUtils.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use Phalcon\Mvc\View;
8 8
 use Phalcon\Mvc\Controller;
9 9
 
10
-class JsUtils extends \Ajax\JsUtils implements InjectionAwareInterface{
10
+class JsUtils extends \Ajax\JsUtils implements InjectionAwareInterface {
11 11
 	protected $_di;
12 12
 	public function setDi(DiInterface $di) {
13 13
 		$this->_di=$di;
@@ -18,50 +18,50 @@  discard block
 block discarded – undo
18 18
 		return $this->_di;
19 19
 	}
20 20
 
21
-	public function getUrl($url){
21
+	public function getUrl($url) {
22 22
 		return $this->_di->get("url")->get($url);
23 23
 	}
24 24
 
25
-	public function addViewElement($identifier,$content,&$view){
25
+	public function addViewElement($identifier, $content, &$view) {
26 26
 		$controls=$view->getVar("q");
27
-		if (isset($controls) === false) {
28
-			$controls=array ();
27
+		if (isset($controls)===false) {
28
+			$controls=array();
29 29
 		}
30 30
 		$controls[$identifier]=$content;
31 31
 		$view->setVar("q", $controls);
32 32
 	}
33 33
 
34
-	public function createScriptVariable(&$view,$view_var, $output){
35
-		$view->setVar($view_var,$output);
34
+	public function createScriptVariable(&$view, $view_var, $output) {
35
+		$view->setVar($view_var, $output);
36 36
 	}
37 37
 
38
-	public function forward($initialController,$controller,$action,$params=array()){
39
-		$dispatcher = $initialController->dispatcher;
38
+	public function forward($initialController, $controller, $action, $params=array()) {
39
+		$dispatcher=$initialController->dispatcher;
40 40
 		$dispatcher->setControllerName($controller);
41 41
 		$dispatcher->setActionName($action);
42 42
 		$dispatcher->dispatch();
43
-		$template=$initialController->view->getRender($dispatcher->getControllerName(), $dispatcher->getActionName(),$dispatcher->getParams(), function ($view) {
43
+		$template=$initialController->view->getRender($dispatcher->getControllerName(), $dispatcher->getActionName(), $dispatcher->getParams(), function($view) {
44 44
 			$view->setRenderLevel(View::LEVEL_ACTION_VIEW);
45 45
 		});
46 46
 		return $template;
47 47
 	}
48 48
 
49
-	public function renderContent($initialControllerInstance,$viewName, $params=NULL) {
50
-		list($controller,$action)=\explode("@", $viewName);
51
-		$template=$initialControllerInstance->view->getRender($controller, $action, $params, function ($view) {
49
+	public function renderContent($initialControllerInstance, $viewName, $params=NULL) {
50
+		list($controller, $action)=\explode("@", $viewName);
51
+		$template=$initialControllerInstance->view->getRender($controller, $action, $params, function($view) {
52 52
 			$view->setRenderLevel(View::LEVEL_ACTION_VIEW);
53 53
 		});
54 54
 		return $template;
55 55
 	}
56 56
 
57
-	public function fromDispatcher($dispatcher){
57
+	public function fromDispatcher($dispatcher) {
58 58
 		$params=$dispatcher->getParams();
59 59
 		$action=$dispatcher->getActionName();
60 60
 		$items=array($dispatcher->getControllerName());
61
-		if(\sizeof($params)>0 || \strtolower($action)!="index" ){
61
+		if (\sizeof($params)>0 || \strtolower($action)!="index") {
62 62
 			$items[]=$action;
63
-			foreach ($params as $p){
64
-				if(\is_object($p)===false)
63
+			foreach ($params as $p) {
64
+				if (\is_object($p)===false)
65 65
 					$items[]=$p;
66 66
 			}
67 67
 		}
Please login to merge, or discard this patch.
Ajax/php/yii/URI.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 	 * @access public
11 11
 	 *
12 12
 	 */
13
-	var $keyval=array ();
13
+	var $keyval=array();
14 14
 	/**
15 15
 	 * Current uri string
16 16
 	 *
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @access public
27 27
 	 *
28 28
 	 */
29
-	var $segments=array ();
29
+	var $segments=array();
30 30
 	/**
31 31
 	 * Re-indexed list of uri segments
32 32
 	 * Starts at 1 instead of 0
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @access public
36 36
 	 *
37 37
 	 */
38
-	var $rsegments=array ();
38
+	var $rsegments=array();
39 39
 	var $permitted_uri_chars="a-z 0-9~%.:_\-";
40 40
 	var $enable_query_strings=false;
41 41
 
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	function _fetch_uri_string() {
77 77
 		$uri="";
78
-		if ($this->uri_protocol == 'AUTO') {
78
+		if ($this->uri_protocol=='AUTO') {
79 79
 			// Is the request coming from the command line?
80
-			if (php_sapi_name() == 'cli' or defined('STDIN')) {
80
+			if (php_sapi_name()=='cli' or defined('STDIN')) {
81 81
 				$this->_set_uri_string($this->_parse_cli_args());
82 82
 				return;
83 83
 			}
@@ -91,20 +91,20 @@  discard block
 block discarded – undo
91 91
 			// Is there a PATH_INFO variable?
92 92
 			// Note: some servers seem to have trouble with getenv() so we'll test it two ways
93 93
 			$path=(isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
94
-			if (trim($path, '/') != '' && $path != "/" . SELF) {
94
+			if (trim($path, '/')!='' && $path!="/".SELF) {
95 95
 				$this->_set_uri_string($path);
96 96
 				return;
97 97
 			}
98 98
 
99 99
 			// No PATH_INFO?... What about QUERY_STRING?
100 100
 			$path=(isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
101
-			if (trim($path, '/') != '') {
101
+			if (trim($path, '/')!='') {
102 102
 				$this->_set_uri_string($path);
103 103
 				return;
104 104
 			}
105 105
 
106 106
 			// As a last ditch effort lets try using the $_GET array
107
-			if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '') {
107
+			if (is_array($_GET) && count($_GET)==1 && trim(key($_GET), '/')!='') {
108 108
 				$this->_set_uri_string(key($_GET));
109 109
 				return;
110 110
 			}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 			return;
115 115
 		}
116 116
 
117
-		if ($uri == 'REQUEST_URI') {
117
+		if ($uri=='REQUEST_URI') {
118 118
 			$this->_set_uri_string($this->_detect_uri());
119 119
 			return;
120 120
 		}
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		// $str = remove_invisible_characters($str, FALSE);
139 139
 
140 140
 		// If the URI contains only a slash we'll kill it
141
-		$this->uri_string=($str == '/') ? '' : $str;
141
+		$this->uri_string=($str=='/') ? '' : $str;
142 142
 	}
143 143
 
144 144
 	// --------------------------------------------------------------------
@@ -159,15 +159,15 @@  discard block
 block discarded – undo
159 159
 		}
160 160
 
161 161
 		$uri=$_SERVER['REQUEST_URI'];
162
-		if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) {
162
+		if (strpos($uri, $_SERVER['SCRIPT_NAME'])===0) {
163 163
 			$uri=substr($uri, strlen($_SERVER['SCRIPT_NAME']));
164
-		} elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) {
164
+		} elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME']))===0) {
165 165
 			$uri=substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
166 166
 		}
167 167
 
168 168
 		// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
169 169
 		// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
170
-		if (strncmp($uri, '?/', 2) === 0) {
170
+		if (strncmp($uri, '?/', 2)===0) {
171 171
 			$uri=substr($uri, 2);
172 172
 		}
173 173
 		$parts=preg_split('#\?#i', $uri, 2);
@@ -177,17 +177,17 @@  discard block
 block discarded – undo
177 177
 			parse_str($_SERVER['QUERY_STRING'], $_GET);
178 178
 		} else {
179 179
 			$_SERVER['QUERY_STRING']='';
180
-			$_GET=array ();
180
+			$_GET=array();
181 181
 		}
182 182
 
183
-		if ($uri == '/' || empty($uri)) {
183
+		if ($uri=='/' || empty($uri)) {
184 184
 			return '/';
185 185
 		}
186 186
 
187 187
 		$uri=parse_url($uri, PHP_URL_PATH);
188 188
 
189 189
 		// Do some final cleaning of the URI and return it
190
-		return str_replace(array ('//','../' ), '/', trim($uri, '/'));
190
+		return str_replace(array('//', '../'), '/', trim($uri, '/'));
191 191
 	}
192 192
 
193 193
 	// --------------------------------------------------------------------
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	private function _parse_cli_args() {
205 205
 		$args=array_slice($_SERVER['argv'], 1);
206 206
 
207
-		return $args ? '/' . implode('/', $args) : '';
207
+		return $args ? '/'.implode('/', $args) : '';
208 208
 	}
209 209
 
210 210
 	// --------------------------------------------------------------------
@@ -218,17 +218,17 @@  discard block
 block discarded – undo
218 218
 	 *
219 219
 	 */
220 220
 	function _filter_uri($str) {
221
-		if ($str != '' && $this->permitted_uri_chars != '' && $this->enable_query_strings == FALSE) {
221
+		if ($str!='' && $this->permitted_uri_chars!='' && $this->enable_query_strings==FALSE) {
222 222
 			// preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards
223 223
 			// compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern
224
-			if (!preg_match("|^[" . str_replace(array ('\\-','\-' ), '-', preg_quote($this->permitted_uri_chars, '-')) . "]+$|i", $str)) {
224
+			if (!preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->permitted_uri_chars, '-'))."]+$|i", $str)) {
225 225
 				show_error('The URI you submitted has disallowed characters.', 400);
226 226
 			}
227 227
 		}
228 228
 
229 229
 		// Convert programatic characters to entities
230
-		$bad=array ('$','(',')','%28','%29' );
231
-		$good=array ('&#36;','&#40;','&#41;','&#40;','&#41;' );
230
+		$bad=array('$', '(', ')', '%28', '%29');
231
+		$good=array('&#36;', '&#40;', '&#41;', '&#40;', '&#41;');
232 232
 
233 233
 		return str_replace($bad, $good, $str);
234 234
 	}
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
 	 *
244 244
 	 */
245 245
 	function _explode_segments() {
246
-		foreach ( explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val ) {
246
+		foreach (explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val) {
247 247
 			// Filter segments for security
248 248
 			$val=trim($this->_filter_uri($val));
249 249
 
250
-			if ($val != '') {
250
+			if ($val!='') {
251 251
 				$this->segments[]=$val;
252 252
 			}
253 253
 		}
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	 *
365 365
 	 */
366 366
 	function _uri_to_assoc($n=3, $default=array(), $which='segment') {
367
-		if ($which == 'segment') {
367
+		if ($which=='segment') {
368 368
 			$total_segments='total_segments';
369 369
 			$segment_array='segment_array';
370 370
 		} else {
@@ -380,25 +380,25 @@  discard block
 block discarded – undo
380 380
 			return $this->keyval[$n];
381 381
 		}
382 382
 
383
-		if ($this->$total_segments() < $n) {
384
-			if (count($default) == 0) {
385
-				return array ();
383
+		if ($this->$total_segments()<$n) {
384
+			if (count($default)==0) {
385
+				return array();
386 386
 			}
387 387
 
388
-			$retval=array ();
389
-			foreach ( $default as $val ) {
388
+			$retval=array();
389
+			foreach ($default as $val) {
390 390
 				$retval[$val]=FALSE;
391 391
 			}
392 392
 			return $retval;
393 393
 		}
394 394
 
395
-		$segments=array_slice($this->$segment_array(), ($n - 1));
395
+		$segments=array_slice($this->$segment_array(), ($n-1));
396 396
 
397 397
 		$i=0;
398 398
 		$lastval='';
399
-		$retval=array ();
400
-		foreach ( $segments as $seg ) {
401
-			if ($i % 2) {
399
+		$retval=array();
400
+		foreach ($segments as $seg) {
401
+			if ($i%2) {
402 402
 				$retval[$lastval]=$seg;
403 403
 			} else {
404 404
 				$retval[$seg]=FALSE;
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 			$i++;
409 409
 		}
410 410
 
411
-		if (count($default) > 0) {
412
-			foreach ( $default as $val ) {
411
+		if (count($default)>0) {
412
+			foreach ($default as $val) {
413 413
 				if (!array_key_exists($val, $retval)) {
414 414
 					$retval[$val]=FALSE;
415 415
 				}
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 	 *
434 434
 	 */
435 435
 	function assoc_to_uri($array) {
436
-		$temp=array ();
437
-		foreach ( ( array ) $array as $key => $val ) {
436
+		$temp=array();
437
+		foreach ((array)$array as $key => $val) {
438 438
 			$temp[]=$key;
439 439
 			$temp[]=$val;
440 440
 		}
@@ -488,13 +488,13 @@  discard block
 block discarded – undo
488 488
 		$leading='/';
489 489
 		$trailing='/';
490 490
 
491
-		if ($where == 'trailing') {
491
+		if ($where=='trailing') {
492 492
 			$leading='';
493
-		} elseif ($where == 'leading') {
493
+		} elseif ($where=='leading') {
494 494
 			$trailing='';
495 495
 		}
496 496
 
497
-		return $leading . $this->$which($n) . $trailing;
497
+		return $leading.$this->$which($n).$trailing;
498 498
 	}
499 499
 
500 500
 	// --------------------------------------------------------------------
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 	 *
573 573
 	 */
574 574
 	function ruri_string() {
575
-		return '/' . implode('/', $this->rsegment_array());
575
+		return '/'.implode('/', $this->rsegment_array());
576 576
 	}
577 577
 }
578 578
 // END URI Class
579 579
\ No newline at end of file
Please login to merge, or discard this patch.