Passed
Branch php-cs-fixer (b9836a)
by Fabio
15:58
created
framework/Web/UI/TTemplate.php 2 patches
Spacing   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -192,38 +192,38 @@  discard block
 block discarded – undo
192 192
 	public function instantiateIn($tplControl, $parentControl = null)
193 193
 	{
194 194
 		$this->_tplControl = $tplControl;
195
-		if($parentControl === null)
195
+		if ($parentControl === null)
196 196
 			$parentControl = $tplControl;
197
-		if(($page = $tplControl->getPage()) === null)
197
+		if (($page = $tplControl->getPage()) === null)
198 198
 			$page = $this->getService()->getRequestedPage();
199 199
 		$controls = [];
200 200
 		$directChildren = [];
201
-		foreach($this->_tpl as $key => $object)
201
+		foreach ($this->_tpl as $key => $object)
202 202
 		{
203
-			if($object[0] === -1)
203
+			if ($object[0] === -1)
204 204
 				$parent = $parentControl;
205
-			elseif(isset($controls[$object[0]]))
205
+			elseif (isset($controls[$object[0]]))
206 206
 				$parent = $controls[$object[0]];
207 207
 			else
208 208
 				continue;
209
-			if(isset($object[2]))	// component
209
+			if (isset($object[2]))	// component
210 210
 			{
211 211
 				$component = Prado::createComponent($object[1]);
212 212
 				$properties = &$object[2];
213
-				if($component instanceof TControl)
213
+				if ($component instanceof TControl)
214 214
 				{
215
-					if($component instanceof \Prado\Web\UI\WebControls\TOutputCache)
216
-						$component->setCacheKeyPrefix($this->_hashCode . $key);
215
+					if ($component instanceof \Prado\Web\UI\WebControls\TOutputCache)
216
+						$component->setCacheKeyPrefix($this->_hashCode.$key);
217 217
 					$component->setTemplateControl($tplControl);
218
-					if(isset($properties['id']))
218
+					if (isset($properties['id']))
219 219
 					{
220
-						if(is_array($properties['id']))
220
+						if (is_array($properties['id']))
221 221
 							$properties['id'] = $component->evaluateExpression($properties['id'][1]);
222 222
 						$tplControl->registerObject($properties['id'], $component);
223 223
 					}
224
-					if(isset($properties['skinid']))
224
+					if (isset($properties['skinid']))
225 225
 					{
226
-						if(is_array($properties['skinid']))
226
+						if (is_array($properties['skinid']))
227 227
 							$component->setSkinID($component->evaluateExpression($properties['skinid'][1]));
228 228
 						else
229 229
 							$component->setSkinID($properties['skinid']);
@@ -233,32 +233,32 @@  discard block
 block discarded – undo
233 233
 					$component->trackViewState(false);
234 234
 
235 235
 					$component->applyStyleSheetSkin($page);
236
-					foreach($properties as $name => $value)
236
+					foreach ($properties as $name => $value)
237 237
 						$this->configureControl($component, $name, $value);
238 238
 
239 239
 					$component->trackViewState(true);
240 240
 
241
-					if($parent === $parentControl)
241
+					if ($parent === $parentControl)
242 242
 						$directChildren[] = $component;
243 243
 					else
244 244
 						$component->createdOnTemplate($parent);
245
-					if($component->getAllowChildControls())
245
+					if ($component->getAllowChildControls())
246 246
 						$controls[$key] = $component;
247 247
 				}
248
-				elseif($component instanceof TComponent)
248
+				elseif ($component instanceof TComponent)
249 249
 				{
250 250
 					$controls[$key] = $component;
251
-					if(isset($properties['id']))
251
+					if (isset($properties['id']))
252 252
 					{
253
-						if(is_array($properties['id']))
253
+						if (is_array($properties['id']))
254 254
 							$properties['id'] = $component->evaluateExpression($properties['id'][1]);
255 255
 						$tplControl->registerObject($properties['id'], $component);
256
-						if(!$component->hasProperty('id'))
256
+						if (!$component->hasProperty('id'))
257 257
 							unset($properties['id']);
258 258
 					}
259
-					foreach($properties as $name => $value)
259
+					foreach ($properties as $name => $value)
260 260
 						$this->configureComponent($component, $name, $value);
261
-					if($parent === $parentControl)
261
+					if ($parent === $parentControl)
262 262
 						$directChildren[] = $component;
263 263
 					else
264 264
 						$component->createdOnTemplate($parent);
@@ -266,19 +266,19 @@  discard block
 block discarded – undo
266 266
 			}
267 267
 			else
268 268
 			{
269
-				if($object[1] instanceof TCompositeLiteral)
269
+				if ($object[1] instanceof TCompositeLiteral)
270 270
 				{
271 271
 					// need to clone a new object because the one in template is reused
272 272
 					$o = clone $object[1];
273 273
 					$o->setContainer($tplControl);
274
-					if($parent === $parentControl)
274
+					if ($parent === $parentControl)
275 275
 						$directChildren[] = $o;
276 276
 					else
277 277
 						$parent->addParsedObject($o);
278 278
 				}
279 279
 				else
280 280
 				{
281
-					if($parent === $parentControl)
281
+					if ($parent === $parentControl)
282 282
 						$directChildren[] = $object[1];
283 283
 					else
284 284
 						$parent->addParsedObject($object[1]);
@@ -288,9 +288,9 @@  discard block
 block discarded – undo
288 288
 		// delay setting parent till now because the parent may cause
289 289
 		// the child to do lifecycle catchup which may cause problem
290 290
 		// if the child needs its own child controls.
291
-		foreach($directChildren as $control)
291
+		foreach ($directChildren as $control)
292 292
 		{
293
-			if($control instanceof TComponent)
293
+			if ($control instanceof TComponent)
294 294
 				$control->createdOnTemplate($parentControl);
295 295
 			else
296 296
 				$parentControl->addParsedObject($control);
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
 	 */
306 306
 	protected function configureControl($control, $name, $value)
307 307
 	{
308
-		if(strncasecmp($name, 'on', 2) === 0)		// is an event
308
+		if (strncasecmp($name, 'on', 2) === 0)		// is an event
309 309
 			$this->configureEvent($control, $name, $value, $control);
310
-		elseif(($pos = strrpos($name, '.')) === false)	// is a simple property or custom attribute
310
+		elseif (($pos = strrpos($name, '.')) === false)	// is a simple property or custom attribute
311 311
 			$this->configureProperty($control, $name, $value);
312 312
 		else	// is a subproperty
313 313
 			$this->configureSubProperty($control, $name, $value);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 	 */
322 322
 	protected function configureComponent($component, $name, $value)
323 323
 	{
324
-		if(strpos($name, '.') === false)	// is a simple property or custom attribute
324
+		if (strpos($name, '.') === false)	// is a simple property or custom attribute
325 325
 			$this->configureProperty($component, $name, $value);
326 326
 		else	// is a subproperty
327 327
 			$this->configureSubProperty($component, $name, $value);
@@ -336,10 +336,10 @@  discard block
 block discarded – undo
336 336
 	 */
337 337
 	protected function configureEvent($control, $name, $value, $contextControl)
338 338
 	{
339
-		if(strpos($value, '.') === false)
340
-			$control->attachEventHandler($name, [$contextControl,'TemplateControl.' . $value]);
339
+		if (strpos($value, '.') === false)
340
+			$control->attachEventHandler($name, [$contextControl, 'TemplateControl.'.$value]);
341 341
 		else
342
-			$control->attachEventHandler($name, [$contextControl,$value]);
342
+			$control->attachEventHandler($name, [$contextControl, $value]);
343 343
 	}
344 344
 
345 345
 	/**
@@ -350,37 +350,37 @@  discard block
 block discarded – undo
350 350
 	 */
351 351
 	protected function configureProperty($component, $name, $value)
352 352
 	{
353
-		if(is_array($value))
353
+		if (is_array($value))
354 354
 		{
355
-			switch($value[0])
355
+			switch ($value[0])
356 356
 			{
357 357
 				case self::CONFIG_DATABIND:
358 358
 					$component->bindProperty($name, $value[1]);
359 359
 					break;
360 360
 				case self::CONFIG_EXPRESSION:
361
-					if($component instanceof TControl)
361
+					if ($component instanceof TControl)
362 362
 						$component->autoBindProperty($name, $value[1]);
363 363
 					else
364 364
 					{
365
-						$setter = 'set' . $name;
365
+						$setter = 'set'.$name;
366 366
 						$component->$setter($this->_tplControl->evaluateExpression($value[1]));
367 367
 					}
368 368
 					break;
369 369
 				case self::CONFIG_TEMPLATE:
370
-					$setter = 'set' . $name;
370
+					$setter = 'set'.$name;
371 371
 					$component->$setter($value[1]);
372 372
 					break;
373 373
 				case self::CONFIG_ASSET:		// asset URL
374
-					$setter = 'set' . $name;
375
-					$url = $this->publishFilePath($this->_contextPath . DIRECTORY_SEPARATOR . $value[1]);
374
+					$setter = 'set'.$name;
375
+					$url = $this->publishFilePath($this->_contextPath.DIRECTORY_SEPARATOR.$value[1]);
376 376
 					$component->$setter($url);
377 377
 					break;
378 378
 				case self::CONFIG_PARAMETER:		// application parameter
379
-					$setter = 'set' . $name;
379
+					$setter = 'set'.$name;
380 380
 					$component->$setter($this->getApplication()->getParameters()->itemAt($value[1]));
381 381
 					break;
382 382
 				case self::CONFIG_LOCALIZATION:
383
-					$setter = 'set' . $name;
383
+					$setter = 'set'.$name;
384 384
 					$component->$setter(Prado::localize($value[1]));
385 385
 					break;
386 386
 				default:	// an error if reaching here
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 			if (substr($name, 0, 2) == 'js')
394 394
 				if ($value and !($value instanceof TJavaScriptLiteral))
395 395
 					$value = new TJavaScriptLiteral($value);
396
-			$setter = 'set' . $name;
396
+			$setter = 'set'.$name;
397 397
 			$component->$setter($value);
398 398
 		}
399 399
 	}
@@ -406,15 +406,15 @@  discard block
 block discarded – undo
406 406
 	 */
407 407
 	protected function configureSubProperty($component, $name, $value)
408 408
 	{
409
-		if(is_array($value))
409
+		if (is_array($value))
410 410
 		{
411
-			switch($value[0])
411
+			switch ($value[0])
412 412
 			{
413 413
 				case self::CONFIG_DATABIND:		// databinding
414 414
 					$component->bindProperty($name, $value[1]);
415 415
 					break;
416 416
 				case self::CONFIG_EXPRESSION:		// expression
417
-					if($component instanceof TControl)
417
+					if ($component instanceof TControl)
418 418
 						$component->autoBindProperty($name, $value[1]);
419 419
 					else
420 420
 						$component->setSubProperty($name, $this->_tplControl->evaluateExpression($value[1]));
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 					$component->setSubProperty($name, $value[1]);
424 424
 					break;
425 425
 				case self::CONFIG_ASSET:		// asset URL
426
-					$url = $this->publishFilePath($this->_contextPath . DIRECTORY_SEPARATOR . $value[1]);
426
+					$url = $this->publishFilePath($this->_contextPath.DIRECTORY_SEPARATOR.$value[1]);
427 427
 					$component->setSubProperty($name, $url);
428 428
 					break;
429 429
 				case self::CONFIG_PARAMETER:		// application parameter
@@ -476,105 +476,105 @@  discard block
 block discarded – undo
476 476
 		$this->_directive = null;
477 477
 		try
478 478
 		{
479
-			for($i = 0;$i < $n;++$i)
479
+			for ($i = 0; $i < $n; ++$i)
480 480
 			{
481 481
 				$match = &$matches[$i];
482 482
 				$str = $match[0][0];
483 483
 				$matchStart = $match[0][1];
484 484
 				$matchEnd = $matchStart + strlen($str) - 1;
485
-				if(strpos($str, '<com:') === 0)	// opening component tag
485
+				if (strpos($str, '<com:') === 0)	// opening component tag
486 486
 				{
487
-					if($expectPropEnd)
487
+					if ($expectPropEnd)
488 488
 						continue;
489
-					if($matchStart > $textStart)
490
-						$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
489
+					if ($matchStart > $textStart)
490
+						$tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)];
491 491
 					$textStart = $matchEnd + 1;
492 492
 					$type = $match[1][0];
493 493
 					$attributes = $this->parseAttributes($match[2][0], $match[2][1]);
494 494
 					$class = $this->validateAttributes($type, $attributes);
495
-					$tpl[$c++] = [$container,$class,$attributes];
496
-					if($str[strlen($str) - 2] !== '/')  // open tag
495
+					$tpl[$c++] = [$container, $class, $attributes];
496
+					if ($str[strlen($str) - 2] !== '/')  // open tag
497 497
 					{
498 498
 						$stack[] = $type;
499 499
 						$container = $c - 1;
500 500
 					}
501 501
 				}
502
-				elseif(strpos($str, '</com:') === 0)	// closing component tag
502
+				elseif (strpos($str, '</com:') === 0)	// closing component tag
503 503
 				{
504
-					if($expectPropEnd)
504
+					if ($expectPropEnd)
505 505
 						continue;
506
-					if($matchStart > $textStart)
507
-						$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
506
+					if ($matchStart > $textStart)
507
+						$tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)];
508 508
 					$textStart = $matchEnd + 1;
509 509
 					$type = $match[1][0];
510 510
 
511
-					if(empty($stack))
511
+					if (empty($stack))
512 512
 						throw new TConfigurationException('template_closingtag_unexpected', "</com:$type>");
513 513
 
514 514
 					$name = array_pop($stack);
515
-					if($name !== $type)
515
+					if ($name !== $type)
516 516
 					{
517
-						$tag = $name[0] === '@' ? '</prop:' . substr($name, 1) . '>' : "</com:$name>";
517
+						$tag = $name[0] === '@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>";
518 518
 						throw new TConfigurationException('template_closingtag_expected', $tag, "</com:$type>");
519 519
 					}
520 520
 					$container = $tpl[$container][0];
521 521
 				}
522
-				elseif(strpos($str, '<%@') === 0)	// directive
522
+				elseif (strpos($str, '<%@') === 0)	// directive
523 523
 				{
524
-					if($expectPropEnd)
524
+					if ($expectPropEnd)
525 525
 						continue;
526
-					if($matchStart > $textStart)
527
-						$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
526
+					if ($matchStart > $textStart)
527
+						$tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)];
528 528
 					$textStart = $matchEnd + 1;
529
-					if(isset($tpl[0]) || $this->_directive !== null)
529
+					if (isset($tpl[0]) || $this->_directive !== null)
530 530
 						throw new TConfigurationException('template_directive_nonunique');
531 531
 					$this->_directive = $this->parseAttributes($match[4][0], $match[4][1]);
532 532
 				}
533
-				elseif(strpos($str, '<%') === 0)	// expression
533
+				elseif (strpos($str, '<%') === 0)	// expression
534 534
 				{
535
-					if($expectPropEnd)
535
+					if ($expectPropEnd)
536 536
 						continue;
537
-					if($matchStart > $textStart)
538
-						$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
537
+					if ($matchStart > $textStart)
538
+						$tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)];
539 539
 					$textStart = $matchEnd + 1;
540 540
 					$literal = trim($match[5][0]);
541
-					if($str[2] === '=')	// expression
542
-						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,$literal]];
543
-					elseif($str[2] === '%')  // statements
544
-						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_STATEMENTS,$literal]];
545
-					elseif($str[2] === '#')
546
-						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_DATABINDING,$literal]];
547
-					elseif($str[2] === '$')
548
-						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')"]];
549
-					elseif($str[2] === '~')
550
-						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')"]];
551
-					elseif($str[2] === '/')
552
-						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"]];
553
-					elseif($str[2] === '[')
541
+					if ($str[2] === '=')	// expression
542
+						$tpl[$c++] = [$container, [TCompositeLiteral::TYPE_EXPRESSION, $literal]];
543
+					elseif ($str[2] === '%')  // statements
544
+						$tpl[$c++] = [$container, [TCompositeLiteral::TYPE_STATEMENTS, $literal]];
545
+					elseif ($str[2] === '#')
546
+						$tpl[$c++] = [$container, [TCompositeLiteral::TYPE_DATABINDING, $literal]];
547
+					elseif ($str[2] === '$')
548
+						$tpl[$c++] = [$container, [TCompositeLiteral::TYPE_EXPRESSION, "\$this->getApplication()->getParameters()->itemAt('$literal')"]];
549
+					elseif ($str[2] === '~')
550
+						$tpl[$c++] = [$container, [TCompositeLiteral::TYPE_EXPRESSION, "\$this->publishFilePath('$this->_contextPath/$literal')"]];
551
+					elseif ($str[2] === '/')
552
+						$tpl[$c++] = [$container, [TCompositeLiteral::TYPE_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"]];
553
+					elseif ($str[2] === '[')
554 554
 					{
555
-						$literal = strtr(trim(substr($literal, 0, strlen($literal) - 1)), ["'" => "\'","\\" => "\\\\"]);
556
-						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')"]];
555
+						$literal = strtr(trim(substr($literal, 0, strlen($literal) - 1)), ["'" => "\'", "\\" => "\\\\"]);
556
+						$tpl[$c++] = [$container, [TCompositeLiteral::TYPE_EXPRESSION, "Prado::localize('$literal')"]];
557 557
 					}
558 558
 				}
559
-				elseif(strpos($str, '<prop:') === 0)	// opening property
559
+				elseif (strpos($str, '<prop:') === 0)	// opening property
560 560
 				{
561
-					if(strrpos($str, '/>') === strlen($str) - 2)  //subproperties
561
+					if (strrpos($str, '/>') === strlen($str) - 2)  //subproperties
562 562
 					{
563
-						if($expectPropEnd)
563
+						if ($expectPropEnd)
564 564
 							continue;
565
-						if($matchStart > $textStart)
566
-							$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
565
+						if ($matchStart > $textStart)
566
+							$tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)];
567 567
 						$textStart = $matchEnd + 1;
568 568
 						$prop = strtolower($match[6][0]);
569 569
 						$attrs = $this->parseAttributes($match[7][0], $match[7][1]);
570 570
 						$attributes = [];
571
-						foreach($attrs as $name => $value)
572
-							$attributes[$prop . '.' . $name] = $value;
571
+						foreach ($attrs as $name => $value)
572
+							$attributes[$prop.'.'.$name] = $value;
573 573
 						$type = $tpl[$container][1];
574 574
 						$this->validateAttributes($type, $attributes);
575
-						foreach($attributes as $name => $value)
575
+						foreach ($attributes as $name => $value)
576 576
 						{
577
-							if(isset($tpl[$container][2][$name]))
577
+							if (isset($tpl[$container][2][$name]))
578 578
 								throw new TConfigurationException('template_property_duplicated', $name);
579 579
 							$tpl[$container][2][$name] = $value;
580 580
 						}
@@ -582,41 +582,41 @@  discard block
 block discarded – undo
582 582
 					else  // regular property
583 583
 					{
584 584
 						$prop = strtolower($match[3][0]);
585
-						$stack[] = '@' . $prop;
586
-						if(!$expectPropEnd)
585
+						$stack[] = '@'.$prop;
586
+						if (!$expectPropEnd)
587 587
 						{
588
-							if($matchStart > $textStart)
589
-								$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
588
+							if ($matchStart > $textStart)
589
+								$tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)];
590 590
 							$textStart = $matchEnd + 1;
591 591
 							$expectPropEnd = true;
592 592
 						}
593 593
 					}
594 594
 				}
