@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param boolean whether this template is a source template, i.e., this template is loaded from |
| 122 | 122 | * some external storage rather than from within another template. |
| 123 | 123 | */ |
| 124 | - public function __construct($template,$contextPath,$tplFile=null,$startingLine=0,$sourceTemplate=true) |
|
| 124 | + public function __construct($template, $contextPath, $tplFile=null, $startingLine=0, $sourceTemplate=true) |
|
| 125 | 125 | { |
| 126 | 126 | $this->_sourceTemplate=$sourceTemplate; |
| 127 | 127 | $this->_contextPath=$contextPath; |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @param TControl the control who owns the template |
| 190 | 190 | * @param TControl the control who will become the root parent of the controls on the template. If null, it uses the template control. |
| 191 | 191 | */ |
| 192 | - public function instantiateIn($tplControl,$parentControl=null) |
|
| 192 | + public function instantiateIn($tplControl, $parentControl=null) |
|
| 193 | 193 | { |
| 194 | 194 | $this->_tplControl=$tplControl; |
| 195 | 195 | if($parentControl===null) |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | { |
| 220 | 220 | if(is_array($properties['id'])) |
| 221 | 221 | $properties['id']=$component->evaluateExpression($properties['id'][1]); |
| 222 | - $tplControl->registerObject($properties['id'],$component); |
|
| 222 | + $tplControl->registerObject($properties['id'], $component); |
|
| 223 | 223 | } |
| 224 | 224 | if(isset($properties['skinid'])) |
| 225 | 225 | { |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | $component->applyStyleSheetSkin($page); |
| 236 | 236 | foreach($properties as $name=>$value) |
| 237 | - $this->configureControl($component,$name,$value); |
|
| 237 | + $this->configureControl($component, $name, $value); |
|
| 238 | 238 | |
| 239 | 239 | $component->trackViewState(true); |
| 240 | 240 | |
@@ -252,12 +252,12 @@ discard block |
||
| 252 | 252 | { |
| 253 | 253 | if(is_array($properties['id'])) |
| 254 | 254 | $properties['id']=$component->evaluateExpression($properties['id'][1]); |
| 255 | - $tplControl->registerObject($properties['id'],$component); |
|
| 255 | + $tplControl->registerObject($properties['id'], $component); |
|
| 256 | 256 | if(!$component->hasProperty('id')) |
| 257 | 257 | unset($properties['id']); |
| 258 | 258 | } |
| 259 | 259 | foreach($properties as $name=>$value) |
| 260 | - $this->configureComponent($component,$name,$value); |
|
| 260 | + $this->configureComponent($component, $name, $value); |
|
| 261 | 261 | if($parent===$parentControl) |
| 262 | 262 | $directChildren[]=$component; |
| 263 | 263 | else |
@@ -303,14 +303,14 @@ discard block |
||
| 303 | 303 | * @param string property name |
| 304 | 304 | * @param mixed property initial value |
| 305 | 305 | */ |
| 306 | - protected function configureControl($control,$name,$value) |
|
| 306 | + protected function configureControl($control, $name, $value) |
|
| 307 | 307 | { |
| 308 | - if(strncasecmp($name,'on',2)===0) // is an event |
|
| 309 | - $this->configureEvent($control,$name,$value,$control); |
|
| 310 | - else if(($pos=strrpos($name,'.'))===false) // is a simple property or custom attribute |
|
| 311 | - $this->configureProperty($control,$name,$value); |
|
| 308 | + if(strncasecmp($name, 'on', 2)===0) // is an event |
|
| 309 | + $this->configureEvent($control, $name, $value, $control); |
|
| 310 | + else if(($pos=strrpos($name, '.'))===false) // is a simple property or custom attribute |
|
| 311 | + $this->configureProperty($control, $name, $value); |
|
| 312 | 312 | else // is a subproperty |
| 313 | - $this->configureSubProperty($control,$name,$value); |
|
| 313 | + $this->configureSubProperty($control, $name, $value); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -319,12 +319,12 @@ discard block |
||
| 319 | 319 | * @param string property name |
| 320 | 320 | * @param mixed property initial value |
| 321 | 321 | */ |
| 322 | - protected function configureComponent($component,$name,$value) |
|
| 322 | + protected function configureComponent($component, $name, $value) |
|
| 323 | 323 | { |
| 324 | - if(strpos($name,'.')===false) // is a simple property or custom attribute |
|
| 325 | - $this->configureProperty($component,$name,$value); |
|
| 324 | + if(strpos($name, '.')===false) // is a simple property or custom attribute |
|
| 325 | + $this->configureProperty($component, $name, $value); |
|
| 326 | 326 | else // is a subproperty |
| 327 | - $this->configureSubProperty($component,$name,$value); |
|
| 327 | + $this->configureSubProperty($component, $name, $value); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -334,12 +334,12 @@ discard block |
||
| 334 | 334 | * @param string event handler |
| 335 | 335 | * @param TControl context control |
| 336 | 336 | */ |
| 337 | - protected function configureEvent($control,$name,$value,$contextControl) |
|
| 337 | + protected function configureEvent($control, $name, $value, $contextControl) |
|
| 338 | 338 | { |
| 339 | - if(strpos($value,'.')===false) |
|
| 340 | - $control->attachEventHandler($name,array($contextControl,'TemplateControl.'.$value)); |
|
| 339 | + if(strpos($value, '.')===false) |
|
| 340 | + $control->attachEventHandler($name, array($contextControl, 'TemplateControl.'.$value)); |
|
| 341 | 341 | else |
| 342 | - $control->attachEventHandler($name,array($contextControl,$value)); |
|
| 342 | + $control->attachEventHandler($name, array($contextControl, $value)); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | /** |
@@ -348,18 +348,18 @@ discard block |
||
| 348 | 348 | * @param string property name |
| 349 | 349 | * @param mixed property initial value |
| 350 | 350 | */ |
| 351 | - protected function configureProperty($component,$name,$value) |
|
| 351 | + protected function configureProperty($component, $name, $value) |
|
| 352 | 352 | { |
| 353 | 353 | if(is_array($value)) |
| 354 | 354 | { |
| 355 | 355 | switch($value[0]) |
| 356 | 356 | { |
| 357 | 357 | case self::CONFIG_DATABIND: |
| 358 | - $component->bindProperty($name,$value[1]); |
|
| 358 | + $component->bindProperty($name, $value[1]); |
|
| 359 | 359 | break; |
| 360 | 360 | case self::CONFIG_EXPRESSION: |
| 361 | 361 | if($component instanceof TControl) |
| 362 | - $component->autoBindProperty($name,$value[1]); |
|
| 362 | + $component->autoBindProperty($name, $value[1]); |
|
| 363 | 363 | else |
| 364 | 364 | { |
| 365 | 365 | $setter='set'.$name; |
@@ -384,15 +384,15 @@ discard block |
||
| 384 | 384 | $component->$setter(Prado::localize($value[1])); |
| 385 | 385 | break; |
| 386 | 386 | default: // an error if reaching here |
| 387 | - throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
|
| 387 | + throw new TConfigurationException('template_tag_unexpected', $name, $value[1]); |
|
| 388 | 388 | break; |
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | 391 | else |
| 392 | 392 | { |
| 393 | - if (substr($name,0,2)=='js') |
|
| 394 | - if ($value and !($value instanceof TJavaScriptLiteral)) |
|
| 395 | - $value = new TJavaScriptLiteral($value); |
|
| 393 | + if(substr($name, 0, 2)=='js') |
|
| 394 | + if($value and !($value instanceof TJavaScriptLiteral)) |
|
| 395 | + $value=new TJavaScriptLiteral($value); |
|
| 396 | 396 | $setter='set'.$name; |
| 397 | 397 | $component->$setter($value); |
| 398 | 398 | } |
@@ -404,41 +404,41 @@ discard block |
||
| 404 | 404 | * @param string subproperty name |
| 405 | 405 | * @param mixed subproperty initial value |
| 406 | 406 | */ |
| 407 | - protected function configureSubProperty($component,$name,$value) |
|
| 407 | + protected function configureSubProperty($component, $name, $value) |
|
| 408 | 408 | { |
| 409 | 409 | if(is_array($value)) |
| 410 | 410 | { |
| 411 | 411 | switch($value[0]) |
| 412 | 412 | { |
| 413 | 413 | case self::CONFIG_DATABIND: // databinding |
| 414 | - $component->bindProperty($name,$value[1]); |
|
| 414 | + $component->bindProperty($name, $value[1]); |
|
| 415 | 415 | break; |
| 416 | 416 | case self::CONFIG_EXPRESSION: // expression |
| 417 | 417 | if($component instanceof TControl) |
| 418 | - $component->autoBindProperty($name,$value[1]); |
|
| 418 | + $component->autoBindProperty($name, $value[1]); |
|
| 419 | 419 | else |
| 420 | - $component->setSubProperty($name,$this->_tplControl->evaluateExpression($value[1])); |
|
| 420 | + $component->setSubProperty($name, $this->_tplControl->evaluateExpression($value[1])); |
|
| 421 | 421 | break; |
| 422 | 422 | case self::CONFIG_TEMPLATE: |
| 423 | - $component->setSubProperty($name,$value[1]); |
|
| 423 | + $component->setSubProperty($name, $value[1]); |
|
| 424 | 424 | break; |
| 425 | 425 | case self::CONFIG_ASSET: // asset URL |
| 426 | 426 | $url=$this->publishFilePath($this->_contextPath.DIRECTORY_SEPARATOR.$value[1]); |
| 427 | - $component->setSubProperty($name,$url); |
|
| 427 | + $component->setSubProperty($name, $url); |
|
| 428 | 428 | break; |
| 429 | 429 | case self::CONFIG_PARAMETER: // application parameter |
| 430 | - $component->setSubProperty($name,$this->getApplication()->getParameters()->itemAt($value[1])); |
|
| 430 | + $component->setSubProperty($name, $this->getApplication()->getParameters()->itemAt($value[1])); |
|
| 431 | 431 | break; |
| 432 | 432 | case self::CONFIG_LOCALIZATION: |
| 433 | - $component->setSubProperty($name,Prado::localize($value[1])); |
|
| 433 | + $component->setSubProperty($name, Prado::localize($value[1])); |
|
| 434 | 434 | break; |
| 435 | 435 | default: // an error if reaching here |
| 436 | - throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
|
| 436 | + throw new TConfigurationException('template_tag_unexpected', $name, $value[1]); |
|
| 437 | 437 | break; |
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | else |
| 441 | - $component->setSubProperty($name,$value); |
|
| 441 | + $component->setSubProperty($name, $value); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | /** |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | { |
| 467 | 467 | $input=$this->preprocess($input); |
| 468 | 468 | $tpl=&$this->_tpl; |
| 469 | - $n=preg_match_all(self::REGEX_RULES,$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE); |
|
| 469 | + $n=preg_match_all(self::REGEX_RULES, $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); |
|
| 470 | 470 | $expectPropEnd=false; |
| 471 | 471 | $textStart=0; |
| 472 | 472 | $stack=array(); |
@@ -476,176 +476,176 @@ discard block |
||
| 476 | 476 | $this->_directive=null; |
| 477 | 477 | //try |
| 478 | 478 | { |
| 479 | - for($i=0;$i<$n;++$i) |
|
| 479 | + for($i=0; $i < $n; ++$i) |
|
| 480 | 480 | { |
| 481 | 481 | $match=&$matches[$i]; |
| 482 | 482 | $str=$match[0][0]; |
| 483 | 483 | $matchStart=$match[0][1]; |
| 484 | - $matchEnd=$matchStart+strlen($str)-1; |
|
| 485 | - if(strpos($str,'<com:')===0) // opening component tag |
|
| 484 | + $matchEnd=$matchStart + strlen($str) - 1; |
|
| 485 | + if(strpos($str, '<com:')===0) // opening component tag |
|
| 486 | 486 | { |
| 487 | 487 | if($expectPropEnd) |
| 488 | 488 | continue; |
| 489 | - if($matchStart>$textStart) |
|
| 490 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 491 | - $textStart=$matchEnd+1; |
|
| 489 | + if($matchStart > $textStart) |
|
| 490 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 491 | + $textStart=$matchEnd + 1; |
|
| 492 | 492 | $type=$match[1][0]; |
| 493 | - $attributes=$this->parseAttributes($match[2][0],$match[2][1]); |
|
| 494 | - $class=$this->validateAttributes($type,$attributes); |
|
| 495 | - $tpl[$c++]=array($container,$class,$attributes); |
|
| 496 | - if($str[strlen($str)-2]!=='/') // open tag |
|
| 493 | + $attributes=$this->parseAttributes($match[2][0], $match[2][1]); |
|
| 494 | + $class=$this->validateAttributes($type, $attributes); |
|
| 495 | + $tpl[$c++]=array($container, $class, $attributes); |
|
| 496 | + if($str[strlen($str) - 2]!=='/') // open tag |
|
| 497 | 497 | { |
| 498 | - $stack[] = $type; |
|
| 499 | - $container=$c-1; |
|
| 498 | + $stack[]=$type; |
|
| 499 | + $container=$c - 1; |
|
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | - else if(strpos($str,'</com:')===0) // closing component tag |
|
| 502 | + else if(strpos($str, '</com:')===0) // closing component tag |
|
| 503 | 503 | { |
| 504 | 504 | if($expectPropEnd) |
| 505 | 505 | continue; |
| 506 | - if($matchStart>$textStart) |
|
| 507 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 508 | - $textStart=$matchEnd+1; |
|
| 506 | + if($matchStart > $textStart) |
|
| 507 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 508 | + $textStart=$matchEnd + 1; |
|
| 509 | 509 | $type=$match[1][0]; |
| 510 | 510 | |
| 511 | 511 | if(empty($stack)) |
| 512 | - throw new TConfigurationException('template_closingtag_unexpected',"</com:$type>"); |
|
| 512 | + throw new TConfigurationException('template_closingtag_unexpected', "</com:$type>"); |
|
| 513 | 513 | |
| 514 | 514 | $name=array_pop($stack); |
| 515 | 515 | if($name!==$type) |
| 516 | 516 | { |
| 517 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
| 518 | - throw new TConfigurationException('template_closingtag_expected',$tag); |
|
| 517 | + $tag=$name[0]==='@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>"; |
|
| 518 | + throw new TConfigurationException('template_closingtag_expected', $tag); |
|
| 519 | 519 | } |
| 520 | 520 | $container=$tpl[$container][0]; |
| 521 | 521 | } |
| 522 | - else if(strpos($str,'<%@')===0) // directive |
|
| 522 | + else if(strpos($str, '<%@')===0) // directive |
|
| 523 | 523 | { |
| 524 | 524 | if($expectPropEnd) |
| 525 | 525 | continue; |
| 526 | - if($matchStart>$textStart) |
|
| 527 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 528 | - $textStart=$matchEnd+1; |
|
| 526 | + if($matchStart > $textStart) |
|
| 527 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 528 | + $textStart=$matchEnd + 1; |
|
| 529 | 529 | if(isset($tpl[0]) || $this->_directive!==null) |
| 530 | 530 | throw new TConfigurationException('template_directive_nonunique'); |
| 531 | - $this->_directive=$this->parseAttributes($match[4][0],$match[4][1]); |
|
| 531 | + $this->_directive=$this->parseAttributes($match[4][0], $match[4][1]); |
|
| 532 | 532 | } |
| 533 | - else if(strpos($str,'<%')===0) // expression |
|
| 533 | + else if(strpos($str, '<%')===0) // expression |
|
| 534 | 534 | { |
| 535 | 535 | if($expectPropEnd) |
| 536 | 536 | continue; |
| 537 | - if($matchStart>$textStart) |
|
| 538 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 539 | - $textStart=$matchEnd+1; |
|
| 537 | + if($matchStart > $textStart) |
|
| 538 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 539 | + $textStart=$matchEnd + 1; |
|
| 540 | 540 | $literal=trim($match[5][0]); |
| 541 | 541 | if($str[2]==='=') // expression |
| 542 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,$literal)); |
|
| 542 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, $literal)); |
|
| 543 | 543 | else if($str[2]==='%') // statements |
| 544 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_STATEMENTS,$literal)); |
|
| 544 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_STATEMENTS, $literal)); |
|
| 545 | 545 | else if($str[2]==='#') |
| 546 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_DATABINDING,$literal)); |
|
| 546 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_DATABINDING, $literal)); |
|
| 547 | 547 | else if($str[2]==='$') |
| 548 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')")); |
|
| 548 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->getApplication()->getParameters()->itemAt('$literal')")); |
|
| 549 | 549 | else if($str[2]==='~') |
| 550 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')")); |
|
| 550 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->publishFilePath('$this->_contextPath/$literal')")); |
|
| 551 | 551 | else if($str[2]==='/') |
| 552 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'")); |
|
| 552 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'")); |
|
| 553 | 553 | else if($str[2]==='[') |
| 554 | 554 | { |
| 555 | - $literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\")); |
|
| 556 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')")); |
|
| 555 | + $literal=strtr(trim(substr($literal, 0, strlen($literal) - 1)), array("'"=>"\'", "\\"=>"\\\\")); |
|
| 556 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "Prado::localize('$literal')")); |
|
| 557 | 557 | } |
| 558 | 558 | } |
| 559 | - else if(strpos($str,'<prop:')===0) // opening property |
|
| 559 | + else if(strpos($str, '<prop:')===0) // opening property |
|
| 560 | 560 | { |
| 561 | - if(strrpos($str,'/>')===strlen($str)-2) //subproperties |
|
| 561 | + if(strrpos($str, '/>')===strlen($str) - 2) //subproperties |
|
| 562 | 562 | { |
| 563 | 563 | if($expectPropEnd) |
| 564 | 564 | continue; |
| 565 | - if($matchStart>$textStart) |
|
| 566 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 567 | - $textStart=$matchEnd+1; |
|
| 565 | + if($matchStart > $textStart) |
|
| 566 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 567 | + $textStart=$matchEnd + 1; |
|
| 568 | 568 | $prop=strtolower($match[6][0]); |
| 569 | - $attrs=$this->parseAttributes($match[7][0],$match[7][1]); |
|
| 569 | + $attrs=$this->parseAttributes($match[7][0], $match[7][1]); |
|
| 570 | 570 | $attributes=array(); |
| 571 | 571 | foreach($attrs as $name=>$value) |
| 572 | 572 | $attributes[$prop.'.'.$name]=$value; |
| 573 | 573 | $type=$tpl[$container][1]; |
| 574 | - $this->validateAttributes($type,$attributes); |
|
| 574 | + $this->validateAttributes($type, $attributes); |
|
| 575 | 575 | foreach($attributes as $name=>$value) |
| 576 | 576 | { |
| 577 | 577 | if(isset($tpl[$container][2][$name])) |
| 578 | - throw new TConfigurationException('template_property_duplicated',$name); |
|
| 578 | + throw new TConfigurationException('template_property_duplicated', $name); |
|
| 579 | 579 | $tpl[$container][2][$name]=$value; |
| 580 | 580 | } |
| 581 | 581 | } |
| 582 | 582 | else // regular property |
| 583 | 583 | { |
| 584 | 584 | $prop=strtolower($match[3][0]); |
| 585 | - $stack[] = '@'.$prop; |
|
| 585 | + $stack[]='@'.$prop; |
|
| 586 | 586 | if(!$expectPropEnd) |
| 587 | 587 | { |
| 588 | - if($matchStart>$textStart) |
|
| 589 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 590 | - $textStart=$matchEnd+1; |
|
| 588 | + if($matchStart > $textStart) |
|
| 589 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 590 | + $textStart=$matchEnd + 1; |
|
| 591 | 591 | $expectPropEnd=true; |
| 592 | 592 | } |
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | - else if(strpos($str,'</prop:')===0) // closing property |
|
| 595 | + else if(strpos($str, '</prop:')===0) // closing property |
|
| 596 | 596 | { |
| 597 | 597 | $prop=strtolower($match[3][0]); |
| 598 | 598 | if(empty($stack)) |
| 599 | - throw new TConfigurationException('template_closingtag_unexpected',"</prop:$prop>"); |
|
| 599 | + throw new TConfigurationException('template_closingtag_unexpected', "</prop:$prop>"); |
|
| 600 | 600 | $name=array_pop($stack); |
| 601 | 601 | if($name!=='@'.$prop) |
| 602 | 602 | { |
| 603 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
| 604 | - throw new TConfigurationException('template_closingtag_expected',$tag); |
|
| 603 | + $tag=$name[0]==='@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>"; |
|
| 604 | + throw new TConfigurationException('template_closingtag_expected', $tag); |
|
| 605 | 605 | } |
| 606 | - if(($last=count($stack))<1 || $stack[$last-1][0]!=='@') |
|
| 606 | + if(($last=count($stack)) < 1 || $stack[$last - 1][0]!=='@') |
|
| 607 | 607 | { |
| 608 | - if($matchStart>$textStart) |
|
| 608 | + if($matchStart > $textStart) |
|
| 609 | 609 | { |
| 610 | - $value=substr($input,$textStart,$matchStart-$textStart); |
|
| 611 | - if(substr($prop,-8,8)==='template') |
|
| 612 | - $value=$this->parseTemplateProperty($value,$textStart); |
|
| 610 | + $value=substr($input, $textStart, $matchStart - $textStart); |
|
| 611 | + if(substr($prop, -8, 8)==='template') |
|
| 612 | + $value=$this->parseTemplateProperty($value, $textStart); |
|
| 613 | 613 | else |
| 614 | 614 | $value=$this->parseAttribute($value); |
| 615 | - if($container>=0) |
|
| 615 | + if($container >= 0) |
|
| 616 | 616 | { |
| 617 | 617 | $type=$tpl[$container][1]; |
| 618 | - $this->validateAttributes($type,array($prop=>$value)); |
|
| 618 | + $this->validateAttributes($type, array($prop=>$value)); |
|
| 619 | 619 | if(isset($tpl[$container][2][$prop])) |
| 620 | - throw new TConfigurationException('template_property_duplicated',$prop); |
|
| 620 | + throw new TConfigurationException('template_property_duplicated', $prop); |
|
| 621 | 621 | $tpl[$container][2][$prop]=$value; |
| 622 | 622 | } |
| 623 | 623 | else // a property for the template control |
| 624 | 624 | $this->_directive[$prop]=$value; |
| 625 | - $textStart=$matchEnd+1; |
|
| 625 | + $textStart=$matchEnd + 1; |
|
| 626 | 626 | } |
| 627 | 627 | $expectPropEnd=false; |
| 628 | 628 | } |
| 629 | 629 | } |
| 630 | - else if(strpos($str,'<!--')===0) // comments |
|
| 630 | + else if(strpos($str, '<!--')===0) // comments |
|
| 631 | 631 | { |
| 632 | 632 | if($expectPropEnd) |
| 633 | 633 | throw new TConfigurationException('template_comments_forbidden'); |
| 634 | - if($matchStart>$textStart) |
|
| 635 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
| 636 | - $textStart=$matchEnd+1; |
|
| 634 | + if($matchStart > $textStart) |
|
| 635 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
| 636 | + $textStart=$matchEnd + 1; |
|
| 637 | 637 | } |
| 638 | 638 | else |
| 639 | - throw new TConfigurationException('template_matching_unexpected',$match); |
|
| 639 | + throw new TConfigurationException('template_matching_unexpected', $match); |
|
| 640 | 640 | } |
| 641 | 641 | if(!empty($stack)) |
| 642 | 642 | { |
| 643 | 643 | $name=array_pop($stack); |
| 644 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
| 645 | - throw new TConfigurationException('template_closingtag_expected',$tag); |
|
| 644 | + $tag=$name[0]==='@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>"; |
|
| 645 | + throw new TConfigurationException('template_closingtag_expected', $tag); |
|
| 646 | 646 | } |
| 647 | - if($textStart<strlen($input)) |
|
| 648 | - $tpl[$c++]=array($container,substr($input,$textStart)); |
|
| 647 | + if($textStart < strlen($input)) |
|
| 648 | + $tpl[$c++]=array($container, substr($input, $textStart)); |
|
| 649 | 649 | } |
| 650 | 650 | /* |
| 651 | 651 | catch(\Exception $e) |
@@ -673,9 +673,9 @@ discard block |
||
| 673 | 673 | if($parent!==null) |
| 674 | 674 | { |
| 675 | 675 | if(count($merged[1])===1 && is_string($merged[1][0])) |
| 676 | - $objects[$id-1]=array($merged[0],$merged[1][0]); |
|
| 676 | + $objects[$id - 1]=array($merged[0], $merged[1][0]); |
|
| 677 | 677 | else |
| 678 | - $objects[$id-1]=array($merged[0],new TCompositeLiteral($merged[1])); |
|
| 678 | + $objects[$id - 1]=array($merged[0], new TCompositeLiteral($merged[1])); |
|
| 679 | 679 | } |
| 680 | 680 | if(isset($object[2])) |
| 681 | 681 | { |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | else |
| 686 | 686 | { |
| 687 | 687 | $parent=$object[0]; |
| 688 | - $merged=array($parent,array($object[1])); |
|
| 688 | + $merged=array($parent, array($object[1])); |
|
| 689 | 689 | } |
| 690 | 690 | } |
| 691 | 691 | else |
@@ -694,9 +694,9 @@ discard block |
||
| 694 | 694 | if($parent!==null) |
| 695 | 695 | { |
| 696 | 696 | if(count($merged[1])===1 && is_string($merged[1][0])) |
| 697 | - $objects[$id]=array($merged[0],$merged[1][0]); |
|
| 697 | + $objects[$id]=array($merged[0], $merged[1][0]); |
|
| 698 | 698 | else |
| 699 | - $objects[$id]=array($merged[0],new TCompositeLiteral($merged[1])); |
|
| 699 | + $objects[$id]=array($merged[0], new TCompositeLiteral($merged[1])); |
|
| 700 | 700 | } |
| 701 | 701 | $tpl=$objects; |
| 702 | 702 | return $objects; |
@@ -707,31 +707,31 @@ discard block |
||
| 707 | 707 | * @param string the string to be parsed. |
| 708 | 708 | * @return array attribute values indexed by names. |
| 709 | 709 | */ |
| 710 | - protected function parseAttributes($str,$offset) |
|
| 710 | + protected function parseAttributes($str, $offset) |
|
| 711 | 711 | { |
| 712 | 712 | if($str==='') |
| 713 | 713 | return array(); |
| 714 | 714 | $pattern='/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS'; |
| 715 | 715 | $attributes=array(); |
| 716 | - $n=preg_match_all($pattern,$str,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE); |
|
| 717 | - for($i=0;$i<$n;++$i) |
|
| 716 | + $n=preg_match_all($pattern, $str, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); |
|
| 717 | + for($i=0; $i < $n; ++$i) |
|
| 718 | 718 | { |
| 719 | 719 | $match=&$matches[$i]; |
| 720 | 720 | $name=strtolower($match[1][0]); |
| 721 | 721 | if(isset($attributes[$name])) |
| 722 | - throw new TConfigurationException('template_property_duplicated',$name); |
|
| 722 | + throw new TConfigurationException('template_property_duplicated', $name); |
|
| 723 | 723 | $value=$match[2][0]; |
| 724 | - if(substr($name,-8,8)==='template') |
|
| 724 | + if(substr($name, -8, 8)==='template') |
|
| 725 | 725 | { |
| 726 | 726 | if($value[0]==='\'' || $value[0]==='"') |
| 727 | - $attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1); |
|
| 727 | + $attributes[$name]=$this->parseTemplateProperty(substr($value, 1, strlen($value) - 2), $match[2][1] + 1); |
|
| 728 | 728 | else |
| 729 | - $attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]); |
|
| 729 | + $attributes[$name]=$this->parseTemplateProperty($value, $match[2][1]); |
|
| 730 | 730 | } |
| 731 | 731 | else |
| 732 | 732 | { |
| 733 | 733 | if($value[0]==='\'' || $value[0]==='"') |
| 734 | - $attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2)); |
|
| 734 | + $attributes[$name]=$this->parseAttribute(substr($value, 1, strlen($value) - 2)); |
|
| 735 | 735 | else |
| 736 | 736 | $attributes[$name]=$this->parseAttribute($value); |
| 737 | 737 | } |
@@ -739,10 +739,10 @@ discard block |
||
| 739 | 739 | return $attributes; |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - protected function parseTemplateProperty($content,$offset) |
|
| 742 | + protected function parseTemplateProperty($content, $offset) |
|
| 743 | 743 | { |
| 744 | - $line=$this->_startingLine+count(explode("\n",substr($this->_content,0,$offset)))-1; |
|
| 745 | - return array(self::CONFIG_TEMPLATE,new TTemplate($content,$this->_contextPath,$this->_tplFile,$line,false)); |
|
| 744 | + $line=$this->_startingLine + count(explode("\n", substr($this->_content, 0, $offset))) - 1; |
|
| 745 | + return array(self::CONFIG_TEMPLATE, new TTemplate($content, $this->_contextPath, $this->_tplFile, $line, false)); |
|
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | /** |
@@ -752,12 +752,12 @@ discard block |
||
| 752 | 752 | */ |
| 753 | 753 | protected function parseAttribute($value) |
| 754 | 754 | { |
| 755 | - if(($n=preg_match_all('/<%[#=].*?%>/msS',$value,$matches,PREG_OFFSET_CAPTURE))>0) |
|
| 755 | + if(($n=preg_match_all('/<%[#=].*?%>/msS', $value, $matches, PREG_OFFSET_CAPTURE)) > 0) |
|
| 756 | 756 | { |
| 757 | 757 | $isDataBind=false; |
| 758 | 758 | $textStart=0; |
| 759 | 759 | $expr=''; |
| 760 | - for($i=0;$i<$n;++$i) |
|
| 760 | + for($i=0; $i < $n; ++$i) |
|
| 761 | 761 | { |
| 762 | 762 | $match=$matches[0][$i]; |
| 763 | 763 | $token=$match[0]; |
@@ -765,114 +765,114 @@ discard block |
||
| 765 | 765 | $length=strlen($token); |
| 766 | 766 | if($token[2]==='#') |
| 767 | 767 | $isDataBind=true; |
| 768 | - if($offset>$textStart) |
|
| 769 | - $expr.=".'".strtr(substr($value,$textStart,$offset-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'"; |
|
| 770 | - $expr.='.('.substr($token,3,$length-5).')'; |
|
| 771 | - $textStart=$offset+$length; |
|
| 768 | + if($offset > $textStart) |
|
| 769 | + $expr.=".'".strtr(substr($value, $textStart, $offset - $textStart), array("'"=>"\\'", "\\"=>"\\\\"))."'"; |
|
| 770 | + $expr.='.('.substr($token, 3, $length - 5).')'; |
|
| 771 | + $textStart=$offset + $length; |
|
| 772 | 772 | } |
| 773 | 773 | $length=strlen($value); |
| 774 | - if($length>$textStart) |
|
| 775 | - $expr.=".'".strtr(substr($value,$textStart,$length-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'"; |
|
| 774 | + if($length > $textStart) |
|
| 775 | + $expr.=".'".strtr(substr($value, $textStart, $length - $textStart), array("'"=>"\\'", "\\"=>"\\\\"))."'"; |
|
| 776 | 776 | if($isDataBind) |
| 777 | - return array(self::CONFIG_DATABIND,ltrim($expr,'.')); |
|
| 777 | + return array(self::CONFIG_DATABIND, ltrim($expr, '.')); |
|
| 778 | 778 | else |
| 779 | - return array(self::CONFIG_EXPRESSION,ltrim($expr,'.')); |
|
| 779 | + return array(self::CONFIG_EXPRESSION, ltrim($expr, '.')); |
|
| 780 | 780 | } |
| 781 | - else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value) |
|
| 781 | + else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0]===$value) |
|
| 782 | 782 | { |
| 783 | 783 | $value=$matches[1]; |
| 784 | 784 | if($value[2]==='~') |
| 785 | - return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5))); |
|
| 785 | + return array(self::CONFIG_ASSET, trim(substr($value, 3, strlen($value) - 5))); |
|
| 786 | 786 | elseif($value[2]==='[') |
| 787 | - return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6))); |
|
| 787 | + return array(self::CONFIG_LOCALIZATION, trim(substr($value, 3, strlen($value) - 6))); |
|
| 788 | 788 | elseif($value[2]==='$') |
| 789 | - return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5))); |
|
| 789 | + return array(self::CONFIG_PARAMETER, trim(substr($value, 3, strlen($value) - 5))); |
|
| 790 | 790 | elseif($value[2]==='/') { |
| 791 | - $literal = trim(substr($value,3,strlen($value)-5)); |
|
| 792 | - return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"); |
|
| 791 | + $literal=trim(substr($value, 3, strlen($value) - 5)); |
|
| 792 | + return array(self::CONFIG_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"); |
|
| 793 | 793 | } |
| 794 | 794 | } |
| 795 | 795 | else |
| 796 | 796 | return $value; |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | - protected function validateAttributes($type,$attributes) |
|
| 799 | + protected function validateAttributes($type, $attributes) |
|
| 800 | 800 | { |
| 801 | 801 | Prado::using($type); |
| 802 | - if(($pos=strrpos($type,'.'))!==false) |
|
| 803 | - $className=substr($type,$pos+1); |
|
| 802 | + if(($pos=strrpos($type, '.'))!==false) |
|
| 803 | + $className=substr($type, $pos + 1); |
|
| 804 | 804 | else |
| 805 | 805 | $className=$type; |
| 806 | 806 | $class=new \ReflectionClass($className); |
| 807 | - if(is_subclass_of($className,'\Prado\Web\UI\TControl') || $className==='\Prado\Web\UI\TControl') |
|
| 807 | + if(is_subclass_of($className, '\Prado\Web\UI\TControl') || $className==='\Prado\Web\UI\TControl') |
|
| 808 | 808 | { |
| 809 | 809 | foreach($attributes as $name=>$att) |
| 810 | 810 | { |
| 811 | - if(($pos=strpos($name,'.'))!==false) |
|
| 811 | + if(($pos=strpos($name, '.'))!==false) |
|
| 812 | 812 | { |
| 813 | 813 | // a subproperty, so the first segment must be readable |
| 814 | - $subname=substr($name,0,$pos); |
|
| 814 | + $subname=substr($name, 0, $pos); |
|
| 815 | 815 | if(!$class->hasMethod('get'.$subname)) |
| 816 | - throw new TConfigurationException('template_property_unknown',$type,$subname); |
|
| 816 | + throw new TConfigurationException('template_property_unknown', $type, $subname); |
|
| 817 | 817 | } |
| 818 | - else if(strncasecmp($name,'on',2)===0) |
|
| 818 | + else if(strncasecmp($name, 'on', 2)===0) |
|
| 819 | 819 | { |
| 820 | 820 | // an event |
| 821 | 821 | if(!$class->hasMethod($name)) |
| 822 | - throw new TConfigurationException('template_event_unknown',$type,$name); |
|
| 822 | + throw new TConfigurationException('template_event_unknown', $type, $name); |
|
| 823 | 823 | else if(!is_string($att)) |
| 824 | - throw new TConfigurationException('template_eventhandler_invalid',$type,$name); |
|
| 824 | + throw new TConfigurationException('template_eventhandler_invalid', $type, $name); |
|
| 825 | 825 | } |
| 826 | 826 | else |
| 827 | 827 | { |
| 828 | 828 | // a simple property |
| 829 | - if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)) ) |
|
| 829 | + if(!($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class, 'set'.$name))) |
|
| 830 | 830 | { |
| 831 | - if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name)) |
|
| 832 | - throw new TConfigurationException('template_property_readonly',$type,$name); |
|
| 831 | + if($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name)) |
|
| 832 | + throw new TConfigurationException('template_property_readonly', $type, $name); |
|
| 833 | 833 | else |
| 834 | - throw new TConfigurationException('template_property_unknown',$type,$name); |
|
| 834 | + throw new TConfigurationException('template_property_unknown', $type, $name); |
|
| 835 | 835 | } |
| 836 | 836 | else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION) |
| 837 | 837 | { |
| 838 | - if(strcasecmp($name,'id')===0) |
|
| 839 | - throw new TConfigurationException('template_controlid_invalid',$type); |
|
| 840 | - else if(strcasecmp($name,'skinid')===0) |
|
| 841 | - throw new TConfigurationException('template_controlskinid_invalid',$type); |
|
| 838 | + if(strcasecmp($name, 'id')===0) |
|
| 839 | + throw new TConfigurationException('template_controlid_invalid', $type); |
|
| 840 | + else if(strcasecmp($name, 'skinid')===0) |
|
| 841 | + throw new TConfigurationException('template_controlskinid_invalid', $type); |
|
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | } |
| 845 | 845 | } |
| 846 | - else if(is_subclass_of($className,'\Prado\TComponent') || $className==='\Prado\TComponent') |
|
| 846 | + else if(is_subclass_of($className, '\Prado\TComponent') || $className==='\Prado\TComponent') |
|
| 847 | 847 | { |
| 848 | 848 | foreach($attributes as $name=>$att) |
| 849 | 849 | { |
| 850 | 850 | if(is_array($att) && ($att[0]===self::CONFIG_DATABIND)) |
| 851 | - throw new TConfigurationException('template_databind_forbidden',$type,$name); |
|
| 852 | - if(($pos=strpos($name,'.'))!==false) |
|
| 851 | + throw new TConfigurationException('template_databind_forbidden', $type, $name); |
|
| 852 | + if(($pos=strpos($name, '.'))!==false) |
|
| 853 | 853 | { |
| 854 | 854 | // a subproperty, so the first segment must be readable |
| 855 | - $subname=substr($name,0,$pos); |
|
| 855 | + $subname=substr($name, 0, $pos); |
|
| 856 | 856 | if(!$class->hasMethod('get'.$subname)) |
| 857 | - throw new TConfigurationException('template_property_unknown',$type,$subname); |
|
| 857 | + throw new TConfigurationException('template_property_unknown', $type, $subname); |
|
| 858 | 858 | } |
| 859 | - else if(strncasecmp($name,'on',2)===0) |
|
| 860 | - throw new TConfigurationException('template_event_forbidden',$type,$name); |
|
| 859 | + else if(strncasecmp($name, 'on', 2)===0) |
|
| 860 | + throw new TConfigurationException('template_event_forbidden', $type, $name); |
|
| 861 | 861 | else |
| 862 | 862 | { |
| 863 | 863 | // id is still alowed for TComponent, even if id property doesn't exist |
| 864 | - if(strcasecmp($name,'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class,'set'.$name))) |
|
| 864 | + if(strcasecmp($name, 'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class, 'set'.$name))) |
|
| 865 | 865 | { |
| 866 | 866 | if($class->hasMethod('get'.$name)) |
| 867 | - throw new TConfigurationException('template_property_readonly',$type,$name); |
|
| 867 | + throw new TConfigurationException('template_property_readonly', $type, $name); |
|
| 868 | 868 | else |
| 869 | - throw new TConfigurationException('template_property_unknown',$type,$name); |
|
| 869 | + throw new TConfigurationException('template_property_unknown', $type, $name); |
|
| 870 | 870 | } |
| 871 | 871 | } |
| 872 | 872 | } |
| 873 | 873 | } |
| 874 | 874 | else |
| 875 | - throw new TConfigurationException('template_component_required',$type); |
|
| 875 | + throw new TConfigurationException('template_component_required', $type); |
|
| 876 | 876 | return $class->getName(); |
| 877 | 877 | } |
| 878 | 878 | |
@@ -892,28 +892,28 @@ discard block |
||
| 892 | 892 | * @param int line number |
| 893 | 893 | * @param string template string if no source file is used |
| 894 | 894 | */ |
| 895 | - protected function handleException($e,$line,$input=null) |
|
| 895 | + protected function handleException($e, $line, $input=null) |
|
| 896 | 896 | { |
| 897 | 897 | $srcFile=$this->_tplFile; |
| 898 | 898 | |
| 899 | - if(($n=count($this->_includedFiles))>0) // need to adjust error row number and file name |
|
| 899 | + if(($n=count($this->_includedFiles)) > 0) // need to adjust error row number and file name |
|
| 900 | 900 | { |
| 901 | - for($i=$n-1;$i>=0;--$i) |
|
| 901 | + for($i=$n - 1; $i >= 0; --$i) |
|
| 902 | 902 | { |
| 903 | - if($this->_includeAtLine[$i]<=$line) |
|
| 903 | + if($this->_includeAtLine[$i] <= $line) |
|
| 904 | 904 | { |
| 905 | - if($line<$this->_includeAtLine[$i]+$this->_includeLines[$i]) |
|
| 905 | + if($line < $this->_includeAtLine[$i] + $this->_includeLines[$i]) |
|
| 906 | 906 | { |
| 907 | - $line=$line-$this->_includeAtLine[$i]+1; |
|
| 907 | + $line=$line - $this->_includeAtLine[$i] + 1; |
|
| 908 | 908 | $srcFile=$this->_includedFiles[$i]; |
| 909 | 909 | break; |
| 910 | 910 | } |
| 911 | 911 | else |
| 912 | - $line=$line-$this->_includeLines[$i]+1; |
|
| 912 | + $line=$line - $this->_includeLines[$i] + 1; |
|
| 913 | 913 | } |
| 914 | 914 | } |
| 915 | 915 | } |
| 916 | - $exception=new TTemplateException('template_format_invalid',$e->getMessage()); |
|
| 916 | + $exception=new TTemplateException('template_format_invalid', $e->getMessage()); |
|
| 917 | 917 | $exception->setLineNumber($line); |
| 918 | 918 | if(!empty($srcFile)) |
| 919 | 919 | $exception->setTemplateFile($srcFile); |
@@ -929,29 +929,29 @@ discard block |
||
| 929 | 929 | */ |
| 930 | 930 | protected function preprocess($input) |
| 931 | 931 | { |
| 932 | - if($n=preg_match_all('/<%include(.*?)%>/',$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE)) |
|
| 932 | + if($n=preg_match_all('/<%include(.*?)%>/', $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) |
|
| 933 | 933 | { |
| 934 | - for($i=0;$i<$n;++$i) |
|
| 934 | + for($i=0; $i < $n; ++$i) |
|
| 935 | 935 | { |
| 936 | - $filePath=Prado::getPathOfNamespace(trim($matches[$i][1][0]),TTemplateManager::TEMPLATE_FILE_EXT); |
|
| 936 | + $filePath=Prado::getPathOfNamespace(trim($matches[$i][1][0]), TTemplateManager::TEMPLATE_FILE_EXT); |
|
| 937 | 937 | if($filePath!==null && is_file($filePath)) |
| 938 | 938 | $this->_includedFiles[]=$filePath; |
| 939 | 939 | else |
| 940 | 940 | { |
| 941 | - $errorLine=count(explode("\n",substr($input,0,$matches[$i][0][1]+1))); |
|
| 942 | - $this->handleException(new TConfigurationException('template_include_invalid',trim($matches[$i][1][0])),$errorLine,$input); |
|
| 941 | + $errorLine=count(explode("\n", substr($input, 0, $matches[$i][0][1] + 1))); |
|
| 942 | + $this->handleException(new TConfigurationException('template_include_invalid', trim($matches[$i][1][0])), $errorLine, $input); |
|
| 943 | 943 | } |
| 944 | 944 | } |
| 945 | 945 | $base=0; |
| 946 | - for($i=0;$i<$n;++$i) |
|
| 946 | + for($i=0; $i < $n; ++$i) |
|
| 947 | 947 | { |
| 948 | 948 | $ext=file_get_contents($this->_includedFiles[$i]); |
| 949 | 949 | $length=strlen($matches[$i][0][0]); |
| 950 | - $offset=$base+$matches[$i][0][1]; |
|
| 951 | - $this->_includeAtLine[$i]=count(explode("\n",substr($input,0,$offset))); |
|
| 952 | - $this->_includeLines[$i]=count(explode("\n",$ext)); |
|
| 953 | - $input=substr_replace($input,$ext,$offset,$length); |
|
| 954 | - $base+=strlen($ext)-$length; |
|
| 950 | + $offset=$base + $matches[$i][0][1]; |
|
| 951 | + $this->_includeAtLine[$i]=count(explode("\n", substr($input, 0, $offset))); |
|
| 952 | + $this->_includeLines[$i]=count(explode("\n", $ext)); |
|
| 953 | + $input=substr_replace($input, $ext, $offset, $length); |
|
| 954 | + $base+=strlen($ext) - $length; |
|
| 955 | 955 | } |
| 956 | 956 | } |
| 957 | 957 | |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | * @param string $method |
| 965 | 965 | * @return boolean |
| 966 | 966 | */ |
| 967 | - protected function isClassBehaviorMethod(\ReflectionClass $class,$method) |
|
| 967 | + protected function isClassBehaviorMethod(\ReflectionClass $class, $method) |
|
| 968 | 968 | { |
| 969 | 969 | $component=new \ReflectionClass('\Prado\TComponent'); |
| 970 | 970 | $behaviors=$component->getStaticProperties(); |
@@ -975,7 +975,7 @@ discard block |
||
| 975 | 975 | if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue; |
| 976 | 976 | foreach($list as $param) |
| 977 | 977 | { |
| 978 | - if(method_exists($param->getBehavior(),$method)) |
|
| 978 | + if(method_exists($param->getBehavior(), $method)) |
|
| 979 | 979 | return true; |
| 980 | 980 | } |
| 981 | 981 | } |