@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | elseif($item[0] === self::TYPE_DATABINDING) |
53 | 53 | $this->_bindings[$id] = $item[1]; |
54 | 54 | $this->_items[$id] = ''; |
55 | - } |
|
56 | - else |
|
55 | + } else |
|
57 | 56 | $this->_items[$id] = $item; |
58 | 57 | } |
59 | 58 | } |
@@ -80,10 +79,12 @@ discard block |
||
80 | 79 | public function evaluateDynamicContent() |
81 | 80 | { |
82 | 81 | $context = $this->_container === null?$this:$this->_container; |
83 | - foreach($this->_expressions as $id => $expression) |
|
84 | - $this->_items[$id] = $context->evaluateExpression($expression); |
|
85 | - foreach($this->_statements as $id => $statement) |
|
86 | - $this->_items[$id] = $context->evaluateStatements($statement); |
|
82 | + foreach($this->_expressions as $id => $expression) { |
|
83 | + $this->_items[$id] = $context->evaluateExpression($expression); |
|
84 | + } |
|
85 | + foreach($this->_statements as $id => $statement) { |
|
86 | + $this->_items[$id] = $context->evaluateStatements($statement); |
|
87 | + } |
|
87 | 88 | } |
88 | 89 | |
89 | 90 | /** |
@@ -93,8 +94,9 @@ discard block |
||
93 | 94 | public function dataBind() |
94 | 95 | { |
95 | 96 | $context = $this->_container === null?$this:$this->_container; |
96 | - foreach($this->_bindings as $id => $binding) |
|
97 | - $this->_items[$id] = $context->evaluateExpression($binding); |
|
97 | + foreach($this->_bindings as $id => $binding) { |
|
98 | + $this->_items[$id] = $context->evaluateExpression($binding); |
|
99 | + } |
|
98 | 100 | } |
99 | 101 | |
100 | 102 | /** |
@@ -108,9 +108,10 @@ discard block |
||
108 | 108 | if(!isset($options['appendTo'])) |
109 | 109 | $options['appendTo'] = 'form:first'; |
110 | 110 | |
111 | - foreach($this->getControls() as $control) |
|
112 | - if($control instanceof TJuiDialogButton) |
|
111 | + foreach($this->getControls() as $control) { |
|
112 | + if($control instanceof TJuiDialogButton) |
|
113 | 113 | $options['buttons'][] = $control->getPostBackOptions(); |
114 | + } |
|
114 | 115 | |
115 | 116 | return $options; |
116 | 117 | } |
@@ -193,8 +194,7 @@ discard block |
||
193 | 194 | { |
194 | 195 | parent::renderContents($writer); |
195 | 196 | $this->getPage()->getCallbackClient()->replaceContent($this, $writer, false); |
196 | - } |
|
197 | - else |
|
197 | + } else |
|
198 | 198 | parent::render($writer); |
199 | 199 | } |
200 | 200 | } |
@@ -141,9 +141,10 @@ |
||
141 | 141 | { |
142 | 142 | $ret = ($this->_options === null) ? [] : $this->_options; |
143 | 143 | |
144 | - foreach($this->_control->getValidEvents() as $event) |
|
145 | - if($this->_control->hasEventHandler('on' . $event)) |
|
144 | + foreach($this->_control->getValidEvents() as $event) { |
|
145 | + if($this->_control->hasEventHandler('on' . $event)) |
|
146 | 146 | $ret[$event] = new TJavaScriptLiteral("function( event, ui ) { Prado.JuiCallback(" . TJavaScript::encode($this->_control->getUniqueID()) . ", " . TJavaScript::encode($event) . ", event, ui, this); }"); |
147 | + } |
|
147 | 148 | |
148 | 149 | return $ret; |
149 | 150 | } |
@@ -233,8 +233,9 @@ discard block |
||
233 | 233 | $component->trackViewState(false); |
234 | 234 | |
235 | 235 | $component->applyStyleSheetSkin($page); |
236 | - foreach($properties as $name => $value) |
|
237 | - $this->configureControl($component, $name, $value); |
|
236 | + foreach($properties as $name => $value) { |
|
237 | + $this->configureControl($component, $name, $value); |
|
238 | + } |
|
238 | 239 | |
239 | 240 | $component->trackViewState(true); |
240 | 241 | |
@@ -244,8 +245,7 @@ discard block |
||
244 | 245 | $component->createdOnTemplate($parent); |
245 | 246 | if($component->getAllowChildControls()) |
246 | 247 | $controls[$key] = $component; |
247 | - } |
|
248 | - elseif($component instanceof TComponent) |
|
248 | + } elseif($component instanceof TComponent) |
|
249 | 249 | { |
250 | 250 | $controls[$key] = $component; |
251 | 251 | if(isset($properties['id'])) |
@@ -256,15 +256,15 @@ discard block |
||
256 | 256 | if(!$component->hasProperty('id')) |
257 | 257 | unset($properties['id']); |
258 | 258 | } |
259 | - foreach($properties as $name => $value) |
|
260 | - $this->configureComponent($component, $name, $value); |
|
259 | + foreach($properties as $name => $value) { |
|
260 | + $this->configureComponent($component, $name, $value); |
|
261 | + } |
|
261 | 262 | if($parent === $parentControl) |
262 | 263 | $directChildren[] = $component; |
263 | 264 | else |
264 | 265 | $component->createdOnTemplate($parent); |
265 | 266 | } |
266 | - } |
|
267 | - else |
|
267 | + } else |
|
268 | 268 | { |
269 | 269 | if($object[1] instanceof TCompositeLiteral) |
270 | 270 | { |
@@ -275,8 +275,7 @@ discard block |
||
275 | 275 | $directChildren[] = $o; |
276 | 276 | else |
277 | 277 | $parent->addParsedObject($o); |
278 | - } |
|
279 | - else |
|
278 | + } else |
|
280 | 279 | { |
281 | 280 | if($parent === $parentControl) |
282 | 281 | $directChildren[] = $object[1]; |
@@ -387,8 +386,7 @@ discard block |
||
387 | 386 | throw new TConfigurationException('template_tag_unexpected', $name, $value[1]); |
388 | 387 | break; |
389 | 388 | } |
390 | - } |
|
391 | - else |
|
389 | + } else |
|
392 | 390 | { |
393 | 391 | if (substr($name, 0, 2) == 'js') |
394 | 392 | if ($value and !($value instanceof TJavaScriptLiteral)) |
@@ -436,8 +434,7 @@ discard block |
||
436 | 434 | throw new TConfigurationException('template_tag_unexpected', $name, $value[1]); |
437 | 435 | break; |
438 | 436 | } |
439 | - } |
|
440 | - else |
|
437 | + } else |
|
441 | 438 | $component->setSubProperty($name, $value); |
442 | 439 | } |
443 | 440 | |
@@ -498,8 +495,7 @@ discard block |
||
498 | 495 | $stack[] = $type; |
499 | 496 | $container = $c - 1; |
500 | 497 | } |
501 | - } |
|
502 | - elseif(strpos($str, '</com:') === 0) // closing component tag |
|
498 | + } elseif(strpos($str, '</com:') === 0) // closing component tag |
|
503 | 499 | { |
504 | 500 | if($expectPropEnd) |
505 | 501 | continue; |
@@ -518,8 +514,7 @@ discard block |
||
518 | 514 | throw new TConfigurationException('template_closingtag_expected', $tag, "</com:$type>"); |
519 | 515 | } |
520 | 516 | $container = $tpl[$container][0]; |
521 | - } |
|
522 | - elseif(strpos($str, '<%@') === 0) // directive |
|
517 | + } elseif(strpos($str, '<%@') === 0) // directive |
|
523 | 518 | { |
524 | 519 | if($expectPropEnd) |
525 | 520 | continue; |
@@ -529,8 +524,7 @@ discard block |
||
529 | 524 | if(isset($tpl[0]) || $this->_directive !== null) |
530 | 525 | throw new TConfigurationException('template_directive_nonunique'); |
531 | 526 | $this->_directive = $this->parseAttributes($match[4][0], $match[4][1]); |
532 | - } |
|
533 | - elseif(strpos($str, '<%') === 0) // expression |
|
527 | + } elseif(strpos($str, '<%') === 0) // expression |
|
534 | 528 | { |
535 | 529 | if($expectPropEnd) |
536 | 530 | continue; |
@@ -555,8 +549,7 @@ discard block |
||
555 | 549 | $literal = strtr(trim(substr($literal, 0, strlen($literal) - 1)), ["'" => "\'","\\" => "\\\\"]); |
556 | 550 | $tpl[$c++] = [$container,[TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')"]]; |
557 | 551 | } |
558 | - } |
|
559 | - elseif(strpos($str, '<prop:') === 0) // opening property |
|
552 | + } elseif(strpos($str, '<prop:') === 0) // opening property |
|
560 | 553 | { |
561 | 554 | if(strrpos($str, '/>') === strlen($str) - 2) //subproperties |
562 | 555 | { |
@@ -568,8 +561,9 @@ discard block |
||
568 | 561 | $prop = strtolower($match[6][0]); |
569 | 562 | $attrs = $this->parseAttributes($match[7][0], $match[7][1]); |
570 | 563 | $attributes = []; |
571 | - foreach($attrs as $name => $value) |
|
572 | - $attributes[$prop . '.' . $name] = $value; |
|
564 | + foreach($attrs as $name => $value) { |
|
565 | + $attributes[$prop . '.' . $name] = $value; |
|
566 | + } |
|
573 | 567 | $type = $tpl[$container][1]; |
574 | 568 | $this->validateAttributes($type, $attributes); |
575 | 569 | foreach($attributes as $name => $value) |
@@ -578,8 +572,7 @@ discard block |
||
578 | 572 | throw new TConfigurationException('template_property_duplicated', $name); |
579 | 573 | $tpl[$container][2][$name] = $value; |
580 | 574 | } |
581 | - } |
|
582 | - else // regular property |
|
575 | + } else // regular property |
|
583 | 576 | { |
584 | 577 | $prop = strtolower($match[3][0]); |
585 | 578 | $stack[] = '@' . $prop; |
@@ -591,8 +584,7 @@ discard block |
||
591 | 584 | $expectPropEnd = true; |
592 | 585 | } |
593 | 586 | } |
594 | - } |
|
595 | - elseif(strpos($str, '</prop:') === 0) // closing property |
|
587 | + } elseif(strpos($str, '</prop:') === 0) // closing property |
|
596 | 588 | { |
597 | 589 | $prop = strtolower($match[3][0]); |
598 | 590 | if(empty($stack)) |
@@ -619,23 +611,20 @@ discard block |
||
619 | 611 | if(isset($tpl[$container][2][$prop])) |
620 | 612 | throw new TConfigurationException('template_property_duplicated', $prop); |
621 | 613 | $tpl[$container][2][$prop] = $value; |
622 | - } |
|
623 | - else // a property for the template control |
|
614 | + } else // a property for the template control |
|
624 | 615 | $this->_directive[$prop] = $value; |
625 | 616 | $textStart = $matchEnd + 1; |
626 | 617 | } |
627 | 618 | $expectPropEnd = false; |
628 | 619 | } |
629 | - } |
|
630 | - elseif(strpos($str, '<!--') === 0) // comments |
|
620 | + } elseif(strpos($str, '<!--') === 0) // comments |
|
631 | 621 | { |
632 | 622 | if($expectPropEnd) |
633 | 623 | throw new TConfigurationException('template_comments_forbidden'); |
634 | 624 | if($matchStart > $textStart) |
635 | 625 | $tpl[$c++] = [$container,substr($input, $textStart, $matchStart - $textStart)]; |
636 | 626 | $textStart = $matchEnd + 1; |
637 | - } |
|
638 | - else |
|
627 | + } else |
|
639 | 628 | throw new TConfigurationException('template_matching_unexpected', $match); |
640 | 629 | } |
641 | 630 | if(!empty($stack)) |
@@ -646,8 +635,7 @@ discard block |
||
646 | 635 | } |
647 | 636 | if($textStart < strlen($input)) |
648 | 637 | $tpl[$c++] = [$container,substr($input, $textStart)]; |
649 | - } |
|
650 | - catch(\Exception $e) |
|
638 | + } catch(\Exception $e) |
|
651 | 639 | { |
652 | 640 | if(($e instanceof TException) && ($e instanceof TTemplateException)) |
653 | 641 | throw $e; |
@@ -680,14 +668,12 @@ discard block |
||
680 | 668 | { |
681 | 669 | $parent = null; |
682 | 670 | $objects[$id] = $object; |
683 | - } |
|
684 | - else |
|
671 | + } else |
|
685 | 672 | { |
686 | 673 | $parent = $object[0]; |
687 | 674 | $merged = [$parent,[$object[1]]]; |
688 | 675 | } |
689 | - } |
|
690 | - else |
|
676 | + } else |
|
691 | 677 | $merged[1][] = $object[1]; |
692 | 678 | } |
693 | 679 | if($parent !== null) |
@@ -726,8 +712,7 @@ discard block |
||
726 | 712 | $attributes[$name] = $this->parseTemplateProperty(substr($value, 1, strlen($value) - 2), $match[2][1] + 1); |
727 | 713 | else |
728 | 714 | $attributes[$name] = $this->parseTemplateProperty($value, $match[2][1]); |
729 | - } |
|
730 | - else |
|
715 | + } else |
|
731 | 716 | { |
732 | 717 | if($value[0] === '\'' || $value[0] === '"') |
733 | 718 | $attributes[$name] = $this->parseAttribute(substr($value, 1, strlen($value) - 2)); |
@@ -776,8 +761,7 @@ discard block |
||
776 | 761 | return [self::CONFIG_DATABIND,ltrim($expr, '.')]; |
777 | 762 | else |
778 | 763 | return [self::CONFIG_EXPRESSION,ltrim($expr, '.')]; |
779 | - } |
|
780 | - elseif(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0] === $value) |
|
764 | + } elseif(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0] === $value) |
|
781 | 765 | { |
782 | 766 | $value = $matches[1]; |
783 | 767 | if($value[2] === '~') |
@@ -790,8 +774,7 @@ discard block |
||
790 | 774 | $literal = trim(substr($value, 3, strlen($value) - 5)); |
791 | 775 | return [self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"]; |
792 | 776 | } |
793 | - } |
|
794 | - else |
|
777 | + } else |
|
795 | 778 | return $value; |
796 | 779 | } |
797 | 780 | |
@@ -813,16 +796,14 @@ discard block |
||
813 | 796 | $subname = substr($name, 0, $pos); |
814 | 797 | if(!$class->hasMethod('get' . $subname)) |
815 | 798 | throw new TConfigurationException('template_property_unknown', $type, $subname); |
816 | - } |
|
817 | - elseif(strncasecmp($name, 'on', 2) === 0) |
|
799 | + } elseif(strncasecmp($name, 'on', 2) === 0) |
|
818 | 800 | { |
819 | 801 | // an event |
820 | 802 | if(!$class->hasMethod($name)) |
821 | 803 | throw new TConfigurationException('template_event_unknown', $type, $name); |
822 | 804 | elseif(!is_string($att)) |
823 | 805 | throw new TConfigurationException('template_eventhandler_invalid', $type, $name); |
824 | - } |
|
825 | - else |
|
806 | + } else |
|
826 | 807 | { |
827 | 808 | // a simple property |
828 | 809 | if (! ($class->hasMethod('set' . $name) || $class->hasMethod('setjs' . $name) || $this->isClassBehaviorMethod($class, 'set' . $name))) |
@@ -831,8 +812,7 @@ discard block |
||
831 | 812 | throw new TConfigurationException('template_property_readonly', $type, $name); |
832 | 813 | else |
833 | 814 | throw new TConfigurationException('template_property_unknown', $type, $name); |
834 | - } |
|
835 | - elseif(is_array($att) && $att[0] !== self::CONFIG_EXPRESSION) |
|
815 | + } elseif(is_array($att) && $att[0] !== self::CONFIG_EXPRESSION) |
|
836 | 816 | { |
837 | 817 | if(strcasecmp($name, 'id') === 0) |
838 | 818 | throw new TConfigurationException('template_controlid_invalid', $type); |
@@ -841,8 +821,7 @@ discard block |
||
841 | 821 | } |
842 | 822 | } |
843 | 823 | } |
844 | - } |
|
845 | - elseif(is_subclass_of($className, '\Prado\TComponent') || $className === '\Prado\TComponent') |
|
824 | + } elseif(is_subclass_of($className, '\Prado\TComponent') || $className === '\Prado\TComponent') |
|
846 | 825 | { |
847 | 826 | foreach($attributes as $name => $att) |
848 | 827 | { |
@@ -854,8 +833,7 @@ discard block |
||
854 | 833 | $subname = substr($name, 0, $pos); |
855 | 834 | if(!$class->hasMethod('get' . $subname)) |
856 | 835 | throw new TConfigurationException('template_property_unknown', $type, $subname); |
857 | - } |
|
858 | - elseif(strncasecmp($name, 'on', 2) === 0) |
|
836 | + } elseif(strncasecmp($name, 'on', 2) === 0) |
|
859 | 837 | throw new TConfigurationException('template_event_forbidden', $type, $name); |
860 | 838 | else |
861 | 839 | { |
@@ -869,8 +847,7 @@ discard block |
||
869 | 847 | } |
870 | 848 | } |
871 | 849 | } |
872 | - } |
|
873 | - else |
|
850 | + } else |
|
874 | 851 | throw new TConfigurationException('template_component_required', $type); |
875 | 852 | return $class->getName(); |
876 | 853 | } |
@@ -906,8 +883,7 @@ discard block |
||
906 | 883 | $line = $line - $this->_includeAtLine[$i] + 1; |
907 | 884 | $srcFile = $this->_includedFiles[$i]; |
908 | 885 | break; |
909 | - } |
|
910 | - else |
|
886 | + } else |
|
911 | 887 | $line = $line - $this->_includeLines[$i] + 1; |
912 | 888 | } |
913 | 889 | } |
@@ -204,8 +204,7 @@ discard block |
||
204 | 204 | $this->processCallbackRequest($writer); |
205 | 205 | else |
206 | 206 | $this->processPostBackRequest($writer); |
207 | - } |
|
208 | - else |
|
207 | + } else |
|
209 | 208 | $this->processNormalRequest($writer); |
210 | 209 | |
211 | 210 | $this->_writer = null; |
@@ -294,8 +293,9 @@ discard block |
||
294 | 293 | { |
295 | 294 | if(is_array($data)) |
296 | 295 | { |
297 | - foreach($data as $k => $v) |
|
298 | - $data[$k] = self::decodeUTF8($v, $enc); |
|
296 | + foreach($data as $k => $v) { |
|
297 | + $data[$k] = self::decodeUTF8($v, $enc); |
|
298 | + } |
|
299 | 299 | return $data; |
300 | 300 | } elseif(is_string($data)) { |
301 | 301 | return iconv('UTF-8', $enc . '//IGNORE', $data); |
@@ -319,8 +319,9 @@ discard block |
||
319 | 319 | // Decode Callback postData from UTF-8 to current Charset |
320 | 320 | if (($g = $this->getApplication()->getGlobalization(false)) !== null && |
321 | 321 | strtoupper($enc = $g->getCharset()) != 'UTF-8') |
322 | - foreach ($this->_postData as $k => $v) |
|
323 | - $this->_postData[$k] = self::decodeUTF8($v, $enc); |
|
322 | + foreach ($this->_postData as $k => $v) { |
|
323 | + $this->_postData[$k] = self::decodeUTF8($v, $enc); |
|
324 | + } |
|
324 | 325 | |
325 | 326 | Prado::trace("Page onPreInit()", 'Prado\Web\UI\TPage'); |
326 | 327 | $this->onPreInit(null); |
@@ -471,9 +472,10 @@ discard block |
||
471 | 472 | else |
472 | 473 | { |
473 | 474 | $list = new TList; |
474 | - foreach($this->_validators as $validator) |
|
475 | - if($validator->getValidationGroup() === $validationGroup) |
|
475 | + foreach($this->_validators as $validator) { |
|
476 | + if($validator->getValidationGroup() === $validationGroup) |
|
476 | 477 | $list->add($validator); |
478 | + } |
|
477 | 479 | return $list; |
478 | 480 | } |
479 | 481 | } |
@@ -492,10 +494,10 @@ discard block |
||
492 | 494 | { |
493 | 495 | if($validationGroup === null) |
494 | 496 | { |
495 | - foreach($this->_validators as $validator) |
|
496 | - $validator->validate(); |
|
497 | - } |
|
498 | - else |
|
497 | + foreach($this->_validators as $validator) { |
|
498 | + $validator->validate(); |
|
499 | + } |
|
500 | + } else |
|
499 | 501 | { |
500 | 502 | foreach($this->_validators as $validator) |
501 | 503 | { |
@@ -518,13 +520,13 @@ discard block |
||
518 | 520 | { |
519 | 521 | if($this->_validators && $this->_validators->getCount()) |
520 | 522 | { |
521 | - foreach($this->_validators as $validator) |
|
522 | - if(!$validator->getIsValid()) |
|
523 | + foreach($this->_validators as $validator) { |
|
524 | + if(!$validator->getIsValid()) |
|
523 | 525 | return false; |
526 | + } |
|
524 | 527 | } |
525 | 528 | return true; |
526 | - } |
|
527 | - else |
|
529 | + } else |
|
528 | 530 | throw new TInvalidOperationException('page_isvalid_unknown'); |
529 | 531 | } |
530 | 532 | |
@@ -673,18 +675,22 @@ discard block |
||
673 | 675 | $theme = $this->getTheme(); |
674 | 676 | if($theme instanceof ITheme) |
675 | 677 | { |
676 | - foreach($theme->getStyleSheetFiles() as $url) |
|
677 | - $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
678 | - foreach($theme->getJavaScriptFiles() as $url) |
|
679 | - $cs->registerHeadScriptFile($url, $url); |
|
678 | + foreach($theme->getStyleSheetFiles() as $url) { |
|
679 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
680 | + } |
|
681 | + foreach($theme->getJavaScriptFiles() as $url) { |
|
682 | + $cs->registerHeadScriptFile($url, $url); |
|
683 | + } |
|
680 | 684 | } |
681 | 685 | $styleSheet = $this->getStyleSheetTheme(); |
682 | 686 | if($styleSheet instanceof ITheme) |
683 | 687 | { |
684 | - foreach($styleSheet->getStyleSheetFiles() as $url) |
|
685 | - $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
686 | - foreach($styleSheet->getJavaScriptFiles() as $url) |
|
687 | - $cs->registerHeadScriptFile($url, $url); |
|
688 | + foreach($styleSheet->getStyleSheetFiles() as $url) { |
|
689 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
690 | + } |
|
691 | + foreach($styleSheet->getJavaScriptFiles() as $url) { |
|
692 | + $cs->registerHeadScriptFile($url, $url); |
|
693 | + } |
|
688 | 694 | } |
689 | 695 | |
690 | 696 | if($cs->getRequiresHead() && $this->getHead() === null) |
@@ -810,8 +816,9 @@ discard block |
||
810 | 816 | $id = is_string($control)?$control:$control->getUniqueID(); |
811 | 817 | $this->_controlsRegisteredForPostData[$id] = true; |
812 | 818 | $params = func_get_args(); |
813 | - foreach($this->getCachingStack() as $item) |
|
814 | - $item->registerAction('Page', 'registerRequiresPostData', [$id]); |
|
819 | + foreach($this->getCachingStack() as $item) { |
|
820 | + $item->registerAction('Page', 'registerRequiresPostData', [$id]); |
|
821 | + } |
|
815 | 822 | } |
816 | 823 | |
817 | 824 | /** |
@@ -878,15 +885,13 @@ discard block |
||
878 | 885 | { |
879 | 886 | if($control->loadPostData($key, $postData)) |
880 | 887 | $this->_controlsPostDataChanged[] = $control; |
881 | - } |
|
882 | - elseif($control instanceof IPostBackEventHandler && |
|
888 | + } elseif($control instanceof IPostBackEventHandler && |
|
883 | 889 | empty($this->_postData[self::FIELD_POSTBACK_TARGET])) |
884 | 890 | { |
885 | 891 | $this->_postData->add(self::FIELD_POSTBACK_TARGET, $key); // not calling setPostBackEventTarget() because the control may be removed later |
886 | 892 | } |
887 | 893 | unset($this->_controlsRequiringPostData[$key]); |
888 | - } |
|
889 | - elseif($beforeLoad) |
|
894 | + } elseif($beforeLoad) |
|
890 | 895 | $this->_restPostData->add($key, $value); |
891 | 896 | } |
892 | 897 | |
@@ -898,8 +903,7 @@ discard block |
||
898 | 903 | { |
899 | 904 | if($control->loadPostData($key, $this->_postData)) |
900 | 905 | $this->_controlsPostDataChanged[] = $control; |
901 | - } |
|
902 | - else |
|
906 | + } else |
|
903 | 907 | throw new TInvalidDataValueException('page_postbackcontrol_invalid', $key); |
904 | 908 | unset($this->_controlsRequiringPostData[$key]); |
905 | 909 | } |
@@ -920,8 +924,9 @@ discard block |
||
920 | 924 | */ |
921 | 925 | protected function raiseChangedEvents() |
922 | 926 | { |
923 | - foreach($this->_controlsPostDataChanged as $control) |
|
924 | - $control->raisePostDataChangedEvent(); |
|
927 | + foreach($this->_controlsPostDataChanged as $control) { |
|
928 | + $control->raisePostDataChangedEvent(); |
|
929 | + } |
|
925 | 930 | } |
926 | 931 | |
927 | 932 | /** |
@@ -978,8 +983,7 @@ discard block |
||
978 | 983 | else |
979 | 984 | $focus = $this->_focus; |
980 | 985 | $this->getClientScript()->registerFocusControl($focus); |
981 | - } |
|
982 | - elseif($this->_postData && ($lastFocus = $this->_postData->itemAt(self::FIELD_LASTFOCUS)) !== null) |
|
986 | + } elseif($this->_postData && ($lastFocus = $this->_postData->itemAt(self::FIELD_LASTFOCUS)) !== null) |
|
983 | 987 | $this->getClientScript()->registerFocusControl($lastFocus); |
984 | 988 | $this->_inFormRender = false; |
985 | 989 | } |
@@ -1196,8 +1200,9 @@ discard block |
||
1196 | 1200 | { |
1197 | 1201 | if($this->_cachingStack) |
1198 | 1202 | { |
1199 | - foreach($this->_cachingStack as $cache) |
|
1200 | - $cache->registerAction($context, $funcName, $funcParams); |
|
1203 | + foreach($this->_cachingStack as $cache) { |
|
1204 | + $cache->registerAction($context, $funcName, $funcParams); |
|
1205 | + } |
|
1201 | 1206 | } |
1202 | 1207 | } |
1203 | 1208 |
@@ -100,8 +100,9 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function addAttributes($attrs) |
102 | 102 | { |
103 | - foreach($attrs as $name => $value) |
|
104 | - $this->_attributes[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
|
103 | + foreach($attrs as $name => $value) { |
|
104 | + $this->_attributes[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
|
105 | + } |
|
105 | 106 | } |
106 | 107 | |
107 | 108 | /** |
@@ -129,8 +130,9 @@ discard block |
||
129 | 130 | */ |
130 | 131 | public function addStyleAttributes($attrs) |
131 | 132 | { |
132 | - foreach($attrs as $name => $value) |
|
133 | - $this->_styles[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
|
133 | + foreach($attrs as $name => $value) { |
|
134 | + $this->_styles[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
|
135 | + } |
|
134 | 136 | } |
135 | 137 | |
136 | 138 | /** |
@@ -195,21 +197,22 @@ discard block |
||
195 | 197 | public function renderBeginTag($tagName) |
196 | 198 | { |
197 | 199 | $str = '<' . $tagName; |
198 | - foreach($this->_attributes as $name => $value) |
|
199 | - $str .= ' ' . $name . '="' . $value . '"'; |
|
200 | + foreach($this->_attributes as $name => $value) { |
|
201 | + $str .= ' ' . $name . '="' . $value . '"'; |
|
202 | + } |
|
200 | 203 | if(!empty($this->_styles)) |
201 | 204 | { |
202 | 205 | $str .= ' style="'; |
203 | - foreach($this->_styles as $name => $value) |
|
204 | - $str .= $name . ':' . $value . ';'; |
|
206 | + foreach($this->_styles as $name => $value) { |
|
207 | + $str .= $name . ':' . $value . ';'; |
|
208 | + } |
|
205 | 209 | $str .= '"'; |
206 | 210 | } |
207 | 211 | if(isset(self::$_simpleTags[$tagName])) |
208 | 212 | { |
209 | 213 | $str .= ' />'; |
210 | 214 | $this->_openTags[] = ''; |
211 | - } |
|
212 | - else |
|
215 | + } else |
|
213 | 216 | { |
214 | 217 | $str .= '>'; |
215 | 218 | $this->_openTags[] = $tagName; |
@@ -406,11 +406,9 @@ discard block |
||
406 | 406 | return $this->_id; |
407 | 407 | else |
408 | 408 | return ($this->_uid = $prefix . self::ID_SEPARATOR . $this->_id); |
409 | - } |
|
410 | - else // no naming container |
|
409 | + } else // no naming container |
|
411 | 410 | return $this->_id; |
412 | - } |
|
413 | - else |
|
411 | + } else |
|
414 | 412 | return $this->_uid; |
415 | 413 | } |
416 | 414 | |
@@ -560,12 +558,12 @@ discard block |
||
560 | 558 | { |
561 | 559 | if($checkParents) |
562 | 560 | { |
563 | - for($control = $this;$control;$control = $control->_parent) |
|
564 | - if(!$control->getVisible(false)) |
|
561 | + for($control = $this;$control;$control = $control->_parent) { |
|
562 | + if(!$control->getVisible(false)) |
|
565 | 563 | return false; |
564 | + } |
|
566 | 565 | return true; |
567 | - } |
|
568 | - else |
|
566 | + } else |
|
569 | 567 | return $this->getViewState('Visible', true); |
570 | 568 | } |
571 | 569 | |
@@ -591,12 +589,12 @@ discard block |
||
591 | 589 | { |
592 | 590 | if($checkParents) |
593 | 591 | { |
594 | - for($control = $this;$control;$control = $control->_parent) |
|
595 | - if(!$control->getViewState('Enabled', true)) |
|
592 | + for($control = $this;$control;$control = $control->_parent) { |
|
593 | + if(!$control->getViewState('Enabled', true)) |
|
596 | 594 | return false; |
595 | + } |
|
597 | 596 | return true; |
598 | - } |
|
599 | - else |
|
597 | + } else |
|
600 | 598 | return $this->getViewState('Enabled', true); |
601 | 599 | } |
602 | 600 | |
@@ -689,12 +687,12 @@ discard block |
||
689 | 687 | { |
690 | 688 | if($checkParents) |
691 | 689 | { |
692 | - for($control = $this;$control !== null;$control = $control->getParent()) |
|
693 | - if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
690 | + for($control = $this;$control !== null;$control = $control->getParent()) { |
|
691 | + if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
694 | 692 | return false; |
693 | + } |
|
695 | 694 | return true; |
696 | - } |
|
697 | - else |
|
695 | + } else |
|
698 | 696 | return !($this->_flags & self::IS_DISABLE_VIEWSTATE); |
699 | 697 | } |
700 | 698 | |
@@ -779,8 +777,7 @@ discard block |
||
779 | 777 | if(is_object($this->_tempState[$key]) && $this->_trackViewState) |
780 | 778 | $this->_viewState[$key] = $this->_tempState[$key]; |
781 | 779 | return $this->_tempState[$key]; |
782 | - } |
|
783 | - else |
|
780 | + } else |
|
784 | 781 | return $defaultValue; |
785 | 782 | } |
786 | 783 | |
@@ -800,8 +797,7 @@ discard block |
||
800 | 797 | { |
801 | 798 | unset($this->_tempState[$key]); |
802 | 799 | $this->_viewState[$key] = $value; |
803 | - } |
|
804 | - else |
|
800 | + } else |
|
805 | 801 | { |
806 | 802 | unset($this->_viewState[$key]); |
807 | 803 | if($value === $defaultValue) |
@@ -874,8 +870,9 @@ discard block |
||
874 | 870 | { |
875 | 871 | if(($context = $this->getTemplateControl()) === null) |
876 | 872 | $context = $this; |
877 | - foreach($this->_rf[self::RF_DATA_BINDINGS] as $property => $expression) |
|
878 | - $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
873 | + foreach($this->_rf[self::RF_DATA_BINDINGS] as $property => $expression) { |
|
874 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
875 | + } |
|
879 | 876 | } |
880 | 877 | } |
881 | 878 | |
@@ -888,8 +885,9 @@ discard block |
||
888 | 885 | { |
889 | 886 | if(($context = $this->getTemplateControl()) === null) |
890 | 887 | $context = $this; |
891 | - foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property => $expression) |
|
892 | - $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
888 | + foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property => $expression) { |
|
889 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
890 | + } |
|
893 | 891 | } |
894 | 892 | } |
895 | 893 | |
@@ -901,9 +899,10 @@ discard block |
||
901 | 899 | Prado::trace("dataBindChildren()", 'Prado\Web\UI\TControl'); |
902 | 900 | if(isset($this->_rf[self::RF_CONTROLS])) |
903 | 901 | { |
904 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
905 | - if($control instanceof IBindable) |
|
902 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
903 | + if($control instanceof IBindable) |
|
906 | 904 | $control->dataBind(); |
905 | + } |
|
907 | 906 | } |
908 | 907 | } |
909 | 908 | |
@@ -950,8 +949,7 @@ discard block |
||
950 | 949 | $this->createChildControls(); |
951 | 950 | $this->_flags &= ~self::IS_CREATING_CHILD; |
952 | 951 | $this->_flags |= self::IS_CHILD_CREATED; |
953 | - } |
|
954 | - catch(Exception $e) |
|
952 | + } catch(Exception $e) |
|
955 | 953 | { |
956 | 954 | $this->_flags &= ~self::IS_CREATING_CHILD; |
957 | 955 | $this->_flags |= self::IS_CHILD_CREATED; |
@@ -1190,8 +1188,9 @@ discard block |
||
1190 | 1188 | final protected function isDescendentOf($ancestor) |
1191 | 1189 | { |
1192 | 1190 | $control = $this; |
1193 | - while($control !== $ancestor && $control->_parent) |
|
1194 | - $control = $control->_parent; |
|
1191 | + while($control !== $ancestor && $control->_parent) { |
|
1192 | + $control = $control->_parent; |
|
1193 | + } |
|
1195 | 1194 | return $control === $ancestor; |
1196 | 1195 | } |
1197 | 1196 | |
@@ -1227,8 +1226,7 @@ discard block |
||
1227 | 1226 | { |
1228 | 1227 | $state = $this->_rf[self::RF_CHILD_STATE][$control->_id]; |
1229 | 1228 | unset($this->_rf[self::RF_CHILD_STATE][$control->_id]); |
1230 | - } |
|
1231 | - else |
|
1229 | + } else |
|
1232 | 1230 | $state = null; |
1233 | 1231 | $control->loadStateRecursive($state, !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1234 | 1232 | if($this->_stage >= self::CS_LOADED) |
@@ -1367,9 +1365,10 @@ discard block |
||
1367 | 1365 | $this->_id = ''; |
1368 | 1366 | if($this->getHasControls()) |
1369 | 1367 | { |
1370 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1371 | - if($control instanceof TControl) |
|
1368 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
1369 | + if($control instanceof TControl) |
|
1372 | 1370 | $control->unloadRecursive(); |
1371 | + } |
|
1373 | 1372 | } |
1374 | 1373 | if(isset($this->_rf[self::RF_ADAPTER])) |
1375 | 1374 | $this->_rf[self::RF_ADAPTER]->onUnload(null); |
@@ -1633,8 +1632,7 @@ discard block |
||
1633 | 1632 | { |
1634 | 1633 | $this->_rf[self::RF_CONTROLSTATE] = &$state[1]; |
1635 | 1634 | unset($state[1]); |
1636 | - } |
|
1637 | - else |
|
1635 | + } else |
|
1638 | 1636 | unset($this->_rf[self::RF_CONTROLSTATE]); |
1639 | 1637 | if($needViewState) |
1640 | 1638 | { |
@@ -1711,8 +1709,7 @@ discard block |
||
1711 | 1709 | { |
1712 | 1710 | $page->applyControlStyleSheet($this); |
1713 | 1711 | $this->_flags |= self::IS_STYLESHEET_APPLIED; |
1714 | - } |
|
1715 | - elseif($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
1712 | + } elseif($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
1716 | 1713 | throw new TInvalidOperationException('control_stylesheet_applied', get_class($this)); |
1717 | 1714 | } |
1718 | 1715 | |
@@ -1725,9 +1722,10 @@ discard block |
||
1725 | 1722 | { |
1726 | 1723 | if($recursive && $this->_uid !== null && isset($this->_rf[self::RF_CONTROLS])) |
1727 | 1724 | { |
1728 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1729 | - if($control instanceof TControl) |
|
1725 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
1726 | + if($control instanceof TControl) |
|
1730 | 1727 | $control->clearCachedUniqueID($recursive); |
1728 | + } |
|
1731 | 1729 | } |
1732 | 1730 | $this->_uid = null; |
1733 | 1731 | } |
@@ -268,8 +268,7 @@ discard block |
||
268 | 268 | { |
269 | 269 | if($control->getVisible(true)) |
270 | 270 | return $control->getClientID(); |
271 | - } |
|
272 | - else |
|
271 | + } else |
|
273 | 272 | return $id; |
274 | 273 | } |
275 | 274 | return ''; |
@@ -308,8 +307,9 @@ discard block |
||
308 | 307 | { |
309 | 308 | $types = ['blank', 'selected', 'half', 'combined']; |
310 | 309 | $files = []; |
311 | - foreach($types as $type) |
|
312 | - $files[$type] = $this->getAssetUrl("{$style}_{$type}{$fileExt}"); |
|
310 | + foreach($types as $type) { |
|
311 | + $files[$type] = $this->getAssetUrl("{$style}_{$type}{$fileExt}"); |
|
312 | + } |
|
313 | 313 | return $files; |
314 | 314 | } |
315 | 315 |
@@ -190,9 +190,10 @@ discard block |
||
190 | 190 | */ |
191 | 191 | private function getClientControlClass($control) |
192 | 192 | { |
193 | - foreach(self::$_clientClass as $type) |
|
194 | - if($control instanceof $type) |
|
193 | + foreach(self::$_clientClass as $type) { |
|
194 | + if($control instanceof $type) |
|
195 | 195 | return $type; |
196 | + } |
|
196 | 197 | $reflectionClass = new \ReflectionClass($control); |
197 | 198 | return $reflectionClass->getShortName(); |
198 | 199 | } |
@@ -523,16 +524,14 @@ discard block |
||
523 | 524 | { |
524 | 525 | $this->setIsValid(true); |
525 | 526 | $this->onValidationSuccess(); |
526 | - } |
|
527 | - else |
|
527 | + } else |
|
528 | 528 | { |
529 | 529 | if($target) |
530 | 530 | $target->setIsValid(false); |
531 | 531 | $this->setIsValid(false); |
532 | 532 | $this->onValidationError(); |
533 | 533 | } |
534 | - } |
|
535 | - else |
|
534 | + } else |
|
536 | 535 | { |
537 | 536 | $this->evaluateIsValid(); |
538 | 537 | $this->setIsValid(true); |