@@ -114,17 +114,17 @@ discard block |
||
114 | 114 | * Indexes for the rare fields. |
115 | 115 | * In order to save memory, rare fields will only be created if they are needed. |
116 | 116 | */ |
117 | - const RF_CONTROLS = 0; // child controls |
|
118 | - const RF_CHILD_STATE = 1; // child state field |
|
119 | - const RF_NAMED_CONTROLS = 2; // list of controls whose namingcontainer is this control |
|
120 | - const RF_NAMED_CONTROLS_ID = 3; // counter for automatic id |
|
121 | - const RF_SKIN_ID = 4; // skin ID |
|
122 | - const RF_DATA_BINDINGS = 5; // data bindings |
|
123 | - const RF_EVENTS = 6; // event handlers |
|
124 | - const RF_CONTROLSTATE = 7; // controlstate |
|
125 | - const RF_NAMED_OBJECTS = 8; // controls declared with ID on template |
|
126 | - const RF_ADAPTER = 9; // adapter |
|
127 | - const RF_AUTO_BINDINGS = 10; // auto data bindings |
|
117 | + const RF_CONTROLS = 0; // child controls |
|
118 | + const RF_CHILD_STATE = 1; // child state field |
|
119 | + const RF_NAMED_CONTROLS = 2; // list of controls whose namingcontainer is this control |
|
120 | + const RF_NAMED_CONTROLS_ID = 3; // counter for automatic id |
|
121 | + const RF_SKIN_ID = 4; // skin ID |
|
122 | + const RF_DATA_BINDINGS = 5; // data bindings |
|
123 | + const RF_EVENTS = 6; // event handlers |
|
124 | + const RF_CONTROLSTATE = 7; // controlstate |
|
125 | + const RF_NAMED_OBJECTS = 8; // controls declared with ID on template |
|
126 | + const RF_ADAPTER = 9; // adapter |
|
127 | + const RF_AUTO_BINDINGS = 10; // auto data bindings |
|
128 | 128 | |
129 | 129 | /** |
130 | 130 | * @var string control ID |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function __get($name) |
195 | 195 | { |
196 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
196 | + if (isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
197 | 197 | return $this->_rf[self::RF_NAMED_OBJECTS][$name]; |
198 | 198 | else |
199 | 199 | return parent::__get($name); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @see __get |
218 | 218 | */ |
219 | 219 | public function __isset($name) { |
220 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) { |
|
220 | + if (isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) { |
|
221 | 221 | return true; |
222 | 222 | } else { |
223 | 223 | return parent::__isset($name); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function getAdapter() |
239 | 239 | { |
240 | - return isset($this->_rf[self::RF_ADAPTER])?$this->_rf[self::RF_ADAPTER]:null; |
|
240 | + return isset($this->_rf[self::RF_ADAPTER]) ? $this->_rf[self::RF_ADAPTER] : null; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function getNamingContainer() |
263 | 263 | { |
264 | - if(!$this->_namingContainer && $this->_parent) |
|
264 | + if (!$this->_namingContainer && $this->_parent) |
|
265 | 265 | { |
266 | - if($this->_parent instanceof INamingContainer) |
|
266 | + if ($this->_parent instanceof INamingContainer) |
|
267 | 267 | $this->_namingContainer = $this->_parent; |
268 | 268 | else |
269 | 269 | $this->_namingContainer = $this->_parent->getNamingContainer(); |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function getPage() |
278 | 278 | { |
279 | - if(!$this->_page) |
|
279 | + if (!$this->_page) |
|
280 | 280 | { |
281 | - if($this->_parent) |
|
281 | + if ($this->_parent) |
|
282 | 282 | $this->_page = $this->_parent->getPage(); |
283 | - elseif($this->_tplControl) |
|
283 | + elseif ($this->_tplControl) |
|
284 | 284 | $this->_page = $this->_tplControl->getPage(); |
285 | 285 | } |
286 | 286 | return $this->_page; |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function getTemplateControl() |
313 | 313 | { |
314 | - if(!$this->_tplControl && $this->_parent) |
|
314 | + if (!$this->_tplControl && $this->_parent) |
|
315 | 315 | $this->_tplControl = $this->_parent->getTemplateControl(); |
316 | 316 | return $this->_tplControl; |
317 | 317 | } |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | public function getSourceTemplateControl() |
325 | 325 | { |
326 | 326 | $control = $this; |
327 | - while(($control instanceof TControl) && ($control = $control->getTemplateControl()) !== null) |
|
327 | + while (($control instanceof TControl) && ($control = $control->getTemplateControl()) !== null) |
|
328 | 328 | { |
329 | - if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) |
|
329 | + if (($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) |
|
330 | 330 | return $control; |
331 | 331 | } |
332 | 332 | return $this->getPage(); |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | */ |
366 | 366 | public function getID($hideAutoID = true) |
367 | 367 | { |
368 | - if($hideAutoID) |
|
368 | + if ($hideAutoID) |
|
369 | 369 | return ($this->_flags & self::IS_ID_SET) ? $this->_id : ''; |
370 | 370 | else |
371 | 371 | return $this->_id; |
@@ -377,12 +377,12 @@ discard block |
||
377 | 377 | */ |
378 | 378 | public function setID($id) |
379 | 379 | { |
380 | - if(!preg_match(self::ID_FORMAT, $id)) |
|
380 | + if (!preg_match(self::ID_FORMAT, $id)) |
|
381 | 381 | throw new TInvalidDataValueException('control_id_invalid', get_class($this), $id); |
382 | 382 | $this->_id = $id; |
383 | 383 | $this->_flags |= self::IS_ID_SET; |
384 | 384 | $this->clearCachedUniqueID($this instanceof INamingContainer); |
385 | - if($this->_namingContainer) |
|
385 | + if ($this->_namingContainer) |
|
386 | 386 | $this->_namingContainer->clearNameTable(); |
387 | 387 | } |
388 | 388 | |
@@ -395,17 +395,17 @@ discard block |
||
395 | 395 | */ |
396 | 396 | public function getUniqueID() |
397 | 397 | { |
398 | - if($this->_uid === '' || $this->_uid === null) // need to build the UniqueID |
|
398 | + if ($this->_uid === '' || $this->_uid === null) // need to build the UniqueID |
|
399 | 399 | { |
400 | - $this->_uid = ''; // set to not-null, so that clearCachedUniqueID() may take action |
|
401 | - if($namingContainer = $this->getNamingContainer()) |
|
400 | + $this->_uid = ''; // set to not-null, so that clearCachedUniqueID() may take action |
|
401 | + if ($namingContainer = $this->getNamingContainer()) |
|
402 | 402 | { |
403 | - if($this->getPage() === $namingContainer) |
|
403 | + if ($this->getPage() === $namingContainer) |
|
404 | 404 | return ($this->_uid = $this->_id); |
405 | - elseif(($prefix = $namingContainer->getUniqueID()) === '') |
|
405 | + elseif (($prefix = $namingContainer->getUniqueID()) === '') |
|
406 | 406 | return $this->_id; |
407 | 407 | else |
408 | - return ($this->_uid = $prefix . self::ID_SEPARATOR . $this->_id); |
|
408 | + return ($this->_uid = $prefix.self::ID_SEPARATOR.$this->_id); |
|
409 | 409 | } |
410 | 410 | else // no naming container |
411 | 411 | return $this->_id; |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | */ |
450 | 450 | public function getSkinID() |
451 | 451 | { |
452 | - return isset($this->_rf[self::RF_SKIN_ID])?$this->_rf[self::RF_SKIN_ID]:''; |
|
452 | + return isset($this->_rf[self::RF_SKIN_ID]) ? $this->_rf[self::RF_SKIN_ID] : ''; |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | */ |
459 | 459 | public function setSkinID($value) |
460 | 460 | { |
461 | - if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage >= self::CS_CHILD_INITIALIZED) |
|
461 | + if (($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage >= self::CS_CHILD_INITIALIZED) |
|
462 | 462 | throw new TInvalidOperationException('control_skinid_unchangeable', get_class($this)); |
463 | 463 | else |
464 | 464 | $this->_rf[self::RF_SKIN_ID] = $value; |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function getEnableTheming() |
481 | 481 | { |
482 | - if($this->_flags & self::IS_DISABLE_THEMING) |
|
482 | + if ($this->_flags & self::IS_DISABLE_THEMING) |
|
483 | 483 | return false; |
484 | 484 | else |
485 | - return $this->_parent?$this->_parent->getEnableTheming():true; |
|
485 | + return $this->_parent ? $this->_parent->getEnableTheming() : true; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
@@ -491,9 +491,9 @@ discard block |
||
491 | 491 | */ |
492 | 492 | public function setEnableTheming($value) |
493 | 493 | { |
494 | - if($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
494 | + if ($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
495 | 495 | throw new TInvalidOperationException('control_enabletheming_unchangeable', get_class($this), $this->getUniqueID()); |
496 | - elseif(TPropertyValue::ensureBoolean($value)) |
|
496 | + elseif (TPropertyValue::ensureBoolean($value)) |
|
497 | 497 | $this->_flags &= ~self::IS_DISABLE_THEMING; |
498 | 498 | else |
499 | 499 | $this->_flags |= self::IS_DISABLE_THEMING; |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | */ |
535 | 535 | public function getControls() |
536 | 536 | { |
537 | - if(!isset($this->_rf[self::RF_CONTROLS])) |
|
537 | + if (!isset($this->_rf[self::RF_CONTROLS])) |
|
538 | 538 | $this->_rf[self::RF_CONTROLS] = $this->createControlCollection(); |
539 | 539 | return $this->_rf[self::RF_CONTROLS]; |
540 | 540 | } |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | */ |
547 | 547 | protected function createControlCollection() |
548 | 548 | { |
549 | - return $this->getAllowChildControls()?new TControlCollection($this):new TEmptyControlCollection($this); |
|
549 | + return $this->getAllowChildControls() ? new TControlCollection($this) : new TEmptyControlCollection($this); |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | /** |
@@ -558,10 +558,10 @@ discard block |
||
558 | 558 | */ |
559 | 559 | public function getVisible($checkParents = true) |
560 | 560 | { |
561 | - if($checkParents) |
|
561 | + if ($checkParents) |
|
562 | 562 | { |
563 | - for($control = $this;$control;$control = $control->_parent) |
|
564 | - if(!$control->getVisible(false)) |
|
563 | + for ($control = $this; $control; $control = $control->_parent) |
|
564 | + if (!$control->getVisible(false)) |
|
565 | 565 | return false; |
566 | 566 | return true; |
567 | 567 | } |
@@ -589,10 +589,10 @@ discard block |
||
589 | 589 | */ |
590 | 590 | public function getEnabled($checkParents = false) |
591 | 591 | { |
592 | - if($checkParents) |
|
592 | + if ($checkParents) |
|
593 | 593 | { |
594 | - for($control = $this;$control;$control = $control->_parent) |
|
595 | - if(!$control->getViewState('Enabled', true)) |
|
594 | + for ($control = $this; $control; $control = $control->_parent) |
|
595 | + if (!$control->getViewState('Enabled', true)) |
|
596 | 596 | return false; |
597 | 597 | return true; |
598 | 598 | } |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | */ |
614 | 614 | public function getHasAttributes() |
615 | 615 | { |
616 | - if($attributes = $this->getViewState('Attributes', null)) |
|
616 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
617 | 617 | return $attributes->getCount() > 0; |
618 | 618 | else |
619 | 619 | return false; |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | */ |
628 | 628 | public function getAttributes() |
629 | 629 | { |
630 | - if($attributes = $this->getViewState('Attributes', null)) |
|
630 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
631 | 631 | return $attributes; |
632 | 632 | else |
633 | 633 | { |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | */ |
643 | 643 | public function hasAttribute($name) |
644 | 644 | { |
645 | - if($attributes = $this->getViewState('Attributes', null)) |
|
645 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
646 | 646 | return $attributes->contains($name); |
647 | 647 | else |
648 | 648 | return false; |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | */ |
654 | 654 | public function getAttribute($name) |
655 | 655 | { |
656 | - if($attributes = $this->getViewState('Attributes', null)) |
|
656 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
657 | 657 | return $attributes->itemAt($name); |
658 | 658 | else |
659 | 659 | return null; |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | */ |
677 | 677 | public function removeAttribute($name) |
678 | 678 | { |
679 | - if($attributes = $this->getViewState('Attributes', null)) |
|
679 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
680 | 680 | return $attributes->remove($name); |
681 | 681 | else |
682 | 682 | return null; |
@@ -687,10 +687,10 @@ discard block |
||
687 | 687 | */ |
688 | 688 | public function getEnableViewState($checkParents = false) |
689 | 689 | { |
690 | - if($checkParents) |
|
690 | + if ($checkParents) |
|
691 | 691 | { |
692 | - for($control = $this;$control !== null;$control = $control->getParent()) |
|
693 | - if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
692 | + for ($control = $this; $control !== null; $control = $control->getParent()) |
|
693 | + if ($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
694 | 694 | return false; |
695 | 695 | return true; |
696 | 696 | } |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | */ |
704 | 704 | public function setEnableViewState($value) |
705 | 705 | { |
706 | - if(TPropertyValue::ensureBoolean($value)) |
|
706 | + if (TPropertyValue::ensureBoolean($value)) |
|
707 | 707 | $this->_flags &= ~self::IS_DISABLE_VIEWSTATE; |
708 | 708 | else |
709 | 709 | $this->_flags |= self::IS_DISABLE_VIEWSTATE; |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | */ |
721 | 721 | protected function getControlState($key, $defaultValue = null) |
722 | 722 | { |
723 | - return isset($this->_rf[self::RF_CONTROLSTATE][$key])?$this->_rf[self::RF_CONTROLSTATE][$key]:$defaultValue; |
|
723 | + return isset($this->_rf[self::RF_CONTROLSTATE][$key]) ? $this->_rf[self::RF_CONTROLSTATE][$key] : $defaultValue; |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | /** |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | */ |
736 | 736 | protected function setControlState($key, $value, $defaultValue = null) |
737 | 737 | { |
738 | - if($value === $defaultValue) |
|
738 | + if ($value === $defaultValue) |
|
739 | 739 | unset($this->_rf[self::RF_CONTROLSTATE][$key]); |
740 | 740 | else |
741 | 741 | $this->_rf[self::RF_CONTROLSTATE][$key] = $value; |
@@ -772,11 +772,11 @@ discard block |
||
772 | 772 | */ |
773 | 773 | public function getViewState($key, $defaultValue = null) |
774 | 774 | { |
775 | - if(isset($this->_viewState[$key])) |
|
776 | - return $this->_viewState[$key] !== null?$this->_viewState[$key]:$defaultValue; |
|
777 | - elseif(isset($this->_tempState[$key])) |
|
775 | + if (isset($this->_viewState[$key])) |
|
776 | + return $this->_viewState[$key] !== null ? $this->_viewState[$key] : $defaultValue; |
|
777 | + elseif (isset($this->_tempState[$key])) |
|
778 | 778 | { |
779 | - if(is_object($this->_tempState[$key]) && $this->_trackViewState) |
|
779 | + if (is_object($this->_tempState[$key]) && $this->_trackViewState) |
|
780 | 780 | $this->_viewState[$key] = $this->_tempState[$key]; |
781 | 781 | return $this->_tempState[$key]; |
782 | 782 | } |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | */ |
797 | 797 | public function setViewState($key, $value, $defaultValue = null) |
798 | 798 | { |
799 | - if($this->_trackViewState) |
|
799 | + if ($this->_trackViewState) |
|
800 | 800 | { |
801 | 801 | unset($this->_tempState[$key]); |
802 | 802 | $this->_viewState[$key] = $value; |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | else |
805 | 805 | { |
806 | 806 | unset($this->_viewState[$key]); |
807 | - if($value === $defaultValue) |
|
807 | + if ($value === $defaultValue) |
|
808 | 808 | unset($this->_tempState[$key]); |
809 | 809 | else |
810 | 810 | $this->_tempState[$key] = $value; |
@@ -870,11 +870,11 @@ discard block |
||
870 | 870 | protected function dataBindProperties() |
871 | 871 | { |
872 | 872 | Prado::trace("Data bind properties", 'Prado\Web\UI\TControl'); |
873 | - if(isset($this->_rf[self::RF_DATA_BINDINGS])) |
|
873 | + if (isset($this->_rf[self::RF_DATA_BINDINGS])) |
|
874 | 874 | { |
875 | - if(($context = $this->getTemplateControl()) === null) |
|
875 | + if (($context = $this->getTemplateControl()) === null) |
|
876 | 876 | $context = $this; |
877 | - foreach($this->_rf[self::RF_DATA_BINDINGS] as $property => $expression) |
|
877 | + foreach ($this->_rf[self::RF_DATA_BINDINGS] as $property => $expression) |
|
878 | 878 | $this->setSubProperty($property, $context->evaluateExpression($expression)); |
879 | 879 | } |
880 | 880 | } |
@@ -884,11 +884,11 @@ discard block |
||
884 | 884 | */ |
885 | 885 | protected function autoDataBindProperties() |
886 | 886 | { |
887 | - if(isset($this->_rf[self::RF_AUTO_BINDINGS])) |
|
887 | + if (isset($this->_rf[self::RF_AUTO_BINDINGS])) |
|
888 | 888 | { |
889 | - if(($context = $this->getTemplateControl()) === null) |
|
889 | + if (($context = $this->getTemplateControl()) === null) |
|
890 | 890 | $context = $this; |
891 | - foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property => $expression) |
|
891 | + foreach ($this->_rf[self::RF_AUTO_BINDINGS] as $property => $expression) |
|
892 | 892 | $this->setSubProperty($property, $context->evaluateExpression($expression)); |
893 | 893 | } |
894 | 894 | } |
@@ -899,10 +899,10 @@ discard block |
||
899 | 899 | protected function dataBindChildren() |
900 | 900 | { |
901 | 901 | Prado::trace("dataBindChildren()", 'Prado\Web\UI\TControl'); |
902 | - if(isset($this->_rf[self::RF_CONTROLS])) |
|
902 | + if (isset($this->_rf[self::RF_CONTROLS])) |
|
903 | 903 | { |
904 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
905 | - if($control instanceof IBindable) |
|
904 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
905 | + if ($control instanceof IBindable) |
|
906 | 906 | $control->dataBind(); |
907 | 907 | } |
908 | 908 | } |
@@ -922,11 +922,11 @@ discard block |
||
922 | 922 | */ |
923 | 923 | final protected function setChildControlsCreated($value) |
924 | 924 | { |
925 | - if($value) |
|
925 | + if ($value) |
|
926 | 926 | $this->_flags |= self::IS_CHILD_CREATED; |
927 | 927 | else |
928 | 928 | { |
929 | - if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) |
|
929 | + if ($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) |
|
930 | 930 | $this->getControls()->clear(); |
931 | 931 | $this->_flags &= ~self::IS_CHILD_CREATED; |
932 | 932 | } |
@@ -939,19 +939,19 @@ discard block |
||
939 | 939 | */ |
940 | 940 | public function ensureChildControls() |
941 | 941 | { |
942 | - if(!($this->_flags & self::IS_CHILD_CREATED) && !($this->_flags & self::IS_CREATING_CHILD)) |
|
942 | + if (!($this->_flags & self::IS_CHILD_CREATED) && !($this->_flags & self::IS_CREATING_CHILD)) |
|
943 | 943 | { |
944 | 944 | try |
945 | 945 | { |
946 | 946 | $this->_flags |= self::IS_CREATING_CHILD; |
947 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
947 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
948 | 948 | $this->_rf[self::RF_ADAPTER]->createChildControls(); |
949 | 949 | else |
950 | 950 | $this->createChildControls(); |
951 | 951 | $this->_flags &= ~self::IS_CREATING_CHILD; |
952 | 952 | $this->_flags |= self::IS_CHILD_CREATED; |
953 | 953 | } |
954 | - catch(Exception $e) |
|
954 | + catch (Exception $e) |
|
955 | 955 | { |
956 | 956 | $this->_flags &= ~self::IS_CREATING_CHILD; |
957 | 957 | $this->_flags |= self::IS_CHILD_CREATED; |
@@ -984,21 +984,21 @@ discard block |
||
984 | 984 | public function findControl($id) |
985 | 985 | { |
986 | 986 | $id = strtr($id, '.', self::ID_SEPARATOR); |
987 | - $container = ($this instanceof INamingContainer)?$this:$this->getNamingContainer(); |
|
988 | - if(!$container || !$container->getHasControls()) |
|
987 | + $container = ($this instanceof INamingContainer) ? $this : $this->getNamingContainer(); |
|
988 | + if (!$container || !$container->getHasControls()) |
|
989 | 989 | return null; |
990 | - if(!isset($container->_rf[self::RF_NAMED_CONTROLS])) |
|
990 | + if (!isset($container->_rf[self::RF_NAMED_CONTROLS])) |
|
991 | 991 | { |
992 | 992 | $container->_rf[self::RF_NAMED_CONTROLS] = []; |
993 | 993 | $container->fillNameTable($container, $container->_rf[self::RF_CONTROLS]); |
994 | 994 | } |
995 | - if(($pos = strpos($id, self::ID_SEPARATOR)) === false) |
|
996 | - return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null; |
|
995 | + if (($pos = strpos($id, self::ID_SEPARATOR)) === false) |
|
996 | + return isset($container->_rf[self::RF_NAMED_CONTROLS][$id]) ? $container->_rf[self::RF_NAMED_CONTROLS][$id] : null; |
|
997 | 997 | else |
998 | 998 | { |
999 | 999 | $cid = substr($id, 0, $pos); |
1000 | 1000 | $sid = substr($id, $pos + 1); |
1001 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) |
|
1001 | + if (isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) |
|
1002 | 1002 | return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid); |
1003 | 1003 | else |
1004 | 1004 | return null; |
@@ -1014,13 +1014,13 @@ discard block |
||
1014 | 1014 | public function findControlsByType($type, $strict = true) |
1015 | 1015 | { |
1016 | 1016 | $controls = []; |
1017 | - if($this->getHasControls()) |
|
1017 | + if ($this->getHasControls()) |
|
1018 | 1018 | { |
1019 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1019 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1020 | 1020 | { |
1021 | - if(is_object($control) && (get_class($control) === $type || (!$strict && ($control instanceof $type)))) |
|
1021 | + if (is_object($control) && (get_class($control) === $type || (!$strict && ($control instanceof $type)))) |
|
1022 | 1022 | $controls[] = $control; |
1023 | - if(($control instanceof TControl) && $control->getHasControls()) |
|
1023 | + if (($control instanceof TControl) && $control->getHasControls()) |
|
1024 | 1024 | $controls = array_merge($controls, $control->findControlsByType($type, $strict)); |
1025 | 1025 | } |
1026 | 1026 | } |
@@ -1039,13 +1039,13 @@ discard block |
||
1039 | 1039 | public function findControlsByID($id) |
1040 | 1040 | { |
1041 | 1041 | $controls = []; |
1042 | - if($this->getHasControls()) |
|
1042 | + if ($this->getHasControls()) |
|
1043 | 1043 | { |
1044 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1044 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1045 | 1045 | { |
1046 | - if($control instanceof TControl) |
|
1046 | + if ($control instanceof TControl) |
|
1047 | 1047 | { |
1048 | - if($control->_id === $id) |
|
1048 | + if ($control->_id === $id) |
|
1049 | 1049 | $controls[] = $control; |
1050 | 1050 | $controls = array_merge($controls, $control->findControlsByID($id)); |
1051 | 1051 | } |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | */ |
1075 | 1075 | public function registerObject($name, $object) |
1076 | 1076 | { |
1077 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
1077 | + if (isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
1078 | 1078 | throw new TInvalidOperationException('control_object_reregistered', $name); |
1079 | 1079 | $this->_rf[self::RF_NAMED_OBJECTS][$name] = $object; |
1080 | 1080 | } |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | */ |
1148 | 1148 | public function getRegisteredObject($name) |
1149 | 1149 | { |
1150 | - return isset($this->_rf[self::RF_NAMED_OBJECTS][$name])?$this->_rf[self::RF_NAMED_OBJECTS][$name]:null; |
|
1150 | + return isset($this->_rf[self::RF_NAMED_OBJECTS][$name]) ? $this->_rf[self::RF_NAMED_OBJECTS][$name] : null; |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | /** |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | final protected function isDescendentOf($ancestor) |
1191 | 1191 | { |
1192 | 1192 | $control = $this; |
1193 | - while($control !== $ancestor && $control->_parent) |
|
1193 | + while ($control !== $ancestor && $control->_parent) |
|
1194 | 1194 | $control = $control->_parent; |
1195 | 1195 | return $control === $ancestor; |
1196 | 1196 | } |
@@ -1203,27 +1203,27 @@ discard block |
||
1203 | 1203 | */ |
1204 | 1204 | public function addedControl($control) |
1205 | 1205 | { |
1206 | - if($control->_parent) |
|
1206 | + if ($control->_parent) |
|
1207 | 1207 | $control->_parent->getControls()->remove($control); |
1208 | 1208 | $control->_parent = $this; |
1209 | 1209 | $control->_page = $this->getPage(); |
1210 | - $namingContainer = ($this instanceof INamingContainer)?$this:$this->_namingContainer; |
|
1211 | - if($namingContainer) |
|
1210 | + $namingContainer = ($this instanceof INamingContainer) ? $this : $this->_namingContainer; |
|
1211 | + if ($namingContainer) |
|
1212 | 1212 | { |
1213 | 1213 | $control->_namingContainer = $namingContainer; |
1214 | - if($control->_id === '') |
|
1214 | + if ($control->_id === '') |
|
1215 | 1215 | $control->generateAutomaticID(); |
1216 | 1216 | else |
1217 | 1217 | $namingContainer->clearNameTable(); |
1218 | 1218 | $control->clearCachedUniqueID($control instanceof INamingContainer); |
1219 | 1219 | } |
1220 | 1220 | |
1221 | - if($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
1221 | + if ($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
1222 | 1222 | { |
1223 | 1223 | $control->initRecursive($namingContainer); |
1224 | - if($this->_stage >= self::CS_STATE_LOADED) |
|
1224 | + if ($this->_stage >= self::CS_STATE_LOADED) |
|
1225 | 1225 | { |
1226 | - if(isset($this->_rf[self::RF_CHILD_STATE][$control->_id])) |
|
1226 | + if (isset($this->_rf[self::RF_CHILD_STATE][$control->_id])) |
|
1227 | 1227 | { |
1228 | 1228 | $state = $this->_rf[self::RF_CHILD_STATE][$control->_id]; |
1229 | 1229 | unset($this->_rf[self::RF_CHILD_STATE][$control->_id]); |
@@ -1231,10 +1231,10 @@ discard block |
||
1231 | 1231 | else |
1232 | 1232 | $state = null; |
1233 | 1233 | $control->loadStateRecursive($state, !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1234 | - if($this->_stage >= self::CS_LOADED) |
|
1234 | + if ($this->_stage >= self::CS_LOADED) |
|
1235 | 1235 | { |
1236 | 1236 | $control->loadRecursive(); |
1237 | - if($this->_stage >= self::CS_PRERENDERED) |
|
1237 | + if ($this->_stage >= self::CS_PRERENDERED) |
|
1238 | 1238 | $control->preRenderRecursive(); |
1239 | 1239 | } |
1240 | 1240 | } |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | */ |
1249 | 1249 | public function removedControl($control) |
1250 | 1250 | { |
1251 | - if($this->_namingContainer) |
|
1251 | + if ($this->_namingContainer) |
|
1252 | 1252 | $this->_namingContainer->clearNameTable(); |
1253 | 1253 | $control->unloadRecursive(); |
1254 | 1254 | $control->_parent = null; |
@@ -1256,7 +1256,7 @@ discard block |
||
1256 | 1256 | $control->_namingContainer = null; |
1257 | 1257 | $control->_tplControl = null; |
1258 | 1258 | //$control->_stage=self::CS_CONSTRUCTED; |
1259 | - if(!($control->_flags & self::IS_ID_SET)) |
|
1259 | + if (!($control->_flags & self::IS_ID_SET)) |
|
1260 | 1260 | $control->_id = ''; |
1261 | 1261 | else |
1262 | 1262 | unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]); |
@@ -1271,32 +1271,32 @@ discard block |
||
1271 | 1271 | protected function initRecursive($namingContainer = null) |
1272 | 1272 | { |
1273 | 1273 | $this->ensureChildControls(); |
1274 | - if($this->getHasControls()) |
|
1274 | + if ($this->getHasControls()) |
|
1275 | 1275 | { |
1276 | - if($this instanceof INamingContainer) |
|
1276 | + if ($this instanceof INamingContainer) |
|
1277 | 1277 | $namingContainer = $this; |
1278 | 1278 | $page = $this->getPage(); |
1279 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1279 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1280 | 1280 | { |
1281 | - if($control instanceof TControl) |
|
1281 | + if ($control instanceof TControl) |
|
1282 | 1282 | { |
1283 | 1283 | $control->_namingContainer = $namingContainer; |
1284 | 1284 | $control->_page = $page; |
1285 | - if($control->_id === '' && $namingContainer) |
|
1285 | + if ($control->_id === '' && $namingContainer) |
|
1286 | 1286 | $control->generateAutomaticID(); |
1287 | 1287 | $control->initRecursive($namingContainer); |
1288 | 1288 | } |
1289 | 1289 | } |
1290 | 1290 | } |
1291 | - if($this->_stage < self::CS_INITIALIZED) |
|
1291 | + if ($this->_stage < self::CS_INITIALIZED) |
|
1292 | 1292 | { |
1293 | 1293 | $this->_stage = self::CS_CHILD_INITIALIZED; |
1294 | - if(($page = $this->getPage()) && $this->getEnableTheming() && !($this->_flags & self::IS_SKIN_APPLIED)) |
|
1294 | + if (($page = $this->getPage()) && $this->getEnableTheming() && !($this->_flags & self::IS_SKIN_APPLIED)) |
|
1295 | 1295 | { |
1296 | 1296 | $page->applyControlSkin($this); |
1297 | 1297 | $this->_flags |= self::IS_SKIN_APPLIED; |
1298 | 1298 | } |
1299 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1299 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1300 | 1300 | $this->_rf[self::RF_ADAPTER]->onInit(null); |
1301 | 1301 | else |
1302 | 1302 | $this->onInit(null); |
@@ -1310,22 +1310,22 @@ discard block |
||
1310 | 1310 | */ |
1311 | 1311 | protected function loadRecursive() |
1312 | 1312 | { |
1313 | - if($this->_stage < self::CS_LOADED) |
|
1313 | + if ($this->_stage < self::CS_LOADED) |
|
1314 | 1314 | { |
1315 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1315 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1316 | 1316 | $this->_rf[self::RF_ADAPTER]->onLoad(null); |
1317 | 1317 | else |
1318 | 1318 | $this->onLoad(null); |
1319 | 1319 | } |
1320 | - if($this->getHasControls()) |
|
1320 | + if ($this->getHasControls()) |
|
1321 | 1321 | { |
1322 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1322 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1323 | 1323 | { |
1324 | - if($control instanceof TControl) |
|
1324 | + if ($control instanceof TControl) |
|
1325 | 1325 | $control->loadRecursive(); |
1326 | 1326 | } |
1327 | 1327 | } |
1328 | - if($this->_stage < self::CS_LOADED) |
|
1328 | + if ($this->_stage < self::CS_LOADED) |
|
1329 | 1329 | $this->_stage = self::CS_LOADED; |
1330 | 1330 | } |
1331 | 1331 | |
@@ -1337,19 +1337,19 @@ discard block |
||
1337 | 1337 | { |
1338 | 1338 | $this->autoDataBindProperties(); |
1339 | 1339 | |
1340 | - if($this->getVisible(false)) |
|
1340 | + if ($this->getVisible(false)) |
|
1341 | 1341 | { |
1342 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1342 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1343 | 1343 | $this->_rf[self::RF_ADAPTER]->onPreRender(null); |
1344 | 1344 | else |
1345 | 1345 | $this->onPreRender(null); |
1346 | - if($this->getHasControls()) |
|
1346 | + if ($this->getHasControls()) |
|
1347 | 1347 | { |
1348 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1348 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1349 | 1349 | { |
1350 | - if($control instanceof TControl) |
|
1350 | + if ($control instanceof TControl) |
|
1351 | 1351 | $control->preRenderRecursive(); |
1352 | - elseif($control instanceof TCompositeLiteral) |
|
1352 | + elseif ($control instanceof TCompositeLiteral) |
|
1353 | 1353 | $control->evaluateDynamicContent(); |
1354 | 1354 | } |
1355 | 1355 | } |
@@ -1363,15 +1363,15 @@ discard block |
||
1363 | 1363 | */ |
1364 | 1364 | protected function unloadRecursive() |
1365 | 1365 | { |
1366 | - if(!($this->_flags & self::IS_ID_SET)) |
|
1366 | + if (!($this->_flags & self::IS_ID_SET)) |
|
1367 | 1367 | $this->_id = ''; |
1368 | - if($this->getHasControls()) |
|
1368 | + if ($this->getHasControls()) |
|
1369 | 1369 | { |
1370 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1371 | - if($control instanceof TControl) |
|
1370 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1371 | + if ($control instanceof TControl) |
|
1372 | 1372 | $control->unloadRecursive(); |
1373 | 1373 | } |
1374 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1374 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1375 | 1375 | $this->_rf[self::RF_ADAPTER]->onUnload(null); |
1376 | 1376 | else |
1377 | 1377 | $this->onUnload(null); |
@@ -1447,9 +1447,9 @@ discard block |
||
1447 | 1447 | protected function raiseBubbleEvent($sender, $param) |
1448 | 1448 | { |
1449 | 1449 | $control = $this; |
1450 | - while($control = $control->_parent) |
|
1450 | + while ($control = $control->_parent) |
|
1451 | 1451 | { |
1452 | - if($control->bubbleEvent($sender, $param)) |
|
1452 | + if ($control->bubbleEvent($sender, $param)) |
|
1453 | 1453 | break; |
1454 | 1454 | } |
1455 | 1455 | } |
@@ -1486,7 +1486,7 @@ discard block |
||
1486 | 1486 | */ |
1487 | 1487 | public function broadcastEvent($name, $sender, $param) |
1488 | 1488 | { |
1489 | - $rootControl = (($page = $this->getPage()) === null)?$this:$page; |
|
1489 | + $rootControl = (($page = $this->getPage()) === null) ? $this : $page; |
|
1490 | 1490 | $rootControl->broadcastEventInternal($name, $sender, new TBroadcastEventParameter($name, $param)); |
1491 | 1491 | } |
1492 | 1492 | |
@@ -1499,15 +1499,15 @@ discard block |
||
1499 | 1499 | */ |
1500 | 1500 | private function broadcastEventInternal($name, $sender, $param) |
1501 | 1501 | { |
1502 | - if($this->hasEvent($name)) |
|
1502 | + if ($this->hasEvent($name)) |
|
1503 | 1503 | $this->raiseEvent($name, $sender, $param->getParameter()); |
1504 | - if($this instanceof IBroadcastEventReceiver) |
|
1504 | + if ($this instanceof IBroadcastEventReceiver) |
|
1505 | 1505 | $this->broadcastEventReceived($sender, $param); |
1506 | - if($this->getHasControls()) |
|
1506 | + if ($this->getHasControls()) |
|
1507 | 1507 | { |
1508 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1508 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1509 | 1509 | { |
1510 | - if($control instanceof TControl) |
|
1510 | + if ($control instanceof TControl) |
|
1511 | 1511 | $control->broadcastEventInternal($name, $sender, $param); |
1512 | 1512 | } |
1513 | 1513 | } |
@@ -1532,19 +1532,19 @@ discard block |
||
1532 | 1532 | */ |
1533 | 1533 | protected function traverseChildControls($param, $preCallback = null, $postCallback = null) |
1534 | 1534 | { |
1535 | - if($preCallback !== null) |
|
1535 | + if ($preCallback !== null) |
|
1536 | 1536 | call_user_func($preCallback, $this, $param); |
1537 | - if($this->getHasControls()) |
|
1537 | + if ($this->getHasControls()) |
|
1538 | 1538 | { |
1539 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1539 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1540 | 1540 | { |
1541 | - if($control instanceof TControl) |
|
1541 | + if ($control instanceof TControl) |
|
1542 | 1542 | { |
1543 | 1543 | $control->traverseChildControls($param, $preCallback, $postCallback); |
1544 | 1544 | } |
1545 | 1545 | } |
1546 | 1546 | } |
1547 | - if($postCallback !== null) |
|
1547 | + if ($postCallback !== null) |
|
1548 | 1548 | call_user_func($postCallback, $this, $param); |
1549 | 1549 | } |
1550 | 1550 | |
@@ -1555,9 +1555,9 @@ discard block |
||
1555 | 1555 | */ |
1556 | 1556 | public function renderControl($writer) |
1557 | 1557 | { |
1558 | - if($this instanceof IActiveControl || $this->getVisible(false)) |
|
1558 | + if ($this instanceof IActiveControl || $this->getVisible(false)) |
|
1559 | 1559 | { |
1560 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1560 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1561 | 1561 | $this->_rf[self::RF_ADAPTER]->render($writer); |
1562 | 1562 | else |
1563 | 1563 | $this->render($writer); |
@@ -1584,15 +1584,15 @@ discard block |
||
1584 | 1584 | */ |
1585 | 1585 | public function renderChildren($writer) |
1586 | 1586 | { |
1587 | - if($this->getHasControls()) |
|
1587 | + if ($this->getHasControls()) |
|
1588 | 1588 | { |
1589 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1589 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1590 | 1590 | { |
1591 | - if(is_string($control)) |
|
1591 | + if (is_string($control)) |
|
1592 | 1592 | $writer->write($control); |
1593 | - elseif($control instanceof TControl) |
|
1593 | + elseif ($control instanceof TControl) |
|
1594 | 1594 | $control->renderControl($writer); |
1595 | - elseif($control instanceof IRenderable) |
|
1595 | + elseif ($control instanceof IRenderable) |
|
1596 | 1596 | $control->render($writer); |
1597 | 1597 | } |
1598 | 1598 | } |
@@ -1624,33 +1624,33 @@ discard block |
||
1624 | 1624 | */ |
1625 | 1625 | protected function loadStateRecursive(&$state, $needViewState = true) |
1626 | 1626 | { |
1627 | - if(is_array($state)) |
|
1627 | + if (is_array($state)) |
|
1628 | 1628 | { |
1629 | 1629 | // A null state means the stateful properties all take default values. |
1630 | 1630 | // So if the state is enabled, we have to assign the null value. |
1631 | 1631 | $needViewState = ($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1632 | - if(isset($state[1])) |
|
1632 | + if (isset($state[1])) |
|
1633 | 1633 | { |
1634 | 1634 | $this->_rf[self::RF_CONTROLSTATE] = &$state[1]; |
1635 | 1635 | unset($state[1]); |
1636 | 1636 | } |
1637 | 1637 | else |
1638 | 1638 | unset($this->_rf[self::RF_CONTROLSTATE]); |
1639 | - if($needViewState) |
|
1639 | + if ($needViewState) |
|
1640 | 1640 | { |
1641 | - if(isset($state[0])) |
|
1641 | + if (isset($state[0])) |
|
1642 | 1642 | $this->_viewState = &$state[0]; |
1643 | 1643 | else |
1644 | 1644 | $this->_viewState = []; |
1645 | 1645 | } |
1646 | 1646 | unset($state[0]); |
1647 | - if($this->getHasControls()) |
|
1647 | + if ($this->getHasControls()) |
|
1648 | 1648 | { |
1649 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1649 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1650 | 1650 | { |
1651 | - if($control instanceof TControl) |
|
1651 | + if ($control instanceof TControl) |
|
1652 | 1652 | { |
1653 | - if(isset($state[$control->_id])) |
|
1653 | + if (isset($state[$control->_id])) |
|
1654 | 1654 | { |
1655 | 1655 | $control->loadStateRecursive($state[$control->_id], $needViewState); |
1656 | 1656 | unset($state[$control->_id]); |
@@ -1658,11 +1658,11 @@ discard block |
||
1658 | 1658 | } |
1659 | 1659 | } |
1660 | 1660 | } |
1661 | - if(!empty($state)) |
|
1661 | + if (!empty($state)) |
|
1662 | 1662 | $this->_rf[self::RF_CHILD_STATE] = &$state; |
1663 | 1663 | } |
1664 | 1664 | $this->_stage = self::CS_STATE_LOADED; |
1665 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1665 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1666 | 1666 | $this->_rf[self::RF_ADAPTER]->loadState(); |
1667 | 1667 | else |
1668 | 1668 | $this->loadState(); |
@@ -1676,26 +1676,26 @@ discard block |
||
1676 | 1676 | */ |
1677 | 1677 | protected function &saveStateRecursive($needViewState = true) |
1678 | 1678 | { |
1679 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1679 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1680 | 1680 | $this->_rf[self::RF_ADAPTER]->saveState(); |
1681 | 1681 | else |
1682 | 1682 | $this->saveState(); |
1683 | 1683 | $needViewState = ($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1684 | 1684 | $state = []; |
1685 | - if($this->getHasControls()) |
|
1685 | + if ($this->getHasControls()) |
|
1686 | 1686 | { |
1687 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1687 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1688 | 1688 | { |
1689 | - if($control instanceof TControl) |
|
1689 | + if ($control instanceof TControl) |
|
1690 | 1690 | { |
1691 | - if(count($tmp = &$control->saveStateRecursive($needViewState))) |
|
1691 | + if (count($tmp = &$control->saveStateRecursive($needViewState))) |
|
1692 | 1692 | $state[$control->_id] = $tmp; |
1693 | 1693 | } |
1694 | 1694 | } |
1695 | 1695 | } |
1696 | - if($needViewState && !empty($this->_viewState)) |
|
1696 | + if ($needViewState && !empty($this->_viewState)) |
|
1697 | 1697 | $state[0] = &$this->_viewState; |
1698 | - if(isset($this->_rf[self::RF_CONTROLSTATE])) |
|
1698 | + if (isset($this->_rf[self::RF_CONTROLSTATE])) |
|
1699 | 1699 | $state[1] = &$this->_rf[self::RF_CONTROLSTATE]; |
1700 | 1700 | return $state; |
1701 | 1701 | } |
@@ -1707,12 +1707,12 @@ discard block |
||
1707 | 1707 | */ |
1708 | 1708 | public function applyStyleSheetSkin($page) |
1709 | 1709 | { |
1710 | - if($page && !($this->_flags & self::IS_STYLESHEET_APPLIED)) |
|
1710 | + if ($page && !($this->_flags & self::IS_STYLESHEET_APPLIED)) |
|
1711 | 1711 | { |
1712 | 1712 | $page->applyControlStyleSheet($this); |
1713 | 1713 | $this->_flags |= self::IS_STYLESHEET_APPLIED; |
1714 | 1714 | } |
1715 | - elseif($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
1715 | + elseif ($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
1716 | 1716 | throw new TInvalidOperationException('control_stylesheet_applied', get_class($this)); |
1717 | 1717 | } |
1718 | 1718 | |
@@ -1723,10 +1723,10 @@ discard block |
||
1723 | 1723 | */ |
1724 | 1724 | private function clearCachedUniqueID($recursive) |
1725 | 1725 | { |
1726 | - if($recursive && $this->_uid !== null && isset($this->_rf[self::RF_CONTROLS])) |
|
1726 | + if ($recursive && $this->_uid !== null && isset($this->_rf[self::RF_CONTROLS])) |
|
1727 | 1727 | { |
1728 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1729 | - if($control instanceof TControl) |
|
1728 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1729 | + if ($control instanceof TControl) |
|
1730 | 1730 | $control->clearCachedUniqueID($recursive); |
1731 | 1731 | } |
1732 | 1732 | $this->_uid = null; |
@@ -1738,10 +1738,10 @@ discard block |
||
1738 | 1738 | private function generateAutomaticID() |
1739 | 1739 | { |
1740 | 1740 | $this->_flags &= ~self::IS_ID_SET; |
1741 | - if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) |
|
1741 | + if (!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) |
|
1742 | 1742 | $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID] = 0; |
1743 | 1743 | $id = $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++; |
1744 | - $this->_id = self::AUTOMATIC_ID_PREFIX . $id; |
|
1744 | + $this->_id = self::AUTOMATIC_ID_PREFIX.$id; |
|
1745 | 1745 | $this->_namingContainer->clearNameTable(); |
1746 | 1746 | } |
1747 | 1747 | |
@@ -1761,18 +1761,18 @@ discard block |
||
1761 | 1761 | */ |
1762 | 1762 | private function fillNameTable($container, $controls) |
1763 | 1763 | { |
1764 | - foreach($controls as $control) |
|
1764 | + foreach ($controls as $control) |
|
1765 | 1765 | { |
1766 | - if($control instanceof TControl) |
|
1766 | + if ($control instanceof TControl) |
|
1767 | 1767 | { |
1768 | - if($control->_id !== '') |
|
1768 | + if ($control->_id !== '') |
|
1769 | 1769 | { |
1770 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) |
|
1770 | + if (isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) |
|
1771 | 1771 | throw new TInvalidDataValueException('control_id_nonunique', get_class($control), $control->_id); |
1772 | 1772 | else |
1773 | 1773 | $container->_rf[self::RF_NAMED_CONTROLS][$control->_id] = $control; |
1774 | 1774 | } |
1775 | - if(!($control instanceof INamingContainer) && $control->getHasControls()) |
|
1775 | + if (!($control instanceof INamingContainer) && $control->getHasControls()) |
|
1776 | 1776 | $this->fillNameTable($container, $control->_rf[self::RF_CONTROLS]); |
1777 | 1777 | } |
1778 | 1778 | } |
@@ -193,10 +193,11 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function __get($name) |
195 | 195 | { |
196 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
197 | - return $this->_rf[self::RF_NAMED_OBJECTS][$name]; |
|
198 | - else |
|
199 | - return parent::__get($name); |
|
196 | + if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) { |
|
197 | + return $this->_rf[self::RF_NAMED_OBJECTS][$name]; |
|
198 | + } else { |
|
199 | + return parent::__get($name); |
|
200 | + } |
|
200 | 201 | } |
201 | 202 | |
202 | 203 | /** |
@@ -263,10 +264,11 @@ discard block |
||
263 | 264 | { |
264 | 265 | if(!$this->_namingContainer && $this->_parent) |
265 | 266 | { |
266 | - if($this->_parent instanceof INamingContainer) |
|
267 | - $this->_namingContainer = $this->_parent; |
|
268 | - else |
|
269 | - $this->_namingContainer = $this->_parent->getNamingContainer(); |
|
267 | + if($this->_parent instanceof INamingContainer) { |
|
268 | + $this->_namingContainer = $this->_parent; |
|
269 | + } else { |
|
270 | + $this->_namingContainer = $this->_parent->getNamingContainer(); |
|
271 | + } |
|
270 | 272 | } |
271 | 273 | return $this->_namingContainer; |
272 | 274 | } |
@@ -278,10 +280,11 @@ discard block |
||
278 | 280 | { |
279 | 281 | if(!$this->_page) |
280 | 282 | { |
281 | - if($this->_parent) |
|
282 | - $this->_page = $this->_parent->getPage(); |
|
283 | - elseif($this->_tplControl) |
|
284 | - $this->_page = $this->_tplControl->getPage(); |
|
283 | + if($this->_parent) { |
|
284 | + $this->_page = $this->_parent->getPage(); |
|
285 | + } elseif($this->_tplControl) { |
|
286 | + $this->_page = $this->_tplControl->getPage(); |
|
287 | + } |
|
285 | 288 | } |
286 | 289 | return $this->_page; |
287 | 290 | } |
@@ -311,8 +314,9 @@ discard block |
||
311 | 314 | */ |
312 | 315 | public function getTemplateControl() |
313 | 316 | { |
314 | - if(!$this->_tplControl && $this->_parent) |
|
315 | - $this->_tplControl = $this->_parent->getTemplateControl(); |
|
317 | + if(!$this->_tplControl && $this->_parent) { |
|
318 | + $this->_tplControl = $this->_parent->getTemplateControl(); |
|
319 | + } |
|
316 | 320 | return $this->_tplControl; |
317 | 321 | } |
318 | 322 | |
@@ -326,8 +330,9 @@ discard block |
||
326 | 330 | $control = $this; |
327 | 331 | while(($control instanceof TControl) && ($control = $control->getTemplateControl()) !== null) |
328 | 332 | { |
329 | - if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) |
|
330 | - return $control; |
|
333 | + if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) { |
|
334 | + return $control; |
|
335 | + } |
|
331 | 336 | } |
332 | 337 | return $this->getPage(); |
333 | 338 | } |
@@ -365,10 +370,11 @@ discard block |
||
365 | 370 | */ |
366 | 371 | public function getID($hideAutoID = true) |
367 | 372 | { |
368 | - if($hideAutoID) |
|
369 | - return ($this->_flags & self::IS_ID_SET) ? $this->_id : ''; |
|
370 | - else |
|
371 | - return $this->_id; |
|
373 | + if($hideAutoID) { |
|
374 | + return ($this->_flags & self::IS_ID_SET) ? $this->_id : ''; |
|
375 | + } else { |
|
376 | + return $this->_id; |
|
377 | + } |
|
372 | 378 | } |
373 | 379 | |
374 | 380 | /** |
@@ -377,13 +383,15 @@ discard block |
||
377 | 383 | */ |
378 | 384 | public function setID($id) |
379 | 385 | { |
380 | - if(!preg_match(self::ID_FORMAT, $id)) |
|
381 | - throw new TInvalidDataValueException('control_id_invalid', get_class($this), $id); |
|
386 | + if(!preg_match(self::ID_FORMAT, $id)) { |
|
387 | + throw new TInvalidDataValueException('control_id_invalid', get_class($this), $id); |
|
388 | + } |
|
382 | 389 | $this->_id = $id; |
383 | 390 | $this->_flags |= self::IS_ID_SET; |
384 | 391 | $this->clearCachedUniqueID($this instanceof INamingContainer); |
385 | - if($this->_namingContainer) |
|
386 | - $this->_namingContainer->clearNameTable(); |
|
392 | + if($this->_namingContainer) { |
|
393 | + $this->_namingContainer->clearNameTable(); |
|
394 | + } |
|
387 | 395 | } |
388 | 396 | |
389 | 397 | /** |
@@ -395,23 +403,28 @@ discard block |
||
395 | 403 | */ |
396 | 404 | public function getUniqueID() |
397 | 405 | { |
398 | - if($this->_uid === '' || $this->_uid === null) // need to build the UniqueID |
|
406 | + if($this->_uid === '' || $this->_uid === null) { |
|
407 | + // need to build the UniqueID |
|
399 | 408 | { |
400 | - $this->_uid = ''; // set to not-null, so that clearCachedUniqueID() may take action |
|
409 | + $this->_uid = ''; |
|
410 | + } |
|
411 | + // set to not-null, so that clearCachedUniqueID() may take action |
|
401 | 412 | if($namingContainer = $this->getNamingContainer()) |
402 | 413 | { |
403 | - if($this->getPage() === $namingContainer) |
|
404 | - return ($this->_uid = $this->_id); |
|
405 | - elseif(($prefix = $namingContainer->getUniqueID()) === '') |
|
406 | - return $this->_id; |
|
407 | - else |
|
408 | - return ($this->_uid = $prefix . self::ID_SEPARATOR . $this->_id); |
|
409 | - } |
|
410 | - else // no naming container |
|
414 | + if($this->getPage() === $namingContainer) { |
|
415 | + return ($this->_uid = $this->_id); |
|
416 | + } elseif(($prefix = $namingContainer->getUniqueID()) === '') { |
|
417 | + return $this->_id; |
|
418 | + } else { |
|
419 | + return ($this->_uid = $prefix . self::ID_SEPARATOR . $this->_id); |
|
420 | + } |
|
421 | + } else { |
|
422 | + // no naming container |
|
411 | 423 | return $this->_id; |
424 | + } |
|
425 | + } else { |
|
426 | + return $this->_uid; |
|
412 | 427 | } |
413 | - else |
|
414 | - return $this->_uid; |
|
415 | 428 | } |
416 | 429 | |
417 | 430 | /** |
@@ -458,10 +471,11 @@ discard block |
||
458 | 471 | */ |
459 | 472 | public function setSkinID($value) |
460 | 473 | { |
461 | - if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage >= self::CS_CHILD_INITIALIZED) |
|
462 | - throw new TInvalidOperationException('control_skinid_unchangeable', get_class($this)); |
|
463 | - else |
|
464 | - $this->_rf[self::RF_SKIN_ID] = $value; |
|
474 | + if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage >= self::CS_CHILD_INITIALIZED) { |
|
475 | + throw new TInvalidOperationException('control_skinid_unchangeable', get_class($this)); |
|
476 | + } else { |
|
477 | + $this->_rf[self::RF_SKIN_ID] = $value; |
|
478 | + } |
|
465 | 479 | } |
466 | 480 | |
467 | 481 | /** |
@@ -479,10 +493,11 @@ discard block |
||
479 | 493 | */ |
480 | 494 | public function getEnableTheming() |
481 | 495 | { |
482 | - if($this->_flags & self::IS_DISABLE_THEMING) |
|
483 | - return false; |
|
484 | - else |
|
485 | - return $this->_parent?$this->_parent->getEnableTheming():true; |
|
496 | + if($this->_flags & self::IS_DISABLE_THEMING) { |
|
497 | + return false; |
|
498 | + } else { |
|
499 | + return $this->_parent?$this->_parent->getEnableTheming():true; |
|
500 | + } |
|
486 | 501 | } |
487 | 502 | |
488 | 503 | /** |
@@ -491,12 +506,13 @@ discard block |
||
491 | 506 | */ |
492 | 507 | public function setEnableTheming($value) |
493 | 508 | { |
494 | - if($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
495 | - throw new TInvalidOperationException('control_enabletheming_unchangeable', get_class($this), $this->getUniqueID()); |
|
496 | - elseif(TPropertyValue::ensureBoolean($value)) |
|
497 | - $this->_flags &= ~self::IS_DISABLE_THEMING; |
|
498 | - else |
|
499 | - $this->_flags |= self::IS_DISABLE_THEMING; |
|
509 | + if($this->_stage >= self::CS_CHILD_INITIALIZED) { |
|
510 | + throw new TInvalidOperationException('control_enabletheming_unchangeable', get_class($this), $this->getUniqueID()); |
|
511 | + } elseif(TPropertyValue::ensureBoolean($value)) { |
|
512 | + $this->_flags &= ~self::IS_DISABLE_THEMING; |
|
513 | + } else { |
|
514 | + $this->_flags |= self::IS_DISABLE_THEMING; |
|
515 | + } |
|
500 | 516 | } |
501 | 517 | |
502 | 518 | /** |
@@ -534,8 +550,9 @@ discard block |
||
534 | 550 | */ |
535 | 551 | public function getControls() |
536 | 552 | { |
537 | - if(!isset($this->_rf[self::RF_CONTROLS])) |
|
538 | - $this->_rf[self::RF_CONTROLS] = $this->createControlCollection(); |
|
553 | + if(!isset($this->_rf[self::RF_CONTROLS])) { |
|
554 | + $this->_rf[self::RF_CONTROLS] = $this->createControlCollection(); |
|
555 | + } |
|
539 | 556 | return $this->_rf[self::RF_CONTROLS]; |
540 | 557 | } |
541 | 558 | |
@@ -560,13 +577,14 @@ discard block |
||
560 | 577 | { |
561 | 578 | if($checkParents) |
562 | 579 | { |
563 | - for($control = $this;$control;$control = $control->_parent) |
|
564 | - if(!$control->getVisible(false)) |
|
580 | + for($control = $this;$control;$control = $control->_parent) { |
|
581 | + if(!$control->getVisible(false)) |
|
565 | 582 | return false; |
583 | + } |
|
566 | 584 | return true; |
585 | + } else { |
|
586 | + return $this->getViewState('Visible', true); |
|
567 | 587 | } |
568 | - else |
|
569 | - return $this->getViewState('Visible', true); |
|
570 | 588 | } |
571 | 589 | |
572 | 590 | /** |
@@ -591,13 +609,14 @@ discard block |
||
591 | 609 | { |
592 | 610 | if($checkParents) |
593 | 611 | { |
594 | - for($control = $this;$control;$control = $control->_parent) |
|
595 | - if(!$control->getViewState('Enabled', true)) |
|
612 | + for($control = $this;$control;$control = $control->_parent) { |
|
613 | + if(!$control->getViewState('Enabled', true)) |
|
596 | 614 | return false; |
615 | + } |
|
597 | 616 | return true; |
617 | + } else { |
|
618 | + return $this->getViewState('Enabled', true); |
|
598 | 619 | } |
599 | - else |
|
600 | - return $this->getViewState('Enabled', true); |
|
601 | 620 | } |
602 | 621 | |
603 | 622 | /** |
@@ -613,10 +632,11 @@ discard block |
||
613 | 632 | */ |
614 | 633 | public function getHasAttributes() |
615 | 634 | { |
616 | - if($attributes = $this->getViewState('Attributes', null)) |
|
617 | - return $attributes->getCount() > 0; |
|
618 | - else |
|
619 | - return false; |
|
635 | + if($attributes = $this->getViewState('Attributes', null)) { |
|
636 | + return $attributes->getCount() > 0; |
|
637 | + } else { |
|
638 | + return false; |
|
639 | + } |
|
620 | 640 | } |
621 | 641 | |
622 | 642 | /** |
@@ -627,9 +647,9 @@ discard block |
||
627 | 647 | */ |
628 | 648 | public function getAttributes() |
629 | 649 | { |
630 | - if($attributes = $this->getViewState('Attributes', null)) |
|
631 | - return $attributes; |
|
632 | - else |
|
650 | + if($attributes = $this->getViewState('Attributes', null)) { |
|
651 | + return $attributes; |
|
652 | + } else |
|
633 | 653 | { |
634 | 654 | $attributes = new TAttributeCollection; |
635 | 655 | $this->setViewState('Attributes', $attributes, null); |
@@ -642,10 +662,11 @@ discard block |
||
642 | 662 | */ |
643 | 663 | public function hasAttribute($name) |
644 | 664 | { |
645 | - if($attributes = $this->getViewState('Attributes', null)) |
|
646 | - return $attributes->contains($name); |
|
647 | - else |
|
648 | - return false; |
|
665 | + if($attributes = $this->getViewState('Attributes', null)) { |
|
666 | + return $attributes->contains($name); |
|
667 | + } else { |
|
668 | + return false; |
|
669 | + } |
|
649 | 670 | } |
650 | 671 | |
651 | 672 | /** |
@@ -653,10 +674,11 @@ discard block |
||
653 | 674 | */ |
654 | 675 | public function getAttribute($name) |
655 | 676 | { |
656 | - if($attributes = $this->getViewState('Attributes', null)) |
|
657 | - return $attributes->itemAt($name); |
|
658 | - else |
|
659 | - return null; |
|
677 | + if($attributes = $this->getViewState('Attributes', null)) { |
|
678 | + return $attributes->itemAt($name); |
|
679 | + } else { |
|
680 | + return null; |
|
681 | + } |
|
660 | 682 | } |
661 | 683 | |
662 | 684 | /** |
@@ -676,10 +698,11 @@ discard block |
||
676 | 698 | */ |
677 | 699 | public function removeAttribute($name) |
678 | 700 | { |
679 | - if($attributes = $this->getViewState('Attributes', null)) |
|
680 | - return $attributes->remove($name); |
|
681 | - else |
|
682 | - return null; |
|
701 | + if($attributes = $this->getViewState('Attributes', null)) { |
|
702 | + return $attributes->remove($name); |
|
703 | + } else { |
|
704 | + return null; |
|
705 | + } |
|
683 | 706 | } |
684 | 707 | |
685 | 708 | /** |
@@ -689,13 +712,14 @@ discard block |
||
689 | 712 | { |
690 | 713 | if($checkParents) |
691 | 714 | { |
692 | - for($control = $this;$control !== null;$control = $control->getParent()) |
|
693 | - if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
715 | + for($control = $this;$control !== null;$control = $control->getParent()) { |
|
716 | + if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
694 | 717 | return false; |
718 | + } |
|
695 | 719 | return true; |
720 | + } else { |
|
721 | + return !($this->_flags & self::IS_DISABLE_VIEWSTATE); |
|
696 | 722 | } |
697 | - else |
|
698 | - return !($this->_flags & self::IS_DISABLE_VIEWSTATE); |
|
699 | 723 | } |
700 | 724 | |
701 | 725 | /** |
@@ -703,10 +727,11 @@ discard block |
||
703 | 727 | */ |
704 | 728 | public function setEnableViewState($value) |
705 | 729 | { |
706 | - if(TPropertyValue::ensureBoolean($value)) |
|
707 | - $this->_flags &= ~self::IS_DISABLE_VIEWSTATE; |
|
708 | - else |
|
709 | - $this->_flags |= self::IS_DISABLE_VIEWSTATE; |
|
730 | + if(TPropertyValue::ensureBoolean($value)) { |
|
731 | + $this->_flags &= ~self::IS_DISABLE_VIEWSTATE; |
|
732 | + } else { |
|
733 | + $this->_flags |= self::IS_DISABLE_VIEWSTATE; |
|
734 | + } |
|
710 | 735 | } |
711 | 736 | |
712 | 737 | /** |
@@ -735,10 +760,11 @@ discard block |
||
735 | 760 | */ |
736 | 761 | protected function setControlState($key, $value, $defaultValue = null) |
737 | 762 | { |
738 | - if($value === $defaultValue) |
|
739 | - unset($this->_rf[self::RF_CONTROLSTATE][$key]); |
|
740 | - else |
|
741 | - $this->_rf[self::RF_CONTROLSTATE][$key] = $value; |
|
763 | + if($value === $defaultValue) { |
|
764 | + unset($this->_rf[self::RF_CONTROLSTATE][$key]); |
|
765 | + } else { |
|
766 | + $this->_rf[self::RF_CONTROLSTATE][$key] = $value; |
|
767 | + } |
|
742 | 768 | } |
743 | 769 | |
744 | 770 | /** |
@@ -772,16 +798,17 @@ discard block |
||
772 | 798 | */ |
773 | 799 | public function getViewState($key, $defaultValue = null) |
774 | 800 | { |
775 | - if(isset($this->_viewState[$key])) |
|
776 | - return $this->_viewState[$key] !== null?$this->_viewState[$key]:$defaultValue; |
|
777 | - elseif(isset($this->_tempState[$key])) |
|
801 | + if(isset($this->_viewState[$key])) { |
|
802 | + return $this->_viewState[$key] !== null?$this->_viewState[$key]:$defaultValue; |
|
803 | + } elseif(isset($this->_tempState[$key])) |
|
778 | 804 | { |
779 | - if(is_object($this->_tempState[$key]) && $this->_trackViewState) |
|
780 | - $this->_viewState[$key] = $this->_tempState[$key]; |
|
805 | + if(is_object($this->_tempState[$key]) && $this->_trackViewState) { |
|
806 | + $this->_viewState[$key] = $this->_tempState[$key]; |
|
807 | + } |
|
781 | 808 | return $this->_tempState[$key]; |
809 | + } else { |
|
810 | + return $defaultValue; |
|
782 | 811 | } |
783 | - else |
|
784 | - return $defaultValue; |
|
785 | 812 | } |
786 | 813 | |
787 | 814 | /** |
@@ -800,14 +827,14 @@ discard block |
||
800 | 827 | { |
801 | 828 | unset($this->_tempState[$key]); |
802 | 829 | $this->_viewState[$key] = $value; |
803 | - } |
|
804 | - else |
|
830 | + } else |
|
805 | 831 | { |
806 | 832 | unset($this->_viewState[$key]); |
807 | - if($value === $defaultValue) |
|
808 | - unset($this->_tempState[$key]); |
|
809 | - else |
|
810 | - $this->_tempState[$key] = $value; |
|
833 | + if($value === $defaultValue) { |
|
834 | + unset($this->_tempState[$key]); |
|
835 | + } else { |
|
836 | + $this->_tempState[$key] = $value; |
|
837 | + } |
|
811 | 838 | } |
812 | 839 | } |
813 | 840 | |
@@ -872,10 +899,12 @@ discard block |
||
872 | 899 | Prado::trace("Data bind properties", 'Prado\Web\UI\TControl'); |
873 | 900 | if(isset($this->_rf[self::RF_DATA_BINDINGS])) |
874 | 901 | { |
875 | - if(($context = $this->getTemplateControl()) === null) |
|
876 | - $context = $this; |
|
877 | - foreach($this->_rf[self::RF_DATA_BINDINGS] as $property => $expression) |
|
878 | - $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
902 | + if(($context = $this->getTemplateControl()) === null) { |
|
903 | + $context = $this; |
|
904 | + } |
|
905 | + foreach($this->_rf[self::RF_DATA_BINDINGS] as $property => $expression) { |
|
906 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
907 | + } |
|
879 | 908 | } |
880 | 909 | } |
881 | 910 | |
@@ -886,10 +915,12 @@ discard block |
||
886 | 915 | { |
887 | 916 | if(isset($this->_rf[self::RF_AUTO_BINDINGS])) |
888 | 917 | { |
889 | - if(($context = $this->getTemplateControl()) === null) |
|
890 | - $context = $this; |
|
891 | - foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property => $expression) |
|
892 | - $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
918 | + if(($context = $this->getTemplateControl()) === null) { |
|
919 | + $context = $this; |
|
920 | + } |
|
921 | + foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property => $expression) { |
|
922 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
923 | + } |
|
893 | 924 | } |
894 | 925 | } |
895 | 926 | |
@@ -901,9 +932,10 @@ discard block |
||
901 | 932 | Prado::trace("dataBindChildren()", 'Prado\Web\UI\TControl'); |
902 | 933 | if(isset($this->_rf[self::RF_CONTROLS])) |
903 | 934 | { |
904 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
905 | - if($control instanceof IBindable) |
|
935 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
936 | + if($control instanceof IBindable) |
|
906 | 937 | $control->dataBind(); |
938 | + } |
|
907 | 939 | } |
908 | 940 | } |
909 | 941 | |
@@ -922,12 +954,13 @@ discard block |
||
922 | 954 | */ |
923 | 955 | final protected function setChildControlsCreated($value) |
924 | 956 | { |
925 | - if($value) |
|
926 | - $this->_flags |= self::IS_CHILD_CREATED; |
|
927 | - else |
|
957 | + if($value) { |
|
958 | + $this->_flags |= self::IS_CHILD_CREATED; |
|
959 | + } else |
|
928 | 960 | { |
929 | - if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) |
|
930 | - $this->getControls()->clear(); |
|
961 | + if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) { |
|
962 | + $this->getControls()->clear(); |
|
963 | + } |
|
931 | 964 | $this->_flags &= ~self::IS_CHILD_CREATED; |
932 | 965 | } |
933 | 966 | } |
@@ -944,14 +977,14 @@ discard block |
||
944 | 977 | try |
945 | 978 | { |
946 | 979 | $this->_flags |= self::IS_CREATING_CHILD; |
947 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
948 | - $this->_rf[self::RF_ADAPTER]->createChildControls(); |
|
949 | - else |
|
950 | - $this->createChildControls(); |
|
980 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
981 | + $this->_rf[self::RF_ADAPTER]->createChildControls(); |
|
982 | + } else { |
|
983 | + $this->createChildControls(); |
|
984 | + } |
|
951 | 985 | $this->_flags &= ~self::IS_CREATING_CHILD; |
952 | 986 | $this->_flags |= self::IS_CHILD_CREATED; |
953 | - } |
|
954 | - catch(Exception $e) |
|
987 | + } catch(Exception $e) |
|
955 | 988 | { |
956 | 989 | $this->_flags &= ~self::IS_CREATING_CHILD; |
957 | 990 | $this->_flags |= self::IS_CHILD_CREATED; |
@@ -985,23 +1018,25 @@ discard block |
||
985 | 1018 | { |
986 | 1019 | $id = strtr($id, '.', self::ID_SEPARATOR); |
987 | 1020 | $container = ($this instanceof INamingContainer)?$this:$this->getNamingContainer(); |
988 | - if(!$container || !$container->getHasControls()) |
|
989 | - return null; |
|
1021 | + if(!$container || !$container->getHasControls()) { |
|
1022 | + return null; |
|
1023 | + } |
|
990 | 1024 | if(!isset($container->_rf[self::RF_NAMED_CONTROLS])) |
991 | 1025 | { |
992 | 1026 | $container->_rf[self::RF_NAMED_CONTROLS] = []; |
993 | 1027 | $container->fillNameTable($container, $container->_rf[self::RF_CONTROLS]); |
994 | 1028 | } |
995 | - if(($pos = strpos($id, self::ID_SEPARATOR)) === false) |
|
996 | - return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null; |
|
997 | - else |
|
1029 | + if(($pos = strpos($id, self::ID_SEPARATOR)) === false) { |
|
1030 | + return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null; |
|
1031 | + } else |
|
998 | 1032 | { |
999 | 1033 | $cid = substr($id, 0, $pos); |
1000 | 1034 | $sid = substr($id, $pos + 1); |
1001 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) |
|
1002 | - return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid); |
|
1003 | - else |
|
1004 | - return null; |
|
1035 | + if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) { |
|
1036 | + return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid); |
|
1037 | + } else { |
|
1038 | + return null; |
|
1039 | + } |
|
1005 | 1040 | } |
1006 | 1041 | } |
1007 | 1042 | |
@@ -1018,10 +1053,12 @@ discard block |
||
1018 | 1053 | { |
1019 | 1054 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1020 | 1055 | { |
1021 | - if(is_object($control) && (get_class($control) === $type || (!$strict && ($control instanceof $type)))) |
|
1022 | - $controls[] = $control; |
|
1023 | - if(($control instanceof TControl) && $control->getHasControls()) |
|
1024 | - $controls = array_merge($controls, $control->findControlsByType($type, $strict)); |
|
1056 | + if(is_object($control) && (get_class($control) === $type || (!$strict && ($control instanceof $type)))) { |
|
1057 | + $controls[] = $control; |
|
1058 | + } |
|
1059 | + if(($control instanceof TControl) && $control->getHasControls()) { |
|
1060 | + $controls = array_merge($controls, $control->findControlsByType($type, $strict)); |
|
1061 | + } |
|
1025 | 1062 | } |
1026 | 1063 | } |
1027 | 1064 | return $controls; |
@@ -1045,8 +1082,9 @@ discard block |
||
1045 | 1082 | { |
1046 | 1083 | if($control instanceof TControl) |
1047 | 1084 | { |
1048 | - if($control->_id === $id) |
|
1049 | - $controls[] = $control; |
|
1085 | + if($control->_id === $id) { |
|
1086 | + $controls[] = $control; |
|
1087 | + } |
|
1050 | 1088 | $controls = array_merge($controls, $control->findControlsByID($id)); |
1051 | 1089 | } |
1052 | 1090 | } |
@@ -1074,8 +1112,9 @@ discard block |
||
1074 | 1112 | */ |
1075 | 1113 | public function registerObject($name, $object) |
1076 | 1114 | { |
1077 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
1078 | - throw new TInvalidOperationException('control_object_reregistered', $name); |
|
1115 | + if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) { |
|
1116 | + throw new TInvalidOperationException('control_object_reregistered', $name); |
|
1117 | + } |
|
1079 | 1118 | $this->_rf[self::RF_NAMED_OBJECTS][$name] = $object; |
1080 | 1119 | } |
1081 | 1120 | |
@@ -1190,8 +1229,9 @@ discard block |
||
1190 | 1229 | final protected function isDescendentOf($ancestor) |
1191 | 1230 | { |
1192 | 1231 | $control = $this; |
1193 | - while($control !== $ancestor && $control->_parent) |
|
1194 | - $control = $control->_parent; |
|
1232 | + while($control !== $ancestor && $control->_parent) { |
|
1233 | + $control = $control->_parent; |
|
1234 | + } |
|
1195 | 1235 | return $control === $ancestor; |
1196 | 1236 | } |
1197 | 1237 | |
@@ -1203,18 +1243,20 @@ discard block |
||
1203 | 1243 | */ |
1204 | 1244 | public function addedControl($control) |
1205 | 1245 | { |
1206 | - if($control->_parent) |
|
1207 | - $control->_parent->getControls()->remove($control); |
|
1246 | + if($control->_parent) { |
|
1247 | + $control->_parent->getControls()->remove($control); |
|
1248 | + } |
|
1208 | 1249 | $control->_parent = $this; |
1209 | 1250 | $control->_page = $this->getPage(); |
1210 | 1251 | $namingContainer = ($this instanceof INamingContainer)?$this:$this->_namingContainer; |
1211 | 1252 | if($namingContainer) |
1212 | 1253 | { |
1213 | 1254 | $control->_namingContainer = $namingContainer; |
1214 | - if($control->_id === '') |
|
1215 | - $control->generateAutomaticID(); |
|
1216 | - else |
|
1217 | - $namingContainer->clearNameTable(); |
|
1255 | + if($control->_id === '') { |
|
1256 | + $control->generateAutomaticID(); |
|
1257 | + } else { |
|
1258 | + $namingContainer->clearNameTable(); |
|
1259 | + } |
|
1218 | 1260 | $control->clearCachedUniqueID($control instanceof INamingContainer); |
1219 | 1261 | } |
1220 | 1262 | |
@@ -1227,15 +1269,16 @@ discard block |
||
1227 | 1269 | { |
1228 | 1270 | $state = $this->_rf[self::RF_CHILD_STATE][$control->_id]; |
1229 | 1271 | unset($this->_rf[self::RF_CHILD_STATE][$control->_id]); |
1272 | + } else { |
|
1273 | + $state = null; |
|
1230 | 1274 | } |
1231 | - else |
|
1232 | - $state = null; |
|
1233 | 1275 | $control->loadStateRecursive($state, !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1234 | 1276 | if($this->_stage >= self::CS_LOADED) |
1235 | 1277 | { |
1236 | 1278 | $control->loadRecursive(); |
1237 | - if($this->_stage >= self::CS_PRERENDERED) |
|
1238 | - $control->preRenderRecursive(); |
|
1279 | + if($this->_stage >= self::CS_PRERENDERED) { |
|
1280 | + $control->preRenderRecursive(); |
|
1281 | + } |
|
1239 | 1282 | } |
1240 | 1283 | } |
1241 | 1284 | } |
@@ -1248,18 +1291,20 @@ discard block |
||
1248 | 1291 | */ |
1249 | 1292 | public function removedControl($control) |
1250 | 1293 | { |
1251 | - if($this->_namingContainer) |
|
1252 | - $this->_namingContainer->clearNameTable(); |
|
1294 | + if($this->_namingContainer) { |
|
1295 | + $this->_namingContainer->clearNameTable(); |
|
1296 | + } |
|
1253 | 1297 | $control->unloadRecursive(); |
1254 | 1298 | $control->_parent = null; |
1255 | 1299 | $control->_page = null; |
1256 | 1300 | $control->_namingContainer = null; |
1257 | 1301 | $control->_tplControl = null; |
1258 | 1302 | //$control->_stage=self::CS_CONSTRUCTED; |
1259 | - if(!($control->_flags & self::IS_ID_SET)) |
|
1260 | - $control->_id = ''; |
|
1261 | - else |
|
1262 | - unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]); |
|
1303 | + if(!($control->_flags & self::IS_ID_SET)) { |
|
1304 | + $control->_id = ''; |
|
1305 | + } else { |
|
1306 | + unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]); |
|
1307 | + } |
|
1263 | 1308 | $control->clearCachedUniqueID(true); |
1264 | 1309 | } |
1265 | 1310 | |
@@ -1273,8 +1318,9 @@ discard block |
||
1273 | 1318 | $this->ensureChildControls(); |
1274 | 1319 | if($this->getHasControls()) |
1275 | 1320 | { |
1276 | - if($this instanceof INamingContainer) |
|
1277 | - $namingContainer = $this; |
|
1321 | + if($this instanceof INamingContainer) { |
|
1322 | + $namingContainer = $this; |
|
1323 | + } |
|
1278 | 1324 | $page = $this->getPage(); |
1279 | 1325 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1280 | 1326 | { |
@@ -1282,8 +1328,9 @@ discard block |
||
1282 | 1328 | { |
1283 | 1329 | $control->_namingContainer = $namingContainer; |
1284 | 1330 | $control->_page = $page; |
1285 | - if($control->_id === '' && $namingContainer) |
|
1286 | - $control->generateAutomaticID(); |
|
1331 | + if($control->_id === '' && $namingContainer) { |
|
1332 | + $control->generateAutomaticID(); |
|
1333 | + } |
|
1287 | 1334 | $control->initRecursive($namingContainer); |
1288 | 1335 | } |
1289 | 1336 | } |
@@ -1296,10 +1343,11 @@ discard block |
||
1296 | 1343 | $page->applyControlSkin($this); |
1297 | 1344 | $this->_flags |= self::IS_SKIN_APPLIED; |
1298 | 1345 | } |
1299 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1300 | - $this->_rf[self::RF_ADAPTER]->onInit(null); |
|
1301 | - else |
|
1302 | - $this->onInit(null); |
|
1346 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1347 | + $this->_rf[self::RF_ADAPTER]->onInit(null); |
|
1348 | + } else { |
|
1349 | + $this->onInit(null); |
|
1350 | + } |
|
1303 | 1351 | $this->_stage = self::CS_INITIALIZED; |
1304 | 1352 | } |
1305 | 1353 | } |
@@ -1312,21 +1360,24 @@ discard block |
||
1312 | 1360 | { |
1313 | 1361 | if($this->_stage < self::CS_LOADED) |
1314 | 1362 | { |
1315 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1316 | - $this->_rf[self::RF_ADAPTER]->onLoad(null); |
|
1317 | - else |
|
1318 | - $this->onLoad(null); |
|
1363 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1364 | + $this->_rf[self::RF_ADAPTER]->onLoad(null); |
|
1365 | + } else { |
|
1366 | + $this->onLoad(null); |
|
1367 | + } |
|
1319 | 1368 | } |
1320 | 1369 | if($this->getHasControls()) |
1321 | 1370 | { |
1322 | 1371 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1323 | 1372 | { |
1324 | - if($control instanceof TControl) |
|
1325 | - $control->loadRecursive(); |
|
1373 | + if($control instanceof TControl) { |
|
1374 | + $control->loadRecursive(); |
|
1375 | + } |
|
1326 | 1376 | } |
1327 | 1377 | } |
1328 | - if($this->_stage < self::CS_LOADED) |
|
1329 | - $this->_stage = self::CS_LOADED; |
|
1378 | + if($this->_stage < self::CS_LOADED) { |
|
1379 | + $this->_stage = self::CS_LOADED; |
|
1380 | + } |
|
1330 | 1381 | } |
1331 | 1382 | |
1332 | 1383 | /** |
@@ -1339,18 +1390,20 @@ discard block |
||
1339 | 1390 | |
1340 | 1391 | if($this->getVisible(false)) |
1341 | 1392 | { |
1342 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1343 | - $this->_rf[self::RF_ADAPTER]->onPreRender(null); |
|
1344 | - else |
|
1345 | - $this->onPreRender(null); |
|
1393 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1394 | + $this->_rf[self::RF_ADAPTER]->onPreRender(null); |
|
1395 | + } else { |
|
1396 | + $this->onPreRender(null); |
|
1397 | + } |
|
1346 | 1398 | if($this->getHasControls()) |
1347 | 1399 | { |
1348 | 1400 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1349 | 1401 | { |
1350 | - if($control instanceof TControl) |
|
1351 | - $control->preRenderRecursive(); |
|
1352 | - elseif($control instanceof TCompositeLiteral) |
|
1353 | - $control->evaluateDynamicContent(); |
|
1402 | + if($control instanceof TControl) { |
|
1403 | + $control->preRenderRecursive(); |
|
1404 | + } elseif($control instanceof TCompositeLiteral) { |
|
1405 | + $control->evaluateDynamicContent(); |
|
1406 | + } |
|
1354 | 1407 | } |
1355 | 1408 | } |
1356 | 1409 | } |
@@ -1363,18 +1416,21 @@ discard block |
||
1363 | 1416 | */ |
1364 | 1417 | protected function unloadRecursive() |
1365 | 1418 | { |
1366 | - if(!($this->_flags & self::IS_ID_SET)) |
|
1367 | - $this->_id = ''; |
|
1419 | + if(!($this->_flags & self::IS_ID_SET)) { |
|
1420 | + $this->_id = ''; |
|
1421 | + } |
|
1368 | 1422 | if($this->getHasControls()) |
1369 | 1423 | { |
1370 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1371 | - if($control instanceof TControl) |
|
1424 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
1425 | + if($control instanceof TControl) |
|
1372 | 1426 | $control->unloadRecursive(); |
1427 | + } |
|
1428 | + } |
|
1429 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1430 | + $this->_rf[self::RF_ADAPTER]->onUnload(null); |
|
1431 | + } else { |
|
1432 | + $this->onUnload(null); |
|
1373 | 1433 | } |
1374 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1375 | - $this->_rf[self::RF_ADAPTER]->onUnload(null); |
|
1376 | - else |
|
1377 | - $this->onUnload(null); |
|
1378 | 1434 | } |
1379 | 1435 | |
1380 | 1436 | /** |
@@ -1449,8 +1505,9 @@ discard block |
||
1449 | 1505 | $control = $this; |
1450 | 1506 | while($control = $control->_parent) |
1451 | 1507 | { |
1452 | - if($control->bubbleEvent($sender, $param)) |
|
1453 | - break; |
|
1508 | + if($control->bubbleEvent($sender, $param)) { |
|
1509 | + break; |
|
1510 | + } |
|
1454 | 1511 | } |
1455 | 1512 | } |
1456 | 1513 | |
@@ -1499,16 +1556,19 @@ discard block |
||
1499 | 1556 | */ |
1500 | 1557 | private function broadcastEventInternal($name, $sender, $param) |
1501 | 1558 | { |
1502 | - if($this->hasEvent($name)) |
|
1503 | - $this->raiseEvent($name, $sender, $param->getParameter()); |
|
1504 | - if($this instanceof IBroadcastEventReceiver) |
|
1505 | - $this->broadcastEventReceived($sender, $param); |
|
1559 | + if($this->hasEvent($name)) { |
|
1560 | + $this->raiseEvent($name, $sender, $param->getParameter()); |
|
1561 | + } |
|
1562 | + if($this instanceof IBroadcastEventReceiver) { |
|
1563 | + $this->broadcastEventReceived($sender, $param); |
|
1564 | + } |
|
1506 | 1565 | if($this->getHasControls()) |
1507 | 1566 | { |
1508 | 1567 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1509 | 1568 | { |
1510 | - if($control instanceof TControl) |
|
1511 | - $control->broadcastEventInternal($name, $sender, $param); |
|
1569 | + if($control instanceof TControl) { |
|
1570 | + $control->broadcastEventInternal($name, $sender, $param); |
|
1571 | + } |
|
1512 | 1572 | } |
1513 | 1573 | } |
1514 | 1574 | } |
@@ -1532,8 +1592,9 @@ discard block |
||
1532 | 1592 | */ |
1533 | 1593 | protected function traverseChildControls($param, $preCallback = null, $postCallback = null) |
1534 | 1594 | { |
1535 | - if($preCallback !== null) |
|
1536 | - call_user_func($preCallback, $this, $param); |
|
1595 | + if($preCallback !== null) { |
|
1596 | + call_user_func($preCallback, $this, $param); |
|
1597 | + } |
|
1537 | 1598 | if($this->getHasControls()) |
1538 | 1599 | { |
1539 | 1600 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
@@ -1544,8 +1605,9 @@ discard block |
||
1544 | 1605 | } |
1545 | 1606 | } |
1546 | 1607 | } |
1547 | - if($postCallback !== null) |
|
1548 | - call_user_func($postCallback, $this, $param); |
|
1608 | + if($postCallback !== null) { |
|
1609 | + call_user_func($postCallback, $this, $param); |
|
1610 | + } |
|
1549 | 1611 | } |
1550 | 1612 | |
1551 | 1613 | /** |
@@ -1557,10 +1619,11 @@ discard block |
||
1557 | 1619 | { |
1558 | 1620 | if($this instanceof IActiveControl || $this->getVisible(false)) |
1559 | 1621 | { |
1560 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1561 | - $this->_rf[self::RF_ADAPTER]->render($writer); |
|
1562 | - else |
|
1563 | - $this->render($writer); |
|
1622 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1623 | + $this->_rf[self::RF_ADAPTER]->render($writer); |
|
1624 | + } else { |
|
1625 | + $this->render($writer); |
|
1626 | + } |
|
1564 | 1627 | } |
1565 | 1628 | } |
1566 | 1629 | |
@@ -1588,12 +1651,13 @@ discard block |
||
1588 | 1651 | { |
1589 | 1652 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1590 | 1653 | { |
1591 | - if(is_string($control)) |
|
1592 | - $writer->write($control); |
|
1593 | - elseif($control instanceof TControl) |
|
1594 | - $control->renderControl($writer); |
|
1595 | - elseif($control instanceof IRenderable) |
|
1596 | - $control->render($writer); |
|
1654 | + if(is_string($control)) { |
|
1655 | + $writer->write($control); |
|
1656 | + } elseif($control instanceof TControl) { |
|
1657 | + $control->renderControl($writer); |
|
1658 | + } elseif($control instanceof IRenderable) { |
|
1659 | + $control->render($writer); |
|
1660 | + } |
|
1597 | 1661 | } |
1598 | 1662 | } |
1599 | 1663 | } |
@@ -1633,15 +1697,16 @@ discard block |
||
1633 | 1697 | { |
1634 | 1698 | $this->_rf[self::RF_CONTROLSTATE] = &$state[1]; |
1635 | 1699 | unset($state[1]); |
1700 | + } else { |
|
1701 | + unset($this->_rf[self::RF_CONTROLSTATE]); |
|
1636 | 1702 | } |
1637 | - else |
|
1638 | - unset($this->_rf[self::RF_CONTROLSTATE]); |
|
1639 | 1703 | if($needViewState) |
1640 | 1704 | { |
1641 | - if(isset($state[0])) |
|
1642 | - $this->_viewState = &$state[0]; |
|
1643 | - else |
|
1644 | - $this->_viewState = []; |
|
1705 | + if(isset($state[0])) { |
|
1706 | + $this->_viewState = &$state[0]; |
|
1707 | + } else { |
|
1708 | + $this->_viewState = []; |
|
1709 | + } |
|
1645 | 1710 | } |
1646 | 1711 | unset($state[0]); |
1647 | 1712 | if($this->getHasControls()) |
@@ -1658,14 +1723,16 @@ discard block |
||
1658 | 1723 | } |
1659 | 1724 | } |
1660 | 1725 | } |
1661 | - if(!empty($state)) |
|
1662 | - $this->_rf[self::RF_CHILD_STATE] = &$state; |
|
1726 | + if(!empty($state)) { |
|
1727 | + $this->_rf[self::RF_CHILD_STATE] = &$state; |
|
1728 | + } |
|
1663 | 1729 | } |
1664 | 1730 | $this->_stage = self::CS_STATE_LOADED; |
1665 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1666 | - $this->_rf[self::RF_ADAPTER]->loadState(); |
|
1667 | - else |
|
1668 | - $this->loadState(); |
|
1731 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1732 | + $this->_rf[self::RF_ADAPTER]->loadState(); |
|
1733 | + } else { |
|
1734 | + $this->loadState(); |
|
1735 | + } |
|
1669 | 1736 | } |
1670 | 1737 | |
1671 | 1738 | /** |
@@ -1676,10 +1743,11 @@ discard block |
||
1676 | 1743 | */ |
1677 | 1744 | protected function &saveStateRecursive($needViewState = true) |
1678 | 1745 | { |
1679 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1680 | - $this->_rf[self::RF_ADAPTER]->saveState(); |
|
1681 | - else |
|
1682 | - $this->saveState(); |
|
1746 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1747 | + $this->_rf[self::RF_ADAPTER]->saveState(); |
|
1748 | + } else { |
|
1749 | + $this->saveState(); |
|
1750 | + } |
|
1683 | 1751 | $needViewState = ($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1684 | 1752 | $state = []; |
1685 | 1753 | if($this->getHasControls()) |
@@ -1688,15 +1756,18 @@ discard block |
||
1688 | 1756 | { |
1689 | 1757 | if($control instanceof TControl) |
1690 | 1758 | { |
1691 | - if(count($tmp = &$control->saveStateRecursive($needViewState))) |
|
1692 | - $state[$control->_id] = $tmp; |
|
1759 | + if(count($tmp = &$control->saveStateRecursive($needViewState))) { |
|
1760 | + $state[$control->_id] = $tmp; |
|
1761 | + } |
|
1693 | 1762 | } |
1694 | 1763 | } |
1695 | 1764 | } |
1696 | - if($needViewState && !empty($this->_viewState)) |
|
1697 | - $state[0] = &$this->_viewState; |
|
1698 | - if(isset($this->_rf[self::RF_CONTROLSTATE])) |
|
1699 | - $state[1] = &$this->_rf[self::RF_CONTROLSTATE]; |
|
1765 | + if($needViewState && !empty($this->_viewState)) { |
|
1766 | + $state[0] = &$this->_viewState; |
|
1767 | + } |
|
1768 | + if(isset($this->_rf[self::RF_CONTROLSTATE])) { |
|
1769 | + $state[1] = &$this->_rf[self::RF_CONTROLSTATE]; |
|
1770 | + } |
|
1700 | 1771 | return $state; |
1701 | 1772 | } |
1702 | 1773 | |
@@ -1711,9 +1782,9 @@ discard block |
||
1711 | 1782 | { |
1712 | 1783 | $page->applyControlStyleSheet($this); |
1713 | 1784 | $this->_flags |= self::IS_STYLESHEET_APPLIED; |
1785 | + } elseif($this->_flags & self::IS_STYLESHEET_APPLIED) { |
|
1786 | + throw new TInvalidOperationException('control_stylesheet_applied', get_class($this)); |
|
1714 | 1787 | } |
1715 | - elseif($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
1716 | - throw new TInvalidOperationException('control_stylesheet_applied', get_class($this)); |
|
1717 | 1788 | } |
1718 | 1789 | |
1719 | 1790 | /** |
@@ -1725,9 +1796,10 @@ discard block |
||
1725 | 1796 | { |
1726 | 1797 | if($recursive && $this->_uid !== null && isset($this->_rf[self::RF_CONTROLS])) |
1727 | 1798 | { |
1728 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1729 | - if($control instanceof TControl) |
|
1799 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
1800 | + if($control instanceof TControl) |
|
1730 | 1801 | $control->clearCachedUniqueID($recursive); |
1802 | + } |
|
1731 | 1803 | } |
1732 | 1804 | $this->_uid = null; |
1733 | 1805 | } |
@@ -1738,8 +1810,9 @@ discard block |
||
1738 | 1810 | private function generateAutomaticID() |
1739 | 1811 | { |
1740 | 1812 | $this->_flags &= ~self::IS_ID_SET; |
1741 | - if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) |
|
1742 | - $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID] = 0; |
|
1813 | + if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) { |
|
1814 | + $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID] = 0; |
|
1815 | + } |
|
1743 | 1816 | $id = $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++; |
1744 | 1817 | $this->_id = self::AUTOMATIC_ID_PREFIX . $id; |
1745 | 1818 | $this->_namingContainer->clearNameTable(); |
@@ -1767,13 +1840,15 @@ discard block |
||
1767 | 1840 | { |
1768 | 1841 | if($control->_id !== '') |
1769 | 1842 | { |
1770 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) |
|
1771 | - throw new TInvalidDataValueException('control_id_nonunique', get_class($control), $control->_id); |
|
1772 | - else |
|
1773 | - $container->_rf[self::RF_NAMED_CONTROLS][$control->_id] = $control; |
|
1843 | + if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) { |
|
1844 | + throw new TInvalidDataValueException('control_id_nonunique', get_class($control), $control->_id); |
|
1845 | + } else { |
|
1846 | + $container->_rf[self::RF_NAMED_CONTROLS][$control->_id] = $control; |
|
1847 | + } |
|
1848 | + } |
|
1849 | + if(!($control instanceof INamingContainer) && $control->getHasControls()) { |
|
1850 | + $this->fillNameTable($container, $control->_rf[self::RF_CONTROLS]); |
|
1774 | 1851 | } |
1775 | - if(!($control instanceof INamingContainer) && $control->getHasControls()) |
|
1776 | - $this->fillNameTable($container, $control->_rf[self::RF_CONTROLS]); |
|
1777 | 1852 | } |
1778 | 1853 | } |
1779 | 1854 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function setHistorySize($value) |
87 | 87 | { |
88 | - if(($value = TPropertyValue::ensureInteger($value)) > 0) |
|
88 | + if (($value = TPropertyValue::ensureInteger($value)) > 0) |
|
89 | 89 | $this->_historySize = $value; |
90 | 90 | else |
91 | 91 | throw new TInvalidDataValueException('sessionpagestatepersister_historysize_invalid'); |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | $session = $this->_page->getSession(); |
100 | 100 | $session->open(); |
101 | 101 | $data = serialize($state); |
102 | - $timestamp = (string)microtime(true); |
|
103 | - $key = self::STATE_SESSION_KEY . $timestamp; |
|
102 | + $timestamp = (string) microtime(true); |
|
103 | + $key = self::STATE_SESSION_KEY.$timestamp; |
|
104 | 104 | $session->add($key, $data); |
105 | - if(($queue = $session->itemAt(self::QUEUE_SESSION_KEY)) === null) |
|
105 | + if (($queue = $session->itemAt(self::QUEUE_SESSION_KEY)) === null) |
|
106 | 106 | $queue = []; |
107 | 107 | $queue[] = $key; |
108 | - if(count($queue) > $this->getHistorySize()) |
|
108 | + if (count($queue) > $this->getHistorySize()) |
|
109 | 109 | { |
110 | 110 | $expiredKey = array_shift($queue); |
111 | 111 | $session->remove($expiredKey); |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function load() |
123 | 123 | { |
124 | - if(($timestamp = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) |
|
124 | + if (($timestamp = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) |
|
125 | 125 | { |
126 | 126 | $session = $this->_page->getSession(); |
127 | 127 | $session->open(); |
128 | - $key = self::STATE_SESSION_KEY . $timestamp; |
|
129 | - if(($data = $session->itemAt($key)) !== null) |
|
128 | + $key = self::STATE_SESSION_KEY.$timestamp; |
|
129 | + if (($data = $session->itemAt($key)) !== null) |
|
130 | 130 | return unserialize($data); |
131 | 131 | } |
132 | 132 | throw new THttpException(400, 'sessionpagestatepersister_pagestate_corrupted'); |
@@ -85,10 +85,11 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function setHistorySize($value) |
87 | 87 | { |
88 | - if(($value = TPropertyValue::ensureInteger($value)) > 0) |
|
89 | - $this->_historySize = $value; |
|
90 | - else |
|
91 | - throw new TInvalidDataValueException('sessionpagestatepersister_historysize_invalid'); |
|
88 | + if(($value = TPropertyValue::ensureInteger($value)) > 0) { |
|
89 | + $this->_historySize = $value; |
|
90 | + } else { |
|
91 | + throw new TInvalidDataValueException('sessionpagestatepersister_historysize_invalid'); |
|
92 | + } |
|
92 | 93 | } |
93 | 94 | /** |
94 | 95 | * Saves state in session. |
@@ -102,8 +103,9 @@ discard block |
||
102 | 103 | $timestamp = (string)microtime(true); |
103 | 104 | $key = self::STATE_SESSION_KEY . $timestamp; |
104 | 105 | $session->add($key, $data); |
105 | - if(($queue = $session->itemAt(self::QUEUE_SESSION_KEY)) === null) |
|
106 | - $queue = []; |
|
106 | + if(($queue = $session->itemAt(self::QUEUE_SESSION_KEY)) === null) { |
|
107 | + $queue = []; |
|
108 | + } |
|
107 | 109 | $queue[] = $key; |
108 | 110 | if(count($queue) > $this->getHistorySize()) |
109 | 111 | { |
@@ -126,8 +128,9 @@ discard block |
||
126 | 128 | $session = $this->_page->getSession(); |
127 | 129 | $session->open(); |
128 | 130 | $key = self::STATE_SESSION_KEY . $timestamp; |
129 | - if(($data = $session->itemAt($key)) !== null) |
|
130 | - return unserialize($data); |
|
131 | + if(($data = $session->itemAt($key)) !== null) { |
|
132 | + return unserialize($data); |
|
133 | + } |
|
131 | 134 | } |
132 | 135 | throw new THttpException(400, 'sessionpagestatepersister_pagestate_corrupted'); |
133 | 136 | } |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | protected function registerPradoScriptInternal($name) |
169 | 169 | { |
170 | 170 | // $this->checkIfNotInRender(); |
171 | - if(!isset($this->_registeredScripts[$name])) |
|
171 | + if (!isset($this->_registeredScripts[$name])) |
|
172 | 172 | { |
173 | - if(self::$_scripts === null) |
|
173 | + if (self::$_scripts === null) |
|
174 | 174 | { |
175 | - $packageFile = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::PACKAGES_FILE; |
|
175 | + $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE; |
|
176 | 176 | list($folders, $packages, $deps) = include($packageFile); |
177 | 177 | self::$_scriptsFolders = $folders; |
178 | 178 | self::$_scripts = $deps; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | else |
185 | 185 | throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); |
186 | 186 | |
187 | - if(($packages = array_keys($this->_registeredScripts)) !== []) |
|
187 | + if (($packages = array_keys($this->_registeredScripts)) !== []) |
|
188 | 188 | { |
189 | 189 | $packagesUrl = []; |
190 | 190 | $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | list($path, $baseUrl) = $this->getPackagePathUrl($base); |
201 | 201 | |
202 | 202 | $this->_expandedScripts[$script] = true; |
203 | - if($isDebug) |
|
203 | + if ($isDebug) |
|
204 | 204 | { |
205 | - if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) |
|
205 | + if (!in_array($url = $baseUrl.'/'.$subPath, $packagesUrl)) |
|
206 | 206 | $packagesUrl[] = $url; |
207 | 207 | } else { |
208 | 208 | $minPath = preg_replace('/^(.*)(?<!\.min)\.js$/', "\\1.min.js", $subPath); |
209 | - if (!in_array($url = $baseUrl . '/' . $minPath, $packagesUrl)) |
|
209 | + if (!in_array($url = $baseUrl.'/'.$minPath, $packagesUrl)) |
|
210 | 210 | { |
211 | - if(!is_file($filePath = $path . DIRECTORY_SEPARATOR . $minPath)) |
|
211 | + if (!is_file($filePath = $path.DIRECTORY_SEPARATOR.$minPath)) |
|
212 | 212 | { |
213 | - file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base . '/' . $subPath))); |
|
213 | + file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base.'/'.$subPath))); |
|
214 | 214 | chmod($filePath, PRADO_CHMOD); |
215 | 215 | } |
216 | 216 | $packagesUrl[] = $url; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | } |
222 | 222 | } |
223 | - foreach($packagesUrl as $url) |
|
223 | + foreach ($packagesUrl as $url) |
|
224 | 224 | $this->registerScriptFile($url, $url); |
225 | 225 | } |
226 | 226 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function getPradoScriptAssetUrl($script = 'prado') |
233 | 233 | { |
234 | - if(!isset(self::$_scriptsFolders[$script])) |
|
234 | + if (!isset(self::$_scriptsFolders[$script])) |
|
235 | 235 | $this->registerPradoScriptInternal($script); |
236 | 236 | |
237 | 237 | $base = Prado::getPathOfNameSpace(self::$_scriptsFolders[$script]); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function getPradoScriptAssetPath($script = 'prado') |
246 | 246 | { |
247 | - if(!isset(self::$_scriptsFolders[$script])) |
|
247 | + if (!isset(self::$_scriptsFolders[$script])) |
|
248 | 248 | $this->registerPradoScriptInternal($script); |
249 | 249 | |
250 | 250 | $base = Prado::getPathOfNameSpace(self::$_scriptsFolders[$script]); |
@@ -272,13 +272,13 @@ discard block |
||
272 | 272 | protected function getPackagePathUrl($base) |
273 | 273 | { |
274 | 274 | $assets = Prado::getApplication()->getAssetManager(); |
275 | - if(strpos($base, $assets->getBaseUrl()) === false) |
|
275 | + if (strpos($base, $assets->getBaseUrl()) === false) |
|
276 | 276 | { |
277 | 277 | return [$assets->getPublishedPath($base), $assets->publishFilePath($base)]; |
278 | 278 | } |
279 | 279 | else |
280 | 280 | { |
281 | - return [$assets->getBasePath() . str_replace($assets->getBaseUrl(), '', $base), $base]; |
|
281 | + return [$assets->getBasePath().str_replace($assets->getBaseUrl(), '', $base), $base]; |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
@@ -290,11 +290,11 @@ discard block |
||
290 | 290 | { |
291 | 291 | list($base, $subPath) = explode("/", $script, 2); |
292 | 292 | |
293 | - if(!array_key_exists($base, self::$_scriptsFolders)) |
|
293 | + if (!array_key_exists($base, self::$_scriptsFolders)) |
|
294 | 294 | throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
295 | 295 | |
296 | 296 | $namespace = self::$_scriptsFolders[$base]; |
297 | - if(($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
|
297 | + if (($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
|
298 | 298 | $namespace = $dir; |
299 | 299 | } |
300 | 300 | |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | { |
310 | 310 | list($base, $subPath) = explode("/", $script, 2); |
311 | 311 | |
312 | - if(!array_key_exists($base, self::$_stylesFolders)) |
|
312 | + if (!array_key_exists($base, self::$_stylesFolders)) |
|
313 | 313 | throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
314 | 314 | |
315 | 315 | $namespace = self::$_stylesFolders[$base]; |
316 | - if(($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
|
316 | + if (($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
|
317 | 317 | $namespace = $dir; |
318 | 318 | } |
319 | 319 | |
@@ -362,10 +362,10 @@ discard block |
||
362 | 362 | */ |
363 | 363 | public function registerPostBackControl($class, $options) |
364 | 364 | { |
365 | - if($class === null) { |
|
365 | + if ($class === null) { |
|
366 | 366 | return; |
367 | 367 | } |
368 | - if(!isset($options['FormID']) && ($form = $this->_page->getForm()) !== null) |
|
368 | + if (!isset($options['FormID']) && ($form = $this->_page->getForm()) !== null) |
|
369 | 369 | $options['FormID'] = $form->getClientID(); |
370 | 370 | $optionString = TJavaScript::encode($options); |
371 | 371 | $code = "new {$class}({$optionString});"; |
@@ -385,9 +385,9 @@ discard block |
||
385 | 385 | */ |
386 | 386 | public function registerDefaultButton($panel, $button) |
387 | 387 | { |
388 | - $panelID = is_string($panel)?$panel:$panel->getUniqueID(); |
|
388 | + $panelID = is_string($panel) ? $panel : $panel->getUniqueID(); |
|
389 | 389 | |
390 | - if(is_string($button)) |
|
390 | + if (is_string($button)) |
|
391 | 391 | $buttonID = $button; |
392 | 392 | else |
393 | 393 | { |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | $options = TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); |
398 | 398 | $code = "new Prado.WebUI.DefaultButton($options);"; |
399 | 399 | |
400 | - $this->_endScripts['prado:' . $panelID] = $code; |
|
400 | + $this->_endScripts['prado:'.$panelID] = $code; |
|
401 | 401 | $this->registerPradoScriptInternal('prado'); |
402 | 402 | |
403 | - $params = [$panelID,$buttonID]; |
|
403 | + $params = [$panelID, $buttonID]; |
|
404 | 404 | $this->_page->registerCachingAction('Page.ClientScript', 'registerDefaultButton', $params); |
405 | 405 | } |
406 | 406 | |
@@ -426,9 +426,9 @@ discard block |
||
426 | 426 | public function registerFocusControl($target) |
427 | 427 | { |
428 | 428 | $this->registerPradoScriptInternal('jquery'); |
429 | - if($target instanceof TControl) |
|
429 | + if ($target instanceof TControl) |
|
430 | 430 | $target = $target->getClientID(); |
431 | - $this->_endScripts['prado:focus'] = 'jQuery(\'#' . $target . '\').focus();'; |
|
431 | + $this->_endScripts['prado:focus'] = 'jQuery(\'#'.$target.'\').focus();'; |
|
432 | 432 | |
433 | 433 | $params = func_get_args(); |
434 | 434 | $this->_page->registerCachingAction('Page.ClientScript', 'registerFocusControl', $params); |
@@ -452,11 +452,11 @@ discard block |
||
452 | 452 | protected function registerPradoStyleInternal($name) |
453 | 453 | { |
454 | 454 | // $this->checkIfNotInRender(); |
455 | - if(!isset($this->_registeredStyles[$name])) |
|
455 | + if (!isset($this->_registeredStyles[$name])) |
|
456 | 456 | { |
457 | - if(self::$_styles === null) |
|
457 | + if (self::$_styles === null) |
|
458 | 458 | { |
459 | - $packageFile = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::CSS_PACKAGES_FILE; |
|
459 | + $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::CSS_PACKAGES_FILE; |
|
460 | 460 | list($folders, $packages, $deps) = include($packageFile); |
461 | 461 | self::$_stylesFolders = $folders; |
462 | 462 | self::$_styles = $deps; |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | else |
469 | 469 | throw new TInvalidOperationException('csmanager_pradostyle_invalid', $name); |
470 | 470 | |
471 | - if(($packages = array_keys($this->_registeredStyles)) !== []) |
|
471 | + if (($packages = array_keys($this->_registeredStyles)) !== []) |
|
472 | 472 | { |
473 | 473 | $packagesUrl = []; |
474 | 474 | $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; |
@@ -485,13 +485,13 @@ discard block |
||
485 | 485 | |
486 | 486 | $this->_expandedStyles[$style] = true; |
487 | 487 | // TODO minify css? |
488 | - if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) |
|
488 | + if (!in_array($url = $baseUrl.'/'.$subPath, $packagesUrl)) |
|
489 | 489 | $packagesUrl[] = $url; |
490 | 490 | } |
491 | 491 | } |
492 | 492 | } |
493 | 493 | } |
494 | - foreach($packagesUrl as $url) |
|
494 | + foreach ($packagesUrl as $url) |
|
495 | 495 | $this->registerStyleSheetFile($url, $url); |
496 | 496 | } |
497 | 497 | } |
@@ -521,10 +521,10 @@ discard block |
||
521 | 521 | */ |
522 | 522 | public function registerStyleSheetFile($key, $url, $media = '') |
523 | 523 | { |
524 | - if($media === '') |
|
524 | + if ($media === '') |
|
525 | 525 | $this->_styleSheetFiles[$key] = $url; |
526 | 526 | else |
527 | - $this->_styleSheetFiles[$key] = [$url,$media]; |
|
527 | + $this->_styleSheetFiles[$key] = [$url, $media]; |
|
528 | 528 | |
529 | 529 | $params = func_get_args(); |
530 | 530 | $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheetFile', $params); |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | }, $this->_styleSheetFiles) |
556 | 556 | ); |
557 | 557 | |
558 | - foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path => $url) |
|
558 | + foreach (Prado::getApplication()->getAssetManager()->getPublished() as $path => $url) |
|
559 | 559 | if (substr($url, strlen($url) - 4) == '.css') |
560 | 560 | $stylesheets[] = $url; |
561 | 561 | |
@@ -749,12 +749,12 @@ discard block |
||
749 | 749 | public function renderStyleSheetFiles($writer) |
750 | 750 | { |
751 | 751 | $str = ''; |
752 | - foreach($this->_styleSheetFiles as $url) |
|
752 | + foreach ($this->_styleSheetFiles as $url) |
|
753 | 753 | { |
754 | - if(is_array($url)) |
|
755 | - $str .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"" . THttpUtility::htmlEncode($url[0]) . "\" />\n"; |
|
754 | + if (is_array($url)) |
|
755 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n"; |
|
756 | 756 | else |
757 | - $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . THttpUtility::htmlEncode($url) . "\" />\n"; |
|
757 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n"; |
|
758 | 758 | } |
759 | 759 | $writer->write($str); |
760 | 760 | } |
@@ -764,8 +764,8 @@ discard block |
||
764 | 764 | */ |
765 | 765 | public function renderStyleSheets($writer) |
766 | 766 | { |
767 | - if(count($this->_styleSheets)) |
|
768 | - $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n" . implode("\n", $this->_styleSheets) . "\n/*]]>*/\n</style>\n"); |
|
767 | + if (count($this->_styleSheets)) |
|
768 | + $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n", $this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | /** |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | |
804 | 804 | protected function renderScriptFiles($writer, array $scripts) |
805 | 805 | { |
806 | - foreach($scripts as $script) |
|
806 | + foreach ($scripts as $script) |
|
807 | 807 | { |
808 | 808 | $writer->write(TJavaScript::renderScriptFile($script)); |
809 | 809 | $this->markScriptFileAsRendered($script); |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | */ |
821 | 821 | public function renderAllPendingScriptFiles($writer) |
822 | 822 | { |
823 | - if(!empty($this->_scriptFiles)) |
|
823 | + if (!empty($this->_scriptFiles)) |
|
824 | 824 | { |
825 | 825 | $addedScripts = array_diff($this->_scriptFiles, $this->getRenderedScriptFiles()); |
826 | 826 | $this->renderScriptFiles($writer, $addedScripts); |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | */ |
877 | 877 | public function flushScriptFiles($writer, $control = null) |
878 | 878 | { |
879 | - if(!$this->_page->getIsCallback()) |
|
879 | + if (!$this->_page->getIsCallback()) |
|
880 | 880 | { |
881 | 881 | $this->_page->ensureRenderInForm($control); |
882 | 882 | $this->renderAllPendingScriptFiles($writer); |
@@ -895,23 +895,23 @@ discard block |
||
895 | 895 | { |
896 | 896 | if ($initial) $this->_renderedHiddenFields = []; |
897 | 897 | $str = ''; |
898 | - foreach($this->_hiddenFields as $name => $value) |
|
898 | + foreach ($this->_hiddenFields as $name => $value) |
|
899 | 899 | { |
900 | 900 | if (in_array($name, $this->_renderedHiddenFields)) continue; |
901 | 901 | $id = strtr($name, ':', '_'); |
902 | - if(is_array($value)) |
|
902 | + if (is_array($value)) |
|
903 | 903 | { |
904 | - foreach($value as $v) |
|
905 | - $str .= '<input type="text" style="display:none" autocomplete="off" name="' . $name . '[]" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
904 | + foreach ($value as $v) |
|
905 | + $str .= '<input type="text" style="display:none" autocomplete="off" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
906 | 906 | } |
907 | 907 | else |
908 | 908 | { |
909 | - $str .= '<input type="text" style="display:none" autocomplete="off" name="' . $name . '" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
909 | + $str .= '<input type="text" style="display:none" autocomplete="off" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
910 | 910 | } |
911 | 911 | $this->_renderedHiddenFields[] = $name; |
912 | 912 | } |
913 | - if($str !== '') |
|
914 | - $writer->write("<div style=\"visibility:hidden;\">\n" . $str . "</div>\n"); |
|
913 | + if ($str !== '') |
|
914 | + $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | public function getHiddenFields() |
@@ -179,10 +179,11 @@ discard block |
||
179 | 179 | self::$_scriptsPackages = $packages; |
180 | 180 | } |
181 | 181 | |
182 | - if (isset(self::$_scripts[$name])) |
|
183 | - $this->_registeredScripts[$name] = true; |
|
184 | - else |
|
185 | - throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); |
|
182 | + if (isset(self::$_scripts[$name])) { |
|
183 | + $this->_registeredScripts[$name] = true; |
|
184 | + } else { |
|
185 | + throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); |
|
186 | + } |
|
186 | 187 | |
187 | 188 | if(($packages = array_keys($this->_registeredScripts)) !== []) |
188 | 189 | { |
@@ -202,8 +203,9 @@ discard block |
||
202 | 203 | $this->_expandedScripts[$script] = true; |
203 | 204 | if($isDebug) |
204 | 205 | { |
205 | - if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) |
|
206 | - $packagesUrl[] = $url; |
|
206 | + if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) { |
|
207 | + $packagesUrl[] = $url; |
|
208 | + } |
|
207 | 209 | } else { |
208 | 210 | $minPath = preg_replace('/^(.*)(?<!\.min)\.js$/', "\\1.min.js", $subPath); |
209 | 211 | if (!in_array($url = $baseUrl . '/' . $minPath, $packagesUrl)) |
@@ -220,8 +222,9 @@ discard block |
||
220 | 222 | } |
221 | 223 | } |
222 | 224 | } |
223 | - foreach($packagesUrl as $url) |
|
224 | - $this->registerScriptFile($url, $url); |
|
225 | + foreach($packagesUrl as $url) { |
|
226 | + $this->registerScriptFile($url, $url); |
|
227 | + } |
|
225 | 228 | } |
226 | 229 | } |
227 | 230 | } |
@@ -231,8 +234,9 @@ discard block |
||
231 | 234 | */ |
232 | 235 | public function getPradoScriptAssetUrl($script = 'prado') |
233 | 236 | { |
234 | - if(!isset(self::$_scriptsFolders[$script])) |
|
235 | - $this->registerPradoScriptInternal($script); |
|
237 | + if(!isset(self::$_scriptsFolders[$script])) { |
|
238 | + $this->registerPradoScriptInternal($script); |
|
239 | + } |
|
236 | 240 | |
237 | 241 | $base = Prado::getPathOfNameSpace(self::$_scriptsFolders[$script]); |
238 | 242 | $assets = Prado::getApplication()->getAssetManager(); |
@@ -244,8 +248,9 @@ discard block |
||
244 | 248 | */ |
245 | 249 | public function getPradoScriptAssetPath($script = 'prado') |
246 | 250 | { |
247 | - if(!isset(self::$_scriptsFolders[$script])) |
|
248 | - $this->registerPradoScriptInternal($script); |
|
251 | + if(!isset(self::$_scriptsFolders[$script])) { |
|
252 | + $this->registerPradoScriptInternal($script); |
|
253 | + } |
|
249 | 254 | |
250 | 255 | $base = Prado::getPathOfNameSpace(self::$_scriptsFolders[$script]); |
251 | 256 | $assets = Prado::getApplication()->getAssetManager(); |
@@ -275,8 +280,7 @@ discard block |
||
275 | 280 | if(strpos($base, $assets->getBaseUrl()) === false) |
276 | 281 | { |
277 | 282 | return [$assets->getPublishedPath($base), $assets->publishFilePath($base)]; |
278 | - } |
|
279 | - else |
|
283 | + } else |
|
280 | 284 | { |
281 | 285 | return [$assets->getBasePath() . str_replace($assets->getBaseUrl(), '', $base), $base]; |
282 | 286 | } |
@@ -290,8 +294,9 @@ discard block |
||
290 | 294 | { |
291 | 295 | list($base, $subPath) = explode("/", $script, 2); |
292 | 296 | |
293 | - if(!array_key_exists($base, self::$_scriptsFolders)) |
|
294 | - throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
|
297 | + if(!array_key_exists($base, self::$_scriptsFolders)) { |
|
298 | + throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
|
299 | + } |
|
295 | 300 | |
296 | 301 | $namespace = self::$_scriptsFolders[$base]; |
297 | 302 | if(($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
@@ -309,8 +314,9 @@ discard block |
||
309 | 314 | { |
310 | 315 | list($base, $subPath) = explode("/", $script, 2); |
311 | 316 | |
312 | - if(!array_key_exists($base, self::$_stylesFolders)) |
|
313 | - throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
|
317 | + if(!array_key_exists($base, self::$_stylesFolders)) { |
|
318 | + throw new TInvalidOperationException('csmanager_pradostyle_invalid', $base); |
|
319 | + } |
|
314 | 320 | |
315 | 321 | $namespace = self::$_stylesFolders[$base]; |
316 | 322 | if(($dir = Prado::getPathOfNameSpace($namespace)) !== null) { |
@@ -365,8 +371,9 @@ discard block |
||
365 | 371 | if($class === null) { |
366 | 372 | return; |
367 | 373 | } |
368 | - if(!isset($options['FormID']) && ($form = $this->_page->getForm()) !== null) |
|
369 | - $options['FormID'] = $form->getClientID(); |
|
374 | + if(!isset($options['FormID']) && ($form = $this->_page->getForm()) !== null) { |
|
375 | + $options['FormID'] = $form->getClientID(); |
|
376 | + } |
|
370 | 377 | $optionString = TJavaScript::encode($options); |
371 | 378 | $code = "new {$class}({$optionString});"; |
372 | 379 | |
@@ -387,9 +394,9 @@ discard block |
||
387 | 394 | { |
388 | 395 | $panelID = is_string($panel)?$panel:$panel->getUniqueID(); |
389 | 396 | |
390 | - if(is_string($button)) |
|
391 | - $buttonID = $button; |
|
392 | - else |
|
397 | + if(is_string($button)) { |
|
398 | + $buttonID = $button; |
|
399 | + } else |
|
393 | 400 | { |
394 | 401 | $button->setIsDefaultButton(true); |
395 | 402 | $buttonID = $button->getUniqueID(); |
@@ -426,8 +433,9 @@ discard block |
||
426 | 433 | public function registerFocusControl($target) |
427 | 434 | { |
428 | 435 | $this->registerPradoScriptInternal('jquery'); |
429 | - if($target instanceof TControl) |
|
430 | - $target = $target->getClientID(); |
|
436 | + if($target instanceof TControl) { |
|
437 | + $target = $target->getClientID(); |
|
438 | + } |
|
431 | 439 | $this->_endScripts['prado:focus'] = 'jQuery(\'#' . $target . '\').focus();'; |
432 | 440 | |
433 | 441 | $params = func_get_args(); |
@@ -463,10 +471,11 @@ discard block |
||
463 | 471 | self::$_stylesPackages = $packages; |
464 | 472 | } |
465 | 473 | |
466 | - if (isset(self::$_styles[$name])) |
|
467 | - $this->_registeredStyles[$name] = true; |
|
468 | - else |
|
469 | - throw new TInvalidOperationException('csmanager_pradostyle_invalid', $name); |
|
474 | + if (isset(self::$_styles[$name])) { |
|
475 | + $this->_registeredStyles[$name] = true; |
|
476 | + } else { |
|
477 | + throw new TInvalidOperationException('csmanager_pradostyle_invalid', $name); |
|
478 | + } |
|
470 | 479 | |
471 | 480 | if(($packages = array_keys($this->_registeredStyles)) !== []) |
472 | 481 | { |
@@ -485,14 +494,16 @@ discard block |
||
485 | 494 | |
486 | 495 | $this->_expandedStyles[$style] = true; |
487 | 496 | // TODO minify css? |
488 | - if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) |
|
489 | - $packagesUrl[] = $url; |
|
497 | + if (!in_array($url = $baseUrl . '/' . $subPath, $packagesUrl)) { |
|
498 | + $packagesUrl[] = $url; |
|
499 | + } |
|
490 | 500 | } |
491 | 501 | } |
492 | 502 | } |
493 | 503 | } |
494 | - foreach($packagesUrl as $url) |
|
495 | - $this->registerStyleSheetFile($url, $url); |
|
504 | + foreach($packagesUrl as $url) { |
|
505 | + $this->registerStyleSheetFile($url, $url); |
|
506 | + } |
|
496 | 507 | } |
497 | 508 | } |
498 | 509 | } |
@@ -521,10 +532,11 @@ discard block |
||
521 | 532 | */ |
522 | 533 | public function registerStyleSheetFile($key, $url, $media = '') |
523 | 534 | { |
524 | - if($media === '') |
|
525 | - $this->_styleSheetFiles[$key] = $url; |
|
526 | - else |
|
527 | - $this->_styleSheetFiles[$key] = [$url,$media]; |
|
535 | + if($media === '') { |
|
536 | + $this->_styleSheetFiles[$key] = $url; |
|
537 | + } else { |
|
538 | + $this->_styleSheetFiles[$key] = [$url,$media]; |
|
539 | + } |
|
528 | 540 | |
529 | 541 | $params = func_get_args(); |
530 | 542 | $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheetFile', $params); |
@@ -555,9 +567,10 @@ discard block |
||
555 | 567 | }, $this->_styleSheetFiles) |
556 | 568 | ); |
557 | 569 | |
558 | - foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path => $url) |
|
559 | - if (substr($url, strlen($url) - 4) == '.css') |
|
570 | + foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path => $url) { |
|
571 | + if (substr($url, strlen($url) - 4) == '.css') |
|
560 | 572 | $stylesheets[] = $url; |
573 | + } |
|
561 | 574 | |
562 | 575 | $stylesheets = array_unique($stylesheets); |
563 | 576 | |
@@ -751,10 +764,11 @@ discard block |
||
751 | 764 | $str = ''; |
752 | 765 | foreach($this->_styleSheetFiles as $url) |
753 | 766 | { |
754 | - if(is_array($url)) |
|
755 | - $str .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"" . THttpUtility::htmlEncode($url[0]) . "\" />\n"; |
|
756 | - else |
|
757 | - $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . THttpUtility::htmlEncode($url) . "\" />\n"; |
|
767 | + if(is_array($url)) { |
|
768 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"" . THttpUtility::htmlEncode($url[0]) . "\" />\n"; |
|
769 | + } else { |
|
770 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . THttpUtility::htmlEncode($url) . "\" />\n"; |
|
771 | + } |
|
758 | 772 | } |
759 | 773 | $writer->write($str); |
760 | 774 | } |
@@ -764,8 +778,9 @@ discard block |
||
764 | 778 | */ |
765 | 779 | public function renderStyleSheets($writer) |
766 | 780 | { |
767 | - if(count($this->_styleSheets)) |
|
768 | - $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n" . implode("\n", $this->_styleSheets) . "\n/*]]>*/\n</style>\n"); |
|
781 | + if(count($this->_styleSheets)) { |
|
782 | + $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n" . implode("\n", $this->_styleSheets) . "\n/*]]>*/\n</style>\n"); |
|
783 | + } |
|
769 | 784 | } |
770 | 785 | |
771 | 786 | /** |
@@ -893,25 +908,30 @@ discard block |
||
893 | 908 | |
894 | 909 | protected function renderHiddenFieldsInt($writer, $initial) |
895 | 910 | { |
896 | - if ($initial) $this->_renderedHiddenFields = []; |
|
911 | + if ($initial) { |
|
912 | + $this->_renderedHiddenFields = []; |
|
913 | + } |
|
897 | 914 | $str = ''; |
898 | 915 | foreach($this->_hiddenFields as $name => $value) |
899 | 916 | { |
900 | - if (in_array($name, $this->_renderedHiddenFields)) continue; |
|
917 | + if (in_array($name, $this->_renderedHiddenFields)) { |
|
918 | + continue; |
|
919 | + } |
|
901 | 920 | $id = strtr($name, ':', '_'); |
902 | 921 | if(is_array($value)) |
903 | 922 | { |
904 | - foreach($value as $v) |
|
905 | - $str .= '<input type="text" style="display:none" autocomplete="off" name="' . $name . '[]" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
906 | - } |
|
907 | - else |
|
923 | + foreach($value as $v) { |
|
924 | + $str .= '<input type="text" style="display:none" autocomplete="off" name="' . $name . '[]" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
925 | + } |
|
926 | + } else |
|
908 | 927 | { |
909 | 928 | $str .= '<input type="text" style="display:none" autocomplete="off" name="' . $name . '" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
910 | 929 | } |
911 | 930 | $this->_renderedHiddenFields[] = $name; |
912 | 931 | } |
913 | - if($str !== '') |
|
914 | - $writer->write("<div style=\"visibility:hidden;\">\n" . $str . "</div>\n"); |
|
932 | + if($str !== '') { |
|
933 | + $writer->write("<div style=\"visibility:hidden;\">\n" . $str . "</div>\n"); |
|
934 | + } |
|
915 | 935 | } |
916 | 936 | |
917 | 937 | public function getHiddenFields() |
@@ -924,7 +944,8 @@ discard block |
||
924 | 944 | */ |
925 | 945 | protected function checkIfNotInRender() |
926 | 946 | { |
927 | - if ($form = $this->_page->InFormRender) |
|
928 | - throw new \Exception('Operation invalid when page is already rendering'); |
|
947 | + if ($form = $this->_page->InFormRender) { |
|
948 | + throw new \Exception('Operation invalid when page is already rendering'); |
|
949 | + } |
|
929 | 950 | } |
930 | 951 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | */ |
44 | 44 | protected function setFunction($name, $code) |
45 | 45 | { |
46 | - if(!TJavaScript::isJsLiteral($code)) |
|
46 | + if (!TJavaScript::isJsLiteral($code)) |
|
47 | 47 | $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
48 | 48 | $this->setOption($name, $code); |
49 | 49 | } |
@@ -43,8 +43,9 @@ discard block |
||
43 | 43 | */ |
44 | 44 | protected function setFunction($name, $code) |
45 | 45 | { |
46 | - if(!TJavaScript::isJsLiteral($code)) |
|
47 | - $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
|
46 | + if(!TJavaScript::isJsLiteral($code)) { |
|
47 | + $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
|
48 | + } |
|
48 | 49 | $this->setOption($name, $code); |
49 | 50 | } |
50 | 51 | |
@@ -53,10 +54,11 @@ discard block |
||
53 | 54 | */ |
54 | 55 | protected function getOption($name) |
55 | 56 | { |
56 | - if ($this->_options) |
|
57 | - return $this->_options->itemAt($name); |
|
58 | - else |
|
59 | - return null; |
|
57 | + if ($this->_options) { |
|
58 | + return $this->_options->itemAt($name); |
|
59 | + } else { |
|
60 | + return null; |
|
61 | + } |
|
60 | 62 | } |
61 | 63 | |
62 | 64 | /** |
@@ -73,8 +75,9 @@ discard block |
||
73 | 75 | */ |
74 | 76 | public function getOptions() |
75 | 77 | { |
76 | - if (!$this->_options) |
|
77 | - $this->_options = new TMap; |
|
78 | + if (!$this->_options) { |
|
79 | + $this->_options = new TMap; |
|
80 | + } |
|
78 | 81 | return $this->_options; |
79 | 82 | } |
80 | 83 |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function createChildControls() |
45 | 45 | { |
46 | - if(null === ($_template = $this->getTemplate())) { |
|
46 | + if (null === ($_template = $this->getTemplate())) { |
|
47 | 47 | return $this->doCreateChildControlsFor(get_class($this)); |
48 | 48 | } |
49 | 49 | |
50 | - foreach($_template->getDirective() as $_name => $_value) { |
|
51 | - if(!is_string($_value)) { |
|
50 | + foreach ($_template->getDirective() as $_name => $_value) { |
|
51 | + if (!is_string($_value)) { |
|
52 | 52 | throw new TConfigurationException('templatecontrol_directive_invalid', get_class($this), $name); |
53 | 53 | } |
54 | 54 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function doCreateChildControlsFor($parentClass) |
68 | 68 | { |
69 | - if(false !== ($_parentClass = get_parent_class($parentClass)) && 'TTemplateControl' != $_parentClass) { |
|
69 | + if (false !== ($_parentClass = get_parent_class($parentClass)) && 'TTemplateControl' != $_parentClass) { |
|
70 | 70 | $this->doCreateChildControlsFor($_parentClass); |
71 | 71 | } |
72 | 72 | |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function doTemplateForClass($parentClass) |
84 | 84 | { |
85 | - if(null !== ($_template = $this->getService()->getTemplateManager()->getTemplateByClassName($parentClass))) { |
|
86 | - foreach($_template->getDirective() as $_name => $_value) { |
|
87 | - if(!is_string($_value)) { |
|
85 | + if (null !== ($_template = $this->getService()->getTemplateManager()->getTemplateByClassName($parentClass))) { |
|
86 | + foreach ($_template->getDirective() as $_name => $_value) { |
|
87 | + if (!is_string($_value)) { |
|
88 | 88 | throw new TConfigurationException('templatecontrol_directive_invalid', get_class(this), $_name); |
89 | 89 | } |
90 | 90 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getIsSourceTemplateControl() |
107 | 107 | { |
108 | - if(null !== ($_template = $this->getTemplate())) { |
|
108 | + if (null !== ($_template = $this->getTemplate())) { |
|
109 | 109 | return $_template->getIsSourceTemplate(); |
110 | 110 | } |
111 | 111 |
@@ -52,16 +52,16 @@ discard block |
||
52 | 52 | $writer->addAttribute('method', $this->getMethod()); |
53 | 53 | $uri = $this->getRequest()->getRequestURI(); |
54 | 54 | $writer->addAttribute('action', str_replace('&', '&', str_replace('&', '&', $uri))); |
55 | - if(($enctype = $this->getEnctype()) !== '') |
|
55 | + if (($enctype = $this->getEnctype()) !== '') |
|
56 | 56 | $writer->addAttribute('enctype', $enctype); |
57 | 57 | |
58 | 58 | $attributes = $this->getAttributes(); |
59 | 59 | $attributes->remove('action'); |
60 | 60 | $writer->addAttributes($attributes); |
61 | 61 | |
62 | - if(($butt = $this->getDefaultButton()) !== '') |
|
62 | + if (($butt = $this->getDefaultButton()) !== '') |
|
63 | 63 | { |
64 | - if(($button = $this->findControl($butt)) !== null) |
|
64 | + if (($button = $this->findControl($butt)) !== null) |
|
65 | 65 | $this->getPage()->getClientScript()->registerDefaultButton($this, $button); |
66 | 66 | else |
67 | 67 | throw new TInvalidDataValueException('form_defaultbutton_invalid', $butt); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $writer->renderBeginTag('form'); |
81 | 81 | |
82 | 82 | $cs = $page->getClientScript(); |
83 | - if($page->getClientSupportsJavaScript()) |
|
83 | + if ($page->getClientSupportsJavaScript()) |
|
84 | 84 | { |
85 | 85 | $cs->renderHiddenFieldsBegin($writer); |
86 | 86 | $cs->renderScriptFilesBegin($writer); |
@@ -52,8 +52,9 @@ discard block |
||
52 | 52 | $writer->addAttribute('method', $this->getMethod()); |
53 | 53 | $uri = $this->getRequest()->getRequestURI(); |
54 | 54 | $writer->addAttribute('action', str_replace('&', '&', str_replace('&', '&', $uri))); |
55 | - if(($enctype = $this->getEnctype()) !== '') |
|
56 | - $writer->addAttribute('enctype', $enctype); |
|
55 | + if(($enctype = $this->getEnctype()) !== '') { |
|
56 | + $writer->addAttribute('enctype', $enctype); |
|
57 | + } |
|
57 | 58 | |
58 | 59 | $attributes = $this->getAttributes(); |
59 | 60 | $attributes->remove('action'); |
@@ -61,10 +62,11 @@ discard block |
||
61 | 62 | |
62 | 63 | if(($butt = $this->getDefaultButton()) !== '') |
63 | 64 | { |
64 | - if(($button = $this->findControl($butt)) !== null) |
|
65 | - $this->getPage()->getClientScript()->registerDefaultButton($this, $button); |
|
66 | - else |
|
67 | - throw new TInvalidDataValueException('form_defaultbutton_invalid', $butt); |
|
65 | + if(($button = $this->findControl($butt)) !== null) { |
|
66 | + $this->getPage()->getClientScript()->registerDefaultButton($this, $button); |
|
67 | + } else { |
|
68 | + throw new TInvalidDataValueException('form_defaultbutton_invalid', $butt); |
|
69 | + } |
|
68 | 70 | } |
69 | 71 | } |
70 | 72 | |
@@ -93,8 +95,7 @@ discard block |
||
93 | 95 | |
94 | 96 | $cs->renderScriptFilesEnd($writer); |
95 | 97 | $cs->renderEndScripts($writer); |
96 | - } |
|
97 | - else |
|
98 | + } else |
|
98 | 99 | { |
99 | 100 | $cs->renderHiddenFieldsBegin($writer); |
100 | 101 |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function init($config) |
187 | 187 | { |
188 | - if($this->_serviceParameter === null) |
|
188 | + if ($this->_serviceParameter === null) |
|
189 | 189 | throw new TConfigurationException('urlmappingpattern_serviceparameter_required', $this->getPattern()); |
190 | - if(strpos($this->_serviceParameter, '*') !== false) |
|
190 | + if (strpos($this->_serviceParameter, '*') !== false) |
|
191 | 191 | $this->_isWildCardPattern = true; |
192 | 192 | } |
193 | 193 | |
@@ -202,27 +202,27 @@ discard block |
||
202 | 202 | $values = []; |
203 | 203 | if ($this->_parameters) |
204 | 204 | { |
205 | - foreach($this->_parameters as $key => $value) |
|
205 | + foreach ($this->_parameters as $key => $value) |
|
206 | 206 | { |
207 | - $params[] = '{' . $key . '}'; |
|
208 | - $values[] = '(?P<' . $key . '>' . $value . ')'; |
|
207 | + $params[] = '{'.$key.'}'; |
|
208 | + $values[] = '(?P<'.$key.'>'.$value.')'; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | if ($this->getIsWildCardPattern()) |
212 | 212 | { |
213 | 213 | $params[] = '{*}'; |
214 | 214 | // service parameter must not contain '=' and '/' |
215 | - $values[] = '(?P<' . $this->getServiceID() . '>[^=/]+)'; |
|
215 | + $values[] = '(?P<'.$this->getServiceID().'>[^=/]+)'; |
|
216 | 216 | } |
217 | 217 | $params[] = '/'; |
218 | 218 | $values[] = '\\/'; |
219 | - $regexp = str_replace($params, $values, trim($this->getPattern(), '/') . '/'); |
|
219 | + $regexp = str_replace($params, $values, trim($this->getPattern(), '/').'/'); |
|
220 | 220 | if ($this->_urlFormat === THttpRequestUrlFormat::Get) |
221 | - $regexp = '/^' . $regexp . '$/u'; |
|
221 | + $regexp = '/^'.$regexp.'$/u'; |
|
222 | 222 | else |
223 | - $regexp = '/^' . $regexp . '(?P<urlparams>.*)$/u'; |
|
223 | + $regexp = '/^'.$regexp.'(?P<urlparams>.*)$/u'; |
|
224 | 224 | |
225 | - if(!$this->getCaseSensitive()) |
|
225 | + if (!$this->getCaseSensitive()) |
|
226 | 226 | $regexp .= 'i'; |
227 | 227 | return $regexp; |
228 | 228 | } |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | public function getPatternMatches($request) |
352 | 352 | { |
353 | 353 | $matches = []; |
354 | - if(($pattern = $this->getRegularExpression()) !== '') |
|
354 | + if (($pattern = $this->getRegularExpression()) !== '') |
|
355 | 355 | preg_match($pattern, $request->getPathInfo(), $matches); |
356 | 356 | else |
357 | - preg_match($this->getParameterizedPattern(), trim($request->getPathInfo(), '/') . '/', $matches); |
|
357 | + preg_match($this->getParameterizedPattern(), trim($request->getPathInfo(), '/').'/', $matches); |
|
358 | 358 | |
359 | - if($this->getIsWildCardPattern() && isset($matches[$this->_serviceID])) |
|
359 | + if ($this->getIsWildCardPattern() && isset($matches[$this->_serviceID])) |
|
360 | 360 | $matches[$this->_serviceID] = str_replace('*', $matches[$this->_serviceID], $this->_serviceParameter); |
361 | 361 | |
362 | 362 | if (isset($matches['urlparams'])) |
@@ -364,13 +364,13 @@ discard block |
||
364 | 364 | $params = explode('/', $matches['urlparams']); |
365 | 365 | if ($this->_separator === '/') |
366 | 366 | { |
367 | - while($key = array_shift($params)) |
|
367 | + while ($key = array_shift($params)) |
|
368 | 368 | $matches[$key] = ($value = array_shift($params)) ? $value : ''; |
369 | 369 | } |
370 | 370 | else |
371 | 371 | { |
372 | 372 | array_pop($params); |
373 | - foreach($params as $param) |
|
373 | + foreach ($params as $param) |
|
374 | 374 | { |
375 | 375 | list($key, $value) = explode($this->_separator, $param, 2); |
376 | 376 | $matches[$key] = $value; |
@@ -379,9 +379,9 @@ discard block |
||
379 | 379 | unset($matches['urlparams']); |
380 | 380 | } |
381 | 381 | |
382 | - if(count($matches) > 0 && $this->_constants) |
|
382 | + if (count($matches) > 0 && $this->_constants) |
|
383 | 383 | { |
384 | - foreach($this->_constants->toArray() as $key => $value) |
|
384 | + foreach ($this->_constants->toArray() as $key => $value) |
|
385 | 385 | $matches[$key] = $value; |
386 | 386 | } |
387 | 387 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | */ |
454 | 454 | public function setUrlParamSeparator($value) |
455 | 455 | { |
456 | - if(strlen($value) === 1) |
|
456 | + if (strlen($value) === 1) |
|
457 | 457 | $this->_separator = $value; |
458 | 458 | else |
459 | 459 | throw new TInvalidDataValueException('httprequest_separator_invalid'); |
@@ -484,20 +484,20 @@ discard block |
||
484 | 484 | */ |
485 | 485 | public function supportCustomUrl($getItems) |
486 | 486 | { |
487 | - if(!$this->_customUrl || $this->getPattern() === null) |
|
487 | + if (!$this->_customUrl || $this->getPattern() === null) |
|
488 | 488 | return false; |
489 | 489 | if ($this->_parameters) |
490 | 490 | { |
491 | - foreach($this->_parameters as $key => $value) |
|
491 | + foreach ($this->_parameters as $key => $value) |
|
492 | 492 | { |
493 | - if(!isset($getItems[$key])) |
|
493 | + if (!isset($getItems[$key])) |
|
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | } |
497 | 497 | |
498 | 498 | if ($this->_constants) |
499 | 499 | { |
500 | - foreach($this->_constants->toArray() as $key => $value) |
|
500 | + foreach ($this->_constants->toArray() as $key => $value) |
|
501 | 501 | { |
502 | 502 | if (!isset($getItems[$key])) |
503 | 503 | return false; |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | { |
521 | 521 | if ($this->_constants) |
522 | 522 | { |
523 | - foreach($this->_constants->toArray() as $key => $value) |
|
523 | + foreach ($this->_constants->toArray() as $key => $value) |
|
524 | 524 | { |
525 | 525 | unset($getItems[$key]); |
526 | 526 | } |
@@ -529,55 +529,55 @@ discard block |
||
529 | 529 | $extra = []; |
530 | 530 | $replace = []; |
531 | 531 | // for the GET variables matching the pattern, put them in the URL path |
532 | - foreach($getItems as $key => $value) |
|
532 | + foreach ($getItems as $key => $value) |
|
533 | 533 | { |
534 | - if(($this->_parameters && $this->_parameters->contains($key)) || ($key === '*' && $this->getIsWildCardPattern())) |
|
535 | - $replace['{' . $key . '}'] = $encodeGetItems ? rawurlencode($value) : $value; |
|
534 | + if (($this->_parameters && $this->_parameters->contains($key)) || ($key === '*' && $this->getIsWildCardPattern())) |
|
535 | + $replace['{'.$key.'}'] = $encodeGetItems ? rawurlencode($value) : $value; |
|
536 | 536 | else |
537 | 537 | $extra[$key] = $value; |
538 | 538 | } |
539 | 539 | |
540 | - $url = $this->_manager->getUrlPrefix() . '/' . ltrim(strtr($this->getPattern(), $replace), '/'); |
|
540 | + $url = $this->_manager->getUrlPrefix().'/'.ltrim(strtr($this->getPattern(), $replace), '/'); |
|
541 | 541 | |
542 | 542 | // for the rest of the GET variables, put them in the query string |
543 | - if(count($extra) > 0) |
|
543 | + if (count($extra) > 0) |
|
544 | 544 | { |
545 | 545 | if ($this->_urlFormat === THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { |
546 | 546 | foreach ($extra as $name => $value) |
547 | - $url .= '/' . $name . $this->_separator . ($encodeGetItems?rawurlencode($value):$value); |
|
547 | + $url .= '/'.$name.$this->_separator.($encodeGetItems ?rawurlencode($value) : $value); |
|
548 | 548 | return $url; |
549 | 549 | } |
550 | 550 | |
551 | 551 | $url2 = ''; |
552 | - $amp = $encodeAmpersand?'&':'&'; |
|
553 | - if($encodeGetItems) |
|
552 | + $amp = $encodeAmpersand ? '&' : '&'; |
|
553 | + if ($encodeGetItems) |
|
554 | 554 | { |
555 | - foreach($extra as $name => $value) |
|
555 | + foreach ($extra as $name => $value) |
|
556 | 556 | { |
557 | - if(is_array($value)) |
|
557 | + if (is_array($value)) |
|
558 | 558 | { |
559 | - $name = rawurlencode($name . '[]'); |
|
560 | - foreach($value as $v) |
|
561 | - $url2 .= $amp . $name . '=' . rawurlencode($v); |
|
559 | + $name = rawurlencode($name.'[]'); |
|
560 | + foreach ($value as $v) |
|
561 | + $url2 .= $amp.$name.'='.rawurlencode($v); |
|
562 | 562 | } |
563 | 563 | else |
564 | - $url2 .= $amp . rawurlencode($name) . '=' . rawurlencode($value); |
|
564 | + $url2 .= $amp.rawurlencode($name).'='.rawurlencode($value); |
|
565 | 565 | } |
566 | 566 | } |
567 | 567 | else |
568 | 568 | { |
569 | - foreach($extra as $name => $value) |
|
569 | + foreach ($extra as $name => $value) |
|
570 | 570 | { |
571 | - if(is_array($value)) |
|
571 | + if (is_array($value)) |
|
572 | 572 | { |
573 | - foreach($value as $v) |
|
574 | - $url2 .= $amp . $name . '[]=' . $v; |
|
573 | + foreach ($value as $v) |
|
574 | + $url2 .= $amp.$name.'[]='.$v; |
|
575 | 575 | } |
576 | 576 | else |
577 | - $url2 .= $amp . $name . '=' . $value; |
|
577 | + $url2 .= $amp.$name.'='.$value; |
|
578 | 578 | } |
579 | 579 | } |
580 | - $url = $url . '?' . substr($url2, strlen($amp)); |
|
580 | + $url = $url.'?'.substr($url2, strlen($amp)); |
|
581 | 581 | } |
582 | 582 | return $this -> applySecureConnectionPrefix($url); |
583 | 583 | } |
@@ -593,26 +593,26 @@ discard block |
||
593 | 593 | protected function applySecureConnectionPrefix($url) |
594 | 594 | { |
595 | 595 | static $request; |
596 | - if($request === null) $request = Prado::getApplication() -> getRequest(); |
|
596 | + if ($request === null) $request = Prado::getApplication() -> getRequest(); |
|
597 | 597 | |
598 | 598 | static $isSecureConnection; |
599 | - if($isSecureConnection === null) $isSecureConnection = $request -> getIsSecureConnection(); |
|
599 | + if ($isSecureConnection === null) $isSecureConnection = $request -> getIsSecureConnection(); |
|
600 | 600 | |
601 | - switch($this -> getSecureConnection()) |
|
601 | + switch ($this -> getSecureConnection()) |
|
602 | 602 | { |
603 | 603 | case TUrlMappingPatternSecureConnection::EnableIfNotSecure: |
604 | - if($isSecureConnection) return $url; |
|
605 | - return $request -> getBaseUrl(true) . $url; |
|
604 | + if ($isSecureConnection) return $url; |
|
605 | + return $request -> getBaseUrl(true).$url; |
|
606 | 606 | break; |
607 | 607 | case TUrlMappingPatternSecureConnection::DisableIfSecure: |
608 | - if(!$isSecureConnection) return $url; |
|
609 | - return $request -> getBaseUrl(false) . $url; |
|
608 | + if (!$isSecureConnection) return $url; |
|
609 | + return $request -> getBaseUrl(false).$url; |
|
610 | 610 | break; |
611 | 611 | case TUrlMappingPatternSecureConnection::Enable: |
612 | - return $request -> getBaseUrl(true) . $url; |
|
612 | + return $request -> getBaseUrl(true).$url; |
|
613 | 613 | break; |
614 | 614 | case TUrlMappingPatternSecureConnection::Disable: |
615 | - return $request -> getBaseUrl(false) . $url; |
|
615 | + return $request -> getBaseUrl(false).$url; |
|
616 | 616 | break; |
617 | 617 | case TUrlMappingPatternSecureConnection::Automatic: |
618 | 618 | default: |
@@ -185,10 +185,12 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function init($config) |
187 | 187 | { |
188 | - if($this->_serviceParameter === null) |
|
189 | - throw new TConfigurationException('urlmappingpattern_serviceparameter_required', $this->getPattern()); |
|
190 | - if(strpos($this->_serviceParameter, '*') !== false) |
|
191 | - $this->_isWildCardPattern = true; |
|
188 | + if($this->_serviceParameter === null) { |
|
189 | + throw new TConfigurationException('urlmappingpattern_serviceparameter_required', $this->getPattern()); |
|
190 | + } |
|
191 | + if(strpos($this->_serviceParameter, '*') !== false) { |
|
192 | + $this->_isWildCardPattern = true; |
|
193 | + } |
|
192 | 194 | } |
193 | 195 | |
194 | 196 | /** |
@@ -217,13 +219,15 @@ discard block |
||
217 | 219 | $params[] = '/'; |
218 | 220 | $values[] = '\\/'; |
219 | 221 | $regexp = str_replace($params, $values, trim($this->getPattern(), '/') . '/'); |
220 | - if ($this->_urlFormat === THttpRequestUrlFormat::Get) |
|
221 | - $regexp = '/^' . $regexp . '$/u'; |
|
222 | - else |
|
223 | - $regexp = '/^' . $regexp . '(?P<urlparams>.*)$/u'; |
|
222 | + if ($this->_urlFormat === THttpRequestUrlFormat::Get) { |
|
223 | + $regexp = '/^' . $regexp . '$/u'; |
|
224 | + } else { |
|
225 | + $regexp = '/^' . $regexp . '(?P<urlparams>.*)$/u'; |
|
226 | + } |
|
224 | 227 | |
225 | - if(!$this->getCaseSensitive()) |
|
226 | - $regexp .= 'i'; |
|
228 | + if(!$this->getCaseSensitive()) { |
|
229 | + $regexp .= 'i'; |
|
230 | + } |
|
227 | 231 | return $regexp; |
228 | 232 | } |
229 | 233 | |
@@ -351,23 +355,25 @@ discard block |
||
351 | 355 | public function getPatternMatches($request) |
352 | 356 | { |
353 | 357 | $matches = []; |
354 | - if(($pattern = $this->getRegularExpression()) !== '') |
|
355 | - preg_match($pattern, $request->getPathInfo(), $matches); |
|
356 | - else |
|
357 | - preg_match($this->getParameterizedPattern(), trim($request->getPathInfo(), '/') . '/', $matches); |
|
358 | + if(($pattern = $this->getRegularExpression()) !== '') { |
|
359 | + preg_match($pattern, $request->getPathInfo(), $matches); |
|
360 | + } else { |
|
361 | + preg_match($this->getParameterizedPattern(), trim($request->getPathInfo(), '/') . '/', $matches); |
|
362 | + } |
|
358 | 363 | |
359 | - if($this->getIsWildCardPattern() && isset($matches[$this->_serviceID])) |
|
360 | - $matches[$this->_serviceID] = str_replace('*', $matches[$this->_serviceID], $this->_serviceParameter); |
|
364 | + if($this->getIsWildCardPattern() && isset($matches[$this->_serviceID])) { |
|
365 | + $matches[$this->_serviceID] = str_replace('*', $matches[$this->_serviceID], $this->_serviceParameter); |
|
366 | + } |
|
361 | 367 | |
362 | 368 | if (isset($matches['urlparams'])) |
363 | 369 | { |
364 | 370 | $params = explode('/', $matches['urlparams']); |
365 | 371 | if ($this->_separator === '/') |
366 | 372 | { |
367 | - while($key = array_shift($params)) |
|
368 | - $matches[$key] = ($value = array_shift($params)) ? $value : ''; |
|
369 | - } |
|
370 | - else |
|
373 | + while($key = array_shift($params)) { |
|
374 | + $matches[$key] = ($value = array_shift($params)) ? $value : ''; |
|
375 | + } |
|
376 | + } else |
|
371 | 377 | { |
372 | 378 | array_pop($params); |
373 | 379 | foreach($params as $param) |
@@ -381,8 +387,9 @@ discard block |
||
381 | 387 | |
382 | 388 | if(count($matches) > 0 && $this->_constants) |
383 | 389 | { |
384 | - foreach($this->_constants->toArray() as $key => $value) |
|
385 | - $matches[$key] = $value; |
|
390 | + foreach($this->_constants->toArray() as $key => $value) { |
|
391 | + $matches[$key] = $value; |
|
392 | + } |
|
386 | 393 | } |
387 | 394 | |
388 | 395 | return $matches; |
@@ -453,10 +460,11 @@ discard block |
||
453 | 460 | */ |
454 | 461 | public function setUrlParamSeparator($value) |
455 | 462 | { |
456 | - if(strlen($value) === 1) |
|
457 | - $this->_separator = $value; |
|
458 | - else |
|
459 | - throw new TInvalidDataValueException('httprequest_separator_invalid'); |
|
463 | + if(strlen($value) === 1) { |
|
464 | + $this->_separator = $value; |
|
465 | + } else { |
|
466 | + throw new TInvalidDataValueException('httprequest_separator_invalid'); |
|
467 | + } |
|
460 | 468 | } |
461 | 469 | |
462 | 470 | /** |
@@ -484,14 +492,16 @@ discard block |
||
484 | 492 | */ |
485 | 493 | public function supportCustomUrl($getItems) |
486 | 494 | { |
487 | - if(!$this->_customUrl || $this->getPattern() === null) |
|
488 | - return false; |
|
495 | + if(!$this->_customUrl || $this->getPattern() === null) { |
|
496 | + return false; |
|
497 | + } |
|
489 | 498 | if ($this->_parameters) |
490 | 499 | { |
491 | 500 | foreach($this->_parameters as $key => $value) |
492 | 501 | { |
493 | - if(!isset($getItems[$key])) |
|
494 | - return false; |
|
502 | + if(!isset($getItems[$key])) { |
|
503 | + return false; |
|
504 | + } |
|
495 | 505 | } |
496 | 506 | } |
497 | 507 | |
@@ -499,10 +509,12 @@ discard block |
||
499 | 509 | { |
500 | 510 | foreach($this->_constants->toArray() as $key => $value) |
501 | 511 | { |
502 | - if (!isset($getItems[$key])) |
|
503 | - return false; |
|
504 | - if ($getItems[$key] != $value) |
|
505 | - return false; |
|
512 | + if (!isset($getItems[$key])) { |
|
513 | + return false; |
|
514 | + } |
|
515 | + if ($getItems[$key] != $value) { |
|
516 | + return false; |
|
517 | + } |
|
506 | 518 | } |
507 | 519 | } |
508 | 520 | return true; |
@@ -531,10 +543,11 @@ discard block |
||
531 | 543 | // for the GET variables matching the pattern, put them in the URL path |
532 | 544 | foreach($getItems as $key => $value) |
533 | 545 | { |
534 | - if(($this->_parameters && $this->_parameters->contains($key)) || ($key === '*' && $this->getIsWildCardPattern())) |
|
535 | - $replace['{' . $key . '}'] = $encodeGetItems ? rawurlencode($value) : $value; |
|
536 | - else |
|
537 | - $extra[$key] = $value; |
|
546 | + if(($this->_parameters && $this->_parameters->contains($key)) || ($key === '*' && $this->getIsWildCardPattern())) { |
|
547 | + $replace['{' . $key . '}'] = $encodeGetItems ? rawurlencode($value) : $value; |
|
548 | + } else { |
|
549 | + $extra[$key] = $value; |
|
550 | + } |
|
538 | 551 | } |
539 | 552 | |
540 | 553 | $url = $this->_manager->getUrlPrefix() . '/' . ltrim(strtr($this->getPattern(), $replace), '/'); |
@@ -543,8 +556,9 @@ discard block |
||
543 | 556 | if(count($extra) > 0) |
544 | 557 | { |
545 | 558 | if ($this->_urlFormat === THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { |
546 | - foreach ($extra as $name => $value) |
|
547 | - $url .= '/' . $name . $this->_separator . ($encodeGetItems?rawurlencode($value):$value); |
|
559 | + foreach ($extra as $name => $value) { |
|
560 | + $url .= '/' . $name . $this->_separator . ($encodeGetItems?rawurlencode($value):$value); |
|
561 | + } |
|
548 | 562 | return $url; |
549 | 563 | } |
550 | 564 | |
@@ -557,24 +571,25 @@ discard block |
||
557 | 571 | if(is_array($value)) |
558 | 572 | { |
559 | 573 | $name = rawurlencode($name . '[]'); |
560 | - foreach($value as $v) |
|
561 | - $url2 .= $amp . $name . '=' . rawurlencode($v); |
|
574 | + foreach($value as $v) { |
|
575 | + $url2 .= $amp . $name . '=' . rawurlencode($v); |
|
576 | + } |
|
577 | + } else { |
|
578 | + $url2 .= $amp . rawurlencode($name) . '=' . rawurlencode($value); |
|
562 | 579 | } |
563 | - else |
|
564 | - $url2 .= $amp . rawurlencode($name) . '=' . rawurlencode($value); |
|
565 | 580 | } |
566 | - } |
|
567 | - else |
|
581 | + } else |
|
568 | 582 | { |
569 | 583 | foreach($extra as $name => $value) |
570 | 584 | { |
571 | 585 | if(is_array($value)) |
572 | 586 | { |
573 | - foreach($value as $v) |
|
574 | - $url2 .= $amp . $name . '[]=' . $v; |
|
587 | + foreach($value as $v) { |
|
588 | + $url2 .= $amp . $name . '[]=' . $v; |
|
589 | + } |
|
590 | + } else { |
|
591 | + $url2 .= $amp . $name . '=' . $value; |
|
575 | 592 | } |
576 | - else |
|
577 | - $url2 .= $amp . $name . '=' . $value; |
|
578 | 593 | } |
579 | 594 | } |
580 | 595 | $url = $url . '?' . substr($url2, strlen($amp)); |
@@ -593,19 +608,27 @@ discard block |
||
593 | 608 | protected function applySecureConnectionPrefix($url) |
594 | 609 | { |
595 | 610 | static $request; |
596 | - if($request === null) $request = Prado::getApplication() -> getRequest(); |
|
611 | + if($request === null) { |
|
612 | + $request = Prado::getApplication() -> getRequest(); |
|
613 | + } |
|
597 | 614 | |
598 | 615 | static $isSecureConnection; |
599 | - if($isSecureConnection === null) $isSecureConnection = $request -> getIsSecureConnection(); |
|
616 | + if($isSecureConnection === null) { |
|
617 | + $isSecureConnection = $request -> getIsSecureConnection(); |
|
618 | + } |
|
600 | 619 | |
601 | 620 | switch($this -> getSecureConnection()) |
602 | 621 | { |
603 | 622 | case TUrlMappingPatternSecureConnection::EnableIfNotSecure: |
604 | - if($isSecureConnection) return $url; |
|
623 | + if($isSecureConnection) { |
|
624 | + return $url; |
|
625 | + } |
|
605 | 626 | return $request -> getBaseUrl(true) . $url; |
606 | 627 | break; |
607 | 628 | case TUrlMappingPatternSecureConnection::DisableIfSecure: |
608 | - if(!$isSecureConnection) return $url; |
|
629 | + if(!$isSecureConnection) { |
|
630 | + return $url; |
|
631 | + } |
|
609 | 632 | return $request -> getBaseUrl(false) . $url; |
610 | 633 | break; |
611 | 634 | case TUrlMappingPatternSecureConnection::Enable: |
@@ -107,15 +107,15 @@ discard block |
||
107 | 107 | public function init($config) |
108 | 108 | { |
109 | 109 | parent::init($config); |
110 | - if($this->getRequest()->getRequestResolved()) |
|
110 | + if ($this->getRequest()->getRequestResolved()) |
|
111 | 111 | throw new TConfigurationException('urlmapping_global_required'); |
112 | - if($this->_configFile !== null) |
|
112 | + if ($this->_configFile !== null) |
|
113 | 113 | $this->loadConfigFile(); |
114 | 114 | $this->loadUrlMappings($config); |
115 | - if($this->_urlPrefix === '') |
|
115 | + if ($this->_urlPrefix === '') |
|
116 | 116 | { |
117 | 117 | $request = $this->getRequest(); |
118 | - if($request->getUrlFormat() === THttpRequestUrlFormat::HiddenPath) |
|
118 | + if ($request->getUrlFormat() === THttpRequestUrlFormat::HiddenPath) |
|
119 | 119 | { |
120 | 120 | $this->_urlPrefix = dirname($request->getApplicationUrl()); |
121 | 121 | } else { |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | */ |
132 | 132 | protected function loadConfigFile() |
133 | 133 | { |
134 | - if(is_file($this->_configFile)) |
|
134 | + if (is_file($this->_configFile)) |
|
135 | 135 | { |
136 | - if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
136 | + if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
137 | 137 | { |
138 | 138 | $config = include $this->_configFile; |
139 | 139 | $this->loadUrlMappings($dom); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function setConfigFile($value) |
209 | 209 | { |
210 | - if(($this->_configFile = Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt())) === null) |
|
210 | + if (($this->_configFile = Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt())) === null) |
|
211 | 211 | throw new TConfigurationException('urlmapping_configfile_invalid', $value); |
212 | 212 | } |
213 | 213 | |
@@ -241,24 +241,24 @@ discard block |
||
241 | 241 | { |
242 | 242 | $defaultClass = $this->getDefaultMappingClass(); |
243 | 243 | |
244 | - if(is_array($config)) |
|
244 | + if (is_array($config)) |
|
245 | 245 | { |
246 | - if(isset($config['urls']) && is_array($config['urls'])) |
|
246 | + if (isset($config['urls']) && is_array($config['urls'])) |
|
247 | 247 | { |
248 | - foreach($config['urls'] as $url) |
|
248 | + foreach ($config['urls'] as $url) |
|
249 | 249 | { |
250 | - $class = isset($url['class'])?$url['class']:$defaultClass; |
|
251 | - $properties = isset($url['properties'])?$url['properties']:[]; |
|
250 | + $class = isset($url['class']) ? $url['class'] : $defaultClass; |
|
251 | + $properties = isset($url['properties']) ? $url['properties'] : []; |
|
252 | 252 | $this->buildUrlMapping($class, $properties, $url); |
253 | 253 | } |
254 | 254 | } |
255 | 255 | } |
256 | 256 | else |
257 | 257 | { |
258 | - foreach($config->getElementsByTagName('url') as $url) |
|
258 | + foreach ($config->getElementsByTagName('url') as $url) |
|
259 | 259 | { |
260 | 260 | $properties = $url->getAttributes(); |
261 | - if(($class = $properties->remove('class')) === null) |
|
261 | + if (($class = $properties->remove('class')) === null) |
|
262 | 262 | $class = $defaultClass; |
263 | 263 | $this->buildUrlMapping($class, $properties, $url); |
264 | 264 | } |
@@ -268,16 +268,16 @@ discard block |
||
268 | 268 | private function buildUrlMapping($class, $properties, $url) |
269 | 269 | { |
270 | 270 | $pattern = Prado::createComponent($class, $this); |
271 | - if(!($pattern instanceof TUrlMappingPattern)) |
|
271 | + if (!($pattern instanceof TUrlMappingPattern)) |
|
272 | 272 | throw new TConfigurationException('urlmapping_urlmappingpattern_required'); |
273 | - foreach($properties as $name => $value) |
|
273 | + foreach ($properties as $name => $value) |
|
274 | 274 | $pattern->setSubproperty($name, $value); |
275 | 275 | |
276 | - if($url instanceof TXmlElement) { |
|
276 | + if ($url instanceof TXmlElement) { |
|
277 | 277 | $text = $url -> getValue(); |
278 | - if($text) { |
|
278 | + if ($text) { |
|
279 | 279 | $text = preg_replace('/(\s+)/S', '', $text); |
280 | - if(($regExp = $pattern->getRegularExpression()) !== '') |
|
280 | + if (($regExp = $pattern->getRegularExpression()) !== '') |
|
281 | 281 | trigger_error(sPrintF('%s.RegularExpression property value "%s" for ServiceID="%s" and ServiceParameter="%s" was replaced by node value "%s"', |
282 | 282 | get_class($pattern), |
283 | 283 | $regExp, |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | $this->_patterns[] = $pattern; |
293 | 293 | $pattern->init($url); |
294 | 294 | |
295 | - $key = $pattern->getServiceID() . ':' . $pattern->getServiceParameter(); |
|
295 | + $key = $pattern->getServiceID().':'.$pattern->getServiceParameter(); |
|
296 | 296 | $this->_constructRules[$key][] = $pattern; |
297 | 297 | } |
298 | 298 | |
@@ -307,16 +307,16 @@ discard block |
||
307 | 307 | public function parseUrl() |
308 | 308 | { |
309 | 309 | $request = $this->getRequest(); |
310 | - foreach($this->_patterns as $pattern) |
|
310 | + foreach ($this->_patterns as $pattern) |
|
311 | 311 | { |
312 | 312 | $matches = $pattern->getPatternMatches($request); |
313 | - if(count($matches) > 0) |
|
313 | + if (count($matches) > 0) |
|
314 | 314 | { |
315 | 315 | $this->_matched = $pattern; |
316 | 316 | $params = []; |
317 | - foreach($matches as $key => $value) |
|
317 | + foreach ($matches as $key => $value) |
|
318 | 318 | { |
319 | - if(is_string($key)) |
|
319 | + if (is_string($key)) |
|
320 | 320 | $params[$key] = $value; |
321 | 321 | } |
322 | 322 | if (!$pattern->getIsWildCardPattern()) |
@@ -353,26 +353,26 @@ discard block |
||
353 | 353 | */ |
354 | 354 | public function constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems) |
355 | 355 | { |
356 | - if($this->_customUrl) |
|
356 | + if ($this->_customUrl) |
|
357 | 357 | { |
358 | - if(!(is_array($getItems) || ($getItems instanceof \Traversable))) |
|
358 | + if (!(is_array($getItems) || ($getItems instanceof \Traversable))) |
|
359 | 359 | $getItems = []; |
360 | - $key = $serviceID . ':' . $serviceParam; |
|
360 | + $key = $serviceID.':'.$serviceParam; |
|
361 | 361 | $wildCardKey = ($pos = strrpos($serviceParam, '.')) !== false ? |
362 | - $serviceID . ':' . substr($serviceParam, 0, $pos) . '.*' : $serviceID . ':*'; |
|
363 | - if(isset($this->_constructRules[$key])) |
|
362 | + $serviceID.':'.substr($serviceParam, 0, $pos).'.*' : $serviceID.':*'; |
|
363 | + if (isset($this->_constructRules[$key])) |
|
364 | 364 | { |
365 | - foreach($this->_constructRules[$key] as $rule) |
|
365 | + foreach ($this->_constructRules[$key] as $rule) |
|
366 | 366 | { |
367 | - if($rule->supportCustomUrl($getItems)) |
|
367 | + if ($rule->supportCustomUrl($getItems)) |
|
368 | 368 | return $rule->constructUrl($getItems, $encodeAmpersand, $encodeGetItems); |
369 | 369 | } |
370 | 370 | } |
371 | - elseif(isset($this->_constructRules[$wildCardKey])) |
|
371 | + elseif (isset($this->_constructRules[$wildCardKey])) |
|
372 | 372 | { |
373 | - foreach($this->_constructRules[$wildCardKey] as $rule) |
|
373 | + foreach ($this->_constructRules[$wildCardKey] as $rule) |
|
374 | 374 | { |
375 | - if($rule->supportCustomUrl($getItems)) |
|
375 | + if ($rule->supportCustomUrl($getItems)) |
|
376 | 376 | { |
377 | 377 | $getItems['*'] = $pos ? substr($serviceParam, $pos + 1) : $serviceParam; |
378 | 378 | return $rule->constructUrl($getItems, $encodeAmpersand, $encodeGetItems); |
@@ -107,10 +107,12 @@ discard block |
||
107 | 107 | public function init($config) |
108 | 108 | { |
109 | 109 | parent::init($config); |
110 | - if($this->getRequest()->getRequestResolved()) |
|
111 | - throw new TConfigurationException('urlmapping_global_required'); |
|
112 | - if($this->_configFile !== null) |
|
113 | - $this->loadConfigFile(); |
|
110 | + if($this->getRequest()->getRequestResolved()) { |
|
111 | + throw new TConfigurationException('urlmapping_global_required'); |
|
112 | + } |
|
113 | + if($this->_configFile !== null) { |
|
114 | + $this->loadConfigFile(); |
|
115 | + } |
|
114 | 116 | $this->loadUrlMappings($config); |
115 | 117 | if($this->_urlPrefix === '') |
116 | 118 | { |
@@ -137,16 +139,15 @@ discard block |
||
137 | 139 | { |
138 | 140 | $config = include $this->_configFile; |
139 | 141 | $this->loadUrlMappings($dom); |
140 | - } |
|
141 | - else |
|
142 | + } else |
|
142 | 143 | { |
143 | 144 | $dom = new TXmlDocument; |
144 | 145 | $dom->loadFromFile($this->_configFile); |
145 | 146 | $this->loadUrlMappings($dom); |
146 | 147 | } |
148 | + } else { |
|
149 | + throw new TConfigurationException('urlmapping_configfile_inexistent', $this->_configFile); |
|
147 | 150 | } |
148 | - else |
|
149 | - throw new TConfigurationException('urlmapping_configfile_inexistent', $this->_configFile); |
|
150 | 151 | } |
151 | 152 | |
152 | 153 | /** |
@@ -207,8 +208,9 @@ discard block |
||
207 | 208 | */ |
208 | 209 | public function setConfigFile($value) |
209 | 210 | { |
210 | - if(($this->_configFile = Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt())) === null) |
|
211 | - throw new TConfigurationException('urlmapping_configfile_invalid', $value); |
|
211 | + if(($this->_configFile = Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt())) === null) { |
|
212 | + throw new TConfigurationException('urlmapping_configfile_invalid', $value); |
|
213 | + } |
|
212 | 214 | } |
213 | 215 | |
214 | 216 | /** |
@@ -252,14 +254,14 @@ discard block |
||
252 | 254 | $this->buildUrlMapping($class, $properties, $url); |
253 | 255 | } |
254 | 256 | } |
255 | - } |
|
256 | - else |
|
257 | + } else |
|
257 | 258 | { |
258 | 259 | foreach($config->getElementsByTagName('url') as $url) |
259 | 260 | { |
260 | 261 | $properties = $url->getAttributes(); |
261 | - if(($class = $properties->remove('class')) === null) |
|
262 | - $class = $defaultClass; |
|
262 | + if(($class = $properties->remove('class')) === null) { |
|
263 | + $class = $defaultClass; |
|
264 | + } |
|
263 | 265 | $this->buildUrlMapping($class, $properties, $url); |
264 | 266 | } |
265 | 267 | } |
@@ -268,23 +270,26 @@ discard block |
||
268 | 270 | private function buildUrlMapping($class, $properties, $url) |
269 | 271 | { |
270 | 272 | $pattern = Prado::createComponent($class, $this); |
271 | - if(!($pattern instanceof TUrlMappingPattern)) |
|
272 | - throw new TConfigurationException('urlmapping_urlmappingpattern_required'); |
|
273 | - foreach($properties as $name => $value) |
|
274 | - $pattern->setSubproperty($name, $value); |
|
273 | + if(!($pattern instanceof TUrlMappingPattern)) { |
|
274 | + throw new TConfigurationException('urlmapping_urlmappingpattern_required'); |
|
275 | + } |
|
276 | + foreach($properties as $name => $value) { |
|
277 | + $pattern->setSubproperty($name, $value); |
|
278 | + } |
|
275 | 279 | |
276 | 280 | if($url instanceof TXmlElement) { |
277 | 281 | $text = $url -> getValue(); |
278 | 282 | if($text) { |
279 | 283 | $text = preg_replace('/(\s+)/S', '', $text); |
280 | - if(($regExp = $pattern->getRegularExpression()) !== '') |
|
281 | - trigger_error(sPrintF('%s.RegularExpression property value "%s" for ServiceID="%s" and ServiceParameter="%s" was replaced by node value "%s"', |
|
284 | + if(($regExp = $pattern->getRegularExpression()) !== '') { |
|
285 | + trigger_error(sPrintF('%s.RegularExpression property value "%s" for ServiceID="%s" and ServiceParameter="%s" was replaced by node value "%s"', |
|
282 | 286 | get_class($pattern), |
283 | 287 | $regExp, |
284 | 288 | $pattern->getServiceID(), |
285 | 289 | $pattern->getServiceParameter(), |
286 | 290 | $text), |
287 | 291 | E_USER_NOTICE); |
292 | + } |
|
288 | 293 | $pattern->setRegularExpression($text); |
289 | 294 | } |
290 | 295 | } |
@@ -316,11 +321,13 @@ discard block |
||
316 | 321 | $params = []; |
317 | 322 | foreach($matches as $key => $value) |
318 | 323 | { |
319 | - if(is_string($key)) |
|
320 | - $params[$key] = $value; |
|
324 | + if(is_string($key)) { |
|
325 | + $params[$key] = $value; |
|
326 | + } |
|
327 | + } |
|
328 | + if (!$pattern->getIsWildCardPattern()) { |
|
329 | + $params[$pattern->getServiceID()] = $pattern->getServiceParameter(); |
|
321 | 330 | } |
322 | - if (!$pattern->getIsWildCardPattern()) |
|
323 | - $params[$pattern->getServiceID()] = $pattern->getServiceParameter(); |
|
324 | 331 | return $params; |
325 | 332 | } |
326 | 333 | } |
@@ -355,8 +362,9 @@ discard block |
||
355 | 362 | { |
356 | 363 | if($this->_customUrl) |
357 | 364 | { |
358 | - if(!(is_array($getItems) || ($getItems instanceof \Traversable))) |
|
359 | - $getItems = []; |
|
365 | + if(!(is_array($getItems) || ($getItems instanceof \Traversable))) { |
|
366 | + $getItems = []; |
|
367 | + } |
|
360 | 368 | $key = $serviceID . ':' . $serviceParam; |
361 | 369 | $wildCardKey = ($pos = strrpos($serviceParam, '.')) !== false ? |
362 | 370 | $serviceID . ':' . substr($serviceParam, 0, $pos) . '.*' : $serviceID . ':*'; |
@@ -364,11 +372,11 @@ discard block |
||
364 | 372 | { |
365 | 373 | foreach($this->_constructRules[$key] as $rule) |
366 | 374 | { |
367 | - if($rule->supportCustomUrl($getItems)) |
|
368 | - return $rule->constructUrl($getItems, $encodeAmpersand, $encodeGetItems); |
|
375 | + if($rule->supportCustomUrl($getItems)) { |
|
376 | + return $rule->constructUrl($getItems, $encodeAmpersand, $encodeGetItems); |
|
377 | + } |
|
369 | 378 | } |
370 | - } |
|
371 | - elseif(isset($this->_constructRules[$wildCardKey])) |
|
379 | + } elseif(isset($this->_constructRules[$wildCardKey])) |
|
372 | 380 | { |
373 | 381 | foreach($this->_constructRules[$wildCardKey] as $rule) |
374 | 382 | { |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | public function init($config) |
163 | 163 | { |
164 | 164 | // Fill in default request info when the script is run in command line |
165 | - if(php_sapi_name() === 'cli') |
|
165 | + if (php_sapi_name() === 'cli') |
|
166 | 166 | { |
167 | 167 | $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; |
168 | 168 | $_SERVER['REQUEST_METHOD'] = 'GET'; |
@@ -177,29 +177,29 @@ discard block |
||
177 | 177 | // QUERY_STRING is the string following the '?' in the ur (eg the a=x part in http://foo/bar?a=x) |
178 | 178 | // REQUEST_URI contains the URI part entered in the browser address bar |
179 | 179 | // SCRIPT_FILENAME is the file path to the executing script |
180 | - if(isset($_SERVER['REQUEST_URI'])) |
|
180 | + if (isset($_SERVER['REQUEST_URI'])) |
|
181 | 181 | $this->_requestUri = $_SERVER['REQUEST_URI']; |
182 | 182 | else // TBD: in this case, SCRIPT_NAME need to be escaped |
183 | - $this->_requestUri = $_SERVER['SCRIPT_NAME'] . (empty($_SERVER['QUERY_STRING'])?'':'?' . $_SERVER['QUERY_STRING']); |
|
183 | + $this->_requestUri = $_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING']) ? '' : '?'.$_SERVER['QUERY_STRING']); |
|
184 | 184 | |
185 | - if($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
185 | + if ($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
186 | 186 | $this->_pathInfo = substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME'])); |
187 | - elseif(isset($_SERVER['PATH_INFO'])) |
|
187 | + elseif (isset($_SERVER['PATH_INFO'])) |
|
188 | 188 | $this->_pathInfo = $_SERVER['PATH_INFO']; |
189 | - elseif(strpos($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME']) === 0 && $_SERVER['PHP_SELF'] !== $_SERVER['SCRIPT_NAME']) |
|
189 | + elseif (strpos($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME']) === 0 && $_SERVER['PHP_SELF'] !== $_SERVER['SCRIPT_NAME']) |
|
190 | 190 | $this->_pathInfo = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])); |
191 | 191 | else |
192 | 192 | $this->_pathInfo = ''; |
193 | 193 | |
194 | - if(get_magic_quotes_gpc()) |
|
194 | + if (get_magic_quotes_gpc()) |
|
195 | 195 | { |
196 | - if(isset($_GET)) |
|
196 | + if (isset($_GET)) |
|
197 | 197 | $_GET = $this->stripSlashes($_GET); |
198 | - if(isset($_POST)) |
|
198 | + if (isset($_POST)) |
|
199 | 199 | $_POST = $this->stripSlashes($_POST); |
200 | - if(isset($_REQUEST)) |
|
200 | + if (isset($_REQUEST)) |
|
201 | 201 | $_REQUEST = $this->stripSlashes($_REQUEST); |
202 | - if(isset($_COOKIE)) |
|
202 | + if (isset($_COOKIE)) |
|
203 | 203 | $_COOKIE = $this->stripSlashes($_COOKIE); |
204 | 204 | } |
205 | 205 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function stripSlashes(&$data) |
216 | 216 | { |
217 | - return is_array($data)?array_map([$this,'stripSlashes'], $data):stripslashes($data); |
|
217 | + return is_array($data) ?array_map([$this, 'stripSlashes'], $data) : stripslashes($data); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function getUrl() |
224 | 224 | { |
225 | - if($this->_url === null) |
|
225 | + if ($this->_url === null) |
|
226 | 226 | { |
227 | 227 | $secure = $this->getIsSecureConnection(); |
228 | - $url = $secure?'https://':'http://'; |
|
229 | - if(empty($_SERVER['HTTP_HOST'])) |
|
228 | + $url = $secure ? 'https://' : 'http://'; |
|
229 | + if (empty($_SERVER['HTTP_HOST'])) |
|
230 | 230 | { |
231 | 231 | $url .= $_SERVER['SERVER_NAME']; |
232 | 232 | $port = $_SERVER['SERVER_PORT']; |
233 | - if(($port != 80 && !$secure) || ($port != 443 && $secure)) |
|
234 | - $url .= ':' . $port; |
|
233 | + if (($port != 80 && !$secure) || ($port != 443 && $secure)) |
|
234 | + $url .= ':'.$port; |
|
235 | 235 | } |
236 | 236 | else |
237 | 237 | $url .= $_SERVER['HTTP_HOST']; |
@@ -270,13 +270,13 @@ discard block |
||
270 | 270 | */ |
271 | 271 | protected function cacheUrlManager($manager) |
272 | 272 | { |
273 | - if($this->getEnableCache()) |
|
273 | + if ($this->getEnableCache()) |
|
274 | 274 | { |
275 | 275 | $cache = $this->getApplication()->getCache(); |
276 | - if($cache !== null) |
|
276 | + if ($cache !== null) |
|
277 | 277 | { |
278 | 278 | $dependencies = null; |
279 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
279 | + if ($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
280 | 280 | if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
281 | 281 | { |
282 | 282 | $fn = Prado::getPathOfNamespace($fn, $this->getApplication()->getConfigurationFileExt()); |
@@ -294,13 +294,13 @@ discard block |
||
294 | 294 | */ |
295 | 295 | protected function loadCachedUrlManager() |
296 | 296 | { |
297 | - if($this->getEnableCache()) |
|
297 | + if ($this->getEnableCache()) |
|
298 | 298 | { |
299 | 299 | $cache = $this->getApplication()->getCache(); |
300 | - if($cache !== null) |
|
300 | + if ($cache !== null) |
|
301 | 301 | { |
302 | 302 | $manager = $cache->get($this->getCacheKey()); |
303 | - if($manager instanceof TUrlManager) |
|
303 | + if ($manager instanceof TUrlManager) |
|
304 | 304 | return $manager; |
305 | 305 | } |
306 | 306 | } |
@@ -333,11 +333,11 @@ discard block |
||
333 | 333 | */ |
334 | 334 | public function getUrlManagerModule() |
335 | 335 | { |
336 | - if($this->_urlManager === null) |
|
336 | + if ($this->_urlManager === null) |
|
337 | 337 | { |
338 | - if(($this->_urlManager = $this->loadCachedUrlManager()) === null) |
|
338 | + if (($this->_urlManager = $this->loadCachedUrlManager()) === null) |
|
339 | 339 | { |
340 | - if(empty($this->_urlManagerID)) |
|
340 | + if (empty($this->_urlManagerID)) |
|
341 | 341 | { |
342 | 342 | $this->_urlManager = new TUrlManager; |
343 | 343 | $this->_urlManager->init(null); |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | else |
346 | 346 | { |
347 | 347 | $this->_urlManager = $this->getApplication()->getModule($this->_urlManagerID); |
348 | - if($this->_urlManager === null) |
|
348 | + if ($this->_urlManager === null) |
|
349 | 349 | throw new TConfigurationException('httprequest_urlmanager_inexist', $this->_urlManagerID); |
350 | - if(!($this->_urlManager instanceof TUrlManager)) |
|
350 | + if (!($this->_urlManager instanceof TUrlManager)) |
|
351 | 351 | throw new TConfigurationException('httprequest_urlmanager_invalid', $this->_urlManagerID); |
352 | 352 | } |
353 | 353 | $this->cacheUrlManager($this->_urlManager); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public function setUrlParamSeparator($value) |
393 | 393 | { |
394 | - if(strlen($value) === 1) |
|
394 | + if (strlen($value) === 1) |
|
395 | 395 | $this->_separator = $value; |
396 | 396 | else |
397 | 397 | throw new TInvalidDataValueException('httprequest_separator_invalid'); |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public function getRequestType() |
404 | 404 | { |
405 | - return isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:null; |
|
405 | + return isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null; |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | */ |
412 | 412 | public function getContentType($mimetypeOnly = true) |
413 | 413 | { |
414 | - if(!isset($_SERVER['CONTENT_TYPE'])) |
|
414 | + if (!isset($_SERVER['CONTENT_TYPE'])) |
|
415 | 415 | return null; |
416 | 416 | |
417 | - if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false) |
|
417 | + if ($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false) |
|
418 | 418 | return substr($_SERVER['CONTENT_TYPE'], 0, $_pos); |
419 | 419 | |
420 | 420 | return $_SERVER['CONTENT_TYPE']; |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | */ |
442 | 442 | public function getQueryString() |
443 | 443 | { |
444 | - return isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:null; |
|
444 | + return isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | */ |
450 | 450 | public function getHttpProtocolVersion() |
451 | 451 | { |
452 | - return isset($_SERVER['SERVER_PROTOCOL'])?$_SERVER['SERVER_PROTOCOL']:null; |
|
452 | + return isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null; |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -460,19 +460,19 @@ discard block |
||
460 | 460 | { |
461 | 461 | static $result; |
462 | 462 | |
463 | - if($result === null && function_exists('apache_request_headers')) { |
|
463 | + if ($result === null && function_exists('apache_request_headers')) { |
|
464 | 464 | $result = apache_request_headers(); |
465 | 465 | } |
466 | - elseif($result === null) { |
|
466 | + elseif ($result === null) { |
|
467 | 467 | $result = []; |
468 | - foreach($_SERVER as $key => $value) { |
|
469 | - if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
|
468 | + foreach ($_SERVER as $key => $value) { |
|
469 | + if (strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
|
470 | 470 | $key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5))))); |
471 | 471 | $result[$key] = $value; |
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
475 | - if($case !== null) |
|
475 | + if ($case !== null) |
|
476 | 476 | return array_change_key_case($result, $case); |
477 | 477 | |
478 | 478 | return $result; |
@@ -496,10 +496,10 @@ discard block |
||
496 | 496 | public function getBaseUrl($forceSecureConnection = null) |
497 | 497 | { |
498 | 498 | $url = $this->getUrl(); |
499 | - $scheme = ($forceSecureConnection)?"https": (($forceSecureConnection === null)?$url->getScheme():'http'); |
|
499 | + $scheme = ($forceSecureConnection) ? "https" : (($forceSecureConnection === null) ? $url->getScheme() : 'http'); |
|
500 | 500 | $host = $url->getHost(); |
501 | - if (($port = $url->getPort())) $host .= ':' . $port; |
|
502 | - return $scheme . '://' . $host; |
|
501 | + if (($port = $url->getPort())) $host .= ':'.$port; |
|
502 | + return $scheme.'://'.$host; |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | /** |
@@ -507,10 +507,10 @@ discard block |
||
507 | 507 | */ |
508 | 508 | public function getApplicationUrl() |
509 | 509 | { |
510 | - if($this->_cgiFix & self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
510 | + if ($this->_cgiFix & self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
511 | 511 | return $_SERVER['ORIG_SCRIPT_NAME']; |
512 | 512 | |
513 | - return isset($_SERVER['SCRIPT_NAME'])?$_SERVER['SCRIPT_NAME']:null; |
|
513 | + return isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : null; |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | */ |
523 | 523 | public function getAbsoluteApplicationUrl($forceSecureConnection = null) |
524 | 524 | { |
525 | - return $this->getBaseUrl($forceSecureConnection) . $this->getApplicationUrl(); |
|
525 | + return $this->getBaseUrl($forceSecureConnection).$this->getApplicationUrl(); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | */ |
531 | 531 | public function getApplicationFilePath() |
532 | 532 | { |
533 | - return realpath(isset($_SERVER['SCRIPT_FILENAME'])?$_SERVER['SCRIPT_FILENAME']:null); |
|
533 | + return realpath(isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : null); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | */ |
539 | 539 | public function getServerName() |
540 | 540 | { |
541 | - return isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:null; |
|
541 | + return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null; |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | */ |
547 | 547 | public function getServerPort() |
548 | 548 | { |
549 | - return isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:null; |
|
549 | + return isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null; |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | /** |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | */ |
555 | 555 | public function getUrlReferrer() |
556 | 556 | { |
557 | - return isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null; |
|
557 | + return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | */ |
564 | 564 | public function getServerSoftware() |
565 | 565 | { |
566 | - return isset($_SERVER['SERVER_SOFTWARE'])?$_SERVER['SERVER_SOFTWARE']:null; |
|
566 | + return isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : null; |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | { |
577 | 577 | return get_browser(); |
578 | 578 | } |
579 | - catch(TPhpErrorException $e) |
|
579 | + catch (TPhpErrorException $e) |
|
580 | 580 | { |
581 | 581 | throw new TConfigurationException('httprequest_browscap_required'); |
582 | 582 | } |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | */ |
588 | 588 | public function getUserAgent() |
589 | 589 | { |
590 | - return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null; |
|
590 | + return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | /** |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | */ |
596 | 596 | public function getUserHostAddress() |
597 | 597 | { |
598 | - return isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null; |
|
598 | + return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | */ |
604 | 604 | public function getUserHost() |
605 | 605 | { |
606 | - return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null; |
|
606 | + return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null; |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | /** |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | public function getAcceptTypes() |
613 | 613 | { |
614 | 614 | // TBD: break it into array?? |
615 | - return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null; |
|
615 | + return isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null; |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | /** |
@@ -668,21 +668,21 @@ discard block |
||
668 | 668 | */ |
669 | 669 | public function getCookies() |
670 | 670 | { |
671 | - if($this->_cookies === null) |
|
671 | + if ($this->_cookies === null) |
|
672 | 672 | { |
673 | 673 | $this->_cookies = new THttpCookieCollection; |
674 | - if($this->getEnableCookieValidation()) |
|
674 | + if ($this->getEnableCookieValidation()) |
|
675 | 675 | { |
676 | 676 | $sm = $this->getApplication()->getSecurityManager(); |
677 | - foreach($_COOKIE as $key => $value) |
|
677 | + foreach ($_COOKIE as $key => $value) |
|
678 | 678 | { |
679 | - if(($value = $sm->validateData($value)) !== false) |
|
679 | + if (($value = $sm->validateData($value)) !== false) |
|
680 | 680 | $this->_cookies->add(new THttpCookie($key, $value)); |
681 | 681 | } |
682 | 682 | } |
683 | 683 | else |
684 | 684 | { |
685 | - foreach($_COOKIE as $key => $value) |
|
685 | + foreach ($_COOKIE as $key => $value) |
|
686 | 686 | $this->_cookies->add(new THttpCookie($key, $value)); |
687 | 687 | } |
688 | 688 | } |
@@ -733,10 +733,10 @@ discard block |
||
733 | 733 | public function constructUrl($serviceID, $serviceParam, $getItems = null, $encodeAmpersand = true, $encodeGetItems = true) |
734 | 734 | { |
735 | 735 | if ($this->_cookieOnly === null) |
736 | - $this->_cookieOnly = (int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies'); |
|
736 | + $this->_cookieOnly = (int) ini_get('session.use_cookies') && (int) ini_get('session.use_only_cookies'); |
|
737 | 737 | $url = $this->getUrlManagerModule()->constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems); |
738 | - if(defined('SID') && SID != '' && !$this->_cookieOnly) |
|
739 | - return $url . (strpos($url, '?') === false? '?' : ($encodeAmpersand?'&':'&')) . SID; |
|
738 | + if (defined('SID') && SID != '' && !$this->_cookieOnly) |
|
739 | + return $url.(strpos($url, '?') === false ? '?' : ($encodeAmpersand ? '&' : '&')).SID; |
|
740 | 740 | else |
741 | 741 | return $url; |
742 | 742 | } |
@@ -764,15 +764,15 @@ discard block |
||
764 | 764 | */ |
765 | 765 | public function resolveRequest($serviceIDs) |
766 | 766 | { |
767 | - Prado::trace("Resolving request from " . $_SERVER['REMOTE_ADDR'], 'Prado\Web\THttpRequest'); |
|
767 | + Prado::trace("Resolving request from ".$_SERVER['REMOTE_ADDR'], 'Prado\Web\THttpRequest'); |
|
768 | 768 | $getParams = $this->parseUrl(); |
769 | - foreach($getParams as $name => $value) |
|
769 | + foreach ($getParams as $name => $value) |
|
770 | 770 | $_GET[$name] = $value; |
771 | 771 | $this->_items = array_merge($_GET, $_POST); |
772 | 772 | $this->_requestResolved = true; |
773 | - foreach($serviceIDs as $serviceID) |
|
773 | + foreach ($serviceIDs as $serviceID) |
|
774 | 774 | { |
775 | - if($this->contains($serviceID)) |
|
775 | + if ($this->contains($serviceID)) |
|
776 | 776 | { |
777 | 777 | $this->setServiceID($serviceID); |
778 | 778 | $this->setServiceParameter($this->itemAt($serviceID)); |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | */ |
893 | 893 | public function remove($key) |
894 | 894 | { |
895 | - if(isset($this->_items[$key]) || array_key_exists($key, $this->_items)) |
|
895 | + if (isset($this->_items[$key]) || array_key_exists($key, $this->_items)) |
|
896 | 896 | { |
897 | 897 | $value = $this->_items[$key]; |
898 | 898 | unset($this->_items[$key]); |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | */ |
908 | 908 | public function clear() |
909 | 909 | { |
910 | - foreach(array_keys($this->_items) as $key) |
|
910 | + foreach (array_keys($this->_items) as $key) |
|
911 | 911 | $this->remove($key); |
912 | 912 | } |
913 | 913 |
@@ -177,30 +177,37 @@ discard block |
||
177 | 177 | // QUERY_STRING is the string following the '?' in the ur (eg the a=x part in http://foo/bar?a=x) |
178 | 178 | // REQUEST_URI contains the URI part entered in the browser address bar |
179 | 179 | // SCRIPT_FILENAME is the file path to the executing script |
180 | - if(isset($_SERVER['REQUEST_URI'])) |
|
181 | - $this->_requestUri = $_SERVER['REQUEST_URI']; |
|
182 | - else // TBD: in this case, SCRIPT_NAME need to be escaped |
|
180 | + if(isset($_SERVER['REQUEST_URI'])) { |
|
181 | + $this->_requestUri = $_SERVER['REQUEST_URI']; |
|
182 | + } else { |
|
183 | + // TBD: in this case, SCRIPT_NAME need to be escaped |
|
183 | 184 | $this->_requestUri = $_SERVER['SCRIPT_NAME'] . (empty($_SERVER['QUERY_STRING'])?'':'?' . $_SERVER['QUERY_STRING']); |
185 | + } |
|
184 | 186 | |
185 | - if($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
186 | - $this->_pathInfo = substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME'])); |
|
187 | - elseif(isset($_SERVER['PATH_INFO'])) |
|
188 | - $this->_pathInfo = $_SERVER['PATH_INFO']; |
|
189 | - elseif(strpos($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME']) === 0 && $_SERVER['PHP_SELF'] !== $_SERVER['SCRIPT_NAME']) |
|
190 | - $this->_pathInfo = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])); |
|
191 | - else |
|
192 | - $this->_pathInfo = ''; |
|
187 | + if($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) { |
|
188 | + $this->_pathInfo = substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME'])); |
|
189 | + } elseif(isset($_SERVER['PATH_INFO'])) { |
|
190 | + $this->_pathInfo = $_SERVER['PATH_INFO']; |
|
191 | + } elseif(strpos($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME']) === 0 && $_SERVER['PHP_SELF'] !== $_SERVER['SCRIPT_NAME']) { |
|
192 | + $this->_pathInfo = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])); |
|
193 | + } else { |
|
194 | + $this->_pathInfo = ''; |
|
195 | + } |
|
193 | 196 | |
194 | 197 | if(get_magic_quotes_gpc()) |
195 | 198 | { |
196 | - if(isset($_GET)) |
|
197 | - $_GET = $this->stripSlashes($_GET); |
|
198 | - if(isset($_POST)) |
|
199 | - $_POST = $this->stripSlashes($_POST); |
|
200 | - if(isset($_REQUEST)) |
|
201 | - $_REQUEST = $this->stripSlashes($_REQUEST); |
|
202 | - if(isset($_COOKIE)) |
|
203 | - $_COOKIE = $this->stripSlashes($_COOKIE); |
|
199 | + if(isset($_GET)) { |
|
200 | + $_GET = $this->stripSlashes($_GET); |
|
201 | + } |
|
202 | + if(isset($_POST)) { |
|
203 | + $_POST = $this->stripSlashes($_POST); |
|
204 | + } |
|
205 | + if(isset($_REQUEST)) { |
|
206 | + $_REQUEST = $this->stripSlashes($_REQUEST); |
|
207 | + } |
|
208 | + if(isset($_COOKIE)) { |
|
209 | + $_COOKIE = $this->stripSlashes($_COOKIE); |
|
210 | + } |
|
204 | 211 | } |
205 | 212 | |
206 | 213 | $this->getApplication()->setRequest($this); |
@@ -230,11 +237,12 @@ discard block |
||
230 | 237 | { |
231 | 238 | $url .= $_SERVER['SERVER_NAME']; |
232 | 239 | $port = $_SERVER['SERVER_PORT']; |
233 | - if(($port != 80 && !$secure) || ($port != 443 && $secure)) |
|
234 | - $url .= ':' . $port; |
|
240 | + if(($port != 80 && !$secure) || ($port != 443 && $secure)) { |
|
241 | + $url .= ':' . $port; |
|
242 | + } |
|
243 | + } else { |
|
244 | + $url .= $_SERVER['HTTP_HOST']; |
|
235 | 245 | } |
236 | - else |
|
237 | - $url .= $_SERVER['HTTP_HOST']; |
|
238 | 246 | $url .= $this->getRequestUri(); |
239 | 247 | $this->_url = new TUri($url); |
240 | 248 | } |
@@ -276,10 +284,11 @@ discard block |
||
276 | 284 | if($cache !== null) |
277 | 285 | { |
278 | 286 | $dependencies = null; |
279 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
280 | - if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
|
287 | + if($this->getApplication()->getMode() !== TApplicationMode::Performance) { |
|
288 | + if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
|
281 | 289 | { |
282 | 290 | $fn = Prado::getPathOfNamespace($fn, $this->getApplication()->getConfigurationFileExt()); |
291 | + } |
|
283 | 292 | $dependencies = new TFileCacheDependency($fn); |
284 | 293 | } |
285 | 294 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
@@ -300,8 +309,9 @@ discard block |
||
300 | 309 | if($cache !== null) |
301 | 310 | { |
302 | 311 | $manager = $cache->get($this->getCacheKey()); |
303 | - if($manager instanceof TUrlManager) |
|
304 | - return $manager; |
|
312 | + if($manager instanceof TUrlManager) { |
|
313 | + return $manager; |
|
314 | + } |
|
305 | 315 | } |
306 | 316 | } |
307 | 317 | return null; |
@@ -341,14 +351,15 @@ discard block |
||
341 | 351 | { |
342 | 352 | $this->_urlManager = new TUrlManager; |
343 | 353 | $this->_urlManager->init(null); |
344 | - } |
|
345 | - else |
|
354 | + } else |
|
346 | 355 | { |
347 | 356 | $this->_urlManager = $this->getApplication()->getModule($this->_urlManagerID); |
348 | - if($this->_urlManager === null) |
|
349 | - throw new TConfigurationException('httprequest_urlmanager_inexist', $this->_urlManagerID); |
|
350 | - if(!($this->_urlManager instanceof TUrlManager)) |
|
351 | - throw new TConfigurationException('httprequest_urlmanager_invalid', $this->_urlManagerID); |
|
357 | + if($this->_urlManager === null) { |
|
358 | + throw new TConfigurationException('httprequest_urlmanager_inexist', $this->_urlManagerID); |
|
359 | + } |
|
360 | + if(!($this->_urlManager instanceof TUrlManager)) { |
|
361 | + throw new TConfigurationException('httprequest_urlmanager_invalid', $this->_urlManagerID); |
|
362 | + } |
|
352 | 363 | } |
353 | 364 | $this->cacheUrlManager($this->_urlManager); |
354 | 365 | } |
@@ -391,10 +402,11 @@ discard block |
||
391 | 402 | */ |
392 | 403 | public function setUrlParamSeparator($value) |
393 | 404 | { |
394 | - if(strlen($value) === 1) |
|
395 | - $this->_separator = $value; |
|
396 | - else |
|
397 | - throw new TInvalidDataValueException('httprequest_separator_invalid'); |
|
405 | + if(strlen($value) === 1) { |
|
406 | + $this->_separator = $value; |
|
407 | + } else { |
|
408 | + throw new TInvalidDataValueException('httprequest_separator_invalid'); |
|
409 | + } |
|
398 | 410 | } |
399 | 411 | |
400 | 412 | /** |
@@ -411,11 +423,13 @@ discard block |
||
411 | 423 | */ |
412 | 424 | public function getContentType($mimetypeOnly = true) |
413 | 425 | { |
414 | - if(!isset($_SERVER['CONTENT_TYPE'])) |
|
415 | - return null; |
|
426 | + if(!isset($_SERVER['CONTENT_TYPE'])) { |
|
427 | + return null; |
|
428 | + } |
|
416 | 429 | |
417 | - if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false) |
|
418 | - return substr($_SERVER['CONTENT_TYPE'], 0, $_pos); |
|
430 | + if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false) { |
|
431 | + return substr($_SERVER['CONTENT_TYPE'], 0, $_pos); |
|
432 | + } |
|
419 | 433 | |
420 | 434 | return $_SERVER['CONTENT_TYPE']; |
421 | 435 | } |
@@ -462,18 +476,20 @@ discard block |
||
462 | 476 | |
463 | 477 | if($result === null && function_exists('apache_request_headers')) { |
464 | 478 | $result = apache_request_headers(); |
465 | - } |
|
466 | - elseif($result === null) { |
|
479 | + } elseif($result === null) { |
|
467 | 480 | $result = []; |
468 | 481 | foreach($_SERVER as $key => $value) { |
469 | - if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
|
482 | + if(strncasecmp($key, 'HTTP_', 5) !== 0) { |
|
483 | + continue; |
|
484 | + } |
|
470 | 485 | $key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5))))); |
471 | 486 | $result[$key] = $value; |
472 | 487 | } |
473 | 488 | } |
474 | 489 | |
475 | - if($case !== null) |
|
476 | - return array_change_key_case($result, $case); |
|
490 | + if($case !== null) { |
|
491 | + return array_change_key_case($result, $case); |
|
492 | + } |
|
477 | 493 | |
478 | 494 | return $result; |
479 | 495 | } |
@@ -498,7 +514,9 @@ discard block |
||
498 | 514 | $url = $this->getUrl(); |
499 | 515 | $scheme = ($forceSecureConnection)?"https": (($forceSecureConnection === null)?$url->getScheme():'http'); |
500 | 516 | $host = $url->getHost(); |
501 | - if (($port = $url->getPort())) $host .= ':' . $port; |
|
517 | + if (($port = $url->getPort())) { |
|
518 | + $host .= ':' . $port; |
|
519 | + } |
|
502 | 520 | return $scheme . '://' . $host; |
503 | 521 | } |
504 | 522 | |
@@ -507,8 +525,9 @@ discard block |
||
507 | 525 | */ |
508 | 526 | public function getApplicationUrl() |
509 | 527 | { |
510 | - if($this->_cgiFix & self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
511 | - return $_SERVER['ORIG_SCRIPT_NAME']; |
|
528 | + if($this->_cgiFix & self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) { |
|
529 | + return $_SERVER['ORIG_SCRIPT_NAME']; |
|
530 | + } |
|
512 | 531 | |
513 | 532 | return isset($_SERVER['SCRIPT_NAME'])?$_SERVER['SCRIPT_NAME']:null; |
514 | 533 | } |
@@ -575,8 +594,7 @@ discard block |
||
575 | 594 | try |
576 | 595 | { |
577 | 596 | return get_browser(); |
578 | - } |
|
579 | - catch(TPhpErrorException $e) |
|
597 | + } catch(TPhpErrorException $e) |
|
580 | 598 | { |
581 | 599 | throw new TConfigurationException('httprequest_browscap_required'); |
582 | 600 | } |
@@ -676,14 +694,15 @@ discard block |
||
676 | 694 | $sm = $this->getApplication()->getSecurityManager(); |
677 | 695 | foreach($_COOKIE as $key => $value) |
678 | 696 | { |
679 | - if(($value = $sm->validateData($value)) !== false) |
|
680 | - $this->_cookies->add(new THttpCookie($key, $value)); |
|
697 | + if(($value = $sm->validateData($value)) !== false) { |
|
698 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
699 | + } |
|
681 | 700 | } |
682 | - } |
|
683 | - else |
|
701 | + } else |
|
684 | 702 | { |
685 | - foreach($_COOKIE as $key => $value) |
|
686 | - $this->_cookies->add(new THttpCookie($key, $value)); |
|
703 | + foreach($_COOKIE as $key => $value) { |
|
704 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
705 | + } |
|
687 | 706 | } |
688 | 707 | } |
689 | 708 | return $this->_cookies; |
@@ -732,13 +751,15 @@ discard block |
||
732 | 751 | */ |
733 | 752 | public function constructUrl($serviceID, $serviceParam, $getItems = null, $encodeAmpersand = true, $encodeGetItems = true) |
734 | 753 | { |
735 | - if ($this->_cookieOnly === null) |
|
736 | - $this->_cookieOnly = (int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies'); |
|
754 | + if ($this->_cookieOnly === null) { |
|
755 | + $this->_cookieOnly = (int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies'); |
|
756 | + } |
|
737 | 757 | $url = $this->getUrlManagerModule()->constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems); |
738 | - if(defined('SID') && SID != '' && !$this->_cookieOnly) |
|
739 | - return $url . (strpos($url, '?') === false? '?' : ($encodeAmpersand?'&':'&')) . SID; |
|
740 | - else |
|
741 | - return $url; |
|
758 | + if(defined('SID') && SID != '' && !$this->_cookieOnly) { |
|
759 | + return $url . (strpos($url, '?') === false? '?' : ($encodeAmpersand?'&':'&')) . SID; |
|
760 | + } else { |
|
761 | + return $url; |
|
762 | + } |
|
742 | 763 | } |
743 | 764 | |
744 | 765 | /** |
@@ -766,8 +787,9 @@ discard block |
||
766 | 787 | { |
767 | 788 | Prado::trace("Resolving request from " . $_SERVER['REMOTE_ADDR'], 'Prado\Web\THttpRequest'); |
768 | 789 | $getParams = $this->parseUrl(); |
769 | - foreach($getParams as $name => $value) |
|
770 | - $_GET[$name] = $value; |
|
790 | + foreach($getParams as $name => $value) { |
|
791 | + $_GET[$name] = $value; |
|
792 | + } |
|
771 | 793 | $this->_items = array_merge($_GET, $_POST); |
772 | 794 | $this->_requestResolved = true; |
773 | 795 | foreach($serviceIDs as $serviceID) |
@@ -897,9 +919,9 @@ discard block |
||
897 | 919 | $value = $this->_items[$key]; |
898 | 920 | unset($this->_items[$key]); |
899 | 921 | return $value; |
922 | + } else { |
|
923 | + return null; |
|
900 | 924 | } |
901 | - else |
|
902 | - return null; |
|
903 | 925 | } |
904 | 926 | |
905 | 927 | /** |
@@ -907,8 +929,9 @@ discard block |
||
907 | 929 | */ |
908 | 930 | public function clear() |
909 | 931 | { |
910 | - foreach(array_keys($this->_items) as $key) |
|
911 | - $this->remove($key); |
|
932 | + foreach(array_keys($this->_items) as $key) { |
|
933 | + $this->remove($key); |
|
934 | + } |
|
912 | 935 | } |
913 | 936 | |
914 | 937 | /** |