595
-				elseif(strpos($str, '</prop:') === 0)	// closing property
595
+				elseif (strpos($str, '</prop:') === 0)	// closing property
596 596
 				{
597 597
 					$prop = strtolower($match[3][0]);
598
-					if(empty($stack))
598
+					if (empty($stack))
599 599
 						throw new TConfigurationException('template_closingtag_unexpected', "</prop:$prop>");
600 600
 					$name = array_pop($stack);
601
-					if($name !== '@' . $prop)
601
+					if ($name !== '@'.$prop)
602 602
 					{
603
-						$tag = $name[0] === '@' ? '</prop:' . substr($name, 1) . '>' : "</com:$name>";
603
+						$tag = $name[0] === '@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>";
604 604
 						throw new TConfigurationException('template_closingtag_expected', $tag, "</prop:$prop>");
605 605
 					}
606
-					if(($last = count($stack)) < 1 || $stack[$last - 1][0] !== '@')
606
+					if (($last = count($stack)) < 1 || $stack[$last - 1][0] !== '@')
607 607
 					{
608
-						if($matchStart > $textStart)
608
+						if ($matchStart > $textStart)
609 609
 						{
610 610
 							$value = substr($input, $textStart, $matchStart - $textStart);
611
-							if(substr($prop, -8, 8) === 'template')
611
+							if (substr($prop, -8, 8) === 'template')
612 612
 								$value = $this->parseTemplateProperty($value, $textStart);
613 613
 							else
614 614
 								$value = $this->parseAttribute($value);
615
-							if($container >= 0)
615
+							if ($container >= 0)
616 616
 							{
617 617
 								$type = $tpl[$container][1];
618 618
 								$this->validateAttributes($type, [$prop => $value]);
619
-								if(isset($tpl[$container][2][$prop]))
619
+								if (isset($tpl[$container][2][$prop]))
620 620
 									throw new TConfigurationException('template_property_duplicated', $prop);
621 621
 								$tpl[$container][2][$prop] = $value;
622 622
 							}
@@ -627,56 +627,56 @@  discard block
 block discarded – undo
627 627
 						$expectPropEnd = false;
628 628
 					}
629 629
 				}
630
-				elseif(strpos($str, '<!--') === 0)	// comments
630
+				elseif (strpos($str, '<!--') === 0)	// comments
631 631
 				{
632
-					if($expectPropEnd)
632
+					if ($expectPropEnd)
633 633
 						throw new TConfigurationException('template_comments_forbidden');
634
-					if($matchStart > $textStart)
635
-						$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
634
+					if ($matchStart > $textStart)
635
+						$tpl[$c++] = [$container, substr($input, $textStart, $matchStart - $textStart)];
636 636
 					$textStart = $matchEnd + 1;
637 637
 				}
638 638
 				else
639 639
 					throw new TConfigurationException('template_matching_unexpected', $match);
640 640
 			}
641
-			if(!empty($stack))
641
+			if (!empty($stack))
642 642
 			{
643 643
 				$name = array_pop($stack);
644
-				$tag = $name[0] === '@' ? '</prop:' . substr($name, 1) . '>' : "</com:$name>";
644
+				$tag = $name[0] === '@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>";
645 645
 				throw new TConfigurationException('template_closingtag_expected', $tag, "nothing");
646 646
 			}
647
-			if($textStart < strlen($input))
648
-				$tpl[$c++] = [$container,substr($input, $textStart)];
647
+			if ($textStart < strlen($input))
648
+				$tpl[$c++] = [$container, substr($input, $textStart)];
649 649
 		}
650
-		catch(\Exception $e)
650
+		catch (\Exception $e)
651 651
 		{
652
-			if(($e instanceof TException) && ($e instanceof TTemplateException))
652
+			if (($e instanceof TException) && ($e instanceof TTemplateException))
653 653
 				throw $e;
654
-			if($matchEnd === 0)
654
+			if ($matchEnd === 0)
655 655
 				$line = $this->_startingLine + 1;
656 656
 			else
657 657
 				$line = $this->_startingLine + count(explode("\n", substr($input, 0, $matchEnd + 1)));
658 658
 			$this->handleException($e, $line, $input);
659 659
 		}
660 660
 
661
-		if($this->_directive === null)
661
+		if ($this->_directive === null)
662 662
 			$this->_directive = [];
663 663
 
664 664
 		// optimization by merging consecutive strings, expressions, statements and bindings
665 665
 		$objects = [];
666 666
 		$parent = null;
667 667
 		$merged = [];
668
-		foreach($tpl as $id => $object)
668
+		foreach ($tpl as $id => $object)
669 669
 		{
670
-			if(isset($object[2]) || $object[0] !== $parent)
670
+			if (isset($object[2]) || $object[0] !== $parent)
671 671
 			{
672
-				if($parent !== null)
672
+				if ($parent !== null)
673 673
 				{
674
-					if(count($merged[1]) === 1 && is_string($merged[1][0]))
675
-						$objects[$id - 1] = [$merged[0],$merged[1][0]];
674
+					if (count($merged[1]) === 1 && is_string($merged[1][0]))
675
+						$objects[$id - 1] = [$merged[0], $merged[1][0]];
676 676
 					else
677
-						$objects[$id - 1] = [$merged[0],new TCompositeLiteral($merged[1])];
677
+						$objects[$id - 1] = [$merged[0], new TCompositeLiteral($merged[1])];
678 678
 				}
679
-				if(isset($object[2]))
679
+				if (isset($object[2]))
680 680
 				{
681 681
 					$parent = null;
682 682
 					$objects[$id] = $object;
@@ -684,18 +684,18 @@  discard block
 block discarded – undo
684 684
 				else
685 685
 				{
686 686
 					$parent = $object[0];
687
-					$merged = [$parent,[$object[1]]];
687
+					$merged = [$parent, [$object[1]]];
688 688
 				}
689 689
 			}
690 690
 			else
691 691
 				$merged[1][] = $object[1];
692 692
 		}
693
-		if($parent !== null)
693
+		if ($parent !== null)
694 694
 		{
695
-			if(count($merged[1]) === 1 && is_string($merged[1][0]))
696
-				$objects[$id] = [$merged[0],$merged[1][0]];
695
+			if (count($merged[1]) === 1 && is_string($merged[1][0]))
696
+				$objects[$id] = [$merged[0], $merged[1][0]];
697 697
 			else
698
-				$objects[$id] = [$merged[0],new TCompositeLiteral($merged[1])];
698
+				$objects[$id] = [$merged[0], new TCompositeLiteral($merged[1])];
699 699
 		}
700 700
 		$tpl = $objects;
701 701
 		return $objects;
@@ -708,28 +708,28 @@  discard block
 block discarded – undo
708 708
 	 */
709 709
 	protected function parseAttributes($str, $offset)
710 710
 	{
711
-		if($str === '')
711
+		if ($str === '')
712 712
 			return [];
713 713
 		$pattern = '/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS';
714 714
 		$attributes = [];
715 715
 		$n = preg_match_all($pattern, $str, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
716
-		for($i = 0;$i < $n;++$i)
716
+		for ($i = 0; $i < $n; ++$i)
717 717
 		{
718 718
 			$match = &$matches[$i];
719 719
 			$name = strtolower($match[1][0]);
720
-			if(isset($attributes[$name]))
720
+			if (isset($attributes[$name]))
721 721
 				throw new TConfigurationException('template_property_duplicated', $name);
722 722
 			$value = $match[2][0];
723
-			if(substr($name, -8, 8) === 'template')
723
+			if (substr($name, -8, 8) === 'template')
724 724
 			{
725
-				if($value[0] === '\'' || $value[0] === '"')
725
+				if ($value[0] === '\'' || $value[0] === '"')
726 726
 					$attributes[$name] = $this->parseTemplateProperty(substr($value, 1, strlen($value) - 2), $match[2][1] + 1);
727 727
 				else
728 728
 					$attributes[$name] = $this->parseTemplateProperty($value, $match[2][1]);
729 729
 			}
730 730
 			else
731 731
 			{
732
-				if($value[0] === '\'' || $value[0] === '"')
732
+				if ($value[0] === '\'' || $value[0] === '"')
733 733
 					$attributes[$name] = $this->parseAttribute(substr($value, 1, strlen($value) - 2));
734 734
 				else
735 735
 					$attributes[$name] = $this->parseAttribute($value);
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 	protected function parseTemplateProperty($content, $offset)
742 742
 	{
743 743
 		$line = $this->_startingLine + count(explode("\n", substr($this->_content, 0, $offset))) - 1;
744
-		return [self::CONFIG_TEMPLATE,new TTemplate($content, $this->_contextPath, $this->_tplFile, $line, false)];
744
+		return [self::CONFIG_TEMPLATE, new TTemplate($content, $this->_contextPath, $this->_tplFile, $line, false)];
745 745
 	}
746 746
 
747 747
 	/**
@@ -751,44 +751,44 @@  discard block
 block discarded – undo
751 751
 	 */
752 752
 	protected function parseAttribute($value)
753 753
 	{
754
-		if(($n = preg_match_all('/<%[#=].*?%>/msS', $value, $matches, PREG_OFFSET_CAPTURE)) > 0)
754
+		if (($n = preg_match_all('/<%[#=].*?%>/msS', $value, $matches, PREG_OFFSET_CAPTURE)) > 0)
755 755
 		{
756 756
 			$isDataBind = false;
757 757
 			$textStart = 0;
758 758
 			$expr = '';
759
-			for($i = 0;$i < $n;++$i)
759
+			for ($i = 0; $i < $n; ++$i)
760 760
 			{
761 761
 				$match = $matches[0][$i];
762 762
 				$token = $match[0];
763 763
 				$offset = $match[1];
764 764
 				$length = strlen($token);
765
-				if($token[2] === '#')
765
+				if ($token[2] === '#')
766 766
 					$isDataBind = true;
767
-				if($offset > $textStart)
768
-					$expr .= ".'" . strtr(substr($value, $textStart, $offset - $textStart), ["'" => "\\'","\\" => "\\\\"]) . "'";
769
-				$expr .= '.(' . substr($token, 3, $length - 5) . ')';
767
+				if ($offset > $textStart)
768
+					$expr .= ".'".strtr(substr($value, $textStart, $offset - $textStart), ["'" => "\\'", "\\" => "\\\\"])."'";
769
+				$expr .= '.('.substr($token, 3, $length - 5).')';
770 770
 				$textStart = $offset + $length;
771 771
 			}
772 772
 			$length = strlen($value);
773
-			if($length > $textStart)
774
-				$expr .= ".'" . strtr(substr($value, $textStart, $length - $textStart), ["'" => "\\'","\\" => "\\\\"]) . "'";
775
-			if($isDataBind)
776
-				return [self::CONFIG_DATABIND,ltrim($expr, '.')];
773
+			if ($length > $textStart)
774
+				$expr .= ".'".strtr(substr($value, $textStart, $length - $textStart), ["'" => "\\'", "\\" => "\\\\"])."'";
775
+			if ($isDataBind)
776
+				return [self::CONFIG_DATABIND, ltrim($expr, '.')];
777 777
 			else
778
-				return [self::CONFIG_EXPRESSION,ltrim($expr, '.')];
778
+				return [self::CONFIG_EXPRESSION, ltrim($expr, '.')];
779 779
 		}
780
-		elseif(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0] === $value)
780
+		elseif (preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0] === $value)
781 781
 		{
782 782
 			$value = $matches[1];
783
-			if($value[2] === '~')
784
-				return [self::CONFIG_ASSET,trim(substr($value, 3, strlen($value) - 5))];
785
-			elseif($value[2] === '[')
786
-				return [self::CONFIG_LOCALIZATION,trim(substr($value, 3, strlen($value) - 6))];
787
-			elseif($value[2] === '$')
788
-				return [self::CONFIG_PARAMETER,trim(substr($value, 3, strlen($value) - 5))];
789
-			elseif($value[2] === '/') {
783
+			if ($value[2] === '~')
784
+				return [self::CONFIG_ASSET, trim(substr($value, 3, strlen($value) - 5))];
785
+			elseif ($value[2] === '[')
786
+				return [self::CONFIG_LOCALIZATION, trim(substr($value, 3, strlen($value) - 6))];
787
+			elseif ($value[2] === '$')
788
+				return [self::CONFIG_PARAMETER, trim(substr($value, 3, strlen($value) - 5))];
789
+			elseif ($value[2] === '/') {
790 790
 				$literal = trim(substr($value, 3, strlen($value) - 5));
791
-				return [self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"];
791
+				return [self::CONFIG_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"];
792 792
 			}
793 793
 		}
794 794
 		else
@@ -798,71 +798,71 @@  discard block
 block discarded – undo
798 798
 	protected function validateAttributes($type, $attributes)
799 799
 	{
800 800
 		Prado::using($type);
801
-		if(($pos = strrpos($type, '.')) !== false)
801
+		if (($pos = strrpos($type, '.')) !== false)
802 802
 			$className = substr($type, $pos + 1);
803 803
 		else
804 804
 			$className = $type;
805 805
 		$class = new \ReflectionClass($className);
806
-		if(is_subclass_of($className, '\Prado\Web\UI\TControl') || $className === '\Prado\Web\UI\TControl')
806
+		if (is_subclass_of($className, '\Prado\Web\UI\TControl') || $className === '\Prado\Web\UI\TControl')
807 807
 		{
808
-			foreach($attributes as $name => $att)
808
+			foreach ($attributes as $name => $att)
809 809
 			{
810
-				if(($pos = strpos($name, '.')) !== false)
810
+				if (($pos = strpos($name, '.')) !== false)
811 811
 				{
812 812
 					// a subproperty, so the first segment must be readable
813 813
 					$subname = substr($name, 0, $pos);
814
-					if(!$class->hasMethod('get' . $subname))
814
+					if (!$class->hasMethod('get'.$subname))
815 815
 						throw new TConfigurationException('template_property_unknown', $type, $subname);
816 816
 				}
817
-				elseif(strncasecmp($name, 'on', 2) === 0)
817
+				elseif (strncasecmp($name, 'on', 2) === 0)
818 818
 				{
819 819
 					// an event
820
-					if(!$class->hasMethod($name))
820
+					if (!$class->hasMethod($name))
821 821
 						throw new TConfigurationException('template_event_unknown', $type, $name);
822
-					elseif(!is_string($att))
822
+					elseif (!is_string($att))
823 823
 						throw new TConfigurationException('template_eventhandler_invalid', $type, $name);
824 824
 				}
825 825
 				else
826 826
 				{
827 827
 					// a simple property
828
-					if (! ($class->hasMethod('set' . $name) || $class->hasMethod('setjs' . $name) || $this->isClassBehaviorMethod($class, 'set' . $name)))
828
+					if (!($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class, 'set'.$name)))
829 829
 					{
830
-						if ($class->hasMethod('get' . $name) || $class->hasMethod('getjs' . $name))
830
+						if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name))
831 831
 							throw new TConfigurationException('template_property_readonly', $type, $name);
832 832
 						else
833 833
 							throw new TConfigurationException('template_property_unknown', $type, $name);
834 834
 					}
835
-					elseif(is_array($att) && $att[0] !== self::CONFIG_EXPRESSION)
835
+					elseif (is_array($att) && $att[0] !== self::CONFIG_EXPRESSION)
836 836
 					{
837
-						if(strcasecmp($name, 'id') === 0)
837
+						if (strcasecmp($name, 'id') === 0)
838 838
 							throw new TConfigurationException('template_controlid_invalid', $type);
839
-						elseif(strcasecmp($name, 'skinid') === 0)
839
+						elseif (strcasecmp($name, 'skinid') === 0)
840 840
 							throw new TConfigurationException('template_controlskinid_invalid', $type);
841 841
 					}
842 842
 				}
843 843
 			}
844 844
 		}
845
-		elseif(is_subclass_of($className, '\Prado\TComponent') || $className === '\Prado\TComponent')
845
+		elseif (is_subclass_of($className, '\Prado\TComponent') || $className === '\Prado\TComponent')
846 846
 		{
847
-			foreach($attributes as $name => $att)
847
+			foreach ($attributes as $name => $att)
848 848
 			{
849
-				if(is_array($att) && ($att[0] === self::CONFIG_DATABIND))
849
+				if (is_array($att) && ($att[0] === self::CONFIG_DATABIND))
850 850
 					throw new TConfigurationException('template_databind_forbidden', $type, $name);
851
-				if(($pos = strpos($name, '.')) !== false)
851
+				if (($pos = strpos($name, '.')) !== false)
852 852
 				{
853 853
 					// a subproperty, so the first segment must be readable
854 854
 					$subname = substr($name, 0, $pos);
855
-					if(!$class->hasMethod('get' . $subname))
855
+					if (!$class->hasMethod('get'.$subname))
856 856
 						throw new TConfigurationException('template_property_unknown', $type, $subname);
857 857
 				}
858
-				elseif(strncasecmp($name, 'on', 2) === 0)
858
+				elseif (strncasecmp($name, 'on', 2) === 0)
859 859
 					throw new TConfigurationException('template_event_forbidden', $type, $name);
860 860
 				else
861 861
 				{
862 862
 					// id is still alowed for TComponent, even if id property doesn't exist
863
-					if(strcasecmp($name, 'id') !== 0 && !($class->hasMethod('set' . $name) || $this->isClassBehaviorMethod($class, 'set' . $name)))
863
+					if (strcasecmp($name, 'id') !== 0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class, 'set'.$name)))
864 864
 					{
865
-						if($class->hasMethod('get' . $name))
865
+						if ($class->hasMethod('get'.$name))
866 866
 							throw new TConfigurationException('template_property_readonly', $type, $name);
867 867
 						else
868 868
 							throw new TConfigurationException('template_property_unknown', $type, $name);
@@ -895,13 +895,13 @@  discard block
 block discarded – undo
895 895
 	{
896 896
 		$srcFile = $this->_tplFile;
897 897
 
898
-		if(($n = count($this->_includedFiles)) > 0) // need to adjust error row number and file name
898
+		if (($n = count($this->_includedFiles)) > 0) // need to adjust error row number and file name
899 899
 		{
900
-			for($i = $n - 1;$i >= 0;--$i)
900
+			for ($i = $n - 1; $i >= 0; --$i)
901 901
 			{
902
-				if($this->_includeAtLine[$i] <= $line)
902
+				if ($this->_includeAtLine[$i] <= $line)
903 903
 				{
904
-					if($line < $this->_includeAtLine[$i] + $this->_includeLines[$i])
904
+					if ($line < $this->_includeAtLine[$i] + $this->_includeLines[$i])
905 905
 					{
906 906
 						$line = $line - $this->_includeAtLine[$i] + 1;
907 907
 						$srcFile = $this->_includedFiles[$i];
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 		}
915 915
 		$exception = new TTemplateException('template_format_invalid', $e->getMessage());
916 916
 		$exception->setLineNumber($line);
917
-		if(!empty($srcFile))
917
+		if (!empty($srcFile))
918 918
 			$exception->setTemplateFile($srcFile);
919 919
 		else
920 920
 			$exception->setTemplateSource($input);
@@ -928,12 +928,12 @@  discard block
 block discarded – undo
928 928
 	 */
929 929
 	protected function preprocess($input)
930 930
 	{
931
-		if($n = preg_match_all('/<%include(.*?)%>/', $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
931
+		if ($n = preg_match_all('/<%include(.*?)%>/', $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
932 932
 		{
933
-			for($i = 0;$i < $n;++$i)
933
+			for ($i = 0; $i < $n; ++$i)
934 934
 			{
935 935
 				$filePath = Prado::getPathOfNamespace(trim($matches[$i][1][0]), TTemplateManager::TEMPLATE_FILE_EXT);
936
-				if($filePath !== null && is_file($filePath))
936
+				if ($filePath !== null && is_file($filePath))
937 937
 					$this->_includedFiles[] = $filePath;
938 938
 				else
939 939
 				{
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 				}
943 943
 			}
944 944
 			$base = 0;
945
-			for($i = 0;$i < $n;++$i)
945
+			for ($i = 0; $i < $n; ++$i)
946 946
 			{
947 947
 				$ext = file_get_contents($this->_includedFiles[$i]);
948 948
 				$length = strlen($matches[$i][0][0]);
@@ -967,14 +967,14 @@  discard block
 block discarded – undo
967 967
 	{
968 968
 	  $component = new \ReflectionClass('\Prado\TComponent');
969 969
 	  $behaviors = $component->getStaticProperties();
970
-	  if(!isset($behaviors['_um']))
970
+	  if (!isset($behaviors['_um']))
971 971
 		return false;
972
-	  foreach($behaviors['_um'] as $name => $list)
972
+	  foreach ($behaviors['_um'] as $name => $list)
973 973
 	  {
974
-		if(strtolower($class->getShortName()) !== $name && !$class->isSubclassOf($name)) continue;
975
-		foreach($list as $param)
974
+		if (strtolower($class->getShortName()) !== $name && !$class->isSubclassOf($name)) continue;
975
+		foreach ($list as $param)
976 976
 		{
977
-		  if(method_exists($param->getBehavior(), $method))
977
+		  if (method_exists($param->getBehavior(), $method))
978 978
 			return true;
979 979
 		}
980 980
 	  }
Please login to merge, or discard this patch.
Braces   +325 added lines, -254 removed lines patch added patch discarded remove patch
@@ -192,96 +192,110 @@  discard block
 block discarded – undo
192 192
 	public function instantiateIn($tplControl, $parentControl = null)
193 193
 	{
194 194
 		$this->_tplControl = $tplControl;
195
-		if($parentControl === null)
196
-			$parentControl = $tplControl;
197
-		if(($page = $tplControl->getPage()) === null)
198
-			$page = $this->getService()->getRequestedPage();
195
+		if($parentControl === null) {
196
+					$parentControl = $tplControl;
197
+		}
198
+		if(($page = $tplControl->getPage()) === null) {
199
+					$page = $this->getService()->getRequestedPage();
200
+		}
199 201
 		$controls = [];
200 202
 		$directChildren = [];
201 203
 		foreach($this->_tpl as $key => $object)
202 204
 		{
203
-			if($object[0] === -1)
204
-				$parent = $parentControl;
205
-			elseif(isset($controls[$object[0]]))
206
-				$parent = $controls[$object[0]];
207
-			else
208
-				continue;
209
-			if(isset($object[2]))	// component
205
+			if($object[0] === -1) {
206
+							$parent = $parentControl;
207
+			} elseif(isset($controls[$object[0]])) {
208
+							$parent = $controls[$object[0]];
209
+			} else {
210
+							continue;
211
+			}
212
+			if(isset($object[2])) {
213
+				// component
210 214
 			{
211 215
 				$component = Prado::createComponent($object[1]);
216
+			}
212 217
 				$properties = &$object[2];
213 218
 				if($component instanceof TControl)
214 219
 				{
215
-					if($component instanceof \Prado\Web\UI\WebControls\TOutputCache)
216
-						$component->setCacheKeyPrefix($this->_hashCode . $key);
220
+					if($component instanceof \Prado\Web\UI\WebControls\TOutputCache) {
221
+											$component->setCacheKeyPrefix($this->_hashCode . $key);
222
+					}
217 223
 					$component->setTemplateControl($tplControl);
218 224
 					if(isset($properties['id']))
219 225
 					{
220
-						if(is_array($properties['id']))
221
-							$properties['id'] = $component->evaluateExpression($properties['id'][1]);
226
+						if(is_array($properties['id'])) {
227
+													$properties['id'] = $component->evaluateExpression($properties['id'][1]);
228
+						}
222 229
 						$tplControl->registerObject($properties['id'], $component);
223 230
 					}
224 231
 					if(isset($properties['skinid']))
225 232
 					{
226
-						if(is_array($properties['skinid']))
227
-							$component->setSkinID($component->evaluateExpression($properties['skinid'][1]));
228
-						else
229
-							$component->setSkinID($properties['skinid']);
233
+						if(is_array($properties['skinid'])) {
234
+													$component->setSkinID($component->evaluateExpression($properties['skinid'][1]));
235
+						} else {
236
+													$component->setSkinID($properties['skinid']);
237
+						}
230 238
 						unset($properties['skinid']);
231 239
 					}
232 240
 
233 241
 					$component->trackViewState(false);
234 242
 
235 243
 					$component->applyStyleSheetSkin($page);
236
-					foreach($properties as $name => $value)
237
-						$this->configureControl($component, $name, $value);
244
+					foreach($properties as $name => $value) {
245
+											$this->configureControl($component, $name, $value);
246
+					}
238 247
 
239 248
 					$component->trackViewState(true);
240 249
 
241
-					if($parent === $parentControl)
242
-						$directChildren[] = $component;
243
-					else
244
-						$component->createdOnTemplate($parent);
245
-					if($component->getAllowChildControls())
246
-						$controls[$key] = $component;
247
-				}
248
-				elseif($component instanceof TComponent)
250
+					if($parent === $parentControl) {
251
+											$directChildren[] = $component;
252
+					} else {
253
+											$component->createdOnTemplate($parent);
254
+					}
255
+					if($component->getAllowChildControls()) {
256
+											$controls[$key] = $component;
257
+					}
258
+				} elseif($component instanceof TComponent)
249 259
 				{
250 260
 					$controls[$key] = $component;
251 261
 					if(isset($properties['id']))
252 262
 					{
253
-						if(is_array($properties['id']))
254
-							$properties['id'] = $component->evaluateExpression($properties['id'][1]);
263
+						if(is_array($properties['id'])) {
264
+													$properties['id'] = $component->evaluateExpression($properties['id'][1]);
265
+						}
255 266
 						$tplControl->registerObject($properties['id'], $component);
256
-						if(!$component->hasProperty('id'))
257
-							unset($properties['id']);
258
-					}
259
-					foreach($properties as $name => $value)
260
-						$this->configureComponent($component, $name, $value);
261
-					if($parent === $parentControl)
262
-						$directChildren[] = $component;
263
-					else
264
-						$component->createdOnTemplate($parent);
267
+						if(!$component->hasProperty('id')) {
268
+													unset($properties['id']);
269
+						}
270
+					}
271
+					foreach($properties as $name => $value) {
272
+											$this->configureComponent($component, $name, $value);
273
+					}
274
+					if($parent === $parentControl) {
275
+											$directChildren[] = $component;
276
+					} else {
277
+											$component->createdOnTemplate($parent);
278
+					}
265 279
 				}
266
-			}
267
-			else
280
+			} else
268 281
 			{
269 282
 				if($object[1] instanceof TCompositeLiteral)
270 283
 				{
271 284
 					// need to clone a new object because the one in template is reused
272 285
 					$o = clone $object[1];
273 286
 					$o->setContainer($tplControl);
274
-					if($parent === $parentControl)
275
-						$directChildren[] = $o;
276
-					else
277
-						$parent->addParsedObject($o);
278
-				}
279
-				else
287
+					if($parent === $parentControl) {
288
+											$directChildren[] = $o;
289
+					} else {
290
+											$parent->addParsedObject($o);
291
+					}
292
+				} else
280 293
 				{
281
-					if($parent === $parentControl)
282
-						$directChildren[] = $object[1];
283
-					else
284
-						$parent->addParsedObject($object[1]);
294
+					if($parent === $parentControl) {
295
+											$directChildren[] = $object[1];
296
+					} else {
297
+											$parent->addParsedObject($object[1]);
298
+					}
285 299
 				}
286 300
 			}
287 301
 		}
@@ -290,10 +304,11 @@  discard block
 block discarded – undo
290 304
 		// if the child needs its own child controls.
291 305
 		foreach($directChildren as $control)
292 306
 		{
293
-			if($control instanceof TComponent)
294
-				$control->createdOnTemplate($parentControl);
295
-			else
296
-				$parentControl->addParsedObject($control);
307
+			if($control instanceof TComponent) {
308
+							$control->createdOnTemplate($parentControl);
309
+			} else {
310
+							$parentControl->addParsedObject($control);
311
+			}
297 312
 		}
298 313
 	}
299 314
 
@@ -305,12 +320,16 @@  discard block
 block discarded – undo
305 320
 	 */
306 321
 	protected function configureControl($control, $name, $value)
307 322
 	{
308
-		if(strncasecmp($name, 'on', 2) === 0)		// is an event
323
+		if(strncasecmp($name, 'on', 2) === 0) {
324
+			// is an event
309 325
 			$this->configureEvent($control, $name, $value, $control);
310
-		elseif(($pos = strrpos($name, '.')) === false)	// is a simple property or custom attribute
326
+		} elseif(($pos = strrpos($name, '.')) === false) {
327
+			// is a simple property or custom attribute
311 328
 			$this->configureProperty($control, $name, $value);
312
-		else	// is a subproperty
329
+		} else {
330
+			// is a subproperty
313 331
 			$this->configureSubProperty($control, $name, $value);
332
+		}
314 333
 	}
315 334
 
316 335
 	/**
@@ -321,10 +340,13 @@  discard block
 block discarded – undo
321 340
 	 */
322 341
 	protected function configureComponent($component, $name, $value)
323 342
 	{
324
-		if(strpos($name, '.') === false)	// is a simple property or custom attribute
343
+		if(strpos($name, '.') === false) {
344
+			// is a simple property or custom attribute
325 345
 			$this->configureProperty($component, $name, $value);
326
-		else	// is a subproperty
346
+		} else {
347
+			// is a subproperty
327 348
 			$this->configureSubProperty($component, $name, $value);
349
+		}
328 350
 	}
329 351
 
330 352
 	/**
@@ -336,10 +358,11 @@  discard block
 block discarded – undo
336 358
 	 */
337 359
 	protected function configureEvent($control, $name, $value, $contextControl)
338 360
 	{
339
-		if(strpos($value, '.') === false)
340
-			$control->attachEventHandler($name, [$contextControl,'TemplateControl.' . $value]);
341
-		else
342
-			$control->attachEventHandler($name, [$contextControl,$value]);
361
+		if(strpos($value, '.') === false) {
362
+					$control->attachEventHandler($name, [$contextControl,'TemplateControl.' . $value]);
363
+		} else {
364
+					$control->attachEventHandler($name, [$contextControl,$value]);
365
+		}
343 366
 	}
344 367
 
345 368
 	/**
@@ -358,9 +381,9 @@  discard block
 block discarded – undo
358 381
 					$component->bindProperty($name, $value[1]);
359 382
 					break;
360 383
 				case self::CONFIG_EXPRESSION:
361
-					if($component instanceof TControl)
362
-						$component->autoBindProperty($name, $value[1]);
363
-					else
384
+					if($component instanceof TControl) {
385
+											$component->autoBindProperty($name, $value[1]);
386
+					} else
364 387
 					{
365 388
 						$setter = 'set' . $name;
366 389
 						$component->$setter($this->_tplControl->evaluateExpression($value[1]));
@@ -387,12 +410,12 @@  discard block
 block discarded – undo
387 410
 					throw new TConfigurationException('template_tag_unexpected', $name, $value[1]);
388 411
 					break;
389 412
 			}
390
-		}
391
-		else
413
+		} else
392 414
 		{
393
-			if (substr($name, 0, 2) == 'js')
394
-				if ($value and !($value instanceof TJavaScriptLiteral))
415
+			if (substr($name, 0, 2) == 'js') {
416
+							if ($value and !($value instanceof TJavaScriptLiteral))
395 417
 					$value = new TJavaScriptLiteral($value);
418
+			}
396 419
 			$setter = 'set' . $name;
397 420
 			$component->$setter($value);
398 421
 		}
@@ -414,10 +437,11 @@  discard block
 block discarded – undo
414 437
 					$component->bindProperty($name, $value[1]);
415 438
 					break;
416 439
 				case self::CONFIG_EXPRESSION:		// expression
417
-					if($component instanceof TControl)
418
-						$component->autoBindProperty($name, $value[1]);
419
-					else
420
-						$component->setSubProperty($name, $this->_tplControl->evaluateExpression($value[1]));
440
+					if($component instanceof TControl) {
441
+											$component->autoBindProperty($name, $value[1]);
442
+					} else {
443
+											$component->setSubProperty($name, $this->_tplControl->evaluateExpression($value[1]));
444
+					}
421 445
 					break;
422 446
 				case self::CONFIG_TEMPLATE:
423 447
 					$component->setSubProperty($name, $value[1]);
@@ -436,9 +460,9 @@  discard block
 block discarded – undo
436 460
 					throw new TConfigurationException('template_tag_unexpected', $name, $value[1]);
437 461
 					break;
438 462
 			}
463
+		} else {
464
+					$component->setSubProperty($name, $value);
439 465
 		}
440
-		else
441
-			$component->setSubProperty($name, $value);
442 466
 	}
443 467
 
444 468
 	/**
@@ -482,34 +506,42 @@  discard block
 block discarded – undo
482 506
 				$str = $match[0][0];
483 507
 				$matchStart = $match[0][1];
484 508
 				$matchEnd = $matchStart + strlen($str) - 1;
485
-				if(strpos($str, '<com:') === 0)	// opening component tag
509
+				if(strpos($str, '<com:') === 0) {
510
+					// opening component tag
486 511
 				{
487 512
 					if($expectPropEnd)
488 513
 						continue;
489
-					if($matchStart > $textStart)
490
-						$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
514
+				}
515
+					if($matchStart > $textStart) {
516
+											$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
517
+					}
491 518
 					$textStart = $matchEnd + 1;
492 519
 					$type = $match[1][0];
493 520
 					$attributes = $this->parseAttributes($match[2][0], $match[2][1]);
494 521
 					$class = $this->validateAttributes($type, $attributes);
495 522
 					$tpl[$c++] = [$container,$class,$attributes];
496
-					if($str[strlen($str) - 2] !== '/')  // open tag
523
+					if($str[strlen($str) - 2] !== '/') {
524
+						// open tag
497 525
 					{
498 526
 						$stack[] = $type;
527
+					}
499 528
 						$container = $c - 1;
500 529
 					}
501
-				}
502
-				elseif(strpos($str, '</com:') === 0)	// closing component tag
530
+				} elseif(strpos($str, '</com:') === 0) {
531
+					// closing component tag
503 532
 				{
504 533
 					if($expectPropEnd)
505 534
 						continue;
506
-					if($matchStart > $textStart)
507
-						$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
535
+				}
536
+					if($matchStart > $textStart) {
537
+											$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
538
+					}
508 539
 					$textStart = $matchEnd + 1;
509 540
 					$type = $match[1][0];
510 541
 
511
-					if(empty($stack))
512
-						throw new TConfigurationException('template_closingtag_unexpected', "</com:$type>");
542
+					if(empty($stack)) {
543
+											throw new TConfigurationException('template_closingtag_unexpected', "</com:$type>");
544
+					}
513 545
 
514 546
 					$name = array_pop($stack);
515 547
 					if($name !== $type)
@@ -518,85 +550,98 @@  discard block
 block discarded – undo
518 550
 						throw new TConfigurationException('template_closingtag_expected', $tag, "</com:$type>");
519 551
 					}
520 552
 					$container = $tpl[$container][0];
521
-				}
522
-				elseif(strpos($str, '<%@') === 0)	// directive
553
+				} elseif(strpos($str, '<%@') === 0) {
554
+					// directive
523 555
 				{
524 556
 					if($expectPropEnd)
525 557
 						continue;
526
-					if($matchStart > $textStart)
527
-						$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
558
+				}
559
+					if($matchStart > $textStart) {
560
+											$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
561
+					}
528 562
 					$textStart = $matchEnd + 1;
529
-					if(isset($tpl[0]) || $this->_directive !== null)
530
-						throw new TConfigurationException('template_directive_nonunique');
563
+					if(isset($tpl[0]) || $this->_directive !== null) {
564
+											throw new TConfigurationException('template_directive_nonunique');
565
+					}
531 566
 					$this->_directive = $this->parseAttributes($match[4][0], $match[4][1]);
532
-				}
533
-				elseif(strpos($str, '<%') === 0)	// expression
567
+				} elseif(strpos($str, '<%') === 0) {
568
+					// expression
534 569
 				{
535 570
 					if($expectPropEnd)
536 571
 						continue;
537
-					if($matchStart > $textStart)
538
-						$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
572
+				}
573
+					if($matchStart > $textStart) {
574
+											$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
575
+					}
539 576
 					$textStart = $matchEnd + 1;
540 577
 					$literal = trim($match[5][0]);
541
-					if($str[2] === '=')	// expression
578
+					if($str[2] === '=') {
579
+						// expression
542 580
 						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,$literal]];
543
-					elseif($str[2] === '%')  // statements
581
+					} elseif($str[2] === '%') {
582
+						// statements
544 583
 						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_STATEMENTS,$literal]];
545
-					elseif($str[2] === '#')
546
-						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_DATABINDING,$literal]];
547
-					elseif($str[2] === '$')
548
-						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')"]];
549
-					elseif($str[2] === '~')
550
-						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')"]];
551
-					elseif($str[2] === '/')
552
-						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"]];
553
-					elseif($str[2] === '[')
584
+					} elseif($str[2] === '#') {
585
+											$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_DATABINDING,$literal]];
586
+					} elseif($str[2] === '$') {
587
+											$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')"]];
588
+					} elseif($str[2] === '~') {
589
+											$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')"]];
590
+					} elseif($str[2] === '/') {
591
+											$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"]];
592
+					} elseif($str[2] === '[')
554 593
 					{
555 594
 						$literal = strtr(trim(substr($literal, 0, strlen($literal) - 1)), ["'" => "\'","\\" => "\\\\"]);
556 595
 						$tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')"]];
557 596
 					}
558
-				}
559
-				elseif(strpos($str, '<prop:') === 0)	// opening property
597
+				} elseif(strpos($str, '<prop:') === 0) {
598
+					// opening property
560 599
 				{
561 600
 					if(strrpos($str, '/>') === strlen($str) - 2)  //subproperties
562 601
 					{
563 602
 						if($expectPropEnd)
564 603
 							continue;
565
-						if($matchStart > $textStart)
566
-							$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
604
+				}
605
+						if($matchStart > $textStart) {
606
+													$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
607
+						}
567 608
 						$textStart = $matchEnd + 1;
568 609
 						$prop = strtolower($match[6][0]);
569 610
 						$attrs = $this->parseAttributes($match[7][0], $match[7][1]);
570 611
 						$attributes = [];
571
-						foreach($attrs as $name => $value)
572
-							$attributes[$prop . '.' . $name] = $value;
612
+						foreach($attrs as $name => $value) {
613
+													$attributes[$prop . '.' . $name] = $value;
614
+						}
573 615
 						$type = $tpl[$container][1];
574 616
 						$this->validateAttributes($type, $attributes);
575 617
 						foreach($attributes as $name => $value)
576 618
 						{
577
-							if(isset($tpl[$container][2][$name]))
578
-								throw new TConfigurationException('template_property_duplicated', $name);
619
+							if(isset($tpl[$container][2][$name])) {
620
+															throw new TConfigurationException('template_property_duplicated', $name);
621
+							}
579 622
 							$tpl[$container][2][$name] = $value;
580 623
 						}
581
-					}
582
-					else  // regular property
624
+					} else  // regular property
583 625
 					{
584 626
 						$prop = strtolower($match[3][0]);
585 627
 						$stack[] = '@' . $prop;
586 628
 						if(!$expectPropEnd)
587 629
 						{
588
-							if($matchStart > $textStart)
589
-								$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
630
+							if($matchStart > $textStart) {
631
+															$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
632
+							}
590 633
 							$textStart = $matchEnd + 1;
591 634
 							$expectPropEnd = true;
592 635
 						}
593 636
 					}
594
-				}
595
-				elseif(strpos($str, '</prop:') === 0)	// closing property
637
+				} elseif(strpos($str, '</prop:') === 0) {
638
+					// closing property
596 639
 				{
597 640
 					$prop = strtolower($match[3][0]);
598
-					if(empty($stack))
599
-						throw new TConfigurationException('template_closingtag_unexpected', "</prop:$prop>");
641
+				}
642
+					if(empty($stack)) {
643
+											throw new TConfigurationException('template_closingtag_unexpected', "</prop:$prop>");
644
+					}
600 645
 					$name = array_pop($stack);
601 646
 					if($name !== '@' . $prop)
602 647
 					{
@@ -608,35 +653,40 @@  discard block
 block discarded – undo
608 653
 						if($matchStart > $textStart)
609 654
 						{
610 655
 							$value = substr($input, $textStart, $matchStart - $textStart);
611
-							if(substr($prop, -8, 8) === 'template')
612
-								$value = $this->parseTemplateProperty($value, $textStart);
613
-							else
614
-								$value = $this->parseAttribute($value);
656
+							if(substr($prop, -8, 8) === 'template') {
657
+															$value = $this->parseTemplateProperty($value, $textStart);
658
+							} else {
659
+															$value = $this->parseAttribute($value);
660
+							}
615 661
 							if($container >= 0)
616 662
 							{
617 663
 								$type = $tpl[$container][1];
618 664
 								$this->validateAttributes($type, [$prop => $value]);
619
-								if(isset($tpl[$container][2][$prop]))
620
-									throw new TConfigurationException('template_property_duplicated', $prop);
665
+								if(isset($tpl[$container][2][$prop])) {
666
+																	throw new TConfigurationException('template_property_duplicated', $prop);
667
+								}
621 668
 								$tpl[$container][2][$prop] = $value;
622
-							}
623
-							else	// a property for the template control
669
+							} else {
670
+								// a property for the template control
624 671
 								$this->_directive[$prop] = $value;
672
+							}
625 673
 							$textStart = $matchEnd + 1;
626 674
 						}
627 675
 						$expectPropEnd = false;
628 676
 					}
629
-				}
630
-				elseif(strpos($str, '<!--') === 0)	// comments
677
+				} elseif(strpos($str, '<!--') === 0) {
678
+					// comments
631 679
 				{
632 680
 					if($expectPropEnd)
633 681
 						throw new TConfigurationException('template_comments_forbidden');
634
-					if($matchStart > $textStart)
635
-						$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
682
+				}
683
+					if($matchStart > $textStart) {
684
+											$tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)];
685
+					}
636 686
 					$textStart = $matchEnd + 1;
687
+				} else {
688
+									throw new TConfigurationException('template_matching_unexpected', $match);
637 689
 				}
638
-				else
639
-					throw new TConfigurationException('template_matching_unexpected', $match);
640 690
 			}
641 691
 			if(!empty($stack))
642 692
 			{
@@ -644,22 +694,25 @@  discard block
 block discarded – undo
644 694
 				$tag = $name[0] === '@' ? '</prop:' . substr($name, 1) . '>' : "</com:$name>";
645 695
 				throw new TConfigurationException('template_closingtag_expected', $tag, "nothing");
646 696
 			}
647
-			if($textStart < strlen($input))
648
-				$tpl[$c++] = [$container,substr($input, $textStart)];
649
-		}
650
-		catch(\Exception $e)
697
+			if($textStart < strlen($input)) {
698
+							$tpl[$c++] = [$container,substr($input, $textStart)];
699
+			}
700
+		} catch(\Exception $e)
651 701
 		{
652
-			if(($e instanceof TException) && ($e instanceof TTemplateException))
653
-				throw $e;
654
-			if($matchEnd === 0)
655
-				$line = $this->_startingLine + 1;
656
-			else
657
-				$line = $this->_startingLine + count(explode("\n", substr($input, 0, $matchEnd + 1)));
702
+			if(($e instanceof TException) && ($e instanceof TTemplateException)) {
703
+							throw $e;
704
+			}
705
+			if($matchEnd === 0) {
706
+							$line = $this->_startingLine + 1;
707
+			} else {
708
+							$line = $this->_startingLine + count(explode("\n", substr($input, 0, $matchEnd + 1)));
709
+			}
658 710
 			$this->handleException($e, $line, $input);
659 711
 		}
660 712
 
661
-		if($this->_directive === null)
662
-			$this->_directive = [];
713
+		if($this->_directive === null) {
714
+					$this->_directive = [];
715
+		}
663 716
 
664 717
 		// optimization by merging consecutive strings, expressions, statements and bindings
665 718
 		$objects = [];
@@ -671,31 +724,32 @@  discard block
 block discarded – undo
671 724
 			{
672 725
 				if($parent !== null)
673 726
 				{
674
-					if(count($merged[1]) === 1 && is_string($merged[1][0]))
675
-						$objects[$id - 1] = [$merged[0],$merged[1][0]];
676
-					else
677
-						$objects[$id - 1] = [$merged[0],new TCompositeLiteral($merged[1])];
727
+					if(count($merged[1]) === 1 && is_string($merged[1][0])) {
728
+											$objects[$id - 1] = [$merged[0],$merged[1][0]];
729
+					} else {
730
+											$objects[$id - 1] = [$merged[0],new TCompositeLiteral($merged[1])];
731
+					}
678 732
 				}
679 733
 				if(isset($object[2]))
680 734
 				{
681 735
 					$parent = null;
682 736
 					$objects[$id] = $object;
683
-				}
684
-				else
737
+				} else
685 738
 				{
686 739
 					$parent = $object[0];
687 740
 					$merged = [$parent,[$object[1]]];
688 741
 				}
742
+			} else {
743
+							$merged[1][] = $object[1];
689 744
 			}
690
-			else
691
-				$merged[1][] = $object[1];
692 745
 		}
693 746
 		if($parent !== null)
694 747
 		{
695
-			if(count($merged[1]) === 1 && is_string($merged[1][0]))
696
-				$objects[$id] = [$merged[0],$merged[1][0]];
697
-			else
698
-				$objects[$id] = [$merged[0],new TCompositeLiteral($merged[1])];
748
+			if(count($merged[1]) === 1 && is_string($merged[1][0])) {
749
+							$objects[$id] = [$merged[0],$merged[1][0]];
750
+			} else {
751
+							$objects[$id] = [$merged[0],new TCompositeLiteral($merged[1])];
752
+			}
699 753
 		}
700 754
 		$tpl = $objects;
701 755
 		return $objects;
@@ -708,8 +762,9 @@  discard block
 block discarded – undo
708 762
 	 */
709 763
 	protected function parseAttributes($str, $offset)
710 764
 	{
711
-		if($str === '')
712
-			return [];
765
+		if($str === '') {
766
+					return [];
767
+		}
713 768
 		$pattern = '/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS';
714 769
 		$attributes = [];
715 770
 		$n = preg_match_all($pattern, $str, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
@@ -717,22 +772,24 @@  discard block
 block discarded – undo
717 772
 		{
718 773
 			$match = &$matches[$i];
719 774
 			$name = strtolower($match[1][0]);
720
-			if(isset($attributes[$name]))
721
-				throw new TConfigurationException('template_property_duplicated', $name);
775
+			if(isset($attributes[$name])) {
776
+							throw new TConfigurationException('template_property_duplicated', $name);
777
+			}
722 778
 			$value = $match[2][0];
723 779
 			if(substr($name, -8, 8) === 'template')
724 780
 			{
725
-				if($value[0] === '\'' || $value[0] === '"')
726
-					$attributes[$name] = $this->parseTemplateProperty(substr($value, 1, strlen($value) - 2), $match[2][1] + 1);
727
-				else
728
-					$attributes[$name] = $this->parseTemplateProperty($value, $match[2][1]);
729
-			}
730
-			else
781
+				if($value[0] === '\'' || $value[0] === '"') {
782
+									$attributes[$name] = $this->parseTemplateProperty(substr($value, 1, strlen($value) - 2), $match[2][1] + 1);
783
+				} else {
784
+									$attributes[$name] = $this->parseTemplateProperty($value, $match[2][1]);
785
+				}
786
+			} else
731 787
 			{
732
-				if($value[0] === '\'' || $value[0] === '"')
733
-					$attributes[$name] = $this->parseAttribute(substr($value, 1, strlen($value) - 2));
734
-				else
735
-					$attributes[$name] = $this->parseAttribute($value);
788
+				if($value[0] === '\'' || $value[0] === '"') {
789
+									$attributes[$name] = $this->parseAttribute(substr($value, 1, strlen($value) - 2));
790
+				} else {
791
+									$attributes[$name] = $this->parseAttribute($value);
792
+				}
736 793
 			}
737 794
 		}
738 795
 		return $attributes;
@@ -762,46 +819,50 @@  discard block
 block discarded – undo
762 819
 				$token = $match[0];
763 820
 				$offset = $match[1];
764 821
 				$length = strlen($token);
765
-				if($token[2] === '#')
766
-					$isDataBind = true;
767
-				if($offset > $textStart)
768
-					$expr .= ".'" . strtr(substr($value, $textStart, $offset - $textStart), ["'" => "\\'","\\" => "\\\\"]) . "'";
822
+				if($token[2] === '#') {
823
+									$isDataBind = true;
824
+				}
825
+				if($offset > $textStart) {
826
+									$expr .= ".'" . strtr(substr($value, $textStart, $offset - $textStart), ["'" => "\\'","\\" => "\\\\"]) . "'";
827
+				}
769 828
 				$expr .= '.(' . substr($token, 3, $length - 5) . ')';
770 829
 				$textStart = $offset + $length;
771 830
 			}
772 831
 			$length = strlen($value);
773
-			if($length > $textStart)
774
-				$expr .= ".'" . strtr(substr($value, $textStart, $length - $textStart), ["'" => "\\'","\\" => "\\\\"]) . "'";
775
-			if($isDataBind)
776
-				return [self::CONFIG_DATABIND,ltrim($expr, '.')];
777
-			else
778
-				return [self::CONFIG_EXPRESSION,ltrim($expr, '.')];
779
-		}
780
-		elseif(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0] === $value)
832
+			if($length > $textStart) {
833
+							$expr .= ".'" . strtr(substr($value, $textStart, $length - $textStart), ["'" => "\\'","\\" => "\\\\"]) . "'";
834
+			}
835
+			if($isDataBind) {
836
+							return [self::CONFIG_DATABIND,ltrim($expr, '.')];
837
+			} else {
838
+							return [self::CONFIG_EXPRESSION,ltrim($expr, '.')];
839
+			}
840
+		} elseif(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0] === $value)
781 841
 		{
782 842
 			$value = $matches[1];
783
-			if($value[2] === '~')
784
-				return [self::CONFIG_ASSET,trim(substr($value, 3, strlen($value) - 5))];
785
-			elseif($value[2] === '[')
786
-				return [self::CONFIG_LOCALIZATION,trim(substr($value, 3, strlen($value) - 6))];
787
-			elseif($value[2] === '$')
788
-				return [self::CONFIG_PARAMETER,trim(substr($value, 3, strlen($value) - 5))];
789
-			elseif($value[2] === '/') {
843
+			if($value[2] === '~') {
844
+							return [self::CONFIG_ASSET,trim(substr($value, 3, strlen($value) - 5))];
845
+			} elseif($value[2] === '[') {
846
+							return [self::CONFIG_LOCALIZATION,trim(substr($value, 3, strlen($value) - 6))];
847
+			} elseif($value[2] === '$') {
848
+							return [self::CONFIG_PARAMETER,trim(substr($value, 3, strlen($value) - 5))];
849
+			} elseif($value[2] === '/') {
790 850
 				$literal = trim(substr($value, 3, strlen($value) - 5));
791 851
 				return [self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"];
792 852
 			}
853
+		} else {
854
+					return $value;
793 855
 		}
794
-		else
795
-			return $value;
796 856
 	}
797 857
 
798 858
 	protected function validateAttributes($type, $attributes)
799 859
 	{
800 860
 		Prado::using($type);
801
-		if(($pos = strrpos($type, '.')) !== false)
802
-			$className = substr($type, $pos + 1);
803
-		else
804
-			$className = $type;
861
+		if(($pos = strrpos($type, '.')) !== false) {
862
+					$className = substr($type, $pos + 1);
863
+		} else {
864
+					$className = $type;
865
+		}
805 866
 		$class = new \ReflectionClass($className);
806 867
 		if(is_subclass_of($className, '\Prado\Web\UI\TControl') || $className === '\Prado\Web\UI\TControl')
807 868
 		{
@@ -811,67 +872,69 @@  discard block
 block discarded – undo
811 872
 				{
812 873
 					// a subproperty, so the first segment must be readable
813 874
 					$subname = substr($name, 0, $pos);
814
-					if(!$class->hasMethod('get' . $subname))
815
-						throw new TConfigurationException('template_property_unknown', $type, $subname);
816
-				}
817
-				elseif(strncasecmp($name, 'on', 2) === 0)
875
+					if(!$class->hasMethod('get' . $subname)) {
876
+											throw new TConfigurationException('template_property_unknown', $type, $subname);
877
+					}
878
+				} elseif(strncasecmp($name, 'on', 2) === 0)
818 879
 				{
819 880
 					// an event
820
-					if(!$class->hasMethod($name))
821
-						throw new TConfigurationException('template_event_unknown', $type, $name);
822
-					elseif(!is_string($att))
823
-						throw new TConfigurationException('template_eventhandler_invalid', $type, $name);
824
-				}
825
-				else
881
+					if(!$class->hasMethod($name)) {
882
+											throw new TConfigurationException('template_event_unknown', $type, $name);
883
+					} elseif(!is_string($att)) {
884
+											throw new TConfigurationException('template_eventhandler_invalid', $type, $name);
885
+					}
886
+				} else
826 887
 				{
827 888
 					// a simple property
828 889
 					if (! ($class->hasMethod('set' . $name) || $class->hasMethod('setjs' . $name) || $this->isClassBehaviorMethod($class, 'set' . $name)))
829 890
 					{
830
-						if ($class->hasMethod('get' . $name) || $class->hasMethod('getjs' . $name))
831
-							throw new TConfigurationException('template_property_readonly', $type, $name);
832
-						else
833
-							throw new TConfigurationException('template_property_unknown', $type, $name);
834
-					}
835
-					elseif(is_array($att) && $att[0] !== self::CONFIG_EXPRESSION)
891
+						if ($class->hasMethod('get' . $name) || $class->hasMethod('getjs' . $name)) {
892
+													throw new TConfigurationException('template_property_readonly', $type, $name);
893
+						} else {
894
+													throw new TConfigurationException('template_property_unknown', $type, $name);
895
+						}
896
+					} elseif(is_array($att) && $att[0] !== self::CONFIG_EXPRESSION)
836 897
 					{
837
-						if(strcasecmp($name, 'id') === 0)
838
-							throw new TConfigurationException('template_controlid_invalid', $type);
839
-						elseif(strcasecmp($name, 'skinid') === 0)
840
-							throw new TConfigurationException('template_controlskinid_invalid', $type);
898
+						if(strcasecmp($name, 'id') === 0) {
899
+													throw new TConfigurationException('template_controlid_invalid', $type);
900
+						} elseif(strcasecmp($name, 'skinid') === 0) {
901
+													throw new TConfigurationException('template_controlskinid_invalid', $type);
902
+						}
841 903
 					}
842 904
 				}
843 905
 			}
844
-		}
845
-		elseif(is_subclass_of($className, '\Prado\TComponent') || $className === '\Prado\TComponent')
906
+		} elseif(is_subclass_of($className, '\Prado\TComponent') || $className === '\Prado\TComponent')
846 907
 		{
847 908
 			foreach($attributes as $name => $att)
848 909
 			{
849
-				if(is_array($att) && ($att[0] === self::CONFIG_DATABIND))
850
-					throw new TConfigurationException('template_databind_forbidden', $type, $name);
910
+				if(is_array($att) && ($att[0] === self::CONFIG_DATABIND)) {
911
+									throw new TConfigurationException('template_databind_forbidden', $type, $name);
912
+				}
851 913
 				if(($pos = strpos($name, '.')) !== false)
852 914
 				{
853 915
 					// a subproperty, so the first segment must be readable
854 916
 					$subname = substr($name, 0, $pos);
855
-					if(!$class->hasMethod('get' . $subname))
856
-						throw new TConfigurationException('template_property_unknown', $type, $subname);
857
-				}
858
-				elseif(strncasecmp($name, 'on', 2) === 0)
859
-					throw new TConfigurationException('template_event_forbidden', $type, $name);
860
-				else
917
+					if(!$class->hasMethod('get' . $subname)) {
918
+											throw new TConfigurationException('template_property_unknown', $type, $subname);
919
+					}
920
+				} elseif(strncasecmp($name, 'on', 2) === 0) {
921
+									throw new TConfigurationException('template_event_forbidden', $type, $name);
922
+				} else
861 923
 				{
862 924
 					// id is still alowed for TComponent, even if id property doesn't exist
863 925
 					if(strcasecmp($name, 'id') !== 0 && !($class->hasMethod('set' . $name) || $this->isClassBehaviorMethod($class, 'set' . $name)))
864 926
 					{
865
-						if($class->hasMethod('get' . $name))
866
-							throw new TConfigurationException('template_property_readonly', $type, $name);
867
-						else
868
-							throw new TConfigurationException('template_property_unknown', $type, $name);
927
+						if($class->hasMethod('get' . $name)) {
928
+													throw new TConfigurationException('template_property_readonly', $type, $name);
929
+						} else {
930
+													throw new TConfigurationException('template_property_unknown', $type, $name);
931
+						}
869 932
 					}
870 933
 				}
871 934
 			}
935
+		} else {
936
+					throw new TConfigurationException('template_component_required', $type);
872 937
 		}
873
-		else
874
-			throw new TConfigurationException('template_component_required', $type);
875 938
 		return $class->getName();
876 939
 	}
877 940
 
@@ -895,9 +958,12 @@  discard block
 block discarded – undo
895 958
 	{
896 959
 		$srcFile = $this->_tplFile;
897 960
 
898
-		if(($n = count($this->_includedFiles)) > 0) // need to adjust error row number and file name
961
+		if(($n = count($this->_includedFiles)) > 0) {
962
+			// need to adjust error row number and file name
899 963
 		{
900
-			for($i = $n - 1;$i >= 0;--$i)
964
+			for($i = $n - 1;
965
+		}
966
+		$i >= 0;--$i)
901 967
 			{
902 968
 				if($this->_includeAtLine[$i] <= $line)
903 969
 				{
@@ -906,18 +972,19 @@  discard block
 block discarded – undo
906 972
 						$line = $line - $this->_includeAtLine[$i] + 1;
907 973
 						$srcFile = $this->_includedFiles[$i];
908 974
 						break;
975
+					} else {
976
+											$line = $line - $this->_includeLines[$i] + 1;
909 977
 					}
910
-					else
911
-						$line = $line - $this->_includeLines[$i] + 1;
912 978
 				}
913 979
 			}
914 980
 		}
915 981
 		$exception = new TTemplateException('template_format_invalid', $e->getMessage());
916 982
 		$exception->setLineNumber($line);
917
-		if(!empty($srcFile))
918
-			$exception->setTemplateFile($srcFile);
919
-		else
920
-			$exception->setTemplateSource($input);
983
+		if(!empty($srcFile)) {
984
+					$exception->setTemplateFile($srcFile);
985
+		} else {
986
+					$exception->setTemplateSource($input);
987
+		}
921 988
 		throw $exception;
922 989
 	}
923 990
 
@@ -933,9 +1000,9 @@  discard block
 block discarded – undo
933 1000
 			for($i = 0;$i < $n;++$i)
934 1001
 			{
935 1002
 				$filePath = Prado::getPathOfNamespace(trim($matches[$i][1][0]), TTemplateManager::TEMPLATE_FILE_EXT);
936
-				if($filePath !== null && is_file($filePath))
937
-					$this->_includedFiles[] = $filePath;
938
-				else
1003
+				if($filePath !== null && is_file($filePath)) {
1004
+									$this->_includedFiles[] = $filePath;
1005
+				} else
939 1006
 				{
940 1007
 					$errorLine = count(explode("\n", substr($input, 0, $matches[$i][0][1] + 1)));
941 1008
 					$this->handleException(new TConfigurationException('template_include_invalid', trim($matches[$i][1][0])), $errorLine, $input);
@@ -967,15 +1034,19 @@  discard block
 block discarded – undo
967 1034
 	{
968 1035
 	  $component = new \ReflectionClass('\Prado\TComponent');
969 1036
 	  $behaviors = $component->getStaticProperties();
970
-	  if(!isset($behaviors['_um']))
971
-		return false;
1037
+	  if(!isset($behaviors['_um'])) {
1038
+	  		return false;
1039
+	  }
972 1040
 	  foreach($behaviors['_um'] as $name => $list)
973 1041
 	  {
974
-		if(strtolower($class->getShortName()) !== $name && !$class->isSubclassOf($name)) continue;
1042
+		if(strtolower($class->getShortName()) !== $name && !$class->isSubclassOf($name)) {
1043
+			continue;
1044
+		}
975 1045
 		foreach($list as $param)
976 1046
 		{
977
-		  if(method_exists($param->getBehavior(), $method))
978
-			return true;
1047
+		  if(method_exists($param->getBehavior(), $method)) {
1048
+		  			return true;
1049
+		  }
979 1050
 		}
980 1051
 	  }
981 1052
 	  return false;
Please login to merge, or discard this patch.
framework/Web/UI/TEmptyControlCollection.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
 	 */
41 41
 	public function insertAt($index, $item)
42 42
 	{
43
-		if(!is_string($item))  // string is possible if property tag is used. we simply ignore it in this case
44
-			parent::insertAt($index, $item);  // this will generate an exception in parent implementation
43
+		if (!is_string($item))  // string is possible if property tag is used. we simply ignore it in this case
44
+			parent::insertAt($index, $item); // this will generate an exception in parent implementation
45 45
 	}
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,10 @@
 block discarded – undo
40 40
 	 */
41 41
 	public function insertAt($index, $item)
42 42
 	{
43
-		if(!is_string($item))  // string is possible if property tag is used. we simply ignore it in this case
44
-			parent::insertAt($index, $item);  // this will generate an exception in parent implementation
43
+		if(!is_string($item)) {
44
+			// string is possible if property tag is used. we simply ignore it in this case
45
+			parent::insertAt($index, $item);
46
+		}
47
+		// this will generate an exception in parent implementation
45 48
 	}
46 49
 }
47 50
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Web/UI/TCachePageStatePersister.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -110,15 +110,15 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function getCache()
112 112
 	{
113
-		if($this->_cache === null)
113
+		if ($this->_cache === null)
114 114
 		{
115
-			if($this->_cacheModuleID !== '')
115
+			if ($this->_cacheModuleID !== '')
116 116
 				$cache = Prado::getApplication()->getModule($this->_cacheModuleID);
117 117
 			else
118 118
 				$cache = Prado::getApplication()->getCache();
119
-			if($cache === null || !($cache instanceof ICache))
119
+			if ($cache === null || !($cache instanceof ICache))
120 120
 			{
121
-				if($this->_cacheModuleID !== '')
121
+				if ($this->_cacheModuleID !== '')
122 122
 					throw new TConfigurationException('cachepagestatepersister_cachemoduleid_invalid', $this->_cacheModuleID);
123 123
 				else
124 124
 					throw new TConfigurationException('cachepagestatepersister_cache_required');
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	public function setCacheTimeout($value)
144 144
 	{
145
-		if(($value = TPropertyValue::ensureInteger($value)) >= 0)
145
+		if (($value = TPropertyValue::ensureInteger($value)) >= 0)
146 146
 			$this->_timeout = $value;
147 147
 		else
148 148
 			throw new TInvalidDataValueException('cachepagestatepersister_timeout_invalid');
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	protected function calculateKey($timestamp)
172 172
 	{
173
-		return $this->getKeyPrefix() . ':'
173
+		return $this->getKeyPrefix().':'
174 174
 			. $this->_page->getRequest()->getUserHostAddress()
175 175
 			. $this->_page->getPagePath()
176 176
 			. $timestamp;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 */
183 183
 	public function save($data)
184 184
 	{
185
-		$timestamp = (string)microtime(true);
185
+		$timestamp = (string) microtime(true);
186 186
 		$key = $this->calculateKey($timestamp);
187 187
 		$this->getCache()->add($key, $data, $this->_timeout);
188 188
 		$this->_page->setClientState(TPageStateFormatter::serialize($this->_page, $timestamp));
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 	 */
196 196
 	public function load()
197 197
 	{
198
-		if(($timestamp = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null)
198
+		if (($timestamp = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null)
199 199
 		{
200 200
 			$key = $this->calculateKey($timestamp);
201
-			if(($data = $this->getCache()->get($key)) !== false)
201
+			if (($data = $this->getCache()->get($key)) !== false)
202 202
 				return $data;
203 203
 		}
204 204
 		throw new THttpException(400, 'cachepagestatepersister_pagestate_corrupted');
Please login to merge, or discard this patch.
Braces   +18 added lines, -14 removed lines patch added patch discarded remove patch
@@ -112,16 +112,18 @@  discard block
 block discarded – undo
112 112
 	{
113 113
 		if($this->_cache === null)
114 114
 		{
115
-			if($this->_cacheModuleID !== '')
116
-				$cache = Prado::getApplication()->getModule($this->_cacheModuleID);
117
-			else
118
-				$cache = Prado::getApplication()->getCache();
115
+			if($this->_cacheModuleID !== '') {
116
+							$cache = Prado::getApplication()->getModule($this->_cacheModuleID);
117
+			} else {
118
+							$cache = Prado::getApplication()->getCache();
119
+			}
119 120
 			if($cache === null || !($cache instanceof ICache))
120 121
 			{
121
-				if($this->_cacheModuleID !== '')
122
-					throw new TConfigurationException('cachepagestatepersister_cachemoduleid_invalid', $this->_cacheModuleID);
123
-				else
124
-					throw new TConfigurationException('cachepagestatepersister_cache_required');
122
+				if($this->_cacheModuleID !== '') {
123
+									throw new TConfigurationException('cachepagestatepersister_cachemoduleid_invalid', $this->_cacheModuleID);
124
+				} else {
125
+									throw new TConfigurationException('cachepagestatepersister_cache_required');
126
+				}
125 127
 			}
126 128
 			$this->_cache = $cache;
127 129
 		}
@@ -142,10 +144,11 @@  discard block
 block discarded – undo
142 144
 	 */
143 145
 	public function setCacheTimeout($value)
144 146
 	{
145
-		if(($value = TPropertyValue::ensureInteger($value)) >= 0)
146
-			$this->_timeout = $value;
147
-		else
148
-			throw new TInvalidDataValueException('cachepagestatepersister_timeout_invalid');
147
+		if(($value = TPropertyValue::ensureInteger($value)) >= 0) {
148
+					$this->_timeout = $value;
149
+		} else {
150
+					throw new TInvalidDataValueException('cachepagestatepersister_timeout_invalid');
151
+		}
149 152
 	}
150 153
 
151 154
 	/**
@@ -198,8 +201,9 @@  discard block
 block discarded – undo
198 201
 		if(($timestamp = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null)
199 202
 		{
200 203
 			$key = $this->calculateKey($timestamp);
201
-			if(($data = $this->getCache()->get($key)) !== false)
202
-				return $data;
204
+			if(($data = $this->getCache()->get($key)) !== false) {
205
+							return $data;
206
+			}
203 207
 		}
204 208
 		throw new THttpException(400, 'cachepagestatepersister_pagestate_corrupted');
205 209
 	}
Please login to merge, or discard this patch.
framework/Web/UI/TPageStateFormatter.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
 	public static function serialize($page, $data)
39 39
 	{
40 40
 		$sm = $page->getApplication()->getSecurityManager();
41
-		if($page->getEnableStateValidation())
41
+		if ($page->getEnableStateValidation())
42 42
 			$str = $sm->hashData(serialize($data));
43 43
 		else
44 44
 			$str = serialize($data);
45
-		if($page->getEnableStateCompression() && extension_loaded('zlib'))
45
+		if ($page->getEnableStateCompression() && extension_loaded('zlib'))
46 46
 			$str = gzcompress($str);
47
-		if($page->getEnableStateEncryption())
47
+		if ($page->getEnableStateEncryption())
48 48
 			$str = $sm->encrypt($str);
49 49
 		return base64_encode($str);
50 50
 	}
@@ -57,18 +57,18 @@  discard block
 block discarded – undo
57 57
 	public static function unserialize($page, $data)
58 58
 	{
59 59
 		$str = base64_decode($data);
60
-		if($str === '')
60
+		if ($str === '')
61 61
 			return null;
62
-		if($str !== false)
62
+		if ($str !== false)
63 63
 		{
64 64
 			$sm = $page->getApplication()->getSecurityManager();
65
-			if($page->getEnableStateEncryption())
65
+			if ($page->getEnableStateEncryption())
66 66
 				$str = $sm->decrypt($str);
67
-			if($page->getEnableStateCompression() && extension_loaded('zlib'))
67
+			if ($page->getEnableStateCompression() && extension_loaded('zlib'))
68 68
 				$str = @gzuncompress($str);
69
-			if($page->getEnableStateValidation())
69
+			if ($page->getEnableStateValidation())
70 70
 			{
71
-				if(($str = $sm->validateData($str)) !== false)
71
+				if (($str = $sm->validateData($str)) !== false)
72 72
 					return unserialize($str);
73 73
 			}
74 74
 			else
Please login to merge, or discard this patch.
Braces   +25 added lines, -18 removed lines patch added patch discarded remove patch
@@ -38,14 +38,17 @@  discard block
 block discarded – undo
38 38
 	public static function serialize($page, $data)
39 39
 	{
40 40
 		$sm = $page->getApplication()->getSecurityManager();
41
-		if($page->getEnableStateValidation())
42
-			$str = $sm->hashData(serialize($data));
43
-		else
44
-			$str = serialize($data);
45
-		if($page->getEnableStateCompression() && extension_loaded('zlib'))
46
-			$str = gzcompress($str);
47
-		if($page->getEnableStateEncryption())
48
-			$str = $sm->encrypt($str);
41
+		if($page->getEnableStateValidation()) {
42
+					$str = $sm->hashData(serialize($data));
43
+		} else {
44
+					$str = serialize($data);
45
+		}
46
+		if($page->getEnableStateCompression() && extension_loaded('zlib')) {
47
+					$str = gzcompress($str);
48
+		}
49
+		if($page->getEnableStateEncryption()) {
50
+					$str = $sm->encrypt($str);
51
+		}
49 52
 		return base64_encode($str);
50 53
 	}
51 54
 
@@ -57,22 +60,26 @@  discard block
 block discarded – undo
57 60
 	public static function unserialize($page, $data)
58 61
 	{
59 62
 		$str = base64_decode($data);
60
-		if($str === '')
61
-			return null;
63
+		if($str === '') {
64
+					return null;
65
+		}
62 66
 		if($str !== false)
63 67
 		{
64 68
 			$sm = $page->getApplication()->getSecurityManager();
65
-			if($page->getEnableStateEncryption())
66
-				$str = $sm->decrypt($str);
67
-			if($page->getEnableStateCompression() && extension_loaded('zlib'))
68
-				$str = @gzuncompress($str);
69
+			if($page->getEnableStateEncryption()) {
70
+							$str = $sm->decrypt($str);
71
+			}
72
+			if($page->getEnableStateCompression() && extension_loaded('zlib')) {
73
+							$str = @gzuncompress($str);
74
+			}
69 75
 			if($page->getEnableStateValidation())
70 76
 			{
71
-				if(($str = $sm->validateData($str)) !== false)
72
-					return unserialize($str);
77
+				if(($str = $sm->validateData($str)) !== false) {
78
+									return unserialize($str);
79
+				}
80
+			} else {
81
+							return unserialize($str);
73 82
 			}
74
-			else
75
-				return unserialize($str);
76 83
 		}
77 84
 		return null;
78 85
 	}
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/THotSpot.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	protected function getViewState($key, $defaultValue = null)
42 42
 	{
43
-		return isset($this->_viewState[$key])?$this->_viewState[$key]:$defaultValue;
43
+		return isset($this->_viewState[$key]) ? $this->_viewState[$key] : $defaultValue;
44 44
 	}
45 45
 
46 46
 	/**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	protected function setViewState($key, $value, $defaultValue = null)
57 57
 	{
58
-		if($value === $defaultValue)
58
+		if ($value === $defaultValue)
59 59
 			unset($this->_viewState[$key]);
60 60
 		else
61 61
 			$this->_viewState[$key] = $value;
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 */
222 222
 	public function getHasAttributes()
223 223
 	{
224
-		if($attributes = $this->getViewState('Attributes', null))
224
+		if ($attributes = $this->getViewState('Attributes', null))
225 225
 			return $attributes->getCount() > 0;
226 226
 		else
227 227
 			return false;
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 */
236 236
 	public function getAttributes()
237 237
 	{
238
-		if($attributes = $this->getViewState('Attributes', null))
238
+		if ($attributes = $this->getViewState('Attributes', null))
239 239
 			return $attributes;
240 240
 		else
241 241
 		{
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	public function hasAttribute($name)
252 252
 	{
253
-		if($attributes = $this->getViewState('Attributes', null))
253
+		if ($attributes = $this->getViewState('Attributes', null))
254 254
 			return $attributes->contains($name);
255 255
 		else
256 256
 			return false;
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function getAttribute($name)
263 263
 	{
264
-		if($attributes = $this->getViewState('Attributes', null))
264
+		if ($attributes = $this->getViewState('Attributes', null))
265 265
 			return $attributes->itemAt($name);
266 266
 		else
267 267
 			return null;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 */
285 285
 	public function removeAttribute($name)
286 286
 	{
287
-		if($attributes = $this->getViewState('Attributes', null))
287
+		if ($attributes = $this->getViewState('Attributes', null))
288 288
 			return $attributes->remove($name);
289 289
 		else
290 290
 			return null;
@@ -298,26 +298,26 @@  discard block
 block discarded – undo
298 298
 	{
299 299
 		$writer->addAttribute('shape', $this->getShape());
300 300
 		$writer->addAttribute('coords', $this->getCoordinates());
301
-		if(($mode = $this->getHotSpotMode()) === THotSpotMode::NotSet)
301
+		if (($mode = $this->getHotSpotMode()) === THotSpotMode::NotSet)
302 302
 			$mode = THotSpotMode::Navigate;
303
-		if($mode === THotSpotMode::Navigate)
303
+		if ($mode === THotSpotMode::Navigate)
304 304
 		{
305 305
 			$writer->addAttribute('href', $this->getNavigateUrl());
306
-			if(($target = $this->getTarget()) !== '')
306
+			if (($target = $this->getTarget()) !== '')
307 307
 				$writer->addAttribute('target', $target);
308 308
 		}
309
-		elseif($mode === THotSpotMode::Inactive)
309
+		elseif ($mode === THotSpotMode::Inactive)
310 310
 			$writer->addAttribute('nohref', 'true');
311 311
 		$text = $this->getAlternateText();
312 312
 		$writer->addAttribute('title', $text);
313 313
 		$writer->addAttribute('alt', $text);
314
-		if(($accessKey = $this->getAccessKey()) !== '')
314
+		if (($accessKey = $this->getAccessKey()) !== '')
315 315
 			$writer->addAttribute('accesskey', $accessKey);
316
-		if(($tabIndex = $this->getTabIndex()) !== 0)
316
+		if (($tabIndex = $this->getTabIndex()) !== 0)
317 317
 			$writer->addAttribute('tabindex', "$tabIndex");
318
-		if($this->getHasAttributes())
318
+		if ($this->getHasAttributes())
319 319
 		{
320
-			foreach($this->getAttributes() as $name => $value)
320
+			foreach ($this->getAttributes() as $name => $value)
321 321
 				$writer->addAttribute($name, $value);
322 322
 		}
323 323
 		$writer->renderBeginTag('area');
Please login to merge, or discard this patch.
Braces   +45 added lines, -35 removed lines patch added patch discarded remove patch
@@ -55,10 +55,11 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	protected function setViewState($key, $value, $defaultValue = null)
57 57
 	{
58
-		if($value === $defaultValue)
59
-			unset($this->_viewState[$key]);
60
-		else
61
-			$this->_viewState[$key] = $value;
58
+		if($value === $defaultValue) {
59
+					unset($this->_viewState[$key]);
60
+		} else {
61
+					$this->_viewState[$key] = $value;
62
+		}
62 63
 	}
63 64
 
64 65
 	/**
@@ -221,10 +222,11 @@  discard block
 block discarded – undo
221 222
 	 */
222 223
 	public function getHasAttributes()
223 224
 	{
224
-		if($attributes = $this->getViewState('Attributes', null))
225
-			return $attributes->getCount() > 0;
226
-		else
227
-			return false;
225
+		if($attributes = $this->getViewState('Attributes', null)) {
226
+					return $attributes->getCount() > 0;
227
+		} else {
228
+					return false;
229
+		}
228 230
 	}
229 231
 
230 232
 	/**
@@ -235,9 +237,9 @@  discard block
 block discarded – undo
235 237
 	 */
236 238
 	public function getAttributes()
237 239
 	{
238
-		if($attributes = $this->getViewState('Attributes', null))
239
-			return $attributes;
240
-		else
240
+		if($attributes = $this->getViewState('Attributes', null)) {
241
+					return $attributes;
242
+		} else
241 243
 		{
242 244
 			$attributes = new TAttributeCollection;
243 245
 			$this->setViewState('Attributes', $attributes, null);
@@ -250,10 +252,11 @@  discard block
 block discarded – undo
250 252
 	 */
251 253
 	public function hasAttribute($name)
252 254
 	{
253
-		if($attributes = $this->getViewState('Attributes', null))
254
-			return $attributes->contains($name);
255
-		else
256
-			return false;
255
+		if($attributes = $this->getViewState('Attributes', null)) {
256
+					return $attributes->contains($name);
257
+		} else {
258
+					return false;
259
+		}
257 260
 	}
258 261
 
259 262
 	/**
@@ -261,10 +264,11 @@  discard block
 block discarded – undo
261 264
 	 */
262 265
 	public function getAttribute($name)
263 266
 	{
264
-		if($attributes = $this->getViewState('Attributes', null))
265
-			return $attributes->itemAt($name);
266
-		else
267
-			return null;
267
+		if($attributes = $this->getViewState('Attributes', null)) {
268
+					return $attributes->itemAt($name);
269
+		} else {
270
+					return null;
271
+		}
268 272
 	}
269 273
 
270 274
 	/**
@@ -284,10 +288,11 @@  discard block
 block discarded – undo
284 288
 	 */
285 289
 	public function removeAttribute($name)
286 290
 	{
287
-		if($attributes = $this->getViewState('Attributes', null))
288
-			return $attributes->remove($name);
289
-		else
290
-			return null;
291
+		if($attributes = $this->getViewState('Attributes', null)) {
292
+					return $attributes->remove($name);
293
+		} else {
294
+					return null;
295
+		}
291 296
 	}
292 297
 
293 298
 	/**
@@ -298,27 +303,32 @@  discard block
 block discarded – undo
298 303
 	{
299 304
 		$writer->addAttribute('shape', $this->getShape());
300 305
 		$writer->addAttribute('coords', $this->getCoordinates());
301
-		if(($mode = $this->getHotSpotMode()) === THotSpotMode::NotSet)
302
-			$mode = THotSpotMode::Navigate;
306
+		if(($mode = $this->getHotSpotMode()) === THotSpotMode::NotSet) {
307
+					$mode = THotSpotMode::Navigate;
308
+		}
303 309
 		if($mode === THotSpotMode::Navigate)
304 310
 		{
305 311
 			$writer->addAttribute('href', $this->getNavigateUrl());
306
-			if(($target = $this->getTarget()) !== '')
307
-				$writer->addAttribute('target', $target);
312
+			if(($target = $this->getTarget()) !== '') {
313
+							$writer->addAttribute('target', $target);
314
+			}
315
+		} elseif($mode === THotSpotMode::Inactive) {
316
+					$writer->addAttribute('nohref', 'true');
308 317
 		}
309
-		elseif($mode === THotSpotMode::Inactive)
310
-			$writer->addAttribute('nohref', 'true');
311 318
 		$text = $this->getAlternateText();
312 319
 		$writer->addAttribute('title', $text);
313 320
 		$writer->addAttribute('alt', $text);
314
-		if(($accessKey = $this->getAccessKey()) !== '')
315
-			$writer->addAttribute('accesskey', $accessKey);
316
-		if(($tabIndex = $this->getTabIndex()) !== 0)
317
-			$writer->addAttribute('tabindex', "$tabIndex");
321
+		if(($accessKey = $this->getAccessKey()) !== '') {
322
+					$writer->addAttribute('accesskey', $accessKey);
323
+		}
324
+		if(($tabIndex = $this->getTabIndex()) !== 0) {
325
+					$writer->addAttribute('tabindex', "$tabIndex");
326
+		}
318 327
 		if($this->getHasAttributes())
319 328
 		{
320
-			foreach($this->getAttributes() as $name => $value)
321
-				$writer->addAttribute($name, $value);
329
+			foreach($this->getAttributes() as $name => $value) {
330
+							$writer->addAttribute($name, $value);
331
+			}
322 332
 		}
323 333
 		$writer->renderBeginTag('area');
324 334
 		$writer->renderEndTag();
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TStyle.php 2 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 		parent::_getZappableSleepProps($exprops);
57 57
 		if ($this->_fields === [])
58 58
 			$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_fields";
59
-		if($this->_font === null)
59
+		if ($this->_font === null)
60 60
 			$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_font";
61
-		if($this->_class === null)
61
+		if ($this->_class === null)
62 62
 			$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_class";
63 63
 		if ($this->_customStyle === null)
64 64
 			$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_customStyle";
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	public function __construct($style = null)
74 74
 	{
75 75
 	parent::__construct();
76
-		if($style !== null)
76
+		if ($style !== null)
77 77
 			$this->copyFrom($style);
78 78
 	}
79 79
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	public function __clone()
84 84
 	{
85
-		if($this->_font !== null)
85
+		if ($this->_font !== null)
86 86
 			$this->_font = clone($this->_font);
87 87
 	}
88 88
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function getBackColor()
93 93
 	{
94
-		return isset($this->_fields['background-color'])?$this->_fields['background-color']:'';
94
+		return isset($this->_fields['background-color']) ? $this->_fields['background-color'] : '';
95 95
 	}
96 96
 
97 97
 	/**
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function setBackColor($value)
101 101
 	{
102
-		if(trim($value) === '')
102
+		if (trim($value) === '')
103 103
 			unset($this->_fields['background-color']);
104 104
 		else
105 105
 			$this->_fields['background-color'] = $value;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function getBorderColor()
112 112
 	{
113
-		return isset($this->_fields['border-color'])?$this->_fields['border-color']:'';
113
+		return isset($this->_fields['border-color']) ? $this->_fields['border-color'] : '';
114 114
 	}
115 115
 
116 116
 	/**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function setBorderColor($value)
120 120
 	{
121
-		if(trim($value) === '')
121
+		if (trim($value) === '')
122 122
 			unset($this->_fields['border-color']);
123 123
 		else
124 124
 			$this->_fields['border-color'] = $value;
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	public function getBorderStyle()
131 131
 	{
132
-		return isset($this->_fields['border-style'])?$this->_fields['border-style']:'';
132
+		return isset($this->_fields['border-style']) ? $this->_fields['border-style'] : '';
133 133
 	}
134 134
 
135 135
 	/**
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public function setBorderStyle($value)
140 140
 	{
141
-		if(trim($value) === '')
141
+		if (trim($value) === '')
142 142
 			unset($this->_fields['border-style']);
143 143
 		else
144 144
 			$this->_fields['border-style'] = $value;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	public function getBorderWidth()
151 151
 	{
152
-		return isset($this->_fields['border-width'])?$this->_fields['border-width']:'';
152
+		return isset($this->_fields['border-width']) ? $this->_fields['border-width'] : '';
153 153
 	}
154 154
 
155 155
 	/**
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	public function setBorderWidth($value)
159 159
 	{
160
-		if(trim($value) === '')
160
+		if (trim($value) === '')
161 161
 			unset($this->_fields['border-width']);
162 162
 		else
163 163
 			$this->_fields['border-width'] = $value;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	public function getCssClass()
170 170
 	{
171
-		return $this->_class === null?'':$this->_class;
171
+		return $this->_class === null ? '' : $this->_class;
172 172
 	}
173 173
 
174 174
 	/**
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 */
193 193
 	public function getFont()
194 194
 	{
195
-		if($this->_font === null)
195
+		if ($this->_font === null)
196 196
 			$this->_font = new TFont;
197 197
 		return $this->_font;
198 198
 	}
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	public function setDisplayStyle($value)
212 212
 	{
213 213
 		$this->_displayStyle = TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TDisplayStyle');
214
-		switch($this->_displayStyle)
214
+		switch ($this->_displayStyle)
215 215
 		{
216 216
 			case TDisplayStyle::None:
217 217
 				$this->_fields['display'] = 'none';
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	public function getForeColor()
243 243
 	{
244
-		return isset($this->_fields['color'])?$this->_fields['color']:'';
244
+		return isset($this->_fields['color']) ? $this->_fields['color'] : '';
245 245
 	}
246 246
 
247 247
 	/**
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	 */
250 250
 	public function setForeColor($value)
251 251
 	{
252
-		if(trim($value) === '')
252
+		if (trim($value) === '')
253 253
 			unset($this->_fields['color']);
254 254
 		else
255 255
 			$this->_fields['color'] = $value;
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 */
261 261
 	public function getHeight()
262 262
 	{
263
-		return isset($this->_fields['height'])?$this->_fields['height']:'';
263
+		return isset($this->_fields['height']) ? $this->_fields['height'] : '';
264 264
 	}
265 265
 
266 266
 	/**
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 */
269 269
 	public function setHeight($value)
270 270
 	{
271
-		if(trim($value) === '')
271
+		if (trim($value) === '')
272 272
 			unset($this->_fields['height']);
273 273
 		else
274 274
 			$this->_fields['height'] = $value;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	public function getCustomStyle()
281 281
 	{
282
-		return $this->_customStyle === null?'':$this->_customStyle;
282
+		return $this->_customStyle === null ? '' : $this->_customStyle;
283 283
 	}
284 284
 
285 285
 	/**
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	public function getStyleField($name)
299 299
 	{
300
-		return isset($this->_fields[$name])?$this->_fields[$name]:'';
300
+		return isset($this->_fields[$name]) ? $this->_fields[$name] : '';
301 301
 	}
302 302
 
303 303
 	/**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 */
334 334
 	public function getWidth()
335 335
 	{
336
-		return isset($this->_fields['width'])?$this->_fields['width']:'';
336
+		return isset($this->_fields['width']) ? $this->_fields['width'] : '';
337 337
 	}
338 338
 
339 339
 	/**
@@ -363,14 +363,14 @@  discard block
 block discarded – undo
363 363
 	 */
364 364
 	public function copyFrom($style)
365 365
 	{
366
-		if($style instanceof TStyle)
366
+		if ($style instanceof TStyle)
367 367
 		{
368 368
 			$this->_fields = array_merge($this->_fields, $style->_fields);
369
-			if($style->_class !== null)
369
+			if ($style->_class !== null)
370 370
 				$this->_class = $style->_class;
371
-			if($style->_customStyle !== null)
371
+			if ($style->_customStyle !== null)
372 372
 				$this->_customStyle = $style->_customStyle;
373
-			if($style->_font !== null)
373
+			if ($style->_font !== null)
374 374
 				$this->getFont()->copyFrom($style->_font);
375 375
 		}
376 376
 	}
@@ -383,14 +383,14 @@  discard block
 block discarded – undo
383 383
 	 */
384 384
 	public function mergeWith($style)
385 385
 	{
386
-		if($style instanceof TStyle)
386
+		if ($style instanceof TStyle)
387 387
 		{
388 388
 			$this->_fields = array_merge($style->_fields, $this->_fields);
389
-			if($this->_class === null)
389
+			if ($this->_class === null)
390 390
 				$this->_class = $style->_class;
391
-			if($this->_customStyle === null)
391
+			if ($this->_customStyle === null)
392 392
 				$this->_customStyle = $style->_customStyle;
393
-			if($style->_font !== null)
393
+			if ($style->_font !== null)
394 394
 				$this->getFont()->mergeWith($style->_font);
395 395
 		}
396 396
 	}
@@ -401,19 +401,19 @@  discard block
 block discarded – undo
401 401
 	 */
402 402
 	public function addAttributesToRender($writer)
403 403
 	{
404
-		if($this->_customStyle !== null)
404
+		if ($this->_customStyle !== null)
405 405
 		{
406
-			foreach(explode(';', $this->_customStyle) as $style)
406
+			foreach (explode(';', $this->_customStyle) as $style)
407 407
 			{
408 408
 				$arr = explode(':', $style, 2);
409
-				if(isset($arr[1]) && trim($arr[0]) !== '')
409
+				if (isset($arr[1]) && trim($arr[0]) !== '')
410 410
 					$writer->addStyleAttribute(trim($arr[0]), trim($arr[1]));
411 411
 			}
412 412
 		}
413 413
 		$writer->addStyleAttributes($this->_fields);
414
-		if($this->_font !== null)
414
+		if ($this->_font !== null)
415 415
 			$this->_font->addAttributesToRender($writer);
416
-		if($this->_class !== null)
416
+		if ($this->_class !== null)
417 417
 			$writer->addAttribute('class', $this->_class);
418 418
 	}
419 419
 
Please login to merge, or discard this patch.
Braces   +81 added lines, -58 removed lines patch added patch discarded remove patch
@@ -54,16 +54,21 @@  discard block
 block discarded – undo
54 54
 	protected function _getZappableSleepProps(&$exprops)
55 55
 	{
56 56
 		parent::_getZappableSleepProps($exprops);
57
-		if ($this->_fields === [])
58
-			$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_fields";
59
-		if($this->_font === null)
60
-			$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_font";
61
-		if($this->_class === null)
62
-			$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_class";
63
-		if ($this->_customStyle === null)
64
-			$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_customStyle";
65
-		if ($this->_displayStyle === 'Fixed')
66
-			$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_displayStyle";
57
+		if ($this->_fields === []) {
58
+					$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_fields";
59
+		}
60
+		if($this->_font === null) {
61
+					$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_font";
62
+		}
63
+		if($this->_class === null) {
64
+					$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_class";
65
+		}
66
+		if ($this->_customStyle === null) {
67
+					$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_customStyle";
68
+		}
69
+		if ($this->_displayStyle === 'Fixed') {
70
+					$exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_displayStyle";
71
+		}
67 72
 	}
68 73
 
69 74
 	/**
@@ -73,8 +78,9 @@  discard block
 block discarded – undo
73 78
 	public function __construct($style = null)
74 79
 	{
75 80
 	parent::__construct();
76
-		if($style !== null)
77
-			$this->copyFrom($style);
81
+		if($style !== null) {
82
+					$this->copyFrom($style);
83
+		}
78 84
 	}
79 85
 
80 86
 	/**
@@ -82,8 +88,9 @@  discard block
 block discarded – undo
82 88
 	 */
83 89
 	public function __clone()
84 90
 	{
85
-		if($this->_font !== null)
86
-			$this->_font = clone($this->_font);
91
+		if($this->_font !== null) {
92
+					$this->_font = clone($this->_font);
93
+		}
87 94
 	}
88 95
 
89 96
 	/**
@@ -99,10 +106,11 @@  discard block
 block discarded – undo
99 106
 	 */
100 107
 	public function setBackColor($value)
101 108
 	{
102
-		if(trim($value) === '')
103
-			unset($this->_fields['background-color']);
104
-		else
105
-			$this->_fields['background-color'] = $value;
109
+		if(trim($value) === '') {
110
+					unset($this->_fields['background-color']);
111
+		} else {
112
+					$this->_fields['background-color'] = $value;
113
+		}
106 114
 	}
107 115
 
108 116
 	/**
@@ -118,10 +126,11 @@  discard block
 block discarded – undo
118 126
 	 */
119 127
 	public function setBorderColor($value)
120 128
 	{
121
-		if(trim($value) === '')
122
-			unset($this->_fields['border-color']);
123
-		else
124
-			$this->_fields['border-color'] = $value;
129
+		if(trim($value) === '') {
130
+					unset($this->_fields['border-color']);
131
+		} else {
132
+					$this->_fields['border-color'] = $value;
133
+		}
125 134
 	}
126 135
 
127 136
 	/**
@@ -138,10 +147,11 @@  discard block
 block discarded – undo
138 147
 	 */
139 148
 	public function setBorderStyle($value)
140 149
 	{
141
-		if(trim($value) === '')
142
-			unset($this->_fields['border-style']);
143
-		else
144
-			$this->_fields['border-style'] = $value;
150
+		if(trim($value) === '') {
151
+					unset($this->_fields['border-style']);
152
+		} else {
153
+					$this->_fields['border-style'] = $value;
154
+		}
145 155
 	}
146 156
 
147 157
 	/**
@@ -157,10 +167,11 @@  discard block
 block discarded – undo
157 167
 	 */
158 168
 	public function setBorderWidth($value)
159 169
 	{
160
-		if(trim($value) === '')
161
-			unset($this->_fields['border-width']);
162
-		else
163
-			$this->_fields['border-width'] = $value;
170
+		if(trim($value) === '') {
171
+					unset($this->_fields['border-width']);
172
+		} else {
173
+					$this->_fields['border-width'] = $value;
174
+		}
164 175
 	}
165 176
 
166 177
 	/**
@@ -192,8 +203,9 @@  discard block
 block discarded – undo
192 203
 	 */
193 204
 	public function getFont()
194 205
 	{
195
-		if($this->_font === null)
196
-			$this->_font = new TFont;
206
+		if($this->_font === null) {
207
+					$this->_font = new TFont;
208
+		}
197 209
 		return $this->_font;
198 210
 	}
199 211
 
@@ -249,10 +261,11 @@  discard block
 block discarded – undo
249 261
 	 */
250 262
 	public function setForeColor($value)
251 263
 	{
252
-		if(trim($value) === '')
253
-			unset($this->_fields['color']);
254
-		else
255
-			$this->_fields['color'] = $value;
264
+		if(trim($value) === '') {
265
+					unset($this->_fields['color']);
266
+		} else {
267
+					$this->_fields['color'] = $value;
268
+		}
256 269
 	}
257 270
 
258 271
 	/**
@@ -268,10 +281,11 @@  discard block
 block discarded – undo
268 281
 	 */
269 282
 	public function setHeight($value)
270 283
 	{
271
-		if(trim($value) === '')
272
-			unset($this->_fields['height']);
273
-		else
274
-			$this->_fields['height'] = $value;
284
+		if(trim($value) === '') {
285
+					unset($this->_fields['height']);
286
+		} else {
287
+					$this->_fields['height'] = $value;
288
+		}
275 289
 	}
276 290
 
277 291
 	/**
@@ -366,12 +380,15 @@  discard block
 block discarded – undo
366 380
 		if($style instanceof TStyle)
367 381
 		{
368 382
 			$this->_fields = array_merge($this->_fields, $style->_fields);
369
-			if($style->_class !== null)
370
-				$this->_class = $style->_class;
371
-			if($style->_customStyle !== null)
372
-				$this->_customStyle = $style->_customStyle;
373
-			if($style->_font !== null)
374
-				$this->getFont()->copyFrom($style->_font);
383
+			if($style->_class !== null) {
384
+							$this->_class = $style->_class;
385
+			}
386
+			if($style->_customStyle !== null) {
387
+							$this->_customStyle = $style->_customStyle;
388
+			}
389
+			if($style->_font !== null) {
390
+							$this->getFont()->copyFrom($style->_font);
391
+			}
375 392
 		}
376 393
 	}
377 394
 
@@ -386,12 +403,15 @@  discard block
 block discarded – undo
386 403
 		if($style instanceof TStyle)
387 404
 		{
388 405
 			$this->_fields = array_merge($style->_fields, $this->_fields);
389
-			if($this->_class === null)
390
-				$this->_class = $style->_class;
391
-			if($this->_customStyle === null)
392
-				$this->_customStyle = $style->_customStyle;
393
-			if($style->_font !== null)
394
-				$this->getFont()->mergeWith($style->_font);
406
+			if($this->_class === null) {
407
+							$this->_class = $style->_class;
408
+			}
409
+			if($this->_customStyle === null) {
410
+							$this->_customStyle = $style->_customStyle;
411
+			}
412
+			if($style->_font !== null) {
413
+							$this->getFont()->mergeWith($style->_font);
414
+			}
395 415
 		}
396 416
 	}
397 417
 
@@ -406,15 +426,18 @@  discard block
 block discarded – undo
406 426
 			foreach(explode(';', $this->_customStyle) as $style)
407 427
 			{
408 428
 				$arr = explode(':', $style, 2);
409
-				if(isset($arr[1]) && trim($arr[0]) !== '')
410
-					$writer->addStyleAttribute(trim($arr[0]), trim($arr[1]));
429
+				if(isset($arr[1]) && trim($arr[0]) !== '') {
430
+									$writer->addStyleAttribute(trim($arr[0]), trim($arr[1]));
431
+				}
411 432
 			}
412 433
 		}
413 434
 		$writer->addStyleAttributes($this->_fields);
414
-		if($this->_font !== null)
415
-			$this->_font->addAttributesToRender($writer);
416
-		if($this->_class !== null)
417
-			$writer->addAttribute('class', $this->_class);
435
+		if($this->_font !== null) {
436
+					$this->_font->addAttributesToRender($writer);
437
+		}
438
+		if($this->_class !== null) {
439
+					$writer->addAttribute('class', $this->_class);
440
+		}
418 441
 	}
419 442
 
420 443
 	/**
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TWizardNavigationTemplate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 	 */
63 63
 	protected function createNavigationButton($buttonStyle, $causesValidation, $commandName)
64 64
 	{
65
-		switch($buttonStyle->getButtonType())
65
+		switch ($buttonStyle->getButtonType())
66 66
 		{
67 67
 			case TWizardNavigationButtonType::Button:
68 68
 				$button = new TButton;
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TContentPlaceHolder.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 	 */
42 42
 	public function createdOnTemplate($parent)
43 43
 	{
44
-		if(($id = $this->getID()) === '')
44
+		if (($id = $this->getID()) === '')
45 45
 			throw new TConfigurationException('contentplaceholder_id_required');
46 46
 		$this->getTemplateControl()->registerContentPlaceHolder($id, $this);
47 47
 		$parent->getControls()->add($this);
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,8 +41,9 @@
 block discarded – undo
41 41
 	 */
42 42
 	public function createdOnTemplate($parent)
43 43
 	{
44
-		if(($id = $this->getID()) === '')
45
-			throw new TConfigurationException('contentplaceholder_id_required');
44
+		if(($id = $this->getID()) === '') {
45
+					throw new TConfigurationException('contentplaceholder_id_required');
46
+		}
46 47
 		$this->getTemplateControl()->registerContentPlaceHolder($id, $this);
47 48
 		$parent->getControls()->add($this);
48 49
 	}
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TDataSourceSelectParameters.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 	public function setStartRowIndex($value)
36 36
 	{
37
-		if(($value = TPropertyValue::ensureInteger($value)) < 0)
37
+		if (($value = TPropertyValue::ensureInteger($value)) < 0)
38 38
 			$value = 0;
39 39
 		$this->_startRowIndex = $value;
40 40
 	}
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
 	public function setMaximumRows($value)
48 48
 	{
49
-		if(($value = TPropertyValue::ensureInteger($value)) < 0)
49
+		if (($value = TPropertyValue::ensureInteger($value)) < 0)
50 50
 			$value = 0;
51 51
 		$this->_maximumRows = $value;
52 52
 	}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
 	public function setTotalRowCount($value)
70 70
 	{
71
-		if(($value = TPropertyValue::ensureInteger($value)) < 0)
71
+		if (($value = TPropertyValue::ensureInteger($value)) < 0)
72 72
 			$value = 0;
73 73
 		$this->_totalRowCount = $value;
74 74
 	}
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,8 +34,9 @@  discard block
 block discarded – undo
34 34
 
35 35
 	public function setStartRowIndex($value)
36 36
 	{
37
-		if(($value = TPropertyValue::ensureInteger($value)) < 0)
38
-			$value = 0;
37
+		if(($value = TPropertyValue::ensureInteger($value)) < 0) {
38
+					$value = 0;
39
+		}
39 40
 		$this->_startRowIndex = $value;
40 41
 	}
41 42
 
@@ -46,8 +47,9 @@  discard block
 block discarded – undo
46 47
 
47 48
 	public function setMaximumRows($value)
48 49
 	{
49
-		if(($value = TPropertyValue::ensureInteger($value)) < 0)
50
-			$value = 0;
50
+		if(($value = TPropertyValue::ensureInteger($value)) < 0) {
51
+					$value = 0;
52
+		}
51 53
 		$this->_maximumRows = $value;
52 54
 	}
53 55
 
@@ -68,8 +70,9 @@  discard block
 block discarded – undo
68 70
 
69 71
 	public function setTotalRowCount($value)
70 72
 	{
71
-		if(($value = TPropertyValue::ensureInteger($value)) < 0)
72
-			$value = 0;
73
+		if(($value = TPropertyValue::ensureInteger($value)) < 0) {
74
+					$value = 0;
75
+		}
73 76
 		$this->_totalRowCount = $value;
74 77
 	}
75 78
 }
76 79
\ No newline at end of file
Please login to merge, or discard this patch.