@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | { |
30 | 30 | if(isset($node['class'])) |
31 | 31 | { |
32 | - $obj = Prado::createComponent((string)$node['class']); |
|
33 | - $this->setObjectPropFromNode($obj,$node,array('class')); |
|
32 | + $obj=Prado::createComponent((string) $node['class']); |
|
33 | + $this->setObjectPropFromNode($obj, $node, array('class')); |
|
34 | 34 | return $obj; |
35 | 35 | } |
36 | 36 | throw new TSqlMapConfigurationException( |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | * @param SimpleXmlNode property node |
46 | 46 | * @param array exception property name |
47 | 47 | */ |
48 | - protected function setObjectPropFromNode($obj,$node,$except=array()) |
|
48 | + protected function setObjectPropFromNode($obj, $node, $except=array()) |
|
49 | 49 | { |
50 | 50 | foreach($node->attributes() as $name=>$value) |
51 | 51 | { |
52 | - if(!in_array($name,$except)) |
|
52 | + if(!in_array($name, $except)) |
|
53 | 53 | { |
54 | 54 | if($obj->canSetProperty($name)) |
55 | - $obj->{$name} = (string)$value; |
|
55 | + $obj->{$name}=(string) $value; |
|
56 | 56 | else |
57 | 57 | throw new TSqlMapConfigurationException( |
58 | 58 | 'sqlmap_invalid_property', $name, get_class($obj), |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | * @param string relative filename |
68 | 68 | * @return string absolute filename. |
69 | 69 | */ |
70 | - protected function getAbsoluteFilePath($basefile,$resource) |
|
70 | + protected function getAbsoluteFilePath($basefile, $resource) |
|
71 | 71 | { |
72 | - $basedir = dirname($basefile); |
|
73 | - $file = realpath($basedir.DIRECTORY_SEPARATOR.$resource); |
|
72 | + $basedir=dirname($basefile); |
|
73 | + $file=realpath($basedir.DIRECTORY_SEPARATOR.$resource); |
|
74 | 74 | if(!is_string($file) || !is_file($file)) |
75 | - $file = realpath($resource); |
|
75 | + $file=realpath($resource); |
|
76 | 76 | if(is_string($file) && is_file($file)) |
77 | 77 | return $file; |
78 | 78 | else |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | * @param string filename. |
86 | 86 | * @return SimpleXmlElement xml document. |
87 | 87 | */ |
88 | - protected function loadXmlDocument($filename,TSqlMapXmlConfiguration $config) |
|
88 | + protected function loadXmlDocument($filename, TSqlMapXmlConfiguration $config) |
|
89 | 89 | { |
90 | - if( strpos($filename, '${') !== false) |
|
91 | - $filename = $config->replaceProperties($filename); |
|
90 | + if(strpos($filename, '${')!==false) |
|
91 | + $filename=$config->replaceProperties($filename); |
|
92 | 92 | |
93 | 93 | if(!is_file($filename)) |
94 | 94 | throw new TSqlMapConfigurationException( |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | protected function getElementByIdValue($document, $tag, $value) |
107 | 107 | { |
108 | 108 | //hack to allow upper case and lower case attribute names. |
109 | - foreach(array('id','ID','Id', 'iD') as $id) |
|
109 | + foreach(array('id', 'ID', 'Id', 'iD') as $id) |
|
110 | 110 | { |
111 | - $xpath = "//{$tag}[@{$id}='{$value}']"; |
|
111 | + $xpath="//{$tag}[@{$id}='{$value}']"; |
|
112 | 112 | foreach($document->xpath($xpath) as $node) |
113 | 113 | return $node; |
114 | 114 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | public function configure($filename=null) |
170 | 170 | { |
171 | 171 | $this->_configFile=$filename; |
172 | - $document = $this->loadXmlDocument($filename,$this); |
|
172 | + $document=$this->loadXmlDocument($filename, $this); |
|
173 | 173 | |
174 | 174 | foreach($document->xpath('//property') as $property) |
175 | 175 | $this->loadGlobalProperty($property); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $this->loadDatabaseConnection($conn); |
182 | 182 | |
183 | 183 | //try to load configuration in the current config file. |
184 | - $mapping = new TSqlMapXmlMappingConfiguration($this); |
|
184 | + $mapping=new TSqlMapXmlMappingConfiguration($this); |
|
185 | 185 | $mapping->configure($filename); |
186 | 186 | |
187 | 187 | foreach($document->xpath('//sqlMap') as $sqlmap) |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | protected function loadGlobalProperty($node) |
199 | 199 | { |
200 | - $this->_properties[(string)$node['name']] = (string)$node['value']; |
|
200 | + $this->_properties[(string) $node['name']]=(string) $node['value']; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | protected function loadTypeHandler($node) |
208 | 208 | { |
209 | - $handler = $this->createObjectFromNode($node); |
|
209 | + $handler=$this->createObjectFromNode($node); |
|
210 | 210 | $this->_manager->getTypeHandlers()->registerTypeHandler($handler); |
211 | 211 | } |
212 | 212 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | protected function loadDatabaseConnection($node) |
218 | 218 | { |
219 | - $conn = $this->createObjectFromNode($node); |
|
219 | + $conn=$this->createObjectFromNode($node); |
|
220 | 220 | $this->_manager->setDbConnection($conn); |
221 | 221 | } |
222 | 222 | |
@@ -226,13 +226,13 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function loadSqlMappingFiles($node) |
228 | 228 | { |
229 | - if(strlen($resource = (string)$node['resource']) > 0) |
|
229 | + if(strlen($resource=(string) $node['resource']) > 0) |
|
230 | 230 | { |
231 | - if( strpos($resource, '${') !== false) |
|
232 | - $resource = $this->replaceProperties($resource); |
|
231 | + if(strpos($resource, '${')!==false) |
|
232 | + $resource=$this->replaceProperties($resource); |
|
233 | 233 | |
234 | - $mapping = new TSqlMapXmlMappingConfiguration($this); |
|
235 | - $filename = $this->getAbsoluteFilePath($this->_configFile, $resource); |
|
234 | + $mapping=new TSqlMapXmlMappingConfiguration($this); |
|
235 | + $filename=$this->getAbsoluteFilePath($this->_configFile, $resource); |
|
236 | 236 | $mapping->configure($filename); |
237 | 237 | } |
238 | 238 | } |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | */ |
243 | 243 | protected function resolveResultMapping() |
244 | 244 | { |
245 | - $maps = $this->_manager->getResultMaps(); |
|
245 | + $maps=$this->_manager->getResultMaps(); |
|
246 | 246 | foreach($maps as $entry) |
247 | 247 | { |
248 | 248 | foreach($entry->getColumns() as $item) |
249 | 249 | { |
250 | - $resultMap = $item->getResultMapping(); |
|
250 | + $resultMap=$item->getResultMapping(); |
|
251 | 251 | if(strlen($resultMap) > 0) |
252 | 252 | { |
253 | 253 | if($maps->contains($resultMap)) |
@@ -270,9 +270,9 @@ discard block |
||
270 | 270 | { |
271 | 271 | foreach($this->_manager->getMappedStatements() as $mappedStatement) |
272 | 272 | { |
273 | - if(strlen($model = $mappedStatement->getStatement()->getCacheModel()) > 0) |
|
273 | + if(strlen($model=$mappedStatement->getStatement()->getCacheModel()) > 0) |
|
274 | 274 | { |
275 | - $cache = $this->_manager->getCacheModel($model); |
|
275 | + $cache=$this->_manager->getCacheModel($model); |
|
276 | 276 | $mappedStatement->getStatement()->setCache($cache); |
277 | 277 | } |
278 | 278 | } |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | public function replaceProperties($string) |
288 | 288 | { |
289 | 289 | foreach($this->_properties as $find => $replace) |
290 | - $string = str_replace('${'.$find.'}', $replace, $string); |
|
290 | + $string=str_replace('${'.$find.'}', $replace, $string); |
|
291 | 291 | return $string; |
292 | 292 | } |
293 | 293 | } |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | public function configure($filename) |
343 | 343 | { |
344 | 344 | $this->_configFile=$filename; |
345 | - $document = $this->loadXmlDocument($filename,$this->_xmlConfig); |
|
345 | + $document=$this->loadXmlDocument($filename, $this->_xmlConfig); |
|
346 | 346 | $this->_document=$document; |
347 | 347 | |
348 | 348 | static $bCacheDependencies; |
349 | - if($bCacheDependencies === null) |
|
350 | - $bCacheDependencies = true; //Prado::getApplication()->getMode() !== TApplicationMode::Performance; |
|
349 | + if($bCacheDependencies===null) |
|
350 | + $bCacheDependencies=true; //Prado::getApplication()->getMode() !== TApplicationMode::Performance; |
|
351 | 351 | |
352 | 352 | if($bCacheDependencies) |
353 | 353 | $this->_manager->getCacheDependencies() |
@@ -390,14 +390,14 @@ discard block |
||
390 | 390 | */ |
391 | 391 | protected function loadResultMap($node) |
392 | 392 | { |
393 | - $resultMap = $this->createResultMap($node); |
|
393 | + $resultMap=$this->createResultMap($node); |
|
394 | 394 | |
395 | 395 | //find extended result map. |
396 | - if(strlen($extendMap = $resultMap->getExtends()) > 0) |
|
396 | + if(strlen($extendMap=$resultMap->getExtends()) > 0) |
|
397 | 397 | { |
398 | 398 | if(!$this->_manager->getResultMaps()->contains($extendMap)) |
399 | 399 | { |
400 | - $extendNode=$this->getElementByIdValue($this->_document,'resultMap',$extendMap); |
|
400 | + $extendNode=$this->getElementByIdValue($this->_document, 'resultMap', $extendMap); |
|
401 | 401 | if($extendNode!==null) |
402 | 402 | $this->loadResultMap($extendNode); |
403 | 403 | } |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | throw new TSqlMapConfigurationException( |
407 | 407 | 'sqlmap_unable_to_find_parent_result_map', $node, $this->_configFile, $extendMap); |
408 | 408 | |
409 | - $superMap = $this->_manager->getResultMap($extendMap); |
|
409 | + $superMap=$this->_manager->getResultMap($extendMap); |
|
410 | 410 | $resultMap->getColumns()->mergeWith($superMap->getColumns()); |
411 | 411 | } |
412 | 412 | |
@@ -423,22 +423,22 @@ discard block |
||
423 | 423 | */ |
424 | 424 | protected function createResultMap($node) |
425 | 425 | { |
426 | - $resultMap = new TResultMap(); |
|
427 | - $this->setObjectPropFromNode($resultMap,$node); |
|
426 | + $resultMap=new TResultMap(); |
|
427 | + $this->setObjectPropFromNode($resultMap, $node); |
|
428 | 428 | |
429 | 429 | //result nodes |
430 | 430 | foreach($node->result as $result) |
431 | 431 | { |
432 | - $property = new TResultProperty($resultMap); |
|
433 | - $this->setObjectPropFromNode($property,$result); |
|
432 | + $property=new TResultProperty($resultMap); |
|
433 | + $this->setObjectPropFromNode($property, $result); |
|
434 | 434 | $resultMap->addResultProperty($property); |
435 | 435 | } |
436 | 436 | |
437 | 437 | //create the discriminator |
438 | - $discriminator = null; |
|
438 | + $discriminator=null; |
|
439 | 439 | if(isset($node->discriminator)) |
440 | 440 | { |
441 | - $discriminator = new TDiscriminator(); |
|
441 | + $discriminator=new TDiscriminator(); |
|
442 | 442 | $this->setObjectPropFromNode($discriminator, $node->discriminator); |
443 | 443 | $discriminator->initMapping($resultMap); |
444 | 444 | } |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | { |
448 | 448 | if($discriminator===null) |
449 | 449 | throw new TSqlMapConfigurationException( |
450 | - 'sqlmap_undefined_discriminator', $node, $this->_configFile,$subMapNode); |
|
451 | - $subMap = new TSubMap; |
|
452 | - $this->setObjectPropFromNode($subMap,$subMapNode); |
|
450 | + 'sqlmap_undefined_discriminator', $node, $this->_configFile, $subMapNode); |
|
451 | + $subMap=new TSubMap; |
|
452 | + $this->setObjectPropFromNode($subMap, $subMapNode); |
|
453 | 453 | $discriminator->addSubMap($subMap); |
454 | 454 | } |
455 | 455 | |
@@ -466,24 +466,24 @@ discard block |
||
466 | 466 | */ |
467 | 467 | protected function loadParameterMap($node) |
468 | 468 | { |
469 | - $parameterMap = $this->createParameterMap($node); |
|
469 | + $parameterMap=$this->createParameterMap($node); |
|
470 | 470 | |
471 | - if(strlen($extendMap = $parameterMap->getExtends()) > 0) |
|
471 | + if(strlen($extendMap=$parameterMap->getExtends()) > 0) |
|
472 | 472 | { |
473 | 473 | if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
474 | 474 | { |
475 | - $extendNode=$this->getElementByIdValue($this->_document,'parameterMap',$extendMap); |
|
475 | + $extendNode=$this->getElementByIdValue($this->_document, 'parameterMap', $extendMap); |
|
476 | 476 | if($extendNode!==null) |
477 | 477 | $this->loadParameterMap($extendNode); |
478 | 478 | } |
479 | 479 | |
480 | 480 | if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
481 | 481 | throw new TSqlMapConfigurationException( |
482 | - 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile,$extendMap); |
|
483 | - $superMap = $this->_manager->getParameterMap($extendMap); |
|
484 | - $index = 0; |
|
482 | + 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile, $extendMap); |
|
483 | + $superMap=$this->_manager->getParameterMap($extendMap); |
|
484 | + $index=0; |
|
485 | 485 | foreach($superMap->getPropertyNames() as $propertyName) |
486 | - $parameterMap->insertProperty($index++,$superMap->getProperty($propertyName)); |
|
486 | + $parameterMap->insertProperty($index++, $superMap->getProperty($propertyName)); |
|
487 | 487 | } |
488 | 488 | $this->_manager->addParameterMap($parameterMap); |
489 | 489 | } |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | */ |
496 | 496 | protected function createParameterMap($node) |
497 | 497 | { |
498 | - $parameterMap = new TParameterMap(); |
|
499 | - $this->setObjectPropFromNode($parameterMap,$node); |
|
498 | + $parameterMap=new TParameterMap(); |
|
499 | + $this->setObjectPropFromNode($parameterMap, $node); |
|
500 | 500 | foreach($node->parameter as $parameter) |
501 | 501 | { |
502 | - $property = new TParameterProperty(); |
|
503 | - $this->setObjectPropFromNode($property,$parameter); |
|
502 | + $property=new TParameterProperty(); |
|
503 | + $this->setObjectPropFromNode($property, $parameter); |
|
504 | 504 | $parameterMap->addProperty($property); |
505 | 505 | } |
506 | 506 | return $parameterMap; |
@@ -512,10 +512,10 @@ discard block |
||
512 | 512 | */ |
513 | 513 | protected function loadStatementTag($node) |
514 | 514 | { |
515 | - $statement = new TSqlMapStatement(); |
|
516 | - $this->setObjectPropFromNode($statement,$node); |
|
515 | + $statement=new TSqlMapStatement(); |
|
516 | + $this->setObjectPropFromNode($statement, $node); |
|
517 | 517 | $this->processSqlStatement($statement, $node); |
518 | - $mappedStatement = new TMappedStatement($this->_manager, $statement); |
|
518 | + $mappedStatement=new TMappedStatement($this->_manager, $statement); |
|
519 | 519 | $this->_manager->addMappedStatement($mappedStatement); |
520 | 520 | } |
521 | 521 | |
@@ -527,15 +527,15 @@ discard block |
||
527 | 527 | */ |
528 | 528 | protected function processSqlStatement($statement, $node) |
529 | 529 | { |
530 | - $commandText = (string)$node; |
|
531 | - if(strlen($extend = $statement->getExtends()) > 0) |
|
530 | + $commandText=(string) $node; |
|
531 | + if(strlen($extend=$statement->getExtends()) > 0) |
|
532 | 532 | { |
533 | - $superNode = $this->getElementByIdValue($this->_document,'*',$extend); |
|
533 | + $superNode=$this->getElementByIdValue($this->_document, '*', $extend); |
|
534 | 534 | if($superNode!==null) |
535 | - $commandText = (string)$superNode . $commandText; |
|
535 | + $commandText=(string) $superNode.$commandText; |
|
536 | 536 | else |
537 | 537 | throw new TSqlMapConfigurationException( |
538 | - 'sqlmap_unable_to_find_parent_sql', $extend, $this->_configFile,$node); |
|
538 | + 'sqlmap_unable_to_find_parent_sql', $extend, $this->_configFile, $node); |
|
539 | 539 | } |
540 | 540 | //$commandText = $this->_xmlConfig->replaceProperties($commandText); |
541 | 541 | $statement->initialize($this->_manager); |
@@ -550,27 +550,27 @@ discard block |
||
550 | 550 | */ |
551 | 551 | protected function applyInlineParameterMap($statement, $sqlStatement, $node) |
552 | 552 | { |
553 | - $scope['file'] = $this->_configFile; |
|
554 | - $scope['node'] = $node; |
|
553 | + $scope['file']=$this->_configFile; |
|
554 | + $scope['node']=$node; |
|
555 | 555 | |
556 | - $sqlStatement=preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP,self::INLINE_PLACEHOLDER,$sqlStatement); |
|
557 | - if($statement->parameterMap() === null) |
|
556 | + $sqlStatement=preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP, self::INLINE_PLACEHOLDER, $sqlStatement); |
|
557 | + if($statement->parameterMap()===null) |
|
558 | 558 | { |
559 | 559 | // Build a Parametermap with the inline parameters. |
560 | 560 | // if they exist. Then delete inline infos from sqltext. |
561 | - $parameterParser = new TInlineParameterMapParser; |
|
562 | - $sqlText = $parameterParser->parse($sqlStatement, $scope); |
|
561 | + $parameterParser=new TInlineParameterMapParser; |
|
562 | + $sqlText=$parameterParser->parse($sqlStatement, $scope); |
|
563 | 563 | if(count($sqlText['parameters']) > 0) |
564 | 564 | { |
565 | - $map = new TParameterMap(); |
|
565 | + $map=new TParameterMap(); |
|
566 | 566 | $map->setID($statement->getID().'-InLineParameterMap'); |
567 | 567 | $statement->setInlineParameterMap($map); |
568 | 568 | foreach($sqlText['parameters'] as $property) |
569 | 569 | $map->addProperty($property); |
570 | 570 | } |
571 | - $sqlStatement = $sqlText['sql']; |
|
571 | + $sqlStatement=$sqlText['sql']; |
|
572 | 572 | } |
573 | - $sqlStatement=preg_replace('/'.self::INLINE_PLACEHOLDER.'/',self::INLINE_SYMBOL,$sqlStatement); |
|
573 | + $sqlStatement=preg_replace('/'.self::INLINE_PLACEHOLDER.'/', self::INLINE_SYMBOL, $sqlStatement); |
|
574 | 574 | |
575 | 575 | $this->prepareSql($statement, $sqlStatement, $node); |
576 | 576 | } |
@@ -582,19 +582,19 @@ discard block |
||
582 | 582 | * @param SimpleXmlElement statement node. |
583 | 583 | * @todo Extend to dynamic sql. |
584 | 584 | */ |
585 | - protected function prepareSql($statement,$sqlStatement, $node) |
|
585 | + protected function prepareSql($statement, $sqlStatement, $node) |
|
586 | 586 | { |
587 | - $simpleDynamic = new TSimpleDynamicParser; |
|
588 | - $sqlStatement=preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP,self::SIMPLE_PLACEHOLDER,$sqlStatement); |
|
589 | - $dynamics = $simpleDynamic->parse($sqlStatement); |
|
587 | + $simpleDynamic=new TSimpleDynamicParser; |
|
588 | + $sqlStatement=preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP, self::SIMPLE_PLACEHOLDER, $sqlStatement); |
|
589 | + $dynamics=$simpleDynamic->parse($sqlStatement); |
|
590 | 590 | if(count($dynamics['parameters']) > 0) |
591 | 591 | { |
592 | - $sql = new TSimpleDynamicSql($dynamics['parameters']); |
|
593 | - $sqlStatement = $dynamics['sql']; |
|
592 | + $sql=new TSimpleDynamicSql($dynamics['parameters']); |
|
593 | + $sqlStatement=$dynamics['sql']; |
|
594 | 594 | } |
595 | 595 | else |
596 | - $sql = new TStaticSql(); |
|
597 | - $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/',self::SIMPLE_MARK,$sqlStatement); |
|
596 | + $sql=new TStaticSql(); |
|
597 | + $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/', self::SIMPLE_MARK, $sqlStatement); |
|
598 | 598 | $sql->buildPreparedStatement($statement, $sqlStatement); |
599 | 599 | $statement->setSqlText($sql); |
600 | 600 | } |
@@ -605,12 +605,12 @@ discard block |
||
605 | 605 | */ |
606 | 606 | protected function loadSelectTag($node) |
607 | 607 | { |
608 | - $select = new TSqlMapSelect; |
|
609 | - $this->setObjectPropFromNode($select,$node); |
|
610 | - $this->processSqlStatement($select,$node); |
|
611 | - $mappedStatement = new TMappedStatement($this->_manager, $select); |
|
608 | + $select=new TSqlMapSelect; |
|
609 | + $this->setObjectPropFromNode($select, $node); |
|
610 | + $this->processSqlStatement($select, $node); |
|
611 | + $mappedStatement=new TMappedStatement($this->_manager, $select); |
|
612 | 612 | if(strlen($select->getCacheModel()) > 0) |
613 | - $mappedStatement = new TCachingStatement($mappedStatement); |
|
613 | + $mappedStatement=new TCachingStatement($mappedStatement); |
|
614 | 614 | |
615 | 615 | $this->_manager->addMappedStatement($mappedStatement); |
616 | 616 | } |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | */ |
622 | 622 | protected function loadInsertTag($node) |
623 | 623 | { |
624 | - $insert = $this->createInsertStatement($node); |
|
624 | + $insert=$this->createInsertStatement($node); |
|
625 | 625 | $this->processSqlStatement($insert, $node); |
626 | - $mappedStatement = new TInsertMappedStatement($this->_manager, $insert); |
|
626 | + $mappedStatement=new TInsertMappedStatement($this->_manager, $insert); |
|
627 | 627 | $this->_manager->addMappedStatement($mappedStatement); |
628 | 628 | } |
629 | 629 | |
@@ -634,10 +634,10 @@ discard block |
||
634 | 634 | */ |
635 | 635 | protected function createInsertStatement($node) |
636 | 636 | { |
637 | - $insert = new TSqlMapInsert; |
|
638 | - $this->setObjectPropFromNode($insert,$node); |
|
637 | + $insert=new TSqlMapInsert; |
|
638 | + $this->setObjectPropFromNode($insert, $node); |
|
639 | 639 | if(isset($node->selectKey)) |
640 | - $this->loadSelectKeyTag($insert,$node->selectKey); |
|
640 | + $this->loadSelectKeyTag($insert, $node->selectKey); |
|
641 | 641 | return $insert; |
642 | 642 | } |
643 | 643 | |
@@ -647,13 +647,13 @@ discard block |
||
647 | 647 | */ |
648 | 648 | protected function loadSelectKeyTag($insert, $node) |
649 | 649 | { |
650 | - $selectKey = new TSqlMapSelectKey; |
|
651 | - $this->setObjectPropFromNode($selectKey,$node); |
|
650 | + $selectKey=new TSqlMapSelectKey; |
|
651 | + $this->setObjectPropFromNode($selectKey, $node); |
|
652 | 652 | $selectKey->setID($insert->getID()); |
653 | 653 | $selectKey->setID($insert->getID().'.SelectKey'); |
654 | - $this->processSqlStatement($selectKey,$node); |
|
654 | + $this->processSqlStatement($selectKey, $node); |
|
655 | 655 | $insert->setSelectKey($selectKey); |
656 | - $mappedStatement = new TMappedStatement($this->_manager, $selectKey); |
|
656 | + $mappedStatement=new TMappedStatement($this->_manager, $selectKey); |
|
657 | 657 | $this->_manager->addMappedStatement($mappedStatement); |
658 | 658 | } |
659 | 659 | |
@@ -663,10 +663,10 @@ discard block |
||
663 | 663 | */ |
664 | 664 | protected function loadUpdateTag($node) |
665 | 665 | { |
666 | - $update = new TSqlMapUpdate; |
|
667 | - $this->setObjectPropFromNode($update,$node); |
|
666 | + $update=new TSqlMapUpdate; |
|
667 | + $this->setObjectPropFromNode($update, $node); |
|
668 | 668 | $this->processSqlStatement($update, $node); |
669 | - $mappedStatement = new TUpdateMappedStatement($this->_manager, $update); |
|
669 | + $mappedStatement=new TUpdateMappedStatement($this->_manager, $update); |
|
670 | 670 | $this->_manager->addMappedStatement($mappedStatement); |
671 | 671 | } |
672 | 672 | |
@@ -676,10 +676,10 @@ discard block |
||
676 | 676 | */ |
677 | 677 | protected function loadDeleteTag($node) |
678 | 678 | { |
679 | - $delete = new TSqlMapDelete; |
|
680 | - $this->setObjectPropFromNode($delete,$node); |
|
679 | + $delete=new TSqlMapDelete; |
|
680 | + $this->setObjectPropFromNode($delete, $node); |
|
681 | 681 | $this->processSqlStatement($delete, $node); |
682 | - $mappedStatement = new TDeleteMappedStatement($this->_manager, $delete); |
|
682 | + $mappedStatement=new TDeleteMappedStatement($this->_manager, $delete); |
|
683 | 683 | $this->_manager->addMappedStatement($mappedStatement); |
684 | 684 | } |
685 | 685 | |
@@ -699,35 +699,35 @@ discard block |
||
699 | 699 | */ |
700 | 700 | protected function loadCacheModel($node) |
701 | 701 | { |
702 | - $cacheModel = new TSqlMapCacheModel; |
|
703 | - $properties = array('id','implementation'); |
|
702 | + $cacheModel=new TSqlMapCacheModel; |
|
703 | + $properties=array('id', 'implementation'); |
|
704 | 704 | foreach($node->attributes() as $name=>$value) |
705 | 705 | { |
706 | 706 | if(in_array(strtolower($name), $properties)) |
707 | - $cacheModel->{'set'.$name}((string)$value); |
|
707 | + $cacheModel->{'set'.$name}((string) $value); |
|
708 | 708 | } |
709 | - $cache = Prado::createComponent($cacheModel->getImplementationClass(), $cacheModel); |
|
710 | - $this->setObjectPropFromNode($cache,$node,$properties); |
|
709 | + $cache=Prado::createComponent($cacheModel->getImplementationClass(), $cacheModel); |
|
710 | + $this->setObjectPropFromNode($cache, $node, $properties); |
|
711 | 711 | |
712 | 712 | foreach($node->xpath('property') as $propertyNode) |
713 | 713 | { |
714 | - $name = $propertyNode->attributes()->name; |
|
714 | + $name=$propertyNode->attributes()->name; |
|
715 | 715 | if($name===null || $name==='') continue; |
716 | 716 | |
717 | - $value = $propertyNode->attributes()->value; |
|
717 | + $value=$propertyNode->attributes()->value; |
|
718 | 718 | if($value===null || $value==='') continue; |
719 | 719 | |
720 | - if( !TPropertyAccess::has($cache, $name) ) continue; |
|
720 | + if(!TPropertyAccess::has($cache, $name)) continue; |
|
721 | 721 | |
722 | 722 | TPropertyAccess::set($cache, $name, $value); |
723 | 723 | } |
724 | 724 | |
725 | - $this->loadFlushInterval($cacheModel,$node); |
|
725 | + $this->loadFlushInterval($cacheModel, $node); |
|
726 | 726 | |
727 | 727 | $cacheModel->initialize($cache); |
728 | 728 | $this->_manager->addCacheModel($cacheModel); |
729 | 729 | foreach($node->xpath('flushOnExecute') as $flush) |
730 | - $this->loadFlushOnCache($cacheModel,$node,$flush); |
|
730 | + $this->loadFlushOnCache($cacheModel, $node, $flush); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | /** |
@@ -737,27 +737,27 @@ discard block |
||
737 | 737 | */ |
738 | 738 | protected function loadFlushInterval($cacheModel, $node) |
739 | 739 | { |
740 | - $flushInterval = $node->xpath('flushInterval'); |
|
741 | - if($flushInterval === null || count($flushInterval) === 0) return; |
|
742 | - $duration = 0; |
|
740 | + $flushInterval=$node->xpath('flushInterval'); |
|
741 | + if($flushInterval===null || count($flushInterval)===0) return; |
|
742 | + $duration=0; |
|
743 | 743 | foreach($flushInterval[0]->attributes() as $name=>$value) |
744 | 744 | { |
745 | 745 | switch(strToLower($name)) |
746 | 746 | { |
747 | 747 | case 'seconds': |
748 | - $duration += (integer)$value; |
|
748 | + $duration+=(integer) $value; |
|
749 | 749 | break; |
750 | 750 | case 'minutes': |
751 | - $duration += 60 * (integer)$value; |
|
751 | + $duration+=60 * (integer) $value; |
|
752 | 752 | break; |
753 | 753 | case 'hours': |
754 | - $duration += 3600 * (integer)$value; |
|
754 | + $duration+=3600 * (integer) $value; |
|
755 | 755 | break; |
756 | 756 | case 'days': |
757 | - $duration += 86400 * (integer)$value; |
|
757 | + $duration+=86400 * (integer) $value; |
|
758 | 758 | break; |
759 | 759 | case 'duration': |
760 | - $duration = (integer)$value; |
|
760 | + $duration=(integer) $value; |
|
761 | 761 | break 2; // switch, foreach |
762 | 762 | } |
763 | 763 | } |
@@ -770,15 +770,15 @@ discard block |
||
770 | 770 | * @param SimpleXmlElement parent node. |
771 | 771 | * @param SimpleXmlElement flush node. |
772 | 772 | */ |
773 | - protected function loadFlushOnCache($cacheModel,$parent,$node) |
|
773 | + protected function loadFlushOnCache($cacheModel, $parent, $node) |
|
774 | 774 | { |
775 | - $id = $cacheModel->getID(); |
|
775 | + $id=$cacheModel->getID(); |
|
776 | 776 | if(!isset($this->_FlushOnExecuteStatements[$id])) |
777 | - $this->_FlushOnExecuteStatements[$id] = array(); |
|
777 | + $this->_FlushOnExecuteStatements[$id]=array(); |
|
778 | 778 | foreach($node->attributes() as $name=>$value) |
779 | 779 | { |
780 | 780 | if(strtolower($name)==='statement') |
781 | - $this->_FlushOnExecuteStatements[$id][] = (string)$value; |
|
781 | + $this->_FlushOnExecuteStatements[$id][]=(string) $value; |
|
782 | 782 | } |
783 | 783 | } |
784 | 784 | |
@@ -789,10 +789,10 @@ discard block |
||
789 | 789 | { |
790 | 790 | foreach($this->_FlushOnExecuteStatements as $cacheID => $statementIDs) |
791 | 791 | { |
792 | - $cacheModel = $this->_manager->getCacheModel($cacheID); |
|
792 | + $cacheModel=$this->_manager->getCacheModel($cacheID); |
|
793 | 793 | foreach($statementIDs as $statementID) |
794 | 794 | { |
795 | - $statement = $this->_manager->getMappedStatement($statementID); |
|
795 | + $statement=$this->_manager->getMappedStatement($statementID); |
|
796 | 796 | $cacheModel->registerTriggerStatement($statement); |
797 | 797 | } |
798 | 798 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | class TReCaptcha2 extends TActivePanel implements ICallbackEventHandler, IValidatable |
57 | 57 | { |
58 | - const ChallengeFieldName = 'g-recaptcha-response'; |
|
58 | + const ChallengeFieldName='g-recaptcha-response'; |
|
59 | 59 | private $_widgetId=0; |
60 | 60 | private $_isValid=true; |
61 | 61 | |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | } |
103 | 103 | public function getResponseFieldName() |
104 | 104 | { |
105 | - $captchas = $this->Page->findControlsByType('TReCaptcha2'); |
|
106 | - $cont = 0; |
|
107 | - $responseFieldName = self::ChallengeFieldName; |
|
108 | - foreach ($captchas as $captcha) |
|
105 | + $captchas=$this->Page->findControlsByType('TReCaptcha2'); |
|
106 | + $cont=0; |
|
107 | + $responseFieldName=self::ChallengeFieldName; |
|
108 | + foreach($captchas as $captcha) |
|
109 | 109 | { |
110 | - if ($this->getClientID() == $captcha->ClientID) |
|
110 | + if($this->getClientID()==$captcha->ClientID) |
|
111 | 111 | { |
112 | - $responseFieldName .= ($cont > 0) ? '-'.$cont : ''; |
|
112 | + $responseFieldName.=($cont > 0) ? '-'.$cont : ''; |
|
113 | 113 | } |
114 | 114 | $cont++; |
115 | 115 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function reset() |
238 | 238 | { |
239 | - $this->Page->CallbackClient->callClientFunction('grecaptcha.reset',array(array($this->WidgetId))); |
|
239 | + $this->Page->CallbackClient->callClientFunction('grecaptcha.reset', array(array($this->WidgetId))); |
|
240 | 240 | } |
241 | 241 | /** |
242 | 242 | * Gets the response for the reCAPTCHA widget. |
@@ -259,34 +259,34 @@ discard block |
||
259 | 259 | } |
260 | 260 | protected function getClientOptions() |
261 | 261 | { |
262 | - $options['ID'] = $this->getClientID(); |
|
263 | - $options['EventTarget'] = $this->getUniqueID(); |
|
264 | - $options['FormID'] = $this->Page->getForm()->getClientID(); |
|
265 | - $options['onCallback'] = $this->hasEventHandler('OnCallback'); |
|
266 | - $options['onCallbackExpired'] = $this->hasEventHandler('OnCallbackExpired'); |
|
267 | - $options['options']['sitekey'] = $this->getSiteKey(); |
|
268 | - if ($theme = $this->getTheme()) $options['options']['theme'] = $theme; |
|
269 | - if ($type = $this->getType()) $options['options']['type'] = $type; |
|
270 | - if ($size = $this->getSize()) $options['options']['size'] = $size; |
|
271 | - if ($tabIndex = $this->getTabIndex()) $options['options']['tabindex'] = $tabIndex; |
|
262 | + $options['ID']=$this->getClientID(); |
|
263 | + $options['EventTarget']=$this->getUniqueID(); |
|
264 | + $options['FormID']=$this->Page->getForm()->getClientID(); |
|
265 | + $options['onCallback']=$this->hasEventHandler('OnCallback'); |
|
266 | + $options['onCallbackExpired']=$this->hasEventHandler('OnCallbackExpired'); |
|
267 | + $options['options']['sitekey']=$this->getSiteKey(); |
|
268 | + if($theme=$this->getTheme()) $options['options']['theme']=$theme; |
|
269 | + if($type=$this->getType()) $options['options']['type']=$type; |
|
270 | + if($size=$this->getSize()) $options['options']['size']=$size; |
|
271 | + if($tabIndex=$this->getTabIndex()) $options['options']['tabindex']=$tabIndex; |
|
272 | 272 | |
273 | 273 | return $options; |
274 | 274 | } |
275 | 275 | protected function registerClientScript() |
276 | 276 | { |
277 | - $id = $this->getClientID(); |
|
278 | - $options = TJavaScript::encode($this->getClientOptions()); |
|
279 | - $className = $this->getClientClassName(); |
|
280 | - $cs = $this->Page->ClientScript; |
|
281 | - $code = "new $className($options);"; |
|
277 | + $id=$this->getClientID(); |
|
278 | + $options=TJavaScript::encode($this->getClientOptions()); |
|
279 | + $className=$this->getClientClassName(); |
|
280 | + $cs=$this->Page->ClientScript; |
|
281 | + $code="new $className($options);"; |
|
282 | 282 | |
283 | 283 | $cs->registerPradoScript('ajax'); |
284 | 284 | $cs->registerEndScript("grecaptcha:$id", $code); |
285 | 285 | } |
286 | 286 | public function validate() |
287 | 287 | { |
288 | - $value = $this->getValidationPropertyValue(); |
|
289 | - if($value === null || empty($value)) |
|
288 | + $value=$this->getValidationPropertyValue(); |
|
289 | + if($value===null || empty($value)) |
|
290 | 290 | return false; |
291 | 291 | |
292 | 292 | return true; |
@@ -299,46 +299,46 @@ discard block |
||
299 | 299 | { |
300 | 300 | parent::onPreRender($param); |
301 | 301 | |
302 | - if("" == $this->getSiteKey()) |
|
302 | + if(""==$this->getSiteKey()) |
|
303 | 303 | throw new TConfigurationException('recaptcha_publickey_unknown'); |
304 | - if("" == $this->getSecretKey()) |
|
304 | + if(""==$this->getSecretKey()) |
|
305 | 305 | throw new TConfigurationException('recaptcha_privatekey_unknown'); |
306 | 306 | |
307 | 307 | // need to register captcha fields so they will be sent postback |
308 | 308 | $this->Page->registerRequiresPostData($this->getResponseFieldName()); |
309 | - $this->Page->ClientScript->registerHeadScriptFile('grecaptcha2', 'https://www.google.com/recaptcha/api.js?onload=TReCaptcha2_onloadCallback&render=explicit&hl=' . $this->getLanguage()); |
|
309 | + $this->Page->ClientScript->registerHeadScriptFile('grecaptcha2', 'https://www.google.com/recaptcha/api.js?onload=TReCaptcha2_onloadCallback&render=explicit&hl='.$this->getLanguage()); |
|
310 | 310 | } |
311 | 311 | protected function addAttributesToRender($writer) |
312 | 312 | { |
313 | - $writer->addAttribute('id',$this->getClientID()); |
|
313 | + $writer->addAttribute('id', $this->getClientID()); |
|
314 | 314 | parent::addAttributesToRender($writer); |
315 | 315 | } |
316 | 316 | public function raiseCallbackEvent($param) |
317 | 317 | { |
318 | - $params = $param->getCallbackParameter(); |
|
319 | - if ($params instanceof stdClass) |
|
318 | + $params=$param->getCallbackParameter(); |
|
319 | + if($params instanceof stdClass) |
|
320 | 320 | { |
321 | - $callback = property_exists($params, 'onCallback'); |
|
322 | - $callbackExpired = property_exists($params, 'onCallbackExpired'); |
|
321 | + $callback=property_exists($params, 'onCallback'); |
|
322 | + $callbackExpired=property_exists($params, 'onCallbackExpired'); |
|
323 | 323 | |
324 | - if ($callback) |
|
324 | + if($callback) |
|
325 | 325 | { |
326 | - $this->WidgetId = $params->widgetId; |
|
327 | - $this->Response = $params->response; |
|
328 | - $this->Page->CallbackClient->jQuery($params->responseField, 'text',array($params->response)); |
|
326 | + $this->WidgetId=$params->widgetId; |
|
327 | + $this->Response=$params->response; |
|
328 | + $this->Page->CallbackClient->jQuery($params->responseField, 'text', array($params->response)); |
|
329 | 329 | |
330 | - if ($params->onCallback) |
|
330 | + if($params->onCallback) |
|
331 | 331 | { |
332 | 332 | $this->onCallback($param); |
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | - if ($callbackExpired) |
|
336 | + if($callbackExpired) |
|
337 | 337 | { |
338 | - $this->Response = ''; |
|
338 | + $this->Response=''; |
|
339 | 339 | $this->reset(); |
340 | 340 | |
341 | - if ($params->onCallbackExpired) |
|
341 | + if($params->onCallbackExpired) |
|
342 | 342 | { |
343 | 343 | $this->onCallbackExpired($param); |
344 | 344 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @var string $_cacheDir |
56 | 56 | */ |
57 | - protected $_cacheDir = '/tmp/'; |
|
57 | + protected $_cacheDir='/tmp/'; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Enable / disable caching |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @var boolean $_caching |
65 | 65 | */ |
66 | - protected $_caching = true; |
|
66 | + protected $_caching=true; |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Cache lifetime (in seconds) |
70 | 70 | * |
71 | 71 | * @var int $_lifeTime |
72 | 72 | */ |
73 | - protected $_lifeTime = 3600; |
|
73 | + protected $_lifeTime=3600; |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Enable / disable fileLocking |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @var boolean $_fileLocking |
81 | 81 | */ |
82 | - protected $_fileLocking = true; |
|
82 | + protected $_fileLocking=true; |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Timestamp of the last valid cache |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @var boolean $_writeControl |
107 | 107 | */ |
108 | - protected $_writeControl = true; |
|
108 | + protected $_writeControl=true; |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * Enable / disable read control |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @var boolean $_writeControl |
117 | 117 | */ |
118 | - protected $_readControl = true; |
|
118 | + protected $_readControl=true; |
|
119 | 119 | |
120 | 120 | /** |
121 | 121 | * Type of read control (only if read control is enabled) |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @var boolean $_readControlType |
130 | 130 | */ |
131 | - protected $_readControlType = 'crc32'; |
|
131 | + protected $_readControlType='crc32'; |
|
132 | 132 | |
133 | 133 | /** |
134 | 134 | * Current cache id |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @var boolean $_memoryCaching |
153 | 153 | */ |
154 | - protected $_memoryCaching = false; |
|
154 | + protected $_memoryCaching=false; |
|
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Enable / Disable "Only Memory Caching" |
@@ -159,28 +159,28 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @var boolean $_onlyMemoryCaching |
161 | 161 | */ |
162 | - protected $_onlyMemoryCaching = false; |
|
162 | + protected $_onlyMemoryCaching=false; |
|
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Memory caching array |
166 | 166 | * |
167 | 167 | * @var array $_memoryCachingArray |
168 | 168 | */ |
169 | - protected $_memoryCachingArray = array(); |
|
169 | + protected $_memoryCachingArray=array(); |
|
170 | 170 | |
171 | 171 | /** |
172 | 172 | * Memory caching counter |
173 | 173 | * |
174 | 174 | * @var int $memoryCachingCounter |
175 | 175 | */ |
176 | - protected $_memoryCachingCounter = 0; |
|
176 | + protected $_memoryCachingCounter=0; |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Memory caching limit |
180 | 180 | * |
181 | 181 | * @var int $memoryCachingLimit |
182 | 182 | */ |
183 | - protected $_memoryCachingLimit = 1000; |
|
183 | + protected $_memoryCachingLimit=1000; |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * File Name protection |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @var boolean $fileNameProtection |
194 | 194 | */ |
195 | - protected $_fileNameProtection = true; |
|
195 | + protected $_fileNameProtection=true; |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Enable / disable automatic serialization |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @var boolean $_serialize |
204 | 204 | */ |
205 | - protected $_automaticSerialization = false; |
|
205 | + protected $_automaticSerialization=false; |
|
206 | 206 | |
207 | 207 | // --- Public methods --- |
208 | 208 | |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | * @param array $options options |
229 | 229 | * @access public |
230 | 230 | */ |
231 | - function __construct($options = array(null)) |
|
231 | + function __construct($options=array(null)) |
|
232 | 232 | { |
233 | - $availableOptions = array( 'automaticSerialization', |
|
233 | + $availableOptions=array('automaticSerialization', |
|
234 | 234 | 'fileNameProtection', |
235 | 235 | 'memoryCaching', |
236 | 236 | 'onlyMemoryCaching', |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | 'readControlType'); |
245 | 245 | foreach($options as $key => $value) { |
246 | 246 | if(in_array($key, $availableOptions)) { |
247 | - $property = '_'.$key; |
|
248 | - $this->$property = $value; |
|
247 | + $property='_'.$key; |
|
248 | + $this->$property=$value; |
|
249 | 249 | } |
250 | 250 | } |
251 | - $this->_refreshTime = time() - $this->_lifeTime; |
|
251 | + $this->_refreshTime=time() - $this->_lifeTime; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -261,41 +261,41 @@ discard block |
||
261 | 261 | * @return string data of the cache (or false if no cache available) |
262 | 262 | * @access public |
263 | 263 | */ |
264 | - function get($id, $group = 'default', $doNotTestCacheValidity = false) |
|
264 | + function get($id, $group='default', $doNotTestCacheValidity=false) |
|
265 | 265 | { |
266 | - $this->_id = $id; |
|
267 | - $this->_group = $group; |
|
268 | - $data = false; |
|
269 | - if ($this->_caching) { |
|
266 | + $this->_id=$id; |
|
267 | + $this->_group=$group; |
|
268 | + $data=false; |
|
269 | + if($this->_caching) { |
|
270 | 270 | $this->_setFileName($id, $group); |
271 | - if ($this->_memoryCaching) { |
|
272 | - if (isset($this->_memoryCachingArray[$this->_file])) { |
|
273 | - if ($this->_automaticSerialization) { |
|
271 | + if($this->_memoryCaching) { |
|
272 | + if(isset($this->_memoryCachingArray[$this->_file])) { |
|
273 | + if($this->_automaticSerialization) { |
|
274 | 274 | return unserialize( |
275 | 275 | $this->_memoryCachingArray[$this->_file]); |
276 | 276 | } else { |
277 | 277 | return $this->_memoryCachingArray[$this->_file]; |
278 | 278 | } |
279 | 279 | } else { |
280 | - if ($this->_onlyMemoryCaching) { |
|
280 | + if($this->_onlyMemoryCaching) { |
|
281 | 281 | return false; |
282 | 282 | } |
283 | 283 | } |
284 | 284 | } |
285 | - if ($doNotTestCacheValidity) { |
|
286 | - if (file_exists($this->_file)) { |
|
287 | - $data = $this->_read(); |
|
285 | + if($doNotTestCacheValidity) { |
|
286 | + if(file_exists($this->_file)) { |
|
287 | + $data=$this->_read(); |
|
288 | 288 | } |
289 | 289 | } else { |
290 | - if (@filemtime($this->_file) > $this->_refreshTime) { |
|
291 | - $data = $this->_read(); |
|
290 | + if(@filemtime($this->_file) > $this->_refreshTime) { |
|
291 | + $data=$this->_read(); |
|
292 | 292 | } |
293 | 293 | } |
294 | - if (($data) and ($this->_memoryCaching)) { |
|
294 | + if(($data) and ($this->_memoryCaching)) { |
|
295 | 295 | $this->_memoryCacheAdd($this->_file, $data); |
296 | 296 | } |
297 | - if ($this->_automaticSerialization && is_string($data)) { |
|
298 | - $data = unserialize($data); |
|
297 | + if($this->_automaticSerialization && is_string($data)) { |
|
298 | + $data=unserialize($data); |
|
299 | 299 | } |
300 | 300 | return $data; |
301 | 301 | } |
@@ -312,24 +312,24 @@ discard block |
||
312 | 312 | * @return boolean true if no problem |
313 | 313 | * @access public |
314 | 314 | */ |
315 | - function save($data, $id = null, $group = 'default') |
|
315 | + function save($data, $id=null, $group='default') |
|
316 | 316 | { |
317 | - if ($this->_caching) { |
|
318 | - if ($this->_automaticSerialization) { |
|
319 | - $data = serialize($data); |
|
317 | + if($this->_caching) { |
|
318 | + if($this->_automaticSerialization) { |
|
319 | + $data=serialize($data); |
|
320 | 320 | } |
321 | - if (isset($id)) { |
|
321 | + if(isset($id)) { |
|
322 | 322 | $this->_setFileName($id, $group); |
323 | 323 | } |
324 | - if ($this->_memoryCaching) { |
|
324 | + if($this->_memoryCaching) { |
|
325 | 325 | $this->_memoryCacheAdd($this->_file, $data); |
326 | - if ($this->_onlyMemoryCaching) { |
|
326 | + if($this->_onlyMemoryCaching) { |
|
327 | 327 | return true; |
328 | 328 | } |
329 | 329 | } |
330 | - if ($this->_writeControl) { |
|
331 | - if (!$this->_writeAndControl($data)) { |
|
332 | - @touch($this->_file, time() - 2*abs($this->_lifeTime)); |
|
330 | + if($this->_writeControl) { |
|
331 | + if(!$this->_writeAndControl($data)) { |
|
332 | + @touch($this->_file, time() - 2 * abs($this->_lifeTime)); |
|
333 | 333 | return false; |
334 | 334 | } else { |
335 | 335 | return true; |
@@ -349,10 +349,10 @@ discard block |
||
349 | 349 | * @return boolean true if no problem |
350 | 350 | * @access public |
351 | 351 | */ |
352 | - function remove($id, $group = 'default') |
|
352 | + function remove($id, $group='default') |
|
353 | 353 | { |
354 | 354 | $this->_setFileName($id, $group); |
355 | - if (!@unlink($this->_file)) { |
|
355 | + if(!@unlink($this->_file)) { |
|
356 | 356 | $this->raiseError('TCache_Lite : Unable to remove cache !', -3); |
357 | 357 | return false; |
358 | 358 | } |
@@ -369,35 +369,35 @@ discard block |
||
369 | 369 | * @return boolean true if no problem |
370 | 370 | * @access public |
371 | 371 | */ |
372 | - function clean($group = false) |
|
372 | + function clean($group=false) |
|
373 | 373 | { |
374 | - if ($this->_fileNameProtection) { |
|
375 | - $motif = ($group) ? 'cache_'.md5($group).'_' : 'cache_'; |
|
374 | + if($this->_fileNameProtection) { |
|
375 | + $motif=($group) ? 'cache_'.md5($group).'_' : 'cache_'; |
|
376 | 376 | } else { |
377 | - $motif = ($group) ? 'cache_'.$group.'_' : 'cache_'; |
|
377 | + $motif=($group) ? 'cache_'.$group.'_' : 'cache_'; |
|
378 | 378 | } |
379 | - if ($this->_memoryCaching) { |
|
380 | - while (list($key, $value) = each($this->_memoryCaching)) { |
|
381 | - if (strpos($key, $motif, 0)) { |
|
379 | + if($this->_memoryCaching) { |
|
380 | + while(list($key, $value)=each($this->_memoryCaching)) { |
|
381 | + if(strpos($key, $motif, 0)) { |
|
382 | 382 | unset($this->_memoryCaching[$key]); |
383 | - $this->_memoryCachingCounter = |
|
383 | + $this->_memoryCachingCounter= |
|
384 | 384 | $this->_memoryCachingCounter - 1; |
385 | 385 | } |
386 | 386 | } |
387 | - if ($this->_onlyMemoryCaching) { |
|
387 | + if($this->_onlyMemoryCaching) { |
|
388 | 388 | return true; |
389 | 389 | } |
390 | 390 | } |
391 | - if (!($dh = opendir($this->_cacheDir))) { |
|
391 | + if(!($dh=opendir($this->_cacheDir))) { |
|
392 | 392 | $this->raiseError('TCache_Lite : Unable to open cache directory !'); |
393 | 393 | return false; |
394 | 394 | } |
395 | - while ($file = readdir($dh)) { |
|
396 | - if (($file != '.') && ($file != '..')) { |
|
397 | - $file = $this->_cacheDir . $file; |
|
398 | - if (is_file($file)) { |
|
399 | - if (strpos($file, $motif, 0)) { |
|
400 | - if (!@unlink($file)) { |
|
395 | + while($file=readdir($dh)) { |
|
396 | + if(($file!='.') && ($file!='..')) { |
|
397 | + $file=$this->_cacheDir.$file; |
|
398 | + if(is_file($file)) { |
|
399 | + if(strpos($file, $motif, 0)) { |
|
400 | + if(!@unlink($file)) { |
|
401 | 401 | $this->raiseError('Cache_Lite : Unable to remove cache !', -3); |
402 | 402 | return false; |
403 | 403 | } |
@@ -416,22 +416,22 @@ discard block |
||
416 | 416 | */ |
417 | 417 | function setLifeTime($newLifeTime) |
418 | 418 | { |
419 | - $this->_lifeTime = $newLifeTime; |
|
420 | - $this->_refreshTime = time() - $newLifeTime; |
|
419 | + $this->_lifeTime=$newLifeTime; |
|
420 | + $this->_refreshTime=time() - $newLifeTime; |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
424 | 424 | * |
425 | 425 | * @access public |
426 | 426 | */ |
427 | - function saveMemoryCachingState($id, $group = 'default') |
|
427 | + function saveMemoryCachingState($id, $group='default') |
|
428 | 428 | { |
429 | - if ($this->_caching) { |
|
430 | - $array = array( |
|
429 | + if($this->_caching) { |
|
430 | + $array=array( |
|
431 | 431 | 'counter' => $this->_memoryCachingCounter, |
432 | 432 | 'array' => $this->_memoryCachingState |
433 | 433 | ); |
434 | - $data = serialize($array); |
|
434 | + $data=serialize($array); |
|
435 | 435 | $this->save($data, $id, $group); |
436 | 436 | } |
437 | 437 | } |
@@ -440,15 +440,15 @@ discard block |
||
440 | 440 | * |
441 | 441 | * @access public |
442 | 442 | */ |
443 | - function getMemoryCachingState($id, $group = 'default', |
|
444 | - $doNotTestCacheValidity = false) |
|
443 | + function getMemoryCachingState($id, $group='default', |
|
444 | + $doNotTestCacheValidity=false) |
|
445 | 445 | { |
446 | - if ($this->_caching) { |
|
447 | - if ($data = $this->get($id, $group, $doNotTestCacheValidity)) |
|
446 | + if($this->_caching) { |
|
447 | + if($data=$this->get($id, $group, $doNotTestCacheValidity)) |
|
448 | 448 | { |
449 | - $array = unserialize($data); |
|
450 | - $this->_memoryCachingCounter = $array['counter']; |
|
451 | - $this->_memoryCachingArray = $array['array']; |
|
449 | + $array=unserialize($data); |
|
450 | + $this->_memoryCachingCounter=$array['counter']; |
|
451 | + $this->_memoryCachingArray=$array['array']; |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 | } |
@@ -488,12 +488,12 @@ discard block |
||
488 | 488 | */ |
489 | 489 | function _memoryCacheAdd($id, $data) |
490 | 490 | { |
491 | - $this->_memoryCachingArray[$this->_file] = $data; |
|
492 | - if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) { |
|
493 | - list($key, $value) = each($this->_memoryCachingArray); |
|
491 | + $this->_memoryCachingArray[$this->_file]=$data; |
|
492 | + if($this->_memoryCachingCounter >= $this->_memoryCachingLimit) { |
|
493 | + list($key, $value)=each($this->_memoryCachingArray); |
|
494 | 494 | unset($this->_memoryCachingArray[$key]); |
495 | 495 | } else { |
496 | - $this->_memoryCachingCounter = $this->_memoryCachingCounter + 1; |
|
496 | + $this->_memoryCachingCounter=$this->_memoryCachingCounter + 1; |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | |
@@ -506,11 +506,11 @@ discard block |
||
506 | 506 | */ |
507 | 507 | function _setFileName($id, $group) |
508 | 508 | { |
509 | - if ($this->_fileNameProtection) { |
|
510 | - $this->_file = ($this->_cacheDir.'cache_'.md5($group).'_' |
|
509 | + if($this->_fileNameProtection) { |
|
510 | + $this->_file=($this->_cacheDir.'cache_'.md5($group).'_' |
|
511 | 511 | .md5($id)); |
512 | 512 | } else { |
513 | - $this->_file = $this->_cacheDir.'cache_'.$group.'_'.$id; |
|
513 | + $this->_file=$this->_cacheDir.'cache_'.$group.'_'.$id; |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | |
@@ -527,23 +527,23 @@ discard block |
||
527 | 527 | */ |
528 | 528 | function _read() |
529 | 529 | { |
530 | - $fp = @fopen($this->_file, "rb"); |
|
531 | - if ($this->_fileLocking) @flock($fp, LOCK_SH); |
|
532 | - if ($fp) { |
|
530 | + $fp=@fopen($this->_file, "rb"); |
|
531 | + if($this->_fileLocking) @flock($fp, LOCK_SH); |
|
532 | + if($fp) { |
|
533 | 533 | // because the filesize can be cached by PHP itself... |
534 | 534 | clearstatcache(); |
535 | - $length = @filesize($this->_file); |
|
536 | - if ($this->_readControl) { |
|
537 | - $hashControl = @fread($fp, 32); |
|
538 | - $length = $length - 32; |
|
535 | + $length=@filesize($this->_file); |
|
536 | + if($this->_readControl) { |
|
537 | + $hashControl=@fread($fp, 32); |
|
538 | + $length=$length - 32; |
|
539 | 539 | } |
540 | - $data = @fread($fp, $length); |
|
541 | - if ($this->_fileLocking) @flock($fp, LOCK_UN); |
|
540 | + $data=@fread($fp, $length); |
|
541 | + if($this->_fileLocking) @flock($fp, LOCK_UN); |
|
542 | 542 | @fclose($fp); |
543 | - if ($this->_readControl) { |
|
544 | - $hashData = $this->_hash($data, $this->_readControlType); |
|
545 | - if ($hashData != $hashControl) { |
|
546 | - @touch($this->_file, time() - 2*abs($this->_lifeTime)); |
|
543 | + if($this->_readControl) { |
|
544 | + $hashData=$this->_hash($data, $this->_readControlType); |
|
545 | + if($hashData!=$hashControl) { |
|
546 | + @touch($this->_file, time() - 2 * abs($this->_lifeTime)); |
|
547 | 547 | return false; |
548 | 548 | } |
549 | 549 | } |
@@ -562,15 +562,15 @@ discard block |
||
562 | 562 | */ |
563 | 563 | function _write($data) |
564 | 564 | { |
565 | - $fp = @fopen($this->_file, "wb"); |
|
566 | - if ($fp) { |
|
567 | - if ($this->_fileLocking) @flock($fp, LOCK_EX); |
|
568 | - if ($this->_readControl) { |
|
565 | + $fp=@fopen($this->_file, "wb"); |
|
566 | + if($fp) { |
|
567 | + if($this->_fileLocking) @flock($fp, LOCK_EX); |
|
568 | + if($this->_readControl) { |
|
569 | 569 | @fwrite($fp, $this->_hash($data, $this->_readControlType), 32); |
570 | 570 | } |
571 | - $len = strlen($data); |
|
571 | + $len=strlen($data); |
|
572 | 572 | @fwrite($fp, $data, $len); |
573 | - if ($this->_fileLocking) @flock($fp, LOCK_UN); |
|
573 | + if($this->_fileLocking) @flock($fp, LOCK_UN); |
|
574 | 574 | @fclose($fp); |
575 | 575 | return true; |
576 | 576 | } |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | function _writeAndControl($data) |
590 | 590 | { |
591 | 591 | $this->_write($data); |
592 | - $dataRead = $this->_read($data); |
|
592 | + $dataRead=$this->_read($data); |
|
593 | 593 | return ($dataRead==$data); |
594 | 594 | } |
595 | 595 | |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | */ |
604 | 604 | function _hash($data, $controlType) |
605 | 605 | { |
606 | - switch ($controlType) { |
|
606 | + switch($controlType) { |
|
607 | 607 | case 'md5': |
608 | 608 | return md5($data); |
609 | 609 | case 'crc32': |
@@ -3,11 +3,11 @@ discard block |
||
3 | 3 | //$Id: packages.php 3319 2013-09-08 20:59:44Z ctrlaltca $ |
4 | 4 | |
5 | 5 | // To make future upgrades easier |
6 | -if (!defined('JQUERY_DIR')) define ('JQUERY_DIR', 'jquery'); |
|
7 | -if (!defined('BOOTSTRAP_DIR')) define ('BOOTSTRAP_DIR', 'bootstrap3'); |
|
6 | +if(!defined('JQUERY_DIR')) define('JQUERY_DIR', 'jquery'); |
|
7 | +if(!defined('BOOTSTRAP_DIR')) define('BOOTSTRAP_DIR', 'bootstrap3'); |
|
8 | 8 | |
9 | 9 | //package names and its contents (files relative to the current directory) |
10 | -$packages = array( |
|
10 | +$packages=array( |
|
11 | 11 | 'jquery-ui' => array( |
12 | 12 | JQUERY_DIR.'/css/base/jquery-ui.css', |
13 | 13 | ), |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | |
70 | 70 | //package names and their dependencies |
71 | -$dependencies = array( |
|
71 | +$dependencies=array( |
|
72 | 72 | 'jquery-ui' => array('jquery-ui'), |
73 | 73 | 'jquery.ui.accordion' => array('jquery.ui.core', 'jquery.ui.accordion'), |
74 | 74 | 'jquery.ui.autocomplete' => array('jquery.ui.core', 'jquery.ui.autocomplete'), |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | { |
145 | 145 | $this->registerPradoScriptInternal($name); |
146 | 146 | $params=func_get_args(); |
147 | - $this->_page->registerCachingAction('Page.ClientScript','registerPradoScript',$params); |
|
147 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPradoScript', $params); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -155,39 +155,39 @@ discard block |
||
155 | 155 | // $this->checkIfNotInRender(); |
156 | 156 | if(!isset($this->_registeredPradoScripts[$name])) |
157 | 157 | { |
158 | - if(self::$_pradoScripts === null) |
|
158 | + if(self::$_pradoScripts===null) |
|
159 | 159 | { |
160 | - $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE; |
|
161 | - list($packages,$deps)= include($packageFile); |
|
162 | - self::$_pradoScripts = $deps; |
|
163 | - self::$_pradoPackages = $packages; |
|
160 | + $packageFile=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE; |
|
161 | + list($packages, $deps)=include($packageFile); |
|
162 | + self::$_pradoScripts=$deps; |
|
163 | + self::$_pradoPackages=$packages; |
|
164 | 164 | } |
165 | 165 | |
166 | - if (isset(self::$_pradoScripts[$name])) |
|
166 | + if(isset(self::$_pradoScripts[$name])) |
|
167 | 167 | $this->_registeredPradoScripts[$name]=true; |
168 | 168 | else |
169 | - throw new TInvalidOperationException('csmanager_pradoscript_invalid',$name); |
|
169 | + throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); |
|
170 | 170 | |
171 | 171 | if(($packages=array_keys($this->_registeredPradoScripts))!==array()) |
172 | 172 | { |
173 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
174 | - list($path,$baseUrl)=$this->getPackagePathUrl($base); |
|
173 | + $base=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
174 | + list($path, $baseUrl)=$this->getPackagePathUrl($base); |
|
175 | 175 | $packagesUrl=array(); |
176 | 176 | $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
177 | - foreach ($packages as $p) |
|
177 | + foreach($packages as $p) |
|
178 | 178 | { |
179 | - foreach (self::$_pradoScripts[$p] as $dep) |
|
179 | + foreach(self::$_pradoScripts[$p] as $dep) |
|
180 | 180 | { |
181 | - foreach (self::$_pradoPackages[$dep] as $script) |
|
182 | - if (!isset($this->_expandedPradoScripts[$script])) |
|
181 | + foreach(self::$_pradoPackages[$dep] as $script) |
|
182 | + if(!isset($this->_expandedPradoScripts[$script])) |
|
183 | 183 | { |
184 | - $this->_expandedPradoScripts[$script] = true; |
|
184 | + $this->_expandedPradoScripts[$script]=true; |
|
185 | 185 | if($isDebug) |
186 | 186 | { |
187 | - if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl)) |
|
187 | + if(!in_array($url=$baseUrl.'/'.$script, $packagesUrl)) |
|
188 | 188 | $packagesUrl[]=$url; |
189 | 189 | } else { |
190 | - if (!in_array($url=$baseUrl.'/min/'.$script,$packagesUrl)) |
|
190 | + if(!in_array($url=$baseUrl.'/min/'.$script, $packagesUrl)) |
|
191 | 191 | { |
192 | 192 | if(!is_file($filePath=$path.'/min/'.$script)) |
193 | 193 | { |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | } |
205 | 205 | } |
206 | 206 | foreach($packagesUrl as $url) |
207 | - $this->registerScriptFile($url,$url); |
|
207 | + $this->registerScriptFile($url, $url); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | } |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function getPradoScriptAssetUrl() |
216 | 216 | { |
217 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
218 | - $assets = Prado::getApplication()->getAssetManager(); |
|
217 | + $base=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
218 | + $assets=Prado::getApplication()->getAssetManager(); |
|
219 | 219 | return $assets->getPublishedUrl($base); |
220 | 220 | } |
221 | 221 | |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function getScriptUrls() |
227 | 227 | { |
228 | - $scripts = array_values($this->_headScriptFiles); |
|
229 | - $scripts = array_merge($scripts, array_values($this->_scriptFiles)); |
|
230 | - $scripts = array_unique($scripts); |
|
228 | + $scripts=array_values($this->_headScriptFiles); |
|
229 | + $scripts=array_merge($scripts, array_values($this->_scriptFiles)); |
|
230 | + $scripts=array_unique($scripts); |
|
231 | 231 | |
232 | 232 | return $scripts; |
233 | 233 | } |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | */ |
239 | 239 | protected function getPackagePathUrl($base) |
240 | 240 | { |
241 | - $assets = Prado::getApplication()->getAssetManager(); |
|
241 | + $assets=Prado::getApplication()->getAssetManager(); |
|
242 | 242 | if(strpos($base, $assets->getBaseUrl())===false) |
243 | 243 | { |
244 | - if(($dir = Prado::getPathOfNameSpace($base)) !== null) { |
|
245 | - $base = $dir; |
|
244 | + if(($dir=Prado::getPathOfNameSpace($base))!==null) { |
|
245 | + $base=$dir; |
|
246 | 246 | } |
247 | 247 | return array($assets->getPublishedPath($base), $assets->publishFilePath($base)); |
248 | 248 | } |
249 | 249 | else |
250 | 250 | { |
251 | - return array($assets->getBasePath().str_replace($assets->getBaseUrl(),'',$base), $base); |
|
251 | + return array($assets->getBasePath().str_replace($assets->getBaseUrl(), '', $base), $base); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options=null) |
262 | 262 | { |
263 | - $options = !is_array($options) ? array() : $options; |
|
264 | - $class = new ReflectionClass($callbackHandler); |
|
265 | - $clientSide = $callbackHandler->getActiveControl()->getClientSide(); |
|
266 | - $options = array_merge($options, $clientSide->getOptions()->toArray()); |
|
267 | - $optionString = TJavaScript::encode($options); |
|
263 | + $options=!is_array($options) ? array() : $options; |
|
264 | + $class=new ReflectionClass($callbackHandler); |
|
265 | + $clientSide=$callbackHandler->getActiveControl()->getClientSide(); |
|
266 | + $options=array_merge($options, $clientSide->getOptions()->toArray()); |
|
267 | + $optionString=TJavaScript::encode($options); |
|
268 | 268 | $this->registerPradoScriptInternal('ajax'); |
269 | - $id = $callbackHandler->getUniqueID(); |
|
269 | + $id=$callbackHandler->getUniqueID(); |
|
270 | 270 | return "new Prado.CallbackRequest('{$id}',{$optionString})"; |
271 | 271 | } |
272 | 272 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $this->registerPradoScriptInternal('ajax'); |
284 | 284 | |
285 | 285 | $params=func_get_args(); |
286 | - $this->_page->registerCachingAction('Page.ClientScript','registerCallbackControl',$params); |
|
286 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerCallbackControl', $params); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | * @param string javascript class responsible for the control being registered for postback |
293 | 293 | * @param array postback options |
294 | 294 | */ |
295 | - public function registerPostBackControl($class,$options) |
|
295 | + public function registerPostBackControl($class, $options) |
|
296 | 296 | { |
297 | - if($class === null) { |
|
297 | + if($class===null) { |
|
298 | 298 | return; |
299 | 299 | } |
300 | 300 | if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null) |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | $this->registerPradoScriptInternal('prado'); |
307 | 307 | |
308 | 308 | $params=func_get_args(); |
309 | - $this->_page->registerCachingAction('Page.ClientScript','registerPostBackControl',$params); |
|
309 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPostBackControl', $params); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function registerDefaultButton($panel, $button) |
319 | 319 | { |
320 | - $panelID=is_string($panel)?$panel:$panel->getUniqueID(); |
|
320 | + $panelID=is_string($panel) ? $panel : $panel->getUniqueID(); |
|
321 | 321 | |
322 | 322 | if(is_string($button)) |
323 | 323 | $buttonID=$button; |
@@ -326,14 +326,14 @@ discard block |
||
326 | 326 | $button->setIsDefaultButton(true); |
327 | 327 | $buttonID=$button->getUniqueID(); |
328 | 328 | } |
329 | - $options = TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); |
|
330 | - $code = "new Prado.WebUI.DefaultButton($options);"; |
|
329 | + $options=TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); |
|
330 | + $code="new Prado.WebUI.DefaultButton($options);"; |
|
331 | 331 | |
332 | 332 | $this->_endScripts['prado:'.$panelID]=$code; |
333 | 333 | $this->registerPradoScriptInternal('prado'); |
334 | 334 | |
335 | - $params=array($panelID,$buttonID); |
|
336 | - $this->_page->registerCachingAction('Page.ClientScript','registerDefaultButton',$params); |
|
335 | + $params=array($panelID, $buttonID); |
|
336 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerDefaultButton', $params); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -343,11 +343,11 @@ discard block |
||
343 | 343 | */ |
344 | 344 | protected function getDefaultButtonOptions($panelID, $buttonID) |
345 | 345 | { |
346 | - $options['ID'] = TControl::convertUniqueIdToClientId($panelID); |
|
347 | - $options['Panel'] = TControl::convertUniqueIdToClientId($panelID); |
|
348 | - $options['Target'] = TControl::convertUniqueIdToClientId($buttonID); |
|
349 | - $options['EventTarget'] = $buttonID; |
|
350 | - $options['Event'] = 'click'; |
|
346 | + $options['ID']=TControl::convertUniqueIdToClientId($panelID); |
|
347 | + $options['Panel']=TControl::convertUniqueIdToClientId($panelID); |
|
348 | + $options['Target']=TControl::convertUniqueIdToClientId($buttonID); |
|
349 | + $options['EventTarget']=$buttonID; |
|
350 | + $options['Event']='click'; |
|
351 | 351 | return $options; |
352 | 352 | } |
353 | 353 | |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | $this->registerPradoScriptInternal('jquery'); |
361 | 361 | if($target instanceof TControl) |
362 | 362 | $target=$target->getClientID(); |
363 | - $this->_endScripts['prado:focus'] = 'jQuery(\'#'.$target.'\').focus();'; |
|
363 | + $this->_endScripts['prado:focus']='jQuery(\'#'.$target.'\').focus();'; |
|
364 | 364 | |
365 | 365 | $params=func_get_args(); |
366 | - $this->_page->registerCachingAction('Page.ClientScript','registerFocusControl',$params); |
|
366 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerFocusControl', $params); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | { |
376 | 376 | $this->registerPradoStyleInternal($name); |
377 | 377 | $params=func_get_args(); |
378 | - $this->_page->registerCachingAction('Page.ClientScript','registerPradoStyle',$params); |
|
378 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPradoStyle', $params); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
@@ -386,43 +386,43 @@ discard block |
||
386 | 386 | // $this->checkIfNotInRender(); |
387 | 387 | if(!isset($this->_registeredPradoStyles[$name])) |
388 | 388 | { |
389 | - $base = $this->getPradoScriptAssetUrl(); |
|
389 | + $base=$this->getPradoScriptAssetUrl(); |
|
390 | 390 | |
391 | - if(self::$_pradoStyles === null) |
|
391 | + if(self::$_pradoStyles===null) |
|
392 | 392 | { |
393 | - $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::CSS_PACKAGES_FILE; |
|
394 | - list($packages,$deps)= include($packageFile); |
|
395 | - self::$_pradoStyles = $deps; |
|
396 | - self::$_pradoStylePackages = $packages; |
|
393 | + $packageFile=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::CSS_PACKAGES_FILE; |
|
394 | + list($packages, $deps)=include($packageFile); |
|
395 | + self::$_pradoStyles=$deps; |
|
396 | + self::$_pradoStylePackages=$packages; |
|
397 | 397 | } |
398 | 398 | |
399 | - if (isset(self::$_pradoStyles[$name])) |
|
399 | + if(isset(self::$_pradoStyles[$name])) |
|
400 | 400 | $this->_registeredPradoStyles[$name]=true; |
401 | 401 | else |
402 | - throw new TInvalidOperationException('csmanager_pradostyle_invalid',$name); |
|
402 | + throw new TInvalidOperationException('csmanager_pradostyle_invalid', $name); |
|
403 | 403 | |
404 | 404 | if(($packages=array_keys($this->_registeredPradoStyles))!==array()) |
405 | 405 | { |
406 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
407 | - list($path,$baseUrl)=$this->getPackagePathUrl($base); |
|
406 | + $base=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
407 | + list($path, $baseUrl)=$this->getPackagePathUrl($base); |
|
408 | 408 | $packagesUrl=array(); |
409 | 409 | $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
410 | - foreach ($packages as $p) |
|
410 | + foreach($packages as $p) |
|
411 | 411 | { |
412 | - foreach (self::$_pradoStyles[$p] as $dep) |
|
412 | + foreach(self::$_pradoStyles[$p] as $dep) |
|
413 | 413 | { |
414 | - foreach (self::$_pradoStylePackages[$dep] as $style) |
|
415 | - if (!isset($this->_expandedPradoStyles[$style])) |
|
414 | + foreach(self::$_pradoStylePackages[$dep] as $style) |
|
415 | + if(!isset($this->_expandedPradoStyles[$style])) |
|
416 | 416 | { |
417 | - $this->_expandedPradoStyles[$style] = true; |
|
417 | + $this->_expandedPradoStyles[$style]=true; |
|
418 | 418 | // TODO minify css? |
419 | - if (!in_array($url=$baseUrl.'/'.$style,$packagesUrl)) |
|
419 | + if(!in_array($url=$baseUrl.'/'.$style, $packagesUrl)) |
|
420 | 420 | $packagesUrl[]=$url; |
421 | 421 | } |
422 | 422 | } |
423 | 423 | } |
424 | 424 | foreach($packagesUrl as $url) |
425 | - $this->registerStyleSheetFile($url,$url); |
|
425 | + $this->registerStyleSheetFile($url, $url); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | } |
@@ -449,15 +449,15 @@ discard block |
||
449 | 449 | * @param string URL to the CSS file |
450 | 450 | * @param string media type of the CSS (such as 'print', 'screen', etc.). Defaults to empty, meaning the CSS applies to all media types. |
451 | 451 | */ |
452 | - public function registerStyleSheetFile($key,$url,$media='') |
|
452 | + public function registerStyleSheetFile($key, $url, $media='') |
|
453 | 453 | { |
454 | 454 | if($media==='') |
455 | 455 | $this->_styleSheetFiles[$key]=$url; |
456 | 456 | else |
457 | - $this->_styleSheetFiles[$key]=array($url,$media); |
|
457 | + $this->_styleSheetFiles[$key]=array($url, $media); |
|
458 | 458 | |
459 | 459 | $params=func_get_args(); |
460 | - $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheetFile',$params); |
|
460 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheetFile', $params); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | /** |
@@ -465,12 +465,12 @@ discard block |
||
465 | 465 | * @param string a unique key identifying the CSS block |
466 | 466 | * @param string CSS block |
467 | 467 | */ |
468 | - public function registerStyleSheet($key,$css,$media='') |
|
468 | + public function registerStyleSheet($key, $css, $media='') |
|
469 | 469 | { |
470 | 470 | $this->_styleSheets[$key]=$css; |
471 | 471 | |
472 | 472 | $params=func_get_args(); |
473 | - $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheet',$params); |
|
473 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheet', $params); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -479,17 +479,17 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function getStyleSheetUrls() |
481 | 481 | { |
482 | - $stylesheets = array_values( |
|
482 | + $stylesheets=array_values( |
|
483 | 483 | array_map( |
484 | 484 | create_function('$e', 'return is_array($e) ? $e[0] : $e;'), |
485 | 485 | $this->_styleSheetFiles) |
486 | 486 | ); |
487 | 487 | |
488 | 488 | foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) |
489 | - if (substr($url,strlen($url)-4)=='.css') |
|
490 | - $stylesheets[] = $url; |
|
489 | + if(substr($url, strlen($url) - 4)=='.css') |
|
490 | + $stylesheets[]=$url; |
|
491 | 491 | |
492 | - $stylesheets = array_unique($stylesheets); |
|
492 | + $stylesheets=array_unique($stylesheets); |
|
493 | 493 | |
494 | 494 | return $stylesheets; |
495 | 495 | } |
@@ -508,13 +508,13 @@ discard block |
||
508 | 508 | * @param string a unique key identifying the file |
509 | 509 | * @param string URL to the javascript file |
510 | 510 | */ |
511 | - public function registerHeadScriptFile($key,$url) |
|
511 | + public function registerHeadScriptFile($key, $url) |
|
512 | 512 | { |
513 | 513 | $this->checkIfNotInRender(); |
514 | 514 | $this->_headScriptFiles[$key]=$url; |
515 | 515 | |
516 | 516 | $params=func_get_args(); |
517 | - $this->_page->registerCachingAction('Page.ClientScript','registerHeadScriptFile',$params); |
|
517 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScriptFile', $params); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
@@ -522,13 +522,13 @@ discard block |
||
522 | 522 | * @param string a unique key identifying the script block |
523 | 523 | * @param string javascript block |
524 | 524 | */ |
525 | - public function registerHeadScript($key,$script) |
|
525 | + public function registerHeadScript($key, $script) |
|
526 | 526 | { |
527 | 527 | $this->checkIfNotInRender(); |
528 | 528 | $this->_headScripts[$key]=$script; |
529 | 529 | |
530 | 530 | $params=func_get_args(); |
531 | - $this->_page->registerCachingAction('Page.ClientScript','registerHeadScript',$params); |
|
531 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScript', $params); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | /** |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | $this->_scriptFiles[$key]=$url; |
542 | 542 | |
543 | 543 | $params=func_get_args(); |
544 | - $this->_page->registerCachingAction('Page.ClientScript','registerScriptFile',$params); |
|
544 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerScriptFile', $params); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -549,13 +549,13 @@ discard block |
||
549 | 549 | * @param string a unique key identifying the script block |
550 | 550 | * @param string javascript block |
551 | 551 | */ |
552 | - public function registerBeginScript($key,$script) |
|
552 | + public function registerBeginScript($key, $script) |
|
553 | 553 | { |
554 | 554 | $this->checkIfNotInRender(); |
555 | 555 | $this->_beginScripts[$key]=$script; |
556 | 556 | |
557 | 557 | $params=func_get_args(); |
558 | - $this->_page->registerCachingAction('Page.ClientScript','registerBeginScript',$params); |
|
558 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerBeginScript', $params); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -563,12 +563,12 @@ discard block |
||
563 | 563 | * @param string a unique key identifying the script block |
564 | 564 | * @param string javascript block |
565 | 565 | */ |
566 | - public function registerEndScript($key,$script) |
|
566 | + public function registerEndScript($key, $script) |
|
567 | 567 | { |
568 | 568 | $this->_endScripts[$key]=$script; |
569 | 569 | |
570 | 570 | $params=func_get_args(); |
571 | - $this->_page->registerCachingAction('Page.ClientScript','registerEndScript',$params); |
|
571 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerEndScript', $params); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -577,12 +577,12 @@ discard block |
||
577 | 577 | * @param string|array hidden field value, if the value is an array, every element |
578 | 578 | * in the array will be rendered as a hidden field value. |
579 | 579 | */ |
580 | - public function registerHiddenField($name,$value) |
|
580 | + public function registerHiddenField($name, $value) |
|
581 | 581 | { |
582 | 582 | $this->_hiddenFields[$name]=$value; |
583 | 583 | |
584 | 584 | $params=func_get_args(); |
585 | - $this->_page->registerCachingAction('Page.ClientScript','registerHiddenField',$params); |
|
585 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHiddenField', $params); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | public function renderStyleSheets($writer) |
696 | 696 | { |
697 | 697 | if(count($this->_styleSheets)) |
698 | - $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n",$this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
698 | + $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n", $this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | */ |
704 | 704 | public function renderHeadScriptFiles($writer) |
705 | 705 | { |
706 | - $this->renderScriptFiles($writer,$this->_headScriptFiles); |
|
706 | + $this->renderScriptFiles($writer, $this->_headScriptFiles); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | /** |
@@ -726,9 +726,9 @@ discard block |
||
726 | 726 | |
727 | 727 | public function markScriptFileAsRendered($url) |
728 | 728 | { |
729 | - $this->_renderedScriptFiles[$url] = $url; |
|
729 | + $this->_renderedScriptFiles[$url]=$url; |
|
730 | 730 | $params=func_get_args(); |
731 | - $this->_page->registerCachingAction('Page.ClientScript','markScriptFileAsRendered',$params); |
|
731 | + $this->_page->registerCachingAction('Page.ClientScript', 'markScriptFileAsRendered', $params); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | protected function renderScriptFiles($writer, Array $scripts) |
@@ -752,8 +752,8 @@ discard block |
||
752 | 752 | { |
753 | 753 | if(!empty($this->_scriptFiles)) |
754 | 754 | { |
755 | - $addedScripts = array_diff($this->_scriptFiles,$this->getRenderedScriptFiles()); |
|
756 | - $this->renderScriptFiles($writer,$addedScripts); |
|
755 | + $addedScripts=array_diff($this->_scriptFiles, $this->getRenderedScriptFiles()); |
|
756 | + $this->renderScriptFiles($writer, $addedScripts); |
|
757 | 757 | } |
758 | 758 | } |
759 | 759 | |
@@ -791,12 +791,12 @@ discard block |
||
791 | 791 | |
792 | 792 | public function renderHiddenFieldsBegin($writer) |
793 | 793 | { |
794 | - $this->renderHiddenFieldsInt($writer,true); |
|
794 | + $this->renderHiddenFieldsInt($writer, true); |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | public function renderHiddenFieldsEnd($writer) |
798 | 798 | { |
799 | - $this->renderHiddenFieldsInt($writer,false); |
|
799 | + $this->renderHiddenFieldsInt($writer, false); |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | /** |
@@ -818,12 +818,12 @@ discard block |
||
818 | 818 | */ |
819 | 819 | protected function renderHiddenFieldsInt($writer, $initial) |
820 | 820 | { |
821 | - if ($initial) $this->_renderedHiddenFields = array(); |
|
821 | + if($initial) $this->_renderedHiddenFields=array(); |
|
822 | 822 | $str=''; |
823 | 823 | foreach($this->_hiddenFields as $name=>$value) |
824 | 824 | { |
825 | - if (in_array($name,$this->_renderedHiddenFields)) continue; |
|
826 | - $id=strtr($name,':','_'); |
|
825 | + if(in_array($name, $this->_renderedHiddenFields)) continue; |
|
826 | + $id=strtr($name, ':', '_'); |
|
827 | 827 | if(is_array($value)) |
828 | 828 | { |
829 | 829 | foreach($value as $v) |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | { |
834 | 834 | $str.='<input type="hidden" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
835 | 835 | } |
836 | - $this->_renderedHiddenFields[] = $name; |
|
836 | + $this->_renderedHiddenFields[]=$name; |
|
837 | 837 | } |
838 | 838 | if($str!=='') |
839 | 839 | $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | */ |
850 | 850 | protected function checkIfNotInRender() |
851 | 851 | { |
852 | - if ($form = $this->_page->InFormRender) |
|
852 | + if($form=$this->_page->InFormRender) |
|
853 | 853 | throw new Exception('Operation invalid when page is already rendering'); |
854 | 854 | } |
855 | 855 | } |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | protected function setFunction($name, $code) |
884 | 884 | { |
885 | 885 | if(!TJavaScript::isJsLiteral($code)) |
886 | - $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
|
886 | + $code=TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
|
887 | 887 | $this->setOption($name, $code); |
888 | 888 | } |
889 | 889 | |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | */ |
893 | 893 | protected function getOption($name) |
894 | 894 | { |
895 | - if ($this->_options) |
|
895 | + if($this->_options) |
|
896 | 896 | return $this->_options->itemAt($name); |
897 | 897 | else |
898 | 898 | return null; |
@@ -912,8 +912,8 @@ discard block |
||
912 | 912 | */ |
913 | 913 | public function getOptions() |
914 | 914 | { |
915 | - if (!$this->_options) |
|
916 | - $this->_options = Prado::createComponent('System.Collections.TMap'); |
|
915 | + if(!$this->_options) |
|
916 | + $this->_options=Prado::createComponent('System.Collections.TMap'); |
|
917 | 917 | return $this->_options; |
918 | 918 | } |
919 | 919 |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function getMediaType() |
84 | 84 | { |
85 | - return $this->getViewState('MediaType',''); |
|
85 | + return $this->getViewState('MediaType', ''); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function setMediaType($value) |
92 | 92 | { |
93 | - $this->setViewState('MediaType',$value,''); |
|
93 | + $this->setViewState('MediaType', $value, ''); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -100,17 +100,17 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function onPreRender($param) |
102 | 102 | { |
103 | - $cs = $this->getPage()->getClientScript(); |
|
103 | + $cs=$this->getPage()->getClientScript(); |
|
104 | 104 | |
105 | - $styles = preg_split('/,|\s+/', $this->getPradoStyles()); |
|
105 | + $styles=preg_split('/,|\s+/', $this->getPradoStyles()); |
|
106 | 106 | foreach($styles as $style) |
107 | 107 | { |
108 | - if(($style = trim($style))!=='') |
|
108 | + if(($style=trim($style))!=='') |
|
109 | 109 | $cs->registerPradoStyle($style); |
110 | 110 | } |
111 | 111 | |
112 | 112 | if(($url=$this->getStyleSheetUrl())!=='') |
113 | - $cs->registerStyleSheetFile($url,$url,$this->getMediaType()); |
|
113 | + $cs->registerStyleSheetFile($url, $url, $this->getMediaType()); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -16,12 +16,12 @@ discard block |
||
16 | 16 | * Defines the PRADO framework installation path. |
17 | 17 | */ |
18 | 18 | if(!defined('PRADO_DIR')) |
19 | - define('PRADO_DIR',dirname(__FILE__)); |
|
19 | + define('PRADO_DIR', dirname(__FILE__)); |
|
20 | 20 | /** |
21 | 21 | * Defines the default permission for writable directories and files |
22 | 22 | */ |
23 | 23 | if(!defined('PRADO_CHMOD')) |
24 | - define('PRADO_CHMOD',0777); |
|
24 | + define('PRADO_CHMOD', 0777); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * PradoBase class. |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * @var array list of class exists checks |
64 | 64 | */ |
65 | - protected static $classExists = array(); |
|
65 | + protected static $classExists=array(); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @return string the version of Prado framework |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * Sets error handler to be Prado::phpErrorHandler |
84 | 84 | */ |
85 | - set_error_handler(array('PradoBase','phpErrorHandler')); |
|
85 | + set_error_handler(array('PradoBase', 'phpErrorHandler')); |
|
86 | 86 | /** |
87 | 87 | * Sets shutdown function to be Prado::phpFatalErrorHandler |
88 | 88 | */ |
89 | - register_shutdown_function(array('PradoBase','phpFatalErrorHandler')); |
|
89 | + register_shutdown_function(array('PradoBase', 'phpFatalErrorHandler')); |
|
90 | 90 | /** |
91 | 91 | * Sets exception handler to be Prado::exceptionHandler |
92 | 92 | */ |
93 | - set_exception_handler(array('PradoBase','exceptionHandler')); |
|
93 | + set_exception_handler(array('PradoBase', 'exceptionHandler')); |
|
94 | 94 | /** |
95 | 95 | * Disable php's builtin error reporting to avoid duplicated reports |
96 | 96 | */ |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public static function poweredByPrado($logoType=0) |
115 | 115 | { |
116 | - $logoName=$logoType==1?'powered2':'powered'; |
|
116 | + $logoName=$logoType==1 ? 'powered2' : 'powered'; |
|
117 | 117 | if(self::$_application!==null) |
118 | 118 | { |
119 | 119 | $am=self::$_application->getAssetManager(); |
120 | - $url=$am->publishFilePath(self::getPathOfNamespace('System.'.$logoName,'.gif')); |
|
120 | + $url=$am->publishFilePath(self::getPathOfNamespace('System.'.$logoName, '.gif')); |
|
121 | 121 | } |
122 | 122 | else |
123 | 123 | $url='http://pradosoft.github.io/docs/'.$logoName.'.gif'; |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | * @param string the filename that the error was raised in |
135 | 135 | * @param integer the line number the error was raised at |
136 | 136 | */ |
137 | - public static function phpErrorHandler($errno,$errstr,$errfile,$errline) |
|
137 | + public static function phpErrorHandler($errno, $errstr, $errfile, $errline) |
|
138 | 138 | { |
139 | 139 | if(error_reporting() & $errno) |
140 | - throw new TPhpErrorException($errno,$errstr,$errfile,$errline); |
|
140 | + throw new TPhpErrorException($errno, $errstr, $errfile, $errline); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public static function phpFatalErrorHandler() |
150 | 150 | { |
151 | - $error = error_get_last(); |
|
151 | + $error=error_get_last(); |
|
152 | 152 | if($error && |
153 | 153 | TPhpErrorException::isFatalError($error) && |
154 | 154 | error_reporting() & $error['type']) |
155 | 155 | { |
156 | - self::exceptionHandler(new TPhpErrorException($error['type'],$error['message'],$error['file'],$error['line'])); |
|
156 | + self::exceptionHandler(new TPhpErrorException($error['type'], $error['message'], $error['file'], $error['line'])); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | { |
171 | 171 | if(self::$_application!==null && ($errorHandler=self::$_application->getErrorHandler())!==null) |
172 | 172 | { |
173 | - $errorHandler->handleError(null,$exception); |
|
173 | + $errorHandler->handleError(null, $exception); |
|
174 | 174 | } |
175 | 175 | else |
176 | 176 | { |
@@ -227,19 +227,19 @@ discard block |
||
227 | 227 | public static function createComponent($type) |
228 | 228 | { |
229 | 229 | if(!isset(self::$classExists[$type])) |
230 | - self::$classExists[$type] = class_exists($type, false); |
|
230 | + self::$classExists[$type]=class_exists($type, false); |
|
231 | 231 | |
232 | - if( !isset(self::$_usings[$type]) && !self::$classExists[$type]) { |
|
232 | + if(!isset(self::$_usings[$type]) && !self::$classExists[$type]) { |
|
233 | 233 | self::using($type); |
234 | - self::$classExists[$type] = class_exists($type, false); |
|
234 | + self::$classExists[$type]=class_exists($type, false); |
|
235 | 235 | } |
236 | 236 | |
237 | - if( ($pos = strrpos($type, '.')) !== false) |
|
238 | - $type = substr($type,$pos+1); |
|
237 | + if(($pos=strrpos($type, '.'))!==false) |
|
238 | + $type=substr($type, $pos + 1); |
|
239 | 239 | |
240 | - if(($n=func_num_args())>1) |
|
240 | + if(($n=func_num_args()) > 1) |
|
241 | 241 | { |
242 | - $args = func_get_args(); |
|
242 | + $args=func_get_args(); |
|
243 | 243 | switch($n) { |
244 | 244 | case 2: |
245 | 245 | return new $type($args[1]); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | break; |
256 | 256 | default: |
257 | 257 | $s='$args[1]'; |
258 | - for($i=2;$i<$n;++$i) |
|
258 | + for($i=2; $i < $n; ++$i) |
|
259 | 259 | $s.=",\$args[$i]"; |
260 | 260 | eval("\$component=new $type($s);"); |
261 | 261 | return $component; |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | * @param boolean whether to check the existence of the class after the class file is included |
276 | 276 | * @throws TInvalidDataValueException if the namespace is invalid |
277 | 277 | */ |
278 | - public static function using($namespace,$checkClassExistence=true) |
|
278 | + public static function using($namespace, $checkClassExistence=true) |
|
279 | 279 | { |
280 | - if(isset(self::$_usings[$namespace]) || class_exists($namespace,false)) |
|
280 | + if(isset(self::$_usings[$namespace]) || class_exists($namespace, false)) |
|
281 | 281 | return; |
282 | - if(($pos=strrpos($namespace,'.'))===false) // a class name |
|
282 | + if(($pos=strrpos($namespace, '.'))===false) // a class name |
|
283 | 283 | { |
284 | 284 | try |
285 | 285 | { |
@@ -287,15 +287,15 @@ discard block |
||
287 | 287 | } |
288 | 288 | catch(Exception $e) |
289 | 289 | { |
290 | - if($checkClassExistence && !class_exists($namespace,false)) |
|
291 | - throw new TInvalidOperationException('prado_component_unknown',$namespace,$e->getMessage()); |
|
290 | + if($checkClassExistence && !class_exists($namespace, false)) |
|
291 | + throw new TInvalidOperationException('prado_component_unknown', $namespace, $e->getMessage()); |
|
292 | 292 | else |
293 | 293 | throw $e; |
294 | 294 | } |
295 | 295 | } |
296 | - else if(($path=self::getPathOfNamespace($namespace,self::CLASS_FILE_EXT))!==null) |
|
296 | + else if(($path=self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT))!==null) |
|
297 | 297 | { |
298 | - $className=substr($namespace,$pos+1); |
|
298 | + $className=substr($namespace, $pos + 1); |
|
299 | 299 | if($className==='*') // a directory |
300 | 300 | { |
301 | 301 | self::$_usings[$namespace]=$path; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | else // a file |
305 | 305 | { |
306 | 306 | self::$_usings[$namespace]=$path; |
307 | - if(!$checkClassExistence || !class_exists($className,false)) |
|
307 | + if(!$checkClassExistence || !class_exists($className, false)) |
|
308 | 308 | { |
309 | 309 | try |
310 | 310 | { |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | } |
313 | 313 | catch(Exception $e) |
314 | 314 | { |
315 | - if($checkClassExistence && !class_exists($className,false)) |
|
316 | - throw new TInvalidOperationException('prado_component_unknown',$className,$e->getMessage()); |
|
315 | + if($checkClassExistence && !class_exists($className, false)) |
|
316 | + throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage()); |
|
317 | 317 | else |
318 | 318 | throw $e; |
319 | 319 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | } |
322 | 322 | } |
323 | 323 | else |
324 | - throw new TInvalidDataValueException('prado_using_invalid',$namespace); |
|
324 | + throw new TInvalidDataValueException('prado_using_invalid', $namespace); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | */ |
339 | 339 | public static function getPathOfNamespace($namespace, $ext='') |
340 | 340 | { |
341 | - if(self::CLASS_FILE_EXT === $ext || empty($ext)) |
|
341 | + if(self::CLASS_FILE_EXT===$ext || empty($ext)) |
|
342 | 342 | { |
343 | 343 | if(isset(self::$_usings[$namespace])) |
344 | 344 | return self::$_usings[$namespace]; |
@@ -347,11 +347,11 @@ discard block |
||
347 | 347 | return self::$_aliases[$namespace]; |
348 | 348 | } |
349 | 349 | |
350 | - $segs = explode('.',$namespace); |
|
351 | - $alias = array_shift($segs); |
|
350 | + $segs=explode('.', $namespace); |
|
351 | + $alias=array_shift($segs); |
|
352 | 352 | |
353 | - if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias))) |
|
354 | - return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR ,$segs),'/\\').(($file === '*') ? '' : DIRECTORY_SEPARATOR.$file.$ext); |
|
353 | + if(null!==($file=array_pop($segs)) && null!==($root=self::getPathOfAlias($alias))) |
|
354 | + return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $segs), '/\\').(($file==='*') ? '' : DIRECTORY_SEPARATOR.$file.$ext); |
|
355 | 355 | |
356 | 356 | return null; |
357 | 357 | } |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | */ |
363 | 363 | public static function getPathOfAlias($alias) |
364 | 364 | { |
365 | - return isset(self::$_aliases[$alias])?self::$_aliases[$alias]:null; |
|
365 | + return isset(self::$_aliases[$alias]) ? self::$_aliases[$alias] : null; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | protected static function getPathAliases() |
@@ -376,19 +376,19 @@ discard block |
||
376 | 376 | * @throws TInvalidOperationException if the alias is already defined |
377 | 377 | * @throws TInvalidDataValueException if the path is not a valid file path |
378 | 378 | */ |
379 | - public static function setPathOfAlias($alias,$path) |
|
379 | + public static function setPathOfAlias($alias, $path) |
|
380 | 380 | { |
381 | 381 | if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN')) |
382 | - throw new TInvalidOperationException('prado_alias_redefined',$alias); |
|
382 | + throw new TInvalidOperationException('prado_alias_redefined', $alias); |
|
383 | 383 | else if(($rp=realpath($path))!==false && is_dir($rp)) |
384 | 384 | { |
385 | - if(strpos($alias,'.')===false) |
|
385 | + if(strpos($alias, '.')===false) |
|
386 | 386 | self::$_aliases[$alias]=$rp; |
387 | 387 | else |
388 | - throw new TInvalidDataValueException('prado_aliasname_invalid',$alias); |
|
388 | + throw new TInvalidDataValueException('prado_aliasname_invalid', $alias); |
|
389 | 389 | } |
390 | 390 | else |
391 | - throw new TInvalidDataValueException('prado_alias_invalid',$alias,$path); |
|
391 | + throw new TInvalidDataValueException('prado_alias_invalid', $alias, $path); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -413,13 +413,13 @@ discard block |
||
413 | 413 | continue; |
414 | 414 | echo '#'.$index.' '; |
415 | 415 | if(isset($t['file'])) |
416 | - echo basename($t['file']) . ':' . $t['line']; |
|
416 | + echo basename($t['file']).':'.$t['line']; |
|
417 | 417 | else |
418 | 418 | echo '<PHP inner-code>'; |
419 | 419 | echo ' -- '; |
420 | 420 | if(isset($t['class'])) |
421 | - echo $t['class'] . $t['type']; |
|
422 | - echo $t['function'] . '('; |
|
421 | + echo $t['class'].$t['type']; |
|
422 | + echo $t['function'].'('; |
|
423 | 423 | if(isset($t['args']) && sizeof($t['args']) > 0) |
424 | 424 | { |
425 | 425 | $count=0; |
@@ -428,25 +428,25 @@ discard block |
||
428 | 428 | if(is_string($item)) |
429 | 429 | { |
430 | 430 | $str=htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES); |
431 | - if (strlen($item) > 70) |
|
432 | - echo "'". substr($str, 0, 70) . "...'"; |
|
431 | + if(strlen($item) > 70) |
|
432 | + echo "'".substr($str, 0, 70)."...'"; |
|
433 | 433 | else |
434 | - echo "'" . $str . "'"; |
|
434 | + echo "'".$str."'"; |
|
435 | 435 | } |
436 | - else if (is_int($item) || is_float($item)) |
|
436 | + else if(is_int($item) || is_float($item)) |
|
437 | 437 | echo $item; |
438 | - else if (is_object($item)) |
|
438 | + else if(is_object($item)) |
|
439 | 439 | echo get_class($item); |
440 | - else if (is_array($item)) |
|
441 | - echo 'array(' . count($item) . ')'; |
|
442 | - else if (is_bool($item)) |
|
440 | + else if(is_array($item)) |
|
441 | + echo 'array('.count($item).')'; |
|
442 | + else if(is_bool($item)) |
|
443 | 443 | echo $item ? 'true' : 'false'; |
444 | - else if ($item === null) |
|
444 | + else if($item===null) |
|
445 | 445 | echo 'NULL'; |
446 | - else if (is_resource($item)) |
|
446 | + else if(is_resource($item)) |
|
447 | 447 | echo get_resource_type($item); |
448 | 448 | $count++; |
449 | - if (count($t['args']) > $count) |
|
449 | + if(count($t['args']) > $count) |
|
450 | 450 | echo ', '; |
451 | 451 | } |
452 | 452 | } |
@@ -473,10 +473,10 @@ discard block |
||
473 | 473 | else |
474 | 474 | { |
475 | 475 | $languages=array(); |
476 | - foreach(explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) |
|
476 | + foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) |
|
477 | 477 | { |
478 | - $array=explode(';q=',trim($language)); |
|
479 | - $languages[trim($array[0])]=isset($array[1])?(float)$array[1]:1.0; |
|
478 | + $array=explode(';q=', trim($language)); |
|
479 | + $languages[trim($array[0])]=isset($array[1]) ? (float) $array[1] : 1.0; |
|
480 | 480 | } |
481 | 481 | arsort($languages); |
482 | 482 | $languages=array_keys($languages); |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | if($language===null) |
498 | 498 | { |
499 | 499 | $langs=Prado::getUserLanguages(); |
500 | - $lang=explode('-',$langs[0]); |
|
500 | + $lang=explode('-', $langs[0]); |
|
501 | 501 | if(empty($lang[0]) || !ctype_alpha($lang[0])) |
502 | 502 | $language='en'; |
503 | 503 | else |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | * @param (string|TControl) control of the message |
519 | 519 | * @see log, getLogger |
520 | 520 | */ |
521 | - public static function trace($msg,$category='Uncategorized',$ctl=null) |
|
521 | + public static function trace($msg, $category='Uncategorized', $ctl=null) |
|
522 | 522 | { |
523 | 523 | if(self::$_application && self::$_application->getMode()===TApplicationMode::Performance) |
524 | 524 | return; |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | } |
532 | 532 | else |
533 | 533 | $level=TLogger::INFO; |
534 | - self::log($msg,$level,$category,$ctl); |
|
534 | + self::log($msg, $level, $category, $ctl); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -546,11 +546,11 @@ discard block |
||
546 | 546 | * @param string category of the message |
547 | 547 | * @param (string|TControl) control of the message |
548 | 548 | */ |
549 | - public static function log($msg,$level=TLogger::INFO,$category='Uncategorized',$ctl=null) |
|
549 | + public static function log($msg, $level=TLogger::INFO, $category='Uncategorized', $ctl=null) |
|
550 | 550 | { |
551 | 551 | if(self::$_logger===null) |
552 | 552 | self::$_logger=new TLogger; |
553 | - self::$_logger->log($msg,$level,$category,$ctl); |
|
553 | + self::$_logger->log($msg, $level, $category, $ctl); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -572,10 +572,10 @@ discard block |
||
572 | 572 | * @param boolean whether to syntax highlight the output. Defaults to false. |
573 | 573 | * @return string the string representation of the variable |
574 | 574 | */ |
575 | - public static function varDump($var,$depth=10,$highlight=false) |
|
575 | + public static function varDump($var, $depth=10, $highlight=false) |
|
576 | 576 | { |
577 | 577 | Prado::using('System.Util.TVarDumper'); |
578 | - return TVarDumper::dump($var,$depth,$highlight); |
|
578 | + return TVarDumper::dump($var, $depth, $highlight); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | /** |
@@ -591,32 +591,32 @@ discard block |
||
591 | 591 | public static function localize($text, $parameters=array(), $catalogue=null, $charset=null) |
592 | 592 | { |
593 | 593 | Prado::using('System.I18N.Translation'); |
594 | - $app = Prado::getApplication()->getGlobalization(false); |
|
594 | + $app=Prado::getApplication()->getGlobalization(false); |
|
595 | 595 | |
596 | - $params = array(); |
|
596 | + $params=array(); |
|
597 | 597 | foreach($parameters as $key => $value) |
598 | - $params['{'.$key.'}'] = $value; |
|
598 | + $params['{'.$key.'}']=$value; |
|
599 | 599 | |
600 | 600 | //no translation handler provided |
601 | - if($app===null || ($config = $app->getTranslationConfiguration())===null) |
|
601 | + if($app===null || ($config=$app->getTranslationConfiguration())===null) |
|
602 | 602 | return strtr($text, $params); |
603 | 603 | |
604 | - if ($catalogue===null) |
|
605 | - $catalogue=isset($config['catalogue'])?$config['catalogue']:'messages'; |
|
604 | + if($catalogue===null) |
|
605 | + $catalogue=isset($config['catalogue']) ? $config['catalogue'] : 'messages'; |
|
606 | 606 | |
607 | 607 | Translation::init($catalogue); |
608 | 608 | |
609 | 609 | //globalization charset |
610 | - $appCharset = $app===null ? '' : $app->getCharset(); |
|
610 | + $appCharset=$app===null ? '' : $app->getCharset(); |
|
611 | 611 | |
612 | 612 | //default charset |
613 | - $defaultCharset = ($app===null) ? 'UTF-8' : $app->getDefaultCharset(); |
|
613 | + $defaultCharset=($app===null) ? 'UTF-8' : $app->getDefaultCharset(); |
|
614 | 614 | |
615 | 615 | //fall back |
616 | - if(empty($charset)) $charset = $appCharset; |
|
617 | - if(empty($charset)) $charset = $defaultCharset; |
|
616 | + if(empty($charset)) $charset=$appCharset; |
|
617 | + if(empty($charset)) $charset=$defaultCharset; |
|
618 | 618 | |
619 | - return Translation::formatter($catalogue)->format($text,$params,$catalogue,$charset); |
|
619 | + return Translation::formatter($catalogue)->format($text, $params, $catalogue, $charset); |
|
620 | 620 | } |
621 | 621 | } |
622 | 622 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | class TActiveFileUpload extends TFileUpload implements IActiveControl, ICallbackEventHandler, INamingContainer |
44 | 44 | { |
45 | 45 | |
46 | - const SCRIPT_PATH = 'prado/activefileupload'; |
|
46 | + const SCRIPT_PATH='prado/activefileupload'; |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @var THiddenField a flag to tell which component is doing the callback. |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * TActiveControlAdapter. If you override this class, be sure to set the |
73 | 73 | * adapter appropriately by, for example, by calling this constructor. |
74 | 74 | */ |
75 | - public function __construct(){ |
|
75 | + public function __construct() { |
|
76 | 76 | parent::__construct(); |
77 | 77 | $this->setAdapter(new TActiveControlAdapter($this)); |
78 | 78 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function getAssetUrl($file='') |
86 | 86 | { |
87 | - $base = $this->getPage()->getClientScript()->getPradoScriptAssetUrl(); |
|
87 | + $base=$this->getPage()->getClientScript()->getPradoScriptAssetUrl(); |
|
88 | 88 | return $base.'/'.self::SCRIPT_PATH.'/'.$file; |
89 | 89 | } |
90 | 90 | |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function onFileUpload($param) |
99 | 99 | { |
100 | - if ($this->_flag->getValue() && $this->getPage()->getIsPostBack() && $param == $this->_target->getUniqueID()){ |
|
100 | + if($this->_flag->getValue() && $this->getPage()->getIsPostBack() && $param==$this->_target->getUniqueID()) { |
|
101 | 101 | // save the file so that it will persist past the end of this return. |
102 | - $localName = str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()),'')); |
|
102 | + $localName=str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()), '')); |
|
103 | 103 | parent::saveAs($localName); |
104 | - $this->_localName = $localName; |
|
104 | + $this->_localName=$localName; |
|
105 | 105 | |
106 | - $params = new TActiveFileUploadCallbackParams; |
|
107 | - $params->localName = $localName; |
|
108 | - $params->fileName = addslashes($this->getFileName()); |
|
109 | - $params->fileSize = $this->getFileSize(); |
|
110 | - $params->fileType = $this->getFileType(); |
|
111 | - $params->errorCode = $this->getErrorCode(); |
|
106 | + $params=new TActiveFileUploadCallbackParams; |
|
107 | + $params->localName=$localName; |
|
108 | + $params->fileName=addslashes($this->getFileName()); |
|
109 | + $params->fileSize=$this->getFileSize(); |
|
110 | + $params->fileType=$this->getFileType(); |
|
111 | + $params->errorCode=$this->getErrorCode(); |
|
112 | 112 | |
113 | 113 | // return some javascript to display a completion status. |
114 | 114 | echo <<<EOS |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @return string the path where the uploaded file will be stored temporarily, in namespace format |
134 | 134 | * default "Application.runtime.*" |
135 | 135 | */ |
136 | - public function getTempPath(){ |
|
136 | + public function getTempPath() { |
|
137 | 137 | return $this->getViewState('TempPath', 'Application.runtime.*'); |
138 | 138 | } |
139 | 139 | |
@@ -141,15 +141,15 @@ discard block |
||
141 | 141 | * @param string the path where the uploaded file will be stored temporarily in namespace format |
142 | 142 | * default "Application.runtime.*" |
143 | 143 | */ |
144 | - public function setTempPath($value){ |
|
145 | - $this->setViewState('TempPath',$value,'Application.runtime.*'); |
|
144 | + public function setTempPath($value) { |
|
145 | + $this->setViewState('TempPath', $value, 'Application.runtime.*'); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
149 | 149 | * @return boolean a value indicating whether an automatic callback to the server will occur whenever the user modifies the text in the TTextBox control and then tabs out of the component. Defaults to true. |
150 | 150 | * Note: When set to false, you will need to trigger the callback yourself. |
151 | 151 | */ |
152 | - public function getAutoPostBack(){ |
|
152 | + public function getAutoPostBack() { |
|
153 | 153 | return $this->getViewState('AutoPostBack', true); |
154 | 154 | } |
155 | 155 | |
@@ -157,28 +157,28 @@ discard block |
||
157 | 157 | * @param boolean a value indicating whether an automatic callback to the server will occur whenever the user modifies the text in the TTextBox control and then tabs out of the component. Defaults to true. |
158 | 158 | * Note: When set to false, you will need to trigger the callback yourself. |
159 | 159 | */ |
160 | - public function setAutoPostBack($value){ |
|
161 | - $this->setViewState('AutoPostBack',TPropertyValue::ensureBoolean($value),true); |
|
160 | + public function setAutoPostBack($value) { |
|
161 | + $this->setViewState('AutoPostBack', TPropertyValue::ensureBoolean($value), true); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * @return string A chuck of javascript that will need to be called if {{@link getAutoPostBack AutoPostBack} is set to false} |
166 | 166 | */ |
167 | - public function getCallbackJavascript(){ |
|
167 | + public function getCallbackJavascript() { |
|
168 | 168 | return "Prado.WebUI.TActiveFileUpload.fileChanged(\"{$this->getClientID()}\")"; |
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | 172 | * @throws TInvalidDataValueException if the {@link getTempPath TempPath} is not writable. |
173 | 173 | */ |
174 | - public function onInit($sender){ |
|
174 | + public function onInit($sender) { |
|
175 | 175 | parent::onInit($sender); |
176 | 176 | |
177 | - if (!Prado::getApplication()->getCache()) |
|
178 | - if (!Prado::getApplication()->getSecurityManager()) |
|
177 | + if(!Prado::getApplication()->getCache()) |
|
178 | + if(!Prado::getApplication()->getSecurityManager()) |
|
179 | 179 | throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely'); |
180 | 180 | |
181 | - if (!is_writable(Prado::getPathOfNamespace($this->getTempPath()))){ |
|
181 | + if(!is_writable(Prado::getPathOfNamespace($this->getTempPath()))) { |
|
182 | 182 | throw new TInvalidDataValueException("activefileupload_temppath_invalid", $this->getTempPath()); |
183 | 183 | } |
184 | 184 | } |
@@ -190,17 +190,17 @@ discard block |
||
190 | 190 | * This method is mainly used by framework and control developers. |
191 | 191 | * @param TCallbackEventParameter the event parameter |
192 | 192 | */ |
193 | - public function raiseCallbackEvent($param){ |
|
194 | - $cp = $param->getCallbackParameter(); |
|
195 | - if ($key = $cp->targetID == $this->_target->getUniqueID()){ |
|
193 | + public function raiseCallbackEvent($param) { |
|
194 | + $cp=$param->getCallbackParameter(); |
|
195 | + if($key=$cp->targetID==$this->_target->getUniqueID()) { |
|
196 | 196 | |
197 | - $params = $this->popParamsByToken($cp->callbackToken); |
|
197 | + $params=$this->popParamsByToken($cp->callbackToken); |
|
198 | 198 | |
199 | - $_FILES[$key]['name'] = stripslashes($params->fileName); |
|
200 | - $_FILES[$key]['size'] = intval($params->fileSize); |
|
201 | - $_FILES[$key]['type'] = $params->fileType; |
|
202 | - $_FILES[$key]['error'] = intval($params->errorCode); |
|
203 | - $_FILES[$key]['tmp_name'] = $params->localName; |
|
199 | + $_FILES[$key]['name']=stripslashes($params->fileName); |
|
200 | + $_FILES[$key]['size']=intval($params->fileSize); |
|
201 | + $_FILES[$key]['type']=$params->fileType; |
|
202 | + $_FILES[$key]['error']=intval($params->errorCode); |
|
203 | + $_FILES[$key]['tmp_name']=$params->localName; |
|
204 | 204 | $this->loadPostData($key, null); |
205 | 205 | |
206 | 206 | $this->raiseEvent('OnFileUpload', $this, $param); |
@@ -219,17 +219,17 @@ discard block |
||
219 | 219 | |
220 | 220 | protected function pushParamsAndGetToken(TActiveFileUploadCallbackParams $params) |
221 | 221 | { |
222 | - if ($cache = Prado::getApplication()->getCache()) |
|
222 | + if($cache=Prado::getApplication()->getCache()) |
|
223 | 223 | { |
224 | 224 | // this is the most secure method, file info can't be forged from client side, no matter what |
225 | - $token = md5('TActiveFileUpload::Params::'.$this->ClientID.'::'+rand(1000*1000,9999*1000)); |
|
226 | - $cache->set($token, serialize($params), 5*60); // expire in 5 minutes - the callback should arrive back in seconds, actually |
|
225 | + $token=md5('TActiveFileUpload::Params::'.$this->ClientID.'::'+rand(1000 * 1000, 9999 * 1000)); |
|
226 | + $cache->set($token, serialize($params), 5 * 60); // expire in 5 minutes - the callback should arrive back in seconds, actually |
|
227 | 227 | } |
228 | 228 | else |
229 | - if ($mgr = Prado::getApplication()->getSecurityManager()) |
|
229 | + if($mgr=Prado::getApplication()->getSecurityManager()) |
|
230 | 230 | { |
231 | 231 | // this is a less secure method, file info can be still forged from client side, but only if attacker knows the secret application key |
232 | - $token = urlencode(base64_encode($mgr->encrypt(serialize($params)))); |
|
232 | + $token=urlencode(base64_encode($mgr->encrypt(serialize($params)))); |
|
233 | 233 | } |
234 | 234 | else |
235 | 235 | throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely'); |
@@ -239,18 +239,18 @@ discard block |
||
239 | 239 | |
240 | 240 | protected function popParamsByToken($token) |
241 | 241 | { |
242 | - if ($cache = Prado::getApplication()->getCache()) |
|
242 | + if($cache=Prado::getApplication()->getCache()) |
|
243 | 243 | { |
244 | - $v = $cache->get($token); |
|
244 | + $v=$cache->get($token); |
|
245 | 245 | assert($v!=''); |
246 | 246 | $cache->delete($token); // remove it from cache so it can't be used again and won't take up space either |
247 | - $params = unserialize($v); |
|
247 | + $params=unserialize($v); |
|
248 | 248 | } |
249 | 249 | else |
250 | - if ($mgr = Prado::getApplication()->getSecurityManager()) |
|
250 | + if($mgr=Prado::getApplication()->getSecurityManager()) |
|
251 | 251 | { |
252 | - $v = $mgr->decrypt(base64_decode(urldecode($token))); |
|
253 | - $params = unserialize($v); |
|
252 | + $v=$mgr->decrypt(base64_decode(urldecode($token))); |
|
253 | + $params=unserialize($v); |
|
254 | 254 | } |
255 | 255 | else |
256 | 256 | throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely'); |
@@ -267,19 +267,19 @@ discard block |
||
267 | 267 | { |
268 | 268 | parent::onPreRender($param); |
269 | 269 | |
270 | - if(!$this->getPage()->getIsPostBack() && isset($_GET['TActiveFileUpload_InputId']) && isset($_GET['TActiveFileUpload_TargetId']) && $_GET['TActiveFileUpload_InputId'] == $this->getClientID()) |
|
270 | + if(!$this->getPage()->getIsPostBack() && isset($_GET['TActiveFileUpload_InputId']) && isset($_GET['TActiveFileUpload_TargetId']) && $_GET['TActiveFileUpload_InputId']==$this->getClientID()) |
|
271 | 271 | { |
272 | 272 | // tricky workaround to intercept "uploaded file too big" error: real uploads happens in onFileUpload instead |
273 | - $this->_errorCode = UPLOAD_ERR_FORM_SIZE; |
|
274 | - $localName = str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()),'')); |
|
275 | - $fileName = addslashes($this->getFileName()); |
|
273 | + $this->_errorCode=UPLOAD_ERR_FORM_SIZE; |
|
274 | + $localName=str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()), '')); |
|
275 | + $fileName=addslashes($this->getFileName()); |
|
276 | 276 | |
277 | - $params = new TActiveFileUploadCallbackParams; |
|
278 | - $params->localName = $localName; |
|
279 | - $params->fileName = $fileName; |
|
280 | - $params->fileSize = $this->getFileSize(); |
|
281 | - $params->fileType = $this->getFileType(); |
|
282 | - $params->errorCode = $this->getErrorCode(); |
|
277 | + $params=new TActiveFileUploadCallbackParams; |
|
278 | + $params->localName=$localName; |
|
279 | + $params->fileName=$fileName; |
|
280 | + $params->fileSize=$this->getFileSize(); |
|
281 | + $params->fileType=$this->getFileType(); |
|
282 | + $params->errorCode=$this->getErrorCode(); |
|
283 | 283 | |
284 | 284 | echo <<<EOS |
285 | 285 | <script language="Javascript"> |
@@ -297,30 +297,30 @@ discard block |
||
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | - public function createChildControls(){ |
|
301 | - $this->_flag = Prado::createComponent('THiddenField'); |
|
300 | + public function createChildControls() { |
|
301 | + $this->_flag=Prado::createComponent('THiddenField'); |
|
302 | 302 | $this->_flag->setID('Flag'); |
303 | 303 | $this->getControls()->add($this->_flag); |
304 | 304 | |
305 | - $this->_busy = Prado::createComponent('TImage'); |
|
305 | + $this->_busy=Prado::createComponent('TImage'); |
|
306 | 306 | $this->_busy->setID('Busy'); |
307 | 307 | $this->_busy->setImageUrl($this->getAssetUrl('ActiveFileUploadIndicator.gif')); |
308 | 308 | $this->_busy->setStyle("display:none"); |
309 | 309 | $this->getControls()->add($this->_busy); |
310 | 310 | |
311 | - $this->_success = Prado::createComponent('TImage'); |
|
311 | + $this->_success=Prado::createComponent('TImage'); |
|
312 | 312 | $this->_success->setID('Success'); |
313 | 313 | $this->_success->setImageUrl($this->getAssetUrl('ActiveFileUploadComplete.png')); |
314 | 314 | $this->_success->setStyle("display:none"); |
315 | 315 | $this->getControls()->add($this->_success); |
316 | 316 | |
317 | - $this->_error = Prado::createComponent('TImage'); |
|
317 | + $this->_error=Prado::createComponent('TImage'); |
|
318 | 318 | $this->_error->setID('Error'); |
319 | 319 | $this->_error->setImageUrl($this->getAssetUrl('ActiveFileUploadError.png')); |
320 | 320 | $this->_error->setStyle("display:none"); |
321 | 321 | $this->getControls()->add($this->_error); |
322 | 322 | |
323 | - $this->_target = Prado::createComponent('TInlineFrame'); |
|
323 | + $this->_target=Prado::createComponent('TInlineFrame'); |
|
324 | 324 | $this->_target->setID('Target'); |
325 | 325 | $this->_target->setFrameUrl($this->getAssetUrl('ActiveFileUploadBlank.html')); |
326 | 326 | $this->_target->setStyle("width:0px; height:0px;"); |
@@ -332,10 +332,10 @@ discard block |
||
332 | 332 | /** |
333 | 333 | * Removes localfile on ending of the callback. |
334 | 334 | */ |
335 | - public function onUnload($param){ |
|
336 | - if ($this->getPage()->getIsCallback() && |
|
335 | + public function onUnload($param) { |
|
336 | + if($this->getPage()->getIsCallback() && |
|
337 | 337 | $this->getHasFile() && |
338 | - file_exists($this->getLocalName())){ |
|
338 | + file_exists($this->getLocalName())) { |
|
339 | 339 | unlink($this->getLocalName()); |
340 | 340 | } |
341 | 341 | parent::onUnload($param); |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | /** |
345 | 345 | * @return TBaseActiveCallbackControl standard callback control options. |
346 | 346 | */ |
347 | - public function getActiveControl(){ |
|
347 | + public function getActiveControl() { |
|
348 | 348 | return $this->getAdapter()->getBaseActiveControl(); |
349 | 349 | } |
350 | 350 | |
@@ -360,18 +360,18 @@ discard block |
||
360 | 360 | * Adds ID attribute, and renders the javascript for active component. |
361 | 361 | * @param THtmlWriter the writer used for the rendering purpose |
362 | 362 | */ |
363 | - public function addAttributesToRender($writer){ |
|
363 | + public function addAttributesToRender($writer) { |
|
364 | 364 | parent::addAttributesToRender($writer); |
365 | - $writer->addAttribute('id',$this->getClientID()); |
|
365 | + $writer->addAttribute('id', $this->getClientID()); |
|
366 | 366 | |
367 | 367 | $this->getPage()->getClientScript()->registerPradoScript('activefileupload'); |
368 | - $this->getActiveControl()->registerCallbackClientScript($this->getClientClassName(),$this->getClientOptions()); |
|
368 | + $this->getActiveControl()->registerCallbackClientScript($this->getClientClassName(), $this->getClientOptions()); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
372 | 372 | * @return string corresponding javascript class name for this control. |
373 | 373 | */ |
374 | - protected function getClientClassName(){ |
|
374 | + protected function getClientClassName() { |
|
375 | 375 | return 'Prado.WebUI.TActiveFileUpload'; |
376 | 376 | } |
377 | 377 | |
@@ -385,18 +385,18 @@ discard block |
||
385 | 385 | * completeID => complete client ID, |
386 | 386 | * errorID => error client ID) |
387 | 387 | */ |
388 | - protected function getClientOptions(){ |
|
389 | - $options['ID'] = $this->getClientID(); |
|
390 | - $options['EventTarget'] = $this->getUniqueID(); |
|
391 | - |
|
392 | - $options['inputID'] = $this->getClientID(); |
|
393 | - $options['flagID'] = $this->_flag->getClientID(); |
|
394 | - $options['targetID'] = $this->_target->getUniqueID(); |
|
395 | - $options['formID'] = $this->getPage()->getForm()->getClientID(); |
|
396 | - $options['indicatorID'] = $this->_busy->getClientID(); |
|
397 | - $options['completeID'] = $this->_success->getClientID(); |
|
398 | - $options['errorID'] = $this->_error->getClientID(); |
|
399 | - $options['autoPostBack'] = $this->getAutoPostBack(); |
|
388 | + protected function getClientOptions() { |
|
389 | + $options['ID']=$this->getClientID(); |
|
390 | + $options['EventTarget']=$this->getUniqueID(); |
|
391 | + |
|
392 | + $options['inputID']=$this->getClientID(); |
|
393 | + $options['flagID']=$this->_flag->getClientID(); |
|
394 | + $options['targetID']=$this->_target->getUniqueID(); |
|
395 | + $options['formID']=$this->getPage()->getForm()->getClientID(); |
|
396 | + $options['indicatorID']=$this->_busy->getClientID(); |
|
397 | + $options['completeID']=$this->_success->getClientID(); |
|
398 | + $options['errorID']=$this->_error->getClientID(); |
|
399 | + $options['autoPostBack']=$this->getAutoPostBack(); |
|
400 | 400 | return $options; |
401 | 401 | } |
402 | 402 | |
@@ -407,12 +407,12 @@ discard block |
||
407 | 407 | * If true, you will not be able to save the uploaded file again. |
408 | 408 | * @return boolean true if the file saving is successful |
409 | 409 | */ |
410 | - public function saveAs($fileName,$deleteTempFile=true){ |
|
411 | - if (($this->getErrorCode()===UPLOAD_ERR_OK) && (file_exists($this->getLocalName()))){ |
|
412 | - if ($deleteTempFile) |
|
413 | - return rename($this->getLocalName(),$fileName); |
|
410 | + public function saveAs($fileName, $deleteTempFile=true) { |
|
411 | + if(($this->getErrorCode()===UPLOAD_ERR_OK) && (file_exists($this->getLocalName()))) { |
|
412 | + if($deleteTempFile) |
|
413 | + return rename($this->getLocalName(), $fileName); |
|
414 | 414 | else |
415 | - return copy($this->getLocalName(),$fileName); |
|
415 | + return copy($this->getLocalName(), $fileName); |
|
416 | 416 | } else |
417 | 417 | return false; |
418 | 418 | } |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | * @return TImage the image displayed when an upload |
422 | 422 | * completes successfully. |
423 | 423 | */ |
424 | - public function getSuccessImage(){ |
|
424 | + public function getSuccessImage() { |
|
425 | 425 | $this->ensureChildControls(); |
426 | 426 | return $this->_success; |
427 | 427 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | * @return TImage the image displayed when an upload |
431 | 431 | * does not complete successfully. |
432 | 432 | */ |
433 | - public function getErrorImage(){ |
|
433 | + public function getErrorImage() { |
|
434 | 434 | $this->ensureChildControls(); |
435 | 435 | return $this->_error; |
436 | 436 | } |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | * @return TImage the image displayed when an upload |
440 | 440 | * is in progress. |
441 | 441 | */ |
442 | - public function getBusyImage(){ |
|
442 | + public function getBusyImage() { |
|
443 | 443 | $this->ensureChildControls(); |
444 | 444 | return $this->_busy; |
445 | 445 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * that start with 'fx' are filtered in. |
374 | 374 | */ |
375 | 375 | private function filter_prado_fx($name) { |
376 | - return strncasecmp($name,'fx',2)===0; |
|
376 | + return strncasecmp($name, 'fx', 2)===0; |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -383,13 +383,13 @@ discard block |
||
383 | 383 | * @param boolean optional should the names be all lowercase true/false |
384 | 384 | * @return array array of strings being the class hierarchy of $this. |
385 | 385 | */ |
386 | - public function getClassHierarchy($lowercase = false) |
|
386 | + public function getClassHierarchy($lowercase=false) |
|
387 | 387 | { |
388 | 388 | $class=get_class($this); |
389 | 389 | $classes=array($class); |
390 | - while($class=get_parent_class($class)){array_unshift($classes,$class);} |
|
390 | + while($class=get_parent_class($class)) {array_unshift($classes, $class); } |
|
391 | 391 | if($lowercase) |
392 | - return array_map('strtolower',$classes); |
|
392 | + return array_map('strtolower', $classes); |
|
393 | 393 | return $classes; |
394 | 394 | } |
395 | 395 | |
@@ -412,14 +412,14 @@ discard block |
||
412 | 412 | if($this->_listeningenabled) |
413 | 413 | return; |
414 | 414 | |
415 | - $fx=array_filter(get_class_methods($this),array($this,'filter_prado_fx')); |
|
415 | + $fx=array_filter(get_class_methods($this), array($this, 'filter_prado_fx')); |
|
416 | 416 | |
417 | 417 | foreach($fx as $func) |
418 | - $this->attachEventHandler($func,array($this,$func)); |
|
418 | + $this->attachEventHandler($func, array($this, $func)); |
|
419 | 419 | |
420 | - if(is_a($this,'IDynamicMethods')) { |
|
421 | - $this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER,array($this,'__dycall')); |
|
422 | - array_push($fx,TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
420 | + if(is_a($this, 'IDynamicMethods')) { |
|
421 | + $this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, array($this, '__dycall')); |
|
422 | + array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | $this->_listeningenabled=true; |
@@ -446,14 +446,14 @@ discard block |
||
446 | 446 | if(!$this->_listeningenabled) |
447 | 447 | return; |
448 | 448 | |
449 | - $fx=array_filter(get_class_methods($this),array($this,'filter_prado_fx')); |
|
449 | + $fx=array_filter(get_class_methods($this), array($this, 'filter_prado_fx')); |
|
450 | 450 | |
451 | 451 | foreach($fx as $func) |
452 | - $this->detachEventHandler($func,array($this,$func)); |
|
452 | + $this->detachEventHandler($func, array($this, $func)); |
|
453 | 453 | |
454 | - if(is_a($this,'IDynamicMethods')) { |
|
455 | - $this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER,array($this,'__dycall')); |
|
456 | - array_push($fx,TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
454 | + if(is_a($this, 'IDynamicMethods')) { |
|
455 | + $this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, array($this, '__dycall')); |
|
456 | + array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | $this->_listeningenabled=false; |
@@ -498,66 +498,66 @@ discard block |
||
498 | 498 | */ |
499 | 499 | public function __call($method, $args) |
500 | 500 | { |
501 | - $getset=substr($method,0,3); |
|
502 | - if(($getset=='get')||($getset=='set')) |
|
501 | + $getset=substr($method, 0, 3); |
|
502 | + if(($getset=='get') || ($getset=='set')) |
|
503 | 503 | { |
504 | - $propname=substr($method,3); |
|
504 | + $propname=substr($method, 3); |
|
505 | 505 | $jsmethod=$getset.'js'.$propname; |
506 | - if(method_exists($this,$jsmethod)) |
|
506 | + if(method_exists($this, $jsmethod)) |
|
507 | 507 | { |
508 | - if(count($args)>0) |
|
509 | - if($args[0]&&!($args[0] instanceof TJavaScriptString)) |
|
508 | + if(count($args) > 0) |
|
509 | + if($args[0] && !($args[0] instanceof TJavaScriptString)) |
|
510 | 510 | $args[0]=new TJavaScriptString($args[0]); |
511 | - return call_user_func_array(array($this,$jsmethod),$args); |
|
511 | + return call_user_func_array(array($this, $jsmethod), $args); |
|
512 | 512 | } |
513 | 513 | |
514 | - if (($getset=='set')&&method_exists($this,'getjs'.$propname)) |
|
515 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$method); |
|
514 | + if(($getset=='set') && method_exists($this, 'getjs'.$propname)) |
|
515 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $method); |
|
516 | 516 | } |
517 | 517 | |
518 | - if($this->_m!==null&&$this->_behaviorsenabled) |
|
518 | + if($this->_m!==null && $this->_behaviorsenabled) |
|
519 | 519 | { |
520 | - if(strncasecmp($method,'dy',2)===0) |
|
520 | + if(strncasecmp($method, 'dy', 2)===0) |
|
521 | 521 | { |
522 | 522 | $callchain=new TCallChain($method); |
523 | 523 | foreach($this->_m->toArray() as $behavior) |
524 | 524 | { |
525 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&(method_exists($behavior,$method)||($behavior instanceof IDynamicMethods))) |
|
525 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && (method_exists($behavior, $method) || ($behavior instanceof IDynamicMethods))) |
|
526 | 526 | { |
527 | 527 | $behavior_args=$args; |
528 | 528 | if($behavior instanceof IClassBehavior) |
529 | - array_unshift($behavior_args,$this); |
|
530 | - $callchain->addCall(array($behavior,$method),$behavior_args); |
|
529 | + array_unshift($behavior_args, $this); |
|
530 | + $callchain->addCall(array($behavior, $method), $behavior_args); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | } |
534 | - if($callchain->getCount()>0) |
|
535 | - return call_user_func_array(array($callchain,'call'),$args); |
|
534 | + if($callchain->getCount() > 0) |
|
535 | + return call_user_func_array(array($callchain, 'call'), $args); |
|
536 | 536 | } |
537 | 537 | else |
538 | 538 | { |
539 | 539 | foreach($this->_m->toArray() as $behavior) |
540 | 540 | { |
541 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&method_exists($behavior,$method)) |
|
541 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && method_exists($behavior, $method)) |
|
542 | 542 | { |
543 | 543 | if($behavior instanceof IClassBehavior) |
544 | - array_unshift($args,$this); |
|
545 | - return call_user_func_array(array($behavior,$method),$args); |
|
544 | + array_unshift($args, $this); |
|
545 | + return call_user_func_array(array($behavior, $method), $args); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | } |
549 | 549 | } |
550 | 550 | |
551 | - if(strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0) |
|
551 | + if(strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
552 | 552 | { |
553 | 553 | if($this instanceof IDynamicMethods) |
554 | - return $this->__dycall($method,$args); |
|
555 | - return isset($args[0])?$args[0]:null; |
|
554 | + return $this->__dycall($method, $args); |
|
555 | + return isset($args[0]) ? $args[0] : null; |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | // don't thrown an exception for __magicMethods() or any other weird methods natively implemented by php |
559 | - if (!method_exists($this, $method)) { |
|
560 | - throw new TApplicationException('component_method_undefined',get_class($this),$method); |
|
559 | + if(!method_exists($this, $method)) { |
|
560 | + throw new TApplicationException('component_method_undefined', get_class($this), $method); |
|
561 | 561 | } |
562 | 562 | } |
563 | 563 | |
@@ -587,17 +587,17 @@ discard block |
||
587 | 587 | */ |
588 | 588 | public function __get($name) |
589 | 589 | { |
590 | - if(method_exists($this,$getter='get'.$name)) |
|
590 | + if(method_exists($this, $getter='get'.$name)) |
|
591 | 591 | { |
592 | 592 | // getting a property |
593 | 593 | return $this->$getter(); |
594 | 594 | } |
595 | - else if(method_exists($this,$jsgetter='getjs'.$name)) |
|
595 | + else if(method_exists($this, $jsgetter='getjs'.$name)) |
|
596 | 596 | { |
597 | 597 | // getting a javascript property |
598 | - return (string)$this->$jsgetter(); |
|
598 | + return (string) $this->$jsgetter(); |
|
599 | 599 | } |
600 | - else if(strncasecmp($name,'on',2)===0 && method_exists($this,$name)) |
|
600 | + else if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
601 | 601 | { |
602 | 602 | // getting an event (handler list) |
603 | 603 | $name=strtolower($name); |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | $this->_e[$name]=new TPriorityList; |
606 | 606 | return $this->_e[$name]; |
607 | 607 | } |
608 | - else if(strncasecmp($name,'fx',2)===0) |
|
608 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
609 | 609 | { |
610 | 610 | // getting a global event (handler list) |
611 | 611 | $name=strtolower($name); |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | { |
623 | 623 | foreach($this->_m->toArray() as $behavior) |
624 | 624 | { |
625 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&& |
|
626 | - (property_exists($behavior,$name)||$behavior->canGetProperty($name)||$behavior->hasEvent($name))) |
|
625 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && |
|
626 | + (property_exists($behavior, $name) || $behavior->canGetProperty($name) || $behavior->hasEvent($name))) |
|
627 | 627 | return $behavior->$name; |
628 | 628 | } |
629 | 629 | } |
630 | 630 | } |
631 | - throw new TInvalidOperationException('component_property_undefined',get_class($this),$name); |
|
631 | + throw new TInvalidOperationException('component_property_undefined', get_class($this), $name); |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | /** |
@@ -646,31 +646,31 @@ discard block |
||
646 | 646 | * @param mixed the property value or event handler |
647 | 647 | * @throws TInvalidOperationException If the property is not defined or read-only. |
648 | 648 | */ |
649 | - public function __set($name,$value) |
|
649 | + public function __set($name, $value) |
|
650 | 650 | { |
651 | - if(method_exists($this,$setter='set'.$name)) |
|
651 | + if(method_exists($this, $setter='set'.$name)) |
|
652 | 652 | { |
653 | - if(strncasecmp($name,'js',2)===0&&$value&&!($value instanceof TJavaScriptLiteral)) |
|
654 | - $value = new TJavaScriptLiteral($value); |
|
653 | + if(strncasecmp($name, 'js', 2)===0 && $value && !($value instanceof TJavaScriptLiteral)) |
|
654 | + $value=new TJavaScriptLiteral($value); |
|
655 | 655 | return $this->$setter($value); |
656 | 656 | } |
657 | - else if(method_exists($this,$jssetter='setjs'.$name)) |
|
657 | + else if(method_exists($this, $jssetter='setjs'.$name)) |
|
658 | 658 | { |
659 | - if($value&&!($value instanceof TJavaScriptString)) |
|
659 | + if($value && !($value instanceof TJavaScriptString)) |
|
660 | 660 | $value=new TJavaScriptString($value); |
661 | 661 | return $this->$jssetter($value); |
662 | 662 | } |
663 | - else if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0) |
|
663 | + else if((strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2)===0) |
|
664 | 664 | { |
665 | - return $this->attachEventHandler($name,$value); |
|
665 | + return $this->attachEventHandler($name, $value); |
|
666 | 666 | } |
667 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
667 | + else if($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
668 | 668 | { |
669 | 669 | $sets=0; |
670 | 670 | foreach($this->_m->toArray() as $behavior) |
671 | 671 | { |
672 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&& |
|
673 | - (property_exists($behavior,$name)||$behavior->canSetProperty($name)||$behavior->hasEvent($name))) { |
|
672 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && |
|
673 | + (property_exists($behavior, $name) || $behavior->canSetProperty($name) || $behavior->hasEvent($name))) { |
|
674 | 674 | $behavior->$name=$value; |
675 | 675 | $sets++; |
676 | 676 | } |
@@ -679,13 +679,13 @@ discard block |
||
679 | 679 | |
680 | 680 | } |
681 | 681 | |
682 | - if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name)) |
|
682 | + if(method_exists($this, 'get'.$name) || method_exists($this, 'getjs'.$name)) |
|
683 | 683 | { |
684 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
|
684 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
|
685 | 685 | } |
686 | 686 | else |
687 | 687 | { |
688 | - throw new TInvalidOperationException('component_property_undefined',get_class($this),$name); |
|
688 | + throw new TInvalidOperationException('component_property_undefined', get_class($this), $name); |
|
689 | 689 | } |
690 | 690 | } |
691 | 691 | |
@@ -703,27 +703,27 @@ discard block |
||
703 | 703 | */ |
704 | 704 | public function __isset($name) |
705 | 705 | { |
706 | - if(method_exists($this,$getter='get'.$name)) |
|
706 | + if(method_exists($this, $getter='get'.$name)) |
|
707 | 707 | return $this->$getter()!==null; |
708 | - else if(method_exists($this,$jsgetter='getjs'.$name)) |
|
708 | + else if(method_exists($this, $jsgetter='getjs'.$name)) |
|
709 | 709 | return $this->$jsgetter()!==null; |
710 | - else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name)) |
|
710 | + else if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
711 | 711 | { |
712 | 712 | $name=strtolower($name); |
713 | - return isset($this->_e[$name])&&$this->_e[$name]->getCount(); |
|
713 | + return isset($this->_e[$name]) && $this->_e[$name]->getCount(); |
|
714 | 714 | } |
715 | - else if(strncasecmp($name,'fx',2)===0) |
|
715 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
716 | 716 | { |
717 | 717 | $name=strtolower($name); |
718 | - return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount(); |
|
718 | + return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount(); |
|
719 | 719 | } |
720 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
720 | + else if($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
721 | 721 | { |
722 | 722 | if(isset($this->_m[$name])) |
723 | 723 | return true; |
724 | 724 | foreach($this->_m->toArray() as $behavior) |
725 | 725 | { |
726 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())) |
|
726 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled())) |
|
727 | 727 | return isset($behavior->$name); |
728 | 728 | } |
729 | 729 | |
@@ -744,15 +744,15 @@ discard block |
||
744 | 744 | */ |
745 | 745 | public function __unset($name) |
746 | 746 | { |
747 | - if(method_exists($this,$setter='set'.$name)) |
|
747 | + if(method_exists($this, $setter='set'.$name)) |
|
748 | 748 | $this->$setter(null); |
749 | - else if(method_exists($this,$jssetter='setjs'.$name)) |
|
749 | + else if(method_exists($this, $jssetter='setjs'.$name)) |
|
750 | 750 | $this->$jssetter(null); |
751 | - else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name)) |
|
751 | + else if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
752 | 752 | $this->_e[strtolower($name)]->clear(); |
753 | - else if(strncasecmp($name,'fx',2)===0) |
|
753 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
754 | 754 | $this->getEventHandlers($name)->remove(array($this, $name)); |
755 | - else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled) |
|
755 | + else if($this->_m!==null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) |
|
756 | 756 | { |
757 | 757 | if(isset($this->_m[$name])) |
758 | 758 | $this->detachBehavior($name); |
@@ -760,16 +760,16 @@ discard block |
||
760 | 760 | $unset=0; |
761 | 761 | foreach($this->_m->toArray() as $behavior) |
762 | 762 | { |
763 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())) { |
|
763 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled())) { |
|
764 | 764 | unset($behavior->$name); |
765 | 765 | $unset++; |
766 | 766 | } |
767 | 767 | } |
768 | - if(!$unset&&method_exists($this,'get'.$name)) |
|
769 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
|
768 | + if(!$unset && method_exists($this, 'get'.$name)) |
|
769 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
|
770 | 770 | } |
771 | - } else if(method_exists($this,'get'.$name)) |
|
772 | - throw new TInvalidOperationException('component_property_readonly',get_class($this),$name); |
|
771 | + } else if(method_exists($this, 'get'.$name)) |
|
772 | + throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | /** |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | */ |
782 | 782 | public function hasProperty($name) |
783 | 783 | { |
784 | - return $this->canGetProperty($name)||$this->canSetProperty($name); |
|
784 | + return $this->canGetProperty($name) || $this->canSetProperty($name); |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | /** |
@@ -795,13 +795,13 @@ discard block |
||
795 | 795 | */ |
796 | 796 | public function canGetProperty($name) |
797 | 797 | { |
798 | - if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name)) |
|
798 | + if(method_exists($this, 'get'.$name) || method_exists($this, 'getjs'.$name)) |
|
799 | 799 | return true; |
800 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
800 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
801 | 801 | { |
802 | 802 | foreach($this->_m->toArray() as $behavior) |
803 | 803 | { |
804 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canGetProperty($name)) |
|
804 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canGetProperty($name)) |
|
805 | 805 | return true; |
806 | 806 | } |
807 | 807 | } |
@@ -819,13 +819,13 @@ discard block |
||
819 | 819 | */ |
820 | 820 | public function canSetProperty($name) |
821 | 821 | { |
822 | - if(method_exists($this,'set'.$name)||method_exists($this,'setjs'.$name)) |
|
822 | + if(method_exists($this, 'set'.$name) || method_exists($this, 'setjs'.$name)) |
|
823 | 823 | return true; |
824 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
824 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
825 | 825 | { |
826 | 826 | foreach($this->_m->toArray() as $behavior) |
827 | 827 | { |
828 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canSetProperty($name)) |
|
828 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canSetProperty($name)) |
|
829 | 829 | return true; |
830 | 830 | } |
831 | 831 | } |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | public function getSubProperty($path) |
846 | 846 | { |
847 | 847 | $object=$this; |
848 | - foreach(explode('.',$path) as $property) |
|
848 | + foreach(explode('.', $path) as $property) |
|
849 | 849 | $object=$object->$property; |
850 | 850 | return $object; |
851 | 851 | } |
@@ -860,15 +860,15 @@ discard block |
||
860 | 860 | * @param string property path |
861 | 861 | * @param mixed the property path value |
862 | 862 | */ |
863 | - public function setSubProperty($path,$value) |
|
863 | + public function setSubProperty($path, $value) |
|
864 | 864 | { |
865 | 865 | $object=$this; |
866 | - if(($pos=strrpos($path,'.'))===false) |
|
866 | + if(($pos=strrpos($path, '.'))===false) |
|
867 | 867 | $property=$path; |
868 | 868 | else |
869 | 869 | { |
870 | - $object=$this->getSubProperty(substr($path,0,$pos)); |
|
871 | - $property=substr($path,$pos+1); |
|
870 | + $object=$this->getSubProperty(substr($path, 0, $pos)); |
|
871 | + $property=substr($path, $pos + 1); |
|
872 | 872 | } |
873 | 873 | $object->$property=$value; |
874 | 874 | } |
@@ -887,14 +887,14 @@ discard block |
||
887 | 887 | */ |
888 | 888 | public function hasEvent($name) |
889 | 889 | { |
890 | - if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0||strncasecmp($name,'dy',2)===0) |
|
890 | + if((strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2)===0 || strncasecmp($name, 'dy', 2)===0) |
|
891 | 891 | return true; |
892 | 892 | |
893 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
893 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
894 | 894 | { |
895 | 895 | foreach($this->_m->toArray() as $behavior) |
896 | 896 | { |
897 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name)) |
|
897 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name)) |
|
898 | 898 | return true; |
899 | 899 | } |
900 | 900 | } |
@@ -911,16 +911,16 @@ discard block |
||
911 | 911 | public function hasEventHandler($name) |
912 | 912 | { |
913 | 913 | $name=strtolower($name); |
914 | - if(strncasecmp($name,'fx',2)===0) |
|
915 | - return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount()>0; |
|
914 | + if(strncasecmp($name, 'fx', 2)===0) |
|
915 | + return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount() > 0; |
|
916 | 916 | else |
917 | 917 | { |
918 | - if(isset($this->_e[$name])&&$this->_e[$name]->getCount()>0) |
|
918 | + if(isset($this->_e[$name]) && $this->_e[$name]->getCount() > 0) |
|
919 | 919 | return true; |
920 | - else if($this->_m!==null&&$this->_behaviorsenabled) { |
|
920 | + else if($this->_m!==null && $this->_behaviorsenabled) { |
|
921 | 921 | foreach($this->_m->toArray() as $behavior) |
922 | 922 | { |
923 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEventHandler($name)) |
|
923 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEventHandler($name)) |
|
924 | 924 | return true; |
925 | 925 | } |
926 | 926 | } |
@@ -936,29 +936,29 @@ discard block |
||
936 | 936 | */ |
937 | 937 | public function getEventHandlers($name) |
938 | 938 | { |
939 | - if(strncasecmp($name,'on',2)===0&&method_exists($this,$name)) |
|
939 | + if(strncasecmp($name, 'on', 2)===0 && method_exists($this, $name)) |
|
940 | 940 | { |
941 | 941 | $name=strtolower($name); |
942 | 942 | if(!isset($this->_e[$name])) |
943 | 943 | $this->_e[$name]=new TPriorityList; |
944 | 944 | return $this->_e[$name]; |
945 | 945 | } |
946 | - else if(strncasecmp($name,'fx',2)===0) |
|
946 | + else if(strncasecmp($name, 'fx', 2)===0) |
|
947 | 947 | { |
948 | 948 | $name=strtolower($name); |
949 | 949 | if(!isset(self::$_ue[$name])) |
950 | 950 | self::$_ue[$name]=new TPriorityList; |
951 | 951 | return self::$_ue[$name]; |
952 | 952 | } |
953 | - else if($this->_m!==null&&$this->_behaviorsenabled) |
|
953 | + else if($this->_m!==null && $this->_behaviorsenabled) |
|
954 | 954 | { |
955 | 955 | foreach($this->_m->toArray() as $behavior) |
956 | 956 | { |
957 | - if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name)) |
|
957 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name)) |
|
958 | 958 | return $behavior->getEventHandlers($name); |
959 | 959 | } |
960 | 960 | } |
961 | - throw new TInvalidOperationException('component_event_undefined',get_class($this),$name); |
|
961 | + throw new TInvalidOperationException('component_event_undefined', get_class($this), $name); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | /** |
@@ -1006,9 +1006,9 @@ discard block |
||
1006 | 1006 | * default priority of 10.0 within {@link TPriorityList} |
1007 | 1007 | * @throws TInvalidOperationException if the event does not exist |
1008 | 1008 | */ |
1009 | - public function attachEventHandler($name,$handler,$priority=null) |
|
1009 | + public function attachEventHandler($name, $handler, $priority=null) |
|
1010 | 1010 | { |
1011 | - $this->getEventHandlers($name)->add($handler,$priority); |
|
1011 | + $this->getEventHandlers($name)->add($handler, $priority); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | /** |
@@ -1021,13 +1021,13 @@ discard block |
||
1021 | 1021 | * to an item of any priority within {@link TPriorityList}; null means the default priority |
1022 | 1022 | * @return boolean if the removal is successful |
1023 | 1023 | */ |
1024 | - public function detachEventHandler($name,$handler,$priority=false) |
|
1024 | + public function detachEventHandler($name, $handler, $priority=false) |
|
1025 | 1025 | { |
1026 | 1026 | if($this->hasEventHandler($name)) |
1027 | 1027 | { |
1028 | 1028 | try |
1029 | 1029 | { |
1030 | - $this->getEventHandlers($name)->remove($handler,$priority); |
|
1030 | + $this->getEventHandlers($name)->remove($handler, $priority); |
|
1031 | 1031 | return true; |
1032 | 1032 | } |
1033 | 1033 | catch(Exception $e) |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | * @throws TInvalidOperationException if the event is undefined |
1110 | 1110 | * @throws TInvalidDataValueException If an event handler is invalid |
1111 | 1111 | */ |
1112 | - public function raiseEvent($name,$sender,$param,$responsetype=null,$postfunction=null) |
|
1112 | + public function raiseEvent($name, $sender, $param, $responsetype=null, $postfunction=null) |
|
1113 | 1113 | { |
1114 | 1114 | $p=$param; |
1115 | 1115 | if(is_callable($responsetype)) |
@@ -1124,90 +1124,90 @@ discard block |
||
1124 | 1124 | $name=strtolower($name); |
1125 | 1125 | $responses=array(); |
1126 | 1126 | |
1127 | - $name=$this->dyPreRaiseEvent($name,$sender,$param,$responsetype,$postfunction); |
|
1127 | + $name=$this->dyPreRaiseEvent($name, $sender, $param, $responsetype, $postfunction); |
|
1128 | 1128 | |
1129 | - if($this->hasEventHandler($name)||$this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
1129 | + if($this->hasEventHandler($name) || $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
1130 | 1130 | { |
1131 | 1131 | $handlers=$this->getEventHandlers($name); |
1132 | 1132 | $handlerArray=$handlers->toArray(); |
1133 | - if(strncasecmp($name,'fx',2)===0&&$this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
1133 | + if(strncasecmp($name, 'fx', 2)===0 && $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) |
|
1134 | 1134 | { |
1135 | 1135 | $globalhandlers=$this->getEventHandlers(TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
1136 | - $handlerArray=array_merge($globalhandlers->toArrayBelowPriority(0),$handlerArray,$globalhandlers->toArrayAbovePriority(0)); |
|
1136 | + $handlerArray=array_merge($globalhandlers->toArrayBelowPriority(0), $handlerArray, $globalhandlers->toArrayAbovePriority(0)); |
|
1137 | 1137 | } |
1138 | 1138 | $response=null; |
1139 | 1139 | foreach($handlerArray as $handler) |
1140 | 1140 | { |
1141 | - if($this->dyIntraRaiseEventTestHandler($handler,$sender,$param,$name)===false) |
|
1141 | + if($this->dyIntraRaiseEventTestHandler($handler, $sender, $param, $name)===false) |
|
1142 | 1142 | continue; |
1143 | 1143 | |
1144 | 1144 | if(is_string($handler)) |
1145 | 1145 | { |
1146 | - if(($pos=strrpos($handler,'.'))!==false) |
|
1146 | + if(($pos=strrpos($handler, '.'))!==false) |
|
1147 | 1147 | { |
1148 | - $object=$this->getSubProperty(substr($handler,0,$pos)); |
|
1149 | - $method=substr($handler,$pos+1); |
|
1150 | - if(method_exists($object,$method)||strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0) |
|
1148 | + $object=$this->getSubProperty(substr($handler, 0, $pos)); |
|
1149 | + $method=substr($handler, $pos + 1); |
|
1150 | + if(method_exists($object, $method) || strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
1151 | 1151 | { |
1152 | 1152 | if($method=='__dycall') |
1153 | - $response=$object->__dycall($name,array($sender,$param,$name)); |
|
1153 | + $response=$object->__dycall($name, array($sender, $param, $name)); |
|
1154 | 1154 | else |
1155 | - $response=$object->$method($sender,$param,$name); |
|
1155 | + $response=$object->$method($sender, $param, $name); |
|
1156 | 1156 | } |
1157 | 1157 | else |
1158 | - throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler); |
|
1158 | + throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler); |
|
1159 | 1159 | } |
1160 | 1160 | else |
1161 | - $response=call_user_func($handler,$sender,$param,$name); |
|
1161 | + $response=call_user_func($handler, $sender, $param, $name); |
|
1162 | 1162 | } |
1163 | - else if(is_callable($handler,true)) |
|
1163 | + else if(is_callable($handler, true)) |
|
1164 | 1164 | { |
1165 | - list($object,$method)=$handler; |
|
1165 | + list($object, $method)=$handler; |
|
1166 | 1166 | if(is_string($object)) |
1167 | - $response=call_user_func($handler,$sender,$param,$name); |
|
1167 | + $response=call_user_func($handler, $sender, $param, $name); |
|
1168 | 1168 | else |
1169 | 1169 | { |
1170 | - if(($pos=strrpos($method,'.'))!==false) |
|
1170 | + if(($pos=strrpos($method, '.'))!==false) |
|
1171 | 1171 | { |
1172 | - $object=$this->getSubProperty(substr($method,0,$pos)); |
|
1173 | - $method=substr($method,$pos+1); |
|
1172 | + $object=$this->getSubProperty(substr($method, 0, $pos)); |
|
1173 | + $method=substr($method, $pos + 1); |
|
1174 | 1174 | } |
1175 | - if(method_exists($object,$method)||strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0) |
|
1175 | + if(method_exists($object, $method) || strncasecmp($method, 'dy', 2)===0 || strncasecmp($method, 'fx', 2)===0) |
|
1176 | 1176 | { |
1177 | 1177 | if($method=='__dycall') |
1178 | - $response=$object->__dycall($name,array($sender,$param,$name)); |
|
1178 | + $response=$object->__dycall($name, array($sender, $param, $name)); |
|
1179 | 1179 | else |
1180 | - $response=$object->$method($sender,$param,$name); |
|
1180 | + $response=$object->$method($sender, $param, $name); |
|
1181 | 1181 | } |
1182 | 1182 | else |
1183 | - throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler[1]); |
|
1183 | + throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler[1]); |
|
1184 | 1184 | } |
1185 | 1185 | } |
1186 | 1186 | else |
1187 | - throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,gettype($handler)); |
|
1187 | + throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, gettype($handler)); |
|
1188 | 1188 | |
1189 | - $this->dyIntraRaiseEventPostHandler($name,$sender,$param,$handler,$response); |
|
1189 | + $this->dyIntraRaiseEventPostHandler($name, $sender, $param, $handler, $response); |
|
1190 | 1190 | |
1191 | 1191 | if($postfunction) |
1192 | - $response=call_user_func_array($postfunction,array($sender,$param,$this,$response)); |
|
1192 | + $response=call_user_func_array($postfunction, array($sender, $param, $this, $response)); |
|
1193 | 1193 | |
1194 | - if($responsetype&TEventResults::EVENT_RESULT_ALL) |
|
1195 | - $responses[]=array('sender'=>$sender,'param'=>$param,'response'=>$response); |
|
1194 | + if($responsetype & TEventResults::EVENT_RESULT_ALL) |
|
1195 | + $responses[]=array('sender'=>$sender, 'param'=>$param, 'response'=>$response); |
|
1196 | 1196 | else |
1197 | 1197 | $responses[]=$response; |
1198 | 1198 | |
1199 | - if($response!==null&&($responsetype&TEventResults::EVENT_RESULT_FEED_FORWARD)) |
|
1199 | + if($response!==null && ($responsetype & TEventResults::EVENT_RESULT_FEED_FORWARD)) |
|
1200 | 1200 | $param=$response; |
1201 | 1201 | |
1202 | 1202 | } |
1203 | 1203 | } |
1204 | - else if(strncasecmp($name,'on',2)===0&&!$this->hasEvent($name)) |
|
1205 | - throw new TInvalidOperationException('component_event_undefined',get_class($this),$name); |
|
1204 | + else if(strncasecmp($name, 'on', 2)===0 && !$this->hasEvent($name)) |
|
1205 | + throw new TInvalidOperationException('component_event_undefined', get_class($this), $name); |
|
1206 | 1206 | |
1207 | - if($responsetype&TEventResults::EVENT_RESULT_FILTER) |
|
1207 | + if($responsetype & TEventResults::EVENT_RESULT_FILTER) |
|
1208 | 1208 | $responses=array_filter($responses); |
1209 | 1209 | |
1210 | - $responses=$this->dyPostRaiseEvent($responses,$name,$sender,$param,$responsetype,$postfunction); |
|
1210 | + $responses=$this->dyPostRaiseEvent($responses, $name, $sender, $param, $responsetype, $postfunction); |
|
1211 | 1211 | |
1212 | 1212 | return $responses; |
1213 | 1213 | } |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | } |
1241 | 1241 | catch(Exception $e) |
1242 | 1242 | { |
1243 | - throw new TInvalidOperationException('component_expression_invalid',get_class($this),$expression,$e->getMessage()); |
|
1243 | + throw new TInvalidOperationException('component_expression_invalid', get_class($this), $expression, $e->getMessage()); |
|
1244 | 1244 | } |
1245 | 1245 | } |
1246 | 1246 | |
@@ -1275,7 +1275,7 @@ discard block |
||
1275 | 1275 | } |
1276 | 1276 | catch(Exception $e) |
1277 | 1277 | { |
1278 | - throw new TInvalidOperationException('component_statements_invalid',get_class($this),$statements,$e->getMessage()); |
|
1278 | + throw new TInvalidOperationException('component_statements_invalid', get_class($this), $statements, $e->getMessage()); |
|
1279 | 1279 | } |
1280 | 1280 | } |
1281 | 1281 | |
@@ -1335,9 +1335,9 @@ discard block |
||
1335 | 1335 | * @param $param TClassBehaviorEventParameter |
1336 | 1336 | * @since 3.2.3 |
1337 | 1337 | */ |
1338 | - public function fxAttachClassBehavior($sender,$param) { |
|
1339 | - if(in_array($param->getClass(),$this->getClassHierarchy(true))) |
|
1340 | - return $this->attachBehavior($param->getName(),$param->getBehavior(),$param->getPriority()); |
|
1338 | + public function fxAttachClassBehavior($sender, $param) { |
|
1339 | + if(in_array($param->getClass(), $this->getClassHierarchy(true))) |
|
1340 | + return $this->attachBehavior($param->getName(), $param->getBehavior(), $param->getPriority()); |
|
1341 | 1341 | } |
1342 | 1342 | |
1343 | 1343 | |
@@ -1349,9 +1349,9 @@ discard block |
||
1349 | 1349 | * @param $param TClassBehaviorEventParameter |
1350 | 1350 | * @since 3.2.3 |
1351 | 1351 | */ |
1352 | - public function fxDetachClassBehavior($sender,$param) { |
|
1353 | - if(in_array($param->getClass(),$this->getClassHierarchy(true))) |
|
1354 | - return $this->detachBehavior($param->getName(),$param->getPriority()); |
|
1352 | + public function fxDetachClassBehavior($sender, $param) { |
|
1353 | + if(in_array($param->getClass(), $this->getClassHierarchy(true))) |
|
1354 | + return $this->detachBehavior($param->getName(), $param->getPriority()); |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | |
@@ -1373,8 +1373,8 @@ discard block |
||
1373 | 1373 | * @throws TInvalidOperationException if the class behavior is already defined |
1374 | 1374 | * @since 3.2.3 |
1375 | 1375 | */ |
1376 | - public static function attachClassBehavior($name,$behavior,$class=null,$priority=null) { |
|
1377 | - if(!$class&&function_exists('get_called_class')) |
|
1376 | + public static function attachClassBehavior($name, $behavior, $class=null, $priority=null) { |
|
1377 | + if(!$class && function_exists('get_called_class')) |
|
1378 | 1378 | $class=get_called_class(); |
1379 | 1379 | if(!$class) |
1380 | 1380 | throw new TInvalidOperationException('component_no_class_provided_nor_late_binding'); |
@@ -1387,11 +1387,11 @@ discard block |
||
1387 | 1387 | if(empty(self::$_um[$class])) |
1388 | 1388 | self::$_um[$class]=array(); |
1389 | 1389 | if(isset(self::$_um[$class][$name])) |
1390 | - throw new TInvalidOperationException('component_class_behavior_defined',$class,$name); |
|
1391 | - $param=new TClassBehaviorEventParameter($class,$name,$behavior,$priority); |
|
1392 | - self::$_um[$class]=array($name=>$param)+self::$_um[$class]; |
|
1393 | - $behaviorObject=is_string($behavior)?new $behavior:$behavior; |
|
1394 | - return $behaviorObject->raiseEvent('fxAttachClassBehavior',null,$param); |
|
1390 | + throw new TInvalidOperationException('component_class_behavior_defined', $class, $name); |
|
1391 | + $param=new TClassBehaviorEventParameter($class, $name, $behavior, $priority); |
|
1392 | + self::$_um[$class]=array($name=>$param) + self::$_um[$class]; |
|
1393 | + $behaviorObject=is_string($behavior) ? new $behavior : $behavior; |
|
1394 | + return $behaviorObject->raiseEvent('fxAttachClassBehavior', null, $param); |
|
1395 | 1395 | } |
1396 | 1396 | |
1397 | 1397 | |
@@ -1407,8 +1407,8 @@ discard block |
||
1407 | 1407 | * not supplied as a parameter. |
1408 | 1408 | * @since 3.2.3 |
1409 | 1409 | */ |
1410 | - public static function detachClassBehavior($name,$class=null,$priority=false) { |
|
1411 | - if(!$class&&function_exists('get_called_class')) |
|
1410 | + public static function detachClassBehavior($name, $class=null, $priority=false) { |
|
1411 | + if(!$class && function_exists('get_called_class')) |
|
1412 | 1412 | $class=get_called_class(); |
1413 | 1413 | if(!$class) |
1414 | 1414 | throw new TInvalidOperationException('component_no_class_provided_nor_late_binding'); |
@@ -1416,13 +1416,13 @@ discard block |
||
1416 | 1416 | $class=strtolower($class); |
1417 | 1417 | if(!is_string($name)) |
1418 | 1418 | $name=get_class($name); |
1419 | - if(empty(self::$_um[$class])||!isset(self::$_um[$class][$name])) |
|
1419 | + if(empty(self::$_um[$class]) || !isset(self::$_um[$class][$name])) |
|
1420 | 1420 | return false; |
1421 | 1421 | $param=self::$_um[$class][$name]; |
1422 | 1422 | $behavior=$param->getBehavior(); |
1423 | 1423 | unset(self::$_um[$class][$name]); |
1424 | - $behaviorObject=is_string($behavior)?new $behavior:$behavior; |
|
1425 | - return $behaviorObject->raiseEvent('fxDetachClassBehavior',null,$param); |
|
1424 | + $behaviorObject=is_string($behavior) ? new $behavior : $behavior; |
|
1425 | + return $behaviorObject->raiseEvent('fxDetachClassBehavior', null, $param); |
|
1426 | 1426 | } |
1427 | 1427 | |
1428 | 1428 | /** |
@@ -1434,7 +1434,7 @@ discard block |
||
1434 | 1434 | */ |
1435 | 1435 | public function asa($behaviorname) |
1436 | 1436 | { |
1437 | - return isset($this->_m[$behaviorname])?$this->_m[$behaviorname]:null; |
|
1437 | + return isset($this->_m[$behaviorname]) ? $this->_m[$behaviorname] : null; |
|
1438 | 1438 | } |
1439 | 1439 | |
1440 | 1440 | /** |
@@ -1460,15 +1460,15 @@ discard block |
||
1460 | 1460 | { |
1461 | 1461 | if($this instanceof $class) |
1462 | 1462 | return true; |
1463 | - if($this->_m!==null&&$this->_behaviorsenabled) |
|
1464 | - foreach($this->_m->toArray() as $behavior){ |
|
1465 | - if(($behavior instanceof IBehavior)&&!$behavior->getEnabled()) |
|
1463 | + if($this->_m!==null && $this->_behaviorsenabled) |
|
1464 | + foreach($this->_m->toArray() as $behavior) { |
|
1465 | + if(($behavior instanceof IBehavior) && !$behavior->getEnabled()) |
|
1466 | 1466 | continue; |
1467 | 1467 | |
1468 | - $check = null; |
|
1469 | - if(($behavior->isa('IInstanceCheck'))&&$check=$behavior->isinstanceof($class,$this)) |
|
1468 | + $check=null; |
|
1469 | + if(($behavior->isa('IInstanceCheck')) && $check=$behavior->isinstanceof($class, $this)) |
|
1470 | 1470 | return true; |
1471 | - if($check===null&&($behavior->isa($class))) |
|
1471 | + if($check===null && ($behavior->isa($class))) |
|
1472 | 1472 | return true; |
1473 | 1473 | } |
1474 | 1474 | return false; |
@@ -1486,9 +1486,9 @@ discard block |
||
1486 | 1486 | { |
1487 | 1487 | foreach($behaviors as $name=>$behavior) |
1488 | 1488 | if($behavior instanceof TClassBehaviorEventParameter) |
1489 | - $this->attachBehavior($behavior->getName(),$behavior->getBehavior(),$behavior->getPriority()); |
|
1489 | + $this->attachBehavior($behavior->getName(), $behavior->getBehavior(), $behavior->getPriority()); |
|
1490 | 1490 | else |
1491 | - $this->attachBehavior($name,$behavior); |
|
1491 | + $this->attachBehavior($name, $behavior); |
|
1492 | 1492 | } |
1493 | 1493 | |
1494 | 1494 | /** |
@@ -1505,9 +1505,9 @@ discard block |
||
1505 | 1505 | { |
1506 | 1506 | foreach($behaviors as $name=>$behavior) |
1507 | 1507 | if($behavior instanceof TClassBehaviorEventParameter) |
1508 | - $this->detachBehavior($behavior->getName(),$behavior->getPriority()); |
|
1508 | + $this->detachBehavior($behavior->getName(), $behavior->getPriority()); |
|
1509 | 1509 | else |
1510 | - $this->detachBehavior(is_string($behavior)?$behavior:$name); |
|
1510 | + $this->detachBehavior(is_string($behavior) ? $behavior : $name); |
|
1511 | 1511 | } |
1512 | 1512 | } |
1513 | 1513 | |
@@ -1545,19 +1545,19 @@ discard block |
||
1545 | 1545 | * @return IBehavior the behavior object |
1546 | 1546 | * @since 3.2.3 |
1547 | 1547 | */ |
1548 | - public function attachBehavior($name,$behavior,$priority=null) |
|
1548 | + public function attachBehavior($name, $behavior, $priority=null) |
|
1549 | 1549 | { |
1550 | 1550 | if(is_string($behavior)) |
1551 | 1551 | $behavior=Prado::createComponent($behavior); |
1552 | 1552 | if(!($behavior instanceof IBaseBehavior)) |
1553 | - throw new TInvalidDataTypeException('component_not_a_behavior',get_class($behavior)); |
|
1553 | + throw new TInvalidDataTypeException('component_not_a_behavior', get_class($behavior)); |
|
1554 | 1554 | if($behavior instanceof IBehavior) |
1555 | 1555 | $behavior->setEnabled(true); |
1556 | 1556 | if($this->_m===null) |
1557 | 1557 | $this->_m=new TPriorityMap; |
1558 | 1558 | $behavior->attach($this); |
1559 | - $this->dyAttachBehavior($name,$behavior); |
|
1560 | - $this->_m->add($name,$behavior,$priority); |
|
1559 | + $this->dyAttachBehavior($name, $behavior); |
|
1560 | + $this->_m->add($name, $behavior, $priority); |
|
1561 | 1561 | return $behavior; |
1562 | 1562 | } |
1563 | 1563 | |
@@ -1578,14 +1578,14 @@ discard block |
||
1578 | 1578 | * @return IBehavior the detached behavior. Null if the behavior does not exist. |
1579 | 1579 | * @since 3.2.3 |
1580 | 1580 | */ |
1581 | - public function detachBehavior($name,$priority=false) |
|
1581 | + public function detachBehavior($name, $priority=false) |
|
1582 | 1582 | { |
1583 | - if($this->_m!=null&&isset($this->_m[$name])) |
|
1583 | + if($this->_m!=null && isset($this->_m[$name])) |
|
1584 | 1584 | { |
1585 | 1585 | $this->_m[$name]->detach($this); |
1586 | 1586 | $behavior=$this->_m->itemAt($name); |
1587 | - $this->_m->remove($name,$priority); |
|
1588 | - $this->dyDetachBehavior($name,$behavior); |
|
1587 | + $this->_m->remove($name, $priority); |
|
1588 | + $this->dyDetachBehavior($name, $behavior); |
|
1589 | 1589 | return $behavior; |
1590 | 1590 | } |
1591 | 1591 | } |
@@ -1661,10 +1661,10 @@ discard block |
||
1661 | 1661 | */ |
1662 | 1662 | public function enableBehavior($name) |
1663 | 1663 | { |
1664 | - if($this->_m!=null&&isset($this->_m[$name])){ |
|
1664 | + if($this->_m!=null && isset($this->_m[$name])) { |
|
1665 | 1665 | if($this->_m[$name] instanceof IBehavior) { |
1666 | 1666 | $this->_m[$name]->setEnabled(true); |
1667 | - $this->dyEnableBehavior($name,$this->_m[$name]); |
|
1667 | + $this->dyEnableBehavior($name, $this->_m[$name]); |
|
1668 | 1668 | return true; |
1669 | 1669 | } |
1670 | 1670 | return false; |
@@ -1689,10 +1689,10 @@ discard block |
||
1689 | 1689 | */ |
1690 | 1690 | public function disableBehavior($name) |
1691 | 1691 | { |
1692 | - if($this->_m!=null&&isset($this->_m[$name])){ |
|
1692 | + if($this->_m!=null && isset($this->_m[$name])) { |
|
1693 | 1693 | if($this->_m[$name] instanceof IBehavior) { |
1694 | 1694 | $this->_m[$name]->setEnabled(false); |
1695 | - $this->dyDisableBehavior($name,$this->_m[$name]); |
|
1695 | + $this->dyDisableBehavior($name, $this->_m[$name]); |
|
1696 | 1696 | return true; |
1697 | 1697 | } |
1698 | 1698 | return false; |
@@ -1707,9 +1707,9 @@ discard block |
||
1707 | 1707 | */ |
1708 | 1708 | public function __sleep() |
1709 | 1709 | { |
1710 | - $a = (array)$this; |
|
1711 | - $a = array_keys($a); |
|
1712 | - $exprops = array(); |
|
1710 | + $a=(array) $this; |
|
1711 | + $a=array_keys($a); |
|
1712 | + $exprops=array(); |
|
1713 | 1713 | $this->_getZappableSleepProps($exprops); |
1714 | 1714 | return array_diff($a, $exprops); |
1715 | 1715 | } |
@@ -1723,13 +1723,13 @@ discard block |
||
1723 | 1723 | protected function _getZappableSleepProps(&$exprops) |
1724 | 1724 | { |
1725 | 1725 | if($this->_listeningenabled===false) |
1726 | - $exprops[] = "\0TComponent\0_listeningenabled"; |
|
1726 | + $exprops[]="\0TComponent\0_listeningenabled"; |
|
1727 | 1727 | if($this->_behaviorsenabled===true) |
1728 | - $exprops[] = "\0TComponent\0_behaviorsenabled"; |
|
1729 | - if ($this->_e===array()) |
|
1730 | - $exprops[] = "\0TComponent\0_e"; |
|
1731 | - if ($this->_m===null) |
|
1732 | - $exprops[] = "\0TComponent\0_m"; |
|
1728 | + $exprops[]="\0TComponent\0_behaviorsenabled"; |
|
1729 | + if($this->_e===array()) |
|
1730 | + $exprops[]="\0TComponent\0_e"; |
|
1731 | + if($this->_m===null) |
|
1732 | + $exprops[]="\0TComponent\0_m"; |
|
1733 | 1733 | } |
1734 | 1734 | } |
1735 | 1735 | |
@@ -1745,7 +1745,7 @@ discard block |
||
1745 | 1745 | */ |
1746 | 1746 | interface IDynamicMethods |
1747 | 1747 | { |
1748 | - public function __dycall($method,$args); |
|
1748 | + public function __dycall($method, $args); |
|
1749 | 1749 | } |
1750 | 1750 | |
1751 | 1751 | |
@@ -1772,7 +1772,7 @@ discard block |
||
1772 | 1772 | * @param string $name the name of the behavior |
1773 | 1773 | * @param object $behavior this is the behavior to implement the class behavior |
1774 | 1774 | */ |
1775 | - public function __construct($class,$name,$behavior,$priority) |
|
1775 | + public function __construct($class, $name, $behavior, $priority) |
|
1776 | 1776 | { |
1777 | 1777 | $this->_class=$class; |
1778 | 1778 | $this->_name=$name; |
@@ -1913,10 +1913,10 @@ discard block |
||
1913 | 1913 | */ |
1914 | 1914 | public static function ensureBoolean($value) |
1915 | 1915 | { |
1916 | - if (is_string($value)) |
|
1917 | - return strcasecmp($value,'true')==0 || $value!=0; |
|
1916 | + if(is_string($value)) |
|
1917 | + return strcasecmp($value, 'true')==0 || $value!=0; |
|
1918 | 1918 | else |
1919 | - return (boolean)$value; |
|
1919 | + return (boolean) $value; |
|
1920 | 1920 | } |
1921 | 1921 | |
1922 | 1922 | /** |
@@ -1928,12 +1928,12 @@ discard block |
||
1928 | 1928 | */ |
1929 | 1929 | public static function ensureString($value) |
1930 | 1930 | { |
1931 | - if (TJavaScript::isJsLiteral($value)) |
|
1931 | + if(TJavaScript::isJsLiteral($value)) |
|
1932 | 1932 | return $value; |
1933 | - if (is_bool($value)) |
|
1934 | - return $value?'true':'false'; |
|
1933 | + if(is_bool($value)) |
|
1934 | + return $value ? 'true' : 'false'; |
|
1935 | 1935 | else |
1936 | - return (string)$value; |
|
1936 | + return (string) $value; |
|
1937 | 1937 | } |
1938 | 1938 | |
1939 | 1939 | /** |
@@ -1943,7 +1943,7 @@ discard block |
||
1943 | 1943 | */ |
1944 | 1944 | public static function ensureInteger($value) |
1945 | 1945 | { |
1946 | - return (integer)$value; |
|
1946 | + return (integer) $value; |
|
1947 | 1947 | } |
1948 | 1948 | |
1949 | 1949 | /** |
@@ -1953,7 +1953,7 @@ discard block |
||
1953 | 1953 | */ |
1954 | 1954 | public static function ensureFloat($value) |
1955 | 1955 | { |
1956 | - return (float)$value; |
|
1956 | + return (float) $value; |
|
1957 | 1957 | } |
1958 | 1958 | |
1959 | 1959 | /** |
@@ -1969,18 +1969,18 @@ discard block |
||
1969 | 1969 | { |
1970 | 1970 | if(is_string($value)) |
1971 | 1971 | { |
1972 | - $value = trim($value); |
|
1973 | - $len = strlen($value); |
|
1974 | - if ($len >= 2 && $value[0] == '(' && $value[$len-1] == ')') |
|
1972 | + $value=trim($value); |
|
1973 | + $len=strlen($value); |
|
1974 | + if($len >= 2 && $value[0]=='(' && $value[$len - 1]==')') |
|
1975 | 1975 | { |
1976 | 1976 | eval('$array=array'.$value.';'); |
1977 | 1977 | return $array; |
1978 | 1978 | } |
1979 | 1979 | else |
1980 | - return $len>0?array($value):array(); |
|
1980 | + return $len > 0 ? array($value) : array(); |
|
1981 | 1981 | } |
1982 | 1982 | else |
1983 | - return (array)$value; |
|
1983 | + return (array) $value; |
|
1984 | 1984 | } |
1985 | 1985 | |
1986 | 1986 | /** |
@@ -1990,7 +1990,7 @@ discard block |
||
1990 | 1990 | */ |
1991 | 1991 | public static function ensureObject($value) |
1992 | 1992 | { |
1993 | - return (object)$value; |
|
1993 | + return (object) $value; |
|
1994 | 1994 | } |
1995 | 1995 | |
1996 | 1996 | /** |
@@ -2009,7 +2009,7 @@ discard block |
||
2009 | 2009 | * @return string the valid enumeration value |
2010 | 2010 | * @throws TInvalidDataValueException if the original value is not in the string array. |
2011 | 2011 | */ |
2012 | - public static function ensureEnum($value,$enums) |
|
2012 | + public static function ensureEnum($value, $enums) |
|
2013 | 2013 | { |
2014 | 2014 | static $types=array(); |
2015 | 2015 | if(func_num_args()===2 && is_string($enums)) |
@@ -2020,18 +2020,18 @@ discard block |
||
2020 | 2020 | return $value; |
2021 | 2021 | else |
2022 | 2022 | throw new TInvalidDataValueException( |
2023 | - 'propertyvalue_enumvalue_invalid',$value, |
|
2024 | - implode(' | ',$types[$enums]->getConstants())); |
|
2023 | + 'propertyvalue_enumvalue_invalid', $value, |
|
2024 | + implode(' | ', $types[$enums]->getConstants())); |
|
2025 | 2025 | } |
2026 | 2026 | else if(!is_array($enums)) |
2027 | 2027 | { |
2028 | 2028 | $enums=func_get_args(); |
2029 | 2029 | array_shift($enums); |
2030 | 2030 | } |
2031 | - if(in_array($value,$enums,true)) |
|
2031 | + if(in_array($value, $enums, true)) |
|
2032 | 2032 | return $value; |
2033 | 2033 | else |
2034 | - throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid',$value,implode(' | ',$enums)); |
|
2034 | + throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid', $value, implode(' | ', $enums)); |
|
2035 | 2035 | } |
2036 | 2036 | |
2037 | 2037 | /** |
@@ -2041,7 +2041,7 @@ discard block |
||
2041 | 2041 | */ |
2042 | 2042 | public static function ensureNullIfEmpty($value) |
2043 | 2043 | { |
2044 | - return empty($value)?null:$value; |
|
2044 | + return empty($value) ? null : $value; |
|
2045 | 2045 | } |
2046 | 2046 | } |
2047 | 2047 | |
@@ -2094,7 +2094,7 @@ discard block |
||
2094 | 2094 | */ |
2095 | 2095 | public function __construct($component) |
2096 | 2096 | { |
2097 | - if(is_string($component) && class_exists($component,false)) |
|
2097 | + if(is_string($component) && class_exists($component, false)) |
|
2098 | 2098 | $this->_className=$component; |
2099 | 2099 | else if(is_object($component)) |
2100 | 2100 | $this->_className=get_class($component); |
@@ -2107,14 +2107,14 @@ discard block |
||
2107 | 2107 | { |
2108 | 2108 | $methodName=$method->getName(); |
2109 | 2109 | return $method->getNumberOfRequiredParameters()===0 |
2110 | - && strncasecmp($methodName,'get',3)===0 |
|
2110 | + && strncasecmp($methodName, 'get', 3)===0 |
|
2111 | 2111 | && isset($methodName[3]); |
2112 | 2112 | } |
2113 | 2113 | |
2114 | 2114 | private function isEventMethod($method) |
2115 | 2115 | { |
2116 | 2116 | $methodName=$method->getName(); |
2117 | - return strncasecmp($methodName,'on',2)===0 |
|
2117 | + return strncasecmp($methodName, 'on', 2)===0 |
|
2118 | 2118 | && isset($methodName[2]); |
2119 | 2119 | } |
2120 | 2120 | |
@@ -2124,7 +2124,7 @@ discard block |
||
2124 | 2124 | $properties=array(); |
2125 | 2125 | $events=array(); |
2126 | 2126 | $methods=array(); |
2127 | - $isComponent=is_subclass_of($this->_className,'TComponent') || strcasecmp($this->_className,'TComponent')===0; |
|
2127 | + $isComponent=is_subclass_of($this->_className, 'TComponent') || strcasecmp($this->_className, 'TComponent')===0; |
|
2128 | 2128 | foreach($class->getMethods() as $method) |
2129 | 2129 | { |
2130 | 2130 | if($method->isPublic() || $method->isProtected()) |
@@ -2133,14 +2133,14 @@ discard block |
||
2133 | 2133 | if(!$method->isStatic() && $isComponent) |
2134 | 2134 | { |
2135 | 2135 | if($this->isPropertyMethod($method)) |
2136 | - $properties[substr($methodName,3)]=$method; |
|
2136 | + $properties[substr($methodName, 3)]=$method; |
|
2137 | 2137 | else if($this->isEventMethod($method)) |
2138 | 2138 | { |
2139 | 2139 | $methodName[0]='O'; |
2140 | 2140 | $events[$methodName]=$method; |
2141 | 2141 | } |
2142 | 2142 | } |
2143 | - if(strncmp($methodName,'__',2)!==0) |
|
2143 | + if(strncmp($methodName, '__', 2)!==0) |
|
2144 | 2144 | $methods[$methodName]=$method; |
2145 | 2145 | } |
2146 | 2146 | } |
@@ -2190,7 +2190,7 @@ discard block |
||
2190 | 2190 | protected function determinePropertyType($method) |
2191 | 2191 | { |
2192 | 2192 | $comment=$method->getDocComment(); |
2193 | - if(preg_match('/@return\\s+(.*?)\\s+/',$comment,$matches)) |
|
2193 | + if(preg_match('/@return\\s+(.*?)\\s+/', $comment, $matches)) |
|
2194 | 2194 | return $matches[1]; |
2195 | 2195 | else |
2196 | 2196 | return '{unknown}'; |
@@ -2348,7 +2348,7 @@ discard block |
||
2348 | 2348 | * @return boolean|null if the this or the instance is of type class. When null, no information could be derived and |
2349 | 2349 | * the default mechanisms take over. |
2350 | 2350 | */ |
2351 | - public function isinstanceof($class,$instance=null); |
|
2351 | + public function isinstanceof($class, $instance=null); |
|
2352 | 2352 | } |
2353 | 2353 | |
2354 | 2354 | /** |
@@ -2378,12 +2378,12 @@ discard block |
||
2378 | 2378 | |
2379 | 2379 | public function __construct($s) |
2380 | 2380 | { |
2381 | - $this->_s = $s; |
|
2381 | + $this->_s=$s; |
|
2382 | 2382 | } |
2383 | 2383 | |
2384 | 2384 | public function __toString() |
2385 | 2385 | { |
2386 | - return (string)$this->_s; |
|
2386 | + return (string) $this->_s; |
|
2387 | 2387 | } |
2388 | 2388 | |
2389 | 2389 | public function toJavaScriptLiteral() |
@@ -2403,7 +2403,7 @@ discard block |
||
2403 | 2403 | { |
2404 | 2404 | public function toJavaScriptLiteral() |
2405 | 2405 | { |
2406 | - return TJavaScript::jsonEncode((string)$this->_s,JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
2406 | + return TJavaScript::jsonEncode((string) $this->_s, JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
2407 | 2407 | } |
2408 | 2408 | } |
2409 | 2409 |