@@ -72,6 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * @param string username |
| 75 | + * @param string $value |
|
| 75 | 76 | */ |
| 76 | 77 | public function setName($value) |
| 77 | 78 | { |
@@ -88,6 +89,7 @@ discard block |
||
| 88 | 89 | |
| 89 | 90 | /** |
| 90 | 91 | * @param boolean if the user is a guest |
| 92 | + * @param boolean $value |
|
| 91 | 93 | */ |
| 92 | 94 | public function setIsGuest($value) |
| 93 | 95 | { |
@@ -169,6 +171,7 @@ discard block |
||
| 169 | 171 | * |
| 170 | 172 | * @param string variable name |
| 171 | 173 | * @param mixed default value |
| 174 | + * @param string $key |
|
| 172 | 175 | * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned |
| 173 | 176 | * @see setState |
| 174 | 177 | */ |
@@ -189,6 +192,7 @@ discard block |
||
| 189 | 192 | * @param string variable name |
| 190 | 193 | * @param mixed variable value |
| 191 | 194 | * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage. |
| 195 | + * @param string $key |
|
| 192 | 196 | * @see getState |
| 193 | 197 | */ |
| 194 | 198 | protected function setState($key, $value, $defaultValue = null) |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * @var boolean whether user state is changed |
| 39 | 39 | */ |
| 40 | - private $_stateChanged = false; |
|
| 40 | + private $_stateChanged=false; |
|
| 41 | 41 | /** |
| 42 | 42 | * @var IUserManager user manager |
| 43 | 43 | */ |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function __construct(IUserManager $manager) |
| 51 | 51 | { |
| 52 | - $this->_state = []; |
|
| 53 | - $this->_manager = $manager; |
|
| 52 | + $this->_state=[]; |
|
| 53 | + $this->_manager=$manager; |
|
| 54 | 54 | $this->setName($manager->getGuestName()); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function setIsGuest($value) |
| 93 | 93 | { |
| 94 | - if($isGuest = TPropertyValue::ensureBoolean($value)) |
|
| 94 | + if($isGuest=TPropertyValue::ensureBoolean($value)) |
|
| 95 | 95 | { |
| 96 | 96 | $this->setName($this->_manager->getGuestName()); |
| 97 | 97 | $this->setRoles([]); |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | $this->setState('Roles', $value, []); |
| 117 | 117 | else |
| 118 | 118 | { |
| 119 | - $roles = []; |
|
| 119 | + $roles=[]; |
|
| 120 | 120 | foreach(explode(',', $value) as $role) |
| 121 | 121 | { |
| 122 | - if(($role = trim($role)) !== '') |
|
| 123 | - $roles[] = $role; |
|
| 122 | + if(($role=trim($role))!=='') |
|
| 123 | + $roles[]=$role; |
|
| 124 | 124 | } |
| 125 | 125 | $this->setState('Roles', $roles, []); |
| 126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | public function isInRole($role) |
| 134 | 134 | { |
| 135 | 135 | foreach($this->getRoles() as $r) |
| 136 | - if(strcasecmp($role, $r) === 0) |
|
| 136 | + if(strcasecmp($role, $r)===0) |
|
| 137 | 137 | return true; |
| 138 | 138 | return false; |
| 139 | 139 | } |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | public function loadFromString($data) |
| 154 | 154 | { |
| 155 | 155 | if(!empty($data)) |
| 156 | - $this->_state = unserialize($data); |
|
| 156 | + $this->_state=unserialize($data); |
|
| 157 | 157 | if(!is_array($this->_state)) |
| 158 | - $this->_state = []; |
|
| 158 | + $this->_state=[]; |
|
| 159 | 159 | return $this; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned |
| 173 | 173 | * @see setState |
| 174 | 174 | */ |
| 175 | - protected function getState($key, $defaultValue = null) |
|
| 175 | + protected function getState($key, $defaultValue=null) |
|
| 176 | 176 | { |
| 177 | - return isset($this->_state[$key])?$this->_state[$key]:$defaultValue; |
|
| 177 | + return isset($this->_state[$key]) ? $this->_state[$key] : $defaultValue; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -191,13 +191,13 @@ discard block |
||
| 191 | 191 | * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage. |
| 192 | 192 | * @see getState |
| 193 | 193 | */ |
| 194 | - protected function setState($key, $value, $defaultValue = null) |
|
| 194 | + protected function setState($key, $value, $defaultValue=null) |
|
| 195 | 195 | { |
| 196 | - if($value === $defaultValue) |
|
| 196 | + if($value===$defaultValue) |
|
| 197 | 197 | unset($this->_state[$key]); |
| 198 | 198 | else |
| 199 | - $this->_state[$key] = $value; |
|
| 200 | - $this->_stateChanged = true; |
|
| 199 | + $this->_state[$key]=$value; |
|
| 200 | + $this->_stateChanged=true; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function setStateChanged($value) |
| 215 | 215 | { |
| 216 | - $this->_stateChanged = TPropertyValue::ensureBoolean($value); |
|
| 216 | + $this->_stateChanged=TPropertyValue::ensureBoolean($value); |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
@@ -317,6 +317,7 @@ discard block |
||
| 317 | 317 | * to determine the application configuration file, |
| 318 | 318 | * application root path and the runtime path. |
| 319 | 319 | * @param string the application root path or the application configuration file |
| 320 | + * @param string $basePath |
|
| 320 | 321 | * @see setBasePath |
| 321 | 322 | * @see setRuntimePath |
| 322 | 323 | * @see setConfigurationFile |
@@ -415,6 +416,7 @@ discard block |
||
| 415 | 416 | * A global value is one that is persistent across users sessions and requests. |
| 416 | 417 | * @param string the name of the value to be returned |
| 417 | 418 | * @param mixed the default value. If $key is not found, $defaultValue will be returned |
| 419 | + * @param integer $defaultValue |
|
| 418 | 420 | * @return mixed the global value corresponding to $key |
| 419 | 421 | */ |
| 420 | 422 | public function getGlobalState($key, $defaultValue = null) |
@@ -431,6 +433,7 @@ discard block |
||
| 431 | 433 | * @param mixed the global value to be set |
| 432 | 434 | * @param mixed the default value. If $key is not found, $defaultValue will be returned |
| 433 | 435 | * @param boolean wheter to force an immediate GlobalState save. defaults to false |
| 436 | + * @param string $key |
|
| 434 | 437 | */ |
| 435 | 438 | public function setGlobalState($key, $value, $defaultValue = null, $forceSave = false) |
| 436 | 439 | { |
@@ -545,6 +548,7 @@ discard block |
||
| 545 | 548 | |
| 546 | 549 | /** |
| 547 | 550 | * @param string the directory containing the application configuration file |
| 551 | + * @param string $value |
|
| 548 | 552 | */ |
| 549 | 553 | public function setBasePath($value) |
| 550 | 554 | { |
@@ -561,6 +565,7 @@ discard block |
||
| 561 | 565 | |
| 562 | 566 | /** |
| 563 | 567 | * @param string the application configuration file (absolute path) |
| 568 | + * @param string $value |
|
| 564 | 569 | */ |
| 565 | 570 | public function setConfigurationFile($value) |
| 566 | 571 | { |
@@ -577,6 +582,7 @@ discard block |
||
| 577 | 582 | |
| 578 | 583 | /** |
| 579 | 584 | * @param string the application configuration type. 'xml' and 'php' are valid values |
| 585 | + * @param string $value |
|
| 580 | 586 | */ |
| 581 | 587 | public function setConfigurationType($value) |
| 582 | 588 | { |
@@ -632,6 +638,7 @@ discard block |
||
| 632 | 638 | |
| 633 | 639 | /** |
| 634 | 640 | * @param string the directory storing cache data and application-level persistent data. (absolute path) |
| 641 | + * @param string $value |
|
| 635 | 642 | */ |
| 636 | 643 | public function setRuntimePath($value) |
| 637 | 644 | { |
@@ -1063,6 +1070,7 @@ discard block |
||
| 1063 | 1070 | * The service instance will be created. Its properties will be initialized |
| 1064 | 1071 | * and the configurations will be applied, if any. |
| 1065 | 1072 | * @param string service ID |
| 1073 | + * @param string $serviceID |
|
| 1066 | 1074 | */ |
| 1067 | 1075 | public function startService($serviceID) |
| 1068 | 1076 | { |
@@ -1101,6 +1109,7 @@ discard block |
||
| 1101 | 1109 | * This method is invoked when an exception is raised during the lifecycles |
| 1102 | 1110 | * of the application. |
| 1103 | 1111 | * @param mixed event parameter |
| 1112 | + * @param \Exception $param |
|
| 1104 | 1113 | */ |
| 1105 | 1114 | public function onError($param) |
| 1106 | 1115 | { |
@@ -96,48 +96,48 @@ discard block |
||
| 96 | 96 | /** |
| 97 | 97 | * Page service ID |
| 98 | 98 | */ |
| 99 | - const PAGE_SERVICE_ID = 'page'; |
|
| 99 | + const PAGE_SERVICE_ID='page'; |
|
| 100 | 100 | /** |
| 101 | 101 | * Application configuration file name |
| 102 | 102 | */ |
| 103 | - const CONFIG_FILE_XML = 'application.xml'; |
|
| 103 | + const CONFIG_FILE_XML='application.xml'; |
|
| 104 | 104 | /** |
| 105 | 105 | * File extension for external config files |
| 106 | 106 | */ |
| 107 | - const CONFIG_FILE_EXT_XML = '.xml'; |
|
| 107 | + const CONFIG_FILE_EXT_XML='.xml'; |
|
| 108 | 108 | /** |
| 109 | 109 | * Configuration file type, application.xml and config.xml |
| 110 | 110 | */ |
| 111 | - const CONFIG_TYPE_XML = 'xml'; |
|
| 111 | + const CONFIG_TYPE_XML='xml'; |
|
| 112 | 112 | /** |
| 113 | 113 | * Application configuration file name |
| 114 | 114 | */ |
| 115 | - const CONFIG_FILE_PHP = 'application.php'; |
|
| 115 | + const CONFIG_FILE_PHP='application.php'; |
|
| 116 | 116 | /** |
| 117 | 117 | * File extension for external config files |
| 118 | 118 | */ |
| 119 | - const CONFIG_FILE_EXT_PHP = '.php'; |
|
| 119 | + const CONFIG_FILE_EXT_PHP='.php'; |
|
| 120 | 120 | /** |
| 121 | 121 | * Configuration file type, application.php and config.php |
| 122 | 122 | */ |
| 123 | - const CONFIG_TYPE_PHP = 'php'; |
|
| 123 | + const CONFIG_TYPE_PHP='php'; |
|
| 124 | 124 | /** |
| 125 | 125 | * Runtime directory name |
| 126 | 126 | */ |
| 127 | - const RUNTIME_PATH = 'runtime'; |
|
| 127 | + const RUNTIME_PATH='runtime'; |
|
| 128 | 128 | /** |
| 129 | 129 | * Config cache file |
| 130 | 130 | */ |
| 131 | - const CONFIGCACHE_FILE = 'config.cache'; |
|
| 131 | + const CONFIGCACHE_FILE='config.cache'; |
|
| 132 | 132 | /** |
| 133 | 133 | * Global data file |
| 134 | 134 | */ |
| 135 | - const GLOBAL_FILE = 'global.cache'; |
|
| 135 | + const GLOBAL_FILE='global.cache'; |
|
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * @var array list of events that define application lifecycles |
| 139 | 139 | */ |
| 140 | - private static $_steps = [ |
|
| 140 | + private static $_steps=[ |
|
| 141 | 141 | 'onBeginRequest', |
| 142 | 142 | 'onLoadState', |
| 143 | 143 | 'onLoadStateComplete', |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | /** |
| 165 | 165 | * @var boolean whether the request is completed |
| 166 | 166 | */ |
| 167 | - private $_requestCompleted = false; |
|
| 167 | + private $_requestCompleted=false; |
|
| 168 | 168 | /** |
| 169 | 169 | * @var integer application state |
| 170 | 170 | */ |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | /** |
| 181 | 181 | * @var array list of loaded application modules |
| 182 | 182 | */ |
| 183 | - private $_modules = []; |
|
| 183 | + private $_modules=[]; |
|
| 184 | 184 | /** |
| 185 | 185 | * @var array list of application modules yet to be loaded |
| 186 | 186 | */ |
| 187 | - private $_lazyModules = []; |
|
| 187 | + private $_lazyModules=[]; |
|
| 188 | 188 | /** |
| 189 | 189 | * @var \Prado\Collections\TMap list of application parameters |
| 190 | 190 | */ |
@@ -212,11 +212,11 @@ discard block |
||
| 212 | 212 | /** |
| 213 | 213 | * @var boolean if any global state is changed during the current request |
| 214 | 214 | */ |
| 215 | - private $_stateChanged = false; |
|
| 215 | + private $_stateChanged=false; |
|
| 216 | 216 | /** |
| 217 | 217 | * @var array global variables (persistent across sessions, requests) |
| 218 | 218 | */ |
| 219 | - private $_globals = []; |
|
| 219 | + private $_globals=[]; |
|
| 220 | 220 | /** |
| 221 | 221 | * @var string cache file |
| 222 | 222 | */ |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | /** |
| 269 | 269 | * @var TApplicationMode application mode |
| 270 | 270 | */ |
| 271 | - private $_mode = TApplicationMode::Debug; |
|
| 271 | + private $_mode=TApplicationMode::Debug; |
|
| 272 | 272 | |
| 273 | 273 | /** |
| 274 | 274 | * @var string Customizable page service ID |
| 275 | 275 | */ |
| 276 | - private $_pageServiceID = self::PAGE_SERVICE_ID; |
|
| 276 | + private $_pageServiceID=self::PAGE_SERVICE_ID; |
|
| 277 | 277 | |
| 278 | 278 | /** |
| 279 | 279 | * Constructor. |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * @param boolean whether to cache application configuration. Defaults to true. |
| 294 | 294 | * @throws TConfigurationException if configuration file cannot be read or the runtime path is invalid. |
| 295 | 295 | */ |
| 296 | - public function __construct($basePath = 'protected', $cacheConfig = true, $configType = self::CONFIG_TYPE_XML) |
|
| 296 | + public function __construct($basePath='protected', $cacheConfig=true, $configType=self::CONFIG_TYPE_XML) |
|
| 297 | 297 | { |
| 298 | 298 | // register application as a singleton |
| 299 | 299 | Prado::setApplication($this); |
@@ -301,12 +301,12 @@ discard block |
||
| 301 | 301 | $this->resolvePaths($basePath); |
| 302 | 302 | |
| 303 | 303 | if($cacheConfig) |
| 304 | - $this->_cacheFile = $this->_runtimePath . DIRECTORY_SEPARATOR . self::CONFIGCACHE_FILE; |
|
| 304 | + $this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE; |
|
| 305 | 305 | |
| 306 | 306 | // generates unique ID by hashing the runtime path |
| 307 | - $this->_uniqueID = md5($this->_runtimePath); |
|
| 308 | - $this->_parameters = new \Prado\Collections\TMap; |
|
| 309 | - $this->_services = [$this->getPageServiceID() => ['TPageService',[],null]]; |
|
| 307 | + $this->_uniqueID=md5($this->_runtimePath); |
|
| 308 | + $this->_parameters=new \Prado\Collections\TMap; |
|
| 309 | + $this->_services=[$this->getPageServiceID() => ['TPageService', [], null]]; |
|
| 310 | 310 | |
| 311 | 311 | Prado::setPathOfAlias('Application', $this->_basePath); |
| 312 | 312 | } |
@@ -324,28 +324,28 @@ discard block |
||
| 324 | 324 | protected function resolvePaths($basePath) |
| 325 | 325 | { |
| 326 | 326 | // determine configuration path and file |
| 327 | - if(empty($basePath) || ($basePath = realpath($basePath)) === false) |
|
| 327 | + if(empty($basePath) || ($basePath=realpath($basePath))===false) |
|
| 328 | 328 | throw new TConfigurationException('application_basepath_invalid', $basePath); |
| 329 | - if(is_dir($basePath) && is_file($basePath . DIRECTORY_SEPARATOR . $this->getConfigurationFileName())) |
|
| 330 | - $configFile = $basePath . DIRECTORY_SEPARATOR . $this->getConfigurationFileName(); |
|
| 329 | + if(is_dir($basePath) && is_file($basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName())) |
|
| 330 | + $configFile=$basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName(); |
|
| 331 | 331 | elseif(is_file($basePath)) |
| 332 | 332 | { |
| 333 | - $configFile = $basePath; |
|
| 334 | - $basePath = dirname($configFile); |
|
| 333 | + $configFile=$basePath; |
|
| 334 | + $basePath=dirname($configFile); |
|
| 335 | 335 | } |
| 336 | 336 | else |
| 337 | - $configFile = null; |
|
| 337 | + $configFile=null; |
|
| 338 | 338 | |
| 339 | 339 | // determine runtime path |
| 340 | - $runtimePath = $basePath . DIRECTORY_SEPARATOR . self::RUNTIME_PATH; |
|
| 340 | + $runtimePath=$basePath.DIRECTORY_SEPARATOR.self::RUNTIME_PATH; |
|
| 341 | 341 | if(is_writable($runtimePath)) |
| 342 | 342 | { |
| 343 | - if($configFile !== null) |
|
| 343 | + if($configFile!==null) |
|
| 344 | 344 | { |
| 345 | - $runtimePath .= DIRECTORY_SEPARATOR . basename($configFile) . '-' . Prado::getVersion(); |
|
| 345 | + $runtimePath.=DIRECTORY_SEPARATOR.basename($configFile).'-'.Prado::getVersion(); |
|
| 346 | 346 | if(!is_dir($runtimePath)) |
| 347 | 347 | { |
| 348 | - if(@mkdir($runtimePath) === false) |
|
| 348 | + if(@mkdir($runtimePath)===false) |
|
| 349 | 349 | throw new TConfigurationException('application_runtimepath_failed', $runtimePath); |
| 350 | 350 | @chmod($runtimePath, PRADO_CHMOD); //make it deletable |
| 351 | 351 | } |
@@ -369,16 +369,16 @@ discard block |
||
| 369 | 369 | try |
| 370 | 370 | { |
| 371 | 371 | $this->initApplication(); |
| 372 | - $n = count(self::$_steps); |
|
| 373 | - $this->_step = 0; |
|
| 374 | - $this->_requestCompleted = false; |
|
| 372 | + $n=count(self::$_steps); |
|
| 373 | + $this->_step=0; |
|
| 374 | + $this->_requestCompleted=false; |
|
| 375 | 375 | while($this->_step < $n) |
| 376 | 376 | { |
| 377 | - if($this->_mode === TApplicationMode::Off) |
|
| 377 | + if($this->_mode===TApplicationMode::Off) |
|
| 378 | 378 | throw new THttpException(503, 'application_unavailable'); |
| 379 | 379 | if($this->_requestCompleted) |
| 380 | 380 | break; |
| 381 | - $method = self::$_steps[$this->_step]; |
|
| 381 | + $method=self::$_steps[$this->_step]; |
|
| 382 | 382 | Prado::trace("Executing $method()", 'Prado\TApplication'); |
| 383 | 383 | $this->$method(); |
| 384 | 384 | $this->_step++; |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | public function completeRequest() |
| 400 | 400 | { |
| 401 | - $this->_requestCompleted = true; |
|
| 401 | + $this->_requestCompleted=true; |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | /** |
@@ -417,9 +417,9 @@ discard block |
||
| 417 | 417 | * @param mixed the default value. If $key is not found, $defaultValue will be returned |
| 418 | 418 | * @return mixed the global value corresponding to $key |
| 419 | 419 | */ |
| 420 | - public function getGlobalState($key, $defaultValue = null) |
|
| 420 | + public function getGlobalState($key, $defaultValue=null) |
|
| 421 | 421 | { |
| 422 | - return isset($this->_globals[$key])?$this->_globals[$key]:$defaultValue; |
|
| 422 | + return isset($this->_globals[$key]) ? $this->_globals[$key] : $defaultValue; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | /** |
@@ -432,13 +432,13 @@ discard block |
||
| 432 | 432 | * @param mixed the default value. If $key is not found, $defaultValue will be returned |
| 433 | 433 | * @param boolean wheter to force an immediate GlobalState save. defaults to false |
| 434 | 434 | */ |
| 435 | - public function setGlobalState($key, $value, $defaultValue = null, $forceSave = false) |
|
| 435 | + public function setGlobalState($key, $value, $defaultValue=null, $forceSave=false) |
|
| 436 | 436 | { |
| 437 | - $this->_stateChanged = true; |
|
| 438 | - if($value === $defaultValue) |
|
| 437 | + $this->_stateChanged=true; |
|
| 438 | + if($value===$defaultValue) |
|
| 439 | 439 | unset($this->_globals[$key]); |
| 440 | 440 | else |
| 441 | - $this->_globals[$key] = $value; |
|
| 441 | + $this->_globals[$key]=$value; |
|
| 442 | 442 | if($forceSave) |
| 443 | 443 | $this->saveGlobals(); |
| 444 | 444 | } |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | */ |
| 452 | 452 | public function clearGlobalState($key) |
| 453 | 453 | { |
| 454 | - $this->_stateChanged = true; |
|
| 454 | + $this->_stateChanged=true; |
|
| 455 | 455 | unset($this->_globals[$key]); |
| 456 | 456 | } |
| 457 | 457 | |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | */ |
| 464 | 464 | protected function loadGlobals() |
| 465 | 465 | { |
| 466 | - $this->_globals = $this->getApplicationStatePersister()->load(); |
|
| 466 | + $this->_globals=$this->getApplicationStatePersister()->load(); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | /** |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | { |
| 475 | 475 | if($this->_stateChanged) |
| 476 | 476 | { |
| 477 | - $this->_stateChanged = false; |
|
| 477 | + $this->_stateChanged=false; |
|
| 478 | 478 | $this->getApplicationStatePersister()->save($this->_globals); |
| 479 | 479 | } |
| 480 | 480 | } |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | */ |
| 493 | 493 | public function setID($value) |
| 494 | 494 | { |
| 495 | - $this->_id = $value; |
|
| 495 | + $this->_id=$value; |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | /** |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | */ |
| 509 | 509 | public function setPageServiceID($value) |
| 510 | 510 | { |
| 511 | - $this->_pageServiceID = $value; |
|
| 511 | + $this->_pageServiceID=$value; |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | /** |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | */ |
| 533 | 533 | public function setMode($value) |
| 534 | 534 | { |
| 535 | - $this->_mode = TPropertyValue::ensureEnum($value, '\Prado\TApplicationMode'); |
|
| 535 | + $this->_mode=TPropertyValue::ensureEnum($value, '\Prado\TApplicationMode'); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | */ |
| 549 | 549 | public function setBasePath($value) |
| 550 | 550 | { |
| 551 | - $this->_basePath = $value; |
|
| 551 | + $this->_basePath=$value; |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | /** |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | */ |
| 565 | 565 | public function setConfigurationFile($value) |
| 566 | 566 | { |
| 567 | - $this->_configFile = $value; |
|
| 567 | + $this->_configFile=$value; |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | /** |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | */ |
| 581 | 581 | public function setConfigurationType($value) |
| 582 | 582 | { |
| 583 | - $this->_configType = $value; |
|
| 583 | + $this->_configType=$value; |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | /** |
@@ -588,15 +588,15 @@ discard block |
||
| 588 | 588 | */ |
| 589 | 589 | public function getConfigurationFileExt() |
| 590 | 590 | { |
| 591 | - if($this->_configFileExt === null) |
|
| 591 | + if($this->_configFileExt===null) |
|
| 592 | 592 | { |
| 593 | 593 | switch($this->_configType) |
| 594 | 594 | { |
| 595 | 595 | case TApplication::CONFIG_TYPE_PHP: |
| 596 | - $this->_configFileExt = TApplication::CONFIG_FILE_EXT_PHP; |
|
| 596 | + $this->_configFileExt=TApplication::CONFIG_FILE_EXT_PHP; |
|
| 597 | 597 | break; |
| 598 | 598 | default: |
| 599 | - $this->_configFileExt = TApplication::CONFIG_FILE_EXT_XML; |
|
| 599 | + $this->_configFileExt=TApplication::CONFIG_FILE_EXT_XML; |
|
| 600 | 600 | } |
| 601 | 601 | } |
| 602 | 602 | return $this->_configFileExt; |
@@ -608,15 +608,15 @@ discard block |
||
| 608 | 608 | public function getConfigurationFileName() |
| 609 | 609 | { |
| 610 | 610 | static $fileName; |
| 611 | - if($fileName == null) |
|
| 611 | + if($fileName==null) |
|
| 612 | 612 | { |
| 613 | 613 | switch($this->_configType) |
| 614 | 614 | { |
| 615 | 615 | case TApplication::CONFIG_TYPE_PHP: |
| 616 | - $fileName = TApplication::CONFIG_FILE_PHP; |
|
| 616 | + $fileName=TApplication::CONFIG_FILE_PHP; |
|
| 617 | 617 | break; |
| 618 | 618 | default: |
| 619 | - $fileName = TApplication::CONFIG_FILE_XML; |
|
| 619 | + $fileName=TApplication::CONFIG_FILE_XML; |
|
| 620 | 620 | } |
| 621 | 621 | } |
| 622 | 622 | return $fileName; |
@@ -635,11 +635,11 @@ discard block |
||
| 635 | 635 | */ |
| 636 | 636 | public function setRuntimePath($value) |
| 637 | 637 | { |
| 638 | - $this->_runtimePath = $value; |
|
| 638 | + $this->_runtimePath=$value; |
|
| 639 | 639 | if($this->_cacheFile) |
| 640 | - $this->_cacheFile = $this->_runtimePath . DIRECTORY_SEPARATOR . self::CONFIGCACHE_FILE; |
|
| 640 | + $this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE; |
|
| 641 | 641 | // generates unique ID by hashing the runtime path |
| 642 | - $this->_uniqueID = md5($this->_runtimePath); |
|
| 642 | + $this->_uniqueID=md5($this->_runtimePath); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | /** |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | */ |
| 656 | 656 | public function setService($value) |
| 657 | 657 | { |
| 658 | - $this->_service = $value; |
|
| 658 | + $this->_service=$value; |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | /** |
@@ -664,12 +664,12 @@ discard block |
||
| 664 | 664 | * @param string ID of the module |
| 665 | 665 | * @param IModule module object or null if the module has not been loaded yet |
| 666 | 666 | */ |
| 667 | - public function setModule($id, IModule $module = null) |
|
| 667 | + public function setModule($id, IModule $module=null) |
|
| 668 | 668 | { |
| 669 | 669 | if(isset($this->_modules[$id])) |
| 670 | 670 | throw new TConfigurationException('application_moduleid_duplicated', $id); |
| 671 | 671 | else |
| 672 | - $this->_modules[$id] = $module; |
|
| 672 | + $this->_modules[$id]=$module; |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | /** |
@@ -681,9 +681,9 @@ discard block |
||
| 681 | 681 | return null; |
| 682 | 682 | |
| 683 | 683 | // force loading of a lazy module |
| 684 | - if($this->_modules[$id] === null) |
|
| 684 | + if($this->_modules[$id]===null) |
|
| 685 | 685 | { |
| 686 | - $module = $this->internalLoadModule($id, true); |
|
| 686 | + $module=$this->internalLoadModule($id, true); |
|
| 687 | 687 | $module[0]->init($module[1]); |
| 688 | 688 | } |
| 689 | 689 | |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | { |
| 719 | 719 | if(!$this->_request) |
| 720 | 720 | { |
| 721 | - $this->_request = new \Prado\Web\THttpRequest; |
|
| 721 | + $this->_request=new \Prado\Web\THttpRequest; |
|
| 722 | 722 | $this->_request->init(null); |
| 723 | 723 | } |
| 724 | 724 | return $this->_request; |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | */ |
| 730 | 730 | public function setRequest(THttpRequest $request) |
| 731 | 731 | { |
| 732 | - $this->_request = $request; |
|
| 732 | + $this->_request=$request; |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | /** |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | { |
| 740 | 740 | if(!$this->_response) |
| 741 | 741 | { |
| 742 | - $this->_response = new THttpResponse; |
|
| 742 | + $this->_response=new THttpResponse; |
|
| 743 | 743 | $this->_response->init(null); |
| 744 | 744 | } |
| 745 | 745 | return $this->_response; |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | */ |
| 751 | 751 | public function setResponse(THttpResponse $response) |
| 752 | 752 | { |
| 753 | - $this->_response = $response; |
|
| 753 | + $this->_response=$response; |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | /** |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | { |
| 761 | 761 | if(!$this->_session) |
| 762 | 762 | { |
| 763 | - $this->_session = new THttpSession; |
|
| 763 | + $this->_session=new THttpSession; |
|
| 764 | 764 | $this->_session->init(null); |
| 765 | 765 | } |
| 766 | 766 | return $this->_session; |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | */ |
| 772 | 772 | public function setSession(THttpSession $session) |
| 773 | 773 | { |
| 774 | - $this->_session = $session; |
|
| 774 | + $this->_session=$session; |
|
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | /** |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | { |
| 782 | 782 | if(!$this->_errorHandler) |
| 783 | 783 | { |
| 784 | - $this->_errorHandler = new TErrorHandler; |
|
| 784 | + $this->_errorHandler=new TErrorHandler; |
|
| 785 | 785 | $this->_errorHandler->init(null); |
| 786 | 786 | } |
| 787 | 787 | return $this->_errorHandler; |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | */ |
| 793 | 793 | public function setErrorHandler(TErrorHandler $handler) |
| 794 | 794 | { |
| 795 | - $this->_errorHandler = $handler; |
|
| 795 | + $this->_errorHandler=$handler; |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | /** |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | { |
| 803 | 803 | if(!$this->_security) |
| 804 | 804 | { |
| 805 | - $this->_security = new TSecurityManager; |
|
| 805 | + $this->_security=new TSecurityManager; |
|
| 806 | 806 | $this->_security->init(null); |
| 807 | 807 | } |
| 808 | 808 | return $this->_security; |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | */ |
| 814 | 814 | public function setSecurityManager(TSecurityManager $sm) |
| 815 | 815 | { |
| 816 | - $this->_security = $sm; |
|
| 816 | + $this->_security=$sm; |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | /** |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | { |
| 824 | 824 | if(!$this->_assetManager) |
| 825 | 825 | { |
| 826 | - $this->_assetManager = new TAssetManager; |
|
| 826 | + $this->_assetManager=new TAssetManager; |
|
| 827 | 827 | $this->_assetManager->init(null); |
| 828 | 828 | } |
| 829 | 829 | return $this->_assetManager; |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | */ |
| 835 | 835 | public function setAssetManager(TAssetManager $value) |
| 836 | 836 | { |
| 837 | - $this->_assetManager = $value; |
|
| 837 | + $this->_assetManager=$value; |
|
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | /** |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | { |
| 845 | 845 | if(!$this->_statePersister) |
| 846 | 846 | { |
| 847 | - $this->_statePersister = new TApplicationStatePersister; |
|
| 847 | + $this->_statePersister=new TApplicationStatePersister; |
|
| 848 | 848 | $this->_statePersister->init(null); |
| 849 | 849 | } |
| 850 | 850 | return $this->_statePersister; |
@@ -855,7 +855,7 @@ discard block |
||
| 855 | 855 | */ |
| 856 | 856 | public function setApplicationStatePersister(IStatePersister $persister) |
| 857 | 857 | { |
| 858 | - $this->_statePersister = $persister; |
|
| 858 | + $this->_statePersister=$persister; |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | /** |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | */ |
| 872 | 872 | public function setCache(\Prado\Caching\ICache $cache) |
| 873 | 873 | { |
| 874 | - $this->_cache = $cache; |
|
| 874 | + $this->_cache=$cache; |
|
| 875 | 875 | } |
| 876 | 876 | |
| 877 | 877 | /** |
@@ -887,18 +887,18 @@ discard block |
||
| 887 | 887 | */ |
| 888 | 888 | public function setUser(\Prado\Security\IUser $user) |
| 889 | 889 | { |
| 890 | - $this->_user = $user; |
|
| 890 | + $this->_user=$user; |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | /** |
| 894 | 894 | * @param boolean whether to create globalization if it does not exist |
| 895 | 895 | * @return TGlobalization globalization module |
| 896 | 896 | */ |
| 897 | - public function getGlobalization($createIfNotExists = true) |
|
| 897 | + public function getGlobalization($createIfNotExists=true) |
|
| 898 | 898 | { |
| 899 | - if($this->_globalization === null && $createIfNotExists) |
|
| 899 | + if($this->_globalization===null && $createIfNotExists) |
|
| 900 | 900 | { |
| 901 | - $this->_globalization = new TGlobalization; |
|
| 901 | + $this->_globalization=new TGlobalization; |
|
| 902 | 902 | $this->_globalization->init(null); |
| 903 | 903 | } |
| 904 | 904 | return $this->_globalization; |
@@ -909,7 +909,7 @@ discard block |
||
| 909 | 909 | */ |
| 910 | 910 | public function setGlobalization(\Prado\I18N\TGlobalization $glob) |
| 911 | 911 | { |
| 912 | - $this->_globalization = $glob; |
|
| 912 | + $this->_globalization=$glob; |
|
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | /** |
@@ -917,8 +917,8 @@ discard block |
||
| 917 | 917 | */ |
| 918 | 918 | public function getAuthorizationRules() |
| 919 | 919 | { |
| 920 | - if($this->_authRules === null) |
|
| 921 | - $this->_authRules = new \Prado\Security\TAuthorizationRuleCollection; |
|
| 920 | + if($this->_authRules===null) |
|
| 921 | + $this->_authRules=new \Prado\Security\TAuthorizationRuleCollection; |
|
| 922 | 922 | return $this->_authRules; |
| 923 | 923 | } |
| 924 | 924 | |
@@ -927,9 +927,9 @@ discard block |
||
| 927 | 927 | return '\Prado\TApplicationConfiguration'; |
| 928 | 928 | } |
| 929 | 929 | |
| 930 | - protected function internalLoadModule($id, $force = false) |
|
| 930 | + protected function internalLoadModule($id, $force=false) |
|
| 931 | 931 | { |
| 932 | - list($moduleClass, $initProperties, $configElement) = $this->_lazyModules[$id]; |
|
| 932 | + list($moduleClass, $initProperties, $configElement)=$this->_lazyModules[$id]; |
|
| 933 | 933 | if(isset($initProperties['lazy']) && $initProperties['lazy'] && !$force) |
| 934 | 934 | { |
| 935 | 935 | Prado::trace("Postponed loading of lazy module $id ({$moduleClass})", '\Prado\TApplication'); |
@@ -938,24 +938,24 @@ discard block |
||
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | Prado::trace("Loading module $id ({$moduleClass})", '\Prado\TApplication'); |
| 941 | - $module = Prado::createComponent($moduleClass); |
|
| 941 | + $module=Prado::createComponent($moduleClass); |
|
| 942 | 942 | foreach($initProperties as $name => $value) |
| 943 | 943 | { |
| 944 | - if($name === 'lazy') continue; |
|
| 944 | + if($name==='lazy') continue; |
|
| 945 | 945 | $module->setSubProperty($name, $value); |
| 946 | 946 | } |
| 947 | 947 | $this->setModule($id, $module); |
| 948 | 948 | // keep the key to avoid reuse of the old module id |
| 949 | - $this->_lazyModules[$id] = null; |
|
| 949 | + $this->_lazyModules[$id]=null; |
|
| 950 | 950 | |
| 951 | - return [$module,$configElement]; |
|
| 951 | + return [$module, $configElement]; |
|
| 952 | 952 | } |
| 953 | 953 | /** |
| 954 | 954 | * Applies an application configuration. |
| 955 | 955 | * @param TApplicationConfiguration the configuration |
| 956 | 956 | * @param boolean whether the configuration is specified within a service. |
| 957 | 957 | */ |
| 958 | - public function applyConfiguration($config, $withinService = false) |
|
| 958 | + public function applyConfiguration($config, $withinService=false) |
|
| 959 | 959 | { |
| 960 | 960 | if($config->getIsEmpty()) |
| 961 | 961 | return; |
@@ -974,14 +974,14 @@ discard block |
||
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | if(empty($this->_services)) |
| 977 | - $this->_services = [$this->getPageServiceID() => ['Prado\Web\Services\TPageService',[],null]]; |
|
| 977 | + $this->_services=[$this->getPageServiceID() => ['Prado\Web\Services\TPageService', [], null]]; |
|
| 978 | 978 | |
| 979 | 979 | // load parameters |
| 980 | 980 | foreach($config->getParameters() as $id => $parameter) |
| 981 | 981 | { |
| 982 | 982 | if(is_array($parameter)) |
| 983 | 983 | { |
| 984 | - $component = Prado::createComponent($parameter[0]); |
|
| 984 | + $component=Prado::createComponent($parameter[0]); |
|
| 985 | 985 | foreach($parameter[1] as $name => $value) |
| 986 | 986 | $component->setSubProperty($name, $value); |
| 987 | 987 | $this->_parameters->add($id, $component); |
@@ -991,33 +991,33 @@ discard block |
||
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | // load and init modules specified in app config |
| 994 | - $modules = []; |
|
| 994 | + $modules=[]; |
|
| 995 | 995 | foreach($config->getModules() as $id => $moduleConfig) |
| 996 | 996 | { |
| 997 | 997 | if(!is_string($id)) |
| 998 | - $id = '_module' . count($this->_lazyModules); |
|
| 999 | - $this->_lazyModules[$id] = $moduleConfig; |
|
| 1000 | - if($module = $this->internalLoadModule($id)) |
|
| 1001 | - $modules[] = $module; |
|
| 998 | + $id='_module'.count($this->_lazyModules); |
|
| 999 | + $this->_lazyModules[$id]=$moduleConfig; |
|
| 1000 | + if($module=$this->internalLoadModule($id)) |
|
| 1001 | + $modules[]=$module; |
|
| 1002 | 1002 | } |
| 1003 | 1003 | foreach($modules as $module) |
| 1004 | 1004 | $module[0]->init($module[1]); |
| 1005 | 1005 | |
| 1006 | 1006 | // load service |
| 1007 | 1007 | foreach($config->getServices() as $serviceID => $serviceConfig) |
| 1008 | - $this->_services[$serviceID] = $serviceConfig; |
|
| 1008 | + $this->_services[$serviceID]=$serviceConfig; |
|
| 1009 | 1009 | |
| 1010 | 1010 | // external configurations |
| 1011 | 1011 | foreach($config->getExternalConfigurations() as $filePath => $condition) |
| 1012 | 1012 | { |
| 1013 | - if($condition !== true) |
|
| 1014 | - $condition = $this->evaluateExpression($condition); |
|
| 1013 | + if($condition!==true) |
|
| 1014 | + $condition=$this->evaluateExpression($condition); |
|
| 1015 | 1015 | if($condition) |
| 1016 | 1016 | { |
| 1017 | - if(($path = Prado::getPathOfNamespace($filePath, $this->getConfigurationFileExt())) === null || !is_file($path)) |
|
| 1017 | + if(($path=Prado::getPathOfNamespace($filePath, $this->getConfigurationFileExt()))===null || !is_file($path)) |
|
| 1018 | 1018 | throw new TConfigurationException('application_includefile_invalid', $filePath); |
| 1019 | - $cn = $this->getApplicationConfigurationClass(); |
|
| 1020 | - $c = new $cn; |
|
| 1019 | + $cn=$this->getApplicationConfigurationClass(); |
|
| 1020 | + $c=new $cn; |
|
| 1021 | 1021 | $c->loadFromFile($path); |
| 1022 | 1022 | $this->applyConfiguration($c, $withinService); |
| 1023 | 1023 | } |
@@ -1037,23 +1037,23 @@ discard block |
||
| 1037 | 1037 | { |
| 1038 | 1038 | Prado::trace('Initializing application', 'Prado\TApplication'); |
| 1039 | 1039 | |
| 1040 | - if($this->_configFile !== null) |
|
| 1040 | + if($this->_configFile!==null) |
|
| 1041 | 1041 | { |
| 1042 | - if($this->_cacheFile === null || @filemtime($this->_cacheFile) < filemtime($this->_configFile)) |
|
| 1042 | + if($this->_cacheFile===null || @filemtime($this->_cacheFile) < filemtime($this->_configFile)) |
|
| 1043 | 1043 | { |
| 1044 | - $config = new TApplicationConfiguration; |
|
| 1044 | + $config=new TApplicationConfiguration; |
|
| 1045 | 1045 | $config->loadFromFile($this->_configFile); |
| 1046 | - if($this->_cacheFile !== null) |
|
| 1046 | + if($this->_cacheFile!==null) |
|
| 1047 | 1047 | file_put_contents($this->_cacheFile, serialize($config), LOCK_EX); |
| 1048 | 1048 | } |
| 1049 | 1049 | else |
| 1050 | - $config = unserialize(file_get_contents($this->_cacheFile)); |
|
| 1050 | + $config=unserialize(file_get_contents($this->_cacheFile)); |
|
| 1051 | 1051 | |
| 1052 | 1052 | $this->applyConfiguration($config, false); |
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | - if(($serviceID = $this->getRequest()->resolveRequest(array_keys($this->_services))) === null) |
|
| 1056 | - $serviceID = $this->getPageServiceID(); |
|
| 1055 | + if(($serviceID=$this->getRequest()->resolveRequest(array_keys($this->_services)))===null) |
|
| 1056 | + $serviceID=$this->getPageServiceID(); |
|
| 1057 | 1057 | |
| 1058 | 1058 | $this->startService($serviceID); |
| 1059 | 1059 | } |
@@ -1068,8 +1068,8 @@ discard block |
||
| 1068 | 1068 | { |
| 1069 | 1069 | if(isset($this->_services[$serviceID])) |
| 1070 | 1070 | { |
| 1071 | - list($serviceClass, $initProperties, $configElement) = $this->_services[$serviceID]; |
|
| 1072 | - $service = Prado::createComponent($serviceClass); |
|
| 1071 | + list($serviceClass, $initProperties, $configElement)=$this->_services[$serviceID]; |
|
| 1072 | + $service=Prado::createComponent($serviceClass); |
|
| 1073 | 1073 | if(!($service instanceof IService)) |
| 1074 | 1074 | throw new THttpException(500, 'application_service_invalid', $serviceClass); |
| 1075 | 1075 | if(!$service->getEnabled()) |
@@ -1080,10 +1080,10 @@ discard block |
||
| 1080 | 1080 | foreach($initProperties as $name => $value) |
| 1081 | 1081 | $service->setSubProperty($name, $value); |
| 1082 | 1082 | |
| 1083 | - if($configElement !== null) |
|
| 1083 | + if($configElement!==null) |
|
| 1084 | 1084 | { |
| 1085 | - $config = new TApplicationConfiguration; |
|
| 1086 | - if($this->getConfigurationType() == self::CONFIG_TYPE_PHP) |
|
| 1085 | + $config=new TApplicationConfiguration; |
|
| 1086 | + if($this->getConfigurationType()==self::CONFIG_TYPE_PHP) |
|
| 1087 | 1087 | $config->loadFromPhp($configElement, $this->getBasePath()); |
| 1088 | 1088 | else |
| 1089 | 1089 | $config->loadFromXml($configElement, $this->getBasePath()); |
@@ -1226,7 +1226,7 @@ discard block |
||
| 1226 | 1226 | * Flushes output to client side. |
| 1227 | 1227 | * @param boolean whether to continue buffering after flush if buffering was active |
| 1228 | 1228 | */ |
| 1229 | - public function flushOutput($continueBuffering = true) |
|
| 1229 | + public function flushOutput($continueBuffering=true) |
|
| 1230 | 1230 | { |
| 1231 | 1231 | $this->getResponse()->flush($continueBuffering); |
| 1232 | 1232 | } |
@@ -1238,7 +1238,7 @@ discard block |
||
| 1238 | 1238 | public function onEndRequest() |
| 1239 | 1239 | { |
| 1240 | 1240 | $this->flushOutput(false); // flush all remaining content in the buffer |
| 1241 | - $this->saveGlobals(); // save global state |
|
| 1241 | + $this->saveGlobals(); // save global state |
|
| 1242 | 1242 | $this->raiseEvent('OnEndRequest', $this, null); |
| 1243 | 1243 | } |
| 1244 | 1244 | } |
@@ -332,8 +332,7 @@ discard block |
||
| 332 | 332 | { |
| 333 | 333 | $configFile = $basePath; |
| 334 | 334 | $basePath = dirname($configFile); |
| 335 | - } |
|
| 336 | - else |
|
| 335 | + } else |
|
| 337 | 336 | $configFile = null; |
| 338 | 337 | |
| 339 | 338 | // determine runtime path |
@@ -353,8 +352,7 @@ discard block |
||
| 353 | 352 | } |
| 354 | 353 | $this->setBasePath($basePath); |
| 355 | 354 | $this->setRuntimePath($runtimePath); |
| 356 | - } |
|
| 357 | - else |
|
| 355 | + } else |
|
| 358 | 356 | throw new TConfigurationException('application_runtimepath_invalid', $runtimePath); |
| 359 | 357 | |
| 360 | 358 | } |
@@ -383,8 +381,7 @@ discard block |
||
| 383 | 381 | $this->$method(); |
| 384 | 382 | $this->_step++; |
| 385 | 383 | } |
| 386 | - } |
|
| 387 | - catch(\Exception $e) |
|
| 384 | + } catch(\Exception $e) |
|
| 388 | 385 | { |
| 389 | 386 | $this->onError($e); |
| 390 | 387 | } |
@@ -985,8 +982,7 @@ discard block |
||
| 985 | 982 | foreach($parameter[1] as $name => $value) |
| 986 | 983 | $component->setSubProperty($name, $value); |
| 987 | 984 | $this->_parameters->add($id, $component); |
| 988 | - } |
|
| 989 | - else |
|
| 985 | + } else |
|
| 990 | 986 | $this->_parameters->add($id, $parameter); |
| 991 | 987 | } |
| 992 | 988 | |
@@ -1045,8 +1041,7 @@ discard block |
||
| 1045 | 1041 | $config->loadFromFile($this->_configFile); |
| 1046 | 1042 | if($this->_cacheFile !== null) |
| 1047 | 1043 | file_put_contents($this->_cacheFile, serialize($config), LOCK_EX); |
| 1048 | - } |
|
| 1049 | - else |
|
| 1044 | + } else |
|
| 1050 | 1045 | $config = unserialize(file_get_contents($this->_cacheFile)); |
| 1051 | 1046 | |
| 1052 | 1047 | $this->applyConfiguration($config, false); |
@@ -1091,8 +1086,7 @@ discard block |
||
| 1091 | 1086 | } |
| 1092 | 1087 | |
| 1093 | 1088 | $service->init($configElement); |
| 1094 | - } |
|
| 1095 | - else |
|
| 1089 | + } else |
|
| 1096 | 1090 | throw new THttpException(500, 'application_service_unknown', $serviceID); |
| 1097 | 1091 | } |
| 1098 | 1092 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | - * @return THttpRequest the current user request |
|
| 54 | + * @return Web\THttpRequest the current user request |
|
| 55 | 55 | */ |
| 56 | 56 | public function getRequest() |
| 57 | 57 | { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | - * @return THttpResponse the response |
|
| 62 | + * @return Web\THttpResponse the response |
|
| 63 | 63 | */ |
| 64 | 64 | public function getResponse() |
| 65 | 65 | { |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | - * @return THttpSession user session |
|
| 70 | + * @return Web\THttpSession user session |
|
| 71 | 71 | */ |
| 72 | 72 | public function getSession() |
| 73 | 73 | { |
@@ -94,6 +94,7 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @param string path of the asset that is relative to the directory containing the specified class file. |
| 96 | 96 | * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this). |
| 97 | + * @param string $assetPath |
|
| 97 | 98 | * @return string URL to the asset path. |
| 98 | 99 | */ |
| 99 | 100 | public function publishAsset($assetPath, $className = null) |
@@ -108,6 +109,7 @@ discard block |
||
| 108 | 109 | /** |
| 109 | 110 | * Publishes a file or directory and returns its URL. |
| 110 | 111 | * @param string absolute path of the file or directory to be published |
| 112 | + * @param string $fullPath |
|
| 111 | 113 | * @return string URL to the published file or directory |
| 112 | 114 | */ |
| 113 | 115 | public function publishFilePath($fullPath, $checkTimestamp = false) |
@@ -96,12 +96,12 @@ discard block |
||
| 96 | 96 | * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this). |
| 97 | 97 | * @return string URL to the asset path. |
| 98 | 98 | */ |
| 99 | - public function publishAsset($assetPath, $className = null) |
|
| 99 | + public function publishAsset($assetPath, $className=null) |
|
| 100 | 100 | { |
| 101 | - if($className === null) |
|
| 102 | - $className = get_class($this); |
|
| 103 | - $class = new \ReflectionClass($className); |
|
| 104 | - $fullPath = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $assetPath; |
|
| 101 | + if($className===null) |
|
| 102 | + $className=get_class($this); |
|
| 103 | + $class=new \ReflectionClass($className); |
|
| 104 | + $fullPath=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$assetPath; |
|
| 105 | 105 | return $this->publishFilePath($fullPath); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param string absolute path of the file or directory to be published |
| 111 | 111 | * @return string URL to the published file or directory |
| 112 | 112 | */ |
| 113 | - public function publishFilePath($fullPath, $checkTimestamp = false) |
|
| 113 | + public function publishFilePath($fullPath, $checkTimestamp=false) |
|
| 114 | 114 | { |
| 115 | 115 | return Prado::getApplication()->getAssetManager()->publishFilePath($fullPath, $checkTimestamp); |
| 116 | 116 | } |
@@ -56,6 +56,9 @@ discard block |
||
| 56 | 56 | $this->reflect(); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | + /** |
|
| 60 | + * @param \ReflectionMethod $method |
|
| 61 | + */ |
|
| 59 | 62 | private function isPropertyMethod($method) |
| 60 | 63 | { |
| 61 | 64 | $methodName = $method->getName(); |
@@ -64,6 +67,9 @@ discard block |
||
| 64 | 67 | && isset($methodName[3]); |
| 65 | 68 | } |
| 66 | 69 | |
| 70 | + /** |
|
| 71 | + * @param \ReflectionMethod $method |
|
| 72 | + */ |
|
| 67 | 73 | private function isEventMethod($method) |
| 68 | 74 | { |
| 69 | 75 | $methodName = $method->getName(); |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | class TComponentReflection extends \Prado\TComponent |
| 37 | 37 | { |
| 38 | 38 | private $_className; |
| 39 | - private $_properties = []; |
|
| 40 | - private $_events = []; |
|
| 41 | - private $_methods = []; |
|
| 39 | + private $_properties=[]; |
|
| 40 | + private $_events=[]; |
|
| 41 | + private $_methods=[]; |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * Constructor. |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | public function __construct($component) |
| 49 | 49 | { |
| 50 | 50 | if(is_string($component) && class_exists($component, false)) |
| 51 | - $this->_className = $component; |
|
| 51 | + $this->_className=$component; |
|
| 52 | 52 | elseif(is_object($component)) |
| 53 | - $this->_className = get_class($component); |
|
| 53 | + $this->_className=get_class($component); |
|
| 54 | 54 | else |
| 55 | 55 | throw new TInvalidDataTypeException('componentreflection_class_invalid'); |
| 56 | 56 | $this->reflect(); |
@@ -58,74 +58,74 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | private function isPropertyMethod($method) |
| 60 | 60 | { |
| 61 | - $methodName = $method->getName(); |
|
| 62 | - return $method->getNumberOfRequiredParameters() === 0 |
|
| 63 | - && strncasecmp($methodName, 'get', 3) === 0 |
|
| 61 | + $methodName=$method->getName(); |
|
| 62 | + return $method->getNumberOfRequiredParameters()===0 |
|
| 63 | + && strncasecmp($methodName, 'get', 3)===0 |
|
| 64 | 64 | && isset($methodName[3]); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | private function isEventMethod($method) |
| 68 | 68 | { |
| 69 | - $methodName = $method->getName(); |
|
| 70 | - return strncasecmp($methodName, 'on', 2) === 0 |
|
| 69 | + $methodName=$method->getName(); |
|
| 70 | + return strncasecmp($methodName, 'on', 2)===0 |
|
| 71 | 71 | && isset($methodName[2]); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | private function reflect() |
| 75 | 75 | { |
| 76 | - $class = new \ReflectionClass($this->_className); |
|
| 77 | - $properties = []; |
|
| 78 | - $events = []; |
|
| 79 | - $methods = []; |
|
| 80 | - $isComponent = is_subclass_of($this->_className, 'TComponent') || strcasecmp($this->_className, 'TComponent') === 0; |
|
| 76 | + $class=new \ReflectionClass($this->_className); |
|
| 77 | + $properties=[]; |
|
| 78 | + $events=[]; |
|
| 79 | + $methods=[]; |
|
| 80 | + $isComponent=is_subclass_of($this->_className, 'TComponent') || strcasecmp($this->_className, 'TComponent')===0; |
|
| 81 | 81 | foreach($class->getMethods() as $method) |
| 82 | 82 | { |
| 83 | 83 | if($method->isPublic() || $method->isProtected()) |
| 84 | 84 | { |
| 85 | - $methodName = $method->getName(); |
|
| 85 | + $methodName=$method->getName(); |
|
| 86 | 86 | if(!$method->isStatic() && $isComponent) |
| 87 | 87 | { |
| 88 | 88 | if($this->isPropertyMethod($method)) |
| 89 | - $properties[substr($methodName, 3)] = $method; |
|
| 89 | + $properties[substr($methodName, 3)]=$method; |
|
| 90 | 90 | elseif($this->isEventMethod($method)) |
| 91 | 91 | { |
| 92 | - $methodName[0] = 'O'; |
|
| 93 | - $events[$methodName] = $method; |
|
| 92 | + $methodName[0]='O'; |
|
| 93 | + $events[$methodName]=$method; |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | - if(strncmp($methodName, '__', 2) !== 0) |
|
| 97 | - $methods[$methodName] = $method; |
|
| 96 | + if(strncmp($methodName, '__', 2)!==0) |
|
| 97 | + $methods[$methodName]=$method; |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | - $reserved = []; |
|
| 100 | + $reserved=[]; |
|
| 101 | 101 | ksort($properties); |
| 102 | 102 | foreach($properties as $name => $method) |
| 103 | 103 | { |
| 104 | - $this->_properties[$name] = [ |
|
| 104 | + $this->_properties[$name]=[ |
|
| 105 | 105 | 'type' => $this->determinePropertyType($method), |
| 106 | - 'readonly' => !$class->hasMethod('set' . $name), |
|
| 106 | + 'readonly' => !$class->hasMethod('set'.$name), |
|
| 107 | 107 | 'protected' => $method->isProtected(), |
| 108 | 108 | 'class' => $method->getDeclaringClass()->getName(), |
| 109 | 109 | 'comments' => $method->getDocComment() |
| 110 | 110 | ]; |
| 111 | - $reserved['get' . strtolower($name)] = 1; |
|
| 112 | - $reserved['set' . strtolower($name)] = 1; |
|
| 111 | + $reserved['get'.strtolower($name)]=1; |
|
| 112 | + $reserved['set'.strtolower($name)]=1; |
|
| 113 | 113 | } |
| 114 | 114 | ksort($events); |
| 115 | 115 | foreach($events as $name => $method) |
| 116 | 116 | { |
| 117 | - $this->_events[$name] = [ |
|
| 117 | + $this->_events[$name]=[ |
|
| 118 | 118 | 'class' => $method->getDeclaringClass()->getName(), |
| 119 | 119 | 'protected' => $method->isProtected(), |
| 120 | 120 | 'comments' => $method->getDocComment() |
| 121 | 121 | ]; |
| 122 | - $reserved[strtolower($name)] = 1; |
|
| 122 | + $reserved[strtolower($name)]=1; |
|
| 123 | 123 | } |
| 124 | 124 | ksort($methods); |
| 125 | 125 | foreach($methods as $name => $method) |
| 126 | 126 | { |
| 127 | 127 | if(!isset($reserved[strtolower($name)])) |
| 128 | - $this->_methods[$name] = [ |
|
| 128 | + $this->_methods[$name]=[ |
|
| 129 | 129 | 'class' => $method->getDeclaringClass()->getName(), |
| 130 | 130 | 'protected' => $method->isProtected(), |
| 131 | 131 | 'static' => $method->isStatic(), |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | protected function determinePropertyType($method) |
| 144 | 144 | { |
| 145 | - $comment = $method->getDocComment(); |
|
| 145 | + $comment=$method->getDocComment(); |
|
| 146 | 146 | if(preg_match('/@return\\s+(.*?)\\s+/', $comment, $matches)) |
| 147 | 147 | return $matches[1]; |
| 148 | 148 | else |
@@ -65,6 +65,7 @@ discard block |
||
| 65 | 65 | * Constructor, create a new date time formatter. |
| 66 | 66 | * @param string formatting pattern. |
| 67 | 67 | * @param string pattern and value charset |
| 68 | + * @param string $pattern |
|
| 68 | 69 | */ |
| 69 | 70 | public function __construct($pattern, $charset = 'UTF-8') |
| 70 | 71 | { |
@@ -98,6 +99,7 @@ discard block |
||
| 98 | 99 | |
| 99 | 100 | /** |
| 100 | 101 | * @param string formatting charset. |
| 102 | + * @param string $charset |
|
| 101 | 103 | */ |
| 102 | 104 | public function setCharset($charset) |
| 103 | 105 | { |
@@ -172,7 +174,7 @@ discard block |
||
| 172 | 174 | /** |
| 173 | 175 | * Gets the time stamp from string or integer. |
| 174 | 176 | * @param string|int date to parse |
| 175 | - * @return array date info array |
|
| 177 | + * @return \DateTime date info array |
|
| 176 | 178 | */ |
| 177 | 179 | private function getDate($value) |
| 178 | 180 | { |
@@ -324,6 +326,7 @@ discard block |
||
| 324 | 326 | |
| 325 | 327 | /** |
| 326 | 328 | * Calculate the length of a string, may be consider iconv_strlen? |
| 329 | + * @param string $string |
|
| 327 | 330 | */ |
| 328 | 331 | private function length($string) |
| 329 | 332 | { |
@@ -349,6 +352,9 @@ discard block |
||
| 349 | 352 | |
| 350 | 353 | /** |
| 351 | 354 | * Returns true if char at position equals a particular char. |
| 355 | + * @param string $string |
|
| 356 | + * @param integer $pos |
|
| 357 | + * @param string $char |
|
| 352 | 358 | */ |
| 353 | 359 | private function charEqual($string, $pos, $char) |
| 354 | 360 | { |
@@ -361,6 +367,10 @@ discard block |
||
| 361 | 367 | * @param int starting position |
| 362 | 368 | * @param int minimum integer length |
| 363 | 369 | * @param int maximum integer length |
| 370 | + * @param string $str |
|
| 371 | + * @param integer $i |
|
| 372 | + * @param integer|null $minlength |
|
| 373 | + * @param integer|null $maxlength |
|
| 364 | 374 | * @return string integer portion of the string, null otherwise |
| 365 | 375 | */ |
| 366 | 376 | private function getInteger($str, $i, $minlength, $maxlength) |
@@ -59,14 +59,14 @@ discard block |
||
| 59 | 59 | * Charset, default is 'UTF-8' |
| 60 | 60 | * @var string |
| 61 | 61 | */ |
| 62 | - private $charset = 'UTF-8'; |
|
| 62 | + private $charset='UTF-8'; |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * Constructor, create a new date time formatter. |
| 66 | 66 | * @param string formatting pattern. |
| 67 | 67 | * @param string pattern and value charset |
| 68 | 68 | */ |
| 69 | - public function __construct($pattern, $charset = 'UTF-8') |
|
| 69 | + public function __construct($pattern, $charset='UTF-8') |
|
| 70 | 70 | { |
| 71 | 71 | $this->setPattern($pattern); |
| 72 | 72 | $this->setCharset($charset); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function setPattern($pattern) |
| 87 | 87 | { |
| 88 | - $this->pattern = $pattern; |
|
| 88 | + $this->pattern=$pattern; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function setCharset($charset) |
| 103 | 103 | { |
| 104 | - $this->charset = $charset; |
|
| 104 | + $this->charset=$charset; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -111,17 +111,17 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function format($value) |
| 113 | 113 | { |
| 114 | - $dt = $this->getDate($value); |
|
| 115 | - $bits['yyyy'] = $dt->format('Y'); |
|
| 116 | - $bits['yy'] = $dt->format('y'); |
|
| 114 | + $dt=$this->getDate($value); |
|
| 115 | + $bits['yyyy']=$dt->format('Y'); |
|
| 116 | + $bits['yy']=$dt->format('y'); |
|
| 117 | 117 | |
| 118 | - $bits['MM'] = $dt->format('m'); |
|
| 119 | - $bits['M'] = $dt->format('n'); |
|
| 118 | + $bits['MM']=$dt->format('m'); |
|
| 119 | + $bits['M']=$dt->format('n'); |
|
| 120 | 120 | |
| 121 | - $bits['dd'] = $dt->format('d'); |
|
| 122 | - $bits['d'] = $dt->format('j'); |
|
| 121 | + $bits['dd']=$dt->format('d'); |
|
| 122 | + $bits['d']=$dt->format('j'); |
|
| 123 | 123 | |
| 124 | - $pattern = preg_replace('/M{3,4}/', 'MM', $this->pattern); |
|
| 124 | + $pattern=preg_replace('/M{3,4}/', 'MM', $this->pattern); |
|
| 125 | 125 | return str_replace(array_keys($bits), $bits, $pattern); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | public function getDayMonthYearOrdering() |
| 160 | 160 | { |
| 161 | - $ordering = []; |
|
| 162 | - if(is_int($day = strpos($this->pattern, 'd'))) |
|
| 163 | - $ordering['day'] = $day; |
|
| 164 | - if(is_int($month = strpos($this->pattern, 'M'))) |
|
| 165 | - $ordering['month'] = $month; |
|
| 166 | - if(is_int($year = strpos($this->pattern, 'yy'))) |
|
| 167 | - $ordering['year'] = $year; |
|
| 161 | + $ordering=[]; |
|
| 162 | + if(is_int($day=strpos($this->pattern, 'd'))) |
|
| 163 | + $ordering['day']=$day; |
|
| 164 | + if(is_int($month=strpos($this->pattern, 'M'))) |
|
| 165 | + $ordering['month']=$month; |
|
| 166 | + if(is_int($year=strpos($this->pattern, 'yy'))) |
|
| 167 | + $ordering['year']=$year; |
|
| 168 | 168 | asort($ordering); |
| 169 | 169 | return array_keys($ordering); |
| 170 | 170 | } |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | { |
| 179 | 179 | if(is_numeric($value)) |
| 180 | 180 | { |
| 181 | - $date = new \DateTime; |
|
| 181 | + $date=new \DateTime; |
|
| 182 | 182 | $date->setTimeStamp($value); |
| 183 | 183 | } else { |
| 184 | - $date = new \DateTime($value); |
|
| 184 | + $date=new \DateTime($value); |
|
| 185 | 185 | } |
| 186 | 186 | return $date; |
| 187 | 187 | } |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | public function isValidDate($value) |
| 193 | 193 | { |
| 194 | - if($value === null) { |
|
| 194 | + if($value===null) { |
|
| 195 | 195 | return false; |
| 196 | 196 | } else { |
| 197 | - return $this->parse($value, false) !== null; |
|
| 197 | + return $this->parse($value, false)!==null; |
|
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @return int date time stamp |
| 205 | 205 | * @throws TInvalidDataValueException if date string is malformed. |
| 206 | 206 | */ |
| 207 | - public function parse($value, $defaultToCurrentTime = true) |
|
| 207 | + public function parse($value, $defaultToCurrentTime=true) |
|
| 208 | 208 | { |
| 209 | 209 | if(is_int($value) || is_float($value)) |
| 210 | 210 | return $value; |
@@ -213,109 +213,109 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | if(empty($this->pattern)) return time(); |
| 215 | 215 | |
| 216 | - $date = time(); |
|
| 216 | + $date=time(); |
|
| 217 | 217 | |
| 218 | 218 | if($this->length(trim($value)) < 1) |
| 219 | 219 | return $defaultToCurrentTime ? $date : null; |
| 220 | 220 | |
| 221 | - $pattern = $this->pattern; |
|
| 221 | + $pattern=$this->pattern; |
|
| 222 | 222 | |
| 223 | - $i_val = 0; |
|
| 224 | - $i_format = 0; |
|
| 225 | - $pattern_length = $this->length($pattern); |
|
| 226 | - $c = ''; |
|
| 227 | - $token = ''; |
|
| 228 | - $x = null; $y = null; |
|
| 223 | + $i_val=0; |
|
| 224 | + $i_format=0; |
|
| 225 | + $pattern_length=$this->length($pattern); |
|
| 226 | + $c=''; |
|
| 227 | + $token=''; |
|
| 228 | + $x=null; $y=null; |
|
| 229 | 229 | |
| 230 | 230 | |
| 231 | 231 | if($defaultToCurrentTime) |
| 232 | 232 | { |
| 233 | - $year = "{$date['year']}"; |
|
| 234 | - $month = $date['mon']; |
|
| 235 | - $day = $date['mday']; |
|
| 233 | + $year="{$date['year']}"; |
|
| 234 | + $month=$date['mon']; |
|
| 235 | + $day=$date['mday']; |
|
| 236 | 236 | } |
| 237 | 237 | else |
| 238 | 238 | { |
| 239 | - $year = null; |
|
| 240 | - $month = null; |
|
| 241 | - $day = null; |
|
| 239 | + $year=null; |
|
| 240 | + $month=null; |
|
| 241 | + $day=null; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - while ($i_format < $pattern_length) |
|
| 244 | + while($i_format < $pattern_length) |
|
| 245 | 245 | { |
| 246 | - $c = $this->charAt($pattern, $i_format); |
|
| 247 | - $token = ''; |
|
| 248 | - while ($this->charEqual($pattern, $i_format, $c) |
|
| 246 | + $c=$this->charAt($pattern, $i_format); |
|
| 247 | + $token=''; |
|
| 248 | + while($this->charEqual($pattern, $i_format, $c) |
|
| 249 | 249 | && ($i_format < $pattern_length)) |
| 250 | 250 | { |
| 251 | - $token .= $this->charAt($pattern, $i_format++); |
|
| 251 | + $token.=$this->charAt($pattern, $i_format++); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if ($token == 'yyyy' || $token == 'yy' || $token == 'y') |
|
| 254 | + if($token=='yyyy' || $token=='yy' || $token=='y') |
|
| 255 | 255 | { |
| 256 | - if ($token == 'yyyy') { $x = 4;$y = 4; } |
|
| 257 | - if ($token == 'yy') { $x = 2;$y = 2; } |
|
| 258 | - if ($token == 'y') { $x = 2;$y = 4; } |
|
| 259 | - $year = $this->getInteger($value, $i_val, $x, $y); |
|
| 260 | - if($year === null) |
|
| 256 | + if($token=='yyyy') { $x=4; $y=4; } |
|
| 257 | + if($token=='yy') { $x=2; $y=2; } |
|
| 258 | + if($token=='y') { $x=2; $y=4; } |
|
| 259 | + $year=$this->getInteger($value, $i_val, $x, $y); |
|
| 260 | + if($year===null) |
|
| 261 | 261 | return null; |
| 262 | 262 | //throw new TInvalidDataValueException('Invalid year', $value); |
| 263 | - $i_val += strlen($year); |
|
| 264 | - if(strlen($year) == 2) |
|
| 263 | + $i_val+=strlen($year); |
|
| 264 | + if(strlen($year)==2) |
|
| 265 | 265 | { |
| 266 | - $iYear = (int)$year; |
|
| 266 | + $iYear=(int) $year; |
|
| 267 | 267 | if($iYear > 70) |
| 268 | - $year = $iYear + 1900; |
|
| 268 | + $year=$iYear + 1900; |
|
| 269 | 269 | else |
| 270 | - $year = $iYear + 2000; |
|
| 270 | + $year=$iYear + 2000; |
|
| 271 | 271 | } |
| 272 | - $year = (int)$year; |
|
| 272 | + $year=(int) $year; |
|
| 273 | 273 | } |
| 274 | - elseif($token == 'MM' || $token == 'M') |
|
| 274 | + elseif($token=='MM' || $token=='M') |
|
| 275 | 275 | { |
| 276 | - $month = $this->getInteger($value,$i_val, |
|
| 276 | + $month=$this->getInteger($value, $i_val, |
|
| 277 | 277 | $this->length($token), 2); |
| 278 | - $iMonth = (int)$month; |
|
| 279 | - if($month === null || $iMonth < 1 || $iMonth > 12) |
|
| 278 | + $iMonth=(int) $month; |
|
| 279 | + if($month===null || $iMonth < 1 || $iMonth > 12) |
|
| 280 | 280 | return null; |
| 281 | 281 | //throw new TInvalidDataValueException('Invalid month', $value); |
| 282 | - $i_val += strlen($month); |
|
| 283 | - $month = $iMonth; |
|
| 282 | + $i_val+=strlen($month); |
|
| 283 | + $month=$iMonth; |
|
| 284 | 284 | } |
| 285 | - elseif ($token == 'dd' || $token == 'd') |
|
| 285 | + elseif($token=='dd' || $token=='d') |
|
| 286 | 286 | { |
| 287 | - $day = $this->getInteger($value,$i_val, |
|
| 287 | + $day=$this->getInteger($value, $i_val, |
|
| 288 | 288 | $this->length($token), 2); |
| 289 | - $iDay = (int)$day; |
|
| 290 | - if($day === null || $iDay < 1 || $iDay > 31) |
|
| 289 | + $iDay=(int) $day; |
|
| 290 | + if($day===null || $iDay < 1 || $iDay > 31) |
|
| 291 | 291 | return null; |
| 292 | 292 | //throw new TInvalidDataValueException('Invalid day', $value); |
| 293 | - $i_val += strlen($day); |
|
| 294 | - $day = $iDay; |
|
| 293 | + $i_val+=strlen($day); |
|
| 294 | + $day=$iDay; |
|
| 295 | 295 | } |
| 296 | 296 | else |
| 297 | 297 | { |
| 298 | - if($this->substring($value, $i_val, $this->length($token)) != $token) |
|
| 298 | + if($this->substring($value, $i_val, $this->length($token))!=$token) |
|
| 299 | 299 | return null; |
| 300 | 300 | //throw new TInvalidDataValueException("Subpattern '{$this->pattern}' mismatch", $value); |
| 301 | 301 | else |
| 302 | - $i_val += $this->length($token); |
|
| 302 | + $i_val+=$this->length($token); |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | - if ($i_val != $this->length($value)) |
|
| 305 | + if($i_val!=$this->length($value)) |
|
| 306 | 306 | return null; |
| 307 | 307 | //throw new TInvalidDataValueException("Pattern '{$this->pattern}' mismatch", $value); |
| 308 | - if(!$defaultToCurrentTime && ($month === null || $day === null || $year === null)) |
|
| 308 | + if(!$defaultToCurrentTime && ($month===null || $day===null || $year===null)) |
|
| 309 | 309 | return null; |
| 310 | 310 | else |
| 311 | 311 | { |
| 312 | 312 | if(empty($year)) { |
| 313 | - $year = date('Y'); |
|
| 313 | + $year=date('Y'); |
|
| 314 | 314 | } |
| 315 | - $day = (int)$day <= 0 ? 1 : (int)$day; |
|
| 316 | - $month = (int)$month <= 0 ? 1 : (int)$month; |
|
| 315 | + $day=(int) $day <= 0 ? 1 : (int) $day; |
|
| 316 | + $month=(int) $month <= 0 ? 1 : (int) $month; |
|
| 317 | 317 | |
| 318 | - $s = new \DateTime; |
|
| 318 | + $s=new \DateTime; |
|
| 319 | 319 | $s->setDate($year, $month, $day); |
| 320 | 320 | $s->setTime(0, 0, 0); |
| 321 | 321 | return $s->getTimeStamp(); |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | */ |
| 353 | 353 | private function charEqual($string, $pos, $char) |
| 354 | 354 | { |
| 355 | - return $this->charAt($string, $pos) == $char; |
|
| 355 | + return $this->charAt($string, $pos)==$char; |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -366,12 +366,12 @@ discard block |
||
| 366 | 366 | private function getInteger($str, $i, $minlength, $maxlength) |
| 367 | 367 | { |
| 368 | 368 | //match for digits backwards |
| 369 | - for ($x = $maxlength; $x >= $minlength; $x--) |
|
| 369 | + for($x=$maxlength; $x >= $minlength; $x--) |
|
| 370 | 370 | { |
| 371 | - $token = $this->substring($str, $i, $x); |
|
| 372 | - if ($this->length($token) < $minlength) |
|
| 371 | + $token=$this->substring($str, $i, $x); |
|
| 372 | + if($this->length($token) < $minlength) |
|
| 373 | 373 | return null; |
| 374 | - if (preg_match('/^\d+$/', $token)) |
|
| 374 | + if(preg_match('/^\d+$/', $token)) |
|
| 375 | 375 | return $token; |
| 376 | 376 | } |
| 377 | 377 | return null; |
@@ -233,8 +233,7 @@ discard block |
||
| 233 | 233 | $year = "{$date['year']}"; |
| 234 | 234 | $month = $date['mon']; |
| 235 | 235 | $day = $date['mday']; |
| 236 | - } |
|
| 237 | - else |
|
| 236 | + } else |
|
| 238 | 237 | { |
| 239 | 238 | $year = null; |
| 240 | 239 | $month = null; |
@@ -270,8 +269,7 @@ discard block |
||
| 270 | 269 | $year = $iYear + 2000; |
| 271 | 270 | } |
| 272 | 271 | $year = (int)$year; |
| 273 | - } |
|
| 274 | - elseif($token == 'MM' || $token == 'M') |
|
| 272 | + } elseif($token == 'MM' || $token == 'M') |
|
| 275 | 273 | { |
| 276 | 274 | $month = $this->getInteger($value,$i_val, |
| 277 | 275 | $this->length($token), 2); |
@@ -281,8 +279,7 @@ discard block |
||
| 281 | 279 | //throw new TInvalidDataValueException('Invalid month', $value); |
| 282 | 280 | $i_val += strlen($month); |
| 283 | 281 | $month = $iMonth; |
| 284 | - } |
|
| 285 | - elseif ($token == 'dd' || $token == 'd') |
|
| 282 | + } elseif ($token == 'dd' || $token == 'd') |
|
| 286 | 283 | { |
| 287 | 284 | $day = $this->getInteger($value,$i_val, |
| 288 | 285 | $this->length($token), 2); |
@@ -292,8 +289,7 @@ discard block |
||
| 292 | 289 | //throw new TInvalidDataValueException('Invalid day', $value); |
| 293 | 290 | $i_val += strlen($day); |
| 294 | 291 | $day = $iDay; |
| 295 | - } |
|
| 296 | - else |
|
| 292 | + } else |
|
| 297 | 293 | { |
| 298 | 294 | if($this->substring($value, $i_val, $this->length($token)) != $token) |
| 299 | 295 | return null; |
@@ -170,6 +170,7 @@ discard block |
||
| 170 | 170 | * parameter initialization, module loadings, page initial properties |
| 171 | 171 | * and authorization rules. |
| 172 | 172 | * @param TPageConfiguration |
| 173 | + * @param TPageConfiguration $pageConfig |
|
| 173 | 174 | */ |
| 174 | 175 | protected function initPageContext($pageConfig) |
| 175 | 176 | { |
@@ -377,6 +378,7 @@ discard block |
||
| 377 | 378 | |
| 378 | 379 | /** |
| 379 | 380 | * @param string default page path to be served if no explicit page is request |
| 381 | + * @param string $value |
|
| 380 | 382 | * @throws TInvalidOperationException if the page service is initialized |
| 381 | 383 | */ |
| 382 | 384 | public function setDefaultPage($value) |
@@ -479,7 +481,8 @@ discard block |
||
| 479 | 481 | /** |
| 480 | 482 | * Creates a page instance based on requested page path. |
| 481 | 483 | * @param string requested page path |
| 482 | - * @return TPage the requested page instance |
|
| 484 | + * @param string $pagePath |
|
| 485 | + * @return \Prado\TComponent the requested page instance |
|
| 483 | 486 | * @throws THttpException if requested page path is invalid |
| 484 | 487 | * @throws TConfigurationException if the page class cannot be found |
| 485 | 488 | */ |
@@ -527,6 +530,7 @@ discard block |
||
| 527 | 530 | * Executes a page. |
| 528 | 531 | * @param TPage the page instance to be run |
| 529 | 532 | * @param array list of initial page properties |
| 533 | + * @param \Prado\TComponent $page |
|
| 530 | 534 | */ |
| 531 | 535 | protected function runPage($page, $properties) |
| 532 | 536 | { |
@@ -541,6 +545,7 @@ discard block |
||
| 541 | 545 | * @param array list of GET parameters, null if no GET parameters required |
| 542 | 546 | * @param boolean whether to encode the ampersand in URL, defaults to true. |
| 543 | 547 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
| 548 | + * @param string $pagePath |
|
| 544 | 549 | * @return string URL for the page and GET parameters |
| 545 | 550 | */ |
| 546 | 551 | public function constructUrl($pagePath, $getParams = null, $encodeAmpersand = true, $encodeGetItems = true) |
@@ -81,31 +81,31 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * Configuration file name |
| 83 | 83 | */ |
| 84 | - const CONFIG_FILE_XML = 'config.xml'; |
|
| 84 | + const CONFIG_FILE_XML='config.xml'; |
|
| 85 | 85 | /** |
| 86 | 86 | * Configuration file name |
| 87 | 87 | */ |
| 88 | - const CONFIG_FILE_PHP = 'config.php'; |
|
| 88 | + const CONFIG_FILE_PHP='config.php'; |
|
| 89 | 89 | /** |
| 90 | 90 | * Default base path |
| 91 | 91 | */ |
| 92 | - const DEFAULT_BASEPATH = 'Pages'; |
|
| 92 | + const DEFAULT_BASEPATH='Pages'; |
|
| 93 | 93 | /** |
| 94 | 94 | * Fallback base path - used to be the default up to Prado < 3.2 |
| 95 | 95 | */ |
| 96 | - const FALLBACK_BASEPATH = 'pages'; |
|
| 96 | + const FALLBACK_BASEPATH='pages'; |
|
| 97 | 97 | /** |
| 98 | 98 | * Prefix of ID used for storing parsed configuration in cache |
| 99 | 99 | */ |
| 100 | - const CONFIG_CACHE_PREFIX = 'prado:pageservice:'; |
|
| 100 | + const CONFIG_CACHE_PREFIX='prado:pageservice:'; |
|
| 101 | 101 | /** |
| 102 | 102 | * Page template file extension |
| 103 | 103 | */ |
| 104 | - const PAGE_FILE_EXT = '.page'; |
|
| 104 | + const PAGE_FILE_EXT='.page'; |
|
| 105 | 105 | /** |
| 106 | 106 | * Prefix of Pages used for instantiating new pages |
| 107 | 107 | */ |
| 108 | - const PAGE_NAMESPACE_PREFIX = 'Application\\Pages\\'; |
|
| 108 | + const PAGE_NAMESPACE_PREFIX='Application\\Pages\\'; |
|
| 109 | 109 | /** |
| 110 | 110 | * @var string root path of pages |
| 111 | 111 | */ |
@@ -113,16 +113,16 @@ discard block |
||
| 113 | 113 | /** |
| 114 | 114 | * @var string base path class in namespace format |
| 115 | 115 | */ |
| 116 | - private $_basePageClass = '\Prado\Web\UI\TPage'; |
|
| 116 | + private $_basePageClass='\Prado\Web\UI\TPage'; |
|
| 117 | 117 | /** |
| 118 | 118 | * @var string clientscript manager class in namespace format |
| 119 | 119 | * @since 3.1.7 |
| 120 | 120 | */ |
| 121 | - private $_clientScriptManagerClass = '\Prado\Web\UI\TClientScriptManager'; |
|
| 121 | + private $_clientScriptManagerClass='\Prado\Web\UI\TClientScriptManager'; |
|
| 122 | 122 | /** |
| 123 | 123 | * @var string default page |
| 124 | 124 | */ |
| 125 | - private $_defaultPage = 'Home'; |
|
| 125 | + private $_defaultPage='Home'; |
|
| 126 | 126 | /** |
| 127 | 127 | * @var string requested page (path) |
| 128 | 128 | */ |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | /** |
| 135 | 135 | * @var array list of initial page property values |
| 136 | 136 | */ |
| 137 | - private $_properties = []; |
|
| 137 | + private $_properties=[]; |
|
| 138 | 138 | /** |
| 139 | 139 | * @var boolean whether service is initialized |
| 140 | 140 | */ |
| 141 | - private $_initialized = false; |
|
| 141 | + private $_initialized=false; |
|
| 142 | 142 | /** |
| 143 | 143 | * @var TThemeManager theme manager |
| 144 | 144 | */ |
@@ -157,11 +157,11 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | Prado::trace("Initializing TPageService", '\Prado\Web\Services\TPageService'); |
| 159 | 159 | |
| 160 | - $pageConfig = $this->loadPageConfig($config); |
|
| 160 | + $pageConfig=$this->loadPageConfig($config); |
|
| 161 | 161 | |
| 162 | 162 | $this->initPageContext($pageConfig); |
| 163 | 163 | |
| 164 | - $this->_initialized = true; |
|
| 164 | + $this->_initialized=true; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | protected function initPageContext($pageConfig) |
| 175 | 175 | { |
| 176 | - $application = $this->getApplication(); |
|
| 176 | + $application=$this->getApplication(); |
|
| 177 | 177 | foreach($pageConfig->getApplicationConfigurations() as $appConfig) |
| 178 | 178 | $application->applyConfiguration($appConfig); |
| 179 | 179 | |
@@ -187,20 +187,20 @@ discard block |
||
| 187 | 187 | protected function applyConfiguration($config) |
| 188 | 188 | { |
| 189 | 189 | // initial page properties (to be set when page runs) |
| 190 | - $this->_properties = array_merge($this->_properties, $config->getProperties()); |
|
| 190 | + $this->_properties=array_merge($this->_properties, $config->getProperties()); |
|
| 191 | 191 | $this->getApplication()->getAuthorizationRules()->mergeWith($config->getRules()); |
| 192 | - $pagePath = $this->getRequestedPagePath(); |
|
| 192 | + $pagePath=$this->getRequestedPagePath(); |
|
| 193 | 193 | // external configurations |
| 194 | 194 | foreach($config->getExternalConfigurations() as $filePath => $params) |
| 195 | 195 | { |
| 196 | - list($configPagePath, $condition) = $params; |
|
| 197 | - if($condition !== true) |
|
| 198 | - $condition = $this->evaluateExpression($condition); |
|
| 196 | + list($configPagePath, $condition)=$params; |
|
| 197 | + if($condition!==true) |
|
| 198 | + $condition=$this->evaluateExpression($condition); |
|
| 199 | 199 | if($condition) |
| 200 | 200 | { |
| 201 | - if(($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path)) |
|
| 201 | + if(($path=Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
| 202 | 202 | throw new TConfigurationException('pageservice_includefile_invalid', $filePath); |
| 203 | - $c = new TPageConfiguration($pagePath); |
|
| 203 | + $c=new TPageConfiguration($pagePath); |
|
| 204 | 204 | $c->loadFromFile($path, $configPagePath); |
| 205 | 205 | $this->applyConfiguration($c); |
| 206 | 206 | } |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | protected function determineRequestedPagePath() |
| 216 | 216 | { |
| 217 | - $pagePath = $this->getRequest()->getServiceParameter(); |
|
| 217 | + $pagePath=$this->getRequest()->getServiceParameter(); |
|
| 218 | 218 | if(empty($pagePath)) |
| 219 | - $pagePath = $this->getDefaultPage(); |
|
| 219 | + $pagePath=$this->getDefaultPage(); |
|
| 220 | 220 | return $pagePath; |
| 221 | 221 | } |
| 222 | 222 | |
@@ -227,14 +227,14 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | protected function loadPageConfig($config) |
| 229 | 229 | { |
| 230 | - $application = $this->getApplication(); |
|
| 231 | - $pagePath = $this->getRequestedPagePath(); |
|
| 232 | - if(($cache = $application->getCache()) === null) |
|
| 230 | + $application=$this->getApplication(); |
|
| 231 | + $pagePath=$this->getRequestedPagePath(); |
|
| 232 | + if(($cache=$application->getCache())===null) |
|
| 233 | 233 | { |
| 234 | - $pageConfig = new TPageConfiguration($pagePath); |
|
| 235 | - if($config !== null) |
|
| 234 | + $pageConfig=new TPageConfiguration($pagePath); |
|
| 235 | + if($config!==null) |
|
| 236 | 236 | { |
| 237 | - if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 237 | + if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 238 | 238 | $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
| 239 | 239 | else |
| 240 | 240 | $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
@@ -243,61 +243,61 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | else |
| 245 | 245 | { |
| 246 | - $configCached = true; |
|
| 247 | - $currentTimestamp = []; |
|
| 248 | - $arr = $cache->get(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath); |
|
| 246 | + $configCached=true; |
|
| 247 | + $currentTimestamp=[]; |
|
| 248 | + $arr=$cache->get(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath); |
|
| 249 | 249 | if(is_array($arr)) |
| 250 | 250 | { |
| 251 | - list($pageConfig, $timestamps) = $arr; |
|
| 252 | - if($application->getMode() !== TApplicationMode::Performance) |
|
| 251 | + list($pageConfig, $timestamps)=$arr; |
|
| 252 | + if($application->getMode()!==TApplicationMode::Performance) |
|
| 253 | 253 | { |
| 254 | 254 | foreach($timestamps as $fileName => $timestamp) |
| 255 | 255 | { |
| 256 | - if($fileName === 0) // application config file |
|
| 256 | + if($fileName===0) // application config file |
|
| 257 | 257 | { |
| 258 | - $appConfigFile = $application->getConfigurationFile(); |
|
| 259 | - $currentTimestamp[0] = $appConfigFile === null?0:@filemtime($appConfigFile); |
|
| 258 | + $appConfigFile=$application->getConfigurationFile(); |
|
| 259 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
| 260 | 260 | if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0])) |
| 261 | - $configCached = false; |
|
| 261 | + $configCached=false; |
|
| 262 | 262 | } |
| 263 | 263 | else |
| 264 | 264 | { |
| 265 | - $currentTimestamp[$fileName] = @filemtime($fileName); |
|
| 265 | + $currentTimestamp[$fileName]=@filemtime($fileName); |
|
| 266 | 266 | if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName])) |
| 267 | - $configCached = false; |
|
| 267 | + $configCached=false; |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | else |
| 273 | 273 | { |
| 274 | - $configCached = false; |
|
| 275 | - $paths = explode('.', $pagePath); |
|
| 276 | - $configPath = $this->getBasePath(); |
|
| 277 | - $fileName = $this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP |
|
| 274 | + $configCached=false; |
|
| 275 | + $paths=explode('.', $pagePath); |
|
| 276 | + $configPath=$this->getBasePath(); |
|
| 277 | + $fileName=$this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
| 278 | 278 | ? self::CONFIG_FILE_PHP |
| 279 | 279 | : self::CONFIG_FILE_XML; |
| 280 | 280 | foreach($paths as $path) |
| 281 | 281 | { |
| 282 | - $configFile = $configPath . DIRECTORY_SEPARATOR . $fileName; |
|
| 283 | - $currentTimestamp[$configFile] = @filemtime($configFile); |
|
| 284 | - $configPath .= DIRECTORY_SEPARATOR . $path; |
|
| 282 | + $configFile=$configPath.DIRECTORY_SEPARATOR.$fileName; |
|
| 283 | + $currentTimestamp[$configFile]=@filemtime($configFile); |
|
| 284 | + $configPath.=DIRECTORY_SEPARATOR.$path; |
|
| 285 | 285 | } |
| 286 | - $appConfigFile = $application->getConfigurationFile(); |
|
| 287 | - $currentTimestamp[0] = $appConfigFile === null?0:@filemtime($appConfigFile); |
|
| 286 | + $appConfigFile=$application->getConfigurationFile(); |
|
| 287 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
| 288 | 288 | } |
| 289 | 289 | if(!$configCached) |
| 290 | 290 | { |
| 291 | - $pageConfig = new TPageConfiguration($pagePath); |
|
| 292 | - if($config !== null) |
|
| 291 | + $pageConfig=new TPageConfiguration($pagePath); |
|
| 292 | + if($config!==null) |
|
| 293 | 293 | { |
| 294 | - if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 294 | + if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 295 | 295 | $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
| 296 | 296 | else |
| 297 | 297 | $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
| 298 | 298 | } |
| 299 | 299 | $pageConfig->loadFromFiles($this->getBasePath()); |
| 300 | - $cache->set(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath, [$pageConfig,$currentTimestamp]); |
|
| 300 | + $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath, [$pageConfig, $currentTimestamp]); |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | return $pageConfig; |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | { |
| 311 | 311 | if(!$this->_templateManager) |
| 312 | 312 | { |
| 313 | - $this->_templateManager = new TTemplateManager; |
|
| 313 | + $this->_templateManager=new TTemplateManager; |
|
| 314 | 314 | $this->_templateManager->init(null); |
| 315 | 315 | } |
| 316 | 316 | return $this->_templateManager; |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | public function setTemplateManager(TTemplateManager $value) |
| 323 | 323 | { |
| 324 | - $this->_templateManager = $value; |
|
| 324 | + $this->_templateManager=$value; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | { |
| 332 | 332 | if(!$this->_themeManager) |
| 333 | 333 | { |
| 334 | - $this->_themeManager = new TThemeManager; |
|
| 334 | + $this->_themeManager=new TThemeManager; |
|
| 335 | 335 | $this->_themeManager->init(null); |
| 336 | 336 | } |
| 337 | 337 | return $this->_themeManager; |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | public function setThemeManager(TThemeManager $value) |
| 344 | 344 | { |
| 345 | - $this->_themeManager = $value; |
|
| 345 | + $this->_themeManager=$value; |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
@@ -350,9 +350,9 @@ discard block |
||
| 350 | 350 | */ |
| 351 | 351 | public function getRequestedPagePath() |
| 352 | 352 | { |
| 353 | - if($this->_pagePath === null) |
|
| 353 | + if($this->_pagePath===null) |
|
| 354 | 354 | { |
| 355 | - $this->_pagePath = strtr($this->determineRequestedPagePath(), '/\\', '..'); |
|
| 355 | + $this->_pagePath=strtr($this->determineRequestedPagePath(), '/\\', '..'); |
|
| 356 | 356 | if(empty($this->_pagePath)) |
| 357 | 357 | throw new THttpException(404, 'pageservice_page_required'); |
| 358 | 358 | } |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | if($this->_initialized) |
| 385 | 385 | throw new TInvalidOperationException('pageservice_defaultpage_unchangeable'); |
| 386 | 386 | else |
| 387 | - $this->_defaultPage = $value; |
|
| 387 | + $this->_defaultPage=$value; |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
@@ -400,13 +400,13 @@ discard block |
||
| 400 | 400 | */ |
| 401 | 401 | public function getBasePath() |
| 402 | 402 | { |
| 403 | - if($this->_basePath === null) |
|
| 403 | + if($this->_basePath===null) |
|
| 404 | 404 | { |
| 405 | - $basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH; |
|
| 406 | - if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath)) |
|
| 405 | + $basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
|
| 406 | + if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) |
|
| 407 | 407 | { |
| 408 | - $basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::FALLBACK_BASEPATH; |
|
| 409 | - if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath)) |
|
| 408 | + $basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::FALLBACK_BASEPATH; |
|
| 409 | + if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) |
|
| 410 | 410 | throw new TConfigurationException('pageservice_basepath_invalid', $basePath); |
| 411 | 411 | } |
| 412 | 412 | } |
@@ -421,9 +421,9 @@ discard block |
||
| 421 | 421 | { |
| 422 | 422 | if($this->_initialized) |
| 423 | 423 | throw new TInvalidOperationException('pageservice_basepath_unchangeable'); |
| 424 | - elseif(($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path)) |
|
| 424 | + elseif(($path=Prado::getPathOfNamespace($value))===null || !is_dir($path)) |
|
| 425 | 425 | throw new TConfigurationException('pageservice_basepath_invalid', $value); |
| 426 | - $this->_basePath = realpath($path); |
|
| 426 | + $this->_basePath=realpath($path); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | /** |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | public function setBasePageClass($value) |
| 436 | 436 | { |
| 437 | - $this->_basePageClass = $value; |
|
| 437 | + $this->_basePageClass=$value; |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | /** |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | public function setClientScriptManagerClass($value) |
| 454 | 454 | { |
| 455 | - $this->_clientScriptManagerClass = $value; |
|
| 455 | + $this->_clientScriptManagerClass=$value; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | public function run() |
| 473 | 473 | { |
| 474 | 474 | Prado::trace("Running page service", 'Prado\Web\Services\TPageService'); |
| 475 | - $this->_page = $this->createPage($this->getRequestedPagePath()); |
|
| 475 | + $this->_page=$this->createPage($this->getRequestedPagePath()); |
|
| 476 | 476 | $this->runPage($this->_page, $this->_properties); |
| 477 | 477 | } |
| 478 | 478 | |
@@ -485,40 +485,40 @@ discard block |
||
| 485 | 485 | */ |
| 486 | 486 | protected function createPage($pagePath) |
| 487 | 487 | { |
| 488 | - $path = $this->getBasePath() . DIRECTORY_SEPARATOR . strtr($pagePath, '.', DIRECTORY_SEPARATOR); |
|
| 489 | - $hasTemplateFile = is_file($path . self::PAGE_FILE_EXT); |
|
| 490 | - $hasClassFile = is_file($path . Prado::CLASS_FILE_EXT); |
|
| 488 | + $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath, '.', DIRECTORY_SEPARATOR); |
|
| 489 | + $hasTemplateFile=is_file($path.self::PAGE_FILE_EXT); |
|
| 490 | + $hasClassFile=is_file($path.Prado::CLASS_FILE_EXT); |
|
| 491 | 491 | |
| 492 | 492 | if(!$hasTemplateFile && !$hasClassFile) |
| 493 | 493 | throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
| 494 | 494 | |
| 495 | 495 | if($hasClassFile) |
| 496 | 496 | { |
| 497 | - $className = basename($path); |
|
| 498 | - $namespacedClassName = static::PAGE_NAMESPACE_PREFIX . str_replace('.', '\\', $pagePath); |
|
| 497 | + $className=basename($path); |
|
| 498 | + $namespacedClassName=static::PAGE_NAMESPACE_PREFIX.str_replace('.', '\\', $pagePath); |
|
| 499 | 499 | |
| 500 | 500 | if(!class_exists($className, false) && !class_exists($namespacedClassName, false)) |
| 501 | - include_once($path . Prado::CLASS_FILE_EXT); |
|
| 501 | + include_once($path.Prado::CLASS_FILE_EXT); |
|
| 502 | 502 | |
| 503 | 503 | if(!class_exists($className, false)) |
| 504 | - $className = $namespacedClassName; |
|
| 504 | + $className=$namespacedClassName; |
|
| 505 | 505 | } |
| 506 | 506 | else |
| 507 | 507 | { |
| 508 | - $className = $this->getBasePageClass(); |
|
| 508 | + $className=$this->getBasePageClass(); |
|
| 509 | 509 | Prado::using($className); |
| 510 | - if(($pos = strrpos($className, '.')) !== false) |
|
| 511 | - $className = substr($className, $pos + 1); |
|
| 510 | + if(($pos=strrpos($className, '.'))!==false) |
|
| 511 | + $className=substr($className, $pos + 1); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - if($className !== '\Prado\Web\UI\TPage' && !is_subclass_of($className, '\Prado\Web\UI\TPage')) |
|
| 514 | + if($className!=='\Prado\Web\UI\TPage' && !is_subclass_of($className, '\Prado\Web\UI\TPage')) |
|
| 515 | 515 | throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
| 516 | 516 | |
| 517 | - $page = Prado::createComponent($className); |
|
| 517 | + $page=Prado::createComponent($className); |
|
| 518 | 518 | $page->setPagePath($pagePath); |
| 519 | 519 | |
| 520 | 520 | if($hasTemplateFile) |
| 521 | - $page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path . self::PAGE_FILE_EXT)); |
|
| 521 | + $page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path.self::PAGE_FILE_EXT)); |
|
| 522 | 522 | |
| 523 | 523 | return $page; |
| 524 | 524 | } |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
| 544 | 544 | * @return string URL for the page and GET parameters |
| 545 | 545 | */ |
| 546 | - public function constructUrl($pagePath, $getParams = null, $encodeAmpersand = true, $encodeGetItems = true) |
|
| 546 | + public function constructUrl($pagePath, $getParams=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
| 547 | 547 | { |
| 548 | 548 | return $this->getRequest()->constructUrl($this->getID(), $pagePath, $getParams, $encodeAmpersand, $encodeGetItems); |
| 549 | 549 | } |
@@ -240,8 +240,7 @@ discard block |
||
| 240 | 240 | $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
| 241 | 241 | } |
| 242 | 242 | $pageConfig->loadFromFiles($this->getBasePath()); |
| 243 | - } |
|
| 244 | - else |
|
| 243 | + } else |
|
| 245 | 244 | { |
| 246 | 245 | $configCached = true; |
| 247 | 246 | $currentTimestamp = []; |
@@ -259,8 +258,7 @@ discard block |
||
| 259 | 258 | $currentTimestamp[0] = $appConfigFile === null?0:@filemtime($appConfigFile); |
| 260 | 259 | if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0])) |
| 261 | 260 | $configCached = false; |
| 262 | - } |
|
| 263 | - else |
|
| 261 | + } else |
|
| 264 | 262 | { |
| 265 | 263 | $currentTimestamp[$fileName] = @filemtime($fileName); |
| 266 | 264 | if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName])) |
@@ -268,8 +266,7 @@ discard block |
||
| 268 | 266 | } |
| 269 | 267 | } |
| 270 | 268 | } |
| 271 | - } |
|
| 272 | - else |
|
| 269 | + } else |
|
| 273 | 270 | { |
| 274 | 271 | $configCached = false; |
| 275 | 272 | $paths = explode('.', $pagePath); |
@@ -502,8 +499,7 @@ discard block |
||
| 502 | 499 | |
| 503 | 500 | if(!class_exists($className, false)) |
| 504 | 501 | $className = $namespacedClassName; |
| 505 | - } |
|
| 506 | - else |
|
| 502 | + } else |
|
| 507 | 503 | { |
| 508 | 504 | $className = $this->getBasePageClass(); |
| 509 | 505 | Prado::using($className); |
@@ -225,6 +225,7 @@ discard block |
||
| 225 | 225 | * This method does not perform any publishing. It merely tells you |
| 226 | 226 | * if the file path is published, what the URL will be to access it. |
| 227 | 227 | * @param string directory or file path being published |
| 228 | + * @param string $path |
|
| 228 | 229 | * @return string the published URL for the file path |
| 229 | 230 | */ |
| 230 | 231 | public function getPublishedUrl($path) |
@@ -240,6 +241,7 @@ discard block |
||
| 240 | 241 | * Generate a CRC32 hash for the directory path. Collisions are higher |
| 241 | 242 | * than MD5 but generates a much smaller hash string. |
| 242 | 243 | * @param string string to be hashed. |
| 244 | + * @param string $dir |
|
| 243 | 245 | * @return string hashed string. |
| 244 | 246 | */ |
| 245 | 247 | protected function hash($dir) |
@@ -253,6 +255,8 @@ discard block |
||
| 253 | 255 | * or has an older file modification time. |
| 254 | 256 | * @param string source file path |
| 255 | 257 | * @param string destination directory (if not exists, it will be created) |
| 258 | + * @param string $src |
|
| 259 | + * @param string $dst |
|
| 256 | 260 | */ |
| 257 | 261 | protected function copyFile($src, $dst) |
| 258 | 262 | { |
@@ -275,6 +279,8 @@ discard block |
||
| 275 | 279 | * File modification time is used to ensure the copied files are latest. |
| 276 | 280 | * @param string the source directory |
| 277 | 281 | * @param string the destination directory |
| 282 | + * @param string $src |
|
| 283 | + * @param string $dst |
|
| 278 | 284 | * @todo a generic solution to ignore certain directories and files |
| 279 | 285 | */ |
| 280 | 286 | public function copyDirectory($src, $dst) |
@@ -316,6 +322,8 @@ discard block |
||
| 316 | 322 | * @param string tar filename |
| 317 | 323 | * @param string MD5 checksum for the corresponding tar file. |
| 318 | 324 | * @param boolean Wether or not to check the time stamp of the file for publishing. Defaults to false. |
| 325 | + * @param string $tarfile |
|
| 326 | + * @param string $md5sum |
|
| 319 | 327 | * @return string URL path to the directory where the tar file was extracted. |
| 320 | 328 | */ |
| 321 | 329 | public function publishTarFile($tarfile, $md5sum, $checkTimestamp = false) |
@@ -346,6 +354,7 @@ discard block |
||
| 346 | 354 | * N.B Tar file must not be compressed. |
| 347 | 355 | * @param string tar file |
| 348 | 356 | * @param string path where the contents of tar file are to be extracted |
| 357 | + * @param string $destination |
|
| 349 | 358 | * @return boolean true if extract successful, false otherwise. |
| 350 | 359 | */ |
| 351 | 360 | protected function deployTarFile($path, $destination) |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * Default web accessible base path for storing private files |
| 57 | 57 | */ |
| 58 | - const DEFAULT_BASEPATH = 'assets'; |
|
| 58 | + const DEFAULT_BASEPATH='assets'; |
|
| 59 | 59 | /** |
| 60 | 60 | * @var string base web accessible path for storing private files |
| 61 | 61 | */ |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * @var boolean whether to use timestamp checking to ensure files are published with up-to-date versions. |
| 69 | 69 | */ |
| 70 | - private $_checkTimestamp = false; |
|
| 70 | + private $_checkTimestamp=false; |
|
| 71 | 71 | /** |
| 72 | 72 | * @var TApplication application instance |
| 73 | 73 | */ |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | /** |
| 76 | 76 | * @var array published assets |
| 77 | 77 | */ |
| 78 | - private $_published = []; |
|
| 78 | + private $_published=[]; |
|
| 79 | 79 | /** |
| 80 | 80 | * @var boolean whether the module is initialized |
| 81 | 81 | */ |
| 82 | - private $_initialized = false; |
|
| 82 | + private $_initialized=false; |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Initializes the module. |
@@ -88,15 +88,15 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function init($config) |
| 90 | 90 | { |
| 91 | - $application = $this->getApplication(); |
|
| 92 | - if($this->_basePath === null) |
|
| 93 | - $this->_basePath = dirname($application->getRequest()->getApplicationFilePath()) . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH; |
|
| 91 | + $application=$this->getApplication(); |
|
| 92 | + if($this->_basePath===null) |
|
| 93 | + $this->_basePath=dirname($application->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
|
| 94 | 94 | if(!is_writable($this->_basePath) || !is_dir($this->_basePath)) |
| 95 | 95 | throw new TConfigurationException('assetmanager_basepath_invalid', $this->_basePath); |
| 96 | - if($this->_baseUrl === null) |
|
| 97 | - $this->_baseUrl = rtrim(dirname($application->getRequest()->getApplicationUrl()), '/\\') . '/' . self::DEFAULT_BASEPATH; |
|
| 96 | + if($this->_baseUrl===null) |
|
| 97 | + $this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()), '/\\').'/'.self::DEFAULT_BASEPATH; |
|
| 98 | 98 | $application->setAssetManager($this); |
| 99 | - $this->_initialized = true; |
|
| 99 | + $this->_initialized=true; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | throw new TInvalidOperationException('assetmanager_basepath_unchangeable'); |
| 120 | 120 | else |
| 121 | 121 | { |
| 122 | - $this->_basePath = Prado::getPathOfNamespace($value); |
|
| 123 | - if($this->_basePath === null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) |
|
| 122 | + $this->_basePath=Prado::getPathOfNamespace($value); |
|
| 123 | + if($this->_basePath===null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) |
|
| 124 | 124 | throw new TInvalidDataValueException('assetmanager_basepath_invalid', $value); |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | if($this->_initialized) |
| 143 | 143 | throw new TInvalidOperationException('assetmanager_baseurl_unchangeable'); |
| 144 | 144 | else |
| 145 | - $this->_baseUrl = rtrim($value, '/'); |
|
| 145 | + $this->_baseUrl=rtrim($value, '/'); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -159,30 +159,30 @@ discard block |
||
| 159 | 159 | * @throws TInvalidDataValueException if the file path to be published is |
| 160 | 160 | * invalid |
| 161 | 161 | */ |
| 162 | - public function publishFilePath($path, $checkTimestamp = false) |
|
| 162 | + public function publishFilePath($path, $checkTimestamp=false) |
|
| 163 | 163 | { |
| 164 | 164 | if(isset($this->_published[$path])) |
| 165 | 165 | return $this->_published[$path]; |
| 166 | - elseif(empty($path) || ($fullpath = realpath($path)) === false) |
|
| 166 | + elseif(empty($path) || ($fullpath=realpath($path))===false) |
|
| 167 | 167 | throw new TInvalidDataValueException('assetmanager_filepath_invalid', $path); |
| 168 | 168 | elseif(is_file($fullpath)) |
| 169 | 169 | { |
| 170 | - $dir = $this->hash(dirname($fullpath)); |
|
| 171 | - $fileName = basename($fullpath); |
|
| 172 | - $dst = $this->_basePath . DIRECTORY_SEPARATOR . $dir; |
|
| 173 | - if(!is_file($dst . DIRECTORY_SEPARATOR . $fileName) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 170 | + $dir=$this->hash(dirname($fullpath)); |
|
| 171 | + $fileName=basename($fullpath); |
|
| 172 | + $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
|
| 173 | + if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 174 | 174 | $this->copyFile($fullpath, $dst); |
| 175 | - return $this->_published[$path] = $this->_baseUrl . '/' . $dir . '/' . $fileName; |
|
| 175 | + return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName; |
|
| 176 | 176 | } |
| 177 | 177 | else |
| 178 | 178 | { |
| 179 | - $dir = $this->hash($fullpath); |
|
| 180 | - if(!is_dir($this->_basePath . DIRECTORY_SEPARATOR . $dir) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 179 | + $dir=$this->hash($fullpath); |
|
| 180 | + if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 181 | 181 | { |
| 182 | 182 | Prado::trace("Publishing directory $fullpath", 'Prado\Web\TAssetManager'); |
| 183 | - $this->copyDirectory($fullpath, $this->_basePath . DIRECTORY_SEPARATOR . $dir); |
|
| 183 | + $this->copyDirectory($fullpath, $this->_basePath.DIRECTORY_SEPARATOR.$dir); |
|
| 184 | 184 | } |
| 185 | - return $this->_published[$path] = $this->_baseUrl . '/' . $dir; |
|
| 185 | + return $this->_published[$path]=$this->_baseUrl.'/'.$dir; |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | * @param $values List of published assets |
| 200 | 200 | * @since 3.1.6 |
| 201 | 201 | */ |
| 202 | - protected function setPublished($values = []) |
|
| 202 | + protected function setPublished($values=[]) |
|
| 203 | 203 | { |
| 204 | - $this->_published = $values; |
|
| 204 | + $this->_published=$values; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -213,11 +213,11 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function getPublishedPath($path) |
| 215 | 215 | { |
| 216 | - $path = realpath($path); |
|
| 216 | + $path=realpath($path); |
|
| 217 | 217 | if(is_file($path)) |
| 218 | - return $this->_basePath . DIRECTORY_SEPARATOR . $this->hash(dirname($path)) . DIRECTORY_SEPARATOR . basename($path); |
|
| 218 | + return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash(dirname($path)).DIRECTORY_SEPARATOR.basename($path); |
|
| 219 | 219 | else |
| 220 | - return $this->_basePath . DIRECTORY_SEPARATOR . $this->hash($path); |
|
| 220 | + return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash($path); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public function getPublishedUrl($path) |
| 231 | 231 | { |
| 232 | - $path = realpath($path); |
|
| 232 | + $path=realpath($path); |
|
| 233 | 233 | if(is_file($path)) |
| 234 | - return $this->_baseUrl . '/' . $this->hash(dirname($path)) . '/' . basename($path); |
|
| 234 | + return $this->_baseUrl.'/'.$this->hash(dirname($path)).'/'.basename($path); |
|
| 235 | 235 | else |
| 236 | - return $this->_baseUrl . '/' . $this->hash($path); |
|
| 236 | + return $this->_baseUrl.'/'.$this->hash($path); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | protected function hash($dir) |
| 246 | 246 | { |
| 247 | - return sprintf('%x', crc32($dir . Prado::getVersion())); |
|
| 247 | + return sprintf('%x', crc32($dir.Prado::getVersion())); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | @mkdir($dst); |
| 262 | 262 | @chmod($dst, PRADO_CHMOD); |
| 263 | 263 | } |
| 264 | - $dstFile = $dst . DIRECTORY_SEPARATOR . basename($src); |
|
| 264 | + $dstFile=$dst.DIRECTORY_SEPARATOR.basename($src); |
|
| 265 | 265 | if(@filemtime($dstFile) < @filemtime($src)) |
| 266 | 266 | { |
| 267 | 267 | Prado::trace("Publishing file $src to $dstFile", 'Prado\Web\TAssetManager'); |
@@ -284,22 +284,22 @@ discard block |
||
| 284 | 284 | @mkdir($dst); |
| 285 | 285 | @chmod($dst, PRADO_CHMOD); |
| 286 | 286 | } |
| 287 | - if($folder = @opendir($src)) |
|
| 287 | + if($folder=@opendir($src)) |
|
| 288 | 288 | { |
| 289 | - while($file = @readdir($folder)) |
|
| 289 | + while($file=@readdir($folder)) |
|
| 290 | 290 | { |
| 291 | - if($file === '.' || $file === '..' || $file === '.svn' || $file === '.git') |
|
| 291 | + if($file==='.' || $file==='..' || $file==='.svn' || $file==='.git') |
|
| 292 | 292 | continue; |
| 293 | - elseif(is_file($src . DIRECTORY_SEPARATOR . $file)) |
|
| 293 | + elseif(is_file($src.DIRECTORY_SEPARATOR.$file)) |
|
| 294 | 294 | { |
| 295 | - if(@filemtime($dst . DIRECTORY_SEPARATOR . $file) < @filemtime($src . DIRECTORY_SEPARATOR . $file)) |
|
| 295 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$file) < @filemtime($src.DIRECTORY_SEPARATOR.$file)) |
|
| 296 | 296 | { |
| 297 | - @copy($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file); |
|
| 298 | - @chmod($dst . DIRECTORY_SEPARATOR . $file, PRADO_CHMOD); |
|
| 297 | + @copy($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
| 298 | + @chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD); |
|
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | else |
| 302 | - $this->copyDirectory($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file); |
|
| 302 | + $this->copyDirectory($src.DIRECTORY_SEPARATOR.$file, $dst.DIRECTORY_SEPARATOR.$file); |
|
| 303 | 303 | } |
| 304 | 304 | closedir($folder); |
| 305 | 305 | } else { |
@@ -318,26 +318,26 @@ discard block |
||
| 318 | 318 | * @param boolean Wether or not to check the time stamp of the file for publishing. Defaults to false. |
| 319 | 319 | * @return string URL path to the directory where the tar file was extracted. |
| 320 | 320 | */ |
| 321 | - public function publishTarFile($tarfile, $md5sum, $checkTimestamp = false) |
|
| 321 | + public function publishTarFile($tarfile, $md5sum, $checkTimestamp=false) |
|
| 322 | 322 | { |
| 323 | 323 | if(isset($this->_published[$md5sum])) |
| 324 | 324 | return $this->_published[$md5sum]; |
| 325 | - elseif(($fullpath = realpath($md5sum)) === false || !is_file($fullpath)) |
|
| 325 | + elseif(($fullpath=realpath($md5sum))===false || !is_file($fullpath)) |
|
| 326 | 326 | throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid', $md5sum); |
| 327 | 327 | else |
| 328 | 328 | { |
| 329 | - $dir = $this->hash(dirname($fullpath)); |
|
| 330 | - $fileName = basename($fullpath); |
|
| 331 | - $dst = $this->_basePath . DIRECTORY_SEPARATOR . $dir; |
|
| 332 | - if(!is_file($dst . DIRECTORY_SEPARATOR . $fileName) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 329 | + $dir=$this->hash(dirname($fullpath)); |
|
| 330 | + $fileName=basename($fullpath); |
|
| 331 | + $dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir; |
|
| 332 | + if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 333 | 333 | { |
| 334 | - if(@filemtime($dst . DIRECTORY_SEPARATOR . $fileName) < @filemtime($fullpath)) |
|
| 334 | + if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName) < @filemtime($fullpath)) |
|
| 335 | 335 | { |
| 336 | 336 | $this->copyFile($fullpath, $dst); |
| 337 | 337 | $this->deployTarFile($tarfile, $dst); |
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | - return $this->_published[$md5sum] = $this->_baseUrl . '/' . $dir; |
|
| 340 | + return $this->_published[$md5sum]=$this->_baseUrl.'/'.$dir; |
|
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | |
@@ -350,11 +350,11 @@ discard block |
||
| 350 | 350 | */ |
| 351 | 351 | protected function deployTarFile($path, $destination) |
| 352 | 352 | { |
| 353 | - if(($fullpath = realpath($path)) === false || !is_file($fullpath)) |
|
| 353 | + if(($fullpath=realpath($path))===false || !is_file($fullpath)) |
|
| 354 | 354 | throw new TIOException('assetmanager_tarfile_invalid', $path); |
| 355 | 355 | else |
| 356 | 356 | { |
| 357 | - $tar = new TTarFileExtractor($fullpath); |
|
| 357 | + $tar=new TTarFileExtractor($fullpath); |
|
| 358 | 358 | return $tar->extract($destination); |
| 359 | 359 | } |
| 360 | 360 | } |
@@ -173,8 +173,7 @@ discard block |
||
| 173 | 173 | if(!is_file($dst . DIRECTORY_SEPARATOR . $fileName) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
| 174 | 174 | $this->copyFile($fullpath, $dst); |
| 175 | 175 | return $this->_published[$path] = $this->_baseUrl . '/' . $dir . '/' . $fileName; |
| 176 | - } |
|
| 177 | - else |
|
| 176 | + } else |
|
| 178 | 177 | { |
| 179 | 178 | $dir = $this->hash($fullpath); |
| 180 | 179 | if(!is_dir($this->_basePath . DIRECTORY_SEPARATOR . $dir) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
@@ -297,8 +296,7 @@ discard block |
||
| 297 | 296 | @copy($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file); |
| 298 | 297 | @chmod($dst . DIRECTORY_SEPARATOR . $file, PRADO_CHMOD); |
| 299 | 298 | } |
| 300 | - } |
|
| 301 | - else |
|
| 299 | + } else |
|
| 302 | 300 | $this->copyDirectory($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file); |
| 303 | 301 | } |
| 304 | 302 | closedir($folder); |
@@ -38,6 +38,7 @@ discard block |
||
| 38 | 38 | /** |
| 39 | 39 | * Constructor. |
| 40 | 40 | * @param mixed owner of this collection. |
| 41 | + * @param THttpResponse $owner |
|
| 41 | 42 | */ |
| 42 | 43 | public function __construct($owner = null) |
| 43 | 44 | { |
@@ -81,6 +82,7 @@ discard block |
||
| 81 | 82 | |
| 82 | 83 | /** |
| 83 | 84 | * @param integer|string index of the cookie in the collection or the cookie's name |
| 85 | + * @param string $index |
|
| 84 | 86 | * @return THttpCookie the cookie found |
| 85 | 87 | */ |
| 86 | 88 | public function itemAt($index) |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | * Constructor. |
| 40 | 40 | * @param mixed owner of this collection. |
| 41 | 41 | */ |
| 42 | - public function __construct($owner = null) |
|
| 42 | + public function __construct($owner=null) |
|
| 43 | 43 | { |
| 44 | - $this->_o = $owner; |
|
| 44 | + $this->_o=$owner; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function removeAt($index) |
| 75 | 75 | { |
| 76 | - $item = parent::removeAt($index); |
|
| 76 | + $item=parent::removeAt($index); |
|
| 77 | 77 | if($this->_o instanceof THttpResponse) |
| 78 | 78 | $this->_o->removeCookie($item); |
| 79 | 79 | return $item; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | public function findCookieByName($name) |
| 100 | 100 | { |
| 101 | 101 | foreach($this as $cookie) |
| 102 | - if($cookie->getName() === $name) |
|
| 102 | + if($cookie->getName()===$name) |
|
| 103 | 103 | return $cookie; |
| 104 | 104 | return null; |
| 105 | 105 | } |
@@ -234,6 +234,7 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | /** |
| 236 | 236 | * @param string|boolean output charset. |
| 237 | + * @param string $charset |
|
| 237 | 238 | */ |
| 238 | 239 | public function setCharset($charset) |
| 239 | 240 | { |
@@ -403,6 +404,7 @@ discard block |
||
| 403 | 404 | * The current application will be terminated after this method is invoked. |
| 404 | 405 | * @param string URL to be redirected to. If the URL is a relative one, the base URL of |
| 405 | 406 | * the current request will be inserted at the beginning. |
| 407 | + * @param string $url |
|
| 406 | 408 | */ |
| 407 | 409 | public function redirect($url) |
| 408 | 410 | { |
@@ -618,6 +620,7 @@ discard block |
||
| 618 | 620 | * Sends a header. |
| 619 | 621 | * @param string header |
| 620 | 622 | * @param boolean whether the header should replace a previous similar header, or add a second header of the same type |
| 623 | + * @param string $value |
|
| 621 | 624 | */ |
| 622 | 625 | public function appendHeader($value, $replace = true) |
| 623 | 626 | { |
@@ -643,6 +646,7 @@ discard block |
||
| 643 | 646 | * Sends a cookie. |
| 644 | 647 | * Do not call this method directly. Operate with the result of {@link getCookies} instead. |
| 645 | 648 | * @param THttpCookie cook to be sent |
| 649 | + * @param THttpCookie $cookie |
|
| 646 | 650 | */ |
| 647 | 651 | public function addCookie($cookie) |
| 648 | 652 | { |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | class THttpResponse extends \Prado\TModule implements \Prado\IO\ITextWriter |
| 68 | 68 | { |
| 69 | - const DEFAULT_CONTENTTYPE = 'text/html'; |
|
| 70 | - const DEFAULT_CHARSET = 'UTF-8'; |
|
| 69 | + const DEFAULT_CONTENTTYPE='text/html'; |
|
| 70 | + const DEFAULT_CHARSET='UTF-8'; |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * @var The differents defined status code by RFC 2616 {@link http://www.faqs.org/rfcs/rfc2616} |
| 74 | 74 | */ |
| 75 | - private static $HTTP_STATUS_CODES = [ |
|
| 75 | + private static $HTTP_STATUS_CODES=[ |
|
| 76 | 76 | 100 => 'Continue', 101 => 'Switching Protocols', |
| 77 | 77 | 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', |
| 78 | 78 | 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | /** |
| 84 | 84 | * @var boolean whether to buffer output |
| 85 | 85 | */ |
| 86 | - private $_bufferOutput = true; |
|
| 86 | + private $_bufferOutput=true; |
|
| 87 | 87 | /** |
| 88 | 88 | * @var boolean if the application is initialized |
| 89 | 89 | */ |
| 90 | - private $_initialized = false; |
|
| 90 | + private $_initialized=false; |
|
| 91 | 91 | /** |
| 92 | 92 | * @var THttpCookieCollection list of cookies to return |
| 93 | 93 | */ |
@@ -95,15 +95,15 @@ discard block |
||
| 95 | 95 | /** |
| 96 | 96 | * @var integer response status code |
| 97 | 97 | */ |
| 98 | - private $_status = 200; |
|
| 98 | + private $_status=200; |
|
| 99 | 99 | /** |
| 100 | 100 | * @var string reason correspond to status code |
| 101 | 101 | */ |
| 102 | - private $_reason = 'OK'; |
|
| 102 | + private $_reason='OK'; |
|
| 103 | 103 | /** |
| 104 | 104 | * @var string HTML writer type |
| 105 | 105 | */ |
| 106 | - private $_htmlWriterType = '\Prado\Web\UI\THtmlWriter'; |
|
| 106 | + private $_htmlWriterType='\Prado\Web\UI\THtmlWriter'; |
|
| 107 | 107 | /** |
| 108 | 108 | * @var string content type |
| 109 | 109 | */ |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | /** |
| 112 | 112 | * @var string|boolean character set, e.g. UTF-8 or false if no character set should be send to client |
| 113 | 113 | */ |
| 114 | - private $_charset = ''; |
|
| 114 | + private $_charset=''; |
|
| 115 | 115 | /** |
| 116 | 116 | * @var THttpResponseAdapter adapter. |
| 117 | 117 | */ |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function setAdapter(THttpResponseAdapter $adapter) |
| 142 | 142 | { |
| 143 | - $this->_adapter = $adapter; |
|
| 143 | + $this->_adapter=$adapter; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public function getHasAdapter() |
| 158 | 158 | { |
| 159 | - return $this->_adapter !== null; |
|
| 159 | + return $this->_adapter!==null; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | if($this->_bufferOutput) |
| 171 | 171 | ob_start(); |
| 172 | - $this->_initialized = true; |
|
| 172 | + $this->_initialized=true; |
|
| 173 | 173 | $this->getApplication()->setResponse($this); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public function setCacheControl($value) |
| 205 | 205 | { |
| 206 | - session_cache_limiter(TPropertyValue::ensureEnum($value, ['none','nocache','private','private_no_expire','public'])); |
|
| 206 | + session_cache_limiter(TPropertyValue::ensureEnum($value, ['none', 'nocache', 'private', 'private_no_expire', 'public'])); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function setContentType($type) |
| 213 | 213 | { |
| 214 | - if ($this->_contentTypeHeaderSent) |
|
| 214 | + if($this->_contentTypeHeaderSent) |
|
| 215 | 215 | throw new \Exception('Unable to alter content-type as it has been already sent'); |
| 216 | - $this->_contentType = $type; |
|
| 216 | + $this->_contentType=$type; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function setCharset($charset) |
| 239 | 239 | { |
| 240 | - $this->_charset = (strToLower($charset) === 'false') ? false : (string)$charset; |
|
| 240 | + $this->_charset=(strToLower($charset)==='false') ? false : (string) $charset; |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | if($this->_initialized) |
| 258 | 258 | throw new TInvalidOperationException('httpresponse_bufferoutput_unchangeable'); |
| 259 | 259 | else |
| 260 | - $this->_bufferOutput = TPropertyValue::ensureBoolean($value); |
|
| 260 | + $this->_bufferOutput=TPropertyValue::ensureBoolean($value); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -276,24 +276,24 @@ discard block |
||
| 276 | 276 | * @param integer HTTP status code |
| 277 | 277 | * @param string HTTP status reason, defaults to standard HTTP reasons |
| 278 | 278 | */ |
| 279 | - public function setStatusCode($status, $reason = null) |
|
| 279 | + public function setStatusCode($status, $reason=null) |
|
| 280 | 280 | { |
| 281 | - if ($this->_httpHeaderSent) |
|
| 281 | + if($this->_httpHeaderSent) |
|
| 282 | 282 | throw new \Exception('Unable to alter response as HTTP header already sent'); |
| 283 | - $status = TPropertyValue::ensureInteger($status); |
|
| 283 | + $status=TPropertyValue::ensureInteger($status); |
|
| 284 | 284 | if(isset(self::$HTTP_STATUS_CODES[$status])) { |
| 285 | - $this->_reason = self::$HTTP_STATUS_CODES[$status]; |
|
| 286 | - }else{ |
|
| 287 | - if($reason === null || $reason === '') { |
|
| 285 | + $this->_reason=self::$HTTP_STATUS_CODES[$status]; |
|
| 286 | + } else { |
|
| 287 | + if($reason===null || $reason==='') { |
|
| 288 | 288 | throw new TInvalidDataValueException("response_status_reason_missing"); |
| 289 | 289 | } |
| 290 | - $reason = TPropertyValue::ensureString($reason); |
|
| 291 | - if(strpos($reason, "\r") != false || strpos($reason, "\n") != false) { |
|
| 290 | + $reason=TPropertyValue::ensureString($reason); |
|
| 291 | + if(strpos($reason, "\r")!=false || strpos($reason, "\n")!=false) { |
|
| 292 | 292 | throw new TInvalidDataValueException("response_status_reason_barchars"); |
| 293 | 293 | } |
| 294 | - $this->_reason = $reason; |
|
| 294 | + $this->_reason=$reason; |
|
| 295 | 295 | } |
| 296 | - $this->_status = $status; |
|
| 296 | + $this->_status=$status; |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | /** |
@@ -308,8 +308,8 @@ discard block |
||
| 308 | 308 | */ |
| 309 | 309 | public function getCookies() |
| 310 | 310 | { |
| 311 | - if($this->_cookies === null) |
|
| 312 | - $this->_cookies = new THttpCookieCollection($this); |
|
| 311 | + if($this->_cookies===null) |
|
| 312 | + $this->_cookies=new THttpCookieCollection($this); |
|
| 313 | 313 | return $this->_cookies; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | public function write($str) |
| 322 | 322 | { |
| 323 | 323 | // when starting output make sure we send the headers first |
| 324 | - if (!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
| 324 | + if(!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
| 325 | 325 | $this->ensureHeadersSent(); |
| 326 | 326 | echo $str; |
| 327 | 327 | } |
@@ -338,9 +338,9 @@ discard block |
||
| 338 | 338 | * @param integer size of file or content in bytes if already known. Defaults to 'null' means auto-detect. |
| 339 | 339 | * @throws TInvalidDataValueException if the file cannot be found |
| 340 | 340 | */ |
| 341 | - public function writeFile($fileName, $content = null, $mimeType = null, $headers = null, $forceDownload = true, $clientFileName = null, $fileSize = null) |
|
| 341 | + public function writeFile($fileName, $content=null, $mimeType=null, $headers=null, $forceDownload=true, $clientFileName=null, $fileSize=null) |
|
| 342 | 342 | { |
| 343 | - static $defaultMimeTypes = [ |
|
| 343 | + static $defaultMimeTypes=[ |
|
| 344 | 344 | 'css' => 'text/css', |
| 345 | 345 | 'gif' => 'image/gif', |
| 346 | 346 | 'png' => 'image/png', |
@@ -353,26 +353,26 @@ discard block |
||
| 353 | 353 | 'xls' => 'application/vnd.ms-excel', |
| 354 | 354 | ]; |
| 355 | 355 | |
| 356 | - if($mimeType === null) |
|
| 356 | + if($mimeType===null) |
|
| 357 | 357 | { |
| 358 | - $mimeType = 'text/plain'; |
|
| 358 | + $mimeType='text/plain'; |
|
| 359 | 359 | if(function_exists('mime_content_type')) |
| 360 | - $mimeType = mime_content_type($fileName); |
|
| 361 | - elseif(($ext = strrchr($fileName, '.')) !== false) |
|
| 360 | + $mimeType=mime_content_type($fileName); |
|
| 361 | + elseif(($ext=strrchr($fileName, '.'))!==false) |
|
| 362 | 362 | { |
| 363 | - $ext = substr($ext, 1); |
|
| 363 | + $ext=substr($ext, 1); |
|
| 364 | 364 | if(isset($defaultMimeTypes[$ext])) |
| 365 | - $mimeType = $defaultMimeTypes[$ext]; |
|
| 365 | + $mimeType=$defaultMimeTypes[$ext]; |
|
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - if($clientFileName === null) |
|
| 370 | - $clientFileName = basename($fileName); |
|
| 369 | + if($clientFileName===null) |
|
| 370 | + $clientFileName=basename($fileName); |
|
| 371 | 371 | else |
| 372 | - $clientFileName = basename($clientFileName); |
|
| 372 | + $clientFileName=basename($clientFileName); |
|
| 373 | 373 | |
| 374 | - if($fileSize === null || $fileSize < 0) |
|
| 375 | - $fileSize = ($content === null?filesize($fileName):strlen($content)); |
|
| 374 | + if($fileSize===null || $fileSize < 0) |
|
| 375 | + $fileSize=($content===null ?filesize($fileName) : strlen($content)); |
|
| 376 | 376 | |
| 377 | 377 | $this->sendHttpHeader(); |
| 378 | 378 | if(is_array($headers)) |
@@ -386,13 +386,13 @@ discard block |
||
| 386 | 386 | header('Expires: 0'); |
| 387 | 387 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| 388 | 388 | header("Content-Type: $mimeType"); |
| 389 | - $this->_contentTypeHeaderSent = true; |
|
| 389 | + $this->_contentTypeHeaderSent=true; |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - header('Content-Length: ' . $fileSize); |
|
| 393 | - header("Content-Disposition: " . ($forceDownload ? 'attachment' : 'inline') . "; filename=\"$clientFileName\""); |
|
| 392 | + header('Content-Length: '.$fileSize); |
|
| 393 | + header("Content-Disposition: ".($forceDownload ? 'attachment' : 'inline')."; filename=\"$clientFileName\""); |
|
| 394 | 394 | header('Content-Transfer-Encoding: binary'); |
| 395 | - if($content === null) |
|
| 395 | + if($content===null) |
|
| 396 | 396 | readfile($fileName); |
| 397 | 397 | else |
| 398 | 398 | echo $content; |
@@ -430,25 +430,25 @@ discard block |
||
| 430 | 430 | |
| 431 | 431 | // Under IIS, explicitly send an HTTP response including the status code |
| 432 | 432 | // this is handled automatically by PHP on Apache and others |
| 433 | - $isIIS = (stripos($this->getRequest()->getServerSoftware(), "microsoft-iis") !== false); |
|
| 434 | - if($url[0] === '/') |
|
| 435 | - $url = $this->getRequest()->getBaseUrl() . $url; |
|
| 436 | - if ($this->_status >= 300 && $this->_status < 400) |
|
| 433 | + $isIIS=(stripos($this->getRequest()->getServerSoftware(), "microsoft-iis")!==false); |
|
| 434 | + if($url[0]==='/') |
|
| 435 | + $url=$this->getRequest()->getBaseUrl().$url; |
|
| 436 | + if($this->_status >= 300 && $this->_status < 400) |
|
| 437 | 437 | { |
| 438 | 438 | // The status code has been modified to a valid redirection status, send it |
| 439 | 439 | if($isIIS) |
| 440 | 440 | { |
| 441 | - header('HTTP/1.1 ' . $this->_status . ' ' . self::$HTTP_STATUS_CODES[ |
|
| 441 | + header('HTTP/1.1 '.$this->_status.' '.self::$HTTP_STATUS_CODES[ |
|
| 442 | 442 | array_key_exists($this->_status, self::$HTTP_STATUS_CODES) |
| 443 | 443 | ? $this->_status |
| 444 | 444 | : 302 |
| 445 | 445 | ]); |
| 446 | 446 | } |
| 447 | - header('Location: ' . str_replace('&', '&', $url), true, $this->_status); |
|
| 447 | + header('Location: '.str_replace('&', '&', $url), true, $this->_status); |
|
| 448 | 448 | } else { |
| 449 | 449 | if($isIIS) |
| 450 | - header('HTTP/1.1 302 ' . self::$HTTP_STATUS_CODES[302]); |
|
| 451 | - header('Location: ' . str_replace('&', '&', $url)); |
|
| 450 | + header('HTTP/1.1 302 '.self::$HTTP_STATUS_CODES[302]); |
|
| 451 | + header('Location: '.str_replace('&', '&', $url)); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | if(!$this->getApplication()->getRequestCompleted()) |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | /** |
| 471 | 471 | * Flush the response contents and headers. |
| 472 | 472 | */ |
| 473 | - public function flush($continueBuffering = true) |
|
| 473 | + public function flush($continueBuffering=true) |
|
| 474 | 474 | { |
| 475 | 475 | if($this->getHasAdapter()) |
| 476 | 476 | $this->_adapter->flushContent($continueBuffering); |
@@ -492,18 +492,18 @@ discard block |
||
| 492 | 492 | * This method is used internally. Please use {@link flush} instead. |
| 493 | 493 | * @param boolean whether to continue buffering after flush if buffering was active |
| 494 | 494 | */ |
| 495 | - public function flushContent($continueBuffering = true) |
|
| 495 | + public function flushContent($continueBuffering=true) |
|
| 496 | 496 | { |
| 497 | 497 | Prado::trace("Flushing output", 'Prado\Web\THttpResponse'); |
| 498 | 498 | $this->ensureHeadersSent(); |
| 499 | 499 | if($this->_bufferOutput) |
| 500 | 500 | { |
| 501 | 501 | // avoid forced send of http headers (ob_flush() does that) if there's no output yet |
| 502 | - if (ob_get_length() > 0) |
|
| 502 | + if(ob_get_length() > 0) |
|
| 503 | 503 | { |
| 504 | - if (!$continueBuffering) |
|
| 504 | + if(!$continueBuffering) |
|
| 505 | 505 | { |
| 506 | - $this->_bufferOutput = false; |
|
| 506 | + $this->_bufferOutput=false; |
|
| 507 | 507 | ob_end_flush(); |
| 508 | 508 | } |
| 509 | 509 | else |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | */ |
| 521 | 521 | protected function ensureHttpHeaderSent() |
| 522 | 522 | { |
| 523 | - if (!$this->_httpHeaderSent) |
|
| 523 | + if(!$this->_httpHeaderSent) |
|
| 524 | 524 | $this->sendHttpHeader(); |
| 525 | 525 | } |
| 526 | 526 | |
@@ -529,13 +529,13 @@ discard block |
||
| 529 | 529 | */ |
| 530 | 530 | protected function sendHttpHeader() |
| 531 | 531 | { |
| 532 | - $protocol = $this->getRequest()->getHttpProtocolVersion(); |
|
| 533 | - if($this->getRequest()->getHttpProtocolVersion() === null) |
|
| 534 | - $protocol = 'HTTP/1.1'; |
|
| 532 | + $protocol=$this->getRequest()->getHttpProtocolVersion(); |
|
| 533 | + if($this->getRequest()->getHttpProtocolVersion()===null) |
|
| 534 | + $protocol='HTTP/1.1'; |
|
| 535 | 535 | |
| 536 | - header($protocol . ' ' . $this->_status . ' ' . $this->_reason, true, TPropertyValue::ensureInteger($this->_status)); |
|
| 536 | + header($protocol.' '.$this->_status.' '.$this->_reason, true, TPropertyValue::ensureInteger($this->_status)); |
|
| 537 | 537 | |
| 538 | - $this->_httpHeaderSent = true; |
|
| 538 | + $this->_httpHeaderSent=true; |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | /** |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | protected function ensureContentTypeHeaderSent() |
| 545 | 545 | { |
| 546 | - if (!$this->_contentTypeHeaderSent) |
|
| 546 | + if(!$this->_contentTypeHeaderSent) |
|
| 547 | 547 | $this->sendContentTypeHeader(); |
| 548 | 548 | } |
| 549 | 549 | |
@@ -552,20 +552,20 @@ discard block |
||
| 552 | 552 | */ |
| 553 | 553 | protected function sendContentTypeHeader() |
| 554 | 554 | { |
| 555 | - $contentType = $this->_contentType === null?self::DEFAULT_CONTENTTYPE:$this->_contentType; |
|
| 556 | - $charset = $this->getCharset(); |
|
| 557 | - if($charset === false) { |
|
| 558 | - $this->appendHeader('Content-Type: ' . $contentType); |
|
| 555 | + $contentType=$this->_contentType===null ?self::DEFAULT_CONTENTTYPE : $this->_contentType; |
|
| 556 | + $charset=$this->getCharset(); |
|
| 557 | + if($charset===false) { |
|
| 558 | + $this->appendHeader('Content-Type: '.$contentType); |
|
| 559 | 559 | return; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - if($charset === '' && ($globalization = $this->getApplication()->getGlobalization(false)) !== null) |
|
| 563 | - $charset = $globalization->getCharset(); |
|
| 562 | + if($charset==='' && ($globalization=$this->getApplication()->getGlobalization(false))!==null) |
|
| 563 | + $charset=$globalization->getCharset(); |
|
| 564 | 564 | |
| 565 | - if($charset === '') $charset = self::DEFAULT_CHARSET; |
|
| 566 | - $this->appendHeader('Content-Type: ' . $contentType . ';charset=' . $charset); |
|
| 565 | + if($charset==='') $charset=self::DEFAULT_CHARSET; |
|
| 566 | + $this->appendHeader('Content-Type: '.$contentType.';charset='.$charset); |
|
| 567 | 567 | |
| 568 | - $this->_contentTypeHeaderSent = true; |
|
| 568 | + $this->_contentTypeHeaderSent=true; |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | public function getContents() |
| 578 | 578 | { |
| 579 | 579 | Prado::trace("Retrieving output", 'Prado\Web\THttpResponse'); |
| 580 | - return $this->_bufferOutput?ob_get_contents():''; |
|
| 580 | + return $this->_bufferOutput ?ob_get_contents() : ''; |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | /** |
@@ -594,21 +594,21 @@ discard block |
||
| 594 | 594 | * @param integer|null Either {@link CASE_UPPER} or {@link CASE_LOWER} or as is null (default) |
| 595 | 595 | * @return array |
| 596 | 596 | */ |
| 597 | - public function getHeaders($case = null) |
|
| 597 | + public function getHeaders($case=null) |
|
| 598 | 598 | { |
| 599 | - $result = []; |
|
| 600 | - $headers = headers_list(); |
|
| 599 | + $result=[]; |
|
| 600 | + $headers=headers_list(); |
|
| 601 | 601 | foreach($headers as $header) { |
| 602 | - $tmp = explode(':', $header); |
|
| 603 | - $key = trim(array_shift($tmp)); |
|
| 604 | - $value = trim(implode(':', $tmp)); |
|
| 602 | + $tmp=explode(':', $header); |
|
| 603 | + $key=trim(array_shift($tmp)); |
|
| 604 | + $value=trim(implode(':', $tmp)); |
|
| 605 | 605 | if(isset($result[$key])) |
| 606 | - $result[$key] .= ', ' . $value; |
|
| 606 | + $result[$key].=', '.$value; |
|
| 607 | 607 | else |
| 608 | - $result[$key] = $value; |
|
| 608 | + $result[$key]=$value; |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - if($case !== null) |
|
| 611 | + if($case!==null) |
|
| 612 | 612 | return array_change_key_case($result, $case); |
| 613 | 613 | |
| 614 | 614 | return $result; |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | * @param string header |
| 620 | 620 | * @param boolean whether the header should replace a previous similar header, or add a second header of the same type |
| 621 | 621 | */ |
| 622 | - public function appendHeader($value, $replace = true) |
|
| 622 | + public function appendHeader($value, $replace=true) |
|
| 623 | 623 | { |
| 624 | 624 | Prado::trace("Sending header '$value'", 'Prado\Web\THttpResponse'); |
| 625 | 625 | header($value, $replace); |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | * @param string The extra headers. It's used when the message parameter is set to 1. This message type uses the same internal function as mail() does. |
| 635 | 635 | * @see http://us2.php.net/manual/en/function.error-log.php |
| 636 | 636 | */ |
| 637 | - public function appendLog($message, $messageType = 0, $destination = '', $extraHeaders = '') |
|
| 637 | + public function appendLog($message, $messageType=0, $destination='', $extraHeaders='') |
|
| 638 | 638 | { |
| 639 | 639 | error_log($message, $messageType, $destination, $extraHeaders); |
| 640 | 640 | } |
@@ -646,10 +646,10 @@ discard block |
||
| 646 | 646 | */ |
| 647 | 647 | public function addCookie($cookie) |
| 648 | 648 | { |
| 649 | - $request = $this->getRequest(); |
|
| 649 | + $request=$this->getRequest(); |
|
| 650 | 650 | if($request->getEnableCookieValidation()) |
| 651 | 651 | { |
| 652 | - $value = $this->getApplication()->getSecurityManager()->hashData($cookie->getValue()); |
|
| 652 | + $value=$this->getApplication()->getSecurityManager()->hashData($cookie->getValue()); |
|
| 653 | 653 | setcookie( |
| 654 | 654 | $cookie->getName(), |
| 655 | 655 | $value, |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | */ |
| 705 | 705 | public function setHtmlWriterType($value) |
| 706 | 706 | { |
| 707 | - $this->_htmlWriterType = $value; |
|
| 707 | + $this->_htmlWriterType=$value; |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | /** |
@@ -712,10 +712,10 @@ discard block |
||
| 712 | 712 | * If the type of the HTML writer is not supplied, {@link getHtmlWriterType HtmlWriterType} will be assumed. |
| 713 | 713 | * @param string type of the HTML writer to be created. If null, {@link getHtmlWriterType HtmlWriterType} will be assumed. |
| 714 | 714 | */ |
| 715 | - public function createHtmlWriter($type = null) |
|
| 715 | + public function createHtmlWriter($type=null) |
|
| 716 | 716 | { |
| 717 | - if($type === null) |
|
| 718 | - $type = $this->getHtmlWriterType(); |
|
| 717 | + if($type===null) |
|
| 718 | + $type=$this->getHtmlWriterType(); |
|
| 719 | 719 | if($this->getHasAdapter()) |
| 720 | 720 | return $this->_adapter->createNewHtmlWriter($type, $this); |
| 721 | 721 | else |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | $status = TPropertyValue::ensureInteger($status); |
| 284 | 284 | if(isset(self::$HTTP_STATUS_CODES[$status])) { |
| 285 | 285 | $this->_reason = self::$HTTP_STATUS_CODES[$status]; |
| 286 | - }else{ |
|
| 286 | + } else{ |
|
| 287 | 287 | if($reason === null || $reason === '') { |
| 288 | 288 | throw new TInvalidDataValueException("response_status_reason_missing"); |
| 289 | 289 | } |
@@ -379,8 +379,7 @@ discard block |
||
| 379 | 379 | { |
| 380 | 380 | foreach($headers as $h) |
| 381 | 381 | header($h); |
| 382 | - } |
|
| 383 | - else |
|
| 382 | + } else |
|
| 384 | 383 | { |
| 385 | 384 | header('Pragma: public'); |
| 386 | 385 | header('Expires: 0'); |
@@ -505,13 +504,11 @@ discard block |
||
| 505 | 504 | { |
| 506 | 505 | $this->_bufferOutput = false; |
| 507 | 506 | ob_end_flush(); |
| 508 | - } |
|
| 509 | - else |
|
| 507 | + } else |
|
| 510 | 508 | ob_flush(); |
| 511 | 509 | flush(); |
| 512 | 510 | } |
| 513 | - } |
|
| 514 | - else |
|
| 511 | + } else |
|
| 515 | 512 | flush(); |
| 516 | 513 | } |
| 517 | 514 | |
@@ -659,8 +656,7 @@ discard block |
||
| 659 | 656 | $cookie->getSecure(), |
| 660 | 657 | $cookie->getHttpOnly() |
| 661 | 658 | ); |
| 662 | - } |
|
| 663 | - else { |
|
| 659 | + } else { |
|
| 664 | 660 | setcookie( |
| 665 | 661 | $cookie->getName(), |
| 666 | 662 | $cookie->getValue(), |