@@ -140,6 +140,7 @@ |
||
| 140 | 140 | /** |
| 141 | 141 | * Renders content provided by TJsonResponse::getJsonContent() as |
| 142 | 142 | * javascript in JSON format. |
| 143 | + * @param TJsonResponse $service |
|
| 143 | 144 | */ |
| 144 | 145 | protected function createJsonResponse($service,$properties,$config) |
| 145 | 146 | { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | if(is_array($config)) |
| 78 | 78 | { |
| 79 | 79 | foreach($config['json'] as $id => $json) |
| 80 | - $this->_services[$id] = $json; |
|
| 80 | + $this->_services[$id]=$json; |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | else |
@@ -109,14 +109,14 @@ discard block |
||
| 109 | 109 | $service=Prado::createComponent($serviceConfig['class']); |
| 110 | 110 | if($service instanceof TJsonResponse) |
| 111 | 111 | { |
| 112 | - $properties = isset($serviceConfig['properties'])?$serviceConfig['properties']:array(); |
|
| 113 | - $this->createJsonResponse($service,$properties,$serviceConfig); |
|
| 112 | + $properties=isset($serviceConfig['properties']) ? $serviceConfig['properties'] : array(); |
|
| 113 | + $this->createJsonResponse($service, $properties, $serviceConfig); |
|
| 114 | 114 | } |
| 115 | 115 | else |
| 116 | - throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
|
| 116 | + throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
|
| 117 | 117 | } |
| 118 | 118 | else |
| 119 | - throw new TConfigurationException('jsonservice_class_required',$id); |
|
| 119 | + throw new TConfigurationException('jsonservice_class_required', $id); |
|
| 120 | 120 | } |
| 121 | 121 | else |
| 122 | 122 | { |
@@ -125,33 +125,33 @@ discard block |
||
| 125 | 125 | { |
| 126 | 126 | $service=Prado::createComponent($class); |
| 127 | 127 | if($service instanceof TJsonResponse) |
| 128 | - $this->createJsonResponse($service,$properties,$serviceConfig); |
|
| 128 | + $this->createJsonResponse($service, $properties, $serviceConfig); |
|
| 129 | 129 | else |
| 130 | - throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
|
| 130 | + throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
|
| 131 | 131 | } |
| 132 | 132 | else |
| 133 | - throw new TConfigurationException('jsonservice_class_required',$id); |
|
| 133 | + throw new TConfigurationException('jsonservice_class_required', $id); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | else |
| 137 | - throw new THttpException(404,'jsonservice_provider_unknown',$id); |
|
| 137 | + throw new THttpException(404, 'jsonservice_provider_unknown', $id); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
| 141 | 141 | * Renders content provided by TJsonResponse::getJsonContent() as |
| 142 | 142 | * javascript in JSON format. |
| 143 | 143 | */ |
| 144 | - protected function createJsonResponse($service,$properties,$config) |
|
| 144 | + protected function createJsonResponse($service, $properties, $config) |
|
| 145 | 145 | { |
| 146 | 146 | // init service properties |
| 147 | 147 | foreach($properties as $name=>$value) |
| 148 | - $service->setSubproperty($name,$value); |
|
| 148 | + $service->setSubproperty($name, $value); |
|
| 149 | 149 | $service->init($config); |
| 150 | 150 | |
| 151 | 151 | //send content if not null |
| 152 | 152 | if(($content=$service->getJsonContent())!==null) |
| 153 | 153 | { |
| 154 | - $response = $this->getResponse(); |
|
| 154 | + $response=$this->getResponse(); |
|
| 155 | 155 | $response->setContentType('application/json'); |
| 156 | 156 | $response->setCharset('UTF-8'); |
| 157 | 157 | //send content |
@@ -79,8 +79,7 @@ discard block |
||
| 79 | 79 | foreach($config['json'] as $id => $json) |
| 80 | 80 | $this->_services[$id] = $json; |
| 81 | 81 | } |
| 82 | - } |
|
| 83 | - else |
|
| 82 | + } else |
|
| 84 | 83 | { |
| 85 | 84 | foreach($config->getElementsByTagName('json') as $json) |
| 86 | 85 | { |
@@ -111,14 +110,11 @@ discard block |
||
| 111 | 110 | { |
| 112 | 111 | $properties = isset($serviceConfig['properties'])?$serviceConfig['properties']:array(); |
| 113 | 112 | $this->createJsonResponse($service,$properties,$serviceConfig); |
| 114 | - } |
|
| 115 | - else |
|
| 113 | + } else |
|
| 116 | 114 | throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
| 117 | - } |
|
| 118 | - else |
|
| 115 | + } else |
|
| 119 | 116 | throw new TConfigurationException('jsonservice_class_required',$id); |
| 120 | - } |
|
| 121 | - else |
|
| 117 | + } else |
|
| 122 | 118 | { |
| 123 | 119 | $properties=$serviceConfig->getAttributes(); |
| 124 | 120 | if(($class=$properties->remove('class'))!==null) |
@@ -128,12 +124,10 @@ discard block |
||
| 128 | 124 | $this->createJsonResponse($service,$properties,$serviceConfig); |
| 129 | 125 | else |
| 130 | 126 | throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
| 131 | - } |
|
| 132 | - else |
|
| 127 | + } else |
|
| 133 | 128 | throw new TConfigurationException('jsonservice_class_required',$id); |
| 134 | 129 | } |
| 135 | - } |
|
| 136 | - else |
|
| 130 | + } else |
|
| 137 | 131 | throw new THttpException(404,'jsonservice_provider_unknown',$id); |
| 138 | 132 | } |
| 139 | 133 | |
@@ -369,6 +369,7 @@ discard block |
||
| 369 | 369 | |
| 370 | 370 | /** |
| 371 | 371 | * @param string default page path to be served if no explicit page is request |
| 372 | + * @param string $value |
|
| 372 | 373 | * @throws TInvalidOperationException if the page service is initialized |
| 373 | 374 | */ |
| 374 | 375 | public function setDefaultPage($value) |
@@ -528,6 +529,7 @@ discard block |
||
| 528 | 529 | * @param array list of GET parameters, null if no GET parameters required |
| 529 | 530 | * @param boolean whether to encode the ampersand in URL, defaults to true. |
| 530 | 531 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
| 532 | + * @param string $pagePath |
|
| 531 | 533 | * @return string URL for the page and GET parameters |
| 532 | 534 | */ |
| 533 | 535 | public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
@@ -670,6 +672,9 @@ discard block |
||
| 670 | 672 | } |
| 671 | 673 | } |
| 672 | 674 | |
| 675 | + /** |
|
| 676 | + * @param string $configPath |
|
| 677 | + */ |
|
| 673 | 678 | public function loadFromPhp($config,$configPath,$configPagePath) |
| 674 | 679 | { |
| 675 | 680 | $this->loadApplicationConfigurationFromPhp($config,$configPath); |
@@ -683,6 +688,8 @@ discard block |
||
| 683 | 688 | * @param TXmlElement config xml element |
| 684 | 689 | * @param string the directory containing this configuration |
| 685 | 690 | * @param string the page path that the config XML is associated with. The page path doesn't include the page name. |
| 691 | + * @param TXmlDocument $dom |
|
| 692 | + * @param string $configPath |
|
| 686 | 693 | */ |
| 687 | 694 | public function loadFromXml($dom,$configPath,$configPagePath) |
| 688 | 695 | { |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function init($config) |
| 149 | 149 | { |
| 150 | - Prado::trace("Initializing TPageService",'System.Web.Services.TPageService'); |
|
| 150 | + Prado::trace("Initializing TPageService", 'System.Web.Services.TPageService'); |
|
| 151 | 151 | |
| 152 | 152 | $pageConfig=$this->loadPageConfig($config); |
| 153 | 153 | |
@@ -185,15 +185,15 @@ discard block |
||
| 185 | 185 | // external configurations |
| 186 | 186 | foreach($config->getExternalConfigurations() as $filePath=>$params) |
| 187 | 187 | { |
| 188 | - list($configPagePath,$condition)=$params; |
|
| 188 | + list($configPagePath, $condition)=$params; |
|
| 189 | 189 | if($condition!==true) |
| 190 | 190 | $condition=$this->evaluateExpression($condition); |
| 191 | 191 | if($condition) |
| 192 | 192 | { |
| 193 | - if(($path=Prado::getPathOfNamespace($filePath,Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
| 194 | - throw new TConfigurationException('pageservice_includefile_invalid',$filePath); |
|
| 193 | + if(($path=Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
| 194 | + throw new TConfigurationException('pageservice_includefile_invalid', $filePath); |
|
| 195 | 195 | $c=new TPageConfiguration($pagePath); |
| 196 | - $c->loadFromFile($path,$configPagePath); |
|
| 196 | + $c->loadFromFile($path, $configPagePath); |
|
| 197 | 197 | $this->applyConfiguration($c); |
| 198 | 198 | } |
| 199 | 199 | } |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | if($config!==null) |
| 228 | 228 | { |
| 229 | 229 | if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
| 230 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
| 230 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
| 231 | 231 | else |
| 232 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
| 232 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
| 233 | 233 | } |
| 234 | 234 | $pageConfig->loadFromFiles($this->getBasePath()); |
| 235 | 235 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | $arr=$cache->get(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath); |
| 241 | 241 | if(is_array($arr)) |
| 242 | 242 | { |
| 243 | - list($pageConfig,$timestamps)=$arr; |
|
| 243 | + list($pageConfig, $timestamps)=$arr; |
|
| 244 | 244 | if($application->getMode()!==TApplicationMode::Performance) |
| 245 | 245 | { |
| 246 | 246 | foreach($timestamps as $fileName=>$timestamp) |
@@ -248,14 +248,14 @@ discard block |
||
| 248 | 248 | if($fileName===0) // application config file |
| 249 | 249 | { |
| 250 | 250 | $appConfigFile=$application->getConfigurationFile(); |
| 251 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
| 252 | - if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0])) |
|
| 251 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
| 252 | + if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0])) |
|
| 253 | 253 | $configCached=false; |
| 254 | 254 | } |
| 255 | 255 | else |
| 256 | 256 | { |
| 257 | 257 | $currentTimestamp[$fileName]=@filemtime($fileName); |
| 258 | - if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName])) |
|
| 258 | + if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName])) |
|
| 259 | 259 | $configCached=false; |
| 260 | 260 | } |
| 261 | 261 | } |
@@ -264,9 +264,9 @@ discard block |
||
| 264 | 264 | else |
| 265 | 265 | { |
| 266 | 266 | $configCached=false; |
| 267 | - $paths=explode('.',$pagePath); |
|
| 267 | + $paths=explode('.', $pagePath); |
|
| 268 | 268 | $configPath=$this->getBasePath(); |
| 269 | - $fileName = $this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
| 269 | + $fileName=$this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
| 270 | 270 | ? self::CONFIG_FILE_PHP |
| 271 | 271 | : self::CONFIG_FILE_XML; |
| 272 | 272 | foreach($paths as $path) |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | $configPath.=DIRECTORY_SEPARATOR.$path; |
| 277 | 277 | } |
| 278 | 278 | $appConfigFile=$application->getConfigurationFile(); |
| 279 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
| 279 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
| 280 | 280 | } |
| 281 | 281 | if(!$configCached) |
| 282 | 282 | { |
@@ -284,12 +284,12 @@ discard block |
||
| 284 | 284 | if($config!==null) |
| 285 | 285 | { |
| 286 | 286 | if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
| 287 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
| 287 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
| 288 | 288 | else |
| 289 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
| 289 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
| 290 | 290 | } |
| 291 | 291 | $pageConfig->loadFromFiles($this->getBasePath()); |
| 292 | - $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath,array($pageConfig,$currentTimestamp)); |
|
| 292 | + $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath, array($pageConfig, $currentTimestamp)); |
|
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | return $pageConfig; |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | { |
| 345 | 345 | if($this->_pagePath===null) |
| 346 | 346 | { |
| 347 | - $this->_pagePath=strtr($this->determineRequestedPagePath(),'/\\','..'); |
|
| 347 | + $this->_pagePath=strtr($this->determineRequestedPagePath(), '/\\', '..'); |
|
| 348 | 348 | if(empty($this->_pagePath)) |
| 349 | - throw new THttpException(404,'pageservice_page_required'); |
|
| 349 | + throw new THttpException(404, 'pageservice_page_required'); |
|
| 350 | 350 | } |
| 351 | 351 | return $this->_pagePath; |
| 352 | 352 | } |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | { |
| 400 | 400 | $basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::FALLBACK_BASEPATH; |
| 401 | 401 | if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) |
| 402 | - throw new TConfigurationException('pageservice_basepath_invalid',$basePath); |
|
| 402 | + throw new TConfigurationException('pageservice_basepath_invalid', $basePath); |
|
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | return $this->_basePath; |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | if($this->_initialized) |
| 415 | 415 | throw new TInvalidOperationException('pageservice_basepath_unchangeable'); |
| 416 | 416 | else if(($path=Prado::getPathOfNamespace($value))===null || !is_dir($path)) |
| 417 | - throw new TConfigurationException('pageservice_basepath_invalid',$value); |
|
| 417 | + throw new TConfigurationException('pageservice_basepath_invalid', $value); |
|
| 418 | 418 | $this->_basePath=realpath($path); |
| 419 | 419 | } |
| 420 | 420 | |
@@ -463,9 +463,9 @@ discard block |
||
| 463 | 463 | */ |
| 464 | 464 | public function run() |
| 465 | 465 | { |
| 466 | - Prado::trace("Running page service",'System.Web.Services.TPageService'); |
|
| 466 | + Prado::trace("Running page service", 'System.Web.Services.TPageService'); |
|
| 467 | 467 | $this->_page=$this->createPage($this->getRequestedPagePath()); |
| 468 | - $this->runPage($this->_page,$this->_properties); |
|
| 468 | + $this->runPage($this->_page, $this->_properties); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /** |
@@ -477,29 +477,29 @@ discard block |
||
| 477 | 477 | */ |
| 478 | 478 | protected function createPage($pagePath) |
| 479 | 479 | { |
| 480 | - $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath,'.',DIRECTORY_SEPARATOR); |
|
| 480 | + $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath, '.', DIRECTORY_SEPARATOR); |
|
| 481 | 481 | $hasTemplateFile=is_file($path.self::PAGE_FILE_EXT); |
| 482 | 482 | $hasClassFile=is_file($path.Prado::CLASS_FILE_EXT); |
| 483 | 483 | |
| 484 | 484 | if(!$hasTemplateFile && !$hasClassFile) |
| 485 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
| 485 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
| 486 | 486 | |
| 487 | 487 | if($hasClassFile) |
| 488 | 488 | { |
| 489 | 489 | $className=basename($path); |
| 490 | - if(!class_exists($className,false)) |
|
| 490 | + if(!class_exists($className, false)) |
|
| 491 | 491 | include_once($path.Prado::CLASS_FILE_EXT); |
| 492 | 492 | } |
| 493 | 493 | else |
| 494 | 494 | { |
| 495 | 495 | $className=$this->getBasePageClass(); |
| 496 | 496 | Prado::using($className); |
| 497 | - if(($pos=strrpos($className,'.'))!==false) |
|
| 498 | - $className=substr($className,$pos+1); |
|
| 497 | + if(($pos=strrpos($className, '.'))!==false) |
|
| 498 | + $className=substr($className, $pos + 1); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | - if(!class_exists($className,false) || ($className!=='TPage' && !is_subclass_of($className,'TPage'))) |
|
| 502 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
| 501 | + if(!class_exists($className, false) || ($className!=='TPage' && !is_subclass_of($className, 'TPage'))) |
|
| 502 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
| 503 | 503 | |
| 504 | 504 | $page=Prado::createComponent($className); |
| 505 | 505 | $page->setPagePath($pagePath); |
@@ -515,10 +515,10 @@ discard block |
||
| 515 | 515 | * @param TPage the page instance to be run |
| 516 | 516 | * @param array list of initial page properties |
| 517 | 517 | */ |
| 518 | - protected function runPage($page,$properties) |
|
| 518 | + protected function runPage($page, $properties) |
|
| 519 | 519 | { |
| 520 | 520 | foreach($properties as $name=>$value) |
| 521 | - $page->setSubProperty($name,$value); |
|
| 521 | + $page->setSubProperty($name, $value); |
|
| 522 | 522 | $page->run($this->getResponse()->createHtmlWriter()); |
| 523 | 523 | } |
| 524 | 524 | |
@@ -530,9 +530,9 @@ discard block |
||
| 530 | 530 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
| 531 | 531 | * @return string URL for the page and GET parameters |
| 532 | 532 | */ |
| 533 | - public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
| 533 | + public function constructUrl($pagePath, $getParams=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
| 534 | 534 | { |
| 535 | - return $this->getRequest()->constructUrl($this->getID(),$pagePath,$getParams,$encodeAmpersand,$encodeGetItems); |
|
| 535 | + return $this->getRequest()->constructUrl($this->getID(), $pagePath, $getParams, $encodeAmpersand, $encodeGetItems); |
|
| 536 | 536 | } |
| 537 | 537 | } |
| 538 | 538 | |
@@ -624,23 +624,23 @@ discard block |
||
| 624 | 624 | */ |
| 625 | 625 | public function loadFromFiles($basePath) |
| 626 | 626 | { |
| 627 | - $paths=explode('.',$this->_pagePath); |
|
| 627 | + $paths=explode('.', $this->_pagePath); |
|
| 628 | 628 | $page=array_pop($paths); |
| 629 | 629 | $path=$basePath; |
| 630 | 630 | $configPagePath=''; |
| 631 | - $fileName = Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
| 631 | + $fileName=Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
| 632 | 632 | ? TPageService::CONFIG_FILE_PHP |
| 633 | 633 | : TPageService::CONFIG_FILE_XML; |
| 634 | 634 | foreach($paths as $p) |
| 635 | 635 | { |
| 636 | - $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath); |
|
| 636 | + $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath); |
|
| 637 | 637 | $path.=DIRECTORY_SEPARATOR.$p; |
| 638 | 638 | if($configPagePath==='') |
| 639 | 639 | $configPagePath=$p; |
| 640 | 640 | else |
| 641 | 641 | $configPagePath.='.'.$p; |
| 642 | 642 | } |
| 643 | - $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath); |
|
| 643 | + $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath); |
|
| 644 | 644 | $this->_rules=new TAuthorizationRuleCollection($this->_rules); |
| 645 | 645 | } |
| 646 | 646 | |
@@ -649,31 +649,31 @@ discard block |
||
| 649 | 649 | * @param string config file name |
| 650 | 650 | * @param string the page path that the config file is associated with. The page path doesn't include the page name. |
| 651 | 651 | */ |
| 652 | - public function loadFromFile($fname,$configPagePath) |
|
| 652 | + public function loadFromFile($fname, $configPagePath) |
|
| 653 | 653 | { |
| 654 | - Prado::trace("Loading page configuration file $fname",'System.Web.Services.TPageService'); |
|
| 654 | + Prado::trace("Loading page configuration file $fname", 'System.Web.Services.TPageService'); |
|
| 655 | 655 | if(empty($fname) || !is_file($fname)) |
| 656 | 656 | return; |
| 657 | 657 | |
| 658 | 658 | if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
| 659 | 659 | { |
| 660 | - $fcontent = include $fname; |
|
| 661 | - $this->loadFromPhp($fcontent,dirname($fname),$configPagePath); |
|
| 660 | + $fcontent=include $fname; |
|
| 661 | + $this->loadFromPhp($fcontent, dirname($fname), $configPagePath); |
|
| 662 | 662 | } |
| 663 | 663 | else |
| 664 | 664 | { |
| 665 | 665 | $dom=new TXmlDocument; |
| 666 | 666 | if($dom->loadFromFile($fname)) |
| 667 | - $this->loadFromXml($dom,dirname($fname),$configPagePath); |
|
| 667 | + $this->loadFromXml($dom, dirname($fname), $configPagePath); |
|
| 668 | 668 | else |
| 669 | - throw new TConfigurationException('pageserviceconf_file_invalid',$fname); |
|
| 669 | + throw new TConfigurationException('pageserviceconf_file_invalid', $fname); |
|
| 670 | 670 | } |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - public function loadFromPhp($config,$configPath,$configPagePath) |
|
| 673 | + public function loadFromPhp($config, $configPath, $configPagePath) |
|
| 674 | 674 | { |
| 675 | - $this->loadApplicationConfigurationFromPhp($config,$configPath); |
|
| 676 | - $this->loadPageConfigurationFromPhp($config,$configPath,$configPagePath); |
|
| 675 | + $this->loadApplicationConfigurationFromPhp($config, $configPath); |
|
| 676 | + $this->loadPageConfigurationFromPhp($config, $configPath, $configPagePath); |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | /** |
@@ -684,16 +684,16 @@ discard block |
||
| 684 | 684 | * @param string the directory containing this configuration |
| 685 | 685 | * @param string the page path that the config XML is associated with. The page path doesn't include the page name. |
| 686 | 686 | */ |
| 687 | - public function loadFromXml($dom,$configPath,$configPagePath) |
|
| 687 | + public function loadFromXml($dom, $configPath, $configPagePath) |
|
| 688 | 688 | { |
| 689 | - $this->loadApplicationConfigurationFromXml($dom,$configPath); |
|
| 690 | - $this->loadPageConfigurationFromXml($dom,$configPath,$configPagePath); |
|
| 689 | + $this->loadApplicationConfigurationFromXml($dom, $configPath); |
|
| 690 | + $this->loadPageConfigurationFromXml($dom, $configPath, $configPagePath); |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - public function loadApplicationConfigurationFromPhp($config,$configPath) |
|
| 693 | + public function loadApplicationConfigurationFromPhp($config, $configPath) |
|
| 694 | 694 | { |
| 695 | 695 | $appConfig=new TApplicationConfiguration; |
| 696 | - $appConfig->loadFromPhp($config,$configPath); |
|
| 696 | + $appConfig->loadFromPhp($config, $configPath); |
|
| 697 | 697 | $this->_appConfigs[]=$appConfig; |
| 698 | 698 | } |
| 699 | 699 | |
@@ -702,10 +702,10 @@ discard block |
||
| 702 | 702 | * @param TXmlElement config xml element |
| 703 | 703 | * @param string base path corresponding to this xml element |
| 704 | 704 | */ |
| 705 | - public function loadApplicationConfigurationFromXml($dom,$configPath) |
|
| 705 | + public function loadApplicationConfigurationFromXml($dom, $configPath) |
|
| 706 | 706 | { |
| 707 | 707 | $appConfig=new TApplicationConfiguration; |
| 708 | - $appConfig->loadFromXml($dom,$configPath); |
|
| 708 | + $appConfig->loadFromXml($dom, $configPath); |
|
| 709 | 709 | $this->_appConfigs[]=$appConfig; |
| 710 | 710 | } |
| 711 | 711 | |
@@ -714,30 +714,30 @@ discard block |
||
| 714 | 714 | // authorization |
| 715 | 715 | if(isset($config['authorization']) && is_array($config['authorization'])) |
| 716 | 716 | { |
| 717 | - $rules = array(); |
|
| 717 | + $rules=array(); |
|
| 718 | 718 | foreach($config['authorization'] as $authorization) |
| 719 | 719 | { |
| 720 | - $patterns=isset($authorization['pages'])?$authorization['pages']:''; |
|
| 720 | + $patterns=isset($authorization['pages']) ? $authorization['pages'] : ''; |
|
| 721 | 721 | $ruleApplies=false; |
| 722 | 722 | if(empty($patterns) || trim($patterns)==='*') // null or empty string |
| 723 | 723 | $ruleApplies=true; |
| 724 | 724 | else |
| 725 | 725 | { |
| 726 | - foreach(explode(',',$patterns) as $pattern) |
|
| 726 | + foreach(explode(',', $patterns) as $pattern) |
|
| 727 | 727 | { |
| 728 | 728 | if(($pattern=trim($pattern))!=='') |
| 729 | 729 | { |
| 730 | 730 | // we know $configPagePath and $this->_pagePath |
| 731 | 731 | if($configPagePath!=='') // prepend the pattern with ConfigPagePath |
| 732 | 732 | $pattern=$configPagePath.'.'.$pattern; |
| 733 | - if(strcasecmp($pattern,$this->_pagePath)===0) |
|
| 733 | + if(strcasecmp($pattern, $this->_pagePath)===0) |
|
| 734 | 734 | { |
| 735 | 735 | $ruleApplies=true; |
| 736 | 736 | break; |
| 737 | 737 | } |
| 738 | - if($pattern[strlen($pattern)-1]==='*') // try wildcard matching |
|
| 738 | + if($pattern[strlen($pattern) - 1]==='*') // try wildcard matching |
|
| 739 | 739 | { |
| 740 | - if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0) |
|
| 740 | + if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1)===0) |
|
| 741 | 741 | { |
| 742 | 742 | $ruleApplies=true; |
| 743 | 743 | break; |
@@ -748,40 +748,40 @@ discard block |
||
| 748 | 748 | } |
| 749 | 749 | if($ruleApplies) |
| 750 | 750 | { |
| 751 | - $action = isset($authorization['action'])?$authorization['action']:''; |
|
| 752 | - $users = isset($authorization['users'])?$authorization['users']:''; |
|
| 753 | - $roles = isset($authorization['roles'])?$authorization['roles']:''; |
|
| 754 | - $verb = isset($authorization['verb'])?$authorization['verb']:''; |
|
| 755 | - $ips = isset($authorization['ips'])?$authorization['ips']:''; |
|
| 756 | - $rules[]=new TAuthorizationRule($action,$users,$roles,$verb,$ips); |
|
| 751 | + $action=isset($authorization['action']) ? $authorization['action'] : ''; |
|
| 752 | + $users=isset($authorization['users']) ? $authorization['users'] : ''; |
|
| 753 | + $roles=isset($authorization['roles']) ? $authorization['roles'] : ''; |
|
| 754 | + $verb=isset($authorization['verb']) ? $authorization['verb'] : ''; |
|
| 755 | + $ips=isset($authorization['ips']) ? $authorization['ips'] : ''; |
|
| 756 | + $rules[]=new TAuthorizationRule($action, $users, $roles, $verb, $ips); |
|
| 757 | 757 | } |
| 758 | 758 | } |
| 759 | - $this->_rules=array_merge($rules,$this->_rules); |
|
| 759 | + $this->_rules=array_merge($rules, $this->_rules); |
|
| 760 | 760 | } |
| 761 | 761 | // pages |
| 762 | 762 | if(isset($config['pages']) && is_array($config['pages'])) |
| 763 | 763 | { |
| 764 | 764 | if(isset($config['pages']['properties'])) |
| 765 | 765 | { |
| 766 | - $this->_properties = array_merge($this->_properties, $config['pages']['properties']); |
|
| 766 | + $this->_properties=array_merge($this->_properties, $config['pages']['properties']); |
|
| 767 | 767 | unset($config['pages']['properties']); |
| 768 | 768 | } |
| 769 | 769 | foreach($config['pages'] as $id => $page) |
| 770 | 770 | { |
| 771 | - $properties = array(); |
|
| 771 | + $properties=array(); |
|
| 772 | 772 | if(isset($page['properties'])) |
| 773 | 773 | { |
| 774 | 774 | $properties=$page['properties']; |
| 775 | 775 | unset($page['properties']); |
| 776 | 776 | } |
| 777 | 777 | $matching=false; |
| 778 | - $id=($configPagePath==='')?$id:$configPagePath.'.'.$id; |
|
| 779 | - if(strcasecmp($id,$this->_pagePath)===0) |
|
| 778 | + $id=($configPagePath==='') ? $id : $configPagePath.'.'.$id; |
|
| 779 | + if(strcasecmp($id, $this->_pagePath)===0) |
|
| 780 | 780 | $matching=true; |
| 781 | - else if($id[strlen($id)-1]==='*') // try wildcard matching |
|
| 782 | - $matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0; |
|
| 781 | + else if($id[strlen($id) - 1]==='*') // try wildcard matching |
|
| 782 | + $matching=strncasecmp($this->_pagePath, $id, strlen($id) - 1)===0; |
|
| 783 | 783 | if($matching) |
| 784 | - $this->_properties=array_merge($this->_properties,$properties); |
|
| 784 | + $this->_properties=array_merge($this->_properties, $properties); |
|
| 785 | 785 | } |
| 786 | 786 | } |
| 787 | 787 | |
@@ -790,14 +790,14 @@ discard block |
||
| 790 | 790 | { |
| 791 | 791 | foreach($config['includes'] as $include) |
| 792 | 792 | { |
| 793 | - $when = isset($include['when'])?true:false; |
|
| 793 | + $when=isset($include['when']) ? true : false; |
|
| 794 | 794 | if(!isset($include['file'])) |
| 795 | 795 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
| 796 | - $filePath = $include['file']; |
|
| 796 | + $filePath=$include['file']; |
|
| 797 | 797 | if(isset($this->_includes[$filePath])) |
| 798 | - $this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
| 798 | + $this->_includes[$filePath]=array($configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
| 799 | 799 | else |
| 800 | - $this->_includes[$filePath]=array($configPagePath,$when); |
|
| 800 | + $this->_includes[$filePath]=array($configPagePath, $when); |
|
| 801 | 801 | } |
| 802 | 802 | } |
| 803 | 803 | } |
@@ -808,7 +808,7 @@ discard block |
||
| 808 | 808 | * @param string base path corresponding to this xml element |
| 809 | 809 | * @param string the page path that the config XML is associated with. The page path doesn't include the page name. |
| 810 | 810 | */ |
| 811 | - public function loadPageConfigurationFromXml($dom,$configPath,$configPagePath) |
|
| 811 | + public function loadPageConfigurationFromXml($dom, $configPath, $configPagePath) |
|
| 812 | 812 | { |
| 813 | 813 | // authorization |
| 814 | 814 | if(($authorizationNode=$dom->getElementByTagName('authorization'))!==null) |
@@ -822,21 +822,21 @@ discard block |
||
| 822 | 822 | $ruleApplies=true; |
| 823 | 823 | else |
| 824 | 824 | { |
| 825 | - foreach(explode(',',$patterns) as $pattern) |
|
| 825 | + foreach(explode(',', $patterns) as $pattern) |
|
| 826 | 826 | { |
| 827 | 827 | if(($pattern=trim($pattern))!=='') |
| 828 | 828 | { |
| 829 | 829 | // we know $configPagePath and $this->_pagePath |
| 830 | 830 | if($configPagePath!=='') // prepend the pattern with ConfigPagePath |
| 831 | 831 | $pattern=$configPagePath.'.'.$pattern; |
| 832 | - if(strcasecmp($pattern,$this->_pagePath)===0) |
|
| 832 | + if(strcasecmp($pattern, $this->_pagePath)===0) |
|
| 833 | 833 | { |
| 834 | 834 | $ruleApplies=true; |
| 835 | 835 | break; |
| 836 | 836 | } |
| 837 | - if($pattern[strlen($pattern)-1]==='*') // try wildcard matching |
|
| 837 | + if($pattern[strlen($pattern) - 1]==='*') // try wildcard matching |
|
| 838 | 838 | { |
| 839 | - if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0) |
|
| 839 | + if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1)===0) |
|
| 840 | 840 | { |
| 841 | 841 | $ruleApplies=true; |
| 842 | 842 | break; |
@@ -846,30 +846,30 @@ discard block |
||
| 846 | 846 | } |
| 847 | 847 | } |
| 848 | 848 | if($ruleApplies) |
| 849 | - $rules[]=new TAuthorizationRule($node->getTagName(),$node->getAttribute('users'),$node->getAttribute('roles'),$node->getAttribute('verb'),$node->getAttribute('ips')); |
|
| 849 | + $rules[]=new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips')); |
|
| 850 | 850 | } |
| 851 | - $this->_rules=array_merge($rules,$this->_rules); |
|
| 851 | + $this->_rules=array_merge($rules, $this->_rules); |
|
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | // pages |
| 855 | 855 | if(($pagesNode=$dom->getElementByTagName('pages'))!==null) |
| 856 | 856 | { |
| 857 | - $this->_properties=array_merge($this->_properties,$pagesNode->getAttributes()->toArray()); |
|
| 857 | + $this->_properties=array_merge($this->_properties, $pagesNode->getAttributes()->toArray()); |
|
| 858 | 858 | // at the page folder |
| 859 | 859 | foreach($pagesNode->getElementsByTagName('page') as $node) |
| 860 | 860 | { |
| 861 | 861 | $properties=$node->getAttributes(); |
| 862 | 862 | $id=$properties->remove('id'); |
| 863 | 863 | if(empty($id)) |
| 864 | - throw new TConfigurationException('pageserviceconf_page_invalid',$configPath); |
|
| 864 | + throw new TConfigurationException('pageserviceconf_page_invalid', $configPath); |
|
| 865 | 865 | $matching=false; |
| 866 | - $id=($configPagePath==='')?$id:$configPagePath.'.'.$id; |
|
| 867 | - if(strcasecmp($id,$this->_pagePath)===0) |
|
| 866 | + $id=($configPagePath==='') ? $id : $configPagePath.'.'.$id; |
|
| 867 | + if(strcasecmp($id, $this->_pagePath)===0) |
|
| 868 | 868 | $matching=true; |
| 869 | - else if($id[strlen($id)-1]==='*') // try wildcard matching |
|
| 870 | - $matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0; |
|
| 869 | + else if($id[strlen($id) - 1]==='*') // try wildcard matching |
|
| 870 | + $matching=strncasecmp($this->_pagePath, $id, strlen($id) - 1)===0; |
|
| 871 | 871 | if($matching) |
| 872 | - $this->_properties=array_merge($this->_properties,$properties->toArray()); |
|
| 872 | + $this->_properties=array_merge($this->_properties, $properties->toArray()); |
|
| 873 | 873 | } |
| 874 | 874 | } |
| 875 | 875 | |
@@ -881,9 +881,9 @@ discard block |
||
| 881 | 881 | if(($filePath=$node->getAttribute('file'))===null) |
| 882 | 882 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
| 883 | 883 | if(isset($this->_includes[$filePath])) |
| 884 | - $this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
| 884 | + $this->_includes[$filePath]=array($configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')'); |
|
| 885 | 885 | else |
| 886 | - $this->_includes[$filePath]=array($configPagePath,$when); |
|
| 886 | + $this->_includes[$filePath]=array($configPagePath, $when); |
|
| 887 | 887 | } |
| 888 | 888 | } |
| 889 | 889 | } |
@@ -232,8 +232,7 @@ discard block |
||
| 232 | 232 | $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
| 233 | 233 | } |
| 234 | 234 | $pageConfig->loadFromFiles($this->getBasePath()); |
| 235 | - } |
|
| 236 | - else |
|
| 235 | + } else |
|
| 237 | 236 | { |
| 238 | 237 | $configCached=true; |
| 239 | 238 | $currentTimestamp=array(); |
@@ -251,8 +250,7 @@ discard block |
||
| 251 | 250 | $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
| 252 | 251 | if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0])) |
| 253 | 252 | $configCached=false; |
| 254 | - } |
|
| 255 | - else |
|
| 253 | + } else |
|
| 256 | 254 | { |
| 257 | 255 | $currentTimestamp[$fileName]=@filemtime($fileName); |
| 258 | 256 | if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName])) |
@@ -260,8 +258,7 @@ discard block |
||
| 260 | 258 | } |
| 261 | 259 | } |
| 262 | 260 | } |
| 263 | - } |
|
| 264 | - else |
|
| 261 | + } else |
|
| 265 | 262 | { |
| 266 | 263 | $configCached=false; |
| 267 | 264 | $paths=explode('.',$pagePath); |
@@ -489,8 +486,7 @@ discard block |
||
| 489 | 486 | $className=basename($path); |
| 490 | 487 | if(!class_exists($className,false)) |
| 491 | 488 | include_once($path.Prado::CLASS_FILE_EXT); |
| 492 | - } |
|
| 493 | - else |
|
| 489 | + } else |
|
| 494 | 490 | { |
| 495 | 491 | $className=$this->getBasePageClass(); |
| 496 | 492 | Prado::using($className); |
@@ -659,8 +655,7 @@ discard block |
||
| 659 | 655 | { |
| 660 | 656 | $fcontent = include $fname; |
| 661 | 657 | $this->loadFromPhp($fcontent,dirname($fname),$configPagePath); |
| 662 | - } |
|
| 663 | - else |
|
| 658 | + } else |
|
| 664 | 659 | { |
| 665 | 660 | $dom=new TXmlDocument; |
| 666 | 661 | if($dom->loadFromFile($fname)) |
@@ -258,6 +258,9 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | class TRpcException extends TException |
| 260 | 260 | { |
| 261 | + /** |
|
| 262 | + * @param string $message |
|
| 263 | + */ |
|
| 261 | 264 | public function __construct($message, $errorCode = -1) |
| 262 | 265 | { |
| 263 | 266 | $this->setErrorCode($errorCode); |
@@ -334,7 +337,7 @@ discard block |
||
| 334 | 337 | } |
| 335 | 338 | |
| 336 | 339 | /** |
| 337 | - * @return rpc server instance |
|
| 340 | + * @return TRpcServer server instance |
|
| 338 | 341 | */ |
| 339 | 342 | public function getRpcServer() |
| 340 | 343 | { |
@@ -366,6 +369,7 @@ discard block |
||
| 366 | 369 | /** |
| 367 | 370 | * @param string request payload |
| 368 | 371 | * Processed the request ans returns the response, if any |
| 372 | + * @param string $requestPayload |
|
| 369 | 373 | * @return processed response |
| 370 | 374 | * @abstract |
| 371 | 375 | */ |
@@ -641,7 +645,6 @@ discard block |
||
| 641 | 645 | /** |
| 642 | 646 | * Registers a new RPC method and handler details |
| 643 | 647 | * @param string $methodName |
| 644 | - * @param array $handlerDetails containing the callback handler |
|
| 645 | 648 | */ |
| 646 | 649 | public function addMethod($methodName, $methodDetails) |
| 647 | 650 | { |
@@ -59,17 +59,17 @@ discard block |
||
| 59 | 59 | /** |
| 60 | 60 | * const string base api provider class which every API must extend |
| 61 | 61 | */ |
| 62 | - const BASE_API_PROVIDER = 'TRpcApiProvider'; |
|
| 62 | + const BASE_API_PROVIDER='TRpcApiProvider'; |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * const string base RPC server implementation |
| 66 | 66 | */ |
| 67 | - const BASE_RPC_SERVER = 'TRpcServer'; |
|
| 67 | + const BASE_RPC_SERVER='TRpcServer'; |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @var array containing mimetype to protocol handler mappings |
| 71 | 71 | */ |
| 72 | - protected $protocolHandlers = array( |
|
| 72 | + protected $protocolHandlers=array( |
|
| 73 | 73 | 'application/json' => 'TJsonRpcProtocol', |
| 74 | 74 | 'text/xml' => 'TXmlRpcProtocol' |
| 75 | 75 | ); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | /** |
| 78 | 78 | * @var array containing API provider and their configured properties |
| 79 | 79 | */ |
| 80 | - protected $apiProviders = array(); |
|
| 80 | + protected $apiProviders=array(); |
|
| 81 | 81 | |
| 82 | 82 | // methods |
| 83 | 83 | |
@@ -88,27 +88,27 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function createApiProvider(TRpcProtocol $protocolHandler, $providerId) |
| 90 | 90 | { |
| 91 | - $_properties = $this->apiProviders[$providerId]; |
|
| 91 | + $_properties=$this->apiProviders[$providerId]; |
|
| 92 | 92 | |
| 93 | - if(($_providerClass = $_properties->remove('class')) === null) |
|
| 93 | + if(($_providerClass=$_properties->remove('class'))===null) |
|
| 94 | 94 | throw new TConfigurationException('rpcservice_apiprovider_required'); |
| 95 | 95 | |
| 96 | 96 | Prado::using($_providerClass); |
| 97 | 97 | |
| 98 | - $_providerClassName = ($_pos = strrpos($_providerClass, '.')) !== false ? substr($_providerClass, $_pos + 1) : $_providerClass; |
|
| 98 | + $_providerClassName=($_pos=strrpos($_providerClass, '.'))!==false ? substr($_providerClass, $_pos + 1) : $_providerClass; |
|
| 99 | 99 | if(!is_subclass_of($_providerClassName, self::BASE_API_PROVIDER)) |
| 100 | 100 | throw new TConfigurationException('rpcservice_apiprovider_invalid'); |
| 101 | 101 | |
| 102 | - if(($_rpcServerClass = $_properties->remove('server')) === null) |
|
| 103 | - $_rpcServerClass = self::BASE_RPC_SERVER; |
|
| 102 | + if(($_rpcServerClass=$_properties->remove('server'))===null) |
|
| 103 | + $_rpcServerClass=self::BASE_RPC_SERVER; |
|
| 104 | 104 | |
| 105 | 105 | Prado::using($_rpcServerClass); |
| 106 | 106 | |
| 107 | - $_rpcServerClassName = ($_pos = strrpos($_rpcServerClass, '.')) !== false ? substr($_rpcServerClass, $_pos + 1) : $_rpcServerClass; |
|
| 107 | + $_rpcServerClassName=($_pos=strrpos($_rpcServerClass, '.'))!==false ? substr($_rpcServerClass, $_pos + 1) : $_rpcServerClass; |
|
| 108 | 108 | if($_rpcServerClassName!==self::BASE_RPC_SERVER && !is_subclass_of($_rpcServerClassName, self::BASE_RPC_SERVER)) |
| 109 | 109 | throw new TConfigurationException('rpcservice_rpcserver_invalid'); |
| 110 | 110 | |
| 111 | - $_apiProvider = new $_providerClassName(new $_rpcServerClassName($protocolHandler)); |
|
| 111 | + $_apiProvider=new $_providerClassName(new $_rpcServerClassName($protocolHandler)); |
|
| 112 | 112 | $_apiProvider->setId($providerId); |
| 113 | 113 | |
| 114 | 114 | foreach($_properties as $_key => $_value) |
@@ -134,15 +134,15 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | foreach($xml->getElementsByTagName('rpcapi') as $_apiProviderXml) |
| 136 | 136 | { |
| 137 | - $_properties = $_apiProviderXml->getAttributes(); |
|
| 137 | + $_properties=$_apiProviderXml->getAttributes(); |
|
| 138 | 138 | |
| 139 | - if(($_id = $_properties->remove('id')) === null || $_id == "") |
|
| 139 | + if(($_id=$_properties->remove('id'))===null || $_id=="") |
|
| 140 | 140 | throw new TConfigurationException('rpcservice_apiproviderid_required'); |
| 141 | 141 | |
| 142 | 142 | if(isset($this->apiProviders[$_id])) |
| 143 | 143 | throw new TConfigurationException('rpcservice_apiproviderid_duplicated'); |
| 144 | 144 | |
| 145 | - $this->apiProviders[$_id] = $_properties; |
|
| 145 | + $this->apiProviders[$_id]=$_properties; |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
@@ -151,26 +151,26 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function run() |
| 153 | 153 | { |
| 154 | - $_request = $this->getRequest(); |
|
| 154 | + $_request=$this->getRequest(); |
|
| 155 | 155 | |
| 156 | - if(($_providerId = $_request->getServiceParameter()) == "") |
|
| 156 | + if(($_providerId=$_request->getServiceParameter())=="") |
|
| 157 | 157 | throw new THttpException(400, 'RPC API-Provider id required'); |
| 158 | 158 | |
| 159 | - if(($_method = $_request->getRequestType()) != 'POST') |
|
| 159 | + if(($_method=$_request->getRequestType())!='POST') |
|
| 160 | 160 | throw new THttpException(405, 'Invalid request method "'.$_method.'"!'); // TODO Exception muss "Allow POST" Header setzen |
| 161 | 161 | |
| 162 | - if(($_mimeType = $_request->getContentType()) === null) |
|
| 162 | + if(($_mimeType=$_request->getContentType())===null) |
|
| 163 | 163 | throw new THttpException(406, 'Content-Type is missing!'); // TODO Exception muss gültige Content-Type werte zurück geben |
| 164 | 164 | |
| 165 | 165 | if(!in_array($_mimeType, array_keys($this->protocolHandlers))) |
| 166 | 166 | throw new THttpException(406, 'Unsupported Content-Type!'); // TODO see previous |
| 167 | 167 | |
| 168 | - $_protocolHandlerClass = $this->protocolHandlers[$_mimeType]; |
|
| 169 | - $_protocolHandler = new $_protocolHandlerClass; |
|
| 168 | + $_protocolHandlerClass=$this->protocolHandlers[$_mimeType]; |
|
| 169 | + $_protocolHandler=new $_protocolHandlerClass; |
|
| 170 | 170 | |
| 171 | - if(($_result = $this->createApiProvider($_protocolHandler, $_providerId)->processRequest()) !== null) |
|
| 171 | + if(($_result=$this->createApiProvider($_protocolHandler, $_providerId)->processRequest())!==null) |
|
| 172 | 172 | { |
| 173 | - $_response = $this->getResponse(); |
|
| 173 | + $_response=$this->getResponse(); |
|
| 174 | 174 | $_protocolHandler->createResponseHeaders($_response); |
| 175 | 175 | $_response->write($_result); |
| 176 | 176 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public function __construct(TRpcProtocol $protocolHandler) |
| 208 | 208 | { |
| 209 | - $this->handler = $protocolHandler; |
|
| 209 | + $this->handler=$protocolHandler; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | class TRpcException extends TException |
| 260 | 260 | { |
| 261 | - public function __construct($message, $errorCode = -1) |
|
| 261 | + public function __construct($message, $errorCode=-1) |
|
| 262 | 262 | { |
| 263 | 263 | $this->setErrorCode($errorCode); |
| 264 | 264 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | public function __construct(TRpcServer $rpcServer) |
| 320 | 320 | { |
| 321 | - $this->rpcServer = $rpcServer; |
|
| 321 | + $this->rpcServer=$rpcServer; |
|
| 322 | 322 | |
| 323 | 323 | foreach($this->registerMethods() as $_methodName => $_methodDetails) |
| 324 | 324 | $this->rpcServer->addRpcMethod($_methodName, $_methodDetails); |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | /** |
| 360 | 360 | * @var array containing the mapping from RPC method names to the actual handlers |
| 361 | 361 | */ |
| 362 | - protected $rpcMethods = array(); |
|
| 362 | + protected $rpcMethods=array(); |
|
| 363 | 363 | |
| 364 | 364 | // abstracts |
| 365 | 365 | |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | */ |
| 408 | 408 | public function addMethod($methodName, $handlerDetails) |
| 409 | 409 | { |
| 410 | - $this->rpcMethods[$methodName] = $handlerDetails; |
|
| 410 | + $this->rpcMethods[$methodName]=$handlerDetails; |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | /** |
@@ -421,11 +421,11 @@ discard block |
||
| 421 | 421 | if(!isset($this->rpcMethods[$methodName])) |
| 422 | 422 | throw new TRpcException('Method "'.$methodName.'" not found'); |
| 423 | 423 | |
| 424 | - if($parameters === null) |
|
| 425 | - $parameters = array(); |
|
| 424 | + if($parameters===null) |
|
| 425 | + $parameters=array(); |
|
| 426 | 426 | |
| 427 | 427 | if(!is_array($parameters)) |
| 428 | - $parameters = array($parameters); |
|
| 428 | + $parameters=array($parameters); |
|
| 429 | 429 | return call_user_func_array($this->rpcMethods[$methodName]['method'], $parameters); |
| 430 | 430 | } |
| 431 | 431 | } |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | { |
| 458 | 458 | try |
| 459 | 459 | { |
| 460 | - $_request = $this->decode($requestPayload); |
|
| 460 | + $_request=$this->decode($requestPayload); |
|
| 461 | 461 | |
| 462 | 462 | if(isset($_request['jsonrpc'])) |
| 463 | 463 | { |
@@ -473,15 +473,15 @@ discard block |
||
| 473 | 473 | throw new TRpcException('Missing request method', '-32600'); |
| 474 | 474 | |
| 475 | 475 | if(!isset($_request['params'])) |
| 476 | - $parameters = array(); |
|
| 476 | + $parameters=array(); |
|
| 477 | 477 | else |
| 478 | - $parameters = $_request['params']; |
|
| 478 | + $parameters=$_request['params']; |
|
| 479 | 479 | |
| 480 | 480 | if(!is_array($parameters)) |
| 481 | - $parameters = array($parameters); |
|
| 481 | + $parameters=array($parameters); |
|
| 482 | 482 | |
| 483 | 483 | // a request without an id is a notification that doesn't need a response |
| 484 | - if($this->_id !== null) |
|
| 484 | + if($this->_id!==null) |
|
| 485 | 485 | { |
| 486 | 486 | if($this->_specificationVersion==2.0) |
| 487 | 487 | { |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | */ |
| 561 | 561 | public function decode($data) |
| 562 | 562 | { |
| 563 | - $s = json_decode($data, true); |
|
| 563 | + $s=json_decode($data, true); |
|
| 564 | 564 | self::checkJsonError(); |
| 565 | 565 | return $s; |
| 566 | 566 | } |
@@ -572,15 +572,15 @@ discard block |
||
| 572 | 572 | */ |
| 573 | 573 | public function encode($data) |
| 574 | 574 | { |
| 575 | - $s = json_encode($data); |
|
| 575 | + $s=json_encode($data); |
|
| 576 | 576 | self::checkJsonError(); |
| 577 | 577 | return $s; |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | private static function checkJsonError() |
| 581 | 581 | { |
| 582 | - $errnum = json_last_error(); |
|
| 583 | - if($errnum != JSON_ERROR_NONE) |
|
| 582 | + $errnum=json_last_error(); |
|
| 583 | + if($errnum!=JSON_ERROR_NONE) |
|
| 584 | 584 | throw new Exception("JSON error: $msg", $err); |
| 585 | 585 | } |
| 586 | 586 | |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | */ |
| 626 | 626 | public function __construct() |
| 627 | 627 | { |
| 628 | - $this->_xmlrpcServer = xmlrpc_server_create(); |
|
| 628 | + $this->_xmlrpcServer=xmlrpc_server_create(); |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | /** |
@@ -237,8 +237,7 @@ discard block |
||
| 237 | 237 | try |
| 238 | 238 | { |
| 239 | 239 | return $this->handler->callMethod($this->getPayload()); |
| 240 | - } |
|
| 241 | - catch(TRpcException $e) |
|
| 240 | + } catch(TRpcException $e) |
|
| 242 | 241 | { |
| 243 | 242 | return $this->handler->createErrorResponse($e); |
| 244 | 243 | } |
@@ -498,16 +497,13 @@ discard block |
||
| 498 | 497 | )); |
| 499 | 498 | } |
| 500 | 499 | } |
| 501 | - } |
|
| 502 | - catch(TRpcException $e) |
|
| 500 | + } catch(TRpcException $e) |
|
| 503 | 501 | { |
| 504 | 502 | return $this->createErrorResponse($e); |
| 505 | - } |
|
| 506 | - catch(THttpException $e) |
|
| 503 | + } catch(THttpException $e) |
|
| 507 | 504 | { |
| 508 | 505 | throw $e; |
| 509 | - } |
|
| 510 | - catch(Exception $e) |
|
| 506 | + } catch(Exception $e) |
|
| 511 | 507 | { |
| 512 | 508 | return $this->createErrorResponse(new TRpcException('An internal error occured', '-32603')); |
| 513 | 509 | } |
@@ -662,16 +658,13 @@ discard block |
||
| 662 | 658 | try |
| 663 | 659 | { |
| 664 | 660 | return xmlrpc_server_call_method($this->_xmlrpcServer, $requestPayload, null); |
| 665 | - } |
|
| 666 | - catch(TRpcException $e) |
|
| 661 | + } catch(TRpcException $e) |
|
| 667 | 662 | { |
| 668 | 663 | return $this->createErrorResponse($e); |
| 669 | - } |
|
| 670 | - catch(THttpException $e) |
|
| 664 | + } catch(THttpException $e) |
|
| 671 | 665 | { |
| 672 | 666 | throw $e; |
| 673 | - } |
|
| 674 | - catch(Exception $e) |
|
| 667 | + } catch(Exception $e) |
|
| 675 | 668 | { |
| 676 | 669 | return $this->createErrorResponse(new TRpcException('An internal error occured')); |
| 677 | 670 | } |
@@ -31,6 +31,7 @@ |
||
| 31 | 31 | /** |
| 32 | 32 | * Constructor. Attach a response to be adapted. |
| 33 | 33 | * @param THttpResponse the response object the adapter is to attach to. |
| 34 | + * @param THttpResponse $response |
|
| 34 | 35 | */ |
| 35 | 36 | public function __construct($response) |
| 36 | 37 | { |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | */ |
| 72 | 72 | public function createNewHtmlWriter($type, $writer) |
| 73 | 73 | { |
| 74 | - return $this->_response->createNewHtmlWriter($type,$writer); |
|
| 74 | + return $this->_response->createNewHtmlWriter($type, $writer); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
@@ -265,6 +265,7 @@ discard block |
||
| 265 | 265 | * If true, make sure the methods {@link _open}, {@link _close}, {@link _read}, |
| 266 | 266 | * {@link _write}, {@link _destroy}, and {@link _gc} are overridden in child |
| 267 | 267 | * class, because they will be used as the callback handlers. |
| 268 | + * @param boolean $value |
|
| 268 | 269 | */ |
| 269 | 270 | public function setUseCustomStorage($value) |
| 270 | 271 | { |
@@ -527,6 +528,7 @@ discard block |
||
| 527 | 528 | * Returns the session variable value with the session variable name. |
| 528 | 529 | * This method is exactly the same as {@link offsetGet}. |
| 529 | 530 | * @param mixed the session variable name |
| 531 | + * @param string $key |
|
| 530 | 532 | * @return mixed the session variable value, null if no such variable exists |
| 531 | 533 | */ |
| 532 | 534 | public function itemAt($key) |
@@ -539,6 +541,7 @@ discard block |
||
| 539 | 541 | * Note, if the specified name already exists, the old value will be removed first. |
| 540 | 542 | * @param mixed session variable name |
| 541 | 543 | * @param mixed session variable value |
| 544 | + * @param string $key |
|
| 542 | 545 | */ |
| 543 | 546 | public function add($key,$value) |
| 544 | 547 | { |
@@ -306,10 +306,10 @@ |
||
| 306 | 306 | { |
| 307 | 307 | $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); |
| 308 | 308 | if($value===THttpSessionCookieMode::None) |
| 309 | - { |
|
| 309 | + { |
|
| 310 | 310 | ini_set('session.use_cookies','0'); |
| 311 | 311 | ini_set('session.use_only_cookies','0'); |
| 312 | - } |
|
| 312 | + } |
|
| 313 | 313 | else if($value===THttpSessionCookieMode::Allow) |
| 314 | 314 | { |
| 315 | 315 | ini_set('session.use_cookies','1'); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @package System.Web |
| 68 | 68 | * @since 3.0 |
| 69 | 69 | */ |
| 70 | -class THttpSession extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule |
|
| 70 | +class THttpSession extends TApplicationComponent implements IteratorAggregate, ArrayAccess, Countable, IModule |
|
| 71 | 71 | { |
| 72 | 72 | /** |
| 73 | 73 | * @var boolean whether this module has been initialized |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | if(!$this->_started) |
| 134 | 134 | { |
| 135 | 135 | if($this->_customStorage) |
| 136 | - session_set_save_handler(array($this,'_open'),array($this,'_close'),array($this,'_read'),array($this,'_write'),array($this,'_destroy'),array($this,'_gc')); |
|
| 136 | + session_set_save_handler(array($this, '_open'), array($this, '_close'), array($this, '_read'), array($this, '_write'), array($this, '_destroy'), array($this, '_gc')); |
|
| 137 | 137 | if($this->_cookie!==null) |
| 138 | - session_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure(),$this->_cookie->getHttpOnly()); |
|
| 138 | + session_set_cookie_params($this->_cookie->getExpire(), $this->_cookie->getPath(), $this->_cookie->getDomain(), $this->_cookie->getSecure(), $this->_cookie->getHttpOnly()); |
|
| 139 | 139 | if(ini_get('session.auto_start')!=='1') |
| 140 | 140 | session_start(); |
| 141 | 141 | $this->_started=true; |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public function regenerate($deleteOld=false) |
| 177 | 177 | { |
| 178 | - $old = $this->getSessionID(); |
|
| 178 | + $old=$this->getSessionID(); |
|
| 179 | 179 | session_regenerate_id($deleteOld); |
| 180 | 180 | return $old; |
| 181 | 181 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | else if(ctype_alnum($value)) |
| 228 | 228 | session_name($value); |
| 229 | 229 | else |
| 230 | - throw new TInvalidDataValueException('httpsession_sessionname_invalid',$value); |
|
| 230 | + throw new TInvalidDataValueException('httpsession_sessionname_invalid', $value); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | else if(is_dir($value)) |
| 250 | 250 | session_save_path($value); |
| 251 | 251 | else |
| 252 | - throw new TInvalidDataValueException('httpsession_savepath_invalid',$value); |
|
| 252 | + throw new TInvalidDataValueException('httpsession_savepath_invalid', $value); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | public function getCookie() |
| 278 | 278 | { |
| 279 | 279 | if($this->_cookie===null) |
| 280 | - $this->_cookie=new THttpCookie($this->getSessionName(),$this->getSessionID()); |
|
| 280 | + $this->_cookie=new THttpCookie($this->getSessionName(), $this->getSessionID()); |
|
| 281 | 281 | return $this->_cookie; |
| 282 | 282 | } |
| 283 | 283 | |
@@ -304,21 +304,21 @@ discard block |
||
| 304 | 304 | throw new TInvalidOperationException('httpsession_cookiemode_unchangeable'); |
| 305 | 305 | else |
| 306 | 306 | { |
| 307 | - $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); |
|
| 307 | + $value=TPropertyValue::ensureEnum($value, 'THttpSessionCookieMode'); |
|
| 308 | 308 | if($value===THttpSessionCookieMode::None) |
| 309 | 309 | { |
| 310 | - ini_set('session.use_cookies','0'); |
|
| 311 | - ini_set('session.use_only_cookies','0'); |
|
| 310 | + ini_set('session.use_cookies', '0'); |
|
| 311 | + ini_set('session.use_only_cookies', '0'); |
|
| 312 | 312 | } |
| 313 | 313 | else if($value===THttpSessionCookieMode::Allow) |
| 314 | 314 | { |
| 315 | - ini_set('session.use_cookies','1'); |
|
| 316 | - ini_set('session.use_only_cookies','0'); |
|
| 315 | + ini_set('session.use_cookies', '1'); |
|
| 316 | + ini_set('session.use_only_cookies', '0'); |
|
| 317 | 317 | } |
| 318 | 318 | else |
| 319 | 319 | { |
| 320 | - ini_set('session.use_cookies','1'); |
|
| 321 | - ini_set('session.use_only_cookies','1'); |
|
| 320 | + ini_set('session.use_cookies', '1'); |
|
| 321 | + ini_set('session.use_only_cookies', '1'); |
|
| 322 | 322 | ini_set('session.use_trans_sid', 0); |
| 323 | 323 | } |
| 324 | 324 | } |
@@ -364,13 +364,13 @@ discard block |
||
| 364 | 364 | else |
| 365 | 365 | { |
| 366 | 366 | $value=TPropertyValue::ensureInteger($value); |
| 367 | - if($value>=0 && $value<=100) |
|
| 367 | + if($value >= 0 && $value <= 100) |
|
| 368 | 368 | { |
| 369 | - ini_set('session.gc_probability',$value); |
|
| 370 | - ini_set('session.gc_divisor','100'); |
|
| 369 | + ini_set('session.gc_probability', $value); |
|
| 370 | + ini_set('session.gc_divisor', '100'); |
|
| 371 | 371 | } |
| 372 | 372 | else |
| 373 | - throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value); |
|
| 373 | + throw new TInvalidDataValueException('httpsession_gcprobability_invalid', $value); |
|
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | |
@@ -392,9 +392,9 @@ discard block |
||
| 392 | 392 | else |
| 393 | 393 | { |
| 394 | 394 | $value=TPropertyValue::ensureBoolean($value); |
| 395 | - if ($value && $this->getCookieMode()==THttpSessionCookieMode::Only) |
|
| 395 | + if($value && $this->getCookieMode()==THttpSessionCookieMode::Only) |
|
| 396 | 396 | throw new TInvalidOperationException('httpsession_transid_cookieonly'); |
| 397 | - ini_set('session.use_trans_sid',$value?'1':'0'); |
|
| 397 | + ini_set('session.use_trans_sid', $value ? '1' : '0'); |
|
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | if($this->_started) |
| 416 | 416 | throw new TInvalidOperationException('httpsession_maxlifetime_unchangeable'); |
| 417 | 417 | else |
| 418 | - ini_set('session.gc_maxlifetime',$value); |
|
| 418 | + ini_set('session.gc_maxlifetime', $value); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | /** |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | * @param string session name |
| 426 | 426 | * @return boolean whether session is opened successfully |
| 427 | 427 | */ |
| 428 | - public function _open($savePath,$sessionName) |
|
| 428 | + public function _open($savePath, $sessionName) |
|
| 429 | 429 | { |
| 430 | 430 | return true; |
| 431 | 431 | } |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | * @param string session data |
| 459 | 459 | * @return boolean whether session write is successful |
| 460 | 460 | */ |
| 461 | - public function _write($id,$data) |
|
| 461 | + public function _write($id, $data) |
|
| 462 | 462 | { |
| 463 | 463 | return true; |
| 464 | 464 | } |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | * @param mixed session variable name |
| 541 | 541 | * @param mixed session variable value |
| 542 | 542 | */ |
| 543 | - public function add($key,$value) |
|
| 543 | + public function add($key, $value) |
|
| 544 | 544 | { |
| 545 | 545 | $_SESSION[$key]=$value; |
| 546 | 546 | } |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | * @param integer the offset to set element |
| 614 | 614 | * @param mixed the element value |
| 615 | 615 | */ |
| 616 | - public function offsetSet($offset,$item) |
|
| 616 | + public function offsetSet($offset, $item) |
|
| 617 | 617 | { |
| 618 | 618 | $_SESSION[$offset]=$item; |
| 619 | 619 | } |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | */ |
| 687 | 687 | public function current() |
| 688 | 688 | { |
| 689 | - return isset($_SESSION[$this->_key])?$_SESSION[$this->_key]:null; |
|
| 689 | + return isset($_SESSION[$this->_key]) ? $_SESSION[$this->_key] : null; |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | /** |
@@ -309,13 +309,11 @@ discard block |
||
| 309 | 309 | { |
| 310 | 310 | ini_set('session.use_cookies','0'); |
| 311 | 311 | ini_set('session.use_only_cookies','0'); |
| 312 | - } |
|
| 313 | - else if($value===THttpSessionCookieMode::Allow) |
|
| 312 | + } else if($value===THttpSessionCookieMode::Allow) |
|
| 314 | 313 | { |
| 315 | 314 | ini_set('session.use_cookies','1'); |
| 316 | 315 | ini_set('session.use_only_cookies','0'); |
| 317 | - } |
|
| 318 | - else |
|
| 316 | + } else |
|
| 319 | 317 | { |
| 320 | 318 | ini_set('session.use_cookies','1'); |
| 321 | 319 | ini_set('session.use_only_cookies','1'); |
@@ -368,8 +366,7 @@ discard block |
||
| 368 | 366 | { |
| 369 | 367 | ini_set('session.gc_probability',$value); |
| 370 | 368 | ini_set('session.gc_divisor','100'); |
| 371 | - } |
|
| 372 | - else |
|
| 369 | + } else |
|
| 373 | 370 | throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value); |
| 374 | 371 | } |
| 375 | 372 | } |
@@ -557,8 +554,7 @@ discard block |
||
| 557 | 554 | $value=$_SESSION[$key]; |
| 558 | 555 | unset($_SESSION[$key]); |
| 559 | 556 | return $value; |
| 560 | - } |
|
| 561 | - else |
|
| 557 | + } else |
|
| 562 | 558 | return null; |
| 563 | 559 | } |
| 564 | 560 | |
@@ -175,6 +175,7 @@ |
||
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | 177 | * @param string state tracker class. |
| 178 | + * @param string $value |
|
| 178 | 179 | */ |
| 179 | 180 | public function setStateTracker($value) |
| 180 | 181 | { |
@@ -78,8 +78,8 @@ |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | - * Publish the ajax script |
|
| 82 | - */ |
|
| 81 | + * Publish the ajax script |
|
| 82 | + */ |
|
| 83 | 83 | public function onPreRender($param) |
| 84 | 84 | { |
| 85 | 85 | parent::onPreRender($param); |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | if($type===null) |
| 70 | 70 | { |
| 71 | 71 | if($this->getControl() instanceof ICallbackEventHandler) |
| 72 | - $this->_activeControlType = 'TBaseActiveCallbackControl'; |
|
| 72 | + $this->_activeControlType='TBaseActiveCallbackControl'; |
|
| 73 | 73 | else |
| 74 | - $this->_activeControlType = 'TBaseActiveControl'; |
|
| 74 | + $this->_activeControlType='TBaseActiveControl'; |
|
| 75 | 75 | } |
| 76 | 76 | else |
| 77 | - $this->_activeControlType = $type; |
|
| 77 | + $this->_activeControlType=$type; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | { |
| 115 | 115 | if($this->_baseActiveControl===null) |
| 116 | 116 | { |
| 117 | - $type = $this->_activeControlType; |
|
| 118 | - $this->_baseActiveControl = new $type($this->getControl()); |
|
| 117 | + $type=$this->_activeControlType; |
|
| 118 | + $this->_baseActiveControl=new $type($this->getControl()); |
|
| 119 | 119 | } |
| 120 | 120 | return $this->_baseActiveControl; |
| 121 | 121 | } |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | { |
| 128 | 128 | if($this->getPage()->getIsCallback()) |
| 129 | 129 | { |
| 130 | - $target = $this->getPage()->getCallbackEventTarget(); |
|
| 130 | + $target=$this->getPage()->getCallbackEventTarget(); |
|
| 131 | 131 | if($target instanceof ICallbackEventHandler) |
| 132 | 132 | { |
| 133 | - $client = $target->getActiveControl()->getClientSide(); |
|
| 133 | + $client=$target->getActiveControl()->getClientSide(); |
|
| 134 | 134 | return $client->getEnablePageStateUpdate(); |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | { |
| 145 | 145 | if($this->getIsTrackingPageState()) |
| 146 | 146 | { |
| 147 | - $stateTrackerClass = $this->_stateTrackerClass; |
|
| 148 | - $this->_stateTracker = new $stateTrackerClass($this->getControl()); |
|
| 147 | + $stateTrackerClass=$this->_stateTrackerClass; |
|
| 148 | + $this->_stateTracker=new $stateTrackerClass($this->getControl()); |
|
| 149 | 149 | $this->_stateTracker->trackChanges(); |
| 150 | 150 | } |
| 151 | 151 | parent::onLoad($param); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function setStateTracker($value) |
| 180 | 180 | { |
| 181 | - $this->_stateTrackerClass = TPropertyValue::ensureString($value); |
|
| 181 | + $this->_stateTrackerClass=TPropertyValue::ensureString($value); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
@@ -216,10 +216,10 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function __construct($control) |
| 218 | 218 | { |
| 219 | - $this->_control = $control; |
|
| 220 | - $this->_existingState = new TMap; |
|
| 221 | - $this->_nullObject = new stdClass; |
|
| 222 | - $this->_states = new TMap; |
|
| 219 | + $this->_control=$control; |
|
| 220 | + $this->_existingState=new TMap; |
|
| 221 | + $this->_nullObject=new stdClass; |
|
| 222 | + $this->_states=new TMap; |
|
| 223 | 223 | $this->addStatesToTrack(); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -233,14 +233,14 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | protected function addStatesToTrack() |
| 235 | 235 | { |
| 236 | - $states = $this->getStatesToTrack(); |
|
| 237 | - $states['Visible'] = array('TScalarDiff', array($this, 'updateVisible')); |
|
| 238 | - $states['Enabled'] = array('TScalarDiff', array($this, 'updateEnabled')); |
|
| 239 | - $states['Attributes'] = array('TMapCollectionDiff', array($this, 'updateAttributes')); |
|
| 240 | - $states['Style'] = array('TStyleDiff', array($this, 'updateStyle')); |
|
| 241 | - $states['TabIndex'] = array('TScalarDiff', array($this, 'updateTabIndex')); |
|
| 242 | - $states['ToolTip'] = array('TScalarDiff', array($this, 'updateToolTip')); |
|
| 243 | - $states['AccessKey'] = array('TScalarDiff', array($this, 'updateAccessKey')); |
|
| 236 | + $states=$this->getStatesToTrack(); |
|
| 237 | + $states['Visible']=array('TScalarDiff', array($this, 'updateVisible')); |
|
| 238 | + $states['Enabled']=array('TScalarDiff', array($this, 'updateEnabled')); |
|
| 239 | + $states['Attributes']=array('TMapCollectionDiff', array($this, 'updateAttributes')); |
|
| 240 | + $states['Style']=array('TStyleDiff', array($this, 'updateStyle')); |
|
| 241 | + $states['TabIndex']=array('TScalarDiff', array($this, 'updateTabIndex')); |
|
| 242 | + $states['ToolTip']=array('TScalarDiff', array($this, 'updateToolTip')); |
|
| 243 | + $states['AccessKey']=array('TScalarDiff', array($this, 'updateAccessKey')); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -259,8 +259,8 @@ discard block |
||
| 259 | 259 | { |
| 260 | 260 | foreach($this->_states as $name => $value) |
| 261 | 261 | { |
| 262 | - $obj = $this->_control->getViewState($name); |
|
| 263 | - $this->_existingState[$name] = is_object($obj) ? clone($obj) : $obj; |
|
| 262 | + $obj=$this->_control->getViewState($name); |
|
| 263 | + $this->_existingState[$name]=is_object($obj) ? clone($obj) : $obj; |
|
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | |
@@ -269,16 +269,16 @@ discard block |
||
| 269 | 269 | */ |
| 270 | 270 | protected function getChanges() |
| 271 | 271 | { |
| 272 | - $changes = array(); |
|
| 272 | + $changes=array(); |
|
| 273 | 273 | foreach($this->_states as $name => $details) |
| 274 | 274 | { |
| 275 | - $new = $this->_control->getViewState($name); |
|
| 276 | - $old = $this->_existingState[$name]; |
|
| 277 | - if($new !== $old) |
|
| 275 | + $new=$this->_control->getViewState($name); |
|
| 276 | + $old=$this->_existingState[$name]; |
|
| 277 | + if($new!==$old) |
|
| 278 | 278 | { |
| 279 | - $diff = new $details[0]($new, $old, $this->_nullObject); |
|
| 280 | - if(($change = $diff->getDifference()) !== $this->_nullObject) |
|
| 281 | - $changes[] = array($details[1],array($change)); |
|
| 279 | + $diff=new $details[0]($new, $old, $this->_nullObject); |
|
| 280 | + if(($change=$diff->getDifference())!==$this->_nullObject) |
|
| 281 | + $changes[]=array($details[1], array($change)); |
|
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | return $changes; |
@@ -335,10 +335,10 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | protected function updateVisible($visible) |
| 337 | 337 | { |
| 338 | - if($visible === false) |
|
| 339 | - $this->client()->replaceContent($this->_control,"<span id=\"".$this->_control->getClientID()."\" style=\"display:none\" ></span>"); |
|
| 338 | + if($visible===false) |
|
| 339 | + $this->client()->replaceContent($this->_control, "<span id=\"".$this->_control->getClientID()."\" style=\"display:none\" ></span>"); |
|
| 340 | 340 | else |
| 341 | - $this->client()->replaceContent($this->_control,$this->_control); |
|
| 341 | + $this->client()->replaceContent($this->_control, $this->_control); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /** |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | */ |
| 404 | 404 | public function __construct($new, $old, $null) |
| 405 | 405 | { |
| 406 | - $this->_new = $new; |
|
| 407 | - $this->_old = $old; |
|
| 408 | - $this->_null = $null; |
|
| 406 | + $this->_new=$new; |
|
| 407 | + $this->_old=$old; |
|
| 408 | + $this->_null=$null; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
@@ -430,8 +430,8 @@ discard block |
||
| 430 | 430 | */ |
| 431 | 431 | public function getDifference() |
| 432 | 432 | { |
| 433 | - if(gettype($this->_new) === gettype($this->_old) |
|
| 434 | - && $this->_new === $this->_old) |
|
| 433 | + if(gettype($this->_new)===gettype($this->_old) |
|
| 434 | + && $this->_new===$this->_old) |
|
| 435 | 435 | return $this->_null; |
| 436 | 436 | else |
| 437 | 437 | return $this->_new; |
@@ -457,10 +457,10 @@ discard block |
||
| 457 | 457 | { |
| 458 | 458 | if(!($obj instanceof TStyle)) |
| 459 | 459 | return array(); |
| 460 | - $style = $obj->getStyleFields(); |
|
| 461 | - $style = array_merge($style,$this->getStyleFromString($obj->getCustomStyle())); |
|
| 460 | + $style=$obj->getStyleFields(); |
|
| 461 | + $style=array_merge($style, $this->getStyleFromString($obj->getCustomStyle())); |
|
| 462 | 462 | if($obj->hasFont()) |
| 463 | - $style = array_merge($style, $this->getStyleFromString($obj->getFont()->toString())); |
|
| 463 | + $style=array_merge($style, $this->getStyleFromString($obj->getFont()->toString())); |
|
| 464 | 464 | return $style; |
| 465 | 465 | } |
| 466 | 466 | |
@@ -470,14 +470,14 @@ discard block |
||
| 470 | 470 | */ |
| 471 | 471 | protected function getStyleFromString($string) |
| 472 | 472 | { |
| 473 | - $style = array(); |
|
| 473 | + $style=array(); |
|
| 474 | 474 | if(!is_string($string)) return $style; |
| 475 | 475 | |
| 476 | - foreach(explode(';',$string) as $sub) |
|
| 476 | + foreach(explode(';', $string) as $sub) |
|
| 477 | 477 | { |
| 478 | - $arr=explode(':',$sub); |
|
| 478 | + $arr=explode(':', $sub); |
|
| 479 | 479 | if(isset($arr[1]) && trim($arr[0])!=='') |
| 480 | - $style[trim($arr[0])] = trim($arr[1]); |
|
| 480 | + $style[trim($arr[0])]=trim($arr[1]); |
|
| 481 | 481 | } |
| 482 | 482 | return $style; |
| 483 | 483 | } |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | } |
| 495 | 495 | else |
| 496 | 496 | { |
| 497 | - return $this->_old->getCssClass() !== $this->_new->getCssClass() ? |
|
| 497 | + return $this->_old->getCssClass()!==$this->_new->getCssClass() ? |
|
| 498 | 498 | $this->_new->getCssClass() : null; |
| 499 | 499 | } |
| 500 | 500 | } |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | */ |
| 505 | 505 | protected function getStyleDiff() |
| 506 | 506 | { |
| 507 | - $diff = array_diff_assoc( |
|
| 507 | + $diff=array_diff_assoc( |
|
| 508 | 508 | $this->getCombinedStyle($this->_new), |
| 509 | 509 | $this->getCombinedStyle($this->_old)); |
| 510 | 510 | return count($diff) > 0 ? $diff : null; |
@@ -519,8 +519,8 @@ discard block |
||
| 519 | 519 | return $this->_null; |
| 520 | 520 | else |
| 521 | 521 | { |
| 522 | - $css = $this->getCssClassDiff(); |
|
| 523 | - $style = $this->getStyleDiff(); |
|
| 522 | + $css=$this->getCssClassDiff(); |
|
| 523 | + $style=$this->getStyleDiff(); |
|
| 524 | 524 | if(($css!==null) || ($style!==null)) |
| 525 | 525 | return array('CssClass' => $css, 'Style' => $style); |
| 526 | 526 | else |
@@ -551,9 +551,9 @@ discard block |
||
| 551 | 551 | } |
| 552 | 552 | else |
| 553 | 553 | { |
| 554 | - $new = $this->_new->toArray(); |
|
| 555 | - $old = $this->_old->toArray(); |
|
| 556 | - $diff = array_diff_assoc($new, $old); |
|
| 554 | + $new=$this->_new->toArray(); |
|
| 555 | + $old=$this->_old->toArray(); |
|
| 556 | + $diff=array_diff_assoc($new, $old); |
|
| 557 | 557 | return count($diff) > 0 ? $diff : $this->_null; |
| 558 | 558 | } |
| 559 | 559 | } |
@@ -72,8 +72,7 @@ discard block |
||
| 72 | 72 | $this->_activeControlType = 'TBaseActiveCallbackControl'; |
| 73 | 73 | else |
| 74 | 74 | $this->_activeControlType = 'TBaseActiveControl'; |
| 75 | - } |
|
| 76 | - else |
|
| 75 | + } else |
|
| 77 | 76 | $this->_activeControlType = $type; |
| 78 | 77 | } |
| 79 | 78 | |
@@ -491,8 +490,7 @@ discard block |
||
| 491 | 490 | { |
| 492 | 491 | return ($this->_new!==null) && $this->_new->hasCssClass() |
| 493 | 492 | ? $this->_new->getCssClass() : null; |
| 494 | - } |
|
| 495 | - else |
|
| 493 | + } else |
|
| 496 | 494 | { |
| 497 | 495 | return $this->_old->getCssClass() !== $this->_new->getCssClass() ? |
| 498 | 496 | $this->_new->getCssClass() : null; |
@@ -548,8 +546,7 @@ discard block |
||
| 548 | 546 | if($this->_old===null) |
| 549 | 547 | { |
| 550 | 548 | return ($this->_new!==null) ? $this->_new->toArray() : $this->_null; |
| 551 | - } |
|
| 552 | - else |
|
| 549 | + } else |
|
| 553 | 550 | { |
| 554 | 551 | $new = $this->_new->toArray(); |
| 555 | 552 | $old = $this->_old->toArray(); |
@@ -252,7 +252,7 @@ |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | - * @return boolean true to observe changes. |
|
| 255 | + * @return boolean|string true to observe changes. |
|
| 256 | 256 | */ |
| 257 | 257 | public function getObserveChanges() |
| 258 | 258 | { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | /** |
| 37 | 37 | * @var boolean true if validation is made during a callback request. |
| 38 | 38 | */ |
| 39 | - private $_isCallback = false; |
|
| 39 | + private $_isCallback=false; |
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @return boolean true if validation is made during a callback request. |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function raiseCallbackEvent($param) |
| 95 | 95 | { |
| 96 | - $this->_isCallback = true; |
|
| 97 | - $result = $this->onServerValidate($param->getCallbackParameter()); |
|
| 96 | + $this->_isCallback=true; |
|
| 97 | + $result=$this->onServerValidate($param->getCallbackParameter()); |
|
| 98 | 98 | $param->setResponseData($result); |
| 99 | 99 | $this->onCallback($param); |
| 100 | 100 | } |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | parent::setIsValid($value); |
| 111 | 111 | if($this->getActiveControl()->canUpdateClientSide()) |
| 112 | 112 | { |
| 113 | - $client = $this->getPage()->getCallbackClient(); |
|
| 114 | - $func = 'Prado.Validation.updateActiveCustomValidator'; |
|
| 113 | + $client=$this->getPage()->getCallbackClient(); |
|
| 114 | + $func='Prado.Validation.updateActiveCustomValidator'; |
|
| 115 | 115 | $client->callClientFunction($func, array($this, $value)); |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | protected function getClientScriptOptions() |
| 136 | 136 | { |
| 137 | 137 | $options=TBaseValidator::getClientScriptOptions(); |
| 138 | - $options['EventTarget'] = $this->getUniqueID(); |
|
| 138 | + $options['EventTarget']=$this->getUniqueID(); |
|
| 139 | 139 | return $options; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -145,15 +145,15 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public function setErrorMessage($value) |
| 147 | 147 | { |
| 148 | - if(parent::getErrorMessage() === $value) |
|
| 148 | + if(parent::getErrorMessage()===$value) |
|
| 149 | 149 | return; |
| 150 | 150 | |
| 151 | 151 | |
| 152 | 152 | parent::setErrorMessage($value); |
| 153 | 153 | if($this->getActiveControl()->canUpdateClientSide()) |
| 154 | 154 | { |
| 155 | - $client = $this->getPage()->getCallbackClient(); |
|
| 156 | - $func = 'Prado.Validation.setErrorMessage'; |
|
| 155 | + $client=$this->getPage()->getCallbackClient(); |
|
| 156 | + $func='Prado.Validation.setErrorMessage'; |
|
| 157 | 157 | $client->callClientFunction($func, array($this, $value)); |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | public function getObserveChanges() |
| 265 | 265 | { |
| 266 | - $changes = $this->getOption('ObserveChanges'); |
|
| 266 | + $changes=$this->getOption('ObserveChanges'); |
|
| 267 | 267 | return ($changes===null) ? true : $changes; |
| 268 | 268 | } |
| 269 | 269 | } |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | /** |
| 67 | 67 | * No client class for this control. |
| 68 | 68 | * This method overrides the parent implementation. |
| 69 | - * @return null no javascript class name. |
|
| 69 | + * @return string no javascript class name. |
|
| 70 | 70 | */ |
| 71 | 71 | protected function getClientClassName() |
| 72 | 72 | { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | protected function createListItemCollection() |
| 84 | 84 | { |
| 85 | - $collection = new TActiveListItemCollection; |
|
| 85 | + $collection=new TActiveListItemCollection; |
|
| 86 | 86 | $collection->setControl($this); |
| 87 | 87 | return $collection; |
| 88 | 88 | } |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | protected function addAttributesToRender($writer) |
| 103 | 103 | { |
| 104 | 104 | parent::addAttributesToRender($writer); |
| 105 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 106 | - if ($this->getAutoPostBack()) |
|
| 105 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 106 | + if($this->getAutoPostBack()) |
|
| 107 | 107 | $this->getActiveControl()->registerCallbackClientScript( |
| 108 | 108 | $this->getClientClassName(), $this->getPostBackOptions()); |
| 109 | 109 | } |
@@ -79,6 +79,7 @@ |
||
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * @param string the URL of the image file |
| 82 | + * @param string $value |
|
| 82 | 83 | */ |
| 83 | 84 | public function setImageUrl($value) |
| 84 | 85 | { |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function setAlternateText($value) |
| 60 | 60 | { |
| 61 | - if(parent::getAlternateText() === $value) |
|
| 61 | + if(parent::getAlternateText()===$value) |
|
| 62 | 62 | return; |
| 63 | 63 | |
| 64 | 64 | parent::setAlternateText($value); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function setImageAlign($value) |
| 77 | 77 | { |
| 78 | - if(parent::getImageAlign() === $value) |
|
| 78 | + if(parent::getImageAlign()===$value) |
|
| 79 | 79 | return; |
| 80 | 80 | |
| 81 | 81 | parent::setImageAlign($value); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function setImageUrl($value) |
| 90 | 90 | { |
| 91 | - if(parent::getImageUrl() === $value) |
|
| 91 | + if(parent::getImageUrl()===$value) |
|
| 92 | 92 | return; |
| 93 | 93 | |
| 94 | 94 | parent::setImageUrl($value); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function setDescriptionUrl($value) |
| 103 | 103 | { |
| 104 | - if(parent::getDescriptionUrl() === $value) |
|
| 104 | + if(parent::getDescriptionUrl()===$value) |
|
| 105 | 105 | return; |
| 106 | 106 | |
| 107 | 107 | parent::setDescriptionUrl($value); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | protected function addAttributesToRender($writer) |
| 152 | 152 | { |
| 153 | 153 | parent::addAttributesToRender($writer); |
| 154 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 154 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 155 | 155 | $this->getActiveControl()->registerCallbackClientScript( |
| 156 | 156 | $this->getClientClassName(), $this->getPostBackOptions()); |
| 157 | 157 | } |