@@ -119,6 +119,7 @@ discard block |
||
| 119 | 119 | * @param integer the line number that parsing starts from (internal use) |
| 120 | 120 | * @param boolean whether this template is a source template, i.e., this template is loaded from |
| 121 | 121 | * some external storage rather than from within another template. |
| 122 | + * @param string $tplFile |
|
| 122 | 123 | */ |
| 123 | 124 | public function __construct($template,$contextPath,$tplFile=null,$startingLine=0,$sourceTemplate=true) |
| 124 | 125 | { |
@@ -301,6 +302,7 @@ discard block |
||
| 301 | 302 | * @param TControl control to be configured |
| 302 | 303 | * @param string property name |
| 303 | 304 | * @param mixed property initial value |
| 305 | + * @param TControl $control |
|
| 304 | 306 | */ |
| 305 | 307 | protected function configureControl($control,$name,$value) |
| 306 | 308 | { |
@@ -317,6 +319,7 @@ discard block |
||
| 317 | 319 | * @param TComponent component to be configured |
| 318 | 320 | * @param string property name |
| 319 | 321 | * @param mixed property initial value |
| 322 | + * @param TComponent $component |
|
| 320 | 323 | */ |
| 321 | 324 | protected function configureComponent($component,$name,$value) |
| 322 | 325 | { |
@@ -703,6 +706,8 @@ discard block |
||
| 703 | 706 | /** |
| 704 | 707 | * Parses the attributes of a tag from a string. |
| 705 | 708 | * @param string the string to be parsed. |
| 709 | + * @param string $str |
|
| 710 | + * @param string $offset |
|
| 706 | 711 | * @return array attribute values indexed by names. |
| 707 | 712 | */ |
| 708 | 713 | protected function parseAttributes($str,$offset) |
@@ -737,6 +742,9 @@ discard block |
||
| 737 | 742 | return $attributes; |
| 738 | 743 | } |
| 739 | 744 | |
| 745 | + /** |
|
| 746 | + * @param string $content |
|
| 747 | + */ |
|
| 740 | 748 | protected function parseTemplateProperty($content,$offset) |
| 741 | 749 | { |
| 742 | 750 | $line=$this->_startingLine+count(explode("\n",substr($this->_content,0,$offset)))-1; |
@@ -746,6 +754,7 @@ discard block |
||
| 746 | 754 | /** |
| 747 | 755 | * Parses a single attribute. |
| 748 | 756 | * @param string the string to be parsed. |
| 757 | + * @param string $value |
|
| 749 | 758 | * @return array attribute initialization |
| 750 | 759 | */ |
| 751 | 760 | protected function parseAttribute($value) |
@@ -889,6 +898,8 @@ discard block |
||
| 889 | 898 | * @param Exception template exception |
| 890 | 899 | * @param int line number |
| 891 | 900 | * @param string template string if no source file is used |
| 901 | + * @param \Exception $e |
|
| 902 | + * @param integer $line |
|
| 892 | 903 | */ |
| 893 | 904 | protected function handleException($e,$line,$input=null) |
| 894 | 905 | { |
@@ -958,7 +969,7 @@ discard block |
||
| 958 | 969 | |
| 959 | 970 | /** |
| 960 | 971 | * Checks if the given method belongs to a previously attached class behavior. |
| 961 | - * @param ReflectionClass $class |
|
| 972 | + * @param \ReflectionClass $class |
|
| 962 | 973 | * @param string $method |
| 963 | 974 | * @return boolean |
| 964 | 975 | */ |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @param boolean whether this template is a source template, i.e., this template is loaded from |
| 121 | 121 | * some external storage rather than from within another template. |
| 122 | 122 | */ |
| 123 | - public function __construct($template,$contextPath,$tplFile=null,$startingLine=0,$sourceTemplate=true) |
|
| 123 | + public function __construct($template, $contextPath, $tplFile=null, $startingLine=0, $sourceTemplate=true) |
|
| 124 | 124 | { |
| 125 | 125 | $this->_sourceTemplate=$sourceTemplate; |
| 126 | 126 | $this->_contextPath=$contextPath; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * @param TControl the control who owns the template |
| 189 | 189 | * @param TControl the control who will become the root parent of the controls on the template. If null, it uses the template control. |
| 190 | 190 | */ |
| 191 | - public function instantiateIn($tplControl,$parentControl=null) |
|
| 191 | + public function instantiateIn($tplControl, $parentControl=null) |
|
| 192 | 192 | { |
| 193 | 193 | $this->_tplControl=$tplControl; |
| 194 | 194 | if($parentControl===null) |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | { |
| 219 | 219 | if(is_array($properties['id'])) |
| 220 | 220 | $properties['id']=$component->evaluateExpression($properties['id'][1]); |
| 221 | - $tplControl->registerObject($properties['id'],$component); |
|
| 221 | + $tplControl->registerObject($properties['id'], $component); |
|
| 222 | 222 | } |
| 223 | 223 | if(isset($properties['skinid'])) |
| 224 | 224 | { |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | $component->applyStyleSheetSkin($page); |
| 235 | 235 | foreach($properties as $name=>$value) |
| 236 | - $this->configureControl($component,$name,$value); |
|
| 236 | + $this->configureControl($component, $name, $value); |
|
| 237 | 237 | |
| 238 | 238 | $component->trackViewState(true); |
| 239 | 239 | |
@@ -251,12 +251,12 @@ discard block |
||
| 251 | 251 | { |
| 252 | 252 | if(is_array($properties['id'])) |
| 253 | 253 | $properties['id']=$component->evaluateExpression($properties['id'][1]); |
| 254 | - $tplControl->registerObject($properties['id'],$component); |
|
| 254 | + $tplControl->registerObject($properties['id'], $component); |
|
| 255 | 255 | if(!$component->hasProperty('id')) |
| 256 | 256 | unset($properties['id']); |
| 257 | 257 | } |
| 258 | 258 | foreach($properties as $name=>$value) |
| 259 | - $this->configureComponent($component,$name,$value); |
|
| 259 | + $this->configureComponent($component, $name, $value); |
|
| 260 | 260 | if($parent===$parentControl) |
| 261 | 261 | $directChildren[]=$component; |
| 262 | 262 | else |
@@ -302,14 +302,14 @@ discard block |
||
| 302 | 302 | * @param string property name |
| 303 | 303 | * @param mixed property initial value |
| 304 | 304 | */ |
| 305 | - protected function configureControl($control,$name,$value) |
|
| 305 | + protected function configureControl($control, $name, $value) |
|
| 306 | 306 | { |
| 307 | - if(strncasecmp($name,'on',2)===0) // is an event |
|
| 308 | - $this->configureEvent($control,$name,$value,$control); |
|
| 309 | - else if(($pos=strrpos($name,'.'))===false) // is a simple property or custom attribute |
|
| 310 | - $this->configureProperty($control,$name,$value); |
|
| 307 | + if(strncasecmp($name, 'on', 2)===0) // is an event |
|
| 308 | + $this->configureEvent($control, $name, $value, $control); |
|
| 309 | + else if(($pos=strrpos($name, '.'))===false) // is a simple property or custom attribute |
|
| 310 | + $this->configureProperty($control, $name, $value); |
|
| 311 | 311 | else // is a subproperty |
| 312 | - $this->configureSubProperty($control,$name,$value); |
|
| 312 | + $this->configureSubProperty($control, $name, $value); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
@@ -318,12 +318,12 @@ discard block |
||
| 318 | 318 | * @param string property name |
| 319 | 319 | * @param mixed property initial value |
| 320 | 320 | */ |
| 321 | - protected function configureComponent($component,$name,$value) |
|
| 321 | + protected function configureComponent($component, $name, $value) |
|
| 322 | 322 | { |
| 323 | - if(strpos($name,'.')===false) // is a simple property or custom attribute |
|
| 324 | - $this->configureProperty($component,$name,$value); |
|
| 323 | + if(strpos($name, '.')===false) // is a simple property or custom attribute |
|
| 324 | + $this->configureProperty($component, $name, $value); |
|
| 325 | 325 | else // is a subproperty |
| 326 | - $this->configureSubProperty($component,$name,$value); |
|
| 326 | + $this->configureSubProperty($component, $name, $value); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -333,12 +333,12 @@ discard block |
||
| 333 | 333 | * @param string event handler |
| 334 | 334 | * @param TControl context control |
| 335 | 335 | */ |
| 336 | - protected function configureEvent($control,$name,$value,$contextControl) |
|
| 336 | + protected function configureEvent($control, $name, $value, $contextControl) |
|
| 337 | 337 | { |
| 338 | - if(strpos($value,'.')===false) |
|
| 339 | - $control->attachEventHandler($name,array($contextControl,'TemplateControl.'.$value)); |
|
| 338 | + if(strpos($value, '.')===false) |
|
| 339 | + $control->attachEventHandler($name, array($contextControl, 'TemplateControl.'.$value)); |
|
| 340 | 340 | else |
| 341 | - $control->attachEventHandler($name,array($contextControl,$value)); |
|
| 341 | + $control->attachEventHandler($name, array($contextControl, $value)); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /** |
@@ -347,18 +347,18 @@ discard block |
||
| 347 | 347 | * @param string property name |
| 348 | 348 | * @param mixed property initial value |
| 349 | 349 | */ |
| 350 | - protected function configureProperty($component,$name,$value) |
|
| 350 | + protected function configureProperty($component, $name, $value) |
|
| 351 | 351 | { |
| 352 | 352 | if(is_array($value)) |
| 353 | 353 | { |
| 354 | 354 | switch($value[0]) |
| 355 | 355 | { |
| 356 | 356 | case self::CONFIG_DATABIND: |
| 357 | - $component->bindProperty($name,$value[1]); |
|
| 357 | + $component->bindProperty($name, $value[1]); |
|
| 358 | 358 | break; |
| 359 | 359 | case self::CONFIG_EXPRESSION: |
| 360 | 360 | if($component instanceof TControl) |
| 361 | - $component->autoBindProperty($name,$value[1]); |
|
| 361 | + $component->autoBindProperty($name, $value[1]); |
|
| 362 | 362 | else |
| 363 | 363 | { |
| 364 | 364 | $setter='set'.$name; |
@@ -383,15 +383,15 @@ discard block |
||
| 383 | 383 | $component->$setter(Prado::localize($value[1])); |
| 384 | 384 | break; |
| 385 | 385 | default: // an error if reaching here |
| 386 | - throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
|
| 386 | + throw new TConfigurationException('template_tag_unexpected', $name, $value[1]); |
|
| 387 | 387 | break; |
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | else |
| 391 | 391 | { |
| 392 | - if (substr($name,0,2)=='js') |
|
| 393 | - if ($value and !($value instanceof TJavaScriptLiteral)) |
|
| 394 | - $value = new TJavaScriptLiteral($value); |
|
| 392 | + if(substr($name, 0, 2)=='js') |
|
| 393 | + if($value and !($value instanceof TJavaScriptLiteral)) |
|
| 394 | + $value=new TJavaScriptLiteral($value); |
|
| 395 | 395 | $setter='set'.$name; |
| 396 | 396 | $component->$setter($value); |
| 397 | 397 | } |
@@ -403,41 +403,41 @@ discard block |
||
| 403 | 403 | * @param string subproperty name |
| 404 | 404 | * @param mixed subproperty initial value |
| 405 | 405 | */ |
| 406 | - protected function configureSubProperty($component,$name,$value) |
|
| 406 | + protected function configureSubProperty($component, $name, $value) |
|
| 407 | 407 | { |
| 408 | 408 | if(is_array($value)) |
| 409 | 409 | { |
| 410 | 410 | switch($value[0]) |
| 411 | 411 | { |
| 412 | 412 | case self::CONFIG_DATABIND: // databinding |
| 413 | - $component->bindProperty($name,$value[1]); |
|
| 413 | + $component->bindProperty($name, $value[1]); |
|
| 414 | 414 | break; |
| 415 | 415 | case self::CONFIG_EXPRESSION: // expression |
| 416 | 416 | if($component instanceof TControl) |
| 417 | - $component->autoBindProperty($name,$value[1]); |
|
| 417 | + $component->autoBindProperty($name, $value[1]); |
|
| 418 | 418 | else |
| 419 | - $component->setSubProperty($name,$this->_tplControl->evaluateExpression($value[1])); |
|
| 419 | + $component->setSubProperty($name, $this->_tplControl->evaluateExpression($value[1])); |
|
| 420 | 420 | break; |
| 421 | 421 | case self::CONFIG_TEMPLATE: |
| 422 | - $component->setSubProperty($name,$value[1]); |
|
| 422 | + $component->setSubProperty($name, $value[1]); |
|
| 423 | 423 | break; |
| 424 | 424 | case self::CONFIG_ASSET: // asset URL |
| 425 | 425 | $url=$this->publishFilePath($this->_contextPath.DIRECTORY_SEPARATOR.$value[1]); |
| 426 | - $component->setSubProperty($name,$url); |
|
| 426 | + $component->setSubProperty($name, $url); |
|
| 427 | 427 | break; |
| 428 | 428 | case self::CONFIG_PARAMETER: // application parameter |
| 429 | - $component->setSubProperty($name,$this->getApplication()->getParameters()->itemAt($value[1])); |
|
| 429 | + $component->setSubProperty($name, $this->getApplication()->getParameters()->itemAt($value[1])); |
|
| 430 | 430 | break; |
| 431 | 431 | case self::CONFIG_LOCALIZATION: |
| 432 | - $component->setSubProperty($name,Prado::localize($value[1])); |
|
| 432 | + $component->setSubProperty($name, Prado::localize($value[1])); |
|
| 433 | 433 | break; |
| 434 | 434 | default: // an error if reaching here |
| 435 | - throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
|
| 435 | + throw new TConfigurationException('template_tag_unexpected', $name, $value[1]); |
|
| 436 | 436 | break; |
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | else |
| 440 | - $component->setSubProperty($name,$value); |
|
| 440 | + $component->setSubProperty($name, $value); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | /** |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | { |
| 466 | 466 | $input=$this->preprocess($input); |
| 467 | 467 | $tpl=&$this->_tpl; |
| 468 | - $n=preg_match_all(self::REGEX_RULES,$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE); |
|
| 468 | + $n=preg_match_all(self::REGEX_RULES, $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); |
|
| 469 | 469 | $expectPropEnd=false; |
| 470 | 470 | $textStart=0; |
| 471 | 471 | $stack=array(); |
@@ -475,186 +475,186 @@ discard block |
||
| 475 | 475 | $this->_directive=null; |
| 476 | 476 | try |
| 477 | 477 | { |
| 478 | - for($i=0;$i<$n;++$i) |
|
| 478 | + for($i=0; $i < $n; ++$i) |
|
| 479 | 479 | { |
| 480 | 480 | $match=&$matches[$i]; |
| 481 | 481 | $str=$match[0][0]; |
| 482 | 482 | $matchStart=$match[0][1]; |
| 483 | - $matchEnd=$matchStart+strlen($str)-1; |
|
| 484 | - if(strpos($str,'<com:')===0) // opening component tag |
|
| 483 | + $matchEnd=$matchStart + strlen($str) - 1; |
|
| 484 | + if(strpos($str, '<com:')===0) // opening component tag |
|
| 485 | 485 | { |
| 486 | 486 | if($expectPropEnd) |
| 487 | 487 | continue; |
| 488 | - if($matchStart>$textStart) |
|
| 489 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 490 | - $textStart=$matchEnd+1; |
|
| 488 | + if($matchStart > $textStart) |
|
| 489 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 490 | + $textStart=$matchEnd + 1; |
|
| 491 | 491 | $type=$match[1][0]; |
| 492 | - $attributes=$this->parseAttributes($match[2][0],$match[2][1]); |
|
| 493 | - $class=$this->validateAttributes($type,$attributes); |
|
| 494 | - $tpl[$c++]=array($container,$class,$attributes); |
|
| 495 | - if($str[strlen($str)-2]!=='/') // open tag |
|
| 492 | + $attributes=$this->parseAttributes($match[2][0], $match[2][1]); |
|
| 493 | + $class=$this->validateAttributes($type, $attributes); |
|
| 494 | + $tpl[$c++]=array($container, $class, $attributes); |
|
| 495 | + if($str[strlen($str) - 2]!=='/') // open tag |
|
| 496 | 496 | { |
| 497 | - $stack[] = $type; |
|
| 498 | - $container=$c-1; |
|
| 497 | + $stack[]=$type; |
|
| 498 | + $container=$c - 1; |
|
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | - else if(strpos($str,'</com:')===0) // closing component tag |
|
| 501 | + else if(strpos($str, '</com:')===0) // closing component tag |
|
| 502 | 502 | { |
| 503 | 503 | if($expectPropEnd) |
| 504 | 504 | continue; |
| 505 | - if($matchStart>$textStart) |
|
| 506 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 507 | - $textStart=$matchEnd+1; |
|
| 505 | + if($matchStart > $textStart) |
|
| 506 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 507 | + $textStart=$matchEnd + 1; |
|
| 508 | 508 | $type=$match[1][0]; |
| 509 | 509 | |
| 510 | 510 | if(empty($stack)) |
| 511 | - throw new TConfigurationException('template_closingtag_unexpected',"</com:$type>"); |
|
| 511 | + throw new TConfigurationException('template_closingtag_unexpected', "</com:$type>"); |
|
| 512 | 512 | |
| 513 | 513 | $name=array_pop($stack); |
| 514 | 514 | if($name!==$type) |
| 515 | 515 | { |
| 516 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
| 517 | - throw new TConfigurationException('template_closingtag_expected',$tag, "</com:$type>"); |
|
| 516 | + $tag=$name[0]==='@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>"; |
|
| 517 | + throw new TConfigurationException('template_closingtag_expected', $tag, "</com:$type>"); |
|
| 518 | 518 | } |
| 519 | 519 | $container=$tpl[$container][0]; |
| 520 | 520 | } |
| 521 | - else if(strpos($str,'<%@')===0) // directive |
|
| 521 | + else if(strpos($str, '<%@')===0) // directive |
|
| 522 | 522 | { |
| 523 | 523 | if($expectPropEnd) |
| 524 | 524 | continue; |
| 525 | - if($matchStart>$textStart) |
|
| 526 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 527 | - $textStart=$matchEnd+1; |
|
| 525 | + if($matchStart > $textStart) |
|
| 526 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 527 | + $textStart=$matchEnd + 1; |
|
| 528 | 528 | if(isset($tpl[0]) || $this->_directive!==null) |
| 529 | 529 | throw new TConfigurationException('template_directive_nonunique'); |
| 530 | - $this->_directive=$this->parseAttributes($match[4][0],$match[4][1]); |
|
| 530 | + $this->_directive=$this->parseAttributes($match[4][0], $match[4][1]); |
|
| 531 | 531 | } |
| 532 | - else if(strpos($str,'<%')===0) // expression |
|
| 532 | + else if(strpos($str, '<%')===0) // expression |
|
| 533 | 533 | { |
| 534 | 534 | if($expectPropEnd) |
| 535 | 535 | continue; |
| 536 | - if($matchStart>$textStart) |
|
| 537 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 538 | - $textStart=$matchEnd+1; |
|
| 536 | + if($matchStart > $textStart) |
|
| 537 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 538 | + $textStart=$matchEnd + 1; |
|
| 539 | 539 | $literal=trim($match[5][0]); |
| 540 | 540 | if($str[2]==='=') // expression |
| 541 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,$literal)); |
|
| 541 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, $literal)); |
|
| 542 | 542 | else if($str[2]==='%') // statements |
| 543 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_STATEMENTS,$literal)); |
|
| 543 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_STATEMENTS, $literal)); |
|
| 544 | 544 | else if($str[2]==='#') |
| 545 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_DATABINDING,$literal)); |
|
| 545 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_DATABINDING, $literal)); |
|
| 546 | 546 | else if($str[2]==='$') |
| 547 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')")); |
|
| 547 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->getApplication()->getParameters()->itemAt('$literal')")); |
|
| 548 | 548 | else if($str[2]==='~') |
| 549 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')")); |
|
| 549 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->publishFilePath('$this->_contextPath/$literal')")); |
|
| 550 | 550 | else if($str[2]==='/') |
| 551 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'")); |
|
| 551 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'")); |
|
| 552 | 552 | else if($str[2]==='[') |
| 553 | 553 | { |
| 554 | - $literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\")); |
|
| 555 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')")); |
|
| 554 | + $literal=strtr(trim(substr($literal, 0, strlen($literal) - 1)), array("'"=>"\'", "\\"=>"\\\\")); |
|
| 555 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "Prado::localize('$literal')")); |
|
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | - else if(strpos($str,'<prop:')===0) // opening property |
|
| 558 | + else if(strpos($str, '<prop:')===0) // opening property |
|
| 559 | 559 | { |
| 560 | - if(strrpos($str,'/>')===strlen($str)-2) //subproperties |
|
| 560 | + if(strrpos($str, '/>')===strlen($str) - 2) //subproperties |
|
| 561 | 561 | { |
| 562 | 562 | if($expectPropEnd) |
| 563 | 563 | continue; |
| 564 | - if($matchStart>$textStart) |
|
| 565 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 566 | - $textStart=$matchEnd+1; |
|
| 564 | + if($matchStart > $textStart) |
|
| 565 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 566 | + $textStart=$matchEnd + 1; |
|
| 567 | 567 | $prop=strtolower($match[6][0]); |
| 568 | - $attrs=$this->parseAttributes($match[7][0],$match[7][1]); |
|
| 568 | + $attrs=$this->parseAttributes($match[7][0], $match[7][1]); |
|
| 569 | 569 | $attributes=array(); |
| 570 | 570 | foreach($attrs as $name=>$value) |
| 571 | 571 | $attributes[$prop.'.'.$name]=$value; |
| 572 | 572 | $type=$tpl[$container][1]; |
| 573 | - $this->validateAttributes($type,$attributes); |
|
| 573 | + $this->validateAttributes($type, $attributes); |
|
| 574 | 574 | foreach($attributes as $name=>$value) |
| 575 | 575 | { |
| 576 | 576 | if(isset($tpl[$container][2][$name])) |
| 577 | - throw new TConfigurationException('template_property_duplicated',$name); |
|
| 577 | + throw new TConfigurationException('template_property_duplicated', $name); |
|
| 578 | 578 | $tpl[$container][2][$name]=$value; |
| 579 | 579 | } |
| 580 | 580 | } |
| 581 | 581 | else // regular property |
| 582 | 582 | { |
| 583 | 583 | $prop=strtolower($match[3][0]); |
| 584 | - $stack[] = '@'.$prop; |
|
| 584 | + $stack[]='@'.$prop; |
|
| 585 | 585 | if(!$expectPropEnd) |
| 586 | 586 | { |
| 587 | - if($matchStart>$textStart) |
|
| 588 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 589 | - $textStart=$matchEnd+1; |
|
| 587 | + if($matchStart > $textStart) |
|
| 588 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 589 | + $textStart=$matchEnd + 1; |
|
| 590 | 590 | $expectPropEnd=true; |
| 591 | 591 | } |
| 592 | 592 | } |
| 593 | 593 | } |
| 594 | - else if(strpos($str,'</prop:')===0) // closing property |
|
| 594 | + else if(strpos($str, '</prop:')===0) // closing property |
|
| 595 | 595 | { |
| 596 | 596 | $prop=strtolower($match[3][0]); |
| 597 | 597 | if(empty($stack)) |
| 598 | - throw new TConfigurationException('template_closingtag_unexpected',"</prop:$prop>"); |
|
| 598 | + throw new TConfigurationException('template_closingtag_unexpected', "</prop:$prop>"); |
|
| 599 | 599 | $name=array_pop($stack); |
| 600 | 600 | if($name!=='@'.$prop) |
| 601 | 601 | { |
| 602 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
| 603 | - throw new TConfigurationException('template_closingtag_expected',$tag,"</prop:$prop>"); |
|
| 602 | + $tag=$name[0]==='@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>"; |
|
| 603 | + throw new TConfigurationException('template_closingtag_expected', $tag, "</prop:$prop>"); |
|
| 604 | 604 | } |
| 605 | - if(($last=count($stack))<1 || $stack[$last-1][0]!=='@') |
|
| 605 | + if(($last=count($stack)) < 1 || $stack[$last - 1][0]!=='@') |
|
| 606 | 606 | { |
| 607 | - if($matchStart>$textStart) |
|
| 607 | + if($matchStart > $textStart) |
|
| 608 | 608 | { |
| 609 | - $value=substr($input,$textStart,$matchStart-$textStart); |
|
| 610 | - if(substr($prop,-8,8)==='template') |
|
| 611 | - $value=$this->parseTemplateProperty($value,$textStart); |
|
| 609 | + $value=substr($input, $textStart, $matchStart - $textStart); |
|
| 610 | + if(substr($prop, -8, 8)==='template') |
|
| 611 | + $value=$this->parseTemplateProperty($value, $textStart); |
|
| 612 | 612 | else |
| 613 | 613 | $value=$this->parseAttribute($value); |
| 614 | - if($container>=0) |
|
| 614 | + if($container >= 0) |
|
| 615 | 615 | { |
| 616 | 616 | $type=$tpl[$container][1]; |
| 617 | - $this->validateAttributes($type,array($prop=>$value)); |
|
| 617 | + $this->validateAttributes($type, array($prop=>$value)); |
|
| 618 | 618 | if(isset($tpl[$container][2][$prop])) |
| 619 | - throw new TConfigurationException('template_property_duplicated',$prop); |
|
| 619 | + throw new TConfigurationException('template_property_duplicated', $prop); |
|
| 620 | 620 | $tpl[$container][2][$prop]=$value; |
| 621 | 621 | } |
| 622 | 622 | else // a property for the template control |
| 623 | 623 | $this->_directive[$prop]=$value; |
| 624 | - $textStart=$matchEnd+1; |
|
| 624 | + $textStart=$matchEnd + 1; |
|
| 625 | 625 | } |
| 626 | 626 | $expectPropEnd=false; |
| 627 | 627 | } |
| 628 | 628 | } |
| 629 | - else if(strpos($str,'<!--')===0) // comments |
|
| 629 | + else if(strpos($str, '<!--')===0) // comments |
|
| 630 | 630 | { |
| 631 | 631 | if($expectPropEnd) |
| 632 | 632 | throw new TConfigurationException('template_comments_forbidden'); |
| 633 | - if($matchStart>$textStart) |
|
| 634 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 635 | - $textStart=$matchEnd+1; |
|
| 633 | + if($matchStart > $textStart) |
|
| 634 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 635 | + $textStart=$matchEnd + 1; |
|
| 636 | 636 | } |
| 637 | 637 | else |
| 638 | - throw new TConfigurationException('template_matching_unexpected',$match); |
|
| 638 | + throw new TConfigurationException('template_matching_unexpected', $match); |
|
| 639 | 639 | } |
| 640 | 640 | if(!empty($stack)) |
| 641 | 641 | { |
| 642 | 642 | $name=array_pop($stack); |
| 643 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
| 644 | - throw new TConfigurationException('template_closingtag_expected',$tag, "nothing"); |
|
| 643 | + $tag=$name[0]==='@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>"; |
|
| 644 | + throw new TConfigurationException('template_closingtag_expected', $tag, "nothing"); |
|
| 645 | 645 | } |
| 646 | - if($textStart<strlen($input)) |
|
| 647 | - $tpl[$c++]=array($container,substr($input,$textStart)); |
|
| 646 | + if($textStart < strlen($input)) |
|
| 647 | + $tpl[$c++]=array($container, substr($input, $textStart)); |
|
| 648 | 648 | } |
| 649 | 649 | catch(\Exception $e) |
| 650 | 650 | { |
| 651 | 651 | if(($e instanceof TException) && ($e instanceof TTemplateException)) |
| 652 | 652 | throw $e; |
| 653 | 653 | if($matchEnd===0) |
| 654 | - $line=$this->_startingLine+1; |
|
| 654 | + $line=$this->_startingLine + 1; |
|
| 655 | 655 | else |
| 656 | - $line=$this->_startingLine+count(explode("\n",substr($input,0,$matchEnd+1))); |
|
| 657 | - $this->handleException($e,$line,$input); |
|
| 656 | + $line=$this->_startingLine + count(explode("\n", substr($input, 0, $matchEnd + 1))); |
|
| 657 | + $this->handleException($e, $line, $input); |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | if($this->_directive===null) |
@@ -671,9 +671,9 @@ discard block |
||
| 671 | 671 | if($parent!==null) |
| 672 | 672 | { |
| 673 | 673 | if(count($merged[1])===1 && is_string($merged[1][0])) |
| 674 | - $objects[$id-1]=array($merged[0],$merged[1][0]); |
|
| 674 | + $objects[$id - 1]=array($merged[0], $merged[1][0]); |
|
| 675 | 675 | else |
| 676 | - $objects[$id-1]=array($merged[0],new TCompositeLiteral($merged[1])); |
|
| 676 | + $objects[$id - 1]=array($merged[0], new TCompositeLiteral($merged[1])); |
|
| 677 | 677 | } |
| 678 | 678 | if(isset($object[2])) |
| 679 | 679 | { |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | else |
| 684 | 684 | { |
| 685 | 685 | $parent=$object[0]; |
| 686 | - $merged=array($parent,array($object[1])); |
|
| 686 | + $merged=array($parent, array($object[1])); |
|
| 687 | 687 | } |
| 688 | 688 | } |
| 689 | 689 | else |
@@ -692,9 +692,9 @@ discard block |
||
| 692 | 692 | if($parent!==null) |
| 693 | 693 | { |
| 694 | 694 | if(count($merged[1])===1 && is_string($merged[1][0])) |
| 695 | - $objects[$id]=array($merged[0],$merged[1][0]); |
|
| 695 | + $objects[$id]=array($merged[0], $merged[1][0]); |
|
| 696 | 696 | else |
| 697 | - $objects[$id]=array($merged[0],new TCompositeLiteral($merged[1])); |
|
| 697 | + $objects[$id]=array($merged[0], new TCompositeLiteral($merged[1])); |
|
| 698 | 698 | } |
| 699 | 699 | $tpl=$objects; |
| 700 | 700 | return $objects; |
@@ -705,31 +705,31 @@ discard block |
||
| 705 | 705 | * @param string the string to be parsed. |
| 706 | 706 | * @return array attribute values indexed by names. |
| 707 | 707 | */ |
| 708 | - protected function parseAttributes($str,$offset) |
|
| 708 | + protected function parseAttributes($str, $offset) |
|
| 709 | 709 | { |
| 710 | 710 | if($str==='') |
| 711 | 711 | return array(); |
| 712 | 712 | $pattern='/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS'; |
| 713 | 713 | $attributes=array(); |
| 714 | - $n=preg_match_all($pattern,$str,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE); |
|
| 715 | - for($i=0;$i<$n;++$i) |
|
| 714 | + $n=preg_match_all($pattern, $str, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); |
|
| 715 | + for($i=0; $i < $n; ++$i) |
|
| 716 | 716 | { |
| 717 | 717 | $match=&$matches[$i]; |
| 718 | 718 | $name=strtolower($match[1][0]); |
| 719 | 719 | if(isset($attributes[$name])) |
| 720 | - throw new TConfigurationException('template_property_duplicated',$name); |
|
| 720 | + throw new TConfigurationException('template_property_duplicated', $name); |
|
| 721 | 721 | $value=$match[2][0]; |
| 722 | - if(substr($name,-8,8)==='template') |
|
| 722 | + if(substr($name, -8, 8)==='template') |
|
| 723 | 723 | { |
| 724 | 724 | if($value[0]==='\'' || $value[0]==='"') |
| 725 | - $attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1); |
|
| 725 | + $attributes[$name]=$this->parseTemplateProperty(substr($value, 1, strlen($value) - 2), $match[2][1] + 1); |
|
| 726 | 726 | else |
| 727 | - $attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]); |
|
| 727 | + $attributes[$name]=$this->parseTemplateProperty($value, $match[2][1]); |
|
| 728 | 728 | } |
| 729 | 729 | else |
| 730 | 730 | { |
| 731 | 731 | if($value[0]==='\'' || $value[0]==='"') |
| 732 | - $attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2)); |
|
| 732 | + $attributes[$name]=$this->parseAttribute(substr($value, 1, strlen($value) - 2)); |
|
| 733 | 733 | else |
| 734 | 734 | $attributes[$name]=$this->parseAttribute($value); |
| 735 | 735 | } |
@@ -737,10 +737,10 @@ discard block |
||
| 737 | 737 | return $attributes; |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | - protected function parseTemplateProperty($content,$offset) |
|
| 740 | + protected function parseTemplateProperty($content, $offset) |
|
| 741 | 741 | { |
| 742 | - $line=$this->_startingLine+count(explode("\n",substr($this->_content,0,$offset)))-1; |
|
| 743 | - return array(self::CONFIG_TEMPLATE,new TTemplate($content,$this->_contextPath,$this->_tplFile,$line,false)); |
|
| 742 | + $line=$this->_startingLine + count(explode("\n", substr($this->_content, 0, $offset))) - 1; |
|
| 743 | + return array(self::CONFIG_TEMPLATE, new TTemplate($content, $this->_contextPath, $this->_tplFile, $line, false)); |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | /** |
@@ -750,12 +750,12 @@ discard block |
||
| 750 | 750 | */ |
| 751 | 751 | protected function parseAttribute($value) |
| 752 | 752 | { |
| 753 | - if(($n=preg_match_all('/<%[#=].*?%>/msS',$value,$matches,PREG_OFFSET_CAPTURE))>0) |
|
| 753 | + if(($n=preg_match_all('/<%[#=].*?%>/msS', $value, $matches, PREG_OFFSET_CAPTURE)) > 0) |
|
| 754 | 754 | { |
| 755 | 755 | $isDataBind=false; |
| 756 | 756 | $textStart=0; |
| 757 | 757 | $expr=''; |
| 758 | - for($i=0;$i<$n;++$i) |
|
| 758 | + for($i=0; $i < $n; ++$i) |
|
| 759 | 759 | { |
| 760 | 760 | $match=$matches[0][$i]; |
| 761 | 761 | $token=$match[0]; |
@@ -763,114 +763,114 @@ discard block |
||
| 763 | 763 | $length=strlen($token); |
| 764 | 764 | if($token[2]==='#') |
| 765 | 765 | $isDataBind=true; |
| 766 | - if($offset>$textStart) |
|
| 767 | - $expr.=".'".strtr(substr($value,$textStart,$offset-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'"; |
|
| 768 | - $expr.='.('.substr($token,3,$length-5).')'; |
|
| 769 | - $textStart=$offset+$length; |
|
| 766 | + if($offset > $textStart) |
|
| 767 | + $expr.=".'".strtr(substr($value, $textStart, $offset - $textStart), array("'"=>"\\'", "\\"=>"\\\\"))."'"; |
|
| 768 | + $expr.='.('.substr($token, 3, $length - 5).')'; |
|
| 769 | + $textStart=$offset + $length; |
|
| 770 | 770 | } |
| 771 | 771 | $length=strlen($value); |
| 772 | - if($length>$textStart) |
|
| 773 | - $expr.=".'".strtr(substr($value,$textStart,$length-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'"; |
|
| 772 | + if($length > $textStart) |
|
| 773 | + $expr.=".'".strtr(substr($value, $textStart, $length - $textStart), array("'"=>"\\'", "\\"=>"\\\\"))."'"; |
|
| 774 | 774 | if($isDataBind) |
| 775 | - return array(self::CONFIG_DATABIND,ltrim($expr,'.')); |
|
| 775 | + return array(self::CONFIG_DATABIND, ltrim($expr, '.')); |
|
| 776 | 776 | else |
| 777 | - return array(self::CONFIG_EXPRESSION,ltrim($expr,'.')); |
|
| 777 | + return array(self::CONFIG_EXPRESSION, ltrim($expr, '.')); |
|
| 778 | 778 | } |
| 779 | - else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value) |
|
| 779 | + else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0]===$value) |
|
| 780 | 780 | { |
| 781 | 781 | $value=$matches[1]; |
| 782 | 782 | if($value[2]==='~') |
| 783 | - return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5))); |
|
| 783 | + return array(self::CONFIG_ASSET, trim(substr($value, 3, strlen($value) - 5))); |
|
| 784 | 784 | elseif($value[2]==='[') |
| 785 | - return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6))); |
|
| 785 | + return array(self::CONFIG_LOCALIZATION, trim(substr($value, 3, strlen($value) - 6))); |
|
| 786 | 786 | elseif($value[2]==='$') |
| 787 | - return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5))); |
|
| 787 | + return array(self::CONFIG_PARAMETER, trim(substr($value, 3, strlen($value) - 5))); |
|
| 788 | 788 | elseif($value[2]==='/') { |
| 789 | - $literal = trim(substr($value,3,strlen($value)-5)); |
|
| 790 | - return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"); |
|
| 789 | + $literal=trim(substr($value, 3, strlen($value) - 5)); |
|
| 790 | + return array(self::CONFIG_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"); |
|
| 791 | 791 | } |
| 792 | 792 | } |
| 793 | 793 | else |
| 794 | 794 | return $value; |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | - protected function validateAttributes($type,$attributes) |
|
| 797 | + protected function validateAttributes($type, $attributes) |
|
| 798 | 798 | { |
| 799 | 799 | Prado::using($type); |
| 800 | - if(($pos=strrpos($type,'.'))!==false) |
|
| 801 | - $className=substr($type,$pos+1); |
|
| 800 | + if(($pos=strrpos($type, '.'))!==false) |
|
| 801 | + $className=substr($type, $pos + 1); |
|
| 802 | 802 | else |
| 803 | 803 | $className=$type; |
| 804 | 804 | $class=new \ReflectionClass($className); |
| 805 | - if(is_subclass_of($className,'\Prado\Web\UI\TControl') || $className==='\Prado\Web\UI\TControl') |
|
| 805 | + if(is_subclass_of($className, '\Prado\Web\UI\TControl') || $className==='\Prado\Web\UI\TControl') |
|
| 806 | 806 | { |
| 807 | 807 | foreach($attributes as $name=>$att) |
| 808 | 808 | { |
| 809 | - if(($pos=strpos($name,'.'))!==false) |
|
| 809 | + if(($pos=strpos($name, '.'))!==false) |
|
| 810 | 810 | { |
| 811 | 811 | // a subproperty, so the first segment must be readable |
| 812 | - $subname=substr($name,0,$pos); |
|
| 812 | + $subname=substr($name, 0, $pos); |
|
| 813 | 813 | if(!$class->hasMethod('get'.$subname)) |
| 814 | - throw new TConfigurationException('template_property_unknown',$type,$subname); |
|
| 814 | + throw new TConfigurationException('template_property_unknown', $type, $subname); |
|
| 815 | 815 | } |
| 816 | - else if(strncasecmp($name,'on',2)===0) |
|
| 816 | + else if(strncasecmp($name, 'on', 2)===0) |
|
| 817 | 817 | { |
| 818 | 818 | // an event |
| 819 | 819 | if(!$class->hasMethod($name)) |
| 820 | - throw new TConfigurationException('template_event_unknown',$type,$name); |
|
| 820 | + throw new TConfigurationException('template_event_unknown', $type, $name); |
|
| 821 | 821 | else if(!is_string($att)) |
| 822 | - throw new TConfigurationException('template_eventhandler_invalid',$type,$name); |
|
| 822 | + throw new TConfigurationException('template_eventhandler_invalid', $type, $name); |
|
| 823 | 823 | } |
| 824 | 824 | else |
| 825 | 825 | { |
| 826 | 826 | // a simple property |
| 827 | - if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)) ) |
|
| 827 | + if(!($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class, 'set'.$name))) |
|
| 828 | 828 | { |
| 829 | - if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name)) |
|
| 830 | - throw new TConfigurationException('template_property_readonly',$type,$name); |
|
| 829 | + if($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name)) |
|
| 830 | + throw new TConfigurationException('template_property_readonly', $type, $name); |
|
| 831 | 831 | else |
| 832 | - throw new TConfigurationException('template_property_unknown',$type,$name); |
|
| 832 | + throw new TConfigurationException('template_property_unknown', $type, $name); |
|
| 833 | 833 | } |
| 834 | 834 | else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION) |
| 835 | 835 | { |
| 836 | - if(strcasecmp($name,'id')===0) |
|
| 837 | - throw new TConfigurationException('template_controlid_invalid',$type); |
|
| 838 | - else if(strcasecmp($name,'skinid')===0) |
|
| 839 | - throw new TConfigurationException('template_controlskinid_invalid',$type); |
|
| 836 | + if(strcasecmp($name, 'id')===0) |
|
| 837 | + throw new TConfigurationException('template_controlid_invalid', $type); |
|
| 838 | + else if(strcasecmp($name, 'skinid')===0) |
|
| 839 | + throw new TConfigurationException('template_controlskinid_invalid', $type); |
|
| 840 | 840 | } |
| 841 | 841 | } |
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | - else if(is_subclass_of($className,'\Prado\TComponent') || $className==='\Prado\TComponent') |
|
| 844 | + else if(is_subclass_of($className, '\Prado\TComponent') || $className==='\Prado\TComponent') |
|
| 845 | 845 | { |
| 846 | 846 | foreach($attributes as $name=>$att) |
| 847 | 847 | { |
| 848 | 848 | if(is_array($att) && ($att[0]===self::CONFIG_DATABIND)) |
| 849 | - throw new TConfigurationException('template_databind_forbidden',$type,$name); |
|
| 850 | - if(($pos=strpos($name,'.'))!==false) |
|
| 849 | + throw new TConfigurationException('template_databind_forbidden', $type, $name); |
|
| 850 | + if(($pos=strpos($name, '.'))!==false) |
|
| 851 | 851 | { |
| 852 | 852 | // a subproperty, so the first segment must be readable |
| 853 | - $subname=substr($name,0,$pos); |
|
| 853 | + $subname=substr($name, 0, $pos); |
|
| 854 | 854 | if(!$class->hasMethod('get'.$subname)) |
| 855 | - throw new TConfigurationException('template_property_unknown',$type,$subname); |
|
| 855 | + throw new TConfigurationException('template_property_unknown', $type, $subname); |
|
| 856 | 856 | } |
| 857 | - else if(strncasecmp($name,'on',2)===0) |
|
| 858 | - throw new TConfigurationException('template_event_forbidden',$type,$name); |
|
| 857 | + else if(strncasecmp($name, 'on', 2)===0) |
|
| 858 | + throw new TConfigurationException('template_event_forbidden', $type, $name); |
|
| 859 | 859 | else |
| 860 | 860 | { |
| 861 | 861 | // id is still alowed for TComponent, even if id property doesn't exist |
| 862 | - if(strcasecmp($name,'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class,'set'.$name))) |
|
| 862 | + if(strcasecmp($name, 'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class, 'set'.$name))) |
|
| 863 | 863 | { |
| 864 | 864 | if($class->hasMethod('get'.$name)) |
| 865 | - throw new TConfigurationException('template_property_readonly',$type,$name); |
|
| 865 | + throw new TConfigurationException('template_property_readonly', $type, $name); |
|
| 866 | 866 | else |
| 867 | - throw new TConfigurationException('template_property_unknown',$type,$name); |
|
| 867 | + throw new TConfigurationException('template_property_unknown', $type, $name); |
|
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | } |
| 871 | 871 | } |
| 872 | 872 | else |
| 873 | - throw new TConfigurationException('template_component_required',$type); |
|
| 873 | + throw new TConfigurationException('template_component_required', $type); |
|
| 874 | 874 | return $class->getName(); |
| 875 | 875 | } |
| 876 | 876 | |
@@ -890,28 +890,28 @@ discard block |
||
| 890 | 890 | * @param int line number |
| 891 | 891 | * @param string template string if no source file is used |
| 892 | 892 | */ |
| 893 | - protected function handleException($e,$line,$input=null) |
|
| 893 | + protected function handleException($e, $line, $input=null) |
|
| 894 | 894 | { |
| 895 | 895 | $srcFile=$this->_tplFile; |
| 896 | 896 | |
| 897 | - if(($n=count($this->_includedFiles))>0) // need to adjust error row number and file name |
|
| 897 | + if(($n=count($this->_includedFiles)) > 0) // need to adjust error row number and file name |
|
| 898 | 898 | { |
| 899 | - for($i=$n-1;$i>=0;--$i) |
|
| 899 | + for($i=$n - 1; $i >= 0; --$i) |
|
| 900 | 900 | { |
| 901 | - if($this->_includeAtLine[$i]<=$line) |
|
| 901 | + if($this->_includeAtLine[$i] <= $line) |
|
| 902 | 902 | { |
| 903 | - if($line<$this->_includeAtLine[$i]+$this->_includeLines[$i]) |
|
| 903 | + if($line < $this->_includeAtLine[$i] + $this->_includeLines[$i]) |
|
| 904 | 904 | { |
| 905 | - $line=$line-$this->_includeAtLine[$i]+1; |
|
| 905 | + $line=$line - $this->_includeAtLine[$i] + 1; |
|
| 906 | 906 | $srcFile=$this->_includedFiles[$i]; |
| 907 | 907 | break; |
| 908 | 908 | } |
| 909 | 909 | else |
| 910 | - $line=$line-$this->_includeLines[$i]+1; |
|
| 910 | + $line=$line - $this->_includeLines[$i] + 1; |
|
| 911 | 911 | } |
| 912 | 912 | } |
| 913 | 913 | } |
| 914 | - $exception=new TTemplateException('template_format_invalid',$e->getMessage()); |
|
| 914 | + $exception=new TTemplateException('template_format_invalid', $e->getMessage()); |
|
| 915 | 915 | $exception->setLineNumber($line); |
| 916 | 916 | if(!empty($srcFile)) |
| 917 | 917 | $exception->setTemplateFile($srcFile); |
@@ -927,29 +927,29 @@ discard block |
||
| 927 | 927 | */ |
| 928 | 928 | protected function preprocess($input) |
| 929 | 929 | { |
| 930 | - if($n=preg_match_all('/<%include(.*?)%>/',$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE)) |
|
| 930 | + if($n=preg_match_all('/<%include(.*?)%>/', $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) |
|
| 931 | 931 | { |
| 932 | - for($i=0;$i<$n;++$i) |
|
| 932 | + for($i=0; $i < $n; ++$i) |
|
| 933 | 933 | { |
| 934 | - $filePath=Prado::getPathOfNamespace(trim($matches[$i][1][0]),TTemplateManager::TEMPLATE_FILE_EXT); |
|
| 934 | + $filePath=Prado::getPathOfNamespace(trim($matches[$i][1][0]), TTemplateManager::TEMPLATE_FILE_EXT); |
|
| 935 | 935 | if($filePath!==null && is_file($filePath)) |
| 936 | 936 | $this->_includedFiles[]=$filePath; |
| 937 | 937 | else |
| 938 | 938 | { |
| 939 | - $errorLine=count(explode("\n",substr($input,0,$matches[$i][0][1]+1))); |
|
| 940 | - $this->handleException(new TConfigurationException('template_include_invalid',trim($matches[$i][1][0])),$errorLine,$input); |
|
| 939 | + $errorLine=count(explode("\n", substr($input, 0, $matches[$i][0][1] + 1))); |
|
| 940 | + $this->handleException(new TConfigurationException('template_include_invalid', trim($matches[$i][1][0])), $errorLine, $input); |
|
| 941 | 941 | } |
| 942 | 942 | } |
| 943 | 943 | $base=0; |
| 944 | - for($i=0;$i<$n;++$i) |
|
| 944 | + for($i=0; $i < $n; ++$i) |
|
| 945 | 945 | { |
| 946 | 946 | $ext=file_get_contents($this->_includedFiles[$i]); |
| 947 | 947 | $length=strlen($matches[$i][0][0]); |
| 948 | - $offset=$base+$matches[$i][0][1]; |
|
| 949 | - $this->_includeAtLine[$i]=count(explode("\n",substr($input,0,$offset))); |
|
| 950 | - $this->_includeLines[$i]=count(explode("\n",$ext)); |
|
| 951 | - $input=substr_replace($input,$ext,$offset,$length); |
|
| 952 | - $base+=strlen($ext)-$length; |
|
| 948 | + $offset=$base + $matches[$i][0][1]; |
|
| 949 | + $this->_includeAtLine[$i]=count(explode("\n", substr($input, 0, $offset))); |
|
| 950 | + $this->_includeLines[$i]=count(explode("\n", $ext)); |
|
| 951 | + $input=substr_replace($input, $ext, $offset, $length); |
|
| 952 | + $base+=strlen($ext) - $length; |
|
| 953 | 953 | } |
| 954 | 954 | } |
| 955 | 955 | |
@@ -962,7 +962,7 @@ discard block |
||
| 962 | 962 | * @param string $method |
| 963 | 963 | * @return boolean |
| 964 | 964 | */ |
| 965 | - protected function isClassBehaviorMethod(\ReflectionClass $class,$method) |
|
| 965 | + protected function isClassBehaviorMethod(\ReflectionClass $class, $method) |
|
| 966 | 966 | { |
| 967 | 967 | $component=new \ReflectionClass('\Prado\TComponent'); |
| 968 | 968 | $behaviors=$component->getStaticProperties(); |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue; |
| 974 | 974 | foreach($list as $param) |
| 975 | 975 | { |
| 976 | - if(method_exists($param->getBehavior(),$method)) |
|
| 976 | + if(method_exists($param->getBehavior(), $method)) |
|
| 977 | 977 | return true; |
| 978 | 978 | } |
| 979 | 979 | } |
@@ -243,8 +243,7 @@ discard block |
||
| 243 | 243 | $component->createdOnTemplate($parent); |
| 244 | 244 | if($component->getAllowChildControls()) |
| 245 | 245 | $controls[$key]=$component; |
| 246 | - } |
|
| 247 | - else if($component instanceof TComponent) |
|
| 246 | + } else if($component instanceof TComponent) |
|
| 248 | 247 | { |
| 249 | 248 | $controls[$key]=$component; |
| 250 | 249 | if(isset($properties['id'])) |
@@ -262,8 +261,7 @@ discard block |
||
| 262 | 261 | else |
| 263 | 262 | $component->createdOnTemplate($parent); |
| 264 | 263 | } |
| 265 | - } |
|
| 266 | - else |
|
| 264 | + } else |
|
| 267 | 265 | { |
| 268 | 266 | if($object[1] instanceof TCompositeLiteral) |
| 269 | 267 | { |
@@ -274,8 +272,7 @@ discard block |
||
| 274 | 272 | $directChildren[]=$o; |
| 275 | 273 | else |
| 276 | 274 | $parent->addParsedObject($o); |
| 277 | - } |
|
| 278 | - else |
|
| 275 | + } else |
|
| 279 | 276 | { |
| 280 | 277 | if($parent===$parentControl) |
| 281 | 278 | $directChildren[]=$object[1]; |
@@ -386,8 +383,7 @@ discard block |
||
| 386 | 383 | throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
| 387 | 384 | break; |
| 388 | 385 | } |
| 389 | - } |
|
| 390 | - else |
|
| 386 | + } else |
|
| 391 | 387 | { |
| 392 | 388 | if (substr($name,0,2)=='js') |
| 393 | 389 | if ($value and !($value instanceof TJavaScriptLiteral)) |
@@ -435,8 +431,7 @@ discard block |
||
| 435 | 431 | throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
| 436 | 432 | break; |
| 437 | 433 | } |
| 438 | - } |
|
| 439 | - else |
|
| 434 | + } else |
|
| 440 | 435 | $component->setSubProperty($name,$value); |
| 441 | 436 | } |
| 442 | 437 | |
@@ -497,8 +492,7 @@ discard block |
||
| 497 | 492 | $stack[] = $type; |
| 498 | 493 | $container=$c-1; |
| 499 | 494 | } |
| 500 | - } |
|
| 501 | - else if(strpos($str,'</com:')===0) // closing component tag |
|
| 495 | + } else if(strpos($str,'</com:')===0) // closing component tag |
|
| 502 | 496 | { |
| 503 | 497 | if($expectPropEnd) |
| 504 | 498 | continue; |
@@ -517,8 +511,7 @@ discard block |
||
| 517 | 511 | throw new TConfigurationException('template_closingtag_expected',$tag, "</com:$type>"); |
| 518 | 512 | } |
| 519 | 513 | $container=$tpl[$container][0]; |
| 520 | - } |
|
| 521 | - else if(strpos($str,'<%@')===0) // directive |
|
| 514 | + } else if(strpos($str,'<%@')===0) // directive |
|
| 522 | 515 | { |
| 523 | 516 | if($expectPropEnd) |
| 524 | 517 | continue; |
@@ -528,8 +521,7 @@ discard block |
||
| 528 | 521 | if(isset($tpl[0]) || $this->_directive!==null) |
| 529 | 522 | throw new TConfigurationException('template_directive_nonunique'); |
| 530 | 523 | $this->_directive=$this->parseAttributes($match[4][0],$match[4][1]); |
| 531 | - } |
|
| 532 | - else if(strpos($str,'<%')===0) // expression |
|
| 524 | + } else if(strpos($str,'<%')===0) // expression |
|
| 533 | 525 | { |
| 534 | 526 | if($expectPropEnd) |
| 535 | 527 | continue; |
@@ -554,8 +546,7 @@ discard block |
||
| 554 | 546 | $literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\")); |
| 555 | 547 | $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')")); |
| 556 | 548 | } |
| 557 | - } |
|
| 558 | - else if(strpos($str,'<prop:')===0) // opening property |
|
| 549 | + } else if(strpos($str,'<prop:')===0) // opening property |
|
| 559 | 550 | { |
| 560 | 551 | if(strrpos($str,'/>')===strlen($str)-2) //subproperties |
| 561 | 552 | { |
@@ -577,8 +568,7 @@ discard block |
||
| 577 | 568 | throw new TConfigurationException('template_property_duplicated',$name); |
| 578 | 569 | $tpl[$container][2][$name]=$value; |
| 579 | 570 | } |
| 580 | - } |
|
| 581 | - else // regular property |
|
| 571 | + } else // regular property |
|
| 582 | 572 | { |
| 583 | 573 | $prop=strtolower($match[3][0]); |
| 584 | 574 | $stack[] = '@'.$prop; |
@@ -590,8 +580,7 @@ discard block |
||
| 590 | 580 | $expectPropEnd=true; |
| 591 | 581 | } |
| 592 | 582 | } |
| 593 | - } |
|
| 594 | - else if(strpos($str,'</prop:')===0) // closing property |
|
| 583 | + } else if(strpos($str,'</prop:')===0) // closing property |
|
| 595 | 584 | { |
| 596 | 585 | $prop=strtolower($match[3][0]); |
| 597 | 586 | if(empty($stack)) |
@@ -618,23 +607,20 @@ discard block |
||
| 618 | 607 | if(isset($tpl[$container][2][$prop])) |
| 619 | 608 | throw new TConfigurationException('template_property_duplicated',$prop); |
| 620 | 609 | $tpl[$container][2][$prop]=$value; |
| 621 | - } |
|
| 622 | - else // a property for the template control |
|
| 610 | + } else // a property for the template control |
|
| 623 | 611 | $this->_directive[$prop]=$value; |
| 624 | 612 | $textStart=$matchEnd+1; |
| 625 | 613 | } |
| 626 | 614 | $expectPropEnd=false; |
| 627 | 615 | } |
| 628 | - } |
|
| 629 | - else if(strpos($str,'<!--')===0) // comments |
|
| 616 | + } else if(strpos($str,'<!--')===0) // comments |
|
| 630 | 617 | { |
| 631 | 618 | if($expectPropEnd) |
| 632 | 619 | throw new TConfigurationException('template_comments_forbidden'); |
| 633 | 620 | if($matchStart>$textStart) |
| 634 | 621 | $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
| 635 | 622 | $textStart=$matchEnd+1; |
| 636 | - } |
|
| 637 | - else |
|
| 623 | + } else |
|
| 638 | 624 | throw new TConfigurationException('template_matching_unexpected',$match); |
| 639 | 625 | } |
| 640 | 626 | if(!empty($stack)) |
@@ -645,8 +631,7 @@ discard block |
||
| 645 | 631 | } |
| 646 | 632 | if($textStart<strlen($input)) |
| 647 | 633 | $tpl[$c++]=array($container,substr($input,$textStart)); |
| 648 | - } |
|
| 649 | - catch(\Exception $e) |
|
| 634 | + } catch(\Exception $e) |
|
| 650 | 635 | { |
| 651 | 636 | if(($e instanceof TException) && ($e instanceof TTemplateException)) |
| 652 | 637 | throw $e; |
@@ -679,14 +664,12 @@ discard block |
||
| 679 | 664 | { |
| 680 | 665 | $parent=null; |
| 681 | 666 | $objects[$id]=$object; |
| 682 | - } |
|
| 683 | - else |
|
| 667 | + } else |
|
| 684 | 668 | { |
| 685 | 669 | $parent=$object[0]; |
| 686 | 670 | $merged=array($parent,array($object[1])); |
| 687 | 671 | } |
| 688 | - } |
|
| 689 | - else |
|
| 672 | + } else |
|
| 690 | 673 | $merged[1][]=$object[1]; |
| 691 | 674 | } |
| 692 | 675 | if($parent!==null) |
@@ -725,8 +708,7 @@ discard block |
||
| 725 | 708 | $attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1); |
| 726 | 709 | else |
| 727 | 710 | $attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]); |
| 728 | - } |
|
| 729 | - else |
|
| 711 | + } else |
|
| 730 | 712 | { |
| 731 | 713 | if($value[0]==='\'' || $value[0]==='"') |
| 732 | 714 | $attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2)); |
@@ -775,8 +757,7 @@ discard block |
||
| 775 | 757 | return array(self::CONFIG_DATABIND,ltrim($expr,'.')); |
| 776 | 758 | else |
| 777 | 759 | return array(self::CONFIG_EXPRESSION,ltrim($expr,'.')); |
| 778 | - } |
|
| 779 | - else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value) |
|
| 760 | + } else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value) |
|
| 780 | 761 | { |
| 781 | 762 | $value=$matches[1]; |
| 782 | 763 | if($value[2]==='~') |
@@ -789,8 +770,7 @@ discard block |
||
| 789 | 770 | $literal = trim(substr($value,3,strlen($value)-5)); |
| 790 | 771 | return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"); |
| 791 | 772 | } |
| 792 | - } |
|
| 793 | - else |
|
| 773 | + } else |
|
| 794 | 774 | return $value; |
| 795 | 775 | } |
| 796 | 776 | |
@@ -812,16 +792,14 @@ discard block |
||
| 812 | 792 | $subname=substr($name,0,$pos); |
| 813 | 793 | if(!$class->hasMethod('get'.$subname)) |
| 814 | 794 | throw new TConfigurationException('template_property_unknown',$type,$subname); |
| 815 | - } |
|
| 816 | - else if(strncasecmp($name,'on',2)===0) |
|
| 795 | + } else if(strncasecmp($name,'on',2)===0) |
|
| 817 | 796 | { |
| 818 | 797 | // an event |
| 819 | 798 | if(!$class->hasMethod($name)) |
| 820 | 799 | throw new TConfigurationException('template_event_unknown',$type,$name); |
| 821 | 800 | else if(!is_string($att)) |
| 822 | 801 | throw new TConfigurationException('template_eventhandler_invalid',$type,$name); |
| 823 | - } |
|
| 824 | - else |
|
| 802 | + } else |
|
| 825 | 803 | { |
| 826 | 804 | // a simple property |
| 827 | 805 | if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)) ) |
@@ -830,8 +808,7 @@ discard block |
||
| 830 | 808 | throw new TConfigurationException('template_property_readonly',$type,$name); |
| 831 | 809 | else |
| 832 | 810 | throw new TConfigurationException('template_property_unknown',$type,$name); |
| 833 | - } |
|
| 834 | - else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION) |
|
| 811 | + } else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION) |
|
| 835 | 812 | { |
| 836 | 813 | if(strcasecmp($name,'id')===0) |
| 837 | 814 | throw new TConfigurationException('template_controlid_invalid',$type); |
@@ -840,8 +817,7 @@ discard block |
||
| 840 | 817 | } |
| 841 | 818 | } |
| 842 | 819 | } |
| 843 | - } |
|
| 844 | - else if(is_subclass_of($className,'\Prado\TComponent') || $className==='\Prado\TComponent') |
|
| 820 | + } else if(is_subclass_of($className,'\Prado\TComponent') || $className==='\Prado\TComponent') |
|
| 845 | 821 | { |
| 846 | 822 | foreach($attributes as $name=>$att) |
| 847 | 823 | { |
@@ -853,8 +829,7 @@ discard block |
||
| 853 | 829 | $subname=substr($name,0,$pos); |
| 854 | 830 | if(!$class->hasMethod('get'.$subname)) |
| 855 | 831 | throw new TConfigurationException('template_property_unknown',$type,$subname); |
| 856 | - } |
|
| 857 | - else if(strncasecmp($name,'on',2)===0) |
|
| 832 | + } else if(strncasecmp($name,'on',2)===0) |
|
| 858 | 833 | throw new TConfigurationException('template_event_forbidden',$type,$name); |
| 859 | 834 | else |
| 860 | 835 | { |
@@ -868,8 +843,7 @@ discard block |
||
| 868 | 843 | } |
| 869 | 844 | } |
| 870 | 845 | } |
| 871 | - } |
|
| 872 | - else |
|
| 846 | + } else |
|
| 873 | 847 | throw new TConfigurationException('template_component_required',$type); |
| 874 | 848 | return $class->getName(); |
| 875 | 849 | } |
@@ -905,8 +879,7 @@ discard block |
||
| 905 | 879 | $line=$line-$this->_includeAtLine[$i]+1; |
| 906 | 880 | $srcFile=$this->_includedFiles[$i]; |
| 907 | 881 | break; |
| 908 | - } |
|
| 909 | - else |
|
| 882 | + } else |
|
| 910 | 883 | $line=$line-$this->_includeLines[$i]+1; |
| 911 | 884 | } |
| 912 | 885 | } |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * that start with 'fx' are filtered in. |
| 390 | 390 | */ |
| 391 | 391 | private function filter_prado_fx($name) { |
| 392 | - return strncasecmp($name,'fx',2)===0; |
|
| 392 | + return strncasecmp($name, 'fx', 2)===0; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
@@ -399,13 +399,13 @@ discard block |
||
| 399 | 399 | * @param boolean optional should the names be all lowercase true/false |
| 400 | 400 | * @return array array of strings being the class hierarchy of $this. |
| 401 | 401 | */ |
| 402 | - public function getClassHierarchy($lowercase = false) |
|
| 402 | + public function getClassHierarchy($lowercase=false) |
|
| 403 | 403 | { |
| 404 | 404 | $class=get_class($this); |
| 405 | 405 | $classes=array($class); |
| 406 | - while($class=get_parent_class($class)){array_unshift($classes,$class);} |
|
| 406 | + while($class=get_parent_class($class)) {array_unshift($classes, $class); } |
|
| 407 | 407 | if($lowercase) |
| 408 | - return array_map('strtolower',$classes); |
|
| 408 | + return array_map('strtolower', $classes); |
|
| 409 | 409 | return $classes; |
| 410 | 410 | } |
| 411 | 411 | |
@@ -428,14 +428,14 @@ discard block |
||
| 428 | 428 | if($this->_listeningenabled) |
| 429 | 429 | return; |
| 430 | 430 | |
| 431 | - $fx=array_filter(get_class_methods($this),array($this,'filter_prado_fx')); |
|
| 431 | + $fx=array_filter(get_class_methods($this), array($this, 'filter_prado_fx')); |
|
| 432 | 432 | |
| 433 | 433 | foreach($fx as $func) |
| 434 | - $this->attachEventHandler($func,array($this,$func)); |
|
| 434 | + $this->attachEventHandler($func, array($this, $func)); |
|
| 435 | 435 | |
| 436 | - if(is_a($this,'Prado\\Util\\IDynamicMethods')) { |
|
| 437 | - $this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER,array($this,'__dycall')); |
|
| 438 | - array_push($fx,TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
| 436 | + if(is_a($this, 'Prado\\Util\\IDynamicMethods')) { |
|
| 437 | + $this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, array($this, '__dycall')); |
|
| 438 | + array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | $this->_listeningenabled=true; |
@@ -462,14 +462,14 @@ discard block |
||
| 462 | 462 | if(!$this->_listeningenabled) |
| 463 | 463 | return; |
| 464 | 464 | |
| 465 | - $fx=array_filter(get_class_methods($this),array($this,'filter_prado_fx')); |
|
| 465 | + $fx=array_filter(get_class_methods($this), array($this, 'filter_prado_fx')); |
|
| 466 | 466 | |
| 467 | 467 | foreach($fx as $func) |
| 468 | - $this->detachEventHandler($func,array($this,$func)); |
|
| 468 | + $this->detachEventHandler($func, array($this, $func)); |
|
| 469 | 469 | |
| 470 | - if(is_a($this,'Prado\\Util\\IDynamicMethods')) { |
|
| 471 | - $this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER,array($this,'__dycall')); |
|
| 472 | - array_push($fx,TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
| 470 | + if(is_a($this, 'Prado\\Util\\IDynamicMethods')) { |
|
| 471 | + $this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, array($this, '__dycall')); |
|
| 472 | + array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | $this->_listeningenabled=false; |
@@ -514,66 +514,66 @@ discard block |
||
| 514 | 514 | */ |
| 515 | 515 | public function __call($method, $args) |
| 516 | 516 | { |
| 517 | - $getset=substr($method,0,3); |
|
| 518 | - if(($getset=='get')||($getset=='set')) |
|
| 517 | + $getset=substr($method, 0, 3); |
|
| 518 | + if(($getset=='get') || ($getset=='set')) |
|
| 519 | 519 | { |
| 520 | - $propname=substr($method,3); |
|
| 520 | + $propname=substr($method, 3); |
|
| 521 | 521 | $jsmethod=$getset.'js'.$propname; |
| 522 | - if(method_exists($this,$jsmethod)) |
|
| 522 | + if(method_exists($this, $jsmethod)) |
|
| 523 | 523 | { |
| 524 | - if(count($args)>0) |
|
| 525 | - if($args[0]&&!($args[0] instanceof TJavaScriptString)) |
|
| 524 | + if(count($args) > 0) |
|
| 525 | + if($args[0] && !($args[0] instanceof TJavaScriptString)) |
|
| 526 | 526 | $args[0]=new TJavaScriptString($args[0]); |
| 527 | - return call_user_func_array(array($this,$jsmethod),$args); |
|
| 527 | + return call_user_func_array(array($this, $jsmethod), $args); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - if (($getset=='set')&&method_exists($this,'getjs'.$propname)) |
|
| 531 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$method); |
|
| 530 | + if(($getset=='set') && method_exists($this, 'getjs'.$propname)) |
|
| 531 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $method); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - if($this->_m!==null&&$this->_behaviorsenabled) |
|
| 534 | + if($this->_m!==null && $this->_behaviorsenabled) |
|
| 535 | 535 | { |
| 536 | - if(strncasecmp($method,'dy',2)===0) |
|
| 536 | + if(strncasecmp($method, 'dy', 2)===0) |
|
| 537 | 537 | { |
| 538 | 538 | $callchain=new TCallChain($method); |
| 539 | 539 | foreach($this->_m->toArray() as $behavior) |
| 540 | 540 | { |
| 541 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&(method_exists($behavior,$method)||($behavior instanceof IDynamicMethods))) |
|
| 541 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && (method_exists($behavior, $method) || ($behavior instanceof IDynamicMethods))) |
|
| 542 | 542 | { |
| 543 | 543 | $behavior_args=$args; |
| 544 | 544 | if($behavior instanceof IClassBehavior) |
| 545 | - array_unshift($behavior_args,$this); |
|
| 546 | - $callchain->addCall(array($behavior,$method),$behavior_args); |
|
| 545 | + array_unshift($behavior_args, $this); |
|
| 546 | + $callchain->addCall(array($behavior, $method), $behavior_args); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | } |
| 550 | - if($callchain->getCount()>0) |
|
| 551 | - return call_user_func_array(array($callchain,'call'),$args); |
|
| 550 | + if($callchain->getCount() > 0) |
|
| 551 | + return call_user_func_array(array($callchain, 'call'), $args); |
|
| 552 | 552 | } |
| 553 | 553 | else |
| 554 | 554 | { |
| 555 | 555 | foreach($this->_m->toArray() as $behavior) |
| 556 | 556 | { |
| 557 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&method_exists($behavior,$method)) |
|
| 557 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && method_exists($behavior, $method)) |
|
| 558 | 558 | { |
| 559 | 559 | if($behavior instanceof IClassBehavior) |
| 560 | - array_unshift($args,$this); |
|
| 561 | - return call_user_func_array(array($behavior,$method),$args); |
|
| 560 | + array_unshift($args, $this); |
|
| 561 | + return call_user_func_array(array($behavior, $method), $args); |
|
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - if(strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0) |
|
| 567 | + if(strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
| 568 | 568 | { |
| 569 | 569 | if($this instanceof IDynamicMethods) |
| 570 | - return $this->__dycall($method,$args); |
|
| 571 | - return isset($args[0])?$args[0]:null; |
|
| 570 | + return $this->__dycall($method, $args); |
|
| 571 | + return isset($args[0]) ? $args[0] : null; |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | // don't thrown an exception for __magicMethods() or any other weird methods natively implemented by php |
| 575 | - if (!method_exists($this, $method)) { |
|
| 576 | - throw new TApplicationException('component_method_undefined',get_class($this),$method); |
|
| 575 | + if(!method_exists($this, $method)) { |
|
| 576 | + throw new TApplicationException('component_method_undefined', get_class($this), $method); |
|
| 577 | 577 | } |
| 578 | 578 | } |
| 579 | 579 | |
@@ -603,17 +603,17 @@ discard block |
||
| 603 | 603 | */ |
| 604 | 604 | public function __get($name) |
| 605 | 605 | { |
| 606 | - if(method_exists($this,$getter='get'.$name)) |
|
| 606 | + if(method_exists($this, $getter='get'.$name)) |
|
| 607 | 607 | { |
| 608 | 608 | // getting a property |
| 609 | 609 | return $this->$getter(); |
| 610 | 610 | } |
| 611 | - else if(method_exists($this,$jsgetter='getjs'.$name)) |
|
| 611 | + else if(method_exists($this, $jsgetter='getjs'.$name)) |
|
| 612 | 612 | { |
| 613 | 613 | // getting a javascript property |
| 614 | - return (string)$this->$jsgetter(); |
|
| 614 | + return (string) $this->$jsgetter(); |
|
| 615 | 615 | } |
| 616 | - else if(strncasecmp($name,'on',2)===0 && method_exists($this,$name)) |
|
| 616 | + else if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
| 617 | 617 | { |
| 618 | 618 | // getting an event (handler list) |
| 619 | 619 | $name=strtolower($name); |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | $this->_e[$name]=new TPriorityList; |
| 622 | 622 | return $this->_e[$name]; |
| 623 | 623 | } |
| 624 | - else if(strncasecmp($name,'fx',2)===0) |
|
| 624 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
| 625 | 625 | { |
| 626 | 626 | // getting a global event (handler list) |
| 627 | 627 | $name=strtolower($name); |
@@ -638,13 +638,13 @@ discard block |
||
| 638 | 638 | { |
| 639 | 639 | foreach($this->_m->toArray() as $behavior) |
| 640 | 640 | { |
| 641 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&& |
|
| 642 | - (property_exists($behavior,$name)||$behavior->canGetProperty($name)||$behavior->hasEvent($name))) |
|
| 641 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && |
|
| 642 | + (property_exists($behavior, $name) || $behavior->canGetProperty($name) || $behavior->hasEvent($name))) |
|
| 643 | 643 | return $behavior->$name; |
| 644 | 644 | } |
| 645 | 645 | } |
| 646 | 646 | } |
| 647 | - throw new TInvalidOperationException('component_property_undefined',get_class($this),$name); |
|
| 647 | + throw new TInvalidOperationException('component_property_undefined', get_class($this), $name); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | /** |
@@ -662,31 +662,31 @@ discard block |
||
| 662 | 662 | * @param mixed the property value or event handler |
| 663 | 663 | * @throws TInvalidOperationException If the property is not defined or read-only. |
| 664 | 664 | */ |
| 665 | - public function __set($name,$value) |
|
| 665 | + public function __set($name, $value) |
|
| 666 | 666 | { |
| 667 | - if(method_exists($this,$setter='set'.$name)) |
|
| 667 | + if(method_exists($this, $setter='set'.$name)) |
|
| 668 | 668 | { |
| 669 | - if(strncasecmp($name,'js',2)===0&&$value&&!($value instanceof TJavaScriptLiteral)) |
|
| 670 | - $value = new TJavaScriptLiteral($value); |
|
| 669 | + if(strncasecmp($name, 'js', 2)===0 && $value && !($value instanceof TJavaScriptLiteral)) |
|
| 670 | + $value=new TJavaScriptLiteral($value); |
|
| 671 | 671 | return $this->$setter($value); |
| 672 | 672 | } |
| 673 | - else if(method_exists($this,$jssetter='setjs'.$name)) |
|
| 673 | + else if(method_exists($this, $jssetter='setjs'.$name)) |
|
| 674 | 674 | { |
| 675 | - if($value&&!($value instanceof TJavaScriptString)) |
|
| 675 | + if($value && !($value instanceof TJavaScriptString)) |
|
| 676 | 676 | $value=new TJavaScriptString($value); |
| 677 | 677 | return $this->$jssetter($value); |
| 678 | 678 | } |
| 679 | - else if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0) |
|
| 679 | + else if((strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2)===0) |
|
| 680 | 680 | { |
| 681 | - return $this->attachEventHandler($name,$value); |
|
| 681 | + return $this->attachEventHandler($name, $value); |
|
| 682 | 682 | } |
| 683 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
| 683 | + else if($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
| 684 | 684 | { |
| 685 | 685 | $sets=0; |
| 686 | 686 | foreach($this->_m->toArray() as $behavior) |
| 687 | 687 | { |
| 688 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&& |
|
| 689 | - (property_exists($behavior,$name)||$behavior->canSetProperty($name)||$behavior->hasEvent($name))) { |
|
| 688 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && |
|
| 689 | + (property_exists($behavior, $name) || $behavior->canSetProperty($name) || $behavior->hasEvent($name))) { |
|
| 690 | 690 | $behavior->$name=$value; |
| 691 | 691 | $sets++; |
| 692 | 692 | } |
@@ -695,13 +695,13 @@ discard block |
||
| 695 | 695 | |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name)) |
|
| 698 | + if(method_exists($this, 'get'.$name) || method_exists($this, 'getjs'.$name)) |
|
| 699 | 699 | { |
| 700 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
|
| 700 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
|
| 701 | 701 | } |
| 702 | 702 | else |
| 703 | 703 | { |
| 704 | - throw new TInvalidOperationException('component_property_undefined',get_class($this),$name); |
|
| 704 | + throw new TInvalidOperationException('component_property_undefined', get_class($this), $name); |
|
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | 707 | |
@@ -719,27 +719,27 @@ discard block |
||
| 719 | 719 | */ |
| 720 | 720 | public function __isset($name) |
| 721 | 721 | { |
| 722 | - if(method_exists($this,$getter='get'.$name)) |
|
| 722 | + if(method_exists($this, $getter='get'.$name)) |
|
| 723 | 723 | return $this->$getter()!==null; |
| 724 | - else if(method_exists($this,$jsgetter='getjs'.$name)) |
|
| 724 | + else if(method_exists($this, $jsgetter='getjs'.$name)) |
|
| 725 | 725 | return $this->$jsgetter()!==null; |
| 726 | - else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name)) |
|
| 726 | + else if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
| 727 | 727 | { |
| 728 | 728 | $name=strtolower($name); |
| 729 | - return isset($this->_e[$name])&&$this->_e[$name]->getCount(); |
|
| 729 | + return isset($this->_e[$name]) && $this->_e[$name]->getCount(); |
|
| 730 | 730 | } |
| 731 | - else if(strncasecmp($name,'fx',2)===0) |
|
| 731 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
| 732 | 732 | { |
| 733 | 733 | $name=strtolower($name); |
| 734 | - return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount(); |
|
| 734 | + return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount(); |
|
| 735 | 735 | } |
| 736 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
| 736 | + else if($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
| 737 | 737 | { |
| 738 | 738 | if(isset($this->_m[$name])) |
| 739 | 739 | return true; |
| 740 | 740 | foreach($this->_m->toArray() as $behavior) |
| 741 | 741 | { |
| 742 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())) |
|
| 742 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled())) |
|
| 743 | 743 | return isset($behavior->$name); |
| 744 | 744 | } |
| 745 | 745 | |
@@ -760,15 +760,15 @@ discard block |
||
| 760 | 760 | */ |
| 761 | 761 | public function __unset($name) |
| 762 | 762 | { |
| 763 | - if(method_exists($this,$setter='set'.$name)) |
|
| 763 | + if(method_exists($this, $setter='set'.$name)) |
|
| 764 | 764 | $this->$setter(null); |
| 765 | - else if(method_exists($this,$jssetter='setjs'.$name)) |
|
| 765 | + else if(method_exists($this, $jssetter='setjs'.$name)) |
|
| 766 | 766 | $this->$jssetter(null); |
| 767 | - else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name)) |
|
| 767 | + else if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
| 768 | 768 | $this->_e[strtolower($name)]->clear(); |
| 769 | - else if(strncasecmp($name,'fx',2)===0) |
|
| 769 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
| 770 | 770 | $this->getEventHandlers($name)->remove(array($this, $name)); |
| 771 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
| 771 | + else if($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
| 772 | 772 | { |
| 773 | 773 | if(isset($this->_m[$name])) |
| 774 | 774 | $this->detachBehavior($name); |
@@ -776,16 +776,16 @@ discard block |
||
| 776 | 776 | $unset=0; |
| 777 | 777 | foreach($this->_m->toArray() as $behavior) |
| 778 | 778 | { |
| 779 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())) { |
|
| 779 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled())) { |
|
| 780 | 780 | unset($behavior->$name); |
| 781 | 781 | $unset++; |
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | - if(!$unset&&method_exists($this,'get'.$name)) |
|
| 785 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
|
| 784 | + if(!$unset && method_exists($this, 'get'.$name)) |
|
| 785 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
|
| 786 | 786 | } |
| 787 | - } else if(method_exists($this,'get'.$name)) |
|
| 788 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
|
| 787 | + } else if(method_exists($this, 'get'.$name)) |
|
| 788 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | /** |
@@ -797,7 +797,7 @@ discard block |
||
| 797 | 797 | */ |
| 798 | 798 | public function hasProperty($name) |
| 799 | 799 | { |
| 800 | - return $this->canGetProperty($name)||$this->canSetProperty($name); |
|
| 800 | + return $this->canGetProperty($name) || $this->canSetProperty($name); |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | /** |
@@ -811,13 +811,13 @@ discard block |
||
| 811 | 811 | */ |
| 812 | 812 | public function canGetProperty($name) |
| 813 | 813 | { |
| 814 | - if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name)) |
|
| 814 | + if(method_exists($this, 'get'.$name) || method_exists($this, 'getjs'.$name)) |
|
| 815 | 815 | return true; |
| 816 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
| 816 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
| 817 | 817 | { |
| 818 | 818 | foreach($this->_m->toArray() as $behavior) |
| 819 | 819 | { |
| 820 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canGetProperty($name)) |
|
| 820 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canGetProperty($name)) |
|
| 821 | 821 | return true; |
| 822 | 822 | } |
| 823 | 823 | } |
@@ -835,13 +835,13 @@ discard block |
||
| 835 | 835 | */ |
| 836 | 836 | public function canSetProperty($name) |
| 837 | 837 | { |
| 838 | - if(method_exists($this,'set'.$name)||method_exists($this,'setjs'.$name)) |
|
| 838 | + if(method_exists($this, 'set'.$name) || method_exists($this, 'setjs'.$name)) |
|
| 839 | 839 | return true; |
| 840 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
| 840 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
| 841 | 841 | { |
| 842 | 842 | foreach($this->_m->toArray() as $behavior) |
| 843 | 843 | { |
| 844 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canSetProperty($name)) |
|
| 844 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canSetProperty($name)) |
|
| 845 | 845 | return true; |
| 846 | 846 | } |
| 847 | 847 | } |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | public function getSubProperty($path) |
| 862 | 862 | { |
| 863 | 863 | $object=$this; |
| 864 | - foreach(explode('.',$path) as $property) |
|
| 864 | + foreach(explode('.', $path) as $property) |
|
| 865 | 865 | $object=$object->$property; |
| 866 | 866 | return $object; |
| 867 | 867 | } |
@@ -876,15 +876,15 @@ discard block |
||
| 876 | 876 | * @param string property path |
| 877 | 877 | * @param mixed the property path value |
| 878 | 878 | */ |
| 879 | - public function setSubProperty($path,$value) |
|
| 879 | + public function setSubProperty($path, $value) |
|
| 880 | 880 | { |
| 881 | 881 | $object=$this; |
| 882 | - if(($pos=strrpos($path,'.'))===false) |
|
| 882 | + if(($pos=strrpos($path, '.'))===false) |
|
| 883 | 883 | $property=$path; |
| 884 | 884 | else |
| 885 | 885 | { |
| 886 | - $object=$this->getSubProperty(substr($path,0,$pos)); |
|
| 887 | - $property=substr($path,$pos+1); |
|
| 886 | + $object=$this->getSubProperty(substr($path, 0, $pos)); |
|
| 887 | + $property=substr($path, $pos + 1); |
|
| 888 | 888 | } |
| 889 | 889 | $object->$property=$value; |
| 890 | 890 | } |
@@ -903,14 +903,14 @@ discard block |
||
| 903 | 903 | */ |
| 904 | 904 | public function hasEvent($name) |
| 905 | 905 | { |
| 906 | - if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0||strncasecmp($name,'dy',2)===0) |
|
| 906 | + if((strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2)===0 || strncasecmp($name, 'dy', 2)===0) |
|
| 907 | 907 | return true; |
| 908 | 908 | |
| 909 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
| 909 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
| 910 | 910 | { |
| 911 | 911 | foreach($this->_m->toArray() as $behavior) |
| 912 | 912 | { |
| 913 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name)) |
|
| 913 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name)) |
|
| 914 | 914 | return true; |
| 915 | 915 | } |
| 916 | 916 | } |
@@ -927,16 +927,16 @@ discard block |
||
| 927 | 927 | public function hasEventHandler($name) |
| 928 | 928 | { |
| 929 | 929 | $name=strtolower($name); |
| 930 | - if(strncasecmp($name,'fx',2)===0) |
|
| 931 | - return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount()>0; |
|
| 930 | + if(strncasecmp($name, 'fx', 2)===0) |
|
| 931 | + return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount() > 0; |
|
| 932 | 932 | else |
| 933 | 933 | { |
| 934 | - if(isset($this->_e[$name])&&$this->_e[$name]->getCount()>0) |
|
| 934 | + if(isset($this->_e[$name]) && $this->_e[$name]->getCount() > 0) |
|
| 935 | 935 | return true; |
| 936 | - else if($this->_m!==null&&$this->_behaviorsenabled) { |
|
| 936 | + else if($this->_m!==null && $this->_behaviorsenabled) { |
|
| 937 | 937 | foreach($this->_m->toArray() as $behavior) |
| 938 | 938 | { |
| 939 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEventHandler($name)) |
|
| 939 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEventHandler($name)) |
|
| 940 | 940 | return true; |
| 941 | 941 | } |
| 942 | 942 | } |
@@ -952,29 +952,29 @@ discard block |
||
| 952 | 952 | */ |
| 953 | 953 | public function getEventHandlers($name) |
| 954 | 954 | { |
| 955 | - if(strncasecmp($name,'on',2)===0&&method_exists($this,$name)) |
|
| 955 | + if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
| 956 | 956 | { |
| 957 | 957 | $name=strtolower($name); |
| 958 | 958 | if(!isset($this->_e[$name])) |
| 959 | 959 | $this->_e[$name]=new TPriorityList; |
| 960 | 960 | return $this->_e[$name]; |
| 961 | 961 | } |
| 962 | - else if(strncasecmp($name,'fx',2)===0) |
|
| 962 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
| 963 | 963 | { |
| 964 | 964 | $name=strtolower($name); |
| 965 | 965 | if(!isset(self::$_ue[$name])) |
| 966 | 966 | self::$_ue[$name]=new TPriorityList; |
| 967 | 967 | return self::$_ue[$name]; |
| 968 | 968 | } |
| 969 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
| 969 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
| 970 | 970 | { |
| 971 | 971 | foreach($this->_m->toArray() as $behavior) |
| 972 | 972 | { |
| 973 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name)) |
|
| 973 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name)) |
|
| 974 | 974 | return $behavior->getEventHandlers($name); |
| 975 | 975 | } |
| 976 | 976 | } |
| 977 | - throw new TInvalidOperationException('component_event_undefined',get_class($this),$name); |
|
| 977 | + throw new TInvalidOperationException('component_event_undefined', get_class($this), $name); |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | /** |
@@ -1022,9 +1022,9 @@ discard block |
||
| 1022 | 1022 | * default priority of 10.0 within {@link TPriorityList} |
| 1023 | 1023 | * @throws TInvalidOperationException if the event does not exist |
| 1024 | 1024 | */ |
| 1025 | - public function attachEventHandler($name,$handler,$priority=null) |
|
| 1025 | + public function attachEventHandler($name, $handler, $priority=null) |
|
| 1026 | 1026 | { |
| 1027 | - $this->getEventHandlers($name)->add($handler,$priority); |
|
| 1027 | + $this->getEventHandlers($name)->add($handler, $priority); |
|
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | 1030 | /** |
@@ -1037,13 +1037,13 @@ discard block |
||
| 1037 | 1037 | * to an item of any priority within {@link TPriorityList}; null means the default priority |
| 1038 | 1038 | * @return boolean if the removal is successful |
| 1039 | 1039 | */ |
| 1040 | - public function detachEventHandler($name,$handler,$priority=false) |
|
| 1040 | + public function detachEventHandler($name, $handler, $priority=false) |
|
| 1041 | 1041 | { |
| 1042 | 1042 | if($this->hasEventHandler($name)) |
| 1043 | 1043 | { |
| 1044 | 1044 | try |
| 1045 | 1045 | { |
| 1046 | - $this->getEventHandlers($name)->remove($handler,$priority); |
|
| 1046 | + $this->getEventHandlers($name)->remove($handler, $priority); |
|
| 1047 | 1047 | return true; |
| 1048 | 1048 | } |
| 1049 | 1049 | catch(\Exception $e) |
@@ -1125,7 +1125,7 @@ discard block |
||
| 1125 | 1125 | * @throws TInvalidOperationException if the event is undefined |
| 1126 | 1126 | * @throws TInvalidDataValueException If an event handler is invalid |
| 1127 | 1127 | */ |
| 1128 | - public function raiseEvent($name,$sender,$param,$responsetype=null,$postfunction=null) |
|
| 1128 | + public function raiseEvent($name, $sender, $param, $responsetype=null, $postfunction=null) |
|
| 1129 | 1129 | { |
| 1130 | 1130 | $p=$param; |
| 1131 | 1131 | if(is_callable($responsetype)) |
@@ -1140,90 +1140,90 @@ discard block |
||
| 1140 | 1140 | $name=strtolower($name); |
| 1141 | 1141 | $responses=array(); |
| 1142 | 1142 | |
| 1143 | - $name=$this->dyPreRaiseEvent($name,$sender,$param,$responsetype,$postfunction); |
|
| 1143 | + $name=$this->dyPreRaiseEvent($name, $sender, $param, $responsetype, $postfunction); |
|
| 1144 | 1144 | |
| 1145 | - if($this->hasEventHandler($name)||$this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
| 1145 | + if($this->hasEventHandler($name) || $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
| 1146 | 1146 | { |
| 1147 | 1147 | $handlers=$this->getEventHandlers($name); |
| 1148 | 1148 | $handlerArray=$handlers->toArray(); |
| 1149 | - if(strncasecmp($name,'fx',2)===0&&$this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
| 1149 | + if(strncasecmp($name, 'fx', 2)===0 && $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
| 1150 | 1150 | { |
| 1151 | 1151 | $globalhandlers=$this->getEventHandlers(TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
| 1152 | - $handlerArray=array_merge($globalhandlers->toArrayBelowPriority(0),$handlerArray,$globalhandlers->toArrayAbovePriority(0)); |
|
| 1152 | + $handlerArray=array_merge($globalhandlers->toArrayBelowPriority(0), $handlerArray, $globalhandlers->toArrayAbovePriority(0)); |
|
| 1153 | 1153 | } |
| 1154 | 1154 | $response=null; |
| 1155 | 1155 | foreach($handlerArray as $handler) |
| 1156 | 1156 | { |
| 1157 | - if($this->dyIntraRaiseEventTestHandler($handler,$sender,$param,$name)===false) |
|
| 1157 | + if($this->dyIntraRaiseEventTestHandler($handler, $sender, $param, $name)===false) |
|
| 1158 | 1158 | continue; |
| 1159 | 1159 | |
| 1160 | 1160 | if(is_string($handler)) |
| 1161 | 1161 | { |
| 1162 | - if(($pos=strrpos($handler,'.'))!==false) |
|
| 1162 | + if(($pos=strrpos($handler, '.'))!==false) |
|
| 1163 | 1163 | { |
| 1164 | - $object=$this->getSubProperty(substr($handler,0,$pos)); |
|
| 1165 | - $method=substr($handler,$pos+1); |
|
| 1166 | - if(method_exists($object,$method)||strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0) |
|
| 1164 | + $object=$this->getSubProperty(substr($handler, 0, $pos)); |
|
| 1165 | + $method=substr($handler, $pos + 1); |
|
| 1166 | + if(method_exists($object, $method) || strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
| 1167 | 1167 | { |
| 1168 | 1168 | if($method=='__dycall') |
| 1169 | - $response=$object->__dycall($name,array($sender,$param,$name)); |
|
| 1169 | + $response=$object->__dycall($name, array($sender, $param, $name)); |
|
| 1170 | 1170 | else |
| 1171 | - $response=$object->$method($sender,$param,$name); |
|
| 1171 | + $response=$object->$method($sender, $param, $name); |
|
| 1172 | 1172 | } |
| 1173 | 1173 | else |
| 1174 | - throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler); |
|
| 1174 | + throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler); |
|
| 1175 | 1175 | } |
| 1176 | 1176 | else |
| 1177 | - $response=call_user_func($handler,$sender,$param,$name); |
|
| 1177 | + $response=call_user_func($handler, $sender, $param, $name); |
|
| 1178 | 1178 | } |
| 1179 | - else if(is_callable($handler,true)) |
|
| 1179 | + else if(is_callable($handler, true)) |
|
| 1180 | 1180 | { |
| 1181 | - list($object,$method)=$handler; |
|
| 1181 | + list($object, $method)=$handler; |
|
| 1182 | 1182 | if(is_string($object)) |
| 1183 | - $response=call_user_func($handler,$sender,$param,$name); |
|
| 1183 | + $response=call_user_func($handler, $sender, $param, $name); |
|
| 1184 | 1184 | else |
| 1185 | 1185 | { |
| 1186 | - if(($pos=strrpos($method,'.'))!==false) |
|
| 1186 | + if(($pos=strrpos($method, '.'))!==false) |
|
| 1187 | 1187 | { |
| 1188 | - $object=$this->getSubProperty(substr($method,0,$pos)); |
|
| 1189 | - $method=substr($method,$pos+1); |
|
| 1188 | + $object=$this->getSubProperty(substr($method, 0, $pos)); |
|
| 1189 | + $method=substr($method, $pos + 1); |
|
| 1190 | 1190 | } |
| 1191 | - if(method_exists($object,$method)||strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0) |
|
| 1191 | + if(method_exists($object, $method) || strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
| 1192 | 1192 | { |
| 1193 | 1193 | if($method=='__dycall') |
| 1194 | - $response=$object->__dycall($name,array($sender,$param,$name)); |
|
| 1194 | + $response=$object->__dycall($name, array($sender, $param, $name)); |
|
| 1195 | 1195 | else |
| 1196 | - $response=$object->$method($sender,$param,$name); |
|
| 1196 | + $response=$object->$method($sender, $param, $name); |
|
| 1197 | 1197 | } |
| 1198 | 1198 | else |
| 1199 | - throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler[1]); |
|
| 1199 | + throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler[1]); |
|
| 1200 | 1200 | } |
| 1201 | 1201 | } |
| 1202 | 1202 | else |
| 1203 | - throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,gettype($handler)); |
|
| 1203 | + throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, gettype($handler)); |
|
| 1204 | 1204 | |
| 1205 | - $this->dyIntraRaiseEventPostHandler($name,$sender,$param,$handler,$response); |
|
| 1205 | + $this->dyIntraRaiseEventPostHandler($name, $sender, $param, $handler, $response); |
|
| 1206 | 1206 | |
| 1207 | 1207 | if($postfunction) |
| 1208 | - $response=call_user_func_array($postfunction,array($sender,$param,$this,$response)); |
|
| 1208 | + $response=call_user_func_array($postfunction, array($sender, $param, $this, $response)); |
|
| 1209 | 1209 | |
| 1210 | - if($responsetype&TEventResults::EVENT_RESULT_ALL) |
|
| 1211 | - $responses[]=array('sender'=>$sender,'param'=>$param,'response'=>$response); |
|
| 1210 | + if($responsetype & TEventResults::EVENT_RESULT_ALL) |
|
| 1211 | + $responses[]=array('sender'=>$sender, 'param'=>$param, 'response'=>$response); |
|
| 1212 | 1212 | else |
| 1213 | 1213 | $responses[]=$response; |
| 1214 | 1214 | |
| 1215 | - if($response!==null&&($responsetype&TEventResults::EVENT_RESULT_FEED_FORWARD)) |
|
| 1215 | + if($response!==null && ($responsetype & TEventResults::EVENT_RESULT_FEED_FORWARD)) |
|
| 1216 | 1216 | $param=$response; |
| 1217 | 1217 | |
| 1218 | 1218 | } |
| 1219 | 1219 | } |
| 1220 | - else if(strncasecmp($name,'on',2)===0&&!$this->hasEvent($name)) |
|
| 1221 | - throw new TInvalidOperationException('component_event_undefined',get_class($this),$name); |
|
| 1220 | + else if(strncasecmp($name, 'on', 2)===0 && !$this->hasEvent($name)) |
|
| 1221 | + throw new TInvalidOperationException('component_event_undefined', get_class($this), $name); |
|
| 1222 | 1222 | |
| 1223 | - if($responsetype&TEventResults::EVENT_RESULT_FILTER) |
|
| 1223 | + if($responsetype & TEventResults::EVENT_RESULT_FILTER) |
|
| 1224 | 1224 | $responses=array_filter($responses); |
| 1225 | 1225 | |
| 1226 | - $responses=$this->dyPostRaiseEvent($responses,$name,$sender,$param,$responsetype,$postfunction); |
|
| 1226 | + $responses=$this->dyPostRaiseEvent($responses, $name, $sender, $param, $responsetype, $postfunction); |
|
| 1227 | 1227 | |
| 1228 | 1228 | return $responses; |
| 1229 | 1229 | } |
@@ -1256,7 +1256,7 @@ discard block |
||
| 1256 | 1256 | } |
| 1257 | 1257 | catch(\Exception $e) |
| 1258 | 1258 | { |
| 1259 | - throw new TInvalidOperationException('component_expression_invalid',get_class($this),$expression,$e->getMessage()); |
|
| 1259 | + throw new TInvalidOperationException('component_expression_invalid', get_class($this), $expression, $e->getMessage()); |
|
| 1260 | 1260 | } |
| 1261 | 1261 | } |
| 1262 | 1262 | |
@@ -1291,7 +1291,7 @@ discard block |
||
| 1291 | 1291 | } |
| 1292 | 1292 | catch(\Exception $e) |
| 1293 | 1293 | { |
| 1294 | - throw new TInvalidOperationException('component_statements_invalid',get_class($this),$statements,$e->getMessage()); |
|
| 1294 | + throw new TInvalidOperationException('component_statements_invalid', get_class($this), $statements, $e->getMessage()); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | } |
| 1297 | 1297 | |
@@ -1351,9 +1351,9 @@ discard block |
||
| 1351 | 1351 | * @param $param TClassBehaviorEventParameter |
| 1352 | 1352 | * @since 3.2.3 |
| 1353 | 1353 | */ |
| 1354 | - public function fxAttachClassBehavior($sender,$param) { |
|
| 1355 | - if(in_array($param->getClass(),$this->getClassHierarchy(true))) |
|
| 1356 | - return $this->attachBehavior($param->getName(),$param->getBehavior(),$param->getPriority()); |
|
| 1354 | + public function fxAttachClassBehavior($sender, $param) { |
|
| 1355 | + if(in_array($param->getClass(), $this->getClassHierarchy(true))) |
|
| 1356 | + return $this->attachBehavior($param->getName(), $param->getBehavior(), $param->getPriority()); |
|
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | 1359 | |
@@ -1365,9 +1365,9 @@ discard block |
||
| 1365 | 1365 | * @param $param TClassBehaviorEventParameter |
| 1366 | 1366 | * @since 3.2.3 |
| 1367 | 1367 | */ |
| 1368 | - public function fxDetachClassBehavior($sender,$param) { |
|
| 1369 | - if(in_array($param->getClass(),$this->getClassHierarchy(true))) |
|
| 1370 | - return $this->detachBehavior($param->getName(),$param->getPriority()); |
|
| 1368 | + public function fxDetachClassBehavior($sender, $param) { |
|
| 1369 | + if(in_array($param->getClass(), $this->getClassHierarchy(true))) |
|
| 1370 | + return $this->detachBehavior($param->getName(), $param->getPriority()); |
|
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | 1373 | |
@@ -1389,8 +1389,8 @@ discard block |
||
| 1389 | 1389 | * @throws TInvalidOperationException if the class behavior is already defined |
| 1390 | 1390 | * @since 3.2.3 |
| 1391 | 1391 | */ |
| 1392 | - public static function attachClassBehavior($name,$behavior,$class=null,$priority=null) { |
|
| 1393 | - if(!$class&&function_exists('get_called_class')) |
|
| 1392 | + public static function attachClassBehavior($name, $behavior, $class=null, $priority=null) { |
|
| 1393 | + if(!$class && function_exists('get_called_class')) |
|
| 1394 | 1394 | $class=get_called_class(); |
| 1395 | 1395 | if(!$class) |
| 1396 | 1396 | throw new TInvalidOperationException('component_no_class_provided_nor_late_binding'); |
@@ -1403,11 +1403,11 @@ discard block |
||
| 1403 | 1403 | if(empty(self::$_um[$class])) |
| 1404 | 1404 | self::$_um[$class]=array(); |
| 1405 | 1405 | if(isset(self::$_um[$class][$name])) |
| 1406 | - throw new TInvalidOperationException('component_class_behavior_defined',$class,$name); |
|
| 1407 | - $param=new TClassBehaviorEventParameter($class,$name,$behavior,$priority); |
|
| 1408 | - self::$_um[$class]=array($name=>$param)+self::$_um[$class]; |
|
| 1409 | - $behaviorObject=is_string($behavior)?new $behavior:$behavior; |
|
| 1410 | - return $behaviorObject->raiseEvent('fxAttachClassBehavior',null,$param); |
|
| 1406 | + throw new TInvalidOperationException('component_class_behavior_defined', $class, $name); |
|
| 1407 | + $param=new TClassBehaviorEventParameter($class, $name, $behavior, $priority); |
|
| 1408 | + self::$_um[$class]=array($name=>$param) + self::$_um[$class]; |
|
| 1409 | + $behaviorObject=is_string($behavior) ? new $behavior : $behavior; |
|
| 1410 | + return $behaviorObject->raiseEvent('fxAttachClassBehavior', null, $param); |
|
| 1411 | 1411 | } |
| 1412 | 1412 | |
| 1413 | 1413 | |
@@ -1423,8 +1423,8 @@ discard block |
||
| 1423 | 1423 | * not supplied as a parameter. |
| 1424 | 1424 | * @since 3.2.3 |
| 1425 | 1425 | */ |
| 1426 | - public static function detachClassBehavior($name,$class=null,$priority=false) { |
|
| 1427 | - if(!$class&&function_exists('get_called_class')) |
|
| 1426 | + public static function detachClassBehavior($name, $class=null, $priority=false) { |
|
| 1427 | + if(!$class && function_exists('get_called_class')) |
|
| 1428 | 1428 | $class=get_called_class(); |
| 1429 | 1429 | if(!$class) |
| 1430 | 1430 | throw new TInvalidOperationException('component_no_class_provided_nor_late_binding'); |
@@ -1432,13 +1432,13 @@ discard block |
||
| 1432 | 1432 | $class=strtolower($class); |
| 1433 | 1433 | if(!is_string($name)) |
| 1434 | 1434 | $name=get_class($name); |
| 1435 | - if(empty(self::$_um[$class])||!isset(self::$_um[$class][$name])) |
|
| 1435 | + if(empty(self::$_um[$class]) || !isset(self::$_um[$class][$name])) |
|
| 1436 | 1436 | return false; |
| 1437 | 1437 | $param=self::$_um[$class][$name]; |
| 1438 | 1438 | $behavior=$param->getBehavior(); |
| 1439 | 1439 | unset(self::$_um[$class][$name]); |
| 1440 | - $behaviorObject=is_string($behavior)?new $behavior:$behavior; |
|
| 1441 | - return $behaviorObject->raiseEvent('fxDetachClassBehavior',null,$param); |
|
| 1440 | + $behaviorObject=is_string($behavior) ? new $behavior : $behavior; |
|
| 1441 | + return $behaviorObject->raiseEvent('fxDetachClassBehavior', null, $param); |
|
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | /** |
@@ -1450,7 +1450,7 @@ discard block |
||
| 1450 | 1450 | */ |
| 1451 | 1451 | public function asa($behaviorname) |
| 1452 | 1452 | { |
| 1453 | - return isset($this->_m[$behaviorname])?$this->_m[$behaviorname]:null; |
|
| 1453 | + return isset($this->_m[$behaviorname]) ? $this->_m[$behaviorname] : null; |
|
| 1454 | 1454 | } |
| 1455 | 1455 | |
| 1456 | 1456 | /** |
@@ -1476,15 +1476,15 @@ discard block |
||
| 1476 | 1476 | { |
| 1477 | 1477 | if($this instanceof $class) |
| 1478 | 1478 | return true; |
| 1479 | - if($this->_m!==null&&$this->_behaviorsenabled) |
|
| 1480 | - foreach($this->_m->toArray() as $behavior){ |
|
| 1481 | - if(($behavior instanceof IBehavior)&&!$behavior->getEnabled()) |
|
| 1479 | + if($this->_m!==null && $this->_behaviorsenabled) |
|
| 1480 | + foreach($this->_m->toArray() as $behavior) { |
|
| 1481 | + if(($behavior instanceof IBehavior) && !$behavior->getEnabled()) |
|
| 1482 | 1482 | continue; |
| 1483 | 1483 | |
| 1484 | - $check = null; |
|
| 1485 | - if(($behavior->isa('\Prado\Util\IInstanceCheck'))&&$check=$behavior->isinstanceof($class,$this)) |
|
| 1484 | + $check=null; |
|
| 1485 | + if(($behavior->isa('\Prado\Util\IInstanceCheck')) && $check=$behavior->isinstanceof($class, $this)) |
|
| 1486 | 1486 | return true; |
| 1487 | - if($check===null&&($behavior->isa($class))) |
|
| 1487 | + if($check===null && ($behavior->isa($class))) |
|
| 1488 | 1488 | return true; |
| 1489 | 1489 | } |
| 1490 | 1490 | return false; |
@@ -1502,9 +1502,9 @@ discard block |
||
| 1502 | 1502 | { |
| 1503 | 1503 | foreach($behaviors as $name=>$behavior) |
| 1504 | 1504 | if($behavior instanceof TClassBehaviorEventParameter) |
| 1505 | - $this->attachBehavior($behavior->getName(),$behavior->getBehavior(),$behavior->getPriority()); |
|
| 1505 | + $this->attachBehavior($behavior->getName(), $behavior->getBehavior(), $behavior->getPriority()); |
|
| 1506 | 1506 | else |
| 1507 | - $this->attachBehavior($name,$behavior); |
|
| 1507 | + $this->attachBehavior($name, $behavior); |
|
| 1508 | 1508 | } |
| 1509 | 1509 | |
| 1510 | 1510 | /** |
@@ -1521,9 +1521,9 @@ discard block |
||
| 1521 | 1521 | { |
| 1522 | 1522 | foreach($behaviors as $name=>$behavior) |
| 1523 | 1523 | if($behavior instanceof TClassBehaviorEventParameter) |
| 1524 | - $this->detachBehavior($behavior->getName(),$behavior->getPriority()); |
|
| 1524 | + $this->detachBehavior($behavior->getName(), $behavior->getPriority()); |
|
| 1525 | 1525 | else |
| 1526 | - $this->detachBehavior(is_string($behavior)?$behavior:$name); |
|
| 1526 | + $this->detachBehavior(is_string($behavior) ? $behavior : $name); |
|
| 1527 | 1527 | } |
| 1528 | 1528 | } |
| 1529 | 1529 | |
@@ -1561,19 +1561,19 @@ discard block |
||
| 1561 | 1561 | * @return IBehavior the behavior object |
| 1562 | 1562 | * @since 3.2.3 |
| 1563 | 1563 | */ |
| 1564 | - public function attachBehavior($name,$behavior,$priority=null) |
|
| 1564 | + public function attachBehavior($name, $behavior, $priority=null) |
|
| 1565 | 1565 | { |
| 1566 | 1566 | if(is_string($behavior)) |
| 1567 | 1567 | $behavior=Prado::createComponent($behavior); |
| 1568 | 1568 | if(!($behavior instanceof IBaseBehavior)) |
| 1569 | - throw new TInvalidDataTypeException('component_not_a_behavior',get_class($behavior)); |
|
| 1569 | + throw new TInvalidDataTypeException('component_not_a_behavior', get_class($behavior)); |
|
| 1570 | 1570 | if($behavior instanceof IBehavior) |
| 1571 | 1571 | $behavior->setEnabled(true); |
| 1572 | 1572 | if($this->_m===null) |
| 1573 | 1573 | $this->_m=new TPriorityMap; |
| 1574 | 1574 | $behavior->attach($this); |
| 1575 | - $this->dyAttachBehavior($name,$behavior); |
|
| 1576 | - $this->_m->add($name,$behavior,$priority); |
|
| 1575 | + $this->dyAttachBehavior($name, $behavior); |
|
| 1576 | + $this->_m->add($name, $behavior, $priority); |
|
| 1577 | 1577 | return $behavior; |
| 1578 | 1578 | } |
| 1579 | 1579 | |
@@ -1594,14 +1594,14 @@ discard block |
||
| 1594 | 1594 | * @return IBehavior the detached behavior. Null if the behavior does not exist. |
| 1595 | 1595 | * @since 3.2.3 |
| 1596 | 1596 | */ |
| 1597 | - public function detachBehavior($name,$priority=false) |
|
| 1597 | + public function detachBehavior($name, $priority=false) |
|
| 1598 | 1598 | { |
| 1599 | - if($this->_m!=null&&isset($this->_m[$name])) |
|
| 1599 | + if($this->_m!=null && isset($this->_m[$name])) |
|
| 1600 | 1600 | { |
| 1601 | 1601 | $this->_m[$name]->detach($this); |
| 1602 | 1602 | $behavior=$this->_m->itemAt($name); |
| 1603 | - $this->_m->remove($name,$priority); |
|
| 1604 | - $this->dyDetachBehavior($name,$behavior); |
|
| 1603 | + $this->_m->remove($name, $priority); |
|
| 1604 | + $this->dyDetachBehavior($name, $behavior); |
|
| 1605 | 1605 | return $behavior; |
| 1606 | 1606 | } |
| 1607 | 1607 | } |
@@ -1677,10 +1677,10 @@ discard block |
||
| 1677 | 1677 | */ |
| 1678 | 1678 | public function enableBehavior($name) |
| 1679 | 1679 | { |
| 1680 | - if($this->_m!=null&&isset($this->_m[$name])){ |
|
| 1680 | + if($this->_m!=null && isset($this->_m[$name])) { |
|
| 1681 | 1681 | if($this->_m[$name] instanceof IBehavior) { |
| 1682 | 1682 | $this->_m[$name]->setEnabled(true); |
| 1683 | - $this->dyEnableBehavior($name,$this->_m[$name]); |
|
| 1683 | + $this->dyEnableBehavior($name, $this->_m[$name]); |
|
| 1684 | 1684 | return true; |
| 1685 | 1685 | } |
| 1686 | 1686 | return false; |
@@ -1705,10 +1705,10 @@ discard block |
||
| 1705 | 1705 | */ |
| 1706 | 1706 | public function disableBehavior($name) |
| 1707 | 1707 | { |
| 1708 | - if($this->_m!=null&&isset($this->_m[$name])){ |
|
| 1708 | + if($this->_m!=null && isset($this->_m[$name])) { |
|
| 1709 | 1709 | if($this->_m[$name] instanceof IBehavior) { |
| 1710 | 1710 | $this->_m[$name]->setEnabled(false); |
| 1711 | - $this->dyDisableBehavior($name,$this->_m[$name]); |
|
| 1711 | + $this->dyDisableBehavior($name, $this->_m[$name]); |
|
| 1712 | 1712 | return true; |
| 1713 | 1713 | } |
| 1714 | 1714 | return false; |
@@ -1723,9 +1723,9 @@ discard block |
||
| 1723 | 1723 | */ |
| 1724 | 1724 | public function __sleep() |
| 1725 | 1725 | { |
| 1726 | - $a = (array)$this; |
|
| 1727 | - $a = array_keys($a); |
|
| 1728 | - $exprops = array(); |
|
| 1726 | + $a=(array) $this; |
|
| 1727 | + $a=array_keys($a); |
|
| 1728 | + $exprops=array(); |
|
| 1729 | 1729 | $this->_getZappableSleepProps($exprops); |
| 1730 | 1730 | return array_diff($a, $exprops); |
| 1731 | 1731 | } |
@@ -1739,12 +1739,12 @@ discard block |
||
| 1739 | 1739 | protected function _getZappableSleepProps(&$exprops) |
| 1740 | 1740 | { |
| 1741 | 1741 | if($this->_listeningenabled===false) |
| 1742 | - $exprops[] = "\0Prado\TComponent\0_listeningenabled"; |
|
| 1742 | + $exprops[]="\0Prado\TComponent\0_listeningenabled"; |
|
| 1743 | 1743 | if($this->_behaviorsenabled===true) |
| 1744 | - $exprops[] = "\0Prado\TComponent\0_behaviorsenabled"; |
|
| 1745 | - if ($this->_e===array()) |
|
| 1746 | - $exprops[] = "\0Prado\TComponent\0_e"; |
|
| 1747 | - if ($this->_m===null) |
|
| 1748 | - $exprops[] = "\0Prado\TComponent\0_m"; |
|
| 1744 | + $exprops[]="\0Prado\TComponent\0_behaviorsenabled"; |
|
| 1745 | + if($this->_e===array()) |
|
| 1746 | + $exprops[]="\0Prado\TComponent\0_e"; |
|
| 1747 | + if($this->_m===null) |
|
| 1748 | + $exprops[]="\0Prado\TComponent\0_m"; |
|
| 1749 | 1749 | } |
| 1750 | 1750 | } |
| 1751 | 1751 | \ No newline at end of file |
@@ -56,10 +56,10 @@ discard block |
||
| 56 | 56 | protected function _getZappableSleepProps(&$exprops) |
| 57 | 57 | { |
| 58 | 58 | parent::_getZappableSleepProps($exprops); |
| 59 | - if ($this->_d===array()) |
|
| 60 | - $exprops[] = "\0Prado\Collections\TMap\0_d"; |
|
| 61 | - if ($this->_r===false) |
|
| 62 | - $exprops[] = "\0Prado\Collections\TMap\0_r"; |
|
| 59 | + if($this->_d===array()) |
|
| 60 | + $exprops[]="\0Prado\Collections\TMap\0_d"; |
|
| 61 | + if($this->_r===false) |
|
| 62 | + $exprops[]="\0Prado\Collections\TMap\0_r"; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param boolean whether the list is read-only |
| 70 | 70 | * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator. |
| 71 | 71 | */ |
| 72 | - public function __construct($data=null,$readOnly=false) |
|
| 72 | + public function __construct($data=null, $readOnly=false) |
|
| 73 | 73 | { |
| 74 | 74 | if($data!==null) |
| 75 | 75 | $this->copyFrom($data); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function getIterator() |
| 101 | 101 | { |
| 102 | - return new \ArrayIterator( $this->_d ); |
|
| 102 | + return new \ArrayIterator($this->_d); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -146,12 +146,12 @@ discard block |
||
| 146 | 146 | * @param mixed value |
| 147 | 147 | * @throws TInvalidOperationException if the map is read-only |
| 148 | 148 | */ |
| 149 | - public function add($key,$value) |
|
| 149 | + public function add($key, $value) |
|
| 150 | 150 | { |
| 151 | 151 | if(!$this->_r) |
| 152 | 152 | $this->_d[$key]=$value; |
| 153 | 153 | else |
| 154 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
| 154 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | { |
| 165 | 165 | if(!$this->_r) |
| 166 | 166 | { |
| 167 | - if(isset($this->_d[$key]) || array_key_exists($key,$this->_d)) |
|
| 167 | + if(isset($this->_d[$key]) || array_key_exists($key, $this->_d)) |
|
| 168 | 168 | { |
| 169 | 169 | $value=$this->_d[$key]; |
| 170 | 170 | unset($this->_d[$key]); |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | return null; |
| 175 | 175 | } |
| 176 | 176 | else |
| 177 | - throw new TInvalidOperationException('map_readonly',get_class($this)); |
|
| 177 | + throw new TInvalidOperationException('map_readonly', get_class($this)); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public function contains($key) |
| 194 | 194 | { |
| 195 | - return isset($this->_d[$key]) || array_key_exists($key,$this->_d); |
|
| 195 | + return isset($this->_d[$key]) || array_key_exists($key, $this->_d); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | { |
| 214 | 214 | if(is_array($data) || $data instanceof Traversable) |
| 215 | 215 | { |
| 216 | - if($this->getCount()>0) |
|
| 216 | + if($this->getCount() > 0) |
|
| 217 | 217 | $this->clear(); |
| 218 | 218 | foreach($data as $key=>$value) |
| 219 | - $this->add($key,$value); |
|
| 219 | + $this->add($key, $value); |
|
| 220 | 220 | } |
| 221 | 221 | else if($data!==null) |
| 222 | 222 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | if(is_array($data) || $data instanceof Traversable) |
| 234 | 234 | { |
| 235 | 235 | foreach($data as $key=>$value) |
| 236 | - $this->add($key,$value); |
|
| 236 | + $this->add($key, $value); |
|
| 237 | 237 | } |
| 238 | 238 | else if($data!==null) |
| 239 | 239 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
@@ -267,9 +267,9 @@ discard block |
||
| 267 | 267 | * @param integer the offset to set element |
| 268 | 268 | * @param mixed the element value |
| 269 | 269 | */ |
| 270 | - public function offsetSet($offset,$item) |
|
| 270 | + public function offsetSet($offset, $item) |
|
| 271 | 271 | { |
| 272 | - $this->add($offset,$item); |
|
| 272 | + $this->add($offset, $item); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | protected function _getZappableSleepProps(&$exprops) |
| 52 | 52 | { |
| 53 | 53 | parent::_getZappableSleepProps($exprops); |
| 54 | - if ($this->_caseSensitive===false) |
|
| 55 | - $exprops[] = "\0Prado\Collections\TAttributeCollection\0_caseSensitive"; |
|
| 54 | + if($this->_caseSensitive===false) |
|
| 55 | + $exprops[]="\0Prado\Collections\TAttributeCollection\0_caseSensitive"; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function __get($name) |
| 67 | 67 | { |
| 68 | - return $this->contains($name)?$this->itemAt($name):parent::__get($name); |
|
| 68 | + return $this->contains($name) ? $this->itemAt($name) : parent::__get($name); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | * @param mixed the property value or event handler |
| 77 | 77 | * @throws TInvalidOperationException If the property is not defined or read-only. |
| 78 | 78 | */ |
| 79 | - public function __set($name,$value) |
|
| 79 | + public function __set($name, $value) |
|
| 80 | 80 | { |
| 81 | - $this->add($name,$value); |
|
| 81 | + $this->add($name, $value); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function itemAt($key) |
| 107 | 107 | { |
| 108 | - return parent::itemAt($this->_caseSensitive?$key:strtolower($key)); |
|
| 108 | + return parent::itemAt($this->_caseSensitive ? $key : strtolower($key)); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | * @param mixed key |
| 116 | 116 | * @param mixed value |
| 117 | 117 | */ |
| 118 | - public function add($key,$value) |
|
| 118 | + public function add($key, $value) |
|
| 119 | 119 | { |
| 120 | - parent::add($this->_caseSensitive?$key:strtolower($key),$value); |
|
| 120 | + parent::add($this->_caseSensitive ? $key : strtolower($key), $value); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function remove($key) |
| 130 | 130 | { |
| 131 | - return parent::remove($this->_caseSensitive?$key:strtolower($key)); |
|
| 131 | + return parent::remove($this->_caseSensitive ? $key : strtolower($key)); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public function contains($key) |
| 141 | 141 | { |
| 142 | - return parent::contains($this->_caseSensitive?$key:strtolower($key)); |
|
| 142 | + return parent::contains($this->_caseSensitive ? $key : strtolower($key)); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | protected function _getZappableSleepProps(&$exprops) |
| 45 | 45 | { |
| 46 | 46 | parent::_getZappableSleepProps($exprops); |
| 47 | - if ($this->_horizontalAlign===null) |
|
| 48 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableItemStyle\0_horizontalAlign"; |
|
| 49 | - if ($this->_verticalAlign===null) |
|
| 50 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableItemStyle\0_verticalAlign"; |
|
| 51 | - if ($this->_wrap===null) |
|
| 52 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableItemStyle\0_wrap"; |
|
| 47 | + if($this->_horizontalAlign===null) |
|
| 48 | + $exprops[]="\0Prado\Web\UI\WebControls\TTableItemStyle\0_horizontalAlign"; |
|
| 49 | + if($this->_verticalAlign===null) |
|
| 50 | + $exprops[]="\0Prado\Web\UI\WebControls\TTableItemStyle\0_verticalAlign"; |
|
| 51 | + if($this->_wrap===null) |
|
| 52 | + $exprops[]="\0Prado\Web\UI\WebControls\TTableItemStyle\0_wrap"; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | public function addAttributesToRender($writer) |
| 114 | 114 | { |
| 115 | 115 | if(!$this->getWrap()) |
| 116 | - $writer->addStyleAttribute('white-space','nowrap'); |
|
| 116 | + $writer->addStyleAttribute('white-space', 'nowrap'); |
|
| 117 | 117 | |
| 118 | 118 | if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet) |
| 119 | - $writer->addAttribute('align',strtolower($horizontalAlign)); |
|
| 119 | + $writer->addAttribute('align', strtolower($horizontalAlign)); |
|
| 120 | 120 | |
| 121 | 121 | if(($verticalAlign=$this->getVerticalAlign())!==TVerticalAlign::NotSet) |
| 122 | - $writer->addAttribute('valign',strtolower($verticalAlign)); |
|
| 122 | + $writer->addAttribute('valign', strtolower($verticalAlign)); |
|
| 123 | 123 | |
| 124 | 124 | parent::addAttributesToRender($writer); |
| 125 | 125 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function getHorizontalAlign() |
| 131 | 131 | { |
| 132 | - return $this->_horizontalAlign===null?THorizontalAlign::NotSet:$this->_horizontalAlign; |
|
| 132 | + return $this->_horizontalAlign===null ? THorizontalAlign::NotSet : $this->_horizontalAlign; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function setHorizontalAlign($value) |
| 140 | 140 | { |
| 141 | - $this->_horizontalAlign=TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\THorizontalAlign'); |
|
| 141 | + $this->_horizontalAlign=TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\THorizontalAlign'); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function getVerticalAlign() |
| 148 | 148 | { |
| 149 | - return $this->_verticalAlign===null?TVerticalAlign::NotSet:$this->_verticalAlign; |
|
| 149 | + return $this->_verticalAlign===null ? TVerticalAlign::NotSet : $this->_verticalAlign; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function setVerticalAlign($value) |
| 157 | 157 | { |
| 158 | - $this->_verticalAlign=TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TVerticalAlign'); |
|
| 158 | + $this->_verticalAlign=TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TVerticalAlign'); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function getWrap() |
| 165 | 165 | { |
| 166 | - return $this->_wrap===null?true:$this->_wrap; |
|
| 166 | + return $this->_wrap===null ? true : $this->_wrap; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -57,18 +57,18 @@ discard block |
||
| 57 | 57 | protected function _getZappableSleepProps(&$exprops) |
| 58 | 58 | { |
| 59 | 59 | parent::_getZappableSleepProps($exprops); |
| 60 | - if ($this->_backImageUrl===null) |
|
| 61 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_backImageUrl"; |
|
| 62 | - if ($this->_horizontalAlign===null) |
|
| 63 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_horizontalAlign"; |
|
| 64 | - if ($this->_cellPadding===null) |
|
| 65 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_cellPadding"; |
|
| 66 | - if ($this->_cellSpacing===null) |
|
| 67 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_cellSpacing"; |
|
| 68 | - if ($this->_gridLines===null) |
|
| 69 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_gridLines"; |
|
| 70 | - if ($this->_borderCollapse===null) |
|
| 71 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_borderCollapse"; |
|
| 60 | + if($this->_backImageUrl===null) |
|
| 61 | + $exprops[]="\0Prado\Web\UI\WebControls\TTableStyle\0_backImageUrl"; |
|
| 62 | + if($this->_horizontalAlign===null) |
|
| 63 | + $exprops[]="\0Prado\Web\UI\WebControls\TTableStyle\0_horizontalAlign"; |
|
| 64 | + if($this->_cellPadding===null) |
|
| 65 | + $exprops[]="\0Prado\Web\UI\WebControls\TTableStyle\0_cellPadding"; |
|
| 66 | + if($this->_cellSpacing===null) |
|
| 67 | + $exprops[]="\0Prado\Web\UI\WebControls\TTableStyle\0_cellSpacing"; |
|
| 68 | + if($this->_gridLines===null) |
|
| 69 | + $exprops[]="\0Prado\Web\UI\WebControls\TTableStyle\0_gridLines"; |
|
| 70 | + if($this->_borderCollapse===null) |
|
| 71 | + $exprops[]="\0Prado\Web\UI\WebControls\TTableStyle\0_borderCollapse"; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -147,25 +147,25 @@ discard block |
||
| 147 | 147 | public function addAttributesToRender($writer) |
| 148 | 148 | { |
| 149 | 149 | if(($url=trim($this->getBackImageUrl()))!=='') |
| 150 | - $writer->addStyleAttribute('background-image','url('.$url.')'); |
|
| 150 | + $writer->addStyleAttribute('background-image', 'url('.$url.')'); |
|
| 151 | 151 | |
| 152 | 152 | if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet) |
| 153 | - $writer->addStyleAttribute('text-align',strtolower($horizontalAlign)); |
|
| 153 | + $writer->addStyleAttribute('text-align', strtolower($horizontalAlign)); |
|
| 154 | 154 | |
| 155 | - if(($cellPadding=$this->getCellPadding())>=0) |
|
| 156 | - $writer->addAttribute('cellpadding',"$cellPadding"); |
|
| 155 | + if(($cellPadding=$this->getCellPadding()) >= 0) |
|
| 156 | + $writer->addAttribute('cellpadding', "$cellPadding"); |
|
| 157 | 157 | |
| 158 | - if(($cellSpacing=$this->getCellSpacing())>=0) |
|
| 159 | - $writer->addAttribute('cellspacing',"$cellSpacing"); |
|
| 158 | + if(($cellSpacing=$this->getCellSpacing()) >= 0) |
|
| 159 | + $writer->addAttribute('cellspacing', "$cellSpacing"); |
|
| 160 | 160 | |
| 161 | 161 | if($this->getBorderCollapse()) |
| 162 | - $writer->addStyleAttribute('border-collapse','collapse'); |
|
| 162 | + $writer->addStyleAttribute('border-collapse', 'collapse'); |
|
| 163 | 163 | |
| 164 | 164 | switch($this->getGridLines()) |
| 165 | 165 | { |
| 166 | - case TTableGridLines::Horizontal : $writer->addAttribute('rules','rows'); break; |
|
| 167 | - case TTableGridLines::Vertical : $writer->addAttribute('rules','cols'); break; |
|
| 168 | - case TTableGridLines::Both : $writer->addAttribute('rules','all'); break; |
|
| 166 | + case TTableGridLines::Horizontal : $writer->addAttribute('rules', 'rows'); break; |
|
| 167 | + case TTableGridLines::Vertical : $writer->addAttribute('rules', 'cols'); break; |
|
| 168 | + case TTableGridLines::Both : $writer->addAttribute('rules', 'all'); break; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | parent::addAttributesToRender($writer); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function getBackImageUrl() |
| 178 | 178 | { |
| 179 | - return $this->_backImageUrl===null?'':$this->_backImageUrl; |
|
| 179 | + return $this->_backImageUrl===null ? '' : $this->_backImageUrl; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public function getHorizontalAlign() |
| 195 | 195 | { |
| 196 | - return $this->_horizontalAlign===null?THorizontalAlign::NotSet:$this->_horizontalAlign; |
|
| 196 | + return $this->_horizontalAlign===null ? THorizontalAlign::NotSet : $this->_horizontalAlign; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function setHorizontalAlign($value) |
| 204 | 204 | { |
| 205 | - $this->_horizontalAlign=TPropertyValue::ensureEnum($value,'THorizontalAlign'); |
|
| 205 | + $this->_horizontalAlign=TPropertyValue::ensureEnum($value, 'THorizontalAlign'); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | public function getCellPadding() |
| 212 | 212 | { |
| 213 | - return $this->_cellPadding===null?-1:$this->_cellPadding; |
|
| 213 | + return $this->_cellPadding===null ?-1 : $this->_cellPadding; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function setCellPadding($value) |
| 221 | 221 | { |
| 222 | - if(($this->_cellPadding=TPropertyValue::ensureInteger($value))<-1) |
|
| 222 | + if(($this->_cellPadding=TPropertyValue::ensureInteger($value)) < -1) |
|
| 223 | 223 | throw new TInvalidDataValueException('tablestyle_cellpadding_invalid'); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | public function getCellSpacing() |
| 230 | 230 | { |
| 231 | - return $this->_cellSpacing===null?-1:$this->_cellSpacing; |
|
| 231 | + return $this->_cellSpacing===null ?-1 : $this->_cellSpacing; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | /** |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function setCellSpacing($value) |
| 239 | 239 | { |
| 240 | - if(($this->_cellSpacing=TPropertyValue::ensureInteger($value))<-1) |
|
| 240 | + if(($this->_cellSpacing=TPropertyValue::ensureInteger($value)) < -1) |
|
| 241 | 241 | throw new TInvalidDataValueException('tablestyle_cellspacing_invalid'); |
| 242 | 242 | } |
| 243 | 243 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | public function getGridLines() |
| 248 | 248 | { |
| 249 | - return $this->_gridLines===null?TTableGridLines::None:$this->_gridLines; |
|
| 249 | + return $this->_gridLines===null ? TTableGridLines::None : $this->_gridLines; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | */ |
| 256 | 256 | public function setGridLines($value) |
| 257 | 257 | { |
| 258 | - $this->_gridLines=TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TTableGridLines'); |
|
| 258 | + $this->_gridLines=TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TTableGridLines'); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | public function getBorderCollapse() |
| 266 | 266 | { |
| 267 | - return $this->_borderCollapse===null?false:$this->_borderCollapse; |
|
| 267 | + return $this->_borderCollapse===null ? false : $this->_borderCollapse; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 65 | protected function _getZappableSleepProps(&$exprops) |
| 66 | 66 | { |
| 67 | 67 | parent::_getZappableSleepProps($exprops); |
| 68 | - if ($this->_flags===0) |
|
| 69 | - $exprops[] = "\0Prado\Web\UI\WebControls\TFont\0_flags"; |
|
| 70 | - if ($this->_name==='') |
|
| 71 | - $exprops[] = "\0Prado\Web\UI\WebControls\TFont\0_name"; |
|
| 72 | - if ($this->_size==='') |
|
| 73 | - $exprops[] = "\0Prado\Web\UI\WebControls\TFont\0_size"; |
|
| 68 | + if($this->_flags===0) |
|
| 69 | + $exprops[]="\0Prado\Web\UI\WebControls\TFont\0_flags"; |
|
| 70 | + if($this->_name==='') |
|
| 71 | + $exprops[]="\0Prado\Web\UI\WebControls\TFont\0_name"; |
|
| 72 | + if($this->_size==='') |
|
| 73 | + $exprops[]="\0Prado\Web\UI\WebControls\TFont\0_size"; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function setBold($value) |
| 88 | 88 | { |
| 89 | - $this->_flags |= self::IS_SET_BOLD; |
|
| 89 | + $this->_flags|=self::IS_SET_BOLD; |
|
| 90 | 90 | if(TPropertyValue::ensureBoolean($value)) |
| 91 | - $this->_flags |= self::IS_BOLD; |
|
| 91 | + $this->_flags|=self::IS_BOLD; |
|
| 92 | 92 | else |
| 93 | - $this->_flags &= ~self::IS_BOLD; |
|
| 93 | + $this->_flags&=~self::IS_BOLD; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function setItalic($value) |
| 108 | 108 | { |
| 109 | - $this->_flags |= self::IS_SET_ITALIC; |
|
| 109 | + $this->_flags|=self::IS_SET_ITALIC; |
|
| 110 | 110 | if(TPropertyValue::ensureBoolean($value)) |
| 111 | - $this->_flags |= self::IS_ITALIC; |
|
| 111 | + $this->_flags|=self::IS_ITALIC; |
|
| 112 | 112 | else |
| 113 | - $this->_flags &= ~self::IS_ITALIC; |
|
| 113 | + $this->_flags&=~self::IS_ITALIC; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -126,11 +126,11 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function setOverline($value) |
| 128 | 128 | { |
| 129 | - $this->_flags |= self::IS_SET_OVERLINE; |
|
| 129 | + $this->_flags|=self::IS_SET_OVERLINE; |
|
| 130 | 130 | if(TPropertyValue::ensureBoolean($value)) |
| 131 | - $this->_flags |= self::IS_OVERLINE; |
|
| 131 | + $this->_flags|=self::IS_OVERLINE; |
|
| 132 | 132 | else |
| 133 | - $this->_flags &= ~self::IS_OVERLINE; |
|
| 133 | + $this->_flags&=~self::IS_OVERLINE; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function setSize($value) |
| 148 | 148 | { |
| 149 | - $this->_flags |= self::IS_SET_SIZE; |
|
| 149 | + $this->_flags|=self::IS_SET_SIZE; |
|
| 150 | 150 | $this->_size=$value; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function setStrikeout($value) |
| 165 | 165 | { |
| 166 | - $this->_flags |= self::IS_SET_STRIKEOUT; |
|
| 166 | + $this->_flags|=self::IS_SET_STRIKEOUT; |
|
| 167 | 167 | if(TPropertyValue::ensureBoolean($value)) |
| 168 | - $this->_flags |= self::IS_STRIKEOUT; |
|
| 168 | + $this->_flags|=self::IS_STRIKEOUT; |
|
| 169 | 169 | else |
| 170 | - $this->_flags &= ~self::IS_STRIKEOUT; |
|
| 170 | + $this->_flags&=~self::IS_STRIKEOUT; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function setUnderline($value) |
| 185 | 185 | { |
| 186 | - $this->_flags |= self::IS_SET_UNDERLINE; |
|
| 186 | + $this->_flags|=self::IS_SET_UNDERLINE; |
|
| 187 | 187 | if(TPropertyValue::ensureBoolean($value)) |
| 188 | - $this->_flags |= self::IS_UNDERLINE; |
|
| 188 | + $this->_flags|=self::IS_UNDERLINE; |
|
| 189 | 189 | else |
| 190 | - $this->_flags &= ~self::IS_UNDERLINE; |
|
| 190 | + $this->_flags&=~self::IS_UNDERLINE; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public function setName($value) |
| 205 | 205 | { |
| 206 | - $this->_flags |= self::IS_SET_NAME; |
|
| 206 | + $this->_flags|=self::IS_SET_NAME; |
|
| 207 | 207 | $this->_name=$value; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -286,9 +286,9 @@ discard block |
||
| 286 | 286 | return ''; |
| 287 | 287 | $str=''; |
| 288 | 288 | if($this->_flags & self::IS_SET_BOLD) |
| 289 | - $str.='font-weight:'.(($this->_flags & self::IS_BOLD)?'bold;':'normal;'); |
|
| 289 | + $str.='font-weight:'.(($this->_flags & self::IS_BOLD) ? 'bold;' : 'normal;'); |
|
| 290 | 290 | if($this->_flags & self::IS_SET_ITALIC) |
| 291 | - $str.='font-style:'.(($this->_flags & self::IS_ITALIC)?'italic;':'normal;'); |
|
| 291 | + $str.='font-style:'.(($this->_flags & self::IS_ITALIC) ? 'italic;' : 'normal;'); |
|
| 292 | 292 | $textDec=''; |
| 293 | 293 | if($this->_flags & self::IS_UNDERLINE) |
| 294 | 294 | $textDec.='underline'; |
@@ -315,9 +315,9 @@ discard block |
||
| 315 | 315 | if($this->_flags===0) |
| 316 | 316 | return; |
| 317 | 317 | if($this->_flags & self::IS_SET_BOLD) |
| 318 | - $writer->addStyleAttribute('font-weight',(($this->_flags & self::IS_BOLD)?'bold':'normal')); |
|
| 318 | + $writer->addStyleAttribute('font-weight', (($this->_flags & self::IS_BOLD) ? 'bold' : 'normal')); |
|
| 319 | 319 | if($this->_flags & self::IS_SET_ITALIC) |
| 320 | - $writer->addStyleAttribute('font-style',(($this->_flags & self::IS_ITALIC)?'italic':'normal')); |
|
| 320 | + $writer->addStyleAttribute('font-style', (($this->_flags & self::IS_ITALIC) ? 'italic' : 'normal')); |
|
| 321 | 321 | $textDec=''; |
| 322 | 322 | if($this->_flags & self::IS_UNDERLINE) |
| 323 | 323 | $textDec.='underline'; |
@@ -327,10 +327,10 @@ discard block |
||
| 327 | 327 | $textDec.=' line-through'; |
| 328 | 328 | $textDec=ltrim($textDec); |
| 329 | 329 | if($textDec!=='') |
| 330 | - $writer->addStyleAttribute('text-decoration',$textDec); |
|
| 330 | + $writer->addStyleAttribute('text-decoration', $textDec); |
|
| 331 | 331 | if($this->_size!=='') |
| 332 | - $writer->addStyleAttribute('font-size',$this->_size); |
|
| 332 | + $writer->addStyleAttribute('font-size', $this->_size); |
|
| 333 | 333 | if($this->_name!=='') |
| 334 | - $writer->addStyleAttribute('font-family',$this->_name); |
|
| 334 | + $writer->addStyleAttribute('font-family', $this->_name); |
|
| 335 | 335 | } |
| 336 | 336 | } |
@@ -53,16 +53,16 @@ discard block |
||
| 53 | 53 | protected function _getZappableSleepProps(&$exprops) |
| 54 | 54 | { |
| 55 | 55 | parent::_getZappableSleepProps($exprops); |
| 56 | - if ($this->_fields===array()) |
|
| 57 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_fields"; |
|
| 56 | + if($this->_fields===array()) |
|
| 57 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_fields"; |
|
| 58 | 58 | if($this->_font===null) |
| 59 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_font"; |
|
| 59 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_font"; |
|
| 60 | 60 | if($this->_class===null) |
| 61 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_class"; |
|
| 62 | - if ($this->_customStyle===null) |
|
| 63 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_customStyle"; |
|
| 64 | - if ($this->_displayStyle==='Fixed') |
|
| 65 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_displayStyle"; |
|
| 61 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_class"; |
|
| 62 | + if($this->_customStyle===null) |
|
| 63 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_customStyle"; |
|
| 64 | + if($this->_displayStyle==='Fixed') |
|
| 65 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_displayStyle"; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | public function __clone() |
| 83 | 83 | { |
| 84 | 84 | if($this->_font!==null) |
| 85 | - $this->_font = clone($this->_font); |
|
| 85 | + $this->_font=clone($this->_font); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function getBackColor() |
| 92 | 92 | { |
| 93 | - return isset($this->_fields['background-color'])?$this->_fields['background-color']:''; |
|
| 93 | + return isset($this->_fields['background-color']) ? $this->_fields['background-color'] : ''; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function getBorderColor() |
| 111 | 111 | { |
| 112 | - return isset($this->_fields['border-color'])?$this->_fields['border-color']:''; |
|
| 112 | + return isset($this->_fields['border-color']) ? $this->_fields['border-color'] : ''; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function getBorderStyle() |
| 130 | 130 | { |
| 131 | - return isset($this->_fields['border-style'])?$this->_fields['border-style']:''; |
|
| 131 | + return isset($this->_fields['border-style']) ? $this->_fields['border-style'] : ''; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function getBorderWidth() |
| 150 | 150 | { |
| 151 | - return isset($this->_fields['border-width'])?$this->_fields['border-width']:''; |
|
| 151 | + return isset($this->_fields['border-width']) ? $this->_fields['border-width'] : ''; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | public function getCssClass() |
| 169 | 169 | { |
| 170 | - return $this->_class===null?'':$this->_class; |
|
| 170 | + return $this->_class===null ? '' : $this->_class; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | public function hasFont() |
| 203 | 203 | { |
| 204 | - return $this->_font !== null; |
|
| 204 | + return $this->_font!==null; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -209,20 +209,20 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | public function setDisplayStyle($value) |
| 211 | 211 | { |
| 212 | - $this->_displayStyle = TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TDisplayStyle'); |
|
| 212 | + $this->_displayStyle=TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TDisplayStyle'); |
|
| 213 | 213 | switch($this->_displayStyle) |
| 214 | 214 | { |
| 215 | 215 | case TDisplayStyle::None: |
| 216 | - $this->_fields['display'] = 'none'; |
|
| 216 | + $this->_fields['display']='none'; |
|
| 217 | 217 | break; |
| 218 | 218 | case TDisplayStyle::Dynamic: |
| 219 | - $this->_fields['display'] = ''; //remove the display property |
|
| 219 | + $this->_fields['display']=''; //remove the display property |
|
| 220 | 220 | break; |
| 221 | 221 | case TDisplayStyle::Fixed: |
| 222 | - $this->_fields['visibility'] = 'visible'; |
|
| 222 | + $this->_fields['visibility']='visible'; |
|
| 223 | 223 | break; |
| 224 | 224 | case TDisplayStyle::Hidden: |
| 225 | - $this->_fields['visibility'] = 'hidden'; |
|
| 225 | + $this->_fields['visibility']='hidden'; |
|
| 226 | 226 | break; |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | public function getForeColor() |
| 242 | 242 | { |
| 243 | - return isset($this->_fields['color'])?$this->_fields['color']:''; |
|
| 243 | + return isset($this->_fields['color']) ? $this->_fields['color'] : ''; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | public function getHeight() |
| 261 | 261 | { |
| 262 | - return isset($this->_fields['height'])?$this->_fields['height']:''; |
|
| 262 | + return isset($this->_fields['height']) ? $this->_fields['height'] : ''; |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | public function getCustomStyle() |
| 280 | 280 | { |
| 281 | - return $this->_customStyle===null?'':$this->_customStyle; |
|
| 281 | + return $this->_customStyle===null ? '' : $this->_customStyle; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | public function getStyleField($name) |
| 298 | 298 | { |
| 299 | - return isset($this->_fields[$name])?$this->_fields[$name]:''; |
|
| 299 | + return isset($this->_fields[$name]) ? $this->_fields[$name] : ''; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | * @param string style field name |
| 306 | 306 | * @param string style field value |
| 307 | 307 | */ |
| 308 | - public function setStyleField($name,$value) |
|
| 308 | + public function setStyleField($name, $value) |
|
| 309 | 309 | { |
| 310 | 310 | $this->_fields[$name]=$value; |
| 311 | 311 | } |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | public function getWidth() |
| 334 | 334 | { |
| 335 | - return isset($this->_fields['width'])?$this->_fields['width']:''; |
|
| 335 | + return isset($this->_fields['width']) ? $this->_fields['width'] : ''; |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | { |
| 365 | 365 | if($style instanceof TStyle) |
| 366 | 366 | { |
| 367 | - $this->_fields=array_merge($this->_fields,$style->_fields); |
|
| 367 | + $this->_fields=array_merge($this->_fields, $style->_fields); |
|
| 368 | 368 | if($style->_class!==null) |
| 369 | 369 | $this->_class=$style->_class; |
| 370 | 370 | if($style->_customStyle!==null) |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | { |
| 385 | 385 | if($style instanceof TStyle) |
| 386 | 386 | { |
| 387 | - $this->_fields=array_merge($style->_fields,$this->_fields); |
|
| 387 | + $this->_fields=array_merge($style->_fields, $this->_fields); |
|
| 388 | 388 | if($this->_class===null) |
| 389 | 389 | $this->_class=$style->_class; |
| 390 | 390 | if($this->_customStyle===null) |
@@ -402,18 +402,18 @@ discard block |
||
| 402 | 402 | { |
| 403 | 403 | if($this->_customStyle!==null) |
| 404 | 404 | { |
| 405 | - foreach(explode(';',$this->_customStyle) as $style) |
|
| 405 | + foreach(explode(';', $this->_customStyle) as $style) |
|
| 406 | 406 | { |
| 407 | - $arr=explode(':',$style,2); |
|
| 407 | + $arr=explode(':', $style, 2); |
|
| 408 | 408 | if(isset($arr[1]) && trim($arr[0])!=='') |
| 409 | - $writer->addStyleAttribute(trim($arr[0]),trim($arr[1])); |
|
| 409 | + $writer->addStyleAttribute(trim($arr[0]), trim($arr[1])); |
|
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | $writer->addStyleAttributes($this->_fields); |
| 413 | 413 | if($this->_font!==null) |
| 414 | 414 | $this->_font->addAttributesToRender($writer); |
| 415 | 415 | if($this->_class!==null) |
| 416 | - $writer->addAttribute('class',$this->_class); |
|
| 416 | + $writer->addAttribute('class', $this->_class); |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | /** |
@@ -52,16 +52,16 @@ discard block |
||
| 52 | 52 | protected function _getZappableSleepProps(&$exprops) |
| 53 | 53 | { |
| 54 | 54 | parent::_getZappableSleepProps($exprops); |
| 55 | - if ($this->_backImageUrl===null) |
|
| 56 | - $exprops[] = "\0Prado\Web\UI\WebControls\TPanelStyle\0_backImageUrl"; |
|
| 57 | - if ($this->_direction===null) |
|
| 58 | - $exprops[] = "\0Prado\Web\UI\WebControls\TPanelStyle\0_direction"; |
|
| 59 | - if ($this->_horizontalAlign===null) |
|
| 60 | - $exprops[] = "\0Prado\Web\UI\WebControls\TPanelStyle\0_horizontalAlign"; |
|
| 61 | - if ($this->_scrollBars===null) |
|
| 62 | - $exprops[] = "\0Prado\Web\UI\WebControls\TPanelStyle\0_scrollBars"; |
|
| 63 | - if ($this->_wrap===null) |
|
| 64 | - $exprops[] = "\0Prado\Web\UI\WebControls\TPanelStyle\0_wrap"; |
|
| 55 | + if($this->_backImageUrl===null) |
|
| 56 | + $exprops[]="\0Prado\Web\UI\WebControls\TPanelStyle\0_backImageUrl"; |
|
| 57 | + if($this->_direction===null) |
|
| 58 | + $exprops[]="\0Prado\Web\UI\WebControls\TPanelStyle\0_direction"; |
|
| 59 | + if($this->_horizontalAlign===null) |
|
| 60 | + $exprops[]="\0Prado\Web\UI\WebControls\TPanelStyle\0_horizontalAlign"; |
|
| 61 | + if($this->_scrollBars===null) |
|
| 62 | + $exprops[]="\0Prado\Web\UI\WebControls\TPanelStyle\0_scrollBars"; |
|
| 63 | + if($this->_wrap===null) |
|
| 64 | + $exprops[]="\0Prado\Web\UI\WebControls\TPanelStyle\0_wrap"; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -72,28 +72,28 @@ discard block |
||
| 72 | 72 | public function addAttributesToRender($writer) |
| 73 | 73 | { |
| 74 | 74 | if(($url=trim($this->getBackImageUrl()))!=='') |
| 75 | - $this->setStyleField('background-image','url('.$url.')'); |
|
| 75 | + $this->setStyleField('background-image', 'url('.$url.')'); |
|
| 76 | 76 | |
| 77 | 77 | switch($this->getScrollBars()) |
| 78 | 78 | { |
| 79 | - case TScrollBars::Horizontal: $this->setStyleField('overflow-x','scroll'); break; |
|
| 80 | - case TScrollBars::Vertical: $this->setStyleField('overflow-y','scroll'); break; |
|
| 81 | - case TScrollBars::Both: $this->setStyleField('overflow','scroll'); break; |
|
| 82 | - case TScrollBars::Auto: $this->setStyleField('overflow','auto'); break; |
|
| 79 | + case TScrollBars::Horizontal: $this->setStyleField('overflow-x', 'scroll'); break; |
|
| 80 | + case TScrollBars::Vertical: $this->setStyleField('overflow-y', 'scroll'); break; |
|
| 81 | + case TScrollBars::Both: $this->setStyleField('overflow', 'scroll'); break; |
|
| 82 | + case TScrollBars::Auto: $this->setStyleField('overflow', 'auto'); break; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | if(($align=$this->getHorizontalAlign())!==THorizontalAlign::NotSet) |
| 86 | - $this->setStyleField('text-align',strtolower($align)); |
|
| 86 | + $this->setStyleField('text-align', strtolower($align)); |
|
| 87 | 87 | |
| 88 | 88 | if(!$this->getWrap()) |
| 89 | - $this->setStyleField('white-space','nowrap'); |
|
| 89 | + $this->setStyleField('white-space', 'nowrap'); |
|
| 90 | 90 | |
| 91 | 91 | if(($direction=$this->getDirection())!==TContentDirection::NotSet) |
| 92 | 92 | { |
| 93 | 93 | if($direction===TContentDirection::LeftToRight) |
| 94 | - $this->setStyleField('direction','ltr'); |
|
| 94 | + $this->setStyleField('direction', 'ltr'); |
|
| 95 | 95 | else |
| 96 | - $this->setStyleField('direction','rtl'); |
|
| 96 | + $this->setStyleField('direction', 'rtl'); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | parent::addAttributesToRender($writer); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function getBackImageUrl() |
| 106 | 106 | { |
| 107 | - return $this->_backImageUrl===null?'':$this->_backImageUrl; |
|
| 107 | + return $this->_backImageUrl===null ? '' : $this->_backImageUrl; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function getDirection() |
| 123 | 123 | { |
| 124 | - return $this->_direction===null?TContentDirection::NotSet:$this->_direction; |
|
| 124 | + return $this->_direction===null ? TContentDirection::NotSet : $this->_direction; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function setDirection($value) |
| 131 | 131 | { |
| 132 | - $this->_direction=TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TContentDirection'); |
|
| 132 | + $this->_direction=TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TContentDirection'); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function getWrap() |
| 139 | 139 | { |
| 140 | - return $this->_wrap===null?true:$this->_wrap; |
|
| 140 | + return $this->_wrap===null ? true : $this->_wrap; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function getHorizontalAlign() |
| 156 | 156 | { |
| 157 | - return $this->_horizontalAlign===null?THorizontalAlign::NotSet:$this->_horizontalAlign; |
|
| 157 | + return $this->_horizontalAlign===null ? THorizontalAlign::NotSet : $this->_horizontalAlign; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function setHorizontalAlign($value) |
| 165 | 165 | { |
| 166 | - $this->_horizontalAlign=TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\THorizontalAlign'); |
|
| 166 | + $this->_horizontalAlign=TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\THorizontalAlign'); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function getScrollBars() |
| 173 | 173 | { |
| 174 | - return $this->_scrollBars===null?TScrollBars::None:$this->_scrollBars; |
|
| 174 | + return $this->_scrollBars===null ? TScrollBars::None : $this->_scrollBars; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function setScrollBars($value) |
| 181 | 181 | { |
| 182 | - $this->_scrollBars=TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TScrollBars'); |
|
| 182 | + $this->_scrollBars=TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TScrollBars'); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |