@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | * </code> |
407 | 407 | * to be executed when listen is called. All attached behaviors are notified through dyListen. |
408 | 408 | * |
409 | - * @return numeric the number of global events that were registered to the global event registry |
|
409 | + * @return null|integer the number of global events that were registered to the global event registry |
|
410 | 410 | */ |
411 | 411 | public function listen() { |
412 | 412 | if($this->_listeningenabled) |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * </code> |
441 | 441 | * to be executed when listen is called. All attached behaviors are notified through dyUnlisten. |
442 | 442 | * |
443 | - * @return numeric the number of global events that were unregistered from the global event registry |
|
443 | + * @return null|integer the number of global events that were unregistered from the global event registry |
|
444 | 444 | */ |
445 | 445 | public function unlisten() { |
446 | 446 | if(!$this->_listeningenabled) |
@@ -774,6 +774,7 @@ discard block |
||
774 | 774 | * A property is defined if there is a getter or setter method |
775 | 775 | * defined in the class. Note, property names are case-insensitive. |
776 | 776 | * @param string the property name |
777 | + * @param string $name |
|
777 | 778 | * @return boolean whether the property is defined |
778 | 779 | */ |
779 | 780 | public function hasProperty($name) |
@@ -2100,6 +2101,9 @@ discard block |
||
2100 | 2101 | $this->reflect(); |
2101 | 2102 | } |
2102 | 2103 | |
2104 | + /** |
|
2105 | + * @param ReflectionMethod $method |
|
2106 | + */ |
|
2103 | 2107 | private function isPropertyMethod($method) |
2104 | 2108 | { |
2105 | 2109 | $methodName=$method->getName(); |
@@ -2108,6 +2112,9 @@ discard block |
||
2108 | 2112 | && isset($methodName[3]); |
2109 | 2113 | } |
2110 | 2114 | |
2115 | + /** |
|
2116 | + * @param ReflectionMethod $method |
|
2117 | + */ |
|
2111 | 2118 | private function isEventMethod($method) |
2112 | 2119 | { |
2113 | 2120 | $methodName=$method->getName(); |
@@ -2254,11 +2261,14 @@ discard block |
||
2254 | 2261 | /** |
2255 | 2262 | * Attaches the behavior object to the component. |
2256 | 2263 | * @param CComponent the component that this behavior is to be attached to. |
2264 | + * @param TComponent $component |
|
2265 | + * @return void |
|
2257 | 2266 | */ |
2258 | 2267 | public function attach($component); |
2259 | 2268 | /** |
2260 | 2269 | * Detaches the behavior object from the component. |
2261 | 2270 | * @param CComponent the component that this behavior is to be detached from. |
2271 | + * @return void |
|
2262 | 2272 | */ |
2263 | 2273 | public function detach($component); |
2264 | 2274 | } |
@@ -2283,6 +2293,8 @@ discard block |
||
2283 | 2293 | public function getEnabled(); |
2284 | 2294 | /** |
2285 | 2295 | * @param boolean whether this behavior is enabled |
2296 | + * @param boolean $value |
|
2297 | + * @return void |
|
2286 | 2298 | */ |
2287 | 2299 | public function setEnabled($value); |
2288 | 2300 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * that start with 'fx' are filtered in. |
374 | 374 | */ |
375 | 375 | private function filter_prado_fx($name) { |
376 | - return strncasecmp($name,'fx',2)===0; |
|
376 | + return strncasecmp($name, 'fx', 2)===0; |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -383,13 +383,13 @@ discard block |
||
383 | 383 | * @param boolean optional should the names be all lowercase true/false |
384 | 384 | * @return array array of strings being the class hierarchy of $this. |
385 | 385 | */ |
386 | - public function getClassHierarchy($lowercase = false) |
|
386 | + public function getClassHierarchy($lowercase=false) |
|
387 | 387 | { |
388 | 388 | $class=get_class($this); |
389 | 389 | $classes=array($class); |
390 | - while($class=get_parent_class($class)){array_unshift($classes,$class);} |
|
390 | + while($class=get_parent_class($class)) {array_unshift($classes, $class); } |
|
391 | 391 | if($lowercase) |
392 | - return array_map('strtolower',$classes); |
|
392 | + return array_map('strtolower', $classes); |
|
393 | 393 | return $classes; |
394 | 394 | } |
395 | 395 | |
@@ -412,14 +412,14 @@ discard block |
||
412 | 412 | if($this->_listeningenabled) |
413 | 413 | return; |
414 | 414 | |
415 | - $fx=array_filter(get_class_methods($this),array($this,'filter_prado_fx')); |
|
415 | + $fx=array_filter(get_class_methods($this), array($this, 'filter_prado_fx')); |
|
416 | 416 | |
417 | 417 | foreach($fx as $func) |
418 | - $this->attachEventHandler($func,array($this,$func)); |
|
418 | + $this->attachEventHandler($func, array($this, $func)); |
|
419 | 419 | |
420 | - if(is_a($this,'IDynamicMethods')) { |
|
421 | - $this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER,array($this,'__dycall')); |
|
422 | - array_push($fx,TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
420 | + if(is_a($this, 'IDynamicMethods')) { |
|
421 | + $this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, array($this, '__dycall')); |
|
422 | + array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | $this->_listeningenabled=true; |
@@ -446,14 +446,14 @@ discard block |
||
446 | 446 | if(!$this->_listeningenabled) |
447 | 447 | return; |
448 | 448 | |
449 | - $fx=array_filter(get_class_methods($this),array($this,'filter_prado_fx')); |
|
449 | + $fx=array_filter(get_class_methods($this), array($this, 'filter_prado_fx')); |
|
450 | 450 | |
451 | 451 | foreach($fx as $func) |
452 | - $this->detachEventHandler($func,array($this,$func)); |
|
452 | + $this->detachEventHandler($func, array($this, $func)); |
|
453 | 453 | |
454 | - if(is_a($this,'IDynamicMethods')) { |
|
455 | - $this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER,array($this,'__dycall')); |
|
456 | - array_push($fx,TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
454 | + if(is_a($this, 'IDynamicMethods')) { |
|
455 | + $this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, array($this, '__dycall')); |
|
456 | + array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | $this->_listeningenabled=false; |
@@ -498,64 +498,64 @@ discard block |
||
498 | 498 | */ |
499 | 499 | public function __call($method, $args) |
500 | 500 | { |
501 | - $getset=substr($method,0,3); |
|
502 | - if(($getset=='get')||($getset=='set')) |
|
501 | + $getset=substr($method, 0, 3); |
|
502 | + if(($getset=='get') || ($getset=='set')) |
|
503 | 503 | { |
504 | - $propname=substr($method,3); |
|
504 | + $propname=substr($method, 3); |
|
505 | 505 | $jsmethod=$getset.'js'.$propname; |
506 | - if(method_exists($this,$jsmethod)) |
|
506 | + if(method_exists($this, $jsmethod)) |
|
507 | 507 | { |
508 | - if(count($args)>0) |
|
509 | - if($args[0]&&!($args[0] instanceof TJavaScriptString)) |
|
508 | + if(count($args) > 0) |
|
509 | + if($args[0] && !($args[0] instanceof TJavaScriptString)) |
|
510 | 510 | $args[0]=new TJavaScriptString($args[0]); |
511 | - return call_user_func_array(array($this,$jsmethod),$args); |
|
511 | + return call_user_func_array(array($this, $jsmethod), $args); |
|
512 | 512 | } |
513 | 513 | |
514 | - if (($getset=='set')&&method_exists($this,'getjs'.$propname)) |
|
515 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$method); |
|
514 | + if(($getset=='set') && method_exists($this, 'getjs'.$propname)) |
|
515 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $method); |
|
516 | 516 | } |
517 | 517 | |
518 | - if($this->_m!==null&&$this->_behaviorsenabled) |
|
518 | + if($this->_m!==null && $this->_behaviorsenabled) |
|
519 | 519 | { |
520 | - if(strncasecmp($method,'dy',2)===0) |
|
520 | + if(strncasecmp($method, 'dy', 2)===0) |
|
521 | 521 | { |
522 | 522 | $callchain=new TCallChain($method); |
523 | 523 | foreach($this->_m->toArray() as $behavior) |
524 | 524 | { |
525 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&(method_exists($behavior,$method)||($behavior instanceof IDynamicMethods))) |
|
525 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && (method_exists($behavior, $method) || ($behavior instanceof IDynamicMethods))) |
|
526 | 526 | { |
527 | 527 | $behavior_args=$args; |
528 | 528 | if($behavior instanceof IClassBehavior) |
529 | - array_unshift($behavior_args,$this); |
|
530 | - $callchain->addCall(array($behavior,$method),$behavior_args); |
|
529 | + array_unshift($behavior_args, $this); |
|
530 | + $callchain->addCall(array($behavior, $method), $behavior_args); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | } |
534 | - if($callchain->getCount()>0) |
|
535 | - return call_user_func_array(array($callchain,'call'),$args); |
|
534 | + if($callchain->getCount() > 0) |
|
535 | + return call_user_func_array(array($callchain, 'call'), $args); |
|
536 | 536 | } |
537 | 537 | else |
538 | 538 | { |
539 | 539 | foreach($this->_m->toArray() as $behavior) |
540 | 540 | { |
541 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&method_exists($behavior,$method)) |
|
541 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && method_exists($behavior, $method)) |
|
542 | 542 | { |
543 | 543 | if($behavior instanceof IClassBehavior) |
544 | - array_unshift($args,$this); |
|
545 | - return call_user_func_array(array($behavior,$method),$args); |
|
544 | + array_unshift($args, $this); |
|
545 | + return call_user_func_array(array($behavior, $method), $args); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | } |
549 | 549 | } |
550 | 550 | |
551 | - if(strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0) |
|
551 | + if(strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
552 | 552 | { |
553 | 553 | if($this instanceof IDynamicMethods) |
554 | - return $this->__dycall($method,$args); |
|
555 | - return isset($args[0])?$args[0]:null; |
|
554 | + return $this->__dycall($method, $args); |
|
555 | + return isset($args[0]) ? $args[0] : null; |
|
556 | 556 | } |
557 | 557 | |
558 | - throw new TApplicationException('component_method_undefined',get_class($this),$method); |
|
558 | + throw new TApplicationException('component_method_undefined', get_class($this), $method); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | |
@@ -584,17 +584,17 @@ discard block |
||
584 | 584 | */ |
585 | 585 | public function __get($name) |
586 | 586 | { |
587 | - if(method_exists($this,$getter='get'.$name)) |
|
587 | + if(method_exists($this, $getter='get'.$name)) |
|
588 | 588 | { |
589 | 589 | // getting a property |
590 | 590 | return $this->$getter(); |
591 | 591 | } |
592 | - else if(method_exists($this,$jsgetter='getjs'.$name)) |
|
592 | + else if(method_exists($this, $jsgetter='getjs'.$name)) |
|
593 | 593 | { |
594 | 594 | // getting a javascript property |
595 | - return (string)$this->$jsgetter(); |
|
595 | + return (string) $this->$jsgetter(); |
|
596 | 596 | } |
597 | - else if(strncasecmp($name,'on',2)===0 && method_exists($this,$name)) |
|
597 | + else if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
598 | 598 | { |
599 | 599 | // getting an event (handler list) |
600 | 600 | $name=strtolower($name); |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | $this->_e[$name]=new TPriorityList; |
603 | 603 | return $this->_e[$name]; |
604 | 604 | } |
605 | - else if(strncasecmp($name,'fx',2)===0) |
|
605 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
606 | 606 | { |
607 | 607 | // getting a global event (handler list) |
608 | 608 | $name=strtolower($name); |
@@ -619,13 +619,13 @@ discard block |
||
619 | 619 | { |
620 | 620 | foreach($this->_m->toArray() as $behavior) |
621 | 621 | { |
622 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&& |
|
623 | - (property_exists($behavior,$name)||$behavior->canGetProperty($name)||$behavior->hasEvent($name))) |
|
622 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && |
|
623 | + (property_exists($behavior, $name) || $behavior->canGetProperty($name) || $behavior->hasEvent($name))) |
|
624 | 624 | return $behavior->$name; |
625 | 625 | } |
626 | 626 | } |
627 | 627 | } |
628 | - throw new TInvalidOperationException('component_property_undefined',get_class($this),$name); |
|
628 | + throw new TInvalidOperationException('component_property_undefined', get_class($this), $name); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
@@ -643,31 +643,31 @@ discard block |
||
643 | 643 | * @param mixed the property value or event handler |
644 | 644 | * @throws TInvalidOperationException If the property is not defined or read-only. |
645 | 645 | */ |
646 | - public function __set($name,$value) |
|
646 | + public function __set($name, $value) |
|
647 | 647 | { |
648 | - if(method_exists($this,$setter='set'.$name)) |
|
648 | + if(method_exists($this, $setter='set'.$name)) |
|
649 | 649 | { |
650 | - if(strncasecmp($name,'js',2)===0&&$value&&!($value instanceof TJavaScriptLiteral)) |
|
651 | - $value = new TJavaScriptLiteral($value); |
|
650 | + if(strncasecmp($name, 'js', 2)===0 && $value && !($value instanceof TJavaScriptLiteral)) |
|
651 | + $value=new TJavaScriptLiteral($value); |
|
652 | 652 | return $this->$setter($value); |
653 | 653 | } |
654 | - else if(method_exists($this,$jssetter='setjs'.$name)) |
|
654 | + else if(method_exists($this, $jssetter='setjs'.$name)) |
|
655 | 655 | { |
656 | - if($value&&!($value instanceof TJavaScriptString)) |
|
656 | + if($value && !($value instanceof TJavaScriptString)) |
|
657 | 657 | $value=new TJavaScriptString($value); |
658 | 658 | return $this->$jssetter($value); |
659 | 659 | } |
660 | - else if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0) |
|
660 | + else if((strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2)===0) |
|
661 | 661 | { |
662 | - return $this->attachEventHandler($name,$value); |
|
662 | + return $this->attachEventHandler($name, $value); |
|
663 | 663 | } |
664 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
664 | + else if($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
665 | 665 | { |
666 | 666 | $sets=0; |
667 | 667 | foreach($this->_m->toArray() as $behavior) |
668 | 668 | { |
669 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&& |
|
670 | - (property_exists($behavior,$name)||$behavior->canSetProperty($name)||$behavior->hasEvent($name))) { |
|
669 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && |
|
670 | + (property_exists($behavior, $name) || $behavior->canSetProperty($name) || $behavior->hasEvent($name))) { |
|
671 | 671 | $behavior->$name=$value; |
672 | 672 | $sets++; |
673 | 673 | } |
@@ -676,13 +676,13 @@ discard block |
||
676 | 676 | |
677 | 677 | } |
678 | 678 | |
679 | - if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name)) |
|
679 | + if(method_exists($this, 'get'.$name) || method_exists($this, 'getjs'.$name)) |
|
680 | 680 | { |
681 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
|
681 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
|
682 | 682 | } |
683 | 683 | else |
684 | 684 | { |
685 | - throw new TInvalidOperationException('component_property_undefined',get_class($this),$name); |
|
685 | + throw new TInvalidOperationException('component_property_undefined', get_class($this), $name); |
|
686 | 686 | } |
687 | 687 | } |
688 | 688 | |
@@ -700,27 +700,27 @@ discard block |
||
700 | 700 | */ |
701 | 701 | public function __isset($name) |
702 | 702 | { |
703 | - if(method_exists($this,$getter='get'.$name)) |
|
703 | + if(method_exists($this, $getter='get'.$name)) |
|
704 | 704 | return $this->$getter()!==null; |
705 | - else if(method_exists($this,$jsgetter='getjs'.$name)) |
|
705 | + else if(method_exists($this, $jsgetter='getjs'.$name)) |
|
706 | 706 | return $this->$jsgetter()!==null; |
707 | - else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name)) |
|
707 | + else if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
708 | 708 | { |
709 | 709 | $name=strtolower($name); |
710 | - return isset($this->_e[$name])&&$this->_e[$name]->getCount(); |
|
710 | + return isset($this->_e[$name]) && $this->_e[$name]->getCount(); |
|
711 | 711 | } |
712 | - else if(strncasecmp($name,'fx',2)===0) |
|
712 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
713 | 713 | { |
714 | 714 | $name=strtolower($name); |
715 | - return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount(); |
|
715 | + return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount(); |
|
716 | 716 | } |
717 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
717 | + else if($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
718 | 718 | { |
719 | 719 | if(isset($this->_m[$name])) |
720 | 720 | return true; |
721 | 721 | foreach($this->_m->toArray() as $behavior) |
722 | 722 | { |
723 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())) |
|
723 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled())) |
|
724 | 724 | return isset($behavior->$name); |
725 | 725 | } |
726 | 726 | |
@@ -741,15 +741,15 @@ discard block |
||
741 | 741 | */ |
742 | 742 | public function __unset($name) |
743 | 743 | { |
744 | - if(method_exists($this,$setter='set'.$name)) |
|
744 | + if(method_exists($this, $setter='set'.$name)) |
|
745 | 745 | $this->$setter(null); |
746 | - else if(method_exists($this,$jssetter='setjs'.$name)) |
|
746 | + else if(method_exists($this, $jssetter='setjs'.$name)) |
|
747 | 747 | $this->$jssetter(null); |
748 | - else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name)) |
|
748 | + else if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
749 | 749 | $this->_e[strtolower($name)]->clear(); |
750 | - else if(strncasecmp($name,'fx',2)===0) |
|
750 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
751 | 751 | $this->getEventHandlers($name)->remove(array($this, $name)); |
752 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
752 | + else if($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
753 | 753 | { |
754 | 754 | if(isset($this->_m[$name])) |
755 | 755 | $this->detachBehavior($name); |
@@ -757,16 +757,16 @@ discard block |
||
757 | 757 | $unset=0; |
758 | 758 | foreach($this->_m->toArray() as $behavior) |
759 | 759 | { |
760 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())) { |
|
760 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled())) { |
|
761 | 761 | unset($behavior->$name); |
762 | 762 | $unset++; |
763 | 763 | } |
764 | 764 | } |
765 | - if(!$unset&&method_exists($this,'get'.$name)) |
|
766 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
|
765 | + if(!$unset && method_exists($this, 'get'.$name)) |
|
766 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
|
767 | 767 | } |
768 | - } else if(method_exists($this,'get'.$name)) |
|
769 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
|
768 | + } else if(method_exists($this, 'get'.$name)) |
|
769 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | /** |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | */ |
779 | 779 | public function hasProperty($name) |
780 | 780 | { |
781 | - return $this->canGetProperty($name)||$this->canSetProperty($name); |
|
781 | + return $this->canGetProperty($name) || $this->canSetProperty($name); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | /** |
@@ -792,13 +792,13 @@ discard block |
||
792 | 792 | */ |
793 | 793 | public function canGetProperty($name) |
794 | 794 | { |
795 | - if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name)) |
|
795 | + if(method_exists($this, 'get'.$name) || method_exists($this, 'getjs'.$name)) |
|
796 | 796 | return true; |
797 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
797 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
798 | 798 | { |
799 | 799 | foreach($this->_m->toArray() as $behavior) |
800 | 800 | { |
801 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canGetProperty($name)) |
|
801 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canGetProperty($name)) |
|
802 | 802 | return true; |
803 | 803 | } |
804 | 804 | } |
@@ -816,13 +816,13 @@ discard block |
||
816 | 816 | */ |
817 | 817 | public function canSetProperty($name) |
818 | 818 | { |
819 | - if(method_exists($this,'set'.$name)||method_exists($this,'setjs'.$name)) |
|
819 | + if(method_exists($this, 'set'.$name) || method_exists($this, 'setjs'.$name)) |
|
820 | 820 | return true; |
821 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
821 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
822 | 822 | { |
823 | 823 | foreach($this->_m->toArray() as $behavior) |
824 | 824 | { |
825 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canSetProperty($name)) |
|
825 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canSetProperty($name)) |
|
826 | 826 | return true; |
827 | 827 | } |
828 | 828 | } |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | public function getSubProperty($path) |
843 | 843 | { |
844 | 844 | $object=$this; |
845 | - foreach(explode('.',$path) as $property) |
|
845 | + foreach(explode('.', $path) as $property) |
|
846 | 846 | $object=$object->$property; |
847 | 847 | return $object; |
848 | 848 | } |
@@ -857,15 +857,15 @@ discard block |
||
857 | 857 | * @param string property path |
858 | 858 | * @param mixed the property path value |
859 | 859 | */ |
860 | - public function setSubProperty($path,$value) |
|
860 | + public function setSubProperty($path, $value) |
|
861 | 861 | { |
862 | 862 | $object=$this; |
863 | - if(($pos=strrpos($path,'.'))===false) |
|
863 | + if(($pos=strrpos($path, '.'))===false) |
|
864 | 864 | $property=$path; |
865 | 865 | else |
866 | 866 | { |
867 | - $object=$this->getSubProperty(substr($path,0,$pos)); |
|
868 | - $property=substr($path,$pos+1); |
|
867 | + $object=$this->getSubProperty(substr($path, 0, $pos)); |
|
868 | + $property=substr($path, $pos + 1); |
|
869 | 869 | } |
870 | 870 | $object->$property=$value; |
871 | 871 | } |
@@ -884,14 +884,14 @@ discard block |
||
884 | 884 | */ |
885 | 885 | public function hasEvent($name) |
886 | 886 | { |
887 | - if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0||strncasecmp($name,'dy',2)===0) |
|
887 | + if((strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2)===0 || strncasecmp($name, 'dy', 2)===0) |
|
888 | 888 | return true; |
889 | 889 | |
890 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
890 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
891 | 891 | { |
892 | 892 | foreach($this->_m->toArray() as $behavior) |
893 | 893 | { |
894 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name)) |
|
894 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name)) |
|
895 | 895 | return true; |
896 | 896 | } |
897 | 897 | } |
@@ -908,16 +908,16 @@ discard block |
||
908 | 908 | public function hasEventHandler($name) |
909 | 909 | { |
910 | 910 | $name=strtolower($name); |
911 | - if(strncasecmp($name,'fx',2)===0) |
|
912 | - return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount()>0; |
|
911 | + if(strncasecmp($name, 'fx', 2)===0) |
|
912 | + return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount() > 0; |
|
913 | 913 | else |
914 | 914 | { |
915 | - if(isset($this->_e[$name])&&$this->_e[$name]->getCount()>0) |
|
915 | + if(isset($this->_e[$name]) && $this->_e[$name]->getCount() > 0) |
|
916 | 916 | return true; |
917 | - else if($this->_m!==null&&$this->_behaviorsenabled) { |
|
917 | + else if($this->_m!==null && $this->_behaviorsenabled) { |
|
918 | 918 | foreach($this->_m->toArray() as $behavior) |
919 | 919 | { |
920 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEventHandler($name)) |
|
920 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEventHandler($name)) |
|
921 | 921 | return true; |
922 | 922 | } |
923 | 923 | } |
@@ -933,29 +933,29 @@ discard block |
||
933 | 933 | */ |
934 | 934 | public function getEventHandlers($name) |
935 | 935 | { |
936 | - if(strncasecmp($name,'on',2)===0&&method_exists($this,$name)) |
|
936 | + if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
937 | 937 | { |
938 | 938 | $name=strtolower($name); |
939 | 939 | if(!isset($this->_e[$name])) |
940 | 940 | $this->_e[$name]=new TPriorityList; |
941 | 941 | return $this->_e[$name]; |
942 | 942 | } |
943 | - else if(strncasecmp($name,'fx',2)===0) |
|
943 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
944 | 944 | { |
945 | 945 | $name=strtolower($name); |
946 | 946 | if(!isset(self::$_ue[$name])) |
947 | 947 | self::$_ue[$name]=new TPriorityList; |
948 | 948 | return self::$_ue[$name]; |
949 | 949 | } |
950 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
950 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
951 | 951 | { |
952 | 952 | foreach($this->_m->toArray() as $behavior) |
953 | 953 | { |
954 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name)) |
|
954 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name)) |
|
955 | 955 | return $behavior->getEventHandlers($name); |
956 | 956 | } |
957 | 957 | } |
958 | - throw new TInvalidOperationException('component_event_undefined',get_class($this),$name); |
|
958 | + throw new TInvalidOperationException('component_event_undefined', get_class($this), $name); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | /** |
@@ -1003,9 +1003,9 @@ discard block |
||
1003 | 1003 | * default priority of 10.0 within {@link TPriorityList} |
1004 | 1004 | * @throws TInvalidOperationException if the event does not exist |
1005 | 1005 | */ |
1006 | - public function attachEventHandler($name,$handler,$priority=null) |
|
1006 | + public function attachEventHandler($name, $handler, $priority=null) |
|
1007 | 1007 | { |
1008 | - $this->getEventHandlers($name)->add($handler,$priority); |
|
1008 | + $this->getEventHandlers($name)->add($handler, $priority); |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | /** |
@@ -1018,13 +1018,13 @@ discard block |
||
1018 | 1018 | * to an item of any priority within {@link TPriorityList}; null means the default priority |
1019 | 1019 | * @return boolean if the removal is successful |
1020 | 1020 | */ |
1021 | - public function detachEventHandler($name,$handler,$priority=false) |
|
1021 | + public function detachEventHandler($name, $handler, $priority=false) |
|
1022 | 1022 | { |
1023 | 1023 | if($this->hasEventHandler($name)) |
1024 | 1024 | { |
1025 | 1025 | try |
1026 | 1026 | { |
1027 | - $this->getEventHandlers($name)->remove($handler,$priority); |
|
1027 | + $this->getEventHandlers($name)->remove($handler, $priority); |
|
1028 | 1028 | return true; |
1029 | 1029 | } |
1030 | 1030 | catch(Exception $e) |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | * @throws TInvalidOperationException if the event is undefined |
1107 | 1107 | * @throws TInvalidDataValueException If an event handler is invalid |
1108 | 1108 | */ |
1109 | - public function raiseEvent($name,$sender,$param,$responsetype=null,$postfunction=null) |
|
1109 | + public function raiseEvent($name, $sender, $param, $responsetype=null, $postfunction=null) |
|
1110 | 1110 | { |
1111 | 1111 | $p=$param; |
1112 | 1112 | if(is_callable($responsetype)) |
@@ -1121,90 +1121,90 @@ discard block |
||
1121 | 1121 | $name=strtolower($name); |
1122 | 1122 | $responses=array(); |
1123 | 1123 | |
1124 | - $name=$this->dyPreRaiseEvent($name,$sender,$param,$responsetype,$postfunction); |
|
1124 | + $name=$this->dyPreRaiseEvent($name, $sender, $param, $responsetype, $postfunction); |
|
1125 | 1125 | |
1126 | - if($this->hasEventHandler($name)||$this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
1126 | + if($this->hasEventHandler($name) || $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
1127 | 1127 | { |
1128 | 1128 | $handlers=$this->getEventHandlers($name); |
1129 | 1129 | $handlerArray=$handlers->toArray(); |
1130 | - if(strncasecmp($name,'fx',2)===0&&$this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
1130 | + if(strncasecmp($name, 'fx', 2)===0 && $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
1131 | 1131 | { |
1132 | 1132 | $globalhandlers=$this->getEventHandlers(TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
1133 | - $handlerArray=array_merge($globalhandlers->toArrayBelowPriority(0),$handlerArray,$globalhandlers->toArrayAbovePriority(0)); |
|
1133 | + $handlerArray=array_merge($globalhandlers->toArrayBelowPriority(0), $handlerArray, $globalhandlers->toArrayAbovePriority(0)); |
|
1134 | 1134 | } |
1135 | 1135 | $response=null; |
1136 | 1136 | foreach($handlerArray as $handler) |
1137 | 1137 | { |
1138 | - if($this->dyIntraRaiseEventTestHandler($handler,$sender,$param,$name)===false) |
|
1138 | + if($this->dyIntraRaiseEventTestHandler($handler, $sender, $param, $name)===false) |
|
1139 | 1139 | continue; |
1140 | 1140 | |
1141 | 1141 | if(is_string($handler)) |
1142 | 1142 | { |
1143 | - if(($pos=strrpos($handler,'.'))!==false) |
|
1143 | + if(($pos=strrpos($handler, '.'))!==false) |
|
1144 | 1144 | { |
1145 | - $object=$this->getSubProperty(substr($handler,0,$pos)); |
|
1146 | - $method=substr($handler,$pos+1); |
|
1147 | - if(method_exists($object,$method)||strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0) |
|
1145 | + $object=$this->getSubProperty(substr($handler, 0, $pos)); |
|
1146 | + $method=substr($handler, $pos + 1); |
|
1147 | + if(method_exists($object, $method) || strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
1148 | 1148 | { |
1149 | 1149 | if($method=='__dycall') |
1150 | - $response=$object->__dycall($name,array($sender,$param,$name)); |
|
1150 | + $response=$object->__dycall($name, array($sender, $param, $name)); |
|
1151 | 1151 | else |
1152 | - $response=$object->$method($sender,$param,$name); |
|
1152 | + $response=$object->$method($sender, $param, $name); |
|
1153 | 1153 | } |
1154 | 1154 | else |
1155 | - throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler); |
|
1155 | + throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler); |
|
1156 | 1156 | } |
1157 | 1157 | else |
1158 | - $response=call_user_func($handler,$sender,$param,$name); |
|
1158 | + $response=call_user_func($handler, $sender, $param, $name); |
|
1159 | 1159 | } |
1160 | - else if(is_callable($handler,true)) |
|
1160 | + else if(is_callable($handler, true)) |
|
1161 | 1161 | { |
1162 | - list($object,$method)=$handler; |
|
1162 | + list($object, $method)=$handler; |
|
1163 | 1163 | if(is_string($object)) |
1164 | - $response=call_user_func($handler,$sender,$param,$name); |
|
1164 | + $response=call_user_func($handler, $sender, $param, $name); |
|
1165 | 1165 | else |
1166 | 1166 | { |
1167 | - if(($pos=strrpos($method,'.'))!==false) |
|
1167 | + if(($pos=strrpos($method, '.'))!==false) |
|
1168 | 1168 | { |
1169 | - $object=$this->getSubProperty(substr($method,0,$pos)); |
|
1170 | - $method=substr($method,$pos+1); |
|
1169 | + $object=$this->getSubProperty(substr($method, 0, $pos)); |
|
1170 | + $method=substr($method, $pos + 1); |
|
1171 | 1171 | } |
1172 | - if(method_exists($object,$method)||strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0) |
|
1172 | + if(method_exists($object, $method) || strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
1173 | 1173 | { |
1174 | 1174 | if($method=='__dycall') |
1175 | - $response=$object->__dycall($name,array($sender,$param,$name)); |
|
1175 | + $response=$object->__dycall($name, array($sender, $param, $name)); |
|
1176 | 1176 | else |
1177 | - $response=$object->$method($sender,$param,$name); |
|
1177 | + $response=$object->$method($sender, $param, $name); |
|
1178 | 1178 | } |
1179 | 1179 | else |
1180 | - throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler[1]); |
|
1180 | + throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler[1]); |
|
1181 | 1181 | } |
1182 | 1182 | } |
1183 | 1183 | else |
1184 | - throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,gettype($handler)); |
|
1184 | + throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, gettype($handler)); |
|
1185 | 1185 | |
1186 | - $this->dyIntraRaiseEventPostHandler($name,$sender,$param,$handler,$response); |
|
1186 | + $this->dyIntraRaiseEventPostHandler($name, $sender, $param, $handler, $response); |
|
1187 | 1187 | |
1188 | 1188 | if($postfunction) |
1189 | - $response=call_user_func_array($postfunction,array($sender,$param,$this,$response)); |
|
1189 | + $response=call_user_func_array($postfunction, array($sender, $param, $this, $response)); |
|
1190 | 1190 | |
1191 | - if($responsetype&TEventResults::EVENT_RESULT_ALL) |
|
1192 | - $responses[]=array('sender'=>$sender,'param'=>$param,'response'=>$response); |
|
1191 | + if($responsetype & TEventResults::EVENT_RESULT_ALL) |
|
1192 | + $responses[]=array('sender'=>$sender, 'param'=>$param, 'response'=>$response); |
|
1193 | 1193 | else |
1194 | 1194 | $responses[]=$response; |
1195 | 1195 | |
1196 | - if($response!==null&&($responsetype&TEventResults::EVENT_RESULT_FEED_FORWARD)) |
|
1196 | + if($response!==null && ($responsetype & TEventResults::EVENT_RESULT_FEED_FORWARD)) |
|
1197 | 1197 | $param=$response; |
1198 | 1198 | |
1199 | 1199 | } |
1200 | 1200 | } |
1201 | - else if(strncasecmp($name,'on',2)===0&&!$this->hasEvent($name)) |
|
1202 | - throw new TInvalidOperationException('component_event_undefined',get_class($this),$name); |
|
1201 | + else if(strncasecmp($name, 'on', 2)===0 && !$this->hasEvent($name)) |
|
1202 | + throw new TInvalidOperationException('component_event_undefined', get_class($this), $name); |
|
1203 | 1203 | |
1204 | - if($responsetype&TEventResults::EVENT_RESULT_FILTER) |
|
1204 | + if($responsetype & TEventResults::EVENT_RESULT_FILTER) |
|
1205 | 1205 | $responses=array_filter($responses); |
1206 | 1206 | |
1207 | - $responses=$this->dyPostRaiseEvent($responses,$name,$sender,$param,$responsetype,$postfunction); |
|
1207 | + $responses=$this->dyPostRaiseEvent($responses, $name, $sender, $param, $responsetype, $postfunction); |
|
1208 | 1208 | |
1209 | 1209 | return $responses; |
1210 | 1210 | } |
@@ -1237,7 +1237,7 @@ discard block |
||
1237 | 1237 | } |
1238 | 1238 | catch(Exception $e) |
1239 | 1239 | { |
1240 | - throw new TInvalidOperationException('component_expression_invalid',get_class($this),$expression,$e->getMessage()); |
|
1240 | + throw new TInvalidOperationException('component_expression_invalid', get_class($this), $expression, $e->getMessage()); |
|
1241 | 1241 | } |
1242 | 1242 | } |
1243 | 1243 | |
@@ -1272,7 +1272,7 @@ discard block |
||
1272 | 1272 | } |
1273 | 1273 | catch(Exception $e) |
1274 | 1274 | { |
1275 | - throw new TInvalidOperationException('component_statements_invalid',get_class($this),$statements,$e->getMessage()); |
|
1275 | + throw new TInvalidOperationException('component_statements_invalid', get_class($this), $statements, $e->getMessage()); |
|
1276 | 1276 | } |
1277 | 1277 | } |
1278 | 1278 | |
@@ -1332,9 +1332,9 @@ discard block |
||
1332 | 1332 | * @param $param TClassBehaviorEventParameter |
1333 | 1333 | * @since 3.2.3 |
1334 | 1334 | */ |
1335 | - public function fxAttachClassBehavior($sender,$param) { |
|
1336 | - if(in_array($param->getClass(),$this->getClassHierarchy(true))) |
|
1337 | - return $this->attachBehavior($param->getName(),$param->getBehavior(),$param->getPriority()); |
|
1335 | + public function fxAttachClassBehavior($sender, $param) { |
|
1336 | + if(in_array($param->getClass(), $this->getClassHierarchy(true))) |
|
1337 | + return $this->attachBehavior($param->getName(), $param->getBehavior(), $param->getPriority()); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | |
@@ -1346,9 +1346,9 @@ discard block |
||
1346 | 1346 | * @param $param TClassBehaviorEventParameter |
1347 | 1347 | * @since 3.2.3 |
1348 | 1348 | */ |
1349 | - public function fxDetachClassBehavior($sender,$param) { |
|
1350 | - if(in_array($param->getClass(),$this->getClassHierarchy(true))) |
|
1351 | - return $this->detachBehavior($param->getName(),$param->getPriority()); |
|
1349 | + public function fxDetachClassBehavior($sender, $param) { |
|
1350 | + if(in_array($param->getClass(), $this->getClassHierarchy(true))) |
|
1351 | + return $this->detachBehavior($param->getName(), $param->getPriority()); |
|
1352 | 1352 | } |
1353 | 1353 | |
1354 | 1354 | |
@@ -1370,8 +1370,8 @@ discard block |
||
1370 | 1370 | * @throws TInvalidOperationException if the class behavior is already defined |
1371 | 1371 | * @since 3.2.3 |
1372 | 1372 | */ |
1373 | - public static function attachClassBehavior($name,$behavior,$class=null,$priority=null) { |
|
1374 | - if(!$class&&function_exists('get_called_class')) |
|
1373 | + public static function attachClassBehavior($name, $behavior, $class=null, $priority=null) { |
|
1374 | + if(!$class && function_exists('get_called_class')) |
|
1375 | 1375 | $class=get_called_class(); |
1376 | 1376 | if(!$class) |
1377 | 1377 | throw new TInvalidOperationException('component_no_class_provided_nor_late_binding'); |
@@ -1384,11 +1384,11 @@ discard block |
||
1384 | 1384 | if(empty(self::$_um[$class])) |
1385 | 1385 | self::$_um[$class]=array(); |
1386 | 1386 | if(isset(self::$_um[$class][$name])) |
1387 | - throw new TInvalidOperationException('component_class_behavior_defined',$class,$name); |
|
1388 | - $param=new TClassBehaviorEventParameter($class,$name,$behavior,$priority); |
|
1389 | - self::$_um[$class]=array($name=>$param)+self::$_um[$class]; |
|
1390 | - $behaviorObject=is_string($behavior)?new $behavior:$behavior; |
|
1391 | - return $behaviorObject->raiseEvent('fxAttachClassBehavior',null,$param); |
|
1387 | + throw new TInvalidOperationException('component_class_behavior_defined', $class, $name); |
|
1388 | + $param=new TClassBehaviorEventParameter($class, $name, $behavior, $priority); |
|
1389 | + self::$_um[$class]=array($name=>$param) + self::$_um[$class]; |
|
1390 | + $behaviorObject=is_string($behavior) ? new $behavior : $behavior; |
|
1391 | + return $behaviorObject->raiseEvent('fxAttachClassBehavior', null, $param); |
|
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | |
@@ -1404,8 +1404,8 @@ discard block |
||
1404 | 1404 | * not supplied as a parameter. |
1405 | 1405 | * @since 3.2.3 |
1406 | 1406 | */ |
1407 | - public static function detachClassBehavior($name,$class=null,$priority=false) { |
|
1408 | - if(!$class&&function_exists('get_called_class')) |
|
1407 | + public static function detachClassBehavior($name, $class=null, $priority=false) { |
|
1408 | + if(!$class && function_exists('get_called_class')) |
|
1409 | 1409 | $class=get_called_class(); |
1410 | 1410 | if(!$class) |
1411 | 1411 | throw new TInvalidOperationException('component_no_class_provided_nor_late_binding'); |
@@ -1413,13 +1413,13 @@ discard block |
||
1413 | 1413 | $class=strtolower($class); |
1414 | 1414 | if(!is_string($name)) |
1415 | 1415 | $name=get_class($name); |
1416 | - if(empty(self::$_um[$class])||!isset(self::$_um[$class][$name])) |
|
1416 | + if(empty(self::$_um[$class]) || !isset(self::$_um[$class][$name])) |
|
1417 | 1417 | return false; |
1418 | 1418 | $param=self::$_um[$class][$name]; |
1419 | 1419 | $behavior=$param->getBehavior(); |
1420 | 1420 | unset(self::$_um[$class][$name]); |
1421 | - $behaviorObject=is_string($behavior)?new $behavior:$behavior; |
|
1422 | - return $behaviorObject->raiseEvent('fxDetachClassBehavior',null,$param); |
|
1421 | + $behaviorObject=is_string($behavior) ? new $behavior : $behavior; |
|
1422 | + return $behaviorObject->raiseEvent('fxDetachClassBehavior', null, $param); |
|
1423 | 1423 | } |
1424 | 1424 | |
1425 | 1425 | /** |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | */ |
1432 | 1432 | public function asa($behaviorname) |
1433 | 1433 | { |
1434 | - return isset($this->_m[$behaviorname])?$this->_m[$behaviorname]:null; |
|
1434 | + return isset($this->_m[$behaviorname]) ? $this->_m[$behaviorname] : null; |
|
1435 | 1435 | } |
1436 | 1436 | |
1437 | 1437 | /** |
@@ -1457,15 +1457,15 @@ discard block |
||
1457 | 1457 | { |
1458 | 1458 | if($this instanceof $class) |
1459 | 1459 | return true; |
1460 | - if($this->_m!==null&&$this->_behaviorsenabled) |
|
1461 | - foreach($this->_m->toArray() as $behavior){ |
|
1462 | - if(($behavior instanceof IBehavior)&&!$behavior->getEnabled()) |
|
1460 | + if($this->_m!==null && $this->_behaviorsenabled) |
|
1461 | + foreach($this->_m->toArray() as $behavior) { |
|
1462 | + if(($behavior instanceof IBehavior) && !$behavior->getEnabled()) |
|
1463 | 1463 | continue; |
1464 | 1464 | |
1465 | - $check = null; |
|
1466 | - if(($behavior->isa('IInstanceCheck'))&&$check=$behavior->isinstanceof($class,$this)) |
|
1465 | + $check=null; |
|
1466 | + if(($behavior->isa('IInstanceCheck')) && $check=$behavior->isinstanceof($class, $this)) |
|
1467 | 1467 | return true; |
1468 | - if($check===null&&($behavior->isa($class))) |
|
1468 | + if($check===null && ($behavior->isa($class))) |
|
1469 | 1469 | return true; |
1470 | 1470 | } |
1471 | 1471 | return false; |
@@ -1483,9 +1483,9 @@ discard block |
||
1483 | 1483 | { |
1484 | 1484 | foreach($behaviors as $name=>$behavior) |
1485 | 1485 | if($behavior instanceof TClassBehaviorEventParameter) |
1486 | - $this->attachBehavior($behavior->getName(),$behavior->getBehavior(),$behavior->getPriority()); |
|
1486 | + $this->attachBehavior($behavior->getName(), $behavior->getBehavior(), $behavior->getPriority()); |
|
1487 | 1487 | else |
1488 | - $this->attachBehavior($name,$behavior); |
|
1488 | + $this->attachBehavior($name, $behavior); |
|
1489 | 1489 | } |
1490 | 1490 | |
1491 | 1491 | /** |
@@ -1502,9 +1502,9 @@ discard block |
||
1502 | 1502 | { |
1503 | 1503 | foreach($behaviors as $name=>$behavior) |
1504 | 1504 | if($behavior instanceof TClassBehaviorEventParameter) |
1505 | - $this->detachBehavior($behavior->getName(),$behavior->getPriority()); |
|
1505 | + $this->detachBehavior($behavior->getName(), $behavior->getPriority()); |
|
1506 | 1506 | else |
1507 | - $this->detachBehavior(is_string($behavior)?$behavior:$name); |
|
1507 | + $this->detachBehavior(is_string($behavior) ? $behavior : $name); |
|
1508 | 1508 | } |
1509 | 1509 | } |
1510 | 1510 | |
@@ -1542,19 +1542,19 @@ discard block |
||
1542 | 1542 | * @return IBehavior the behavior object |
1543 | 1543 | * @since 3.2.3 |
1544 | 1544 | */ |
1545 | - public function attachBehavior($name,$behavior,$priority=null) |
|
1545 | + public function attachBehavior($name, $behavior, $priority=null) |
|
1546 | 1546 | { |
1547 | 1547 | if(is_string($behavior)) |
1548 | 1548 | $behavior=Prado::createComponent($behavior); |
1549 | 1549 | if(!($behavior instanceof IBaseBehavior)) |
1550 | - throw new TInvalidDataTypeException('component_not_a_behavior',get_class($behavior)); |
|
1550 | + throw new TInvalidDataTypeException('component_not_a_behavior', get_class($behavior)); |
|
1551 | 1551 | if($behavior instanceof IBehavior) |
1552 | 1552 | $behavior->setEnabled(true); |
1553 | 1553 | if($this->_m===null) |
1554 | 1554 | $this->_m=new TPriorityMap; |
1555 | 1555 | $behavior->attach($this); |
1556 | - $this->dyAttachBehavior($name,$behavior); |
|
1557 | - $this->_m->add($name,$behavior,$priority); |
|
1556 | + $this->dyAttachBehavior($name, $behavior); |
|
1557 | + $this->_m->add($name, $behavior, $priority); |
|
1558 | 1558 | return $behavior; |
1559 | 1559 | } |
1560 | 1560 | |
@@ -1575,14 +1575,14 @@ discard block |
||
1575 | 1575 | * @return IBehavior the detached behavior. Null if the behavior does not exist. |
1576 | 1576 | * @since 3.2.3 |
1577 | 1577 | */ |
1578 | - public function detachBehavior($name,$priority=false) |
|
1578 | + public function detachBehavior($name, $priority=false) |
|
1579 | 1579 | { |
1580 | - if($this->_m!=null&&isset($this->_m[$name])) |
|
1580 | + if($this->_m!=null && isset($this->_m[$name])) |
|
1581 | 1581 | { |
1582 | 1582 | $this->_m[$name]->detach($this); |
1583 | 1583 | $behavior=$this->_m->itemAt($name); |
1584 | - $this->_m->remove($name,$priority); |
|
1585 | - $this->dyDetachBehavior($name,$behavior); |
|
1584 | + $this->_m->remove($name, $priority); |
|
1585 | + $this->dyDetachBehavior($name, $behavior); |
|
1586 | 1586 | return $behavior; |
1587 | 1587 | } |
1588 | 1588 | } |
@@ -1658,10 +1658,10 @@ discard block |
||
1658 | 1658 | */ |
1659 | 1659 | public function enableBehavior($name) |
1660 | 1660 | { |
1661 | - if($this->_m!=null&&isset($this->_m[$name])){ |
|
1661 | + if($this->_m!=null && isset($this->_m[$name])) { |
|
1662 | 1662 | if($this->_m[$name] instanceof IBehavior) { |
1663 | 1663 | $this->_m[$name]->setEnabled(true); |
1664 | - $this->dyEnableBehavior($name,$this->_m[$name]); |
|
1664 | + $this->dyEnableBehavior($name, $this->_m[$name]); |
|
1665 | 1665 | return true; |
1666 | 1666 | } |
1667 | 1667 | return false; |
@@ -1686,10 +1686,10 @@ discard block |
||
1686 | 1686 | */ |
1687 | 1687 | public function disableBehavior($name) |
1688 | 1688 | { |
1689 | - if($this->_m!=null&&isset($this->_m[$name])){ |
|
1689 | + if($this->_m!=null && isset($this->_m[$name])) { |
|
1690 | 1690 | if($this->_m[$name] instanceof IBehavior) { |
1691 | 1691 | $this->_m[$name]->setEnabled(false); |
1692 | - $this->dyDisableBehavior($name,$this->_m[$name]); |
|
1692 | + $this->dyDisableBehavior($name, $this->_m[$name]); |
|
1693 | 1693 | return true; |
1694 | 1694 | } |
1695 | 1695 | return false; |
@@ -1704,9 +1704,9 @@ discard block |
||
1704 | 1704 | */ |
1705 | 1705 | public function __sleep() |
1706 | 1706 | { |
1707 | - $a = (array)$this; |
|
1708 | - $a = array_keys($a); |
|
1709 | - $exprops = array(); |
|
1707 | + $a=(array) $this; |
|
1708 | + $a=array_keys($a); |
|
1709 | + $exprops=array(); |
|
1710 | 1710 | $this->__getZappableSleepProps($exprops); |
1711 | 1711 | return array_diff($a, $exprops); |
1712 | 1712 | } |
@@ -1720,13 +1720,13 @@ discard block |
||
1720 | 1720 | protected function __getZappableSleepProps(&$exprops) |
1721 | 1721 | { |
1722 | 1722 | if($this->_listeningenabled===false) |
1723 | - $exprops[] = "\0TComponent\0_listeningenabled"; |
|
1723 | + $exprops[]="\0TComponent\0_listeningenabled"; |
|
1724 | 1724 | if($this->_behaviorsenabled===true) |
1725 | - $exprops[] = "\0TComponent\0_behaviorsenabled"; |
|
1726 | - if ($this->_e===array()) |
|
1727 | - $exprops[] = "\0TComponent\0_e"; |
|
1728 | - if ($this->_m===null) |
|
1729 | - $exprops[] = "\0TComponent\0_m"; |
|
1725 | + $exprops[]="\0TComponent\0_behaviorsenabled"; |
|
1726 | + if($this->_e===array()) |
|
1727 | + $exprops[]="\0TComponent\0_e"; |
|
1728 | + if($this->_m===null) |
|
1729 | + $exprops[]="\0TComponent\0_m"; |
|
1730 | 1730 | } |
1731 | 1731 | } |
1732 | 1732 | |
@@ -1742,7 +1742,7 @@ discard block |
||
1742 | 1742 | */ |
1743 | 1743 | interface IDynamicMethods |
1744 | 1744 | { |
1745 | - public function __dycall($method,$args); |
|
1745 | + public function __dycall($method, $args); |
|
1746 | 1746 | } |
1747 | 1747 | |
1748 | 1748 | |
@@ -1769,7 +1769,7 @@ discard block |
||
1769 | 1769 | * @param string $name the name of the behavior |
1770 | 1770 | * @param object $behavior this is the behavior to implement the class behavior |
1771 | 1771 | */ |
1772 | - public function __construct($class,$name,$behavior,$priority) |
|
1772 | + public function __construct($class, $name, $behavior, $priority) |
|
1773 | 1773 | { |
1774 | 1774 | $this->_class=$class; |
1775 | 1775 | $this->_name=$name; |
@@ -1910,10 +1910,10 @@ discard block |
||
1910 | 1910 | */ |
1911 | 1911 | public static function ensureBoolean($value) |
1912 | 1912 | { |
1913 | - if (is_string($value)) |
|
1914 | - return strcasecmp($value,'true')==0 || $value!=0; |
|
1913 | + if(is_string($value)) |
|
1914 | + return strcasecmp($value, 'true')==0 || $value!=0; |
|
1915 | 1915 | else |
1916 | - return (boolean)$value; |
|
1916 | + return (boolean) $value; |
|
1917 | 1917 | } |
1918 | 1918 | |
1919 | 1919 | /** |
@@ -1925,12 +1925,12 @@ discard block |
||
1925 | 1925 | */ |
1926 | 1926 | public static function ensureString($value) |
1927 | 1927 | { |
1928 | - if (TJavaScript::isJsLiteral($value)) |
|
1928 | + if(TJavaScript::isJsLiteral($value)) |
|
1929 | 1929 | return $value; |
1930 | - if (is_bool($value)) |
|
1931 | - return $value?'true':'false'; |
|
1930 | + if(is_bool($value)) |
|
1931 | + return $value ? 'true' : 'false'; |
|
1932 | 1932 | else |
1933 | - return (string)$value; |
|
1933 | + return (string) $value; |
|
1934 | 1934 | } |
1935 | 1935 | |
1936 | 1936 | /** |
@@ -1940,7 +1940,7 @@ discard block |
||
1940 | 1940 | */ |
1941 | 1941 | public static function ensureInteger($value) |
1942 | 1942 | { |
1943 | - return (integer)$value; |
|
1943 | + return (integer) $value; |
|
1944 | 1944 | } |
1945 | 1945 | |
1946 | 1946 | /** |
@@ -1950,7 +1950,7 @@ discard block |
||
1950 | 1950 | */ |
1951 | 1951 | public static function ensureFloat($value) |
1952 | 1952 | { |
1953 | - return (float)$value; |
|
1953 | + return (float) $value; |
|
1954 | 1954 | } |
1955 | 1955 | |
1956 | 1956 | /** |
@@ -1966,18 +1966,18 @@ discard block |
||
1966 | 1966 | { |
1967 | 1967 | if(is_string($value)) |
1968 | 1968 | { |
1969 | - $value = trim($value); |
|
1970 | - $len = strlen($value); |
|
1971 | - if ($len >= 2 && $value[0] == '(' && $value[$len-1] == ')') |
|
1969 | + $value=trim($value); |
|
1970 | + $len=strlen($value); |
|
1971 | + if($len >= 2 && $value[0]=='(' && $value[$len - 1]==')') |
|
1972 | 1972 | { |
1973 | 1973 | eval('$array=array'.$value.';'); |
1974 | 1974 | return $array; |
1975 | 1975 | } |
1976 | 1976 | else |
1977 | - return $len>0?array($value):array(); |
|
1977 | + return $len > 0 ? array($value) : array(); |
|
1978 | 1978 | } |
1979 | 1979 | else |
1980 | - return (array)$value; |
|
1980 | + return (array) $value; |
|
1981 | 1981 | } |
1982 | 1982 | |
1983 | 1983 | /** |
@@ -1987,7 +1987,7 @@ discard block |
||
1987 | 1987 | */ |
1988 | 1988 | public static function ensureObject($value) |
1989 | 1989 | { |
1990 | - return (object)$value; |
|
1990 | + return (object) $value; |
|
1991 | 1991 | } |
1992 | 1992 | |
1993 | 1993 | /** |
@@ -2006,7 +2006,7 @@ discard block |
||
2006 | 2006 | * @return string the valid enumeration value |
2007 | 2007 | * @throws TInvalidDataValueException if the original value is not in the string array. |
2008 | 2008 | */ |
2009 | - public static function ensureEnum($value,$enums) |
|
2009 | + public static function ensureEnum($value, $enums) |
|
2010 | 2010 | { |
2011 | 2011 | static $types=array(); |
2012 | 2012 | if(func_num_args()===2 && is_string($enums)) |
@@ -2017,18 +2017,18 @@ discard block |
||
2017 | 2017 | return $value; |
2018 | 2018 | else |
2019 | 2019 | throw new TInvalidDataValueException( |
2020 | - 'propertyvalue_enumvalue_invalid',$value, |
|
2021 | - implode(' | ',$types[$enums]->getConstants())); |
|
2020 | + 'propertyvalue_enumvalue_invalid', $value, |
|
2021 | + implode(' | ', $types[$enums]->getConstants())); |
|
2022 | 2022 | } |
2023 | 2023 | else if(!is_array($enums)) |
2024 | 2024 | { |
2025 | 2025 | $enums=func_get_args(); |
2026 | 2026 | array_shift($enums); |
2027 | 2027 | } |
2028 | - if(in_array($value,$enums,true)) |
|
2028 | + if(in_array($value, $enums, true)) |
|
2029 | 2029 | return $value; |
2030 | 2030 | else |
2031 | - throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid',$value,implode(' | ',$enums)); |
|
2031 | + throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid', $value, implode(' | ', $enums)); |
|
2032 | 2032 | } |
2033 | 2033 | |
2034 | 2034 | /** |
@@ -2038,7 +2038,7 @@ discard block |
||
2038 | 2038 | */ |
2039 | 2039 | public static function ensureNullIfEmpty($value) |
2040 | 2040 | { |
2041 | - return empty($value)?null:$value; |
|
2041 | + return empty($value) ? null : $value; |
|
2042 | 2042 | } |
2043 | 2043 | } |
2044 | 2044 | |
@@ -2091,7 +2091,7 @@ discard block |
||
2091 | 2091 | */ |
2092 | 2092 | public function __construct($component) |
2093 | 2093 | { |
2094 | - if(is_string($component) && class_exists($component,false)) |
|
2094 | + if(is_string($component) && class_exists($component, false)) |
|
2095 | 2095 | $this->_className=$component; |
2096 | 2096 | else if(is_object($component)) |
2097 | 2097 | $this->_className=get_class($component); |
@@ -2104,14 +2104,14 @@ discard block |
||
2104 | 2104 | { |
2105 | 2105 | $methodName=$method->getName(); |
2106 | 2106 | return $method->getNumberOfRequiredParameters()===0 |
2107 | - && strncasecmp($methodName,'get',3)===0 |
|
2107 | + && strncasecmp($methodName, 'get', 3)===0 |
|
2108 | 2108 | && isset($methodName[3]); |
2109 | 2109 | } |
2110 | 2110 | |
2111 | 2111 | private function isEventMethod($method) |
2112 | 2112 | { |
2113 | 2113 | $methodName=$method->getName(); |
2114 | - return strncasecmp($methodName,'on',2)===0 |
|
2114 | + return strncasecmp($methodName, 'on', 2)===0 |
|
2115 | 2115 | && isset($methodName[2]); |
2116 | 2116 | } |
2117 | 2117 | |
@@ -2121,7 +2121,7 @@ discard block |
||
2121 | 2121 | $properties=array(); |
2122 | 2122 | $events=array(); |
2123 | 2123 | $methods=array(); |
2124 | - $isComponent=is_subclass_of($this->_className,'TComponent') || strcasecmp($this->_className,'TComponent')===0; |
|
2124 | + $isComponent=is_subclass_of($this->_className, 'TComponent') || strcasecmp($this->_className, 'TComponent')===0; |
|
2125 | 2125 | foreach($class->getMethods() as $method) |
2126 | 2126 | { |
2127 | 2127 | if($method->isPublic() || $method->isProtected()) |
@@ -2130,14 +2130,14 @@ discard block |
||
2130 | 2130 | if(!$method->isStatic() && $isComponent) |
2131 | 2131 | { |
2132 | 2132 | if($this->isPropertyMethod($method)) |
2133 | - $properties[substr($methodName,3)]=$method; |
|
2133 | + $properties[substr($methodName, 3)]=$method; |
|
2134 | 2134 | else if($this->isEventMethod($method)) |
2135 | 2135 | { |
2136 | 2136 | $methodName[0]='O'; |
2137 | 2137 | $events[$methodName]=$method; |
2138 | 2138 | } |
2139 | 2139 | } |
2140 | - if(strncmp($methodName,'__',2)!==0) |
|
2140 | + if(strncmp($methodName, '__', 2)!==0) |
|
2141 | 2141 | $methods[$methodName]=$method; |
2142 | 2142 | } |
2143 | 2143 | } |
@@ -2187,7 +2187,7 @@ discard block |
||
2187 | 2187 | protected function determinePropertyType($method) |
2188 | 2188 | { |
2189 | 2189 | $comment=$method->getDocComment(); |
2190 | - if(preg_match('/@return\\s+(.*?)\\s+/',$comment,$matches)) |
|
2190 | + if(preg_match('/@return\\s+(.*?)\\s+/', $comment, $matches)) |
|
2191 | 2191 | return $matches[1]; |
2192 | 2192 | else |
2193 | 2193 | return '{unknown}'; |
@@ -2345,7 +2345,7 @@ discard block |
||
2345 | 2345 | * @return boolean|null if the this or the instance is of type class. When null, no information could be derived and |
2346 | 2346 | * the default mechanisms take over. |
2347 | 2347 | */ |
2348 | - public function isinstanceof($class,$instance=null); |
|
2348 | + public function isinstanceof($class, $instance=null); |
|
2349 | 2349 | } |
2350 | 2350 | |
2351 | 2351 | /** |
@@ -2375,12 +2375,12 @@ discard block |
||
2375 | 2375 | |
2376 | 2376 | public function __construct($s) |
2377 | 2377 | { |
2378 | - $this->_s = $s; |
|
2378 | + $this->_s=$s; |
|
2379 | 2379 | } |
2380 | 2380 | |
2381 | 2381 | public function __toString() |
2382 | 2382 | { |
2383 | - return (string)$this->_s; |
|
2383 | + return (string) $this->_s; |
|
2384 | 2384 | } |
2385 | 2385 | |
2386 | 2386 | public function toJavaScriptLiteral() |
@@ -2400,7 +2400,7 @@ discard block |
||
2400 | 2400 | { |
2401 | 2401 | public function toJavaScriptLiteral() |
2402 | 2402 | { |
2403 | - return TJavaScript::jsonEncode((string)$this->_s,JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
2403 | + return TJavaScript::jsonEncode((string) $this->_s, JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
2404 | 2404 | } |
2405 | 2405 | } |
2406 | 2406 |
@@ -533,8 +533,7 @@ discard block |
||
533 | 533 | } |
534 | 534 | if($callchain->getCount()>0) |
535 | 535 | return call_user_func_array(array($callchain,'call'),$args); |
536 | - } |
|
537 | - else |
|
536 | + } else |
|
538 | 537 | { |
539 | 538 | foreach($this->_m->toArray() as $behavior) |
540 | 539 | { |
@@ -588,29 +587,25 @@ discard block |
||
588 | 587 | { |
589 | 588 | // getting a property |
590 | 589 | return $this->$getter(); |
591 | - } |
|
592 | - else if(method_exists($this,$jsgetter='getjs'.$name)) |
|
590 | + } else if(method_exists($this,$jsgetter='getjs'.$name)) |
|
593 | 591 | { |
594 | 592 | // getting a javascript property |
595 | 593 | return (string)$this->$jsgetter(); |
596 | - } |
|
597 | - else if(strncasecmp($name,'on',2)===0 && method_exists($this,$name)) |
|
594 | + } else if(strncasecmp($name,'on',2)===0 && method_exists($this,$name)) |
|
598 | 595 | { |
599 | 596 | // getting an event (handler list) |
600 | 597 | $name=strtolower($name); |
601 | 598 | if(!isset($this->_e[$name])) |
602 | 599 | $this->_e[$name]=new TPriorityList; |
603 | 600 | return $this->_e[$name]; |
604 | - } |
|
605 | - else if(strncasecmp($name,'fx',2)===0) |
|
601 | + } else if(strncasecmp($name,'fx',2)===0) |
|
606 | 602 | { |
607 | 603 | // getting a global event (handler list) |
608 | 604 | $name=strtolower($name); |
609 | 605 | if(!isset(self::$_ue[$name])) |
610 | 606 | self::$_ue[$name]=new TPriorityList; |
611 | 607 | return self::$_ue[$name]; |
612 | - } |
|
613 | - else if($this->_behaviorsenabled) |
|
608 | + } else if($this->_behaviorsenabled) |
|
614 | 609 | { |
615 | 610 | // getting a behavior property/event (handler list) |
616 | 611 | if(isset($this->_m[$name])) |
@@ -650,18 +645,15 @@ discard block |
||
650 | 645 | if(strncasecmp($name,'js',2)===0&&$value&&!($value instanceof TJavaScriptLiteral)) |
651 | 646 | $value = new TJavaScriptLiteral($value); |
652 | 647 | return $this->$setter($value); |
653 | - } |
|
654 | - else if(method_exists($this,$jssetter='setjs'.$name)) |
|
648 | + } else if(method_exists($this,$jssetter='setjs'.$name)) |
|
655 | 649 | { |
656 | 650 | if($value&&!($value instanceof TJavaScriptString)) |
657 | 651 | $value=new TJavaScriptString($value); |
658 | 652 | return $this->$jssetter($value); |
659 | - } |
|
660 | - else if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0) |
|
653 | + } else if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0) |
|
661 | 654 | { |
662 | 655 | return $this->attachEventHandler($name,$value); |
663 | - } |
|
664 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
656 | + } else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
665 | 657 | { |
666 | 658 | $sets=0; |
667 | 659 | foreach($this->_m->toArray() as $behavior) |
@@ -679,8 +671,7 @@ discard block |
||
679 | 671 | if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name)) |
680 | 672 | { |
681 | 673 | throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
682 | - } |
|
683 | - else |
|
674 | + } else |
|
684 | 675 | { |
685 | 676 | throw new TInvalidOperationException('component_property_undefined',get_class($this),$name); |
686 | 677 | } |
@@ -708,13 +699,11 @@ discard block |
||
708 | 699 | { |
709 | 700 | $name=strtolower($name); |
710 | 701 | return isset($this->_e[$name])&&$this->_e[$name]->getCount(); |
711 | - } |
|
712 | - else if(strncasecmp($name,'fx',2)===0) |
|
702 | + } else if(strncasecmp($name,'fx',2)===0) |
|
713 | 703 | { |
714 | 704 | $name=strtolower($name); |
715 | 705 | return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount(); |
716 | - } |
|
717 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
706 | + } else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
718 | 707 | { |
719 | 708 | if(isset($this->_m[$name])) |
720 | 709 | return true; |
@@ -724,8 +713,7 @@ discard block |
||
724 | 713 | return isset($behavior->$name); |
725 | 714 | } |
726 | 715 | |
727 | - } |
|
728 | - else |
|
716 | + } else |
|
729 | 717 | return false; |
730 | 718 | } |
731 | 719 | |
@@ -939,15 +927,13 @@ discard block |
||
939 | 927 | if(!isset($this->_e[$name])) |
940 | 928 | $this->_e[$name]=new TPriorityList; |
941 | 929 | return $this->_e[$name]; |
942 | - } |
|
943 | - else if(strncasecmp($name,'fx',2)===0) |
|
930 | + } else if(strncasecmp($name,'fx',2)===0) |
|
944 | 931 | { |
945 | 932 | $name=strtolower($name); |
946 | 933 | if(!isset(self::$_ue[$name])) |
947 | 934 | self::$_ue[$name]=new TPriorityList; |
948 | 935 | return self::$_ue[$name]; |
949 | - } |
|
950 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
936 | + } else if($this->_m!==null&&$this->_behaviorsenabled) |
|
951 | 937 | { |
952 | 938 | foreach($this->_m->toArray() as $behavior) |
953 | 939 | { |
@@ -1026,8 +1012,7 @@ discard block |
||
1026 | 1012 | { |
1027 | 1013 | $this->getEventHandlers($name)->remove($handler,$priority); |
1028 | 1014 | return true; |
1029 | - } |
|
1030 | - catch(Exception $e) |
|
1015 | + } catch(Exception $e) |
|
1031 | 1016 | { |
1032 | 1017 | } |
1033 | 1018 | } |
@@ -1150,14 +1135,11 @@ discard block |
||
1150 | 1135 | $response=$object->__dycall($name,array($sender,$param,$name)); |
1151 | 1136 | else |
1152 | 1137 | $response=$object->$method($sender,$param,$name); |
1153 | - } |
|
1154 | - else |
|
1138 | + } else |
|
1155 | 1139 | throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler); |
1156 | - } |
|
1157 | - else |
|
1140 | + } else |
|
1158 | 1141 | $response=call_user_func($handler,$sender,$param,$name); |
1159 | - } |
|
1160 | - else if(is_callable($handler,true)) |
|
1142 | + } else if(is_callable($handler,true)) |
|
1161 | 1143 | { |
1162 | 1144 | list($object,$method)=$handler; |
1163 | 1145 | if(is_string($object)) |
@@ -1175,12 +1157,10 @@ discard block |
||
1175 | 1157 | $response=$object->__dycall($name,array($sender,$param,$name)); |
1176 | 1158 | else |
1177 | 1159 | $response=$object->$method($sender,$param,$name); |
1178 | - } |
|
1179 | - else |
|
1160 | + } else |
|
1180 | 1161 | throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler[1]); |
1181 | 1162 | } |
1182 | - } |
|
1183 | - else |
|
1163 | + } else |
|
1184 | 1164 | throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,gettype($handler)); |
1185 | 1165 | |
1186 | 1166 | $this->dyIntraRaiseEventPostHandler($name,$sender,$param,$handler,$response); |
@@ -1197,8 +1177,7 @@ discard block |
||
1197 | 1177 | $param=$response; |
1198 | 1178 | |
1199 | 1179 | } |
1200 | - } |
|
1201 | - else if(strncasecmp($name,'on',2)===0&&!$this->hasEvent($name)) |
|
1180 | + } else if(strncasecmp($name,'on',2)===0&&!$this->hasEvent($name)) |
|
1202 | 1181 | throw new TInvalidOperationException('component_event_undefined',get_class($this),$name); |
1203 | 1182 | |
1204 | 1183 | if($responsetype&TEventResults::EVENT_RESULT_FILTER) |
@@ -1234,8 +1213,7 @@ discard block |
||
1234 | 1213 | if(eval("\$result=$expression;")===false) |
1235 | 1214 | throw new Exception(''); |
1236 | 1215 | return $result; |
1237 | - } |
|
1238 | - catch(Exception $e) |
|
1216 | + } catch(Exception $e) |
|
1239 | 1217 | { |
1240 | 1218 | throw new TInvalidOperationException('component_expression_invalid',get_class($this),$expression,$e->getMessage()); |
1241 | 1219 | } |
@@ -1269,8 +1247,7 @@ discard block |
||
1269 | 1247 | $content=ob_get_contents(); |
1270 | 1248 | ob_end_clean(); |
1271 | 1249 | return $content; |
1272 | - } |
|
1273 | - catch(Exception $e) |
|
1250 | + } catch(Exception $e) |
|
1274 | 1251 | { |
1275 | 1252 | throw new TInvalidOperationException('component_statements_invalid',get_class($this),$statements,$e->getMessage()); |
1276 | 1253 | } |
@@ -1972,11 +1949,9 @@ discard block |
||
1972 | 1949 | { |
1973 | 1950 | eval('$array=array'.$value.';'); |
1974 | 1951 | return $array; |
1975 | - } |
|
1976 | - else |
|
1952 | + } else |
|
1977 | 1953 | return $len>0?array($value):array(); |
1978 | - } |
|
1979 | - else |
|
1954 | + } else |
|
1980 | 1955 | return (array)$value; |
1981 | 1956 | } |
1982 | 1957 | |
@@ -2019,8 +1994,7 @@ discard block |
||
2019 | 1994 | throw new TInvalidDataValueException( |
2020 | 1995 | 'propertyvalue_enumvalue_invalid',$value, |
2021 | 1996 | implode(' | ',$types[$enums]->getConstants())); |
2022 | - } |
|
2023 | - else if(!is_array($enums)) |
|
1997 | + } else if(!is_array($enums)) |
|
2024 | 1998 | { |
2025 | 1999 | $enums=func_get_args(); |
2026 | 2000 | array_shift($enums); |
@@ -185,7 +185,7 @@ |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
188 | - * @return integer|float a timestamp given a local time |
|
188 | + * @return integer a timestamp given a local time |
|
189 | 189 | */ |
190 | 190 | function getTimeStamp($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_gmt=false) |
191 | 191 | { |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | */ |
26 | 26 | class TDateTimeStamp |
27 | 27 | { |
28 | - protected static $_month_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); |
|
29 | - protected static $_month_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); |
|
28 | + protected static $_month_normal=array("", 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
29 | + protected static $_month_leaf=array("", 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Returns the day of the week (0=Sunday, 1=Monday, .. 6=Saturday) |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function getDayofWeek($year, $month, $day) |
38 | 38 | { |
39 | - $dt = new DateTime(); |
|
39 | + $dt=new DateTime(); |
|
40 | 40 | $dt->setDate($year, $month, $day); |
41 | 41 | return (int) $dt->format('w'); |
42 | 42 | } |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function isLeapYear($year) |
51 | 51 | { |
52 | - $year = $this->digitCheck($year); |
|
53 | - $dt = new DateTime(); |
|
52 | + $year=$this->digitCheck($year); |
|
53 | + $dt=new DateTime(); |
|
54 | 54 | $dt->setDate($year, 1, 1); |
55 | 55 | return (bool) $dt->format('L'); |
56 | 56 | } |
@@ -62,22 +62,22 @@ discard block |
||
62 | 62 | */ |
63 | 63 | protected function digitCheck($y) |
64 | 64 | { |
65 | - if ($y < 100){ |
|
66 | - $yr = (integer) date("Y"); |
|
67 | - $century = (integer) ($yr /100); |
|
65 | + if($y < 100) { |
|
66 | + $yr=(integer) date("Y"); |
|
67 | + $century=(integer) ($yr / 100); |
|
68 | 68 | |
69 | - if ($yr%100 > 50) { |
|
70 | - $c1 = $century + 1; |
|
71 | - $c0 = $century; |
|
69 | + if($yr % 100 > 50) { |
|
70 | + $c1=$century + 1; |
|
71 | + $c0=$century; |
|
72 | 72 | } else { |
73 | - $c1 = $century; |
|
74 | - $c0 = $century - 1; |
|
73 | + $c1=$century; |
|
74 | + $c0=$century - 1; |
|
75 | 75 | } |
76 | - $c1 *= 100; |
|
76 | + $c1*=100; |
|
77 | 77 | // if 2-digit year is less than 30 years in future, set it to this century |
78 | 78 | // otherwise if more than 30 years in future, then we set 2-digit year to the prev century. |
79 | - if (($y + $c1) < $yr+30) $y = $y + $c1; |
|
80 | - else $y = $y + $c0*100; |
|
79 | + if(($y + $c1) < $yr + 30) $y=$y + $c1; |
|
80 | + else $y=$y + $c0 * 100; |
|
81 | 81 | } |
82 | 82 | return $y; |
83 | 83 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function getGMTDiff($ts=false) |
94 | 94 | { |
95 | - $dt = new DateTime(); |
|
95 | + $dt=new DateTime(); |
|
96 | 96 | if($ts) |
97 | 97 | $dt->setTimeStamp($ts); |
98 | 98 | else |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | */ |
107 | 107 | function parseDate($txt=false) |
108 | 108 | { |
109 | - if ($txt === false) return getdate(); |
|
109 | + if($txt===false) return getdate(); |
|
110 | 110 | |
111 | - $dt = new DateTime($txt); |
|
111 | + $dt=new DateTime($txt); |
|
112 | 112 | |
113 | 113 | return array( |
114 | 114 | 'seconds' => (int) $dt->format('s'), |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | /** |
129 | 129 | * @return array an array with date info. |
130 | 130 | */ |
131 | - function getDate($d=false,$fast=false) |
|
131 | + function getDate($d=false, $fast=false) |
|
132 | 132 | { |
133 | - if ($d === false) return getdate(); |
|
133 | + if($d===false) return getdate(); |
|
134 | 134 | |
135 | - $dt = new DateTime(); |
|
135 | + $dt=new DateTime(); |
|
136 | 136 | $dt->setTimestamp($d); |
137 | 137 | |
138 | 138 | return array( |
@@ -153,20 +153,20 @@ discard block |
||
153 | 153 | /** |
154 | 154 | * @return boolean true if valid date, semantic check only. |
155 | 155 | */ |
156 | - public function isValidDate($y,$m,$d) |
|
156 | + public function isValidDate($y, $m, $d) |
|
157 | 157 | { |
158 | - if ($this->isLeapYear($y)) |
|
159 | - $marr =& self::$_month_leaf; |
|
158 | + if($this->isLeapYear($y)) |
|
159 | + $marr=& self::$_month_leaf; |
|
160 | 160 | else |
161 | - $marr =& self::$_month_normal; |
|
161 | + $marr=& self::$_month_normal; |
|
162 | 162 | |
163 | - if ($m > 12 || $m < 1) return false; |
|
163 | + if($m > 12 || $m < 1) return false; |
|
164 | 164 | |
165 | - if ($d > 31 || $d < 1) return false; |
|
165 | + if($d > 31 || $d < 1) return false; |
|
166 | 166 | |
167 | - if ($marr[$m] < $d) return false; |
|
167 | + if($marr[$m] < $d) return false; |
|
168 | 168 | |
169 | - if ($y < 1000 && $y > 3000) return false; |
|
169 | + if($y < 1000 && $y > 3000) return false; |
|
170 | 170 | |
171 | 171 | return true; |
172 | 172 | } |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * @return string formatted date based on timestamp $d |
176 | 176 | */ |
177 | - function formatDate($fmt,$ts=false,$is_gmt=false) |
|
177 | + function formatDate($fmt, $ts=false, $is_gmt=false) |
|
178 | 178 | { |
179 | - $dt = new DateTime(); |
|
179 | + $dt=new DateTime(); |
|
180 | 180 | if($is_gmt) |
181 | 181 | $dt->setTimeZone(new DateTimeZone('UTC')); |
182 | 182 | $dt->setTimestamp($ts); |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | /** |
188 | 188 | * @return integer|float a timestamp given a local time |
189 | 189 | */ |
190 | - function getTimeStamp($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_gmt=false) |
|
190 | + function getTimeStamp($hr, $min, $sec, $mon=false, $day=false, $year=false, $is_gmt=false) |
|
191 | 191 | { |
192 | - $dt = new DateTime(); |
|
192 | + $dt=new DateTime(); |
|
193 | 193 | if($is_gmt) |
194 | 194 | $dt->setTimeZone(new DateTimeZone('UTC')); |
195 | 195 | $dt->setDate($year!==false ? $year : date('Y'), |
@@ -1,13 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * TDateTimeStamp class file. |
|
4 | - |
|
5 | - * @author Fabio Bas ctrlaltca[AT]gmail[DOT]com |
|
6 | - * @link https://github.com/pradosoft/prado |
|
7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | - * @package System.Util |
|
10 | - */ |
|
3 | + * TDateTimeStamp class file. |
|
4 | + * @author Fabio Bas ctrlaltca[AT]gmail[DOT]com |
|
5 | + * @link https://github.com/pradosoft/prado |
|
6 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
7 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
8 | + * @package System.Util |
|
9 | + */ |
|
11 | 10 | |
12 | 11 | /** |
13 | 12 | * TDateTimeStamp Class |
@@ -186,7 +185,7 @@ discard block |
||
186 | 185 | |
187 | 186 | /** |
188 | 187 | * @return integer|float a timestamp given a local time |
189 | - */ |
|
188 | + */ |
|
190 | 189 | function getTimeStamp($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_gmt=false) |
191 | 190 | { |
192 | 191 | $dt = new DateTime(); |
@@ -93,6 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | /** |
95 | 95 | * @param string formatting charset. |
96 | + * @param string $charset |
|
96 | 97 | */ |
97 | 98 | public function setCharset($charset) |
98 | 99 | { |
@@ -313,6 +314,7 @@ discard block |
||
313 | 314 | |
314 | 315 | /** |
315 | 316 | * Calculate the length of a string, may be consider iconv_strlen? |
317 | + * @param string $string |
|
316 | 318 | */ |
317 | 319 | private function length($string) |
318 | 320 | { |
@@ -338,6 +340,9 @@ discard block |
||
338 | 340 | |
339 | 341 | /** |
340 | 342 | * Returns true if char at position equals a particular char. |
343 | + * @param string $string |
|
344 | + * @param integer $pos |
|
345 | + * @param string $char |
|
341 | 346 | */ |
342 | 347 | private function charEqual($string, $pos, $char) |
343 | 348 | { |
@@ -350,6 +355,10 @@ discard block |
||
350 | 355 | * @param int starting position |
351 | 356 | * @param int minimum integer length |
352 | 357 | * @param int maximum integer length |
358 | + * @param string $str |
|
359 | + * @param integer $i |
|
360 | + * @param integer|null $minlength |
|
361 | + * @param integer|null $maxlength |
|
353 | 362 | * @return string integer portion of the string, null otherwise |
354 | 363 | */ |
355 | 364 | private function getInteger($str,$i,$minlength,$maxlength) |
@@ -225,8 +225,7 @@ discard block |
||
225 | 225 | $year = "{$date['year']}"; |
226 | 226 | $month = $date['mon']; |
227 | 227 | $day = $date['mday']; |
228 | - } |
|
229 | - else |
|
228 | + } else |
|
230 | 229 | { |
231 | 230 | $year = null; |
232 | 231 | $month = null; |
@@ -262,8 +261,7 @@ discard block |
||
262 | 261 | $year = $iYear + 2000; |
263 | 262 | } |
264 | 263 | $year = (int)$year; |
265 | - } |
|
266 | - elseif($token=='MM' || $token=='M') |
|
264 | + } elseif($token=='MM' || $token=='M') |
|
267 | 265 | { |
268 | 266 | $month=$this->getInteger($value,$i_val, |
269 | 267 | $this->length($token),2); |
@@ -273,8 +271,7 @@ discard block |
||
273 | 271 | //throw new TInvalidDataValueException('Invalid month', $value); |
274 | 272 | $i_val += strlen($month); |
275 | 273 | $month = $iMonth; |
276 | - } |
|
277 | - elseif ($token=='dd' || $token=='d') |
|
274 | + } elseif ($token=='dd' || $token=='d') |
|
278 | 275 | { |
279 | 276 | $day = $this->getInteger($value,$i_val, |
280 | 277 | $this->length($token), 2); |
@@ -284,8 +281,7 @@ discard block |
||
284 | 281 | //throw new TInvalidDataValueException('Invalid day', $value); |
285 | 282 | $i_val += strlen($day); |
286 | 283 | $day = $iDay; |
287 | - } |
|
288 | - else |
|
284 | + } else |
|
289 | 285 | { |
290 | 286 | if($this->substring($value, $i_val, $this->length($token)) != $token) |
291 | 287 | return null; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * Charset, default is 'UTF-8' |
55 | 55 | * @var string |
56 | 56 | */ |
57 | - private $charset = 'UTF-8'; |
|
57 | + private $charset='UTF-8'; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Constructor, create a new date time formatter. |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function setPattern($pattern) |
82 | 82 | { |
83 | - $this->pattern = $pattern; |
|
83 | + $this->pattern=$pattern; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function setCharset($charset) |
98 | 98 | { |
99 | - $this->charset = $charset; |
|
99 | + $this->charset=$charset; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -106,17 +106,17 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function format($value) |
108 | 108 | { |
109 | - $date = $this->getDate($value); |
|
110 | - $bits['yyyy'] = $date['year']; |
|
111 | - $bits['yy'] = substr("{$date['year']}", -2); |
|
109 | + $date=$this->getDate($value); |
|
110 | + $bits['yyyy']=$date['year']; |
|
111 | + $bits['yy']=substr("{$date['year']}", -2); |
|
112 | 112 | |
113 | - $bits['MM'] = str_pad("{$date['mon']}", 2, '0', STR_PAD_LEFT); |
|
114 | - $bits['M'] = $date['mon']; |
|
113 | + $bits['MM']=str_pad("{$date['mon']}", 2, '0', STR_PAD_LEFT); |
|
114 | + $bits['M']=$date['mon']; |
|
115 | 115 | |
116 | - $bits['dd'] = str_pad("{$date['mday']}", 2, '0', STR_PAD_LEFT); |
|
117 | - $bits['d'] = $date['mday']; |
|
116 | + $bits['dd']=str_pad("{$date['mday']}", 2, '0', STR_PAD_LEFT); |
|
117 | + $bits['d']=$date['mday']; |
|
118 | 118 | |
119 | - $pattern = preg_replace('/M{3,4}/', 'MM', $this->pattern); |
|
119 | + $pattern=preg_replace('/M{3,4}/', 'MM', $this->pattern); |
|
120 | 120 | return str_replace(array_keys($bits), $bits, $pattern); |
121 | 121 | } |
122 | 122 | |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | |
154 | 154 | public function getDayMonthYearOrdering() |
155 | 155 | { |
156 | - $ordering = array(); |
|
157 | - if(is_int($day= strpos($this->pattern, 'd'))) |
|
158 | - $ordering['day'] = $day; |
|
159 | - if(is_int($month= strpos($this->pattern, 'M'))) |
|
160 | - $ordering['month'] = $month; |
|
161 | - if(is_int($year= strpos($this->pattern, 'yy'))) |
|
162 | - $ordering['year'] = $year; |
|
156 | + $ordering=array(); |
|
157 | + if(is_int($day=strpos($this->pattern, 'd'))) |
|
158 | + $ordering['day']=$day; |
|
159 | + if(is_int($month=strpos($this->pattern, 'M'))) |
|
160 | + $ordering['month']=$month; |
|
161 | + if(is_int($year=strpos($this->pattern, 'yy'))) |
|
162 | + $ordering['year']=$year; |
|
163 | 163 | asort($ordering); |
164 | 164 | return array_keys($ordering); |
165 | 165 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | private function getDate($value) |
173 | 173 | { |
174 | - $s = Prado::createComponent('System.Util.TDateTimeStamp'); |
|
174 | + $s=Prado::createComponent('System.Util.TDateTimeStamp'); |
|
175 | 175 | if(is_numeric($value)) |
176 | 176 | return $s->getDate($value); |
177 | 177 | else |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function isValidDate($value) |
185 | 185 | { |
186 | - if($value === null) { |
|
186 | + if($value===null) { |
|
187 | 187 | return false; |
188 | 188 | } else { |
189 | - return $this->parse($value, false) !== null; |
|
189 | + return $this->parse($value, false)!==null; |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @return int date time stamp |
197 | 197 | * @throws TInvalidDataValueException if date string is malformed. |
198 | 198 | */ |
199 | - public function parse($value,$defaultToCurrentTime=true) |
|
199 | + public function parse($value, $defaultToCurrentTime=true) |
|
200 | 200 | { |
201 | 201 | if(is_int($value) || is_float($value)) |
202 | 202 | return $value; |
@@ -205,108 +205,108 @@ discard block |
||
205 | 205 | |
206 | 206 | if(empty($this->pattern)) return time(); |
207 | 207 | |
208 | - $date = time(); |
|
208 | + $date=time(); |
|
209 | 209 | |
210 | 210 | if($this->length(trim($value)) < 1) |
211 | 211 | return $defaultToCurrentTime ? $date : null; |
212 | 212 | |
213 | - $pattern = $this->pattern; |
|
213 | + $pattern=$this->pattern; |
|
214 | 214 | |
215 | - $i_val = 0; |
|
216 | - $i_format = 0; |
|
217 | - $pattern_length = $this->length($pattern); |
|
218 | - $c = ''; |
|
215 | + $i_val=0; |
|
216 | + $i_format=0; |
|
217 | + $pattern_length=$this->length($pattern); |
|
218 | + $c=''; |
|
219 | 219 | $token=''; |
220 | 220 | $x=null; $y=null; |
221 | 221 | |
222 | 222 | |
223 | 223 | if($defaultToCurrentTime) |
224 | 224 | { |
225 | - $year = "{$date['year']}"; |
|
226 | - $month = $date['mon']; |
|
227 | - $day = $date['mday']; |
|
225 | + $year="{$date['year']}"; |
|
226 | + $month=$date['mon']; |
|
227 | + $day=$date['mday']; |
|
228 | 228 | } |
229 | 229 | else |
230 | 230 | { |
231 | - $year = null; |
|
232 | - $month = null; |
|
233 | - $day = null; |
|
231 | + $year=null; |
|
232 | + $month=null; |
|
233 | + $day=null; |
|
234 | 234 | } |
235 | 235 | |
236 | - while ($i_format < $pattern_length) |
|
236 | + while($i_format < $pattern_length) |
|
237 | 237 | { |
238 | - $c = $this->charAt($pattern,$i_format); |
|
238 | + $c=$this->charAt($pattern, $i_format); |
|
239 | 239 | $token=''; |
240 | - while ($this->charEqual($pattern, $i_format, $c) |
|
240 | + while($this->charEqual($pattern, $i_format, $c) |
|
241 | 241 | && ($i_format < $pattern_length)) |
242 | 242 | { |
243 | - $token .= $this->charAt($pattern, $i_format++); |
|
243 | + $token.=$this->charAt($pattern, $i_format++); |
|
244 | 244 | } |
245 | 245 | |
246 | - if ($token=='yyyy' || $token=='yy' || $token=='y') |
|
246 | + if($token=='yyyy' || $token=='yy' || $token=='y') |
|
247 | 247 | { |
248 | - if ($token=='yyyy') { $x=4;$y=4; } |
|
249 | - if ($token=='yy') { $x=2;$y=2; } |
|
250 | - if ($token=='y') { $x=2;$y=4; } |
|
251 | - $year = $this->getInteger($value,$i_val,$x,$y); |
|
252 | - if($year === null) |
|
248 | + if($token=='yyyy') { $x=4; $y=4; } |
|
249 | + if($token=='yy') { $x=2; $y=2; } |
|
250 | + if($token=='y') { $x=2; $y=4; } |
|
251 | + $year=$this->getInteger($value, $i_val, $x, $y); |
|
252 | + if($year===null) |
|
253 | 253 | return null; |
254 | 254 | //throw new TInvalidDataValueException('Invalid year', $value); |
255 | - $i_val += strlen($year); |
|
256 | - if(strlen($year) == 2) |
|
255 | + $i_val+=strlen($year); |
|
256 | + if(strlen($year)==2) |
|
257 | 257 | { |
258 | - $iYear = (int)$year; |
|
258 | + $iYear=(int) $year; |
|
259 | 259 | if($iYear > 70) |
260 | - $year = $iYear + 1900; |
|
260 | + $year=$iYear + 1900; |
|
261 | 261 | else |
262 | - $year = $iYear + 2000; |
|
262 | + $year=$iYear + 2000; |
|
263 | 263 | } |
264 | - $year = (int)$year; |
|
264 | + $year=(int) $year; |
|
265 | 265 | } |
266 | 266 | elseif($token=='MM' || $token=='M') |
267 | 267 | { |
268 | - $month=$this->getInteger($value,$i_val, |
|
269 | - $this->length($token),2); |
|
270 | - $iMonth = (int)$month; |
|
271 | - if($month === null || $iMonth < 1 || $iMonth > 12 ) |
|
268 | + $month=$this->getInteger($value, $i_val, |
|
269 | + $this->length($token), 2); |
|
270 | + $iMonth=(int) $month; |
|
271 | + if($month===null || $iMonth < 1 || $iMonth > 12) |
|
272 | 272 | return null; |
273 | 273 | //throw new TInvalidDataValueException('Invalid month', $value); |
274 | - $i_val += strlen($month); |
|
275 | - $month = $iMonth; |
|
274 | + $i_val+=strlen($month); |
|
275 | + $month=$iMonth; |
|
276 | 276 | } |
277 | - elseif ($token=='dd' || $token=='d') |
|
277 | + elseif($token=='dd' || $token=='d') |
|
278 | 278 | { |
279 | - $day = $this->getInteger($value,$i_val, |
|
279 | + $day=$this->getInteger($value, $i_val, |
|
280 | 280 | $this->length($token), 2); |
281 | - $iDay = (int)$day; |
|
282 | - if($day === null || $iDay < 1 || $iDay >31) |
|
281 | + $iDay=(int) $day; |
|
282 | + if($day===null || $iDay < 1 || $iDay > 31) |
|
283 | 283 | return null; |
284 | 284 | //throw new TInvalidDataValueException('Invalid day', $value); |
285 | - $i_val += strlen($day); |
|
286 | - $day = $iDay; |
|
285 | + $i_val+=strlen($day); |
|
286 | + $day=$iDay; |
|
287 | 287 | } |
288 | 288 | else |
289 | 289 | { |
290 | - if($this->substring($value, $i_val, $this->length($token)) != $token) |
|
290 | + if($this->substring($value, $i_val, $this->length($token))!=$token) |
|
291 | 291 | return null; |
292 | 292 | //throw new TInvalidDataValueException("Subpattern '{$this->pattern}' mismatch", $value); |
293 | 293 | else |
294 | - $i_val += $this->length($token); |
|
294 | + $i_val+=$this->length($token); |
|
295 | 295 | } |
296 | 296 | } |
297 | - if ($i_val != $this->length($value)) |
|
297 | + if($i_val!=$this->length($value)) |
|
298 | 298 | return null; |
299 | 299 | //throw new TInvalidDataValueException("Pattern '{$this->pattern}' mismatch", $value); |
300 | - if(!$defaultToCurrentTime && ($month === null || $day === null || $year === null)) |
|
300 | + if(!$defaultToCurrentTime && ($month===null || $day===null || $year===null)) |
|
301 | 301 | return null; |
302 | 302 | else |
303 | 303 | { |
304 | 304 | if(empty($year)) { |
305 | - $year = date('Y'); |
|
305 | + $year=date('Y'); |
|
306 | 306 | } |
307 | - $day = (int)$day <= 0 ? 1 : (int)$day; |
|
308 | - $month = (int)$month <= 0 ? 1 : (int)$month; |
|
309 | - $s = Prado::createComponent('System.Util.TDateTimeStamp'); |
|
307 | + $day=(int) $day <= 0 ? 1 : (int) $day; |
|
308 | + $month=(int) $month <= 0 ? 1 : (int) $month; |
|
309 | + $s=Prado::createComponent('System.Util.TDateTimeStamp'); |
|
310 | 310 | return $s->getTimeStamp(0, 0, 0, $month, $day, $year); |
311 | 311 | } |
312 | 312 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | */ |
342 | 342 | private function charEqual($string, $pos, $char) |
343 | 343 | { |
344 | - return $this->charAt($string, $pos) == $char; |
|
344 | + return $this->charAt($string, $pos)==$char; |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -352,15 +352,15 @@ discard block |
||
352 | 352 | * @param int maximum integer length |
353 | 353 | * @return string integer portion of the string, null otherwise |
354 | 354 | */ |
355 | - private function getInteger($str,$i,$minlength,$maxlength) |
|
355 | + private function getInteger($str, $i, $minlength, $maxlength) |
|
356 | 356 | { |
357 | 357 | //match for digits backwards |
358 | - for ($x = $maxlength; $x >= $minlength; $x--) |
|
358 | + for($x=$maxlength; $x >= $minlength; $x--) |
|
359 | 359 | { |
360 | - $token= $this->substring($str, $i,$x); |
|
361 | - if ($this->length($token) < $minlength) |
|
360 | + $token=$this->substring($str, $i, $x); |
|
361 | + if($this->length($token) < $minlength) |
|
362 | 362 | return null; |
363 | - if (preg_match('/^\d+$/', $token)) |
|
363 | + if(preg_match('/^\d+$/', $token)) |
|
364 | 364 | return $token; |
365 | 365 | } |
366 | 366 | return null; |
@@ -215,6 +215,7 @@ discard block |
||
215 | 215 | * This method does not perform any publishing. It merely tells you |
216 | 216 | * if the file path is published, what the URL will be to access it. |
217 | 217 | * @param string directory or file path being published |
218 | + * @param string $path |
|
218 | 219 | * @return string the published URL for the file path |
219 | 220 | */ |
220 | 221 | public function getPublishedUrl($path) |
@@ -230,6 +231,7 @@ discard block |
||
230 | 231 | * Generate a CRC32 hash for the directory path. Collisions are higher |
231 | 232 | * than MD5 but generates a much smaller hash string. |
232 | 233 | * @param string string to be hashed. |
234 | + * @param string $dir |
|
233 | 235 | * @return string hashed string. |
234 | 236 | */ |
235 | 237 | protected function hash($dir) |
@@ -243,6 +245,8 @@ discard block |
||
243 | 245 | * or has an older file modification time. |
244 | 246 | * @param string source file path |
245 | 247 | * @param string destination directory (if not exists, it will be created) |
248 | + * @param string $src |
|
249 | + * @param string $dst |
|
246 | 250 | */ |
247 | 251 | protected function copyFile($src,$dst) |
248 | 252 | { |
@@ -265,6 +269,8 @@ discard block |
||
265 | 269 | * File modification time is used to ensure the copied files are latest. |
266 | 270 | * @param string the source directory |
267 | 271 | * @param string the destination directory |
272 | + * @param string $src |
|
273 | + * @param string $dst |
|
268 | 274 | * @todo a generic solution to ignore certain directories and files |
269 | 275 | */ |
270 | 276 | public function copyDirectory($src,$dst) |
@@ -306,6 +312,8 @@ discard block |
||
306 | 312 | * @param string tar filename |
307 | 313 | * @param string MD5 checksum for the corresponding tar file. |
308 | 314 | * @param boolean Wether or not to check the time stamp of the file for publishing. Defaults to false. |
315 | + * @param string $tarfile |
|
316 | + * @param string $md5sum |
|
309 | 317 | * @return string URL path to the directory where the tar file was extracted. |
310 | 318 | */ |
311 | 319 | public function publishTarFile($tarfile, $md5sum, $checkTimestamp=false) |
@@ -336,6 +344,7 @@ discard block |
||
336 | 344 | * N.B Tar file must not be compressed. |
337 | 345 | * @param string tar file |
338 | 346 | * @param string path where the contents of tar file are to be extracted |
347 | + * @param string $destination |
|
339 | 348 | * @return boolean true if extract successful, false otherwise. |
340 | 349 | */ |
341 | 350 | protected function deployTarFile($path,$destination) |
@@ -163,8 +163,7 @@ discard block |
||
163 | 163 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
164 | 164 | $this->copyFile($fullpath,$dst); |
165 | 165 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
166 | - } |
|
167 | - else |
|
166 | + } else |
|
168 | 167 | { |
169 | 168 | $dir=$this->hash($fullpath); |
170 | 169 | if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
@@ -287,8 +286,7 @@ discard block |
||
287 | 286 | @copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
288 | 287 | @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
289 | 288 | } |
290 | - } |
|
291 | - else |
|
289 | + } else |
|
292 | 290 | $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
293 | 291 | } |
294 | 292 | closedir($folder); |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | if($this->_basePath===null) |
83 | 83 | $this->_basePath=dirname($application->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
84 | 84 | if(!is_writable($this->_basePath) || !is_dir($this->_basePath)) |
85 | - throw new TConfigurationException('assetmanager_basepath_invalid',$this->_basePath); |
|
85 | + throw new TConfigurationException('assetmanager_basepath_invalid', $this->_basePath); |
|
86 | 86 | if($this->_baseUrl===null) |
87 | - $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()),'/\\').'/'.self::DEFAULT_BASEPATH; |
|
87 | + $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()), '/\\').'/'.self::DEFAULT_BASEPATH; |
|
88 | 88 | $application->setAssetManager($this); |
89 | 89 | $this->_initialized=true; |
90 | 90 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | { |
112 | 112 | $this->_basePath=Prado::getPathOfNamespace($value); |
113 | 113 | if($this->_basePath===null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) |
114 | - throw new TInvalidDataValueException('assetmanager_basepath_invalid',$value); |
|
114 | + throw new TInvalidDataValueException('assetmanager_basepath_invalid', $value); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | if($this->_initialized) |
133 | 133 | throw new TInvalidOperationException('assetmanager_baseurl_unchangeable'); |
134 | 134 | else |
135 | - $this->_baseUrl=rtrim($value,'/'); |
|
135 | + $this->_baseUrl=rtrim($value, '/'); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -149,19 +149,19 @@ discard block |
||
149 | 149 | * @throws TInvalidDataValueException if the file path to be published is |
150 | 150 | * invalid |
151 | 151 | */ |
152 | - public function publishFilePath($path,$checkTimestamp=false) |
|
152 | + public function publishFilePath($path, $checkTimestamp=false) |
|
153 | 153 | { |
154 | 154 | if(isset($this->_published[$path])) |
155 | 155 | return $this->_published[$path]; |
156 | 156 | else if(empty($path) || ($fullpath=realpath($path))===false) |
157 | - throw new TInvalidDataValueException('assetmanager_filepath_invalid',$path); |
|
157 | + throw new TInvalidDataValueException('assetmanager_filepath_invalid', $path); |
|
158 | 158 | else if(is_file($fullpath)) |
159 | 159 | { |
160 | 160 | $dir=$this->hash(dirname($fullpath)); |
161 | 161 | $fileName=basename($fullpath); |
162 | 162 | $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
163 | 163 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
164 | - $this->copyFile($fullpath,$dst); |
|
164 | + $this->copyFile($fullpath, $dst); |
|
165 | 165 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
166 | 166 | } |
167 | 167 | else |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | $dir=$this->hash($fullpath); |
170 | 170 | if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
171 | 171 | { |
172 | - Prado::trace("Publishing directory $fullpath",'System.Web.UI.TAssetManager'); |
|
173 | - $this->copyDirectory($fullpath,$this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
172 | + Prado::trace("Publishing directory $fullpath", 'System.Web.UI.TAssetManager'); |
|
173 | + $this->copyDirectory($fullpath, $this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
174 | 174 | } |
175 | 175 | return $this->_published[$path]=$this->_baseUrl.'/'.$dir; |
176 | 176 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | protected function setPublished($values=array()) |
193 | 193 | { |
194 | - $this->_published = $values; |
|
194 | + $this->_published=$values; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | */ |
235 | 235 | protected function hash($dir) |
236 | 236 | { |
237 | - return sprintf('%x',crc32($dir.Prado::getVersion())); |
|
237 | + return sprintf('%x', crc32($dir.Prado::getVersion())); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @param string source file path |
245 | 245 | * @param string destination directory (if not exists, it will be created) |
246 | 246 | */ |
247 | - protected function copyFile($src,$dst) |
|
247 | + protected function copyFile($src, $dst) |
|
248 | 248 | { |
249 | 249 | if(!is_dir($dst)) |
250 | 250 | { |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | @chmod($dst, PRADO_CHMOD); |
253 | 253 | } |
254 | 254 | $dstFile=$dst.DIRECTORY_SEPARATOR.basename($src); |
255 | - if(@filemtime($dstFile)<@filemtime($src)) |
|
255 | + if(@filemtime($dstFile) < @filemtime($src)) |
|
256 | 256 | { |
257 | - Prado::trace("Publishing file $src to $dstFile",'System.Web.TAssetManager'); |
|
258 | - @copy($src,$dstFile); |
|
257 | + Prado::trace("Publishing file $src to $dstFile", 'System.Web.TAssetManager'); |
|
258 | + @copy($src, $dstFile); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @param string the destination directory |
268 | 268 | * @todo a generic solution to ignore certain directories and files |
269 | 269 | */ |
270 | - public function copyDirectory($src,$dst) |
|
270 | + public function copyDirectory($src, $dst) |
|
271 | 271 | { |
272 | 272 | if(!is_dir($dst)) |
273 | 273 | { |
@@ -282,14 +282,14 @@ discard block |
||
282 | 282 | continue; |
283 | 283 | else if(is_file($src.DIRECTORY_SEPARATOR.$file)) |
284 | 284 | { |
285 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$file)<@filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
285 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$file) < @filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
286 | 286 | { |
287 | - @copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
287 | + @copy($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
288 | 288 | @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
289 | 289 | } |
290 | 290 | } |
291 | 291 | else |
292 | - $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file); |
|
292 | + $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
293 | 293 | } |
294 | 294 | closedir($folder); |
295 | 295 | } else { |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | if(isset($this->_published[$md5sum])) |
314 | 314 | return $this->_published[$md5sum]; |
315 | 315 | else if(($fullpath=realpath($md5sum))===false || !is_file($fullpath)) |
316 | - throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid',$md5sum); |
|
316 | + throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid', $md5sum); |
|
317 | 317 | else |
318 | 318 | { |
319 | 319 | $dir=$this->hash(dirname($fullpath)); |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
322 | 322 | if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
323 | 323 | { |
324 | - if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName)<@filemtime($fullpath)) |
|
324 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName) < @filemtime($fullpath)) |
|
325 | 325 | { |
326 | - $this->copyFile($fullpath,$dst); |
|
327 | - $this->deployTarFile($tarfile,$dst); |
|
326 | + $this->copyFile($fullpath, $dst); |
|
327 | + $this->deployTarFile($tarfile, $dst); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | return $this->_published[$md5sum]=$this->_baseUrl.'/'.$dir; |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | * @param string path where the contents of tar file are to be extracted |
339 | 339 | * @return boolean true if extract successful, false otherwise. |
340 | 340 | */ |
341 | - protected function deployTarFile($path,$destination) |
|
341 | + protected function deployTarFile($path, $destination) |
|
342 | 342 | { |
343 | 343 | if(($fullpath=realpath($path))===false || !is_file($fullpath)) |
344 | - throw new TIOException('assetmanager_tarfile_invalid',$path); |
|
344 | + throw new TIOException('assetmanager_tarfile_invalid', $path); |
|
345 | 345 | else |
346 | 346 | { |
347 | 347 | Prado::using('System.IO.TTarFileExtractor'); |
348 | - $tar = new TTarFileExtractor($fullpath); |
|
348 | + $tar=new TTarFileExtractor($fullpath); |
|
349 | 349 | return $tar->extract($destination); |
350 | 350 | } |
351 | 351 | } |
@@ -258,6 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Saves the current UrlManager instance to cache. |
261 | + * @param TUrlManager $manager |
|
261 | 262 | * @return boolean true if UrlManager instance was cached, false otherwise. |
262 | 263 | */ |
263 | 264 | protected function cacheUrlManager($manager) |
@@ -349,7 +350,7 @@ discard block |
||
349 | 350 | } |
350 | 351 | |
351 | 352 | /** |
352 | - * @return THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
353 | + * @return string the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
353 | 354 | */ |
354 | 355 | public function getUrlFormat() |
355 | 356 | { |
@@ -710,6 +711,7 @@ discard block |
||
710 | 711 | * @param array GET parameters, null if not needed |
711 | 712 | * @param boolean whether to encode the ampersand in URL, defaults to true. |
712 | 713 | * @param boolean whether to encode the GET parameters (their names and values), defaults to false. |
714 | + * @param string $serviceID |
|
713 | 715 | * @return string URL |
714 | 716 | * @see TUrlManager::constructUrl |
715 | 717 | */ |
@@ -980,6 +982,7 @@ discard block |
||
980 | 982 | /** |
981 | 983 | * Constructor. |
982 | 984 | * @param mixed owner of this collection. |
985 | + * @param THttpResponse $owner |
|
983 | 986 | */ |
984 | 987 | public function __construct($owner=null) |
985 | 988 | { |
@@ -1125,6 +1128,7 @@ discard block |
||
1125 | 1128 | |
1126 | 1129 | /** |
1127 | 1130 | * @param integer the time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch. |
1131 | + * @param integer $value |
|
1128 | 1132 | */ |
1129 | 1133 | public function setExpire($value) |
1130 | 1134 | { |
@@ -1287,6 +1291,7 @@ discard block |
||
1287 | 1291 | * Constructor. |
1288 | 1292 | * Decomposes the specified URI into parts. |
1289 | 1293 | * @param string URI to be represented |
1294 | + * @param string $uri |
|
1290 | 1295 | * @throws TInvalidDataValueException if URI is of bad format |
1291 | 1296 | */ |
1292 | 1297 | public function __construct($uri) |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * @package System.Web |
67 | 67 | * @since 3.0 |
68 | 68 | */ |
69 | -class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule |
|
69 | +class THttpRequest extends TApplicationComponent implements IteratorAggregate, ArrayAccess, Countable, IModule |
|
70 | 70 | { |
71 | - const CGIFIX__PATH_INFO = 1; |
|
72 | - const CGIFIX__SCRIPT_NAME = 2; |
|
71 | + const CGIFIX__PATH_INFO=1; |
|
72 | + const CGIFIX__SCRIPT_NAME=2; |
|
73 | 73 | /** |
74 | 74 | * @var TUrlManager the URL manager module |
75 | 75 | */ |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | if(isset($_SERVER['REQUEST_URI'])) |
173 | 173 | $this->_requestUri=$_SERVER['REQUEST_URI']; |
174 | 174 | else // TBD: in this case, SCRIPT_NAME need to be escaped |
175 | - $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING'])?'':'?'.$_SERVER['QUERY_STRING']); |
|
175 | + $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING']) ? '' : '?'.$_SERVER['QUERY_STRING']); |
|
176 | 176 | |
177 | - if($this->_cgiFix&self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
177 | + if($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
178 | 178 | $this->_pathInfo=substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME'])); |
179 | 179 | elseif(isset($_SERVER['PATH_INFO'])) |
180 | 180 | $this->_pathInfo=$_SERVER['PATH_INFO']; |
181 | - else if(strpos($_SERVER['PHP_SELF'],$_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) |
|
182 | - $this->_pathInfo=substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME'])); |
|
181 | + else if(strpos($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) |
|
182 | + $this->_pathInfo=substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])); |
|
183 | 183 | else |
184 | 184 | $this->_pathInfo=''; |
185 | 185 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function stripSlashes(&$data) |
208 | 208 | { |
209 | - return is_array($data)?array_map(array($this,'stripSlashes'),$data):stripslashes($data); |
|
209 | + return is_array($data) ? array_map(array($this, 'stripSlashes'), $data) : stripslashes($data); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | if($this->_url===null) |
218 | 218 | { |
219 | 219 | $secure=$this->getIsSecureConnection(); |
220 | - $url=$secure?'https://':'http://'; |
|
220 | + $url=$secure ? 'https://' : 'http://'; |
|
221 | 221 | if(empty($_SERVER['HTTP_HOST'])) |
222 | 222 | { |
223 | 223 | $url.=$_SERVER['SERVER_NAME']; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function setEnableCache($value) |
242 | 242 | { |
243 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
243 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -264,15 +264,15 @@ discard block |
||
264 | 264 | { |
265 | 265 | if($this->getEnableCache()) |
266 | 266 | { |
267 | - $cache = $this->getApplication()->getCache(); |
|
268 | - if($cache !== null) |
|
267 | + $cache=$this->getApplication()->getCache(); |
|
268 | + if($cache!==null) |
|
269 | 269 | { |
270 | - $dependencies = null; |
|
271 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
272 | - if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
|
270 | + $dependencies=null; |
|
271 | + if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
272 | + if($manager instanceof TUrlMapping && $fn=$manager->getConfigFile()) |
|
273 | 273 | { |
274 | - $fn = Prado::getPathOfNamespace($fn,$this->getApplication()->getConfigurationFileExt()); |
|
275 | - $dependencies = new TFileCacheDependency($fn); |
|
274 | + $fn=Prado::getPathOfNamespace($fn, $this->getApplication()->getConfigurationFileExt()); |
|
275 | + $dependencies=new TFileCacheDependency($fn); |
|
276 | 276 | } |
277 | 277 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
278 | 278 | } |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | { |
289 | 289 | if($this->getEnableCache()) |
290 | 290 | { |
291 | - $cache = $this->getApplication()->getCache(); |
|
292 | - if($cache !== null) |
|
291 | + $cache=$this->getApplication()->getCache(); |
|
292 | + if($cache!==null) |
|
293 | 293 | { |
294 | - $manager = $cache->get($this->getCacheKey()); |
|
294 | + $manager=$cache->get($this->getCacheKey()); |
|
295 | 295 | if($manager instanceof TUrlManager) |
296 | 296 | return $manager; |
297 | 297 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | { |
328 | 328 | if($this->_urlManager===null) |
329 | 329 | { |
330 | - if(($this->_urlManager = $this->loadCachedUrlManager())===null) |
|
330 | + if(($this->_urlManager=$this->loadCachedUrlManager())===null) |
|
331 | 331 | { |
332 | 332 | if(empty($this->_urlManagerID)) |
333 | 333 | { |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | { |
339 | 339 | $this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID); |
340 | 340 | if($this->_urlManager===null) |
341 | - throw new TConfigurationException('httprequest_urlmanager_inexist',$this->_urlManagerID); |
|
341 | + throw new TConfigurationException('httprequest_urlmanager_inexist', $this->_urlManagerID); |
|
342 | 342 | if(!($this->_urlManager instanceof TUrlManager)) |
343 | - throw new TConfigurationException('httprequest_urlmanager_invalid',$this->_urlManagerID); |
|
343 | + throw new TConfigurationException('httprequest_urlmanager_invalid', $this->_urlManagerID); |
|
344 | 344 | } |
345 | 345 | $this->cacheUrlManager($this->_urlManager); |
346 | 346 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | */ |
367 | 367 | public function setUrlFormat($value) |
368 | 368 | { |
369 | - $this->_urlFormat=TPropertyValue::ensureEnum($value,'THttpRequestUrlFormat'); |
|
369 | + $this->_urlFormat=TPropertyValue::ensureEnum($value, 'THttpRequestUrlFormat'); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -394,19 +394,19 @@ discard block |
||
394 | 394 | */ |
395 | 395 | public function getRequestType() |
396 | 396 | { |
397 | - return isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:null; |
|
397 | + return isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null; |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
401 | 401 | * @param boolean $mimetypeOnly whether to return only the mimetype (default: true) |
402 | 402 | * @return string content type (e.g. 'application/json' or 'text/html; encoding=gzip') or null if not specified |
403 | 403 | */ |
404 | - public function getContentType($mimetypeOnly = true) |
|
404 | + public function getContentType($mimetypeOnly=true) |
|
405 | 405 | { |
406 | 406 | if(!isset($_SERVER['CONTENT_TYPE'])) |
407 | 407 | return null; |
408 | 408 | |
409 | - if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false) |
|
409 | + if($mimetypeOnly===true && ($_pos=strpos(';', $_SERVER['CONTENT_TYPE']))!==false) |
|
410 | 410 | return substr($_SERVER['CONTENT_TYPE'], 0, $_pos); |
411 | 411 | |
412 | 412 | return $_SERVER['CONTENT_TYPE']; |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function getIsSecureConnection() |
419 | 419 | { |
420 | - return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'],'off'); |
|
420 | + return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off'); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public function getQueryString() |
435 | 435 | { |
436 | - return isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:null; |
|
436 | + return isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | /** |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | */ |
442 | 442 | public function getHttpProtocolVersion() |
443 | 443 | { |
444 | - return isset($_SERVER['SERVER_PROTOCOL'])?$_SERVER['SERVER_PROTOCOL']:null; |
|
444 | + return isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -452,19 +452,19 @@ discard block |
||
452 | 452 | { |
453 | 453 | static $result; |
454 | 454 | |
455 | - if($result === null && function_exists('apache_request_headers')) { |
|
456 | - $result = apache_request_headers(); |
|
455 | + if($result===null && function_exists('apache_request_headers')) { |
|
456 | + $result=apache_request_headers(); |
|
457 | 457 | } |
458 | - elseif($result === null) { |
|
459 | - $result = array(); |
|
458 | + elseif($result===null) { |
|
459 | + $result=array(); |
|
460 | 460 | foreach($_SERVER as $key=>$value) { |
461 | - if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
|
462 | - $key = str_replace(' ','-', ucwords(strtolower(str_replace('_',' ', substr($key, 5))))); |
|
463 | - $result[$key] = $value; |
|
461 | + if(strncasecmp($key, 'HTTP_', 5)!==0) continue; |
|
462 | + $key=str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5))))); |
|
463 | + $result[$key]=$value; |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | - if($case !== null) |
|
467 | + if($case!==null) |
|
468 | 468 | return array_change_key_case($result, $case); |
469 | 469 | |
470 | 470 | return $result; |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | public function getBaseUrl($forceSecureConnection=null) |
489 | 489 | { |
490 | 490 | $url=$this->getUrl(); |
491 | - $scheme=($forceSecureConnection)?"https": (($forceSecureConnection === null)?$url->getScheme():'http'); |
|
491 | + $scheme=($forceSecureConnection) ? "https" : (($forceSecureConnection===null) ? $url->getScheme() : 'http'); |
|
492 | 492 | $host=$url->getHost(); |
493 | - if (($port=$url->getPort())) $host.=':'.$port; |
|
493 | + if(($port=$url->getPort())) $host.=':'.$port; |
|
494 | 494 | return $scheme.'://'.$host; |
495 | 495 | } |
496 | 496 | |
@@ -499,10 +499,10 @@ discard block |
||
499 | 499 | */ |
500 | 500 | public function getApplicationUrl() |
501 | 501 | { |
502 | - if($this->_cgiFix&self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
502 | + if($this->_cgiFix & self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
503 | 503 | return $_SERVER['ORIG_SCRIPT_NAME']; |
504 | 504 | |
505 | - return isset($_SERVER['SCRIPT_NAME'])?$_SERVER['SCRIPT_NAME']:null; |
|
505 | + return isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : null; |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | */ |
515 | 515 | public function getAbsoluteApplicationUrl($forceSecureConnection=null) |
516 | 516 | { |
517 | - return $this->getBaseUrl($forceSecureConnection) . $this->getApplicationUrl(); |
|
517 | + return $this->getBaseUrl($forceSecureConnection).$this->getApplicationUrl(); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | */ |
523 | 523 | public function getApplicationFilePath() |
524 | 524 | { |
525 | - return realpath(isset($_SERVER['SCRIPT_FILENAME'])?$_SERVER['SCRIPT_FILENAME']:null); |
|
525 | + return realpath(isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : null); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | */ |
531 | 531 | public function getServerName() |
532 | 532 | { |
533 | - return isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:null; |
|
533 | + return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null; |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | */ |
539 | 539 | public function getServerPort() |
540 | 540 | { |
541 | - return isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:null; |
|
541 | + return isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null; |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | */ |
547 | 547 | public function getUrlReferrer() |
548 | 548 | { |
549 | - return isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null; |
|
549 | + return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | /** |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | */ |
571 | 571 | public function getUserAgent() |
572 | 572 | { |
573 | - return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null; |
|
573 | + return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | */ |
579 | 579 | public function getUserHostAddress() |
580 | 580 | { |
581 | - return isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null; |
|
581 | + return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | /** |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | */ |
587 | 587 | public function getUserHost() |
588 | 588 | { |
589 | - return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null; |
|
589 | + return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null; |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | public function getAcceptTypes() |
596 | 596 | { |
597 | 597 | // TBD: break it into array?? |
598 | - return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null; |
|
598 | + return isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
@@ -660,13 +660,13 @@ discard block |
||
660 | 660 | foreach($_COOKIE as $key=>$value) |
661 | 661 | { |
662 | 662 | if(($value=$sm->validateData($value))!==false) |
663 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
663 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
664 | 664 | } |
665 | 665 | } |
666 | 666 | else |
667 | 667 | { |
668 | 668 | foreach($_COOKIE as $key=>$value) |
669 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
669 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
670 | 670 | } |
671 | 671 | } |
672 | 672 | return $this->_cookies; |
@@ -713,13 +713,13 @@ discard block |
||
713 | 713 | * @return string URL |
714 | 714 | * @see TUrlManager::constructUrl |
715 | 715 | */ |
716 | - public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
716 | + public function constructUrl($serviceID, $serviceParam, $getItems=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
717 | 717 | { |
718 | - if ($this->_cookieOnly===null) |
|
719 | - $this->_cookieOnly=(int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies'); |
|
720 | - $url=$this->getUrlManagerModule()->constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems); |
|
721 | - if(defined('SID') && SID != '' && !$this->_cookieOnly) |
|
722 | - return $url . (strpos($url,'?')===false? '?' : ($encodeAmpersand?'&':'&')) . SID; |
|
718 | + if($this->_cookieOnly===null) |
|
719 | + $this->_cookieOnly=(int) ini_get('session.use_cookies') && (int) ini_get('session.use_only_cookies'); |
|
720 | + $url=$this->getUrlManagerModule()->constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems); |
|
721 | + if(defined('SID') && SID!='' && !$this->_cookieOnly) |
|
722 | + return $url.(strpos($url, '?')===false ? '?' : ($encodeAmpersand ? '&' : '&')).SID; |
|
723 | 723 | else |
724 | 724 | return $url; |
725 | 725 | } |
@@ -747,11 +747,11 @@ discard block |
||
747 | 747 | */ |
748 | 748 | public function resolveRequest($serviceIDs) |
749 | 749 | { |
750 | - Prado::trace("Resolving request from ".$_SERVER['REMOTE_ADDR'],'System.Web.THttpRequest'); |
|
750 | + Prado::trace("Resolving request from ".$_SERVER['REMOTE_ADDR'], 'System.Web.THttpRequest'); |
|
751 | 751 | $getParams=$this->parseUrl(); |
752 | 752 | foreach($getParams as $name=>$value) |
753 | 753 | $_GET[$name]=$value; |
754 | - $this->_items=array_merge($_GET,$_POST); |
|
754 | + $this->_items=array_merge($_GET, $_POST); |
|
755 | 755 | $this->_requestResolved=true; |
756 | 756 | foreach($serviceIDs as $serviceID) |
757 | 757 | { |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | * @param mixed key |
863 | 863 | * @param mixed value |
864 | 864 | */ |
865 | - public function add($key,$value) |
|
865 | + public function add($key, $value) |
|
866 | 866 | { |
867 | 867 | $this->_items[$key]=$value; |
868 | 868 | } |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | */ |
876 | 876 | public function remove($key) |
877 | 877 | { |
878 | - if(isset($this->_items[$key]) || array_key_exists($key,$this->_items)) |
|
878 | + if(isset($this->_items[$key]) || array_key_exists($key, $this->_items)) |
|
879 | 879 | { |
880 | 880 | $value=$this->_items[$key]; |
881 | 881 | unset($this->_items[$key]); |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | */ |
901 | 901 | public function contains($key) |
902 | 902 | { |
903 | - return isset($this->_items[$key]) || array_key_exists($key,$this->_items); |
|
903 | + return isset($this->_items[$key]) || array_key_exists($key, $this->_items); |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | /** |
@@ -939,9 +939,9 @@ discard block |
||
939 | 939 | * @param integer the offset to set element |
940 | 940 | * @param mixed the element value |
941 | 941 | */ |
942 | - public function offsetSet($offset,$item) |
|
942 | + public function offsetSet($offset, $item) |
|
943 | 943 | { |
944 | - $this->add($offset,$item); |
|
944 | + $this->add($offset, $item); |
|
945 | 945 | } |
946 | 946 | |
947 | 947 | /** |
@@ -994,11 +994,11 @@ discard block |
||
994 | 994 | * @param mixed new item |
995 | 995 | * @throws TInvalidDataTypeException if the item to be inserted is not a THttpCookie object. |
996 | 996 | */ |
997 | - public function insertAt($index,$item) |
|
997 | + public function insertAt($index, $item) |
|
998 | 998 | { |
999 | 999 | if($item instanceof THttpCookie) |
1000 | 1000 | { |
1001 | - parent::insertAt($index,$item); |
|
1001 | + parent::insertAt($index, $item); |
|
1002 | 1002 | if($this->_o instanceof THttpResponse) |
1003 | 1003 | $this->_o->addCookie($item); |
1004 | 1004 | } |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | * @param string name of this cookie |
1094 | 1094 | * @param string value of this cookie |
1095 | 1095 | */ |
1096 | - public function __construct($name,$value) |
|
1096 | + public function __construct($name, $value) |
|
1097 | 1097 | { |
1098 | 1098 | $this->_name=$name; |
1099 | 1099 | $this->_value=$value; |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | */ |
1145 | 1145 | public function setHttpOnly($value) |
1146 | 1146 | { |
1147 | - $this->_httpOnly = TPropertyValue::ensureBoolean($value); |
|
1147 | + $this->_httpOnly=TPropertyValue::ensureBoolean($value); |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | /** |
@@ -1294,19 +1294,19 @@ discard block |
||
1294 | 1294 | if(($ret=@parse_url($uri))!==false) |
1295 | 1295 | { |
1296 | 1296 | // decoding??? |
1297 | - $this->_scheme=isset($ret['scheme'])?$ret['scheme']:''; |
|
1298 | - $this->_host=isset($ret['host'])?$ret['host']:''; |
|
1299 | - $this->_port=isset($ret['port'])?$ret['port']:''; |
|
1300 | - $this->_user=isset($ret['user'])?$ret['user']:''; |
|
1301 | - $this->_pass=isset($ret['pass'])?$ret['pass']:''; |
|
1302 | - $this->_path=isset($ret['path'])?$ret['path']:''; |
|
1303 | - $this->_query=isset($ret['query'])?$ret['query']:''; |
|
1304 | - $this->_fragment=isset($ret['fragment'])?$ret['fragment']:''; |
|
1297 | + $this->_scheme=isset($ret['scheme']) ? $ret['scheme'] : ''; |
|
1298 | + $this->_host=isset($ret['host']) ? $ret['host'] : ''; |
|
1299 | + $this->_port=isset($ret['port']) ? $ret['port'] : ''; |
|
1300 | + $this->_user=isset($ret['user']) ? $ret['user'] : ''; |
|
1301 | + $this->_pass=isset($ret['pass']) ? $ret['pass'] : ''; |
|
1302 | + $this->_path=isset($ret['path']) ? $ret['path'] : ''; |
|
1303 | + $this->_query=isset($ret['query']) ? $ret['query'] : ''; |
|
1304 | + $this->_fragment=isset($ret['fragment']) ? $ret['fragment'] : ''; |
|
1305 | 1305 | $this->_uri=$uri; |
1306 | 1306 | } |
1307 | 1307 | else |
1308 | 1308 | { |
1309 | - throw new TInvalidDataValueException('uri_format_invalid',$uri); |
|
1309 | + throw new TInvalidDataValueException('uri_format_invalid', $uri); |
|
1310 | 1310 | } |
1311 | 1311 | } |
1312 | 1312 |
@@ -224,8 +224,7 @@ discard block |
||
224 | 224 | $port=$_SERVER['SERVER_PORT']; |
225 | 225 | if(($port!=80 && !$secure) || ($port!=443 && $secure)) |
226 | 226 | $url.=':'.$port; |
227 | - } |
|
228 | - else |
|
227 | + } else |
|
229 | 228 | $url.=$_SERVER['HTTP_HOST']; |
230 | 229 | $url.=$this->getRequestUri(); |
231 | 230 | $this->_url=new TUri($url); |
@@ -333,8 +332,7 @@ discard block |
||
333 | 332 | { |
334 | 333 | $this->_urlManager=new TUrlManager; |
335 | 334 | $this->_urlManager->init(null); |
336 | - } |
|
337 | - else |
|
335 | + } else |
|
338 | 336 | { |
339 | 337 | $this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID); |
340 | 338 | if($this->_urlManager===null) |
@@ -454,8 +452,7 @@ discard block |
||
454 | 452 | |
455 | 453 | if($result === null && function_exists('apache_request_headers')) { |
456 | 454 | $result = apache_request_headers(); |
457 | - } |
|
458 | - elseif($result === null) { |
|
455 | + } elseif($result === null) { |
|
459 | 456 | $result = array(); |
460 | 457 | foreach($_SERVER as $key=>$value) { |
461 | 458 | if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
@@ -558,8 +555,7 @@ discard block |
||
558 | 555 | try |
559 | 556 | { |
560 | 557 | return get_browser(); |
561 | - } |
|
562 | - catch(TPhpErrorException $e) |
|
558 | + } catch(TPhpErrorException $e) |
|
563 | 559 | { |
564 | 560 | throw new TConfigurationException('httprequest_browscap_required'); |
565 | 561 | } |
@@ -662,8 +658,7 @@ discard block |
||
662 | 658 | if(($value=$sm->validateData($value))!==false) |
663 | 659 | $this->_cookies->add(new THttpCookie($key,$value)); |
664 | 660 | } |
665 | - } |
|
666 | - else |
|
661 | + } else |
|
667 | 662 | { |
668 | 663 | foreach($_COOKIE as $key=>$value) |
669 | 664 | $this->_cookies->add(new THttpCookie($key,$value)); |
@@ -880,8 +875,7 @@ discard block |
||
880 | 875 | $value=$this->_items[$key]; |
881 | 876 | unset($this->_items[$key]); |
882 | 877 | return $value; |
883 | - } |
|
884 | - else |
|
878 | + } else |
|
885 | 879 | return null; |
886 | 880 | } |
887 | 881 | |
@@ -1001,8 +995,7 @@ discard block |
||
1001 | 995 | parent::insertAt($index,$item); |
1002 | 996 | if($this->_o instanceof THttpResponse) |
1003 | 997 | $this->_o->addCookie($item); |
1004 | - } |
|
1005 | - else |
|
998 | + } else |
|
1006 | 999 | throw new TInvalidDataTypeException('httpcookiecollection_httpcookie_required'); |
1007 | 1000 | } |
1008 | 1001 | |
@@ -1303,8 +1296,7 @@ discard block |
||
1303 | 1296 | $this->_query=isset($ret['query'])?$ret['query']:''; |
1304 | 1297 | $this->_fragment=isset($ret['fragment'])?$ret['fragment']:''; |
1305 | 1298 | $this->_uri=$uri; |
1306 | - } |
|
1307 | - else |
|
1299 | + } else |
|
1308 | 1300 | { |
1309 | 1301 | throw new TInvalidDataValueException('uri_format_invalid',$uri); |
1310 | 1302 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
226 | - * @return string|boolean output charset. |
|
226 | + * @return string output charset. |
|
227 | 227 | */ |
228 | 228 | public function getCharset() |
229 | 229 | { |
@@ -232,6 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | /** |
234 | 234 | * @param string|boolean output charset. |
235 | + * @param string $charset |
|
235 | 236 | */ |
236 | 237 | public function setCharset($charset) |
237 | 238 | { |
@@ -604,6 +605,7 @@ discard block |
||
604 | 605 | * Sends a header. |
605 | 606 | * @param string header |
606 | 607 | * @param boolean whether the header should replace a previous similar header, or add a second header of the same type |
608 | + * @param string $value |
|
607 | 609 | */ |
608 | 610 | public function appendHeader($value, $replace=true) |
609 | 611 | { |
@@ -629,6 +631,7 @@ discard block |
||
629 | 631 | * Sends a cookie. |
630 | 632 | * Do not call this method directly. Operate with the result of {@link getCookies} instead. |
631 | 633 | * @param THttpCookie cook to be sent |
634 | + * @param THttpCookie $cookie |
|
632 | 635 | */ |
633 | 636 | public function addCookie($cookie) |
634 | 637 | { |
@@ -713,6 +716,7 @@ discard block |
||
713 | 716 | * This method is used internally. Please use {@link createHtmlWriter} instead. |
714 | 717 | * @param string type of HTML writer to be created. |
715 | 718 | * @param ITextWriter text writer holding the contents. |
719 | + * @param THttpResponse $writer |
|
716 | 720 | */ |
717 | 721 | public function createNewHtmlWriter($type, $writer) |
718 | 722 | { |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | */ |
65 | 65 | class THttpResponse extends TModule implements ITextWriter |
66 | 66 | { |
67 | - const DEFAULT_CONTENTTYPE = 'text/html'; |
|
68 | - const DEFAULT_CHARSET = 'UTF-8'; |
|
67 | + const DEFAULT_CONTENTTYPE='text/html'; |
|
68 | + const DEFAULT_CHARSET='UTF-8'; |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @var The differents defined status code by RFC 2616 {@link http://www.faqs.org/rfcs/rfc2616} |
72 | 72 | */ |
73 | - private static $HTTP_STATUS_CODES = array( |
|
73 | + private static $HTTP_STATUS_CODES=array( |
|
74 | 74 | 100 => 'Continue', 101 => 'Switching Protocols', |
75 | 75 | 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', |
76 | 76 | 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function setCacheControl($value) |
203 | 203 | { |
204 | - session_cache_limiter(TPropertyValue::ensureEnum($value,array('none','nocache','private','private_no_expire','public'))); |
|
204 | + session_cache_limiter(TPropertyValue::ensureEnum($value, array('none', 'nocache', 'private', 'private_no_expire', 'public'))); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function setContentType($type) |
211 | 211 | { |
212 | - if ($this->_contentTypeHeaderSent) |
|
212 | + if($this->_contentTypeHeaderSent) |
|
213 | 213 | throw new Exception('Unable to alter content-type as it has been already sent'); |
214 | - $this->_contentType = $type; |
|
214 | + $this->_contentType=$type; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function setCharset($charset) |
237 | 237 | { |
238 | - $this->_charset = (strToLower($charset) === 'false') ? false : (string)$charset; |
|
238 | + $this->_charset=(strToLower($charset)==='false') ? false : (string) $charset; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function setStatusCode($status, $reason=null) |
278 | 278 | { |
279 | - if ($this->_httpHeaderSent) |
|
279 | + if($this->_httpHeaderSent) |
|
280 | 280 | throw new Exception('Unable to alter response as HTTP header already sent'); |
281 | 281 | $status=TPropertyValue::ensureInteger($status); |
282 | 282 | if(isset(self::$HTTP_STATUS_CODES[$status])) { |
283 | 283 | $this->_reason=self::$HTTP_STATUS_CODES[$status]; |
284 | - }else{ |
|
284 | + } else { |
|
285 | 285 | if($reason===null || $reason==='') { |
286 | 286 | throw new TInvalidDataValueException("response_status_reason_missing"); |
287 | 287 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | public function write($str) |
320 | 320 | { |
321 | 321 | // when starting output make sure we send the headers first |
322 | - if (!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
322 | + if(!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
323 | 323 | $this->ensureHeadersSent(); |
324 | 324 | echo $str; |
325 | 325 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @param integer size of file or content in bytes if already known. Defaults to 'null' means auto-detect. |
337 | 337 | * @throws TInvalidDataValueException if the file cannot be found |
338 | 338 | */ |
339 | - public function writeFile($fileName,$content=null,$mimeType=null,$headers=null,$forceDownload=true,$clientFileName=null,$fileSize=null) |
|
339 | + public function writeFile($fileName, $content=null, $mimeType=null, $headers=null, $forceDownload=true, $clientFileName=null, $fileSize=null) |
|
340 | 340 | { |
341 | 341 | static $defaultMimeTypes=array( |
342 | 342 | 'css'=>'text/css', |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | $mimeType='text/plain'; |
357 | 357 | if(function_exists('mime_content_type')) |
358 | 358 | $mimeType=mime_content_type($fileName); |
359 | - else if(($ext=strrchr($fileName,'.'))!==false) |
|
359 | + else if(($ext=strrchr($fileName, '.'))!==false) |
|
360 | 360 | { |
361 | - $ext=substr($ext,1); |
|
361 | + $ext=substr($ext, 1); |
|
362 | 362 | if(isset($defaultMimeTypes[$ext])) |
363 | 363 | $mimeType=$defaultMimeTypes[$ext]; |
364 | 364 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $clientFileName=basename($clientFileName); |
371 | 371 | |
372 | 372 | if($fileSize===null || $fileSize < 0) |
373 | - $fileSize = ($content===null?filesize($fileName):strlen($content)); |
|
373 | + $fileSize=($content===null ? filesize($fileName) : strlen($content)); |
|
374 | 374 | |
375 | 375 | $this->sendHttpHeader(); |
376 | 376 | if(is_array($headers)) |
@@ -384,11 +384,11 @@ discard block |
||
384 | 384 | header('Expires: 0'); |
385 | 385 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
386 | 386 | header("Content-Type: $mimeType"); |
387 | - $this->_contentTypeHeaderSent = true; |
|
387 | + $this->_contentTypeHeaderSent=true; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | header('Content-Length: '.$fileSize); |
391 | - header("Content-Disposition: " . ($forceDownload ? 'attachment' : 'inline') . "; filename=\"$clientFileName\""); |
|
391 | + header("Content-Disposition: ".($forceDownload ? 'attachment' : 'inline')."; filename=\"$clientFileName\""); |
|
392 | 392 | header('Content-Transfer-Encoding: binary'); |
393 | 393 | if($content===null) |
394 | 394 | readfile($fileName); |
@@ -428,11 +428,11 @@ discard block |
||
428 | 428 | |
429 | 429 | if($url[0]==='/') |
430 | 430 | $url=$this->getRequest()->getBaseUrl().$url; |
431 | - if ($this->_status >= 300 && $this->_status < 400) |
|
431 | + if($this->_status >= 300 && $this->_status < 400) |
|
432 | 432 | // The status code has been modified to a valid redirection status, send it |
433 | - header('Location: '.str_replace('&','&',$url), true, $this->_status); |
|
433 | + header('Location: '.str_replace('&', '&', $url), true, $this->_status); |
|
434 | 434 | else |
435 | - header('Location: '.str_replace('&','&',$url)); |
|
435 | + header('Location: '.str_replace('&', '&', $url)); |
|
436 | 436 | |
437 | 437 | if(!$this->getApplication()->getRequestCompleted()) |
438 | 438 | $this->getApplication()->onEndRequest(); |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | /** |
454 | 454 | * Flush the response contents and headers. |
455 | 455 | */ |
456 | - public function flush($continueBuffering = true) |
|
456 | + public function flush($continueBuffering=true) |
|
457 | 457 | { |
458 | 458 | if($this->getHasAdapter()) |
459 | 459 | $this->_adapter->flushContent($continueBuffering); |
@@ -475,18 +475,18 @@ discard block |
||
475 | 475 | * This method is used internally. Please use {@link flush} instead. |
476 | 476 | * @param boolean whether to continue buffering after flush if buffering was active |
477 | 477 | */ |
478 | - public function flushContent($continueBuffering = true) |
|
478 | + public function flushContent($continueBuffering=true) |
|
479 | 479 | { |
480 | - Prado::trace("Flushing output",'System.Web.THttpResponse'); |
|
480 | + Prado::trace("Flushing output", 'System.Web.THttpResponse'); |
|
481 | 481 | $this->ensureHeadersSent(); |
482 | 482 | if($this->_bufferOutput) |
483 | 483 | { |
484 | 484 | // avoid forced send of http headers (ob_flush() does that) if there's no output yet |
485 | - if (ob_get_length()>0) |
|
485 | + if(ob_get_length() > 0) |
|
486 | 486 | { |
487 | - if (!$continueBuffering) |
|
487 | + if(!$continueBuffering) |
|
488 | 488 | { |
489 | - $this->_bufferOutput = false; |
|
489 | + $this->_bufferOutput=false; |
|
490 | 490 | ob_end_flush(); |
491 | 491 | } |
492 | 492 | else |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | */ |
504 | 504 | protected function ensureHttpHeaderSent() |
505 | 505 | { |
506 | - if (!$this->_httpHeaderSent) |
|
506 | + if(!$this->_httpHeaderSent) |
|
507 | 507 | $this->sendHttpHeader(); |
508 | 508 | } |
509 | 509 | |
@@ -513,15 +513,15 @@ discard block |
||
513 | 513 | protected function sendHttpHeader() |
514 | 514 | { |
515 | 515 | $protocol=$this->getRequest()->getHttpProtocolVersion(); |
516 | - if($this->getRequest()->getHttpProtocolVersion() === null) |
|
516 | + if($this->getRequest()->getHttpProtocolVersion()===null) |
|
517 | 517 | $protocol='HTTP/1.1'; |
518 | 518 | |
519 | - $phpSapiName = substr(php_sapi_name(), 0, 3); |
|
520 | - $cgi = $phpSapiName == 'cgi' || $phpSapiName == 'fpm'; |
|
519 | + $phpSapiName=substr(php_sapi_name(), 0, 3); |
|
520 | + $cgi=$phpSapiName=='cgi' || $phpSapiName=='fpm'; |
|
521 | 521 | |
522 | 522 | header(($cgi ? 'Status:' : $protocol).' '.$this->_status.' '.$this->_reason, true, TPropertyValue::ensureInteger($this->_status)); |
523 | 523 | |
524 | - $this->_httpHeaderSent = true; |
|
524 | + $this->_httpHeaderSent=true; |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | */ |
530 | 530 | protected function ensureContentTypeHeaderSent() |
531 | 531 | { |
532 | - if (!$this->_contentTypeHeaderSent) |
|
532 | + if(!$this->_contentTypeHeaderSent) |
|
533 | 533 | $this->sendContentTypeHeader(); |
534 | 534 | } |
535 | 535 | |
@@ -538,9 +538,9 @@ discard block |
||
538 | 538 | */ |
539 | 539 | protected function sendContentTypeHeader() |
540 | 540 | { |
541 | - $contentType=$this->_contentType===null?self::DEFAULT_CONTENTTYPE:$this->_contentType; |
|
541 | + $contentType=$this->_contentType===null ? self::DEFAULT_CONTENTTYPE : $this->_contentType; |
|
542 | 542 | $charset=$this->getCharset(); |
543 | - if($charset === false) { |
|
543 | + if($charset===false) { |
|
544 | 544 | $this->appendHeader('Content-Type: '.$contentType); |
545 | 545 | return; |
546 | 546 | } |
@@ -548,10 +548,10 @@ discard block |
||
548 | 548 | if($charset==='' && ($globalization=$this->getApplication()->getGlobalization(false))!==null) |
549 | 549 | $charset=$globalization->getCharset(); |
550 | 550 | |
551 | - if($charset==='') $charset = self::DEFAULT_CHARSET; |
|
551 | + if($charset==='') $charset=self::DEFAULT_CHARSET; |
|
552 | 552 | $this->appendHeader('Content-Type: '.$contentType.';charset='.$charset); |
553 | 553 | |
554 | - $this->_contentTypeHeaderSent = true; |
|
554 | + $this->_contentTypeHeaderSent=true; |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -562,8 +562,8 @@ discard block |
||
562 | 562 | */ |
563 | 563 | public function getContents() |
564 | 564 | { |
565 | - Prado::trace("Retrieving output",'System.Web.THttpResponse'); |
|
566 | - return $this->_bufferOutput?ob_get_contents():''; |
|
565 | + Prado::trace("Retrieving output", 'System.Web.THttpResponse'); |
|
566 | + return $this->_bufferOutput ? ob_get_contents() : ''; |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | { |
574 | 574 | if($this->_bufferOutput) |
575 | 575 | ob_clean(); |
576 | - Prado::trace("Clearing output",'System.Web.THttpResponse'); |
|
576 | + Prado::trace("Clearing output", 'System.Web.THttpResponse'); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | /** |
@@ -582,19 +582,19 @@ discard block |
||
582 | 582 | */ |
583 | 583 | public function getHeaders($case=null) |
584 | 584 | { |
585 | - $result = array(); |
|
586 | - $headers = headers_list(); |
|
585 | + $result=array(); |
|
586 | + $headers=headers_list(); |
|
587 | 587 | foreach($headers as $header) { |
588 | - $tmp = explode(':', $header); |
|
589 | - $key = trim(array_shift($tmp)); |
|
590 | - $value = trim(implode(':', $tmp)); |
|
588 | + $tmp=explode(':', $header); |
|
589 | + $key=trim(array_shift($tmp)); |
|
590 | + $value=trim(implode(':', $tmp)); |
|
591 | 591 | if(isset($result[$key])) |
592 | - $result[$key] .= ', ' . $value; |
|
592 | + $result[$key].=', '.$value; |
|
593 | 593 | else |
594 | - $result[$key] = $value; |
|
594 | + $result[$key]=$value; |
|
595 | 595 | } |
596 | 596 | |
597 | - if($case !== null) |
|
597 | + if($case!==null) |
|
598 | 598 | return array_change_key_case($result, $case); |
599 | 599 | |
600 | 600 | return $result; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | */ |
608 | 608 | public function appendHeader($value, $replace=true) |
609 | 609 | { |
610 | - Prado::trace("Sending header '$value'",'System.Web.THttpResponse'); |
|
610 | + Prado::trace("Sending header '$value'", 'System.Web.THttpResponse'); |
|
611 | 611 | header($value, $replace); |
612 | 612 | } |
613 | 613 | |
@@ -620,9 +620,9 @@ discard block |
||
620 | 620 | * @param string The extra headers. It's used when the message parameter is set to 1. This message type uses the same internal function as mail() does. |
621 | 621 | * @see http://us2.php.net/manual/en/function.error-log.php |
622 | 622 | */ |
623 | - public function appendLog($message,$messageType=0,$destination='',$extraHeaders='') |
|
623 | + public function appendLog($message, $messageType=0, $destination='', $extraHeaders='') |
|
624 | 624 | { |
625 | - error_log($message,$messageType,$destination,$extraHeaders); |
|
625 | + error_log($message, $messageType, $destination, $extraHeaders); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | /** |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $status=TPropertyValue::ensureInteger($status); |
282 | 282 | if(isset(self::$HTTP_STATUS_CODES[$status])) { |
283 | 283 | $this->_reason=self::$HTTP_STATUS_CODES[$status]; |
284 | - }else{ |
|
284 | + } else{ |
|
285 | 285 | if($reason===null || $reason==='') { |
286 | 286 | throw new TInvalidDataValueException("response_status_reason_missing"); |
287 | 287 | } |
@@ -377,8 +377,7 @@ discard block |
||
377 | 377 | { |
378 | 378 | foreach($headers as $h) |
379 | 379 | header($h); |
380 | - } |
|
381 | - else |
|
380 | + } else |
|
382 | 381 | { |
383 | 382 | header('Pragma: public'); |
384 | 383 | header('Expires: 0'); |
@@ -488,13 +487,11 @@ discard block |
||
488 | 487 | { |
489 | 488 | $this->_bufferOutput = false; |
490 | 489 | ob_end_flush(); |
491 | - } |
|
492 | - else |
|
490 | + } else |
|
493 | 491 | ob_flush(); |
494 | 492 | flush(); |
495 | 493 | } |
496 | - } |
|
497 | - else |
|
494 | + } else |
|
498 | 495 | flush(); |
499 | 496 | } |
500 | 497 | |
@@ -645,8 +642,7 @@ discard block |
||
645 | 642 | $cookie->getSecure(), |
646 | 643 | $cookie->getHttpOnly() |
647 | 644 | ); |
648 | - } |
|
649 | - else { |
|
645 | + } else { |
|
650 | 646 | setcookie( |
651 | 647 | $cookie->getName(), |
652 | 648 | $cookie->getValue(), |
@@ -606,6 +606,7 @@ discard block |
||
606 | 606 | |
607 | 607 | /** |
608 | 608 | * @param string full regular expression mapping pattern. |
609 | + * @param string $value |
|
609 | 610 | */ |
610 | 611 | public function setRegularExpression($value) |
611 | 612 | { |
@@ -715,6 +716,7 @@ discard block |
||
715 | 716 | * Uses URL pattern (or full regular expression if available) to |
716 | 717 | * match the given url path. |
717 | 718 | * @param THttpRequest the request module |
719 | + * @param THttpRequest $request |
|
718 | 720 | * @return array matched parameters, empty if no matches. |
719 | 721 | */ |
720 | 722 | public function getPatternMatches($request) |
@@ -785,7 +787,7 @@ discard block |
||
785 | 787 | } |
786 | 788 | |
787 | 789 | /** |
788 | - * @return THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
790 | + * @return string the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
789 | 791 | */ |
790 | 792 | public function getUrlFormat() |
791 | 793 | { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $this->_urlPrefix=$request->getApplicationUrl(); |
117 | 117 | } |
118 | 118 | } |
119 | - $this->_urlPrefix=rtrim($this->_urlPrefix,'/'); |
|
119 | + $this->_urlPrefix=rtrim($this->_urlPrefix, '/'); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
131 | 131 | { |
132 | - $config = include $this->_configFile; |
|
132 | + $config=include $this->_configFile; |
|
133 | 133 | $this->loadUrlMappings($dom); |
134 | 134 | } |
135 | 135 | else |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | } |
142 | 142 | else |
143 | - throw new TConfigurationException('urlmapping_configfile_inexistent',$this->_configFile); |
|
143 | + throw new TConfigurationException('urlmapping_configfile_inexistent', $this->_configFile); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function setConfigFile($value) |
203 | 203 | { |
204 | - if(($this->_configFile=Prado::getPathOfNamespace($value,$this->getApplication()->getConfigurationFileExt()))===null) |
|
205 | - throw new TConfigurationException('urlmapping_configfile_invalid',$value); |
|
204 | + if(($this->_configFile=Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt()))===null) |
|
205 | + throw new TConfigurationException('urlmapping_configfile_invalid', $value); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | protected function loadUrlMappings($config) |
235 | 235 | { |
236 | - $defaultClass = $this->getDefaultMappingClass(); |
|
236 | + $defaultClass=$this->getDefaultMappingClass(); |
|
237 | 237 | |
238 | 238 | if(is_array($config)) |
239 | 239 | { |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | { |
242 | 242 | foreach($config['urls'] as $url) |
243 | 243 | { |
244 | - $class=isset($url['class'])?$url['class']:$defaultClass; |
|
245 | - $properties = isset($url['properties'])?$url['properties']:array(); |
|
246 | - $this->buildUrlMapping($class,$properties,$url); |
|
244 | + $class=isset($url['class']) ? $url['class'] : $defaultClass; |
|
245 | + $properties=isset($url['properties']) ? $url['properties'] : array(); |
|
246 | + $this->buildUrlMapping($class, $properties, $url); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
@@ -254,24 +254,24 @@ discard block |
||
254 | 254 | $properties=$url->getAttributes(); |
255 | 255 | if(($class=$properties->remove('class'))===null) |
256 | 256 | $class=$defaultClass; |
257 | - $this->buildUrlMapping($class,$properties,$url); |
|
257 | + $this->buildUrlMapping($class, $properties, $url); |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | 262 | private function buildUrlMapping($class, $properties, $url) |
263 | 263 | { |
264 | - $pattern=Prado::createComponent($class,$this); |
|
264 | + $pattern=Prado::createComponent($class, $this); |
|
265 | 265 | if(!($pattern instanceof TUrlMappingPattern)) |
266 | 266 | throw new TConfigurationException('urlmapping_urlmappingpattern_required'); |
267 | 267 | foreach($properties as $name=>$value) |
268 | - $pattern->setSubproperty($name,$value); |
|
268 | + $pattern->setSubproperty($name, $value); |
|
269 | 269 | |
270 | 270 | if($url instanceof TXmlElement) { |
271 | - $text = $url -> getValue(); |
|
271 | + $text=$url -> getValue(); |
|
272 | 272 | if($text) { |
273 | - $text = preg_replace('/(\s+)/S', '', $text); |
|
274 | - if(($regExp = $pattern->getRegularExpression()) !== '') |
|
273 | + $text=preg_replace('/(\s+)/S', '', $text); |
|
274 | + if(($regExp=$pattern->getRegularExpression())!=='') |
|
275 | 275 | trigger_error(sPrintF('%s.RegularExpression property value "%s" for ServiceID="%s" and ServiceParameter="%s" was replaced by node value "%s"', |
276 | 276 | get_class($pattern), |
277 | 277 | $regExp, |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | foreach($this->_patterns as $pattern) |
305 | 305 | { |
306 | 306 | $matches=$pattern->getPatternMatches($request); |
307 | - if(count($matches)>0) |
|
307 | + if(count($matches) > 0) |
|
308 | 308 | { |
309 | 309 | $this->_matched=$pattern; |
310 | 310 | $params=array(); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | if(is_string($key)) |
314 | 314 | $params[$key]=$value; |
315 | 315 | } |
316 | - if (!$pattern->getIsWildCardPattern()) |
|
316 | + if(!$pattern->getIsWildCardPattern()) |
|
317 | 317 | $params[$pattern->getServiceID()]=$pattern->getServiceParameter(); |
318 | 318 | return $params; |
319 | 319 | } |
@@ -345,21 +345,21 @@ discard block |
||
345 | 345 | * @see parseUrl |
346 | 346 | * @since 3.1.1 |
347 | 347 | */ |
348 | - public function constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems) |
|
348 | + public function constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems) |
|
349 | 349 | { |
350 | 350 | if($this->_customUrl) |
351 | 351 | { |
352 | 352 | if(!(is_array($getItems) || ($getItems instanceof Traversable))) |
353 | 353 | $getItems=array(); |
354 | 354 | $key=$serviceID.':'.$serviceParam; |
355 | - $wildCardKey = ($pos=strrpos($serviceParam,'.'))!==false ? |
|
356 | - $serviceID.':'.substr($serviceParam,0,$pos).'.*' : $serviceID.':*'; |
|
355 | + $wildCardKey=($pos=strrpos($serviceParam, '.'))!==false ? |
|
356 | + $serviceID.':'.substr($serviceParam, 0, $pos).'.*' : $serviceID.':*'; |
|
357 | 357 | if(isset($this->_constructRules[$key])) |
358 | 358 | { |
359 | 359 | foreach($this->_constructRules[$key] as $rule) |
360 | 360 | { |
361 | 361 | if($rule->supportCustomUrl($getItems)) |
362 | - return $rule->constructUrl($getItems,$encodeAmpersand,$encodeGetItems); |
|
362 | + return $rule->constructUrl($getItems, $encodeAmpersand, $encodeGetItems); |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | elseif(isset($this->_constructRules[$wildCardKey])) |
@@ -368,13 +368,13 @@ discard block |
||
368 | 368 | { |
369 | 369 | if($rule->supportCustomUrl($getItems)) |
370 | 370 | { |
371 | - $getItems['*']= $pos ? substr($serviceParam,$pos+1) : $serviceParam; |
|
372 | - return $rule->constructUrl($getItems,$encodeAmpersand,$encodeGetItems); |
|
371 | + $getItems['*']=$pos ? substr($serviceParam, $pos + 1) : $serviceParam; |
|
372 | + return $rule->constructUrl($getItems, $encodeAmpersand, $encodeGetItems); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | } |
376 | 376 | } |
377 | - return parent::constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems); |
|
377 | + return parent::constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | * @var TUrlMappingPatternSecureConnection |
529 | 529 | * @since 3.2 |
530 | 530 | */ |
531 | - private $_secureConnection = TUrlMappingPatternSecureConnection::Automatic; |
|
531 | + private $_secureConnection=TUrlMappingPatternSecureConnection::Automatic; |
|
532 | 532 | |
533 | 533 | /** |
534 | 534 | * Constructor. |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | { |
557 | 557 | if($this->_serviceParameter===null) |
558 | 558 | throw new TConfigurationException('urlmappingpattern_serviceparameter_required', $this->getPattern()); |
559 | - if(strpos($this->_serviceParameter,'*')!==false) |
|
559 | + if(strpos($this->_serviceParameter, '*')!==false) |
|
560 | 560 | $this->_isWildCardPattern=true; |
561 | 561 | } |
562 | 562 | |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | { |
570 | 570 | $params=array(); |
571 | 571 | $values=array(); |
572 | - if ($this->_parameters) |
|
572 | + if($this->_parameters) |
|
573 | 573 | { |
574 | 574 | foreach($this->_parameters as $key=>$value) |
575 | 575 | { |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | $values[]='(?P<'.$key.'>'.$value.')'; |
578 | 578 | } |
579 | 579 | } |
580 | - if ($this->getIsWildCardPattern()) |
|
580 | + if($this->getIsWildCardPattern()) |
|
581 | 581 | { |
582 | 582 | $params[]='{*}'; |
583 | 583 | // service parameter must not contain '=' and '/' |
@@ -585,8 +585,8 @@ discard block |
||
585 | 585 | } |
586 | 586 | $params[]='/'; |
587 | 587 | $values[]='\\/'; |
588 | - $regexp=str_replace($params,$values,trim($this->getPattern(),'/').'/'); |
|
589 | - if ($this->_urlFormat===THttpRequestUrlFormat::Get) |
|
588 | + $regexp=str_replace($params, $values, trim($this->getPattern(), '/').'/'); |
|
589 | + if($this->_urlFormat===THttpRequestUrlFormat::Get) |
|
590 | 590 | $regexp='/^'.$regexp.'$/u'; |
591 | 591 | else |
592 | 592 | $regexp='/^'.$regexp.'(?P<urlparams>.*)$/u'; |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | */ |
674 | 674 | public function setPattern($value) |
675 | 675 | { |
676 | - $this->_pattern = $value; |
|
676 | + $this->_pattern=$value; |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | /** |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | */ |
682 | 682 | public function getParameters() |
683 | 683 | { |
684 | - if (!$this->_parameters) |
|
684 | + if(!$this->_parameters) |
|
685 | 685 | { |
686 | 686 | $this->_parameters=new TAttributeCollection; |
687 | 687 | $this->_parameters->setCaseSensitive(true); |
@@ -703,9 +703,9 @@ discard block |
||
703 | 703 | */ |
704 | 704 | public function getConstants() |
705 | 705 | { |
706 | - if (!$this->_constants) |
|
706 | + if(!$this->_constants) |
|
707 | 707 | { |
708 | - $this->_constants = new TAttributeCollection; |
|
708 | + $this->_constants=new TAttributeCollection; |
|
709 | 709 | $this->_constants->setCaseSensitive(true); |
710 | 710 | } |
711 | 711 | return $this->_constants; |
@@ -721,17 +721,17 @@ discard block |
||
721 | 721 | { |
722 | 722 | $matches=array(); |
723 | 723 | if(($pattern=$this->getRegularExpression())!=='') |
724 | - preg_match($pattern,$request->getPathInfo(),$matches); |
|
724 | + preg_match($pattern, $request->getPathInfo(), $matches); |
|
725 | 725 | else |
726 | - preg_match($this->getParameterizedPattern(),trim($request->getPathInfo(),'/').'/',$matches); |
|
726 | + preg_match($this->getParameterizedPattern(), trim($request->getPathInfo(), '/').'/', $matches); |
|
727 | 727 | |
728 | 728 | if($this->getIsWildCardPattern() && isset($matches[$this->_serviceID])) |
729 | - $matches[$this->_serviceID]=str_replace('*',$matches[$this->_serviceID],$this->_serviceParameter); |
|
729 | + $matches[$this->_serviceID]=str_replace('*', $matches[$this->_serviceID], $this->_serviceParameter); |
|
730 | 730 | |
731 | - if (isset($matches['urlparams'])) |
|
731 | + if(isset($matches['urlparams'])) |
|
732 | 732 | { |
733 | - $params=explode('/',$matches['urlparams']); |
|
734 | - if ($this->_separator==='/') |
|
733 | + $params=explode('/', $matches['urlparams']); |
|
734 | + if($this->_separator==='/') |
|
735 | 735 | { |
736 | 736 | while($key=array_shift($params)) |
737 | 737 | $matches[$key]=($value=array_shift($params)) ? $value : ''; |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | array_pop($params); |
742 | 742 | foreach($params as $param) |
743 | 743 | { |
744 | - list($key,$value)=explode($this->_separator,$param,2); |
|
744 | + list($key, $value)=explode($this->_separator, $param, 2); |
|
745 | 745 | $matches[$key]=$value; |
746 | 746 | } |
747 | 747 | } |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | if(count($matches) > 0 && $this->_constants) |
752 | 752 | { |
753 | 753 | foreach($this->_constants->toArray() as $key=>$value) |
754 | - $matches[$key] = $value; |
|
754 | + $matches[$key]=$value; |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | return $matches; |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | */ |
806 | 806 | public function setUrlFormat($value) |
807 | 807 | { |
808 | - $this->_urlFormat=TPropertyValue::ensureEnum($value,'THttpRequestUrlFormat'); |
|
808 | + $this->_urlFormat=TPropertyValue::ensureEnum($value, 'THttpRequestUrlFormat'); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | /** |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | */ |
844 | 844 | public function setSecureConnection($value) |
845 | 845 | { |
846 | - $this->_secureConnection = TPropertyValue::ensureEnum($value, 'TUrlMappingPatternSecureConnection'); |
|
846 | + $this->_secureConnection=TPropertyValue::ensureEnum($value, 'TUrlMappingPatternSecureConnection'); |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | /** |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | { |
856 | 856 | if(!$this->_customUrl || $this->getPattern()===null) |
857 | 857 | return false; |
858 | - if ($this->_parameters) |
|
858 | + if($this->_parameters) |
|
859 | 859 | { |
860 | 860 | foreach($this->_parameters as $key=>$value) |
861 | 861 | { |
@@ -864,13 +864,13 @@ discard block |
||
864 | 864 | } |
865 | 865 | } |
866 | 866 | |
867 | - if ($this->_constants) |
|
867 | + if($this->_constants) |
|
868 | 868 | { |
869 | 869 | foreach($this->_constants->toArray() as $key=>$value) |
870 | 870 | { |
871 | - if (!isset($getItems[$key])) |
|
871 | + if(!isset($getItems[$key])) |
|
872 | 872 | return false; |
873 | - if ($getItems[$key]!=$value) |
|
873 | + if($getItems[$key]!=$value) |
|
874 | 874 | return false; |
875 | 875 | } |
876 | 876 | } |
@@ -885,9 +885,9 @@ discard block |
||
885 | 885 | * @return string the constructed URL |
886 | 886 | * @since 3.1.1 |
887 | 887 | */ |
888 | - public function constructUrl($getItems,$encodeAmpersand,$encodeGetItems) |
|
888 | + public function constructUrl($getItems, $encodeAmpersand, $encodeGetItems) |
|
889 | 889 | { |
890 | - if ($this->_constants) |
|
890 | + if($this->_constants) |
|
891 | 891 | { |
892 | 892 | foreach($this->_constants->toArray() as $key=>$value) |
893 | 893 | { |
@@ -906,19 +906,19 @@ discard block |
||
906 | 906 | $extra[$key]=$value; |
907 | 907 | } |
908 | 908 | |
909 | - $url=$this->_manager->getUrlPrefix().'/'.ltrim(strtr($this->getPattern(),$replace),'/'); |
|
909 | + $url=$this->_manager->getUrlPrefix().'/'.ltrim(strtr($this->getPattern(), $replace), '/'); |
|
910 | 910 | |
911 | 911 | // for the rest of the GET variables, put them in the query string |
912 | - if(count($extra)>0) |
|
912 | + if(count($extra) > 0) |
|
913 | 913 | { |
914 | - if ($this->_urlFormat===THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { |
|
915 | - foreach ($extra as $name=>$value) |
|
916 | - $url.='/'.$name.$this->_separator.($encodeGetItems?rawurlencode($value):$value); |
|
914 | + if($this->_urlFormat===THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { |
|
915 | + foreach($extra as $name=>$value) |
|
916 | + $url.='/'.$name.$this->_separator.($encodeGetItems ? rawurlencode($value) : $value); |
|
917 | 917 | return $url; |
918 | 918 | } |
919 | 919 | |
920 | 920 | $url2=''; |
921 | - $amp=$encodeAmpersand?'&':'&'; |
|
921 | + $amp=$encodeAmpersand ? '&' : '&'; |
|
922 | 922 | if($encodeGetItems) |
923 | 923 | { |
924 | 924 | foreach($extra as $name=>$value) |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | $url2.=$amp.$name.'='.$value; |
947 | 947 | } |
948 | 948 | } |
949 | - $url=$url.'?'.substr($url2,strlen($amp)); |
|
949 | + $url=$url.'?'.substr($url2, strlen($amp)); |
|
950 | 950 | } |
951 | 951 | return $this -> applySecureConnectionPrefix($url); |
952 | 952 | } |
@@ -962,26 +962,26 @@ discard block |
||
962 | 962 | protected function applySecureConnectionPrefix($url) |
963 | 963 | { |
964 | 964 | static $request; |
965 | - if($request === null) $request = Prado::getApplication() -> getRequest(); |
|
965 | + if($request===null) $request=Prado::getApplication() -> getRequest(); |
|
966 | 966 | |
967 | 967 | static $isSecureConnection; |
968 | - if($isSecureConnection === null) $isSecureConnection = $request -> getIsSecureConnection(); |
|
968 | + if($isSecureConnection===null) $isSecureConnection=$request -> getIsSecureConnection(); |
|
969 | 969 | |
970 | 970 | switch($this -> getSecureConnection()) |
971 | 971 | { |
972 | 972 | case TUrlMappingPatternSecureConnection::EnableIfNotSecure: |
973 | 973 | if($isSecureConnection) return $url; |
974 | - return $request -> getBaseUrl(true) . $url; |
|
974 | + return $request -> getBaseUrl(true).$url; |
|
975 | 975 | break; |
976 | 976 | case TUrlMappingPatternSecureConnection::DisableIfSecure: |
977 | 977 | if(!$isSecureConnection) return $url; |
978 | - return $request -> getBaseUrl(false) . $url; |
|
978 | + return $request -> getBaseUrl(false).$url; |
|
979 | 979 | break; |
980 | 980 | case TUrlMappingPatternSecureConnection::Enable: |
981 | - return $request -> getBaseUrl(true) . $url; |
|
981 | + return $request -> getBaseUrl(true).$url; |
|
982 | 982 | break; |
983 | 983 | case TUrlMappingPatternSecureConnection::Disable: |
984 | - return $request -> getBaseUrl(false) . $url; |
|
984 | + return $request -> getBaseUrl(false).$url; |
|
985 | 985 | break; |
986 | 986 | case TUrlMappingPatternSecureConnection::Automatic: |
987 | 987 | default: |
@@ -1007,29 +1007,29 @@ discard block |
||
1007 | 1007 | * Keep current SecureConnection status |
1008 | 1008 | * means no prefixing |
1009 | 1009 | */ |
1010 | - const Automatic = 'Automatic'; |
|
1010 | + const Automatic='Automatic'; |
|
1011 | 1011 | |
1012 | 1012 | /** |
1013 | 1013 | * Force use secured connection |
1014 | 1014 | * always prefixing with https://example.com/path/to/app |
1015 | 1015 | */ |
1016 | - const Enable = 'Enable'; |
|
1016 | + const Enable='Enable'; |
|
1017 | 1017 | |
1018 | 1018 | /** |
1019 | 1019 | * Force use unsecured connection |
1020 | 1020 | * always prefixing with http://example.com/path/to/app |
1021 | 1021 | */ |
1022 | - const Disable = 'Disable'; |
|
1022 | + const Disable='Disable'; |
|
1023 | 1023 | |
1024 | 1024 | /** |
1025 | 1025 | * Force use secured connection, if in unsecured mode |
1026 | 1026 | * prefixing with https://example.com/path/to/app |
1027 | 1027 | */ |
1028 | - const EnableIfNotSecure = 'EnableIfNotSecure'; |
|
1028 | + const EnableIfNotSecure='EnableIfNotSecure'; |
|
1029 | 1029 | |
1030 | 1030 | /** |
1031 | 1031 | * Force use unsecured connection, if in secured mode |
1032 | 1032 | * prefixing with https://example.com/path/to/app |
1033 | 1033 | */ |
1034 | - const DisableIfSecure = 'DisableIfSecure'; |
|
1034 | + const DisableIfSecure='DisableIfSecure'; |
|
1035 | 1035 | } |
@@ -131,15 +131,13 @@ discard block |
||
131 | 131 | { |
132 | 132 | $config = include $this->_configFile; |
133 | 133 | $this->loadUrlMappings($dom); |
134 | - } |
|
135 | - else |
|
134 | + } else |
|
136 | 135 | { |
137 | 136 | $dom=new TXmlDocument; |
138 | 137 | $dom->loadFromFile($this->_configFile); |
139 | 138 | $this->loadUrlMappings($dom); |
140 | 139 | } |
141 | - } |
|
142 | - else |
|
140 | + } else |
|
143 | 141 | throw new TConfigurationException('urlmapping_configfile_inexistent',$this->_configFile); |
144 | 142 | } |
145 | 143 | |
@@ -246,8 +244,7 @@ discard block |
||
246 | 244 | $this->buildUrlMapping($class,$properties,$url); |
247 | 245 | } |
248 | 246 | } |
249 | - } |
|
250 | - else |
|
247 | + } else |
|
251 | 248 | { |
252 | 249 | foreach($config->getElementsByTagName('url') as $url) |
253 | 250 | { |
@@ -361,8 +358,7 @@ discard block |
||
361 | 358 | if($rule->supportCustomUrl($getItems)) |
362 | 359 | return $rule->constructUrl($getItems,$encodeAmpersand,$encodeGetItems); |
363 | 360 | } |
364 | - } |
|
365 | - elseif(isset($this->_constructRules[$wildCardKey])) |
|
361 | + } elseif(isset($this->_constructRules[$wildCardKey])) |
|
366 | 362 | { |
367 | 363 | foreach($this->_constructRules[$wildCardKey] as $rule) |
368 | 364 | { |
@@ -733,10 +729,10 @@ discard block |
||
733 | 729 | $params=explode('/',$matches['urlparams']); |
734 | 730 | if ($this->_separator==='/') |
735 | 731 | { |
736 | - while($key=array_shift($params)) |
|
737 | - $matches[$key]=($value=array_shift($params)) ? $value : ''; |
|
738 | - } |
|
739 | - else |
|
732 | + while($key=array_shift($params)) { |
|
733 | + $matches[$key]=($value=array_shift($params)) ? $value : ''; |
|
734 | + } |
|
735 | + } else |
|
740 | 736 | { |
741 | 737 | array_pop($params); |
742 | 738 | foreach($params as $param) |
@@ -928,12 +924,10 @@ discard block |
||
928 | 924 | $name=rawurlencode($name.'[]'); |
929 | 925 | foreach($value as $v) |
930 | 926 | $url2.=$amp.$name.'='.rawurlencode($v); |
931 | - } |
|
932 | - else |
|
927 | + } else |
|
933 | 928 | $url2.=$amp.rawurlencode($name).'='.rawurlencode($value); |
934 | 929 | } |
935 | - } |
|
936 | - else |
|
930 | + } else |
|
937 | 931 | { |
938 | 932 | foreach($extra as $name=>$value) |
939 | 933 | { |
@@ -941,8 +935,7 @@ discard block |
||
941 | 935 | { |
942 | 936 | foreach($value as $v) |
943 | 937 | $url2.=$amp.$name.'[]='.$v; |
944 | - } |
|
945 | - else |
|
938 | + } else |
|
946 | 939 | $url2.=$amp.$name.'='.$value; |
947 | 940 | } |
948 | 941 | } |
@@ -261,6 +261,7 @@ discard block |
||
261 | 261 | * Sets the page for a control. |
262 | 262 | * Only framework developers should use this method. |
263 | 263 | * @param TPage the page that contains this control |
264 | + * @param TPage $page |
|
264 | 265 | */ |
265 | 266 | public function setPage($page) |
266 | 267 | { |
@@ -542,6 +543,7 @@ discard block |
||
542 | 543 | |
543 | 544 | /** |
544 | 545 | * @param boolean whether the control is visible |
546 | + * @param boolean $value |
|
545 | 547 | */ |
546 | 548 | public function setVisible($value) |
547 | 549 | { |
@@ -609,6 +611,7 @@ discard block |
||
609 | 611 | } |
610 | 612 | |
611 | 613 | /** |
614 | + * @param string $name |
|
612 | 615 | * @return boolean whether the named attribute exists |
613 | 616 | */ |
614 | 617 | public function hasAttribute($name) |
@@ -620,6 +623,7 @@ discard block |
||
620 | 623 | } |
621 | 624 | |
622 | 625 | /** |
626 | + * @param string $name |
|
623 | 627 | * @return string attribute value, null if attribute does not exist |
624 | 628 | */ |
625 | 629 | public function getAttribute($name) |
@@ -634,6 +638,7 @@ discard block |
||
634 | 638 | * Sets a custom control attribute. |
635 | 639 | * @param string attribute name |
636 | 640 | * @param string value of the attribute |
641 | + * @param string $name |
|
637 | 642 | */ |
638 | 643 | public function setAttribute($name,$value) |
639 | 644 | { |
@@ -671,6 +676,7 @@ discard block |
||
671 | 676 | |
672 | 677 | /** |
673 | 678 | * @param boolean set whether to enable viewstate |
679 | + * @param boolean $value |
|
674 | 680 | */ |
675 | 681 | public function setEnableViewState($value) |
676 | 682 | { |
@@ -687,6 +693,8 @@ discard block |
||
687 | 693 | * that must be kept in controlstate. |
688 | 694 | * @param string the name of the controlstate value to be returned |
689 | 695 | * @param mixed the default value. If $key is not found in controlstate, $defaultValue will be returned |
696 | + * @param string $key |
|
697 | + * @param integer $defaultValue |
|
690 | 698 | * @return mixed the controlstate value corresponding to $key |
691 | 699 | */ |
692 | 700 | protected function getControlState($key,$defaultValue=null) |
@@ -703,6 +711,8 @@ discard block |
||
703 | 711 | * @param string the name of the controlstate value |
704 | 712 | * @param mixed the controlstate value to be set |
705 | 713 | * @param mixed default value. If $value===$defaultValue, the item will be cleared from controlstate |
714 | + * @param string $key |
|
715 | + * @param integer $defaultValue |
|
706 | 716 | */ |
707 | 717 | protected function setControlState($key,$value,$defaultValue=null) |
708 | 718 | { |
@@ -726,6 +736,7 @@ discard block |
||
726 | 736 | * When it is false, data saved via setViewState() will not be persisted. |
727 | 737 | * By default, it is true, meaning data will be persisted across postbacks. |
728 | 738 | * @param boolean whether data should be persisted |
739 | + * @param boolean $enabled |
|
729 | 740 | */ |
730 | 741 | public function trackViewState($enabled) |
731 | 742 | { |
@@ -764,6 +775,7 @@ discard block |
||
764 | 775 | * @param string the name of the viewstate value |
765 | 776 | * @param mixed the viewstate value to be set |
766 | 777 | * @param mixed default value. If $value===$defaultValue, the item will be cleared from the viewstate. |
778 | + * @param string $key |
|
767 | 779 | */ |
768 | 780 | public function setViewState($key,$value,$defaultValue=null) |
769 | 781 | { |
@@ -788,6 +800,7 @@ discard block |
||
788 | 800 | /** |
789 | 801 | * Clears a viewstate value. |
790 | 802 | * @param string the name of the viewstate value to be cleared |
803 | + * @param string $key |
|
791 | 804 | */ |
792 | 805 | public function clearViewState($key) |
793 | 806 | { |
@@ -893,6 +906,7 @@ discard block |
||
893 | 906 | * Sets a value indicating whether child controls are created. |
894 | 907 | * If false, any existing child controls will be cleared up. |
895 | 908 | * @param boolean whether child controls are created |
909 | + * @param boolean $value |
|
896 | 910 | */ |
897 | 911 | final protected function setChildControlsCreated($value) |
898 | 912 | { |
@@ -983,6 +997,7 @@ discard block |
||
983 | 997 | * Finds all child and grand-child controls that are of the specified type. |
984 | 998 | * @param string the class name |
985 | 999 | * @param boolean whether the type comparison is strict or not. If false, controls of the parent classes of the specified class will also be returned. |
1000 | + * @param string $type |
|
986 | 1001 | * @return array list of controls found |
987 | 1002 | */ |
988 | 1003 | public function findControlsByType($type,$strict=true) |
@@ -1117,6 +1132,7 @@ discard block |
||
1117 | 1132 | * A component with explicit ID on a template will be registered to |
1118 | 1133 | * the template owner. This method allows you to obtain this component |
1119 | 1134 | * with the ID. |
1135 | + * @param string $name |
|
1120 | 1136 | * @return mixed the named registered object. Null if object is not found. |
1121 | 1137 | */ |
1122 | 1138 | public function getRegisteredObject($name) |
@@ -1174,6 +1190,7 @@ discard block |
||
1174 | 1190 | * Control lifecycles will be caught up during the addition. |
1175 | 1191 | * Only framework developers should use this method. |
1176 | 1192 | * @param TControl the new child control |
1193 | + * @param TControl $control |
|
1177 | 1194 | */ |
1178 | 1195 | public function addedControl($control) |
1179 | 1196 | { |
@@ -1219,6 +1236,7 @@ discard block |
||
1219 | 1236 | * Removes a control from the child collection of the control. |
1220 | 1237 | * Only framework developers should use this method. |
1221 | 1238 | * @param TControl the child control removed |
1239 | + * @param TControl $control |
|
1222 | 1240 | */ |
1223 | 1241 | public function removedControl($control) |
1224 | 1242 | { |
@@ -1470,6 +1488,7 @@ discard block |
||
1470 | 1488 | * @param string name of the broadcast event |
1471 | 1489 | * @param TControl sender of the event |
1472 | 1490 | * @param TBroadcastEventParameter event parameter |
1491 | + * @param TBroadcastEventParameter $param |
|
1473 | 1492 | */ |
1474 | 1493 | private function broadcastEventInternal($name,$sender,$param) |
1475 | 1494 | { |
@@ -1694,6 +1713,7 @@ discard block |
||
1694 | 1713 | * Clears the cached UniqueID. |
1695 | 1714 | * If $recursive=true, all children's cached UniqueID will be cleared as well. |
1696 | 1715 | * @param boolean whether the clearing is recursive. |
1716 | + * @param boolean $recursive |
|
1697 | 1717 | */ |
1698 | 1718 | private function clearCachedUniqueID($recursive) |
1699 | 1719 | { |
@@ -1731,6 +1751,7 @@ discard block |
||
1731 | 1751 | * Updates the list of the controls whose IDs are managed by the specified naming container. |
1732 | 1752 | * @param TControl the naming container |
1733 | 1753 | * @param TControlCollection list of controls |
1754 | + * @param TControl $container |
|
1734 | 1755 | * @throws TInvalidDataValueException if a control's ID is not unique within its naming container. |
1735 | 1756 | */ |
1736 | 1757 | private function fillNameTable($container,$controls) |
@@ -1900,6 +1921,7 @@ discard block |
||
1900 | 1921 | * The implementation of this function should raise appropriate event(s) (e.g. OnClick, OnCommand) |
1901 | 1922 | * indicating the component is responsible for the postback event. |
1902 | 1923 | * @param string the parameter associated with the postback event |
1924 | + * @return void |
|
1903 | 1925 | */ |
1904 | 1926 | public function raisePostBackEvent($param); |
1905 | 1927 | } |
@@ -1928,6 +1950,7 @@ discard block |
||
1928 | 1950 | * Raises postdata changed event. |
1929 | 1951 | * The implementation of this function should raise appropriate event(s) (e.g. OnTextChanged) |
1930 | 1952 | * indicating the control data is changed. |
1953 | + * @return void |
|
1931 | 1954 | */ |
1932 | 1955 | public function raisePostDataChangedEvent(); |
1933 | 1956 | /** |
@@ -1961,6 +1984,7 @@ discard block |
||
1961 | 1984 | public function getIsValid(); |
1962 | 1985 | /** |
1963 | 1986 | * @param boolean whether the validator validates successfully |
1987 | + * @return void |
|
1964 | 1988 | */ |
1965 | 1989 | public function setIsValid($value); |
1966 | 1990 | /** |
@@ -1969,6 +1993,7 @@ discard block |
||
1969 | 1993 | public function getErrorMessage(); |
1970 | 1994 | /** |
1971 | 1995 | * @param string error message for the validation |
1996 | + * @return void |
|
1972 | 1997 | */ |
1973 | 1998 | public function setErrorMessage($value); |
1974 | 1999 | } |
@@ -2036,6 +2061,7 @@ discard block |
||
2036 | 2061 | /** |
2037 | 2062 | * Applies this theme to the specified control. |
2038 | 2063 | * @param TControl the control to be applied with this theme |
2064 | + * @return boolean |
|
2039 | 2065 | */ |
2040 | 2066 | public function applySkin($control); |
2041 | 2067 | } |
@@ -2057,6 +2083,7 @@ discard block |
||
2057 | 2083 | * Content in the template will be instantiated as components and text strings |
2058 | 2084 | * and passed to the specified parent control. |
2059 | 2085 | * @param TControl the parent control |
2086 | + * @return void |
|
2060 | 2087 | */ |
2061 | 2088 | public function instantiateIn($parent); |
2062 | 2089 | } |
@@ -2081,6 +2108,8 @@ discard block |
||
2081 | 2108 | |
2082 | 2109 | /** |
2083 | 2110 | * @param string caption of the button |
2111 | + * @param string $value |
|
2112 | + * @return void |
|
2084 | 2113 | */ |
2085 | 2114 | public function setText($value); |
2086 | 2115 | |
@@ -2091,6 +2120,7 @@ discard block |
||
2091 | 2120 | |
2092 | 2121 | /** |
2093 | 2122 | * @param boolean whether postback event trigger by this button will cause input validation |
2123 | + * @return void |
|
2094 | 2124 | */ |
2095 | 2125 | public function setCausesValidation($value); |
2096 | 2126 | |
@@ -2101,6 +2131,7 @@ discard block |
||
2101 | 2131 | |
2102 | 2132 | /** |
2103 | 2133 | * @param string the command name associated with the {@link onCommand OnCommand} event. |
2134 | + * @return void |
|
2104 | 2135 | */ |
2105 | 2136 | public function setCommandName($value); |
2106 | 2137 | |
@@ -2111,6 +2142,7 @@ discard block |
||
2111 | 2142 | |
2112 | 2143 | /** |
2113 | 2144 | * @param string the parameter associated with the {@link onCommand OnCommand} event. |
2145 | + * @return void |
|
2114 | 2146 | */ |
2115 | 2147 | public function setCommandParameter($value); |
2116 | 2148 | |
@@ -2121,23 +2153,27 @@ discard block |
||
2121 | 2153 | |
2122 | 2154 | /** |
2123 | 2155 | * @param string the group of validators which the button causes validation upon postback |
2156 | + * @return void |
|
2124 | 2157 | */ |
2125 | 2158 | public function setValidationGroup($value); |
2126 | 2159 | |
2127 | 2160 | /** |
2128 | 2161 | * Raises <b>OnClick</b> event. |
2129 | 2162 | * @param TEventParameter event parameter to be passed to the event handlers |
2163 | + * @return void |
|
2130 | 2164 | */ |
2131 | 2165 | public function onClick($param); |
2132 | 2166 | |
2133 | 2167 | /** |
2134 | 2168 | * Raises <b>OnCommand</b> event. |
2135 | 2169 | * @param TCommandEventParameter event parameter to be passed to the event handlers |
2170 | + * @return void |
|
2136 | 2171 | */ |
2137 | 2172 | public function onCommand($param); |
2138 | 2173 | |
2139 | 2174 | /** |
2140 | 2175 | * @param boolean set by a panel to register this button as the default button for the panel. |
2176 | + * @return void |
|
2141 | 2177 | */ |
2142 | 2178 | public function setIsDefaultButton($value); |
2143 | 2179 |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | * Indexes for the rare fields. |
111 | 111 | * In order to save memory, rare fields will only be created if they are needed. |
112 | 112 | */ |
113 | - const RF_CONTROLS=0; // child controls |
|
114 | - const RF_CHILD_STATE=1; // child state field |
|
115 | - const RF_NAMED_CONTROLS=2; // list of controls whose namingcontainer is this control |
|
116 | - const RF_NAMED_CONTROLS_ID=3; // counter for automatic id |
|
117 | - const RF_SKIN_ID=4; // skin ID |
|
118 | - const RF_DATA_BINDINGS=5; // data bindings |
|
119 | - const RF_EVENTS=6; // event handlers |
|
120 | - const RF_CONTROLSTATE=7; // controlstate |
|
121 | - const RF_NAMED_OBJECTS=8; // controls declared with ID on template |
|
122 | - const RF_ADAPTER=9; // adapter |
|
123 | - const RF_AUTO_BINDINGS=10; // auto data bindings |
|
113 | + const RF_CONTROLS=0; // child controls |
|
114 | + const RF_CHILD_STATE=1; // child state field |
|
115 | + const RF_NAMED_CONTROLS=2; // list of controls whose namingcontainer is this control |
|
116 | + const RF_NAMED_CONTROLS_ID=3; // counter for automatic id |
|
117 | + const RF_SKIN_ID=4; // skin ID |
|
118 | + const RF_DATA_BINDINGS=5; // data bindings |
|
119 | + const RF_EVENTS=6; // event handlers |
|
120 | + const RF_CONTROLSTATE=7; // controlstate |
|
121 | + const RF_NAMED_OBJECTS=8; // controls declared with ID on template |
|
122 | + const RF_ADAPTER=9; // adapter |
|
123 | + const RF_AUTO_BINDINGS=10; // auto data bindings |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * @var string control ID |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function getAdapter() |
210 | 210 | { |
211 | - return isset($this->_rf[self::RF_ADAPTER])?$this->_rf[self::RF_ADAPTER]:null; |
|
211 | + return isset($this->_rf[self::RF_ADAPTER]) ? $this->_rf[self::RF_ADAPTER] : null; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -348,10 +348,10 @@ discard block |
||
348 | 348 | */ |
349 | 349 | public function setID($id) |
350 | 350 | { |
351 | - if(!preg_match(self::ID_FORMAT,$id)) |
|
352 | - throw new TInvalidDataValueException('control_id_invalid',get_class($this),$id); |
|
351 | + if(!preg_match(self::ID_FORMAT, $id)) |
|
352 | + throw new TInvalidDataValueException('control_id_invalid', get_class($this), $id); |
|
353 | 353 | $this->_id=$id; |
354 | - $this->_flags |= self::IS_ID_SET; |
|
354 | + $this->_flags|=self::IS_ID_SET; |
|
355 | 355 | $this->clearCachedUniqueID($this instanceof INamingContainer); |
356 | 356 | if($this->_namingContainer) |
357 | 357 | $this->_namingContainer->clearNameTable(); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | { |
369 | 369 | if($this->_uid==='' || $this->_uid===null) // need to build the UniqueID |
370 | 370 | { |
371 | - $this->_uid=''; // set to not-null, so that clearCachedUniqueID() may take action |
|
371 | + $this->_uid=''; // set to not-null, so that clearCachedUniqueID() may take action |
|
372 | 372 | if($namingContainer=$this->getNamingContainer()) |
373 | 373 | { |
374 | 374 | if($this->getPage()===$namingContainer) |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public function getClientID() |
404 | 404 | { |
405 | - return strtr($this->getUniqueID(),self::ID_SEPARATOR,self::CLIENT_ID_SEPARATOR); |
|
405 | + return strtr($this->getUniqueID(), self::ID_SEPARATOR, self::CLIENT_ID_SEPARATOR); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public static function convertUniqueIdToClientId($uniqueID) |
414 | 414 | { |
415 | - return strtr($uniqueID,self::ID_SEPARATOR,self::CLIENT_ID_SEPARATOR); |
|
415 | + return strtr($uniqueID, self::ID_SEPARATOR, self::CLIENT_ID_SEPARATOR); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | */ |
421 | 421 | public function getSkinID() |
422 | 422 | { |
423 | - return isset($this->_rf[self::RF_SKIN_ID])?$this->_rf[self::RF_SKIN_ID]:''; |
|
423 | + return isset($this->_rf[self::RF_SKIN_ID]) ? $this->_rf[self::RF_SKIN_ID] : ''; |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | */ |
430 | 430 | public function setSkinID($value) |
431 | 431 | { |
432 | - if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage>=self::CS_CHILD_INITIALIZED) |
|
433 | - throw new TInvalidOperationException('control_skinid_unchangeable',get_class($this)); |
|
432 | + if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage >= self::CS_CHILD_INITIALIZED) |
|
433 | + throw new TInvalidOperationException('control_skinid_unchangeable', get_class($this)); |
|
434 | 434 | else |
435 | 435 | $this->_rf[self::RF_SKIN_ID]=$value; |
436 | 436 | } |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | if($this->_flags & self::IS_DISABLE_THEMING) |
454 | 454 | return false; |
455 | 455 | else |
456 | - return $this->_parent?$this->_parent->getEnableTheming():true; |
|
456 | + return $this->_parent ? $this->_parent->getEnableTheming() : true; |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | /** |
@@ -462,12 +462,12 @@ discard block |
||
462 | 462 | */ |
463 | 463 | public function setEnableTheming($value) |
464 | 464 | { |
465 | - if($this->_stage>=self::CS_CHILD_INITIALIZED) |
|
466 | - throw new TInvalidOperationException('control_enabletheming_unchangeable',get_class($this),$this->getUniqueID()); |
|
465 | + if($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
466 | + throw new TInvalidOperationException('control_enabletheming_unchangeable', get_class($this), $this->getUniqueID()); |
|
467 | 467 | else if(TPropertyValue::ensureBoolean($value)) |
468 | - $this->_flags &= ~self::IS_DISABLE_THEMING; |
|
468 | + $this->_flags&=~self::IS_DISABLE_THEMING; |
|
469 | 469 | else |
470 | - $this->_flags |= self::IS_DISABLE_THEMING; |
|
470 | + $this->_flags|=self::IS_DISABLE_THEMING; |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | /** |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function getCustomData() |
481 | 481 | { |
482 | - return $this->getViewState('CustomData',null); |
|
482 | + return $this->getViewState('CustomData', null); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | */ |
490 | 490 | public function setCustomData($value) |
491 | 491 | { |
492 | - $this->setViewState('CustomData',$value,null); |
|
492 | + $this->setViewState('CustomData', $value, null); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | */ |
498 | 498 | public function getHasControls() |
499 | 499 | { |
500 | - return isset($this->_rf[self::RF_CONTROLS]) && $this->_rf[self::RF_CONTROLS]->getCount()>0; |
|
500 | + return isset($this->_rf[self::RF_CONTROLS]) && $this->_rf[self::RF_CONTROLS]->getCount() > 0; |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | */ |
518 | 518 | protected function createControlCollection() |
519 | 519 | { |
520 | - return $this->getAllowChildControls()?new TControlCollection($this):new TEmptyControlCollection($this); |
|
520 | + return $this->getAllowChildControls() ? new TControlCollection($this) : new TEmptyControlCollection($this); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
@@ -531,13 +531,13 @@ discard block |
||
531 | 531 | { |
532 | 532 | if($checkParents) |
533 | 533 | { |
534 | - for($control=$this;$control;$control=$control->_parent) |
|
534 | + for($control=$this; $control; $control=$control->_parent) |
|
535 | 535 | if(!$control->getVisible(false)) |
536 | 536 | return false; |
537 | 537 | return true; |
538 | 538 | } |
539 | 539 | else |
540 | - return $this->getViewState('Visible',true); |
|
540 | + return $this->getViewState('Visible', true); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | /** |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | */ |
546 | 546 | public function setVisible($value) |
547 | 547 | { |
548 | - $this->setViewState('Visible',TPropertyValue::ensureBoolean($value),true); |
|
548 | + $this->setViewState('Visible', TPropertyValue::ensureBoolean($value), true); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
@@ -562,13 +562,13 @@ discard block |
||
562 | 562 | { |
563 | 563 | if($checkParents) |
564 | 564 | { |
565 | - for($control=$this;$control;$control=$control->_parent) |
|
566 | - if(!$control->getViewState('Enabled',true)) |
|
565 | + for($control=$this; $control; $control=$control->_parent) |
|
566 | + if(!$control->getViewState('Enabled', true)) |
|
567 | 567 | return false; |
568 | 568 | return true; |
569 | 569 | } |
570 | 570 | else |
571 | - return $this->getViewState('Enabled',true); |
|
571 | + return $this->getViewState('Enabled', true); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | */ |
577 | 577 | public function setEnabled($value) |
578 | 578 | { |
579 | - $this->setViewState('Enabled',TPropertyValue::ensureBoolean($value),true); |
|
579 | + $this->setViewState('Enabled', TPropertyValue::ensureBoolean($value), true); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | */ |
585 | 585 | public function getHasAttributes() |
586 | 586 | { |
587 | - if($attributes=$this->getViewState('Attributes',null)) |
|
588 | - return $attributes->getCount()>0; |
|
587 | + if($attributes=$this->getViewState('Attributes', null)) |
|
588 | + return $attributes->getCount() > 0; |
|
589 | 589 | else |
590 | 590 | return false; |
591 | 591 | } |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | */ |
599 | 599 | public function getAttributes() |
600 | 600 | { |
601 | - if($attributes=$this->getViewState('Attributes',null)) |
|
601 | + if($attributes=$this->getViewState('Attributes', null)) |
|
602 | 602 | return $attributes; |
603 | 603 | else |
604 | 604 | { |
605 | 605 | $attributes=new TAttributeCollection; |
606 | - $this->setViewState('Attributes',$attributes,null); |
|
606 | + $this->setViewState('Attributes', $attributes, null); |
|
607 | 607 | return $attributes; |
608 | 608 | } |
609 | 609 | } |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | */ |
614 | 614 | public function hasAttribute($name) |
615 | 615 | { |
616 | - if($attributes=$this->getViewState('Attributes',null)) |
|
616 | + if($attributes=$this->getViewState('Attributes', null)) |
|
617 | 617 | return $attributes->contains($name); |
618 | 618 | else |
619 | 619 | return false; |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | */ |
625 | 625 | public function getAttribute($name) |
626 | 626 | { |
627 | - if($attributes=$this->getViewState('Attributes',null)) |
|
627 | + if($attributes=$this->getViewState('Attributes', null)) |
|
628 | 628 | return $attributes->itemAt($name); |
629 | 629 | else |
630 | 630 | return null; |
@@ -635,9 +635,9 @@ discard block |
||
635 | 635 | * @param string attribute name |
636 | 636 | * @param string value of the attribute |
637 | 637 | */ |
638 | - public function setAttribute($name,$value) |
|
638 | + public function setAttribute($name, $value) |
|
639 | 639 | { |
640 | - $this->getAttributes()->add($name,$value); |
|
640 | + $this->getAttributes()->add($name, $value); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | /** |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | */ |
648 | 648 | public function removeAttribute($name) |
649 | 649 | { |
650 | - if($attributes=$this->getViewState('Attributes',null)) |
|
650 | + if($attributes=$this->getViewState('Attributes', null)) |
|
651 | 651 | return $attributes->remove($name); |
652 | 652 | else |
653 | 653 | return null; |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | { |
661 | 661 | if($checkParents) |
662 | 662 | { |
663 | - for($control=$this;$control!==null;$control=$control->getParent()) |
|
663 | + for($control=$this; $control!==null; $control=$control->getParent()) |
|
664 | 664 | if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
665 | 665 | return false; |
666 | 666 | return true; |
@@ -675,9 +675,9 @@ discard block |
||
675 | 675 | public function setEnableViewState($value) |
676 | 676 | { |
677 | 677 | if(TPropertyValue::ensureBoolean($value)) |
678 | - $this->_flags &= ~self::IS_DISABLE_VIEWSTATE; |
|
678 | + $this->_flags&=~self::IS_DISABLE_VIEWSTATE; |
|
679 | 679 | else |
680 | - $this->_flags |= self::IS_DISABLE_VIEWSTATE; |
|
680 | + $this->_flags|=self::IS_DISABLE_VIEWSTATE; |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -689,9 +689,9 @@ discard block |
||
689 | 689 | * @param mixed the default value. If $key is not found in controlstate, $defaultValue will be returned |
690 | 690 | * @return mixed the controlstate value corresponding to $key |
691 | 691 | */ |
692 | - protected function getControlState($key,$defaultValue=null) |
|
692 | + protected function getControlState($key, $defaultValue=null) |
|
693 | 693 | { |
694 | - return isset($this->_rf[self::RF_CONTROLSTATE][$key])?$this->_rf[self::RF_CONTROLSTATE][$key]:$defaultValue; |
|
694 | + return isset($this->_rf[self::RF_CONTROLSTATE][$key]) ? $this->_rf[self::RF_CONTROLSTATE][$key] : $defaultValue; |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | * @param mixed the controlstate value to be set |
705 | 705 | * @param mixed default value. If $value===$defaultValue, the item will be cleared from controlstate |
706 | 706 | */ |
707 | - protected function setControlState($key,$value,$defaultValue=null) |
|
707 | + protected function setControlState($key, $value, $defaultValue=null) |
|
708 | 708 | { |
709 | 709 | if($value===$defaultValue) |
710 | 710 | unset($this->_rf[self::RF_CONTROLSTATE][$key]); |
@@ -741,10 +741,10 @@ discard block |
||
741 | 741 | * @param mixed the default value. If $key is not found in viewstate, $defaultValue will be returned |
742 | 742 | * @return mixed the viewstate value corresponding to $key |
743 | 743 | */ |
744 | - public function getViewState($key,$defaultValue=null) |
|
744 | + public function getViewState($key, $defaultValue=null) |
|
745 | 745 | { |
746 | 746 | if(isset($this->_viewState[$key])) |
747 | - return $this->_viewState[$key]!==null?$this->_viewState[$key]:$defaultValue; |
|
747 | + return $this->_viewState[$key]!==null ? $this->_viewState[$key] : $defaultValue; |
|
748 | 748 | else if(isset($this->_tempState[$key])) |
749 | 749 | { |
750 | 750 | if(is_object($this->_tempState[$key]) && $this->_trackViewState) |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | * @param mixed the viewstate value to be set |
766 | 766 | * @param mixed default value. If $value===$defaultValue, the item will be cleared from the viewstate. |
767 | 767 | */ |
768 | - public function setViewState($key,$value,$defaultValue=null) |
|
768 | + public function setViewState($key, $value, $defaultValue=null) |
|
769 | 769 | { |
770 | 770 | if($this->_trackViewState) |
771 | 771 | { |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | * @param string the property name, or property path |
802 | 802 | * @param string the expression |
803 | 803 | */ |
804 | - public function bindProperty($name,$expression) |
|
804 | + public function bindProperty($name, $expression) |
|
805 | 805 | { |
806 | 806 | $this->_rf[self::RF_DATA_BINDINGS][$name]=$expression; |
807 | 807 | } |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | * @param string the property name, or property path |
824 | 824 | * @param string the expression |
825 | 825 | */ |
826 | - public function autoBindProperty($name,$expression) |
|
826 | + public function autoBindProperty($name, $expression) |
|
827 | 827 | { |
828 | 828 | $this->_rf[self::RF_AUTO_BINDINGS][$name]=$expression; |
829 | 829 | } |
@@ -843,13 +843,13 @@ discard block |
||
843 | 843 | */ |
844 | 844 | protected function dataBindProperties() |
845 | 845 | { |
846 | - Prado::trace("Data bind properties",'System.Web.UI.TControl'); |
|
846 | + Prado::trace("Data bind properties", 'System.Web.UI.TControl'); |
|
847 | 847 | if(isset($this->_rf[self::RF_DATA_BINDINGS])) |
848 | 848 | { |
849 | 849 | if(($context=$this->getTemplateControl())===null) |
850 | 850 | $context=$this; |
851 | 851 | foreach($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression) |
852 | - $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
852 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | if(($context=$this->getTemplateControl())===null) |
864 | 864 | $context=$this; |
865 | 865 | foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression) |
866 | - $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
866 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
867 | 867 | } |
868 | 868 | } |
869 | 869 | |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | */ |
873 | 873 | protected function dataBindChildren() |
874 | 874 | { |
875 | - Prado::trace("dataBindChildren()",'System.Web.UI.TControl'); |
|
875 | + Prado::trace("dataBindChildren()", 'System.Web.UI.TControl'); |
|
876 | 876 | if(isset($this->_rf[self::RF_CONTROLS])) |
877 | 877 | { |
878 | 878 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
@@ -897,12 +897,12 @@ discard block |
||
897 | 897 | final protected function setChildControlsCreated($value) |
898 | 898 | { |
899 | 899 | if($value) |
900 | - $this->_flags |= self::IS_CHILD_CREATED; |
|
900 | + $this->_flags|=self::IS_CHILD_CREATED; |
|
901 | 901 | else |
902 | 902 | { |
903 | 903 | if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) |
904 | 904 | $this->getControls()->clear(); |
905 | - $this->_flags &= ~self::IS_CHILD_CREATED; |
|
905 | + $this->_flags&=~self::IS_CHILD_CREATED; |
|
906 | 906 | } |
907 | 907 | } |
908 | 908 | |
@@ -917,18 +917,18 @@ discard block |
||
917 | 917 | { |
918 | 918 | try |
919 | 919 | { |
920 | - $this->_flags |= self::IS_CREATING_CHILD; |
|
920 | + $this->_flags|=self::IS_CREATING_CHILD; |
|
921 | 921 | if(isset($this->_rf[self::RF_ADAPTER])) |
922 | 922 | $this->_rf[self::RF_ADAPTER]->createChildControls(); |
923 | 923 | else |
924 | 924 | $this->createChildControls(); |
925 | - $this->_flags &= ~self::IS_CREATING_CHILD; |
|
926 | - $this->_flags |= self::IS_CHILD_CREATED; |
|
925 | + $this->_flags&=~self::IS_CREATING_CHILD; |
|
926 | + $this->_flags|=self::IS_CHILD_CREATED; |
|
927 | 927 | } |
928 | 928 | catch(Exception $e) |
929 | 929 | { |
930 | - $this->_flags &= ~self::IS_CREATING_CHILD; |
|
931 | - $this->_flags |= self::IS_CHILD_CREATED; |
|
930 | + $this->_flags&=~self::IS_CREATING_CHILD; |
|
931 | + $this->_flags|=self::IS_CHILD_CREATED; |
|
932 | 932 | throw $e; |
933 | 933 | } |
934 | 934 | } |
@@ -957,21 +957,21 @@ discard block |
||
957 | 957 | */ |
958 | 958 | public function findControl($id) |
959 | 959 | { |
960 | - $id=strtr($id,'.',self::ID_SEPARATOR); |
|
961 | - $container=($this instanceof INamingContainer)?$this:$this->getNamingContainer(); |
|
960 | + $id=strtr($id, '.', self::ID_SEPARATOR); |
|
961 | + $container=($this instanceof INamingContainer) ? $this : $this->getNamingContainer(); |
|
962 | 962 | if(!$container || !$container->getHasControls()) |
963 | 963 | return null; |
964 | 964 | if(!isset($container->_rf[self::RF_NAMED_CONTROLS])) |
965 | 965 | { |
966 | 966 | $container->_rf[self::RF_NAMED_CONTROLS]=array(); |
967 | - $container->fillNameTable($container,$container->_rf[self::RF_CONTROLS]); |
|
967 | + $container->fillNameTable($container, $container->_rf[self::RF_CONTROLS]); |
|
968 | 968 | } |
969 | - if(($pos=strpos($id,self::ID_SEPARATOR))===false) |
|
970 | - return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null; |
|
969 | + if(($pos=strpos($id, self::ID_SEPARATOR))===false) |
|
970 | + return isset($container->_rf[self::RF_NAMED_CONTROLS][$id]) ? $container->_rf[self::RF_NAMED_CONTROLS][$id] : null; |
|
971 | 971 | else |
972 | 972 | { |
973 | - $cid=substr($id,0,$pos); |
|
974 | - $sid=substr($id,$pos+1); |
|
973 | + $cid=substr($id, 0, $pos); |
|
974 | + $sid=substr($id, $pos + 1); |
|
975 | 975 | if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) |
976 | 976 | return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid); |
977 | 977 | else |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | * @param boolean whether the type comparison is strict or not. If false, controls of the parent classes of the specified class will also be returned. |
986 | 986 | * @return array list of controls found |
987 | 987 | */ |
988 | - public function findControlsByType($type,$strict=true) |
|
988 | + public function findControlsByType($type, $strict=true) |
|
989 | 989 | { |
990 | 990 | $controls=array(); |
991 | 991 | if($this->getHasControls()) |
@@ -995,7 +995,7 @@ discard block |
||
995 | 995 | if(is_object($control) && (get_class($control)===$type || (!$strict && ($control instanceof $type)))) |
996 | 996 | $controls[]=$control; |
997 | 997 | if(($control instanceof TControl) && $control->getHasControls()) |
998 | - $controls=array_merge($controls,$control->findControlsByType($type,$strict)); |
|
998 | + $controls=array_merge($controls, $control->findControlsByType($type, $strict)); |
|
999 | 999 | } |
1000 | 1000 | } |
1001 | 1001 | return $controls; |
@@ -1021,7 +1021,7 @@ discard block |
||
1021 | 1021 | { |
1022 | 1022 | if($control->_id===$id) |
1023 | 1023 | $controls[]=$control; |
1024 | - $controls=array_merge($controls,$control->findControlsByID($id)); |
|
1024 | + $controls=array_merge($controls, $control->findControlsByID($id)); |
|
1025 | 1025 | } |
1026 | 1026 | } |
1027 | 1027 | } |
@@ -1046,10 +1046,10 @@ discard block |
||
1046 | 1046 | * @param object object to be declared |
1047 | 1047 | * @see __get |
1048 | 1048 | */ |
1049 | - public function registerObject($name,$object) |
|
1049 | + public function registerObject($name, $object) |
|
1050 | 1050 | { |
1051 | 1051 | if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
1052 | - throw new TInvalidOperationException('control_object_reregistered',$name); |
|
1052 | + throw new TInvalidOperationException('control_object_reregistered', $name); |
|
1053 | 1053 | $this->_rf[self::RF_NAMED_OBJECTS][$name]=$object; |
1054 | 1054 | } |
1055 | 1055 | |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | */ |
1122 | 1122 | public function getRegisteredObject($name) |
1123 | 1123 | { |
1124 | - return isset($this->_rf[self::RF_NAMED_OBJECTS][$name])?$this->_rf[self::RF_NAMED_OBJECTS][$name]:null; |
|
1124 | + return isset($this->_rf[self::RF_NAMED_OBJECTS][$name]) ? $this->_rf[self::RF_NAMED_OBJECTS][$name] : null; |
|
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | /** |
@@ -1181,7 +1181,7 @@ discard block |
||
1181 | 1181 | $control->_parent->getControls()->remove($control); |
1182 | 1182 | $control->_parent=$this; |
1183 | 1183 | $control->_page=$this->getPage(); |
1184 | - $namingContainer=($this instanceof INamingContainer)?$this:$this->_namingContainer; |
|
1184 | + $namingContainer=($this instanceof INamingContainer) ? $this : $this->_namingContainer; |
|
1185 | 1185 | if($namingContainer) |
1186 | 1186 | { |
1187 | 1187 | $control->_namingContainer=$namingContainer; |
@@ -1192,10 +1192,10 @@ discard block |
||
1192 | 1192 | $control->clearCachedUniqueID($control instanceof INamingContainer); |
1193 | 1193 | } |
1194 | 1194 | |
1195 | - if($this->_stage>=self::CS_CHILD_INITIALIZED) |
|
1195 | + if($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
1196 | 1196 | { |
1197 | 1197 | $control->initRecursive($namingContainer); |
1198 | - if($this->_stage>=self::CS_STATE_LOADED) |
|
1198 | + if($this->_stage >= self::CS_STATE_LOADED) |
|
1199 | 1199 | { |
1200 | 1200 | if(isset($this->_rf[self::RF_CHILD_STATE][$control->_id])) |
1201 | 1201 | { |
@@ -1204,11 +1204,11 @@ discard block |
||
1204 | 1204 | } |
1205 | 1205 | else |
1206 | 1206 | $state=null; |
1207 | - $control->loadStateRecursive($state,!($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
1208 | - if($this->_stage>=self::CS_LOADED) |
|
1207 | + $control->loadStateRecursive($state, !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
1208 | + if($this->_stage >= self::CS_LOADED) |
|
1209 | 1209 | { |
1210 | 1210 | $control->loadRecursive(); |
1211 | - if($this->_stage>=self::CS_PRERENDERED) |
|
1211 | + if($this->_stage >= self::CS_PRERENDERED) |
|
1212 | 1212 | $control->preRenderRecursive(); |
1213 | 1213 | } |
1214 | 1214 | } |
@@ -1262,13 +1262,13 @@ discard block |
||
1262 | 1262 | } |
1263 | 1263 | } |
1264 | 1264 | } |
1265 | - if($this->_stage<self::CS_INITIALIZED) |
|
1265 | + if($this->_stage < self::CS_INITIALIZED) |
|
1266 | 1266 | { |
1267 | 1267 | $this->_stage=self::CS_CHILD_INITIALIZED; |
1268 | 1268 | if(($page=$this->getPage()) && $this->getEnableTheming() && !($this->_flags & self::IS_SKIN_APPLIED)) |
1269 | 1269 | { |
1270 | 1270 | $page->applyControlSkin($this); |
1271 | - $this->_flags |= self::IS_SKIN_APPLIED; |
|
1271 | + $this->_flags|=self::IS_SKIN_APPLIED; |
|
1272 | 1272 | } |
1273 | 1273 | if(isset($this->_rf[self::RF_ADAPTER])) |
1274 | 1274 | $this->_rf[self::RF_ADAPTER]->onInit(null); |
@@ -1284,7 +1284,7 @@ discard block |
||
1284 | 1284 | */ |
1285 | 1285 | protected function loadRecursive() |
1286 | 1286 | { |
1287 | - if($this->_stage<self::CS_LOADED) |
|
1287 | + if($this->_stage < self::CS_LOADED) |
|
1288 | 1288 | { |
1289 | 1289 | if(isset($this->_rf[self::RF_ADAPTER])) |
1290 | 1290 | $this->_rf[self::RF_ADAPTER]->onLoad(null); |
@@ -1299,7 +1299,7 @@ discard block |
||
1299 | 1299 | $control->loadRecursive(); |
1300 | 1300 | } |
1301 | 1301 | } |
1302 | - if($this->_stage<self::CS_LOADED) |
|
1302 | + if($this->_stage < self::CS_LOADED) |
|
1303 | 1303 | $this->_stage=self::CS_LOADED; |
1304 | 1304 | } |
1305 | 1305 | |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | */ |
1361 | 1361 | public function onInit($param) |
1362 | 1362 | { |
1363 | - $this->raiseEvent('OnInit',$this,$param); |
|
1363 | + $this->raiseEvent('OnInit', $this, $param); |
|
1364 | 1364 | } |
1365 | 1365 | |
1366 | 1366 | /** |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | */ |
1373 | 1373 | public function onLoad($param) |
1374 | 1374 | { |
1375 | - $this->raiseEvent('OnLoad',$this,$param); |
|
1375 | + $this->raiseEvent('OnLoad', $this, $param); |
|
1376 | 1376 | } |
1377 | 1377 | |
1378 | 1378 | /** |
@@ -1382,8 +1382,8 @@ discard block |
||
1382 | 1382 | */ |
1383 | 1383 | public function onDataBinding($param) |
1384 | 1384 | { |
1385 | - Prado::trace("onDataBinding()",'System.Web.UI.TControl'); |
|
1386 | - $this->raiseEvent('OnDataBinding',$this,$param); |
|
1385 | + Prado::trace("onDataBinding()", 'System.Web.UI.TControl'); |
|
1386 | + $this->raiseEvent('OnDataBinding', $this, $param); |
|
1387 | 1387 | } |
1388 | 1388 | |
1389 | 1389 | |
@@ -1396,7 +1396,7 @@ discard block |
||
1396 | 1396 | */ |
1397 | 1397 | public function onUnload($param) |
1398 | 1398 | { |
1399 | - $this->raiseEvent('OnUnload',$this,$param); |
|
1399 | + $this->raiseEvent('OnUnload', $this, $param); |
|
1400 | 1400 | } |
1401 | 1401 | |
1402 | 1402 | /** |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | */ |
1409 | 1409 | public function onPreRender($param) |
1410 | 1410 | { |
1411 | - $this->raiseEvent('OnPreRender',$this,$param); |
|
1411 | + $this->raiseEvent('OnPreRender', $this, $param); |
|
1412 | 1412 | } |
1413 | 1413 | |
1414 | 1414 | /** |
@@ -1418,12 +1418,12 @@ discard block |
||
1418 | 1418 | * @param TEventParameter event parameter |
1419 | 1419 | * @see bubbleEvent |
1420 | 1420 | */ |
1421 | - protected function raiseBubbleEvent($sender,$param) |
|
1421 | + protected function raiseBubbleEvent($sender, $param) |
|
1422 | 1422 | { |
1423 | 1423 | $control=$this; |
1424 | 1424 | while($control=$control->_parent) |
1425 | 1425 | { |
1426 | - if($control->bubbleEvent($sender,$param)) |
|
1426 | + if($control->bubbleEvent($sender, $param)) |
|
1427 | 1427 | break; |
1428 | 1428 | } |
1429 | 1429 | } |
@@ -1437,7 +1437,7 @@ discard block |
||
1437 | 1437 | * @return boolean true if the event bubbling is handled and no more bubbling. |
1438 | 1438 | * @see raiseBubbleEvent |
1439 | 1439 | */ |
1440 | - public function bubbleEvent($sender,$param) |
|
1440 | + public function bubbleEvent($sender, $param) |
|
1441 | 1441 | { |
1442 | 1442 | return false; |
1443 | 1443 | } |
@@ -1458,10 +1458,10 @@ discard block |
||
1458 | 1458 | * @param TControl sender of this event |
1459 | 1459 | * @param TEventParameter event parameter |
1460 | 1460 | */ |
1461 | - public function broadcastEvent($name,$sender,$param) |
|
1461 | + public function broadcastEvent($name, $sender, $param) |
|
1462 | 1462 | { |
1463 | - $rootControl=(($page=$this->getPage())===null)?$this:$page; |
|
1464 | - $rootControl->broadcastEventInternal($name,$sender,new TBroadcastEventParameter($name,$param)); |
|
1463 | + $rootControl=(($page=$this->getPage())===null) ? $this : $page; |
|
1464 | + $rootControl->broadcastEventInternal($name, $sender, new TBroadcastEventParameter($name, $param)); |
|
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | /** |
@@ -1471,18 +1471,18 @@ discard block |
||
1471 | 1471 | * @param TControl sender of the event |
1472 | 1472 | * @param TBroadcastEventParameter event parameter |
1473 | 1473 | */ |
1474 | - private function broadcastEventInternal($name,$sender,$param) |
|
1474 | + private function broadcastEventInternal($name, $sender, $param) |
|
1475 | 1475 | { |
1476 | 1476 | if($this->hasEvent($name)) |
1477 | - $this->raiseEvent($name,$sender,$param->getParameter()); |
|
1477 | + $this->raiseEvent($name, $sender, $param->getParameter()); |
|
1478 | 1478 | if($this instanceof IBroadcastEventReceiver) |
1479 | - $this->broadcastEventReceived($sender,$param); |
|
1479 | + $this->broadcastEventReceived($sender, $param); |
|
1480 | 1480 | if($this->getHasControls()) |
1481 | 1481 | { |
1482 | 1482 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1483 | 1483 | { |
1484 | 1484 | if($control instanceof TControl) |
1485 | - $control->broadcastEventInternal($name,$sender,$param); |
|
1485 | + $control->broadcastEventInternal($name, $sender, $param); |
|
1486 | 1486 | } |
1487 | 1487 | } |
1488 | 1488 | } |
@@ -1504,22 +1504,22 @@ discard block |
||
1504 | 1504 | * @param callback callback invoked before traversing child controls. If null, it is ignored. |
1505 | 1505 | * @param callback callback invoked after traversing child controls. If null, it is ignored. |
1506 | 1506 | */ |
1507 | - protected function traverseChildControls($param,$preCallback=null,$postCallback=null) |
|
1507 | + protected function traverseChildControls($param, $preCallback=null, $postCallback=null) |
|
1508 | 1508 | { |
1509 | 1509 | if($preCallback!==null) |
1510 | - call_user_func($preCallback,$this,$param); |
|
1510 | + call_user_func($preCallback, $this, $param); |
|
1511 | 1511 | if($this->getHasControls()) |
1512 | 1512 | { |
1513 | 1513 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1514 | 1514 | { |
1515 | 1515 | if($control instanceof TControl) |
1516 | 1516 | { |
1517 | - $control->traverseChildControls($param,$preCallback,$postCallback); |
|
1517 | + $control->traverseChildControls($param, $preCallback, $postCallback); |
|
1518 | 1518 | } |
1519 | 1519 | } |
1520 | 1520 | } |
1521 | 1521 | if($postCallback!==null) |
1522 | - call_user_func($postCallback,$this,$param); |
|
1522 | + call_user_func($postCallback, $this, $param); |
|
1523 | 1523 | } |
1524 | 1524 | |
1525 | 1525 | /** |
@@ -1596,7 +1596,7 @@ discard block |
||
1596 | 1596 | * @param array the collection of the state |
1597 | 1597 | * @param boolean whether the viewstate should be loaded |
1598 | 1598 | */ |
1599 | - protected function loadStateRecursive(&$state,$needViewState=true) |
|
1599 | + protected function loadStateRecursive(&$state, $needViewState=true) |
|
1600 | 1600 | { |
1601 | 1601 | if(is_array($state)) |
1602 | 1602 | { |
@@ -1626,7 +1626,7 @@ discard block |
||
1626 | 1626 | { |
1627 | 1627 | if(isset($state[$control->_id])) |
1628 | 1628 | { |
1629 | - $control->loadStateRecursive($state[$control->_id],$needViewState); |
|
1629 | + $control->loadStateRecursive($state[$control->_id], $needViewState); |
|
1630 | 1630 | unset($state[$control->_id]); |
1631 | 1631 | } |
1632 | 1632 | } |
@@ -1662,7 +1662,7 @@ discard block |
||
1662 | 1662 | { |
1663 | 1663 | if($control instanceof TControl) |
1664 | 1664 | { |
1665 | - if(count($tmp = &$control->saveStateRecursive($needViewState))) |
|
1665 | + if(count($tmp=&$control->saveStateRecursive($needViewState))) |
|
1666 | 1666 | $state[$control->_id]=$tmp; |
1667 | 1667 | } |
1668 | 1668 | } |
@@ -1684,10 +1684,10 @@ discard block |
||
1684 | 1684 | if($page && !($this->_flags & self::IS_STYLESHEET_APPLIED)) |
1685 | 1685 | { |
1686 | 1686 | $page->applyControlStyleSheet($this); |
1687 | - $this->_flags |= self::IS_STYLESHEET_APPLIED; |
|
1687 | + $this->_flags|=self::IS_STYLESHEET_APPLIED; |
|
1688 | 1688 | } |
1689 | 1689 | else if($this->_flags & self::IS_STYLESHEET_APPLIED) |
1690 | - throw new TInvalidOperationException('control_stylesheet_applied',get_class($this)); |
|
1690 | + throw new TInvalidOperationException('control_stylesheet_applied', get_class($this)); |
|
1691 | 1691 | } |
1692 | 1692 | |
1693 | 1693 | /** |
@@ -1711,11 +1711,11 @@ discard block |
||
1711 | 1711 | */ |
1712 | 1712 | private function generateAutomaticID() |
1713 | 1713 | { |
1714 | - $this->_flags &= ~self::IS_ID_SET; |
|
1714 | + $this->_flags&=~self::IS_ID_SET; |
|
1715 | 1715 | if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) |
1716 | 1716 | $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]=0; |
1717 | 1717 | $id=$this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++; |
1718 | - $this->_id=self::AUTOMATIC_ID_PREFIX . $id; |
|
1718 | + $this->_id=self::AUTOMATIC_ID_PREFIX.$id; |
|
1719 | 1719 | $this->_namingContainer->clearNameTable(); |
1720 | 1720 | } |
1721 | 1721 | |
@@ -1733,7 +1733,7 @@ discard block |
||
1733 | 1733 | * @param TControlCollection list of controls |
1734 | 1734 | * @throws TInvalidDataValueException if a control's ID is not unique within its naming container. |
1735 | 1735 | */ |
1736 | - private function fillNameTable($container,$controls) |
|
1736 | + private function fillNameTable($container, $controls) |
|
1737 | 1737 | { |
1738 | 1738 | foreach($controls as $control) |
1739 | 1739 | { |
@@ -1742,12 +1742,12 @@ discard block |
||
1742 | 1742 | if($control->_id!=='') |
1743 | 1743 | { |
1744 | 1744 | if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) |
1745 | - throw new TInvalidDataValueException('control_id_nonunique',get_class($control),$control->_id); |
|
1745 | + throw new TInvalidDataValueException('control_id_nonunique', get_class($control), $control->_id); |
|
1746 | 1746 | else |
1747 | 1747 | $container->_rf[self::RF_NAMED_CONTROLS][$control->_id]=$control; |
1748 | 1748 | } |
1749 | 1749 | if(!($control instanceof INamingContainer) && $control->getHasControls()) |
1750 | - $this->fillNameTable($container,$control->_rf[self::RF_CONTROLS]); |
|
1750 | + $this->fillNameTable($container, $control->_rf[self::RF_CONTROLS]); |
|
1751 | 1751 | } |
1752 | 1752 | } |
1753 | 1753 | } |
@@ -1777,10 +1777,10 @@ discard block |
||
1777 | 1777 | * @param TControl the control that owns this collection. |
1778 | 1778 | * @param boolean whether the list is read-only |
1779 | 1779 | */ |
1780 | - public function __construct(TControl $owner,$readOnly=false) |
|
1780 | + public function __construct(TControl $owner, $readOnly=false) |
|
1781 | 1781 | { |
1782 | 1782 | $this->_o=$owner; |
1783 | - parent::__construct(null,$readOnly); |
|
1783 | + parent::__construct(null, $readOnly); |
|
1784 | 1784 | } |
1785 | 1785 | |
1786 | 1786 | /** |
@@ -1799,15 +1799,15 @@ discard block |
||
1799 | 1799 | * @param mixed new item |
1800 | 1800 | * @throws TInvalidDataTypeException if the item to be inserted is neither a string nor a TControl. |
1801 | 1801 | */ |
1802 | - public function insertAt($index,$item) |
|
1802 | + public function insertAt($index, $item) |
|
1803 | 1803 | { |
1804 | 1804 | if($item instanceof TControl) |
1805 | 1805 | { |
1806 | - parent::insertAt($index,$item); |
|
1806 | + parent::insertAt($index, $item); |
|
1807 | 1807 | $this->_o->addedControl($item); |
1808 | 1808 | } |
1809 | 1809 | else if(is_string($item) || ($item instanceof IRenderable)) |
1810 | - parent::insertAt($index,$item); |
|
1810 | + parent::insertAt($index, $item); |
|
1811 | 1811 | else |
1812 | 1812 | throw new TInvalidDataTypeException('controlcollection_control_required'); |
1813 | 1813 | } |
@@ -1856,7 +1856,7 @@ discard block |
||
1856 | 1856 | */ |
1857 | 1857 | public function __construct(TControl $owner) |
1858 | 1858 | { |
1859 | - parent::__construct($owner,true); |
|
1859 | + parent::__construct($owner, true); |
|
1860 | 1860 | } |
1861 | 1861 | |
1862 | 1862 | /** |
@@ -1865,10 +1865,10 @@ discard block |
||
1865 | 1865 | * @param integer the speicified position. |
1866 | 1866 | * @param mixed new item |
1867 | 1867 | */ |
1868 | - public function insertAt($index,$item) |
|
1868 | + public function insertAt($index, $item) |
|
1869 | 1869 | { |
1870 | 1870 | if(!is_string($item)) // string is possible if property tag is used. we simply ignore it in this case |
1871 | - parent::insertAt($index,$item); // this will generate an exception in parent implementation |
|
1871 | + parent::insertAt($index, $item); // this will generate an exception in parent implementation |
|
1872 | 1872 | } |
1873 | 1873 | } |
1874 | 1874 | |
@@ -1923,7 +1923,7 @@ discard block |
||
1923 | 1923 | * @param array the input data collection |
1924 | 1924 | * @return boolean whether the data of the control has been changed |
1925 | 1925 | */ |
1926 | - public function loadPostData($key,$values); |
|
1926 | + public function loadPostData($key, $values); |
|
1927 | 1927 | /** |
1928 | 1928 | * Raises postdata changed event. |
1929 | 1929 | * The implementation of this function should raise appropriate event(s) (e.g. OnTextChanged) |
@@ -2019,7 +2019,7 @@ discard block |
||
2019 | 2019 | * @param TControl sender of the event |
2020 | 2020 | * @param TBroadCastEventParameter event parameter |
2021 | 2021 | */ |
2022 | - public function broadcastEventReceived($sender,$param); |
|
2022 | + public function broadcastEventReceived($sender, $param); |
|
2023 | 2023 | } |
2024 | 2024 | |
2025 | 2025 | /** |
@@ -2192,7 +2192,7 @@ discard block |
||
2192 | 2192 | * @param string name of the broadcast event |
2193 | 2193 | * @param mixed parameter of the broadcast event |
2194 | 2194 | */ |
2195 | - public function __construct($name='',$parameter=null) |
|
2195 | + public function __construct($name='', $parameter=null) |
|
2196 | 2196 | { |
2197 | 2197 | $this->_name=$name; |
2198 | 2198 | $this->_param=$parameter; |
@@ -2253,7 +2253,7 @@ discard block |
||
2253 | 2253 | * @param string name of the command |
2254 | 2254 | * @param string parameter of the command |
2255 | 2255 | */ |
2256 | - public function __construct($name='',$parameter='') |
|
2256 | + public function __construct($name='', $parameter='') |
|
2257 | 2257 | { |
2258 | 2258 | $this->_name=$name; |
2259 | 2259 | $this->_param=$parameter; |
@@ -2345,7 +2345,7 @@ discard block |
||
2345 | 2345 | */ |
2346 | 2346 | public function evaluateDynamicContent() |
2347 | 2347 | { |
2348 | - $context=$this->_container===null?$this:$this->_container; |
|
2348 | + $context=$this->_container===null ? $this : $this->_container; |
|
2349 | 2349 | foreach($this->_expressions as $id=>$expression) |
2350 | 2350 | $this->_items[$id]=$context->evaluateExpression($expression); |
2351 | 2351 | foreach($this->_statements as $id=>$statement) |
@@ -2358,7 +2358,7 @@ discard block |
||
2358 | 2358 | */ |
2359 | 2359 | public function dataBind() |
2360 | 2360 | { |
2361 | - $context=$this->_container===null?$this:$this->_container; |
|
2361 | + $context=$this->_container===null ? $this : $this->_container; |
|
2362 | 2362 | foreach($this->_bindings as $id=>$binding) |
2363 | 2363 | $this->_items[$id]=$context->evaluateExpression($binding); |
2364 | 2364 | } |
@@ -2370,7 +2370,7 @@ discard block |
||
2370 | 2370 | */ |
2371 | 2371 | public function render($writer) |
2372 | 2372 | { |
2373 | - $writer->write(implode('',$this->_items)); |
|
2373 | + $writer->write(implode('', $this->_items)); |
|
2374 | 2374 | } |
2375 | 2375 | } |
2376 | 2376 |
@@ -377,11 +377,9 @@ discard block |
||
377 | 377 | return $this->_id; |
378 | 378 | else |
379 | 379 | return ($this->_uid=$prefix.self::ID_SEPARATOR.$this->_id); |
380 | - } |
|
381 | - else // no naming container |
|
380 | + } else // no naming container |
|
382 | 381 | return $this->_id; |
383 | - } |
|
384 | - else |
|
382 | + } else |
|
385 | 383 | return $this->_uid; |
386 | 384 | } |
387 | 385 | |
@@ -535,8 +533,7 @@ discard block |
||
535 | 533 | if(!$control->getVisible(false)) |
536 | 534 | return false; |
537 | 535 | return true; |
538 | - } |
|
539 | - else |
|
536 | + } else |
|
540 | 537 | return $this->getViewState('Visible',true); |
541 | 538 | } |
542 | 539 | |
@@ -566,8 +563,7 @@ discard block |
||
566 | 563 | if(!$control->getViewState('Enabled',true)) |
567 | 564 | return false; |
568 | 565 | return true; |
569 | - } |
|
570 | - else |
|
566 | + } else |
|
571 | 567 | return $this->getViewState('Enabled',true); |
572 | 568 | } |
573 | 569 | |
@@ -664,8 +660,7 @@ discard block |
||
664 | 660 | if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
665 | 661 | return false; |
666 | 662 | return true; |
667 | - } |
|
668 | - else |
|
663 | + } else |
|
669 | 664 | return !($this->_flags & self::IS_DISABLE_VIEWSTATE); |
670 | 665 | } |
671 | 666 | |
@@ -750,8 +745,7 @@ discard block |
||
750 | 745 | if(is_object($this->_tempState[$key]) && $this->_trackViewState) |
751 | 746 | $this->_viewState[$key]=$this->_tempState[$key]; |
752 | 747 | return $this->_tempState[$key]; |
753 | - } |
|
754 | - else |
|
748 | + } else |
|
755 | 749 | return $defaultValue; |
756 | 750 | } |
757 | 751 | |
@@ -774,8 +768,7 @@ discard block |
||
774 | 768 | unset($this->_viewState[$key]); |
775 | 769 | else |
776 | 770 | $this->_viewState[$key]=$value; |
777 | - } |
|
778 | - else |
|
771 | + } else |
|
779 | 772 | { |
780 | 773 | unset($this->_viewState[$key]); |
781 | 774 | if($value===$defaultValue) |
@@ -924,8 +917,7 @@ discard block |
||
924 | 917 | $this->createChildControls(); |
925 | 918 | $this->_flags &= ~self::IS_CREATING_CHILD; |
926 | 919 | $this->_flags |= self::IS_CHILD_CREATED; |
927 | - } |
|
928 | - catch(Exception $e) |
|
920 | + } catch(Exception $e) |
|
929 | 921 | { |
930 | 922 | $this->_flags &= ~self::IS_CREATING_CHILD; |
931 | 923 | $this->_flags |= self::IS_CHILD_CREATED; |
@@ -1164,8 +1156,9 @@ discard block |
||
1164 | 1156 | final protected function isDescendentOf($ancestor) |
1165 | 1157 | { |
1166 | 1158 | $control=$this; |
1167 | - while($control!==$ancestor && $control->_parent) |
|
1168 | - $control=$control->_parent; |
|
1159 | + while($control!==$ancestor && $control->_parent) { |
|
1160 | + $control=$control->_parent; |
|
1161 | + } |
|
1169 | 1162 | return $control===$ancestor; |
1170 | 1163 | } |
1171 | 1164 | |
@@ -1201,8 +1194,7 @@ discard block |
||
1201 | 1194 | { |
1202 | 1195 | $state=$this->_rf[self::RF_CHILD_STATE][$control->_id]; |
1203 | 1196 | unset($this->_rf[self::RF_CHILD_STATE][$control->_id]); |
1204 | - } |
|
1205 | - else |
|
1197 | + } else |
|
1206 | 1198 | $state=null; |
1207 | 1199 | $control->loadStateRecursive($state,!($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1208 | 1200 | if($this->_stage>=self::CS_LOADED) |
@@ -1607,8 +1599,7 @@ discard block |
||
1607 | 1599 | { |
1608 | 1600 | $this->_rf[self::RF_CONTROLSTATE]=&$state[1]; |
1609 | 1601 | unset($state[1]); |
1610 | - } |
|
1611 | - else |
|
1602 | + } else |
|
1612 | 1603 | unset($this->_rf[self::RF_CONTROLSTATE]); |
1613 | 1604 | if($needViewState) |
1614 | 1605 | { |
@@ -1685,8 +1676,7 @@ discard block |
||
1685 | 1676 | { |
1686 | 1677 | $page->applyControlStyleSheet($this); |
1687 | 1678 | $this->_flags |= self::IS_STYLESHEET_APPLIED; |
1688 | - } |
|
1689 | - else if($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
1679 | + } else if($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
1690 | 1680 | throw new TInvalidOperationException('control_stylesheet_applied',get_class($this)); |
1691 | 1681 | } |
1692 | 1682 | |
@@ -1805,8 +1795,7 @@ discard block |
||
1805 | 1795 | { |
1806 | 1796 | parent::insertAt($index,$item); |
1807 | 1797 | $this->_o->addedControl($item); |
1808 | - } |
|
1809 | - else if(is_string($item) || ($item instanceof IRenderable)) |
|
1798 | + } else if(is_string($item) || ($item instanceof IRenderable)) |
|
1810 | 1799 | parent::insertAt($index,$item); |
1811 | 1800 | else |
1812 | 1801 | throw new TInvalidDataTypeException('controlcollection_control_required'); |
@@ -2318,8 +2307,7 @@ discard block |
||
2318 | 2307 | else if($item[0]===self::TYPE_DATABINDING) |
2319 | 2308 | $this->_bindings[$id]=$item[1]; |
2320 | 2309 | $this->_items[$id]=''; |
2321 | - } |
|
2322 | - else |
|
2310 | + } else |
|
2323 | 2311 | $this->_items[$id]=$item; |
2324 | 2312 | } |
2325 | 2313 | } |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * TControl, TControlCollection, TEventParameter and INamingContainer class file |
|
4 | - * |
|
5 | - * @author Qiang Xue <[email protected]> |
|
6 | - * @link https://github.com/pradosoft/prado |
|
7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | - * @package System.Web.UI |
|
10 | - */ |
|
3 | + * TControl, TControlCollection, TEventParameter and INamingContainer class file |
|
4 | + * |
|
5 | + * @author Qiang Xue <[email protected]> |
|
6 | + * @link https://github.com/pradosoft/prado |
|
7 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | + * @package System.Web.UI |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Includes TAttributeCollection and TControlAdapter class |
@@ -220,6 +220,7 @@ discard block |
||
220 | 220 | * If you override this method, be sure to call the parent implementation |
221 | 221 | * so that the event handler can be invoked. |
222 | 222 | * @param TImageClickEventParameter event parameter to be passed to the event handlers |
223 | + * @param TImageClickEventParameter $param |
|
223 | 224 | */ |
224 | 225 | public function onClick($param) |
225 | 226 | { |
@@ -232,6 +233,7 @@ discard block |
||
232 | 233 | * If you override this method, be sure to call the parent implementation |
233 | 234 | * so that the event handlers can be invoked. |
234 | 235 | * @param TCommandEventParameter event parameter to be passed to the event handlers |
236 | + * @param TCommandEventParameter $param |
|
235 | 237 | */ |
236 | 238 | public function onCommand($param) |
237 | 239 | { |
@@ -324,6 +326,7 @@ discard block |
||
324 | 326 | |
325 | 327 | /** |
326 | 328 | * @param string the group of validators which the button causes validation upon postback |
329 | + * @param string $value |
|
327 | 330 | */ |
328 | 331 | public function setValidationGroup($value) |
329 | 332 | { |
@@ -396,6 +399,8 @@ discard block |
||
396 | 399 | * Constructor. |
397 | 400 | * @param integer X coordinate of the clicking point |
398 | 401 | * @param integer Y coordinate of the clicking point |
402 | + * @param integer $x |
|
403 | + * @param integer $y |
|
399 | 404 | */ |
400 | 405 | public function __construct($x,$y) |
401 | 406 | { |
@@ -106,8 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | if($this->getEnableClientScript() && $this->needPostBackScript()) |
108 | 108 | $this->renderClientControlScript($writer); |
109 | - } |
|
110 | - else if($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
109 | + } else if($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
111 | 110 | $writer->addAttribute('disabled','disabled'); |
112 | 111 | parent::addAttributesToRender($writer); |
113 | 112 | } |
@@ -141,8 +140,7 @@ discard block |
||
141 | 140 | { |
142 | 141 | $group=$this->getValidationGroup(); |
143 | 142 | return $this->getPage()->getValidators($group)->getCount()>0; |
144 | - } |
|
145 | - else |
|
143 | + } else |
|
146 | 144 | return false; |
147 | 145 | } |
148 | 146 |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function getEnableClientScript() |
81 | 81 | { |
82 | - return $this->getViewState('EnableClientScript',true); |
|
82 | + return $this->getViewState('EnableClientScript', true); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function setEnableClientScript($value) |
89 | 89 | { |
90 | - $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
|
90 | + $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -99,16 +99,16 @@ discard block |
||
99 | 99 | { |
100 | 100 | $page=$this->getPage(); |
101 | 101 | $page->ensureRenderInForm($this); |
102 | - $writer->addAttribute('type','image'); |
|
102 | + $writer->addAttribute('type', 'image'); |
|
103 | 103 | if(($uniqueID=$this->getUniqueID())!=='') |
104 | - $writer->addAttribute('name',$uniqueID); |
|
104 | + $writer->addAttribute('name', $uniqueID); |
|
105 | 105 | if($this->getEnabled(true)) |
106 | 106 | { |
107 | 107 | if($this->getEnableClientScript() && $this->needPostBackScript()) |
108 | 108 | $this->renderClientControlScript($writer); |
109 | 109 | } |
110 | 110 | else if($this->getEnabled()) // in this case, parent will not render 'disabled' |
111 | - $writer->addAttribute('disabled','disabled'); |
|
111 | + $writer->addAttribute('disabled', 'disabled'); |
|
112 | 112 | parent::addAttributesToRender($writer); |
113 | 113 | } |
114 | 114 | |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function renderClientControlScript($writer) |
119 | 119 | { |
120 | - $writer->addAttribute('id',$this->getClientID()); |
|
121 | - $cs = $this->getPage()->getClientScript(); |
|
122 | - $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); |
|
120 | + $writer->addAttribute('id', $this->getClientID()); |
|
121 | + $cs=$this->getPage()->getClientScript(); |
|
122 | + $cs->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions()); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | if($this->getCausesValidation()) |
141 | 141 | { |
142 | 142 | $group=$this->getValidationGroup(); |
143 | - return $this->getPage()->getValidators($group)->getCount()>0; |
|
143 | + return $this->getPage()->getValidators($group)->getCount() > 0; |
|
144 | 144 | } |
145 | 145 | else |
146 | 146 | return false; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function setIsDefaultButton($value) |
153 | 153 | { |
154 | - $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value),false); |
|
154 | + $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value), false); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function getPostBackOptions() |
179 | 179 | { |
180 | - $options['ID'] = $this->getClientID(); |
|
181 | - $options['CausesValidation'] = $this->getCausesValidation(); |
|
182 | - $options['ValidationGroup'] = $this->getValidationGroup(); |
|
183 | - $options['EventTarget'] = $this->getUniqueID(); |
|
180 | + $options['ID']=$this->getClientID(); |
|
181 | + $options['CausesValidation']=$this->getCausesValidation(); |
|
182 | + $options['ValidationGroup']=$this->getValidationGroup(); |
|
183 | + $options['EventTarget']=$this->getUniqueID(); |
|
184 | 184 | |
185 | 185 | return $options; |
186 | 186 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param array the input data collection |
193 | 193 | * @return boolean whether the data of the component has been changed |
194 | 194 | */ |
195 | - public function loadPostData($key,$values) |
|
195 | + public function loadPostData($key, $values) |
|
196 | 196 | { |
197 | 197 | $uid=$this->getUniqueID(); |
198 | 198 | if(isset($values["{$uid}_x"]) && isset($values["{$uid}_y"])) |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function onClick($param) |
225 | 225 | { |
226 | - $this->raiseEvent('OnClick',$this,$param); |
|
226 | + $this->raiseEvent('OnClick', $this, $param); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function onCommand($param) |
237 | 237 | { |
238 | - $this->raiseEvent('OnCommand',$this,$param); |
|
239 | - $this->raiseBubbleEvent($this,$param); |
|
238 | + $this->raiseEvent('OnCommand', $this, $param); |
|
239 | + $this->raiseBubbleEvent($this, $param); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | { |
253 | 253 | if($this->getCausesValidation()) |
254 | 254 | $this->getPage()->validate($this->getValidationGroup()); |
255 | - $this->onClick(new TImageClickEventParameter($this->_x,$this->_y)); |
|
256 | - $this->onCommand(new TCommandEventParameter($this->getCommandName(),$this->getCommandParameter())); |
|
255 | + $this->onClick(new TImageClickEventParameter($this->_x, $this->_y)); |
|
256 | + $this->onCommand(new TCommandEventParameter($this->getCommandName(), $this->getCommandParameter())); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public function getCausesValidation() |
273 | 273 | { |
274 | - return $this->getViewState('CausesValidation',true); |
|
274 | + return $this->getViewState('CausesValidation', true); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function setCausesValidation($value) |
281 | 281 | { |
282 | - $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); |
|
282 | + $this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | public function getCommandName() |
289 | 289 | { |
290 | - return $this->getViewState('CommandName',''); |
|
290 | + return $this->getViewState('CommandName', ''); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | */ |
296 | 296 | public function setCommandName($value) |
297 | 297 | { |
298 | - $this->setViewState('CommandName',$value,''); |
|
298 | + $this->setViewState('CommandName', $value, ''); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function getCommandParameter() |
305 | 305 | { |
306 | - return $this->getViewState('CommandParameter',''); |
|
306 | + return $this->getViewState('CommandParameter', ''); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function setCommandParameter($value) |
313 | 313 | { |
314 | - $this->setViewState('CommandParameter',$value,''); |
|
314 | + $this->setViewState('CommandParameter', $value, ''); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function getValidationGroup() |
321 | 321 | { |
322 | - return $this->getViewState('ValidationGroup',''); |
|
322 | + return $this->getViewState('ValidationGroup', ''); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | */ |
328 | 328 | public function setValidationGroup($value) |
329 | 329 | { |
330 | - $this->setViewState('ValidationGroup',$value,''); |
|
330 | + $this->setViewState('ValidationGroup', $value, ''); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | * @param integer X coordinate of the clicking point |
398 | 398 | * @param integer Y coordinate of the clicking point |
399 | 399 | */ |
400 | - public function __construct($x,$y) |
|
400 | + public function __construct($x, $y) |
|
401 | 401 | { |
402 | 402 | $this->_x=$x; |
403 | 403 | $this->_y=$y; |