@@ -96,6 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * @param boolean whether to allow custom paging |
| 99 | + * @param boolean $value |
|
| 99 | 100 | */ |
| 100 | 101 | public function setCustomPaging($value) |
| 101 | 102 | { |
@@ -143,6 +144,7 @@ discard block |
||
| 143 | 144 | * Raises <b>OnPageIndexChanged</b> event. |
| 144 | 145 | * This event is raised each time when the list changes to a different page. |
| 145 | 146 | * @param TPagedListPageChangedEventParameter event parameter |
| 147 | + * @param TPagedListPageChangedEventParameter|null $param |
|
| 146 | 148 | */ |
| 147 | 149 | public function onPageIndexChanged($param) |
| 148 | 150 | { |
@@ -155,6 +157,7 @@ discard block |
||
| 155 | 157 | * and needs the new page of data. This event can only be raised when |
| 156 | 158 | * {@link setCustomPaging CustomPaging} is true. |
| 157 | 159 | * @param TPagedListFetchDataEventParameter event parameter |
| 160 | + * @param TPagedListFetchDataEventParameter $param |
|
| 158 | 161 | */ |
| 159 | 162 | public function onFetchData($param) |
| 160 | 163 | { |
@@ -290,7 +293,7 @@ discard block |
||
| 290 | 293 | } |
| 291 | 294 | |
| 292 | 295 | /** |
| 293 | - * @return Iterator iterator |
|
| 296 | + * @return \ArrayIterator iterator |
|
| 294 | 297 | */ |
| 295 | 298 | public function getIterator() |
| 296 | 299 | { |
@@ -266,6 +266,7 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | 268 | * Saves the current UrlManager instance to cache. |
| 269 | + * @param TUrlManager $manager |
|
| 269 | 270 | * @return boolean true if UrlManager instance was cached, false otherwise. |
| 270 | 271 | */ |
| 271 | 272 | protected function cacheUrlManager($manager) |
@@ -357,7 +358,7 @@ discard block |
||
| 357 | 358 | } |
| 358 | 359 | |
| 359 | 360 | /** |
| 360 | - * @return THttpRequestUrlFormat the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
| 361 | + * @return string the format of URLs. Defaults to THttpRequestUrlFormat::Get. |
|
| 361 | 362 | */ |
| 362 | 363 | public function getUrlFormat() |
| 363 | 364 | { |
@@ -718,6 +719,7 @@ discard block |
||
| 718 | 719 | * @param array GET parameters, null if not needed |
| 719 | 720 | * @param boolean whether to encode the ampersand in URL, defaults to true. |
| 720 | 721 | * @param boolean whether to encode the GET parameters (their names and values), defaults to false. |
| 722 | + * @param string $serviceID |
|
| 721 | 723 | * @return string URL |
| 722 | 724 | * @see TUrlManager::constructUrl |
| 723 | 725 | */ |
@@ -820,7 +822,7 @@ discard block |
||
| 820 | 822 | /** |
| 821 | 823 | * Returns an iterator for traversing the items in the list. |
| 822 | 824 | * This method is required by the interface \IteratorAggregate. |
| 823 | - * @return Iterator an iterator for traversing the items in the list. |
|
| 825 | + * @return \ArrayIterator an iterator for traversing the items in the list. |
|
| 824 | 826 | */ |
| 825 | 827 | public function getIterator() |
| 826 | 828 | { |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | class THttpRequest extends \Prado\TApplicationComponent implements \IteratorAggregate, \ArrayAccess, \Countable, \Prado\IModule |
| 78 | 78 | { |
| 79 | - const CGIFIX__PATH_INFO = 1; |
|
| 80 | - const CGIFIX__SCRIPT_NAME = 2; |
|
| 79 | + const CGIFIX__PATH_INFO=1; |
|
| 80 | + const CGIFIX__SCRIPT_NAME=2; |
|
| 81 | 81 | /** |
| 82 | 82 | * @var TUrlManager the URL manager module |
| 83 | 83 | */ |
@@ -180,14 +180,14 @@ discard block |
||
| 180 | 180 | if(isset($_SERVER['REQUEST_URI'])) |
| 181 | 181 | $this->_requestUri=$_SERVER['REQUEST_URI']; |
| 182 | 182 | else // TBD: in this case, SCRIPT_NAME need to be escaped |
| 183 | - $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING'])?'':'?'.$_SERVER['QUERY_STRING']); |
|
| 183 | + $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING']) ? '' : '?'.$_SERVER['QUERY_STRING']); |
|
| 184 | 184 | |
| 185 | - if($this->_cgiFix&self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
| 185 | + if($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) |
|
| 186 | 186 | $this->_pathInfo=substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME'])); |
| 187 | 187 | elseif(isset($_SERVER['PATH_INFO'])) |
| 188 | 188 | $this->_pathInfo=$_SERVER['PATH_INFO']; |
| 189 | - else if(strpos($_SERVER['PHP_SELF'],$_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) |
|
| 190 | - $this->_pathInfo=substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME'])); |
|
| 189 | + else if(strpos($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) |
|
| 190 | + $this->_pathInfo=substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])); |
|
| 191 | 191 | else |
| 192 | 192 | $this->_pathInfo=''; |
| 193 | 193 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | public function stripSlashes(&$data) |
| 216 | 216 | { |
| 217 | - return is_array($data)?array_map(array($this,'stripSlashes'),$data):stripslashes($data); |
|
| 217 | + return is_array($data) ? array_map(array($this, 'stripSlashes'), $data) : stripslashes($data); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | if($this->_url===null) |
| 226 | 226 | { |
| 227 | 227 | $secure=$this->getIsSecureConnection(); |
| 228 | - $url=$secure?'https://':'http://'; |
|
| 228 | + $url=$secure ? 'https://' : 'http://'; |
|
| 229 | 229 | if(empty($_SERVER['HTTP_HOST'])) |
| 230 | 230 | { |
| 231 | 231 | $url.=$_SERVER['SERVER_NAME']; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | public function setEnableCache($value) |
| 250 | 250 | { |
| 251 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
| 251 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
@@ -272,15 +272,15 @@ discard block |
||
| 272 | 272 | { |
| 273 | 273 | if($this->getEnableCache()) |
| 274 | 274 | { |
| 275 | - $cache = $this->getApplication()->getCache(); |
|
| 276 | - if($cache !== null) |
|
| 275 | + $cache=$this->getApplication()->getCache(); |
|
| 276 | + if($cache!==null) |
|
| 277 | 277 | { |
| 278 | - $dependencies = null; |
|
| 279 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 280 | - if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
|
| 278 | + $dependencies=null; |
|
| 279 | + if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 280 | + if($manager instanceof TUrlMapping && $fn=$manager->getConfigFile()) |
|
| 281 | 281 | { |
| 282 | - $fn = Prado::getPathOfNamespace($fn,$this->getApplication()->getConfigurationFileExt()); |
|
| 283 | - $dependencies = new TFileCacheDependency($fn); |
|
| 282 | + $fn=Prado::getPathOfNamespace($fn, $this->getApplication()->getConfigurationFileExt()); |
|
| 283 | + $dependencies=new TFileCacheDependency($fn); |
|
| 284 | 284 | } |
| 285 | 285 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
| 286 | 286 | } |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | { |
| 297 | 297 | if($this->getEnableCache()) |
| 298 | 298 | { |
| 299 | - $cache = $this->getApplication()->getCache(); |
|
| 300 | - if($cache !== null) |
|
| 299 | + $cache=$this->getApplication()->getCache(); |
|
| 300 | + if($cache!==null) |
|
| 301 | 301 | { |
| 302 | - $manager = $cache->get($this->getCacheKey()); |
|
| 302 | + $manager=$cache->get($this->getCacheKey()); |
|
| 303 | 303 | if($manager instanceof TUrlManager) |
| 304 | 304 | return $manager; |
| 305 | 305 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | { |
| 336 | 336 | if($this->_urlManager===null) |
| 337 | 337 | { |
| 338 | - if(($this->_urlManager = $this->loadCachedUrlManager())===null) |
|
| 338 | + if(($this->_urlManager=$this->loadCachedUrlManager())===null) |
|
| 339 | 339 | { |
| 340 | 340 | if(empty($this->_urlManagerID)) |
| 341 | 341 | { |
@@ -346,9 +346,9 @@ discard block |
||
| 346 | 346 | { |
| 347 | 347 | $this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID); |
| 348 | 348 | if($this->_urlManager===null) |
| 349 | - throw new TConfigurationException('httprequest_urlmanager_inexist',$this->_urlManagerID); |
|
| 349 | + throw new TConfigurationException('httprequest_urlmanager_inexist', $this->_urlManagerID); |
|
| 350 | 350 | if(!($this->_urlManager instanceof TUrlManager)) |
| 351 | - throw new TConfigurationException('httprequest_urlmanager_invalid',$this->_urlManagerID); |
|
| 351 | + throw new TConfigurationException('httprequest_urlmanager_invalid', $this->_urlManagerID); |
|
| 352 | 352 | } |
| 353 | 353 | $this->cacheUrlManager($this->_urlManager); |
| 354 | 354 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | public function setUrlFormat($value) |
| 376 | 376 | { |
| 377 | - $this->_urlFormat=TPropertyValue::ensureEnum($value,'Prado\\Web\\THttpRequestUrlFormat'); |
|
| 377 | + $this->_urlFormat=TPropertyValue::ensureEnum($value, 'Prado\\Web\\THttpRequestUrlFormat'); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
@@ -402,19 +402,19 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | public function getRequestType() |
| 404 | 404 | { |
| 405 | - return isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:null; |
|
| 405 | + return isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null; |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | /** |
| 409 | 409 | * @param boolean $mimetypeOnly whether to return only the mimetype (default: true) |
| 410 | 410 | * @return string content type (e.g. 'application/json' or 'text/html; encoding=gzip') or null if not specified |
| 411 | 411 | */ |
| 412 | - public function getContentType($mimetypeOnly = true) |
|
| 412 | + public function getContentType($mimetypeOnly=true) |
|
| 413 | 413 | { |
| 414 | 414 | if(!isset($_SERVER['CONTENT_TYPE'])) |
| 415 | 415 | return null; |
| 416 | 416 | |
| 417 | - if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false) |
|
| 417 | + if($mimetypeOnly===true && ($_pos=strpos(';', $_SERVER['CONTENT_TYPE']))!==false) |
|
| 418 | 418 | return substr($_SERVER['CONTENT_TYPE'], 0, $_pos); |
| 419 | 419 | |
| 420 | 420 | return $_SERVER['CONTENT_TYPE']; |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | */ |
| 426 | 426 | public function getIsSecureConnection() |
| 427 | 427 | { |
| 428 | - return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'],'off'); |
|
| 428 | + return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off'); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | /** |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | public function getQueryString() |
| 443 | 443 | { |
| 444 | - return isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:null; |
|
| 444 | + return isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null; |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | /** |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | */ |
| 450 | 450 | public function getHttpProtocolVersion() |
| 451 | 451 | { |
| 452 | - return isset($_SERVER['SERVER_PROTOCOL'])?$_SERVER['SERVER_PROTOCOL']:null; |
|
| 452 | + return isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null; |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | /** |
@@ -460,19 +460,19 @@ discard block |
||
| 460 | 460 | { |
| 461 | 461 | static $result; |
| 462 | 462 | |
| 463 | - if($result === null && function_exists('apache_request_headers')) { |
|
| 464 | - $result = apache_request_headers(); |
|
| 463 | + if($result===null && function_exists('apache_request_headers')) { |
|
| 464 | + $result=apache_request_headers(); |
|
| 465 | 465 | } |
| 466 | - elseif($result === null) { |
|
| 467 | - $result = array(); |
|
| 466 | + elseif($result===null) { |
|
| 467 | + $result=array(); |
|
| 468 | 468 | foreach($_SERVER as $key=>$value) { |
| 469 | - if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
|
| 470 | - $key = str_replace(' ','-', ucwords(strtolower(str_replace('_',' ', substr($key, 5))))); |
|
| 471 | - $result[$key] = $value; |
|
| 469 | + if(strncasecmp($key, 'HTTP_', 5)!==0) continue; |
|
| 470 | + $key=str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5))))); |
|
| 471 | + $result[$key]=$value; |
|
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - if($case !== null) |
|
| 475 | + if($case!==null) |
|
| 476 | 476 | return array_change_key_case($result, $case); |
| 477 | 477 | |
| 478 | 478 | return $result; |
@@ -496,9 +496,9 @@ discard block |
||
| 496 | 496 | public function getBaseUrl($forceSecureConnection=null) |
| 497 | 497 | { |
| 498 | 498 | $url=$this->getUrl(); |
| 499 | - $scheme=($forceSecureConnection)?"https": (($forceSecureConnection === null)?$url->getScheme():'http'); |
|
| 499 | + $scheme=($forceSecureConnection) ? "https" : (($forceSecureConnection===null) ? $url->getScheme() : 'http'); |
|
| 500 | 500 | $host=$url->getHost(); |
| 501 | - if (($port=$url->getPort())) $host.=':'.$port; |
|
| 501 | + if(($port=$url->getPort())) $host.=':'.$port; |
|
| 502 | 502 | return $scheme.'://'.$host; |
| 503 | 503 | } |
| 504 | 504 | |
@@ -507,10 +507,10 @@ discard block |
||
| 507 | 507 | */ |
| 508 | 508 | public function getApplicationUrl() |
| 509 | 509 | { |
| 510 | - if($this->_cgiFix&self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
| 510 | + if($this->_cgiFix & self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) |
|
| 511 | 511 | return $_SERVER['ORIG_SCRIPT_NAME']; |
| 512 | 512 | |
| 513 | - return isset($_SERVER['SCRIPT_NAME'])?$_SERVER['SCRIPT_NAME']:null; |
|
| 513 | + return isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : null; |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | /** |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | */ |
| 523 | 523 | public function getAbsoluteApplicationUrl($forceSecureConnection=null) |
| 524 | 524 | { |
| 525 | - return $this->getBaseUrl($forceSecureConnection) . $this->getApplicationUrl(); |
|
| 525 | + return $this->getBaseUrl($forceSecureConnection).$this->getApplicationUrl(); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | /** |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | */ |
| 531 | 531 | public function getApplicationFilePath() |
| 532 | 532 | { |
| 533 | - return realpath(isset($_SERVER['SCRIPT_FILENAME'])?$_SERVER['SCRIPT_FILENAME']:null); |
|
| 533 | + return realpath(isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : null); |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | /** |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | */ |
| 539 | 539 | public function getServerName() |
| 540 | 540 | { |
| 541 | - return isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:null; |
|
| 541 | + return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null; |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | */ |
| 547 | 547 | public function getServerPort() |
| 548 | 548 | { |
| 549 | - return isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:null; |
|
| 549 | + return isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null; |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | /** |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | */ |
| 555 | 555 | public function getUrlReferrer() |
| 556 | 556 | { |
| 557 | - return isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null; |
|
| 557 | + return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | /** |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | */ |
| 579 | 579 | public function getUserAgent() |
| 580 | 580 | { |
| 581 | - return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null; |
|
| 581 | + return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | */ |
| 587 | 587 | public function getUserHostAddress() |
| 588 | 588 | { |
| 589 | - return isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null; |
|
| 589 | + return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | /** |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | */ |
| 595 | 595 | public function getUserHost() |
| 596 | 596 | { |
| 597 | - return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null; |
|
| 597 | + return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null; |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | /** |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | public function getAcceptTypes() |
| 604 | 604 | { |
| 605 | 605 | // TBD: break it into array?? |
| 606 | - return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null; |
|
| 606 | + return isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null; |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | /** |
@@ -668,13 +668,13 @@ discard block |
||
| 668 | 668 | foreach($_COOKIE as $key=>$value) |
| 669 | 669 | { |
| 670 | 670 | if(($value=$sm->validateData($value))!==false) |
| 671 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
| 671 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
| 672 | 672 | } |
| 673 | 673 | } |
| 674 | 674 | else |
| 675 | 675 | { |
| 676 | 676 | foreach($_COOKIE as $key=>$value) |
| 677 | - $this->_cookies->add(new THttpCookie($key,$value)); |
|
| 677 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
| 678 | 678 | } |
| 679 | 679 | } |
| 680 | 680 | return $this->_cookies; |
@@ -721,13 +721,13 @@ discard block |
||
| 721 | 721 | * @return string URL |
| 722 | 722 | * @see TUrlManager::constructUrl |
| 723 | 723 | */ |
| 724 | - public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
| 724 | + public function constructUrl($serviceID, $serviceParam, $getItems=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
| 725 | 725 | { |
| 726 | - if ($this->_cookieOnly===null) |
|
| 727 | - $this->_cookieOnly=(int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies'); |
|
| 728 | - $url=$this->getUrlManagerModule()->constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems); |
|
| 729 | - if(defined('SID') && SID != '' && !$this->_cookieOnly) |
|
| 730 | - return $url . (strpos($url,'?')===false? '?' : ($encodeAmpersand?'&':'&')) . SID; |
|
| 726 | + if($this->_cookieOnly===null) |
|
| 727 | + $this->_cookieOnly=(int) ini_get('session.use_cookies') && (int) ini_get('session.use_only_cookies'); |
|
| 728 | + $url=$this->getUrlManagerModule()->constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems); |
|
| 729 | + if(defined('SID') && SID!='' && !$this->_cookieOnly) |
|
| 730 | + return $url.(strpos($url, '?')===false ? '?' : ($encodeAmpersand ? '&' : '&')).SID; |
|
| 731 | 731 | else |
| 732 | 732 | return $url; |
| 733 | 733 | } |
@@ -755,11 +755,11 @@ discard block |
||
| 755 | 755 | */ |
| 756 | 756 | public function resolveRequest($serviceIDs) |
| 757 | 757 | { |
| 758 | - Prado::trace("Resolving request from ".$_SERVER['REMOTE_ADDR'],'Prado\Web\THttpRequest'); |
|
| 758 | + Prado::trace("Resolving request from ".$_SERVER['REMOTE_ADDR'], 'Prado\Web\THttpRequest'); |
|
| 759 | 759 | $getParams=$this->parseUrl(); |
| 760 | 760 | foreach($getParams as $name=>$value) |
| 761 | 761 | $_GET[$name]=$value; |
| 762 | - $this->_items=array_merge($_GET,$_POST); |
|
| 762 | + $this->_items=array_merge($_GET, $_POST); |
|
| 763 | 763 | $this->_requestResolved=true; |
| 764 | 764 | foreach($serviceIDs as $serviceID) |
| 765 | 765 | { |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | * @param mixed key |
| 871 | 871 | * @param mixed value |
| 872 | 872 | */ |
| 873 | - public function add($key,$value) |
|
| 873 | + public function add($key, $value) |
|
| 874 | 874 | { |
| 875 | 875 | $this->_items[$key]=$value; |
| 876 | 876 | } |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | */ |
| 884 | 884 | public function remove($key) |
| 885 | 885 | { |
| 886 | - if(isset($this->_items[$key]) || array_key_exists($key,$this->_items)) |
|
| 886 | + if(isset($this->_items[$key]) || array_key_exists($key, $this->_items)) |
|
| 887 | 887 | { |
| 888 | 888 | $value=$this->_items[$key]; |
| 889 | 889 | unset($this->_items[$key]); |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | */ |
| 909 | 909 | public function contains($key) |
| 910 | 910 | { |
| 911 | - return isset($this->_items[$key]) || array_key_exists($key,$this->_items); |
|
| 911 | + return isset($this->_items[$key]) || array_key_exists($key, $this->_items); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | /** |
@@ -947,9 +947,9 @@ discard block |
||
| 947 | 947 | * @param integer the offset to set element |
| 948 | 948 | * @param mixed the element value |
| 949 | 949 | */ |
| 950 | - public function offsetSet($offset,$item) |
|
| 950 | + public function offsetSet($offset, $item) |
|
| 951 | 951 | { |
| 952 | - $this->add($offset,$item); |
|
| 952 | + $this->add($offset, $item); |
|
| 953 | 953 | } |
| 954 | 954 | |
| 955 | 955 | /** |
@@ -13,7 +13,6 @@ |
||
| 13 | 13 | |
| 14 | 14 | use Prado\TPropertyValue; |
| 15 | 15 | use Prado\Exceptions\TNotSupportedException; |
| 16 | -use Prado\Web\Javascripts\TJavaScript; |
|
| 17 | 16 | use Prado\Web\UI\ActiveControls\TActiveTextBox; |
| 18 | 17 | use Prado\Web\UI\INamingContainer; |
| 19 | 18 | |
@@ -12,7 +12,6 @@ |
||
| 12 | 12 | namespace Prado\Web\UI\JuiControls; |
| 13 | 13 | |
| 14 | 14 | use Prado\Exceptions\TNotSupportedException; |
| 15 | -use Prado\Web\Javascripts\TJavaScript; |
|
| 16 | 15 | use Prado\Web\UI\ActiveControls\ICallbackEventHandler; |
| 17 | 16 | use Prado\Web\UI\ActiveControls\TActivePanel; |
| 18 | 17 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function getOptions() |
| 74 | 74 | { |
| 75 | - if (($options=$this->getViewState('JuiOptions'))===null) |
|
| 75 | + if(($options=$this->getViewState('JuiOptions'))===null) |
|
| 76 | 76 | { |
| 77 | 77 | $options=new TJuiControlOptions($this); |
| 78 | 78 | $this->setViewState('JuiOptions', $options); |
@@ -103,14 +103,14 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | protected function getPostBackOptions() |
| 105 | 105 | { |
| 106 | - $options = $this->getOptions()->toArray(); |
|
| 106 | + $options=$this->getOptions()->toArray(); |
|
| 107 | 107 | // always make the dialog a child of the form, or its inner inputs won't be collected |
| 108 | 108 | if(!isset($options['appendTo'])) |
| 109 | - $options['appendTo'] = 'form:first'; |
|
| 109 | + $options['appendTo']='form:first'; |
|
| 110 | 110 | |
| 111 | 111 | foreach($this->getControls() as $control) |
| 112 | 112 | if($control instanceof TJuiDialogButton) |
| 113 | - $options['buttons'][] = $control->getPostBackOptions(); |
|
| 113 | + $options['buttons'][]=$control->getPostBackOptions(); |
|
| 114 | 114 | |
| 115 | 115 | return $options; |
| 116 | 116 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | { |
| 124 | 124 | parent::addAttributesToRender($writer); |
| 125 | 125 | |
| 126 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 126 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 127 | 127 | $options=TJavascript::encode($this->getPostBackOptions()); |
| 128 | 128 | $cs=$this->getPage()->getClientScript(); |
| 129 | 129 | $code="jQuery('#".$this->getWidgetID()."').".$this->getWidget()."(".$options.");"; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * Raises the OnCreate event |
| 145 | 145 | * @param object $params event parameters |
| 146 | 146 | */ |
| 147 | - public function onOpen ($params) |
|
| 147 | + public function onOpen($params) |
|
| 148 | 148 | { |
| 149 | 149 | $this->raiseEvent('OnOpen', $this, $params); |
| 150 | 150 | } |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | private function triggerClientMethod($method) |
| 169 | 169 | { |
| 170 | - $cs = $this->getPage()->getClientScript(); |
|
| 171 | - $code = "jQuery(document).ready(function() { jQuery('#".$this->getClientId()."').dialog('".$method."'); })"; |
|
| 170 | + $cs=$this->getPage()->getClientScript(); |
|
| 171 | + $code="jQuery(document).ready(function() { jQuery('#".$this->getClientId()."').dialog('".$method."'); })"; |
|
| 172 | 172 | $cs->registerEndScript(sprintf('%08X', crc32($code)), $code); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | /** |
| 111 | 111 | * @var boolean |
| 112 | 112 | */ |
| 113 | - private $_cacheInitialized = false; |
|
| 113 | + private $_cacheInitialized=false; |
|
| 114 | 114 | /** |
| 115 | 115 | * @var boolean |
| 116 | 116 | */ |
| 117 | - private $_createCheck= false; |
|
| 117 | + private $_createCheck=false; |
|
| 118 | 118 | /** |
| 119 | 119 | * @var boolean whether the cache DB table should be created automatically |
| 120 | 120 | */ |
@@ -188,20 +188,20 @@ discard block |
||
| 188 | 188 | $db=$this->getDbConnection(); |
| 189 | 189 | try |
| 190 | 190 | { |
| 191 | - $key = 'TDbCache:' . $this->_cacheTable . ':created'; |
|
| 191 | + $key='TDbCache:'.$this->_cacheTable.':created'; |
|
| 192 | 192 | if($force) |
| 193 | - $this -> _createCheck = false; |
|
| 193 | + $this -> _createCheck=false; |
|
| 194 | 194 | else |
| 195 | - $this -> _createCheck = $this -> getApplication() -> getGlobalState($key, 0); |
|
| 195 | + $this -> _createCheck=$this -> getApplication() -> getGlobalState($key, 0); |
|
| 196 | 196 | |
| 197 | 197 | if($this->_autoCreate && !$this -> _createCheck) { |
| 198 | 198 | |
| 199 | - Prado::trace(($force ? 'Force initializing: ' : 'Initializing: ') . $this -> id . ', ' . $this->_cacheTable, '\Prado\Caching\TDbCache'); |
|
| 199 | + Prado::trace(($force ? 'Force initializing: ' : 'Initializing: ').$this -> id.', '.$this->_cacheTable, '\Prado\Caching\TDbCache'); |
|
| 200 | 200 | |
| 201 | 201 | $sql='SELECT 1 FROM '.$this->_cacheTable.' WHERE 0=1'; |
| 202 | 202 | $db->createCommand($sql)->queryScalar(); |
| 203 | 203 | |
| 204 | - $this -> _createCheck = true; |
|
| 204 | + $this -> _createCheck=true; |
|
| 205 | 205 | $this -> getApplication() -> setGlobalState($key, time()); |
| 206 | 206 | } |
| 207 | 207 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | // DB table not exists |
| 211 | 211 | if($this->_autoCreate) |
| 212 | 212 | { |
| 213 | - Prado::trace('Autocreate: ' . $this->_cacheTable, '\Prado\Caching\TDbCache'); |
|
| 213 | + Prado::trace('Autocreate: '.$this->_cacheTable, '\Prado\Caching\TDbCache'); |
|
| 214 | 214 | |
| 215 | 215 | $driver=$db->getDriverName(); |
| 216 | 216 | if($driver==='mysql') |
@@ -223,16 +223,16 @@ discard block |
||
| 223 | 223 | $sql='CREATE TABLE '.$this->_cacheTable." (itemkey CHAR(128) PRIMARY KEY, value $blob, expire INTEGER)"; |
| 224 | 224 | $db->createCommand($sql)->execute(); |
| 225 | 225 | |
| 226 | - $sql='CREATE INDEX IX_expire ON ' . $this->_cacheTable . ' (expire)'; |
|
| 226 | + $sql='CREATE INDEX IX_expire ON '.$this->_cacheTable.' (expire)'; |
|
| 227 | 227 | $db->createCommand($sql)->execute(); |
| 228 | 228 | |
| 229 | - $this -> _createCheck = true; |
|
| 229 | + $this -> _createCheck=true; |
|
| 230 | 230 | $this -> getApplication() -> setGlobalState($key, time()); |
| 231 | 231 | } |
| 232 | 232 | else |
| 233 | - throw new TConfigurationException('db_cachetable_inexistent',$this->_cacheTable); |
|
| 233 | + throw new TConfigurationException('db_cachetable_inexistent', $this->_cacheTable); |
|
| 234 | 234 | } |
| 235 | - $this->_cacheInitialized = true; |
|
| 235 | + $this->_cacheInitialized=true; |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -243,17 +243,17 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | public function flushCacheExpired($force=false) |
| 245 | 245 | { |
| 246 | - $interval = $this -> getFlushInterval(); |
|
| 247 | - if(!$force && $interval === 0) return; |
|
| 246 | + $interval=$this -> getFlushInterval(); |
|
| 247 | + if(!$force && $interval===0) return; |
|
| 248 | 248 | |
| 249 | - $key = 'TDbCache:' . $this->_cacheTable . ':flushed'; |
|
| 250 | - $now = time(); |
|
| 251 | - $next = $interval + (integer)$this -> getApplication() -> getGlobalState($key, 0); |
|
| 249 | + $key='TDbCache:'.$this->_cacheTable.':flushed'; |
|
| 250 | + $now=time(); |
|
| 251 | + $next=$interval + (integer) $this -> getApplication() -> getGlobalState($key, 0); |
|
| 252 | 252 | |
| 253 | 253 | if($force || $next <= $now) |
| 254 | 254 | { |
| 255 | 255 | if(!$this->_cacheInitialized) $this->initializeCache(); |
| 256 | - Prado::trace(($force ? 'Force flush of expired items: ' : 'Flush expired items: ') . $this -> id . ', ' . $this->_cacheTable, '\Prado\Caching\TDbCache'); |
|
| 256 | + Prado::trace(($force ? 'Force flush of expired items: ' : 'Flush expired items: ').$this -> id.', '.$this->_cacheTable, '\Prado\Caching\TDbCache'); |
|
| 257 | 257 | $sql='DELETE FROM '.$this->_cacheTable.' WHERE expire<>0 AND expire<'.$now; |
| 258 | 258 | $this->getDbConnection()->createCommand($sql)->execute(); |
| 259 | 259 | $this -> getApplication() -> setGlobalState($key, $now); |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | */ |
| 281 | 281 | public function setFlushInterval($value) |
| 282 | 282 | { |
| 283 | - $this->_flushInterval = (integer) $value; |
|
| 283 | + $this->_flushInterval=(integer) $value; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | if($config instanceof TDataSourceConfig) |
| 298 | 298 | return $config->getDbConnection(); |
| 299 | 299 | else |
| 300 | - throw new TConfigurationException('dbcache_connectionid_invalid',$this->_connID); |
|
| 300 | + throw new TConfigurationException('dbcache_connectionid_invalid', $this->_connID); |
|
| 301 | 301 | } |
| 302 | 302 | else |
| 303 | 303 | { |
@@ -484,10 +484,10 @@ discard block |
||
| 484 | 484 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 485 | 485 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 486 | 486 | */ |
| 487 | - protected function setValue($key,$value,$expire) |
|
| 487 | + protected function setValue($key, $value, $expire) |
|
| 488 | 488 | { |
| 489 | 489 | $this->deleteValue($key); |
| 490 | - return $this->addValue($key,$value,$expire); |
|
| 490 | + return $this->addValue($key, $value, $expire); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | /** |
@@ -499,16 +499,16 @@ discard block |
||
| 499 | 499 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 500 | 500 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 501 | 501 | */ |
| 502 | - protected function addValue($key,$value,$expire) |
|
| 502 | + protected function addValue($key, $value, $expire) |
|
| 503 | 503 | { |
| 504 | 504 | if(!$this->_cacheInitialized) $this->initializeCache(); |
| 505 | - $expire=($expire<=0)?0:time()+$expire; |
|
| 505 | + $expire=($expire <= 0) ? 0 : time() + $expire; |
|
| 506 | 506 | $sql="INSERT INTO {$this->_cacheTable} (itemkey,value,expire) VALUES(:key,:value,$expire)"; |
| 507 | 507 | try |
| 508 | 508 | { |
| 509 | 509 | $command=$this->getDbConnection()->createCommand($sql); |
| 510 | - $command->bindValue(':key',$key,\PDO::PARAM_STR); |
|
| 511 | - $command->bindValue(':value',serialize($value),\PDO::PARAM_LOB); |
|
| 510 | + $command->bindValue(':key', $key, \PDO::PARAM_STR); |
|
| 511 | + $command->bindValue(':value', serialize($value), \PDO::PARAM_LOB); |
|
| 512 | 512 | $command->execute(); |
| 513 | 513 | return true; |
| 514 | 514 | } |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | try |
| 540 | 540 | { |
| 541 | 541 | $command=$this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable} WHERE itemkey=:key"); |
| 542 | - $command->bindValue(':key',$key,\PDO::PARAM_STR); |
|
| 542 | + $command->bindValue(':key', $key, \PDO::PARAM_STR); |
|
| 543 | 543 | $command->execute(); |
| 544 | 544 | return true; |
| 545 | 545 | } |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | if(!$this->_cacheInitialized) $this->initializeCache(); |
| 561 | 561 | try |
| 562 | 562 | { |
| 563 | - $command = $this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable}"); |
|
| 563 | + $command=$this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable}"); |
|
| 564 | 564 | $command->execute(); |
| 565 | 565 | } |
| 566 | 566 | catch(\Exception $e) |
@@ -111,30 +111,30 @@ discard block |
||
| 111 | 111 | /** |
| 112 | 112 | * @var boolean controls the use of a persistent connection. Default to true. |
| 113 | 113 | */ |
| 114 | - private $_persistence = true; |
|
| 115 | - /** |
|
| 116 | - * @var integer number of buckets to create for this server which in turn control its |
|
| 117 | - * probability of it being selected. The probability is relative to the total weight |
|
| 118 | - * of all servers. |
|
| 119 | - */ |
|
| 120 | - private $_weight = 1; |
|
| 114 | + private $_persistence = true; |
|
| 115 | + /** |
|
| 116 | + * @var integer number of buckets to create for this server which in turn control its |
|
| 117 | + * probability of it being selected. The probability is relative to the total weight |
|
| 118 | + * of all servers. |
|
| 119 | + */ |
|
| 120 | + private $_weight = 1; |
|
| 121 | 121 | |
| 122 | - private $_timeout = 360; |
|
| 122 | + private $_timeout = 360; |
|
| 123 | 123 | |
| 124 | - private $_retryInterval = 15; |
|
| 124 | + private $_retryInterval = 15; |
|
| 125 | 125 | /** |
| 126 | - * @var integer Controls the minimum value length before attempting to compress automatically. |
|
| 127 | - */ |
|
| 128 | - private $_threshold=0; |
|
| 126 | + * @var integer Controls the minimum value length before attempting to compress automatically. |
|
| 127 | + */ |
|
| 128 | + private $_threshold=0; |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | - * @var float Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings. |
|
| 132 | - */ |
|
| 133 | - private $_minSavings=0.0; |
|
| 131 | + * @var float Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings. |
|
| 132 | + */ |
|
| 133 | + private $_minSavings=0.0; |
|
| 134 | 134 | |
| 135 | - private $_status = true; |
|
| 135 | + private $_status = true; |
|
| 136 | 136 | |
| 137 | - private $_failureCallback = null; |
|
| 137 | + private $_failureCallback = null; |
|
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | 140 | * @var boolean whether to use memcached or memcache as the underlying caching extension. |
@@ -178,63 +178,63 @@ discard block |
||
| 178 | 178 | $this->_cache = $this->_useMemcached ? new Memcached : new Memcache; |
| 179 | 179 | $this->loadConfig($config); |
| 180 | 180 | if(count($this->_servers)) |
| 181 | - { |
|
| 182 | - foreach($this->_servers as $server) |
|
| 183 | - { |
|
| 184 | - Prado::trace('Adding server '.$server['Host'].' from serverlist', '\Prado\Caching\TMemCache'); |
|
| 185 | - if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
| 186 | - $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
| 187 | - throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - else |
|
| 191 | - { |
|
| 192 | - Prado::trace('Adding server '.$this->_host, '\Prado\Caching\TMemCache'); |
|
| 193 | - if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
| 194 | - throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
| 195 | - } |
|
| 181 | + { |
|
| 182 | + foreach($this->_servers as $server) |
|
| 183 | + { |
|
| 184 | + Prado::trace('Adding server '.$server['Host'].' from serverlist', '\Prado\Caching\TMemCache'); |
|
| 185 | + if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
| 186 | + $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
| 187 | + throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + else |
|
| 191 | + { |
|
| 192 | + Prado::trace('Adding server '.$this->_host, '\Prado\Caching\TMemCache'); |
|
| 193 | + if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
| 194 | + throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
| 195 | + } |
|
| 196 | 196 | if($this->_threshold!==0) |
| 197 | - $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
| 197 | + $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
| 198 | 198 | $this->_initialized=true; |
| 199 | 199 | parent::init($config); |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - /** |
|
| 202 | + /** |
|
| 203 | 203 | * Loads configuration from an XML element |
| 204 | 204 | * @param TXmlElement configuration node |
| 205 | 205 | * @throws TConfigurationException if log route class or type is not specified |
| 206 | 206 | */ |
| 207 | 207 | private function loadConfig($xml) |
| 208 | 208 | { |
| 209 | - if($xml instanceof TXmlElement) |
|
| 209 | + if($xml instanceof TXmlElement) |
|
| 210 | 210 | { |
| 211 | - foreach($xml->getElementsByTagName('server') as $serverConfig) |
|
| 212 | - { |
|
| 213 | - $properties=$serverConfig->getAttributes(); |
|
| 214 | - if(($host=$properties->remove('Host'))===null) |
|
| 215 | - throw new TConfigurationException('memcache_serverhost_required'); |
|
| 216 | - if(($port=$properties->remove('Port'))===null) |
|
| 217 | - throw new TConfigurationException('memcache_serverport_required'); |
|
| 218 | - if(!is_numeric($port)) |
|
| 219 | - throw new TConfigurationException('memcache_serverport_invalid'); |
|
| 220 | - $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
| 221 | - $checks = array( |
|
| 222 | - 'Weight'=>'memcache_serverweight_invalid', |
|
| 223 | - 'Timeout'=>'memcache_servertimeout_invalid', |
|
| 224 | - 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
|
| 225 | - ); |
|
| 226 | - foreach($checks as $property=>$exception) |
|
| 227 | - { |
|
| 228 | - $value=$properties->remove($property); |
|
| 229 | - if($value!==null && is_numeric($value)) |
|
| 230 | - $server[$property]=$value; |
|
| 231 | - else if($value!==null) |
|
| 232 | - throw new TConfigurationException($exception); |
|
| 233 | - } |
|
| 234 | - $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 235 | - $this->_servers[]=$server; |
|
| 236 | - } |
|
| 237 | - } |
|
| 211 | + foreach($xml->getElementsByTagName('server') as $serverConfig) |
|
| 212 | + { |
|
| 213 | + $properties=$serverConfig->getAttributes(); |
|
| 214 | + if(($host=$properties->remove('Host'))===null) |
|
| 215 | + throw new TConfigurationException('memcache_serverhost_required'); |
|
| 216 | + if(($port=$properties->remove('Port'))===null) |
|
| 217 | + throw new TConfigurationException('memcache_serverport_required'); |
|
| 218 | + if(!is_numeric($port)) |
|
| 219 | + throw new TConfigurationException('memcache_serverport_invalid'); |
|
| 220 | + $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
| 221 | + $checks = array( |
|
| 222 | + 'Weight'=>'memcache_serverweight_invalid', |
|
| 223 | + 'Timeout'=>'memcache_servertimeout_invalid', |
|
| 224 | + 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
|
| 225 | + ); |
|
| 226 | + foreach($checks as $property=>$exception) |
|
| 227 | + { |
|
| 228 | + $value=$properties->remove($property); |
|
| 229 | + if($value!==null && is_numeric($value)) |
|
| 230 | + $server[$property]=$value; |
|
| 231 | + else if($value!==null) |
|
| 232 | + throw new TConfigurationException($exception); |
|
| 233 | + } |
|
| 234 | + $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 235 | + $this->_servers[]=$server; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function setID($id) |
| 63 | 63 | { |
| 64 | - if(strrpos($this->_id,'.wsdl')===strlen($this->_id)-5) |
|
| 65 | - throw new TInvalidDataValueException('soapserver_id_invalid',$id); |
|
| 64 | + if(strrpos($this->_id, '.wsdl')===strlen($this->_id) - 5) |
|
| 65 | + throw new TInvalidDataValueException('soapserver_id_invalid', $id); |
|
| 66 | 66 | $this->_id=$id; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | if(($provider=$this->getProvider())!==null) |
| 75 | 75 | { |
| 76 | 76 | Prado::using($provider); |
| 77 | - $providerClass=($pos=strrpos($provider,'.'))!==false?substr($provider,$pos+1):$provider; |
|
| 77 | + $providerClass=($pos=strrpos($provider, '.'))!==false ? substr($provider, $pos + 1) : $provider; |
|
| 78 | 78 | $this->guessMethodCallRequested($providerClass); |
| 79 | 79 | $server=$this->createServer(); |
| 80 | 80 | $server->setClass($providerClass, $this); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | $server->handle(); |
| 89 | 89 | } |
| 90 | - catch (\Exception $e) |
|
| 90 | + catch(\Exception $e) |
|
| 91 | 91 | { |
| 92 | 92 | if($this->getApplication()->getMode()===TApplicationMode::Debug) |
| 93 | 93 | $this->fault($e->getMessage(), $e->__toString()); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function fault($title, $details='', $code='SERVER', $actor='', $name='') |
| 108 | 108 | { |
| 109 | - Prado::trace('SOAP-Fault '.$code. ' '.$title.' : '.$details, 'Prado\Web\Services\TSoapService'); |
|
| 109 | + Prado::trace('SOAP-Fault '.$code.' '.$title.' : '.$details, 'Prado\Web\Services\TSoapService'); |
|
| 110 | 110 | $this->_server->fault($code, $title, $actor, $details, $name); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -117,14 +117,14 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | protected function guessMethodCallRequested($class) |
| 119 | 119 | { |
| 120 | - $namespace = $class.'wsdl'; |
|
| 121 | - $message = file_get_contents("php://input"); |
|
| 122 | - $matches= array(); |
|
| 120 | + $namespace=$class.'wsdl'; |
|
| 121 | + $message=file_get_contents("php://input"); |
|
| 122 | + $matches=array(); |
|
| 123 | 123 | if(preg_match('/xmlns:([^=]+)="urn:'.$namespace.'"/', $message, $matches)) |
| 124 | 124 | { |
| 125 | 125 | if(preg_match('/<'.$matches[1].':([a-zA-Z_]+[a-zA-Z0-9_]+)/', $message, $method)) |
| 126 | 126 | { |
| 127 | - $this->_requestedMethod = $method[1]; |
|
| 127 | + $this->_requestedMethod=$method[1]; |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | if($this->_server===null) |
| 148 | 148 | { |
| 149 | 149 | if($this->getApplication()->getMode()===TApplicationMode::Debug) |
| 150 | - ini_set("soap.wsdl_cache_enabled",0); |
|
| 151 | - $this->_server = new \SoapServer($this->getWsdlUri(),$this->getOptions()); |
|
| 150 | + ini_set("soap.wsdl_cache_enabled", 0); |
|
| 151 | + $this->_server=new \SoapServer($this->getWsdlUri(), $this->getOptions()); |
|
| 152 | 152 | } |
| 153 | 153 | return $this->_server; |
| 154 | 154 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | if($this->_wsdlUri==='') |
| 190 | 190 | { |
| 191 | 191 | $provider=$this->getProvider(); |
| 192 | - $providerClass=($pos=strrpos($provider,'.'))!==false?substr($provider,$pos+1):$provider; |
|
| 192 | + $providerClass=($pos=strrpos($provider, '.'))!==false ? substr($provider, $pos + 1) : $provider; |
|
| 193 | 193 | Prado::using($provider); |
| 194 | 194 | if($this->getApplication()->getMode()===TApplicationMode::Performance && ($cache=$this->getApplication()->getCache())!==null) |
| 195 | 195 | { |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | if(is_string($wsdl)) |
| 198 | 198 | return $wsdl; |
| 199 | 199 | $wsdl=WsdlGenerator::generate($providerClass, $this->getUri(), $this->getEncoding()); |
| 200 | - $cache->set(self::WSDL_CACHE_PREFIX.$providerClass,$wsdl); |
|
| 200 | + $cache->set(self::WSDL_CACHE_PREFIX.$providerClass, $wsdl); |
|
| 201 | 201 | return $wsdl; |
| 202 | 202 | } |
| 203 | 203 | else |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | public function getWsdlUri() |
| 216 | 216 | { |
| 217 | 217 | if($this->_wsdlUri==='') |
| 218 | - return $this->getRequest()->getBaseUrl().$this->getService()->constructUrl($this->getID().'.wsdl',false); |
|
| 218 | + return $this->getRequest()->getBaseUrl().$this->getService()->constructUrl($this->getID().'.wsdl', false); |
|
| 219 | 219 | else |
| 220 | 220 | return $this->_wsdlUri; |
| 221 | 221 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | public function getUri() |
| 235 | 235 | { |
| 236 | 236 | if($this->_uri==='') |
| 237 | - return $this->getRequest()->getBaseUrl().$this->getService()->constructUrl($this->getID(),false); |
|
| 237 | + return $this->getRequest()->getBaseUrl().$this->getService()->constructUrl($this->getID(), false); |
|
| 238 | 238 | else |
| 239 | 239 | return $this->_uri; |
| 240 | 240 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | if($value==='1.1' || $value==='1.2' || $value==='') |
| 281 | 281 | $this->_version=$value; |
| 282 | 282 | else |
| 283 | - throw new TInvalidDataValueException('soapserver_version_invalid',$value); |
|
| 283 | + throw new TInvalidDataValueException('soapserver_version_invalid', $value); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -344,6 +344,6 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | public function setClassMaps($classes) |
| 346 | 346 | { |
| 347 | - $this->_classMap = $classes; |
|
| 347 | + $this->_classMap=$classes; |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | \ No newline at end of file |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $this->loadConfig($dom); |
| 128 | 128 | } |
| 129 | 129 | else |
| 130 | - throw new TConfigurationException('soapservice_configfile_invalid',$this->_configFile); |
|
| 130 | + throw new TConfigurationException('soapservice_configfile_invalid', $this->_configFile); |
|
| 131 | 131 | } |
| 132 | 132 | $this->loadConfig($config); |
| 133 | 133 | |
@@ -144,16 +144,16 @@ discard block |
||
| 144 | 144 | protected function resolveRequest() |
| 145 | 145 | { |
| 146 | 146 | $serverID=$this->getRequest()->getServiceParameter(); |
| 147 | - if(($pos=strrpos($serverID,'.wsdl'))===strlen($serverID)-5) |
|
| 147 | + if(($pos=strrpos($serverID, '.wsdl'))===strlen($serverID) - 5) |
|
| 148 | 148 | { |
| 149 | - $serverID=substr($serverID,0,$pos); |
|
| 149 | + $serverID=substr($serverID, 0, $pos); |
|
| 150 | 150 | $this->_wsdlRequest=true; |
| 151 | 151 | } |
| 152 | 152 | else |
| 153 | 153 | $this->_wsdlRequest=false; |
| 154 | 154 | $this->_serverID=$serverID; |
| 155 | 155 | if(!isset($this->_servers[$serverID])) |
| 156 | - throw new THttpException(400,'soapservice_request_invalid',$serverID); |
|
| 156 | + throw new THttpException(400, 'soapservice_request_invalid', $serverID); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -169,9 +169,9 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | foreach($config['soap'] as $id => $server) |
| 171 | 171 | { |
| 172 | - $properties = isset($server['properties'])?$server['properties']:array(); |
|
| 172 | + $properties=isset($server['properties']) ? $server['properties'] : array(); |
|
| 173 | 173 | if(isset($this->_servers[$id])) |
| 174 | - throw new TConfigurationException('soapservice_serverid_duplicated',$id); |
|
| 174 | + throw new TConfigurationException('soapservice_serverid_duplicated', $id); |
|
| 175 | 175 | $this->_servers[$id]=$properties; |
| 176 | 176 | } |
| 177 | 177 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | if(($id=$properties->remove('id'))===null) |
| 185 | 185 | throw new TConfigurationException('soapservice_serverid_required'); |
| 186 | 186 | if(isset($this->_servers[$id])) |
| 187 | - throw new TConfigurationException('soapservice_serverid_duplicated',$id); |
|
| 187 | + throw new TConfigurationException('soapservice_serverid_duplicated', $id); |
|
| 188 | 188 | $this->_servers[$id]=$properties; |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function setConfigFile($value) |
| 207 | 207 | { |
| 208 | - if(($this->_configFile=Prado::getPathOfNamespace($value,Prado::getApplication()->getConfigurationFileExt()))===null) |
|
| 209 | - throw new TConfigurationException('soapservice_configfile_invalid',$value); |
|
| 208 | + if(($this->_configFile=Prado::getPathOfNamespace($value, Prado::getApplication()->getConfigurationFileExt()))===null) |
|
| 209 | + throw new TConfigurationException('soapservice_configfile_invalid', $value); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -217,9 +217,9 @@ discard block |
||
| 217 | 217 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
| 218 | 218 | * @return string URL for the page and GET parameters |
| 219 | 219 | */ |
| 220 | - public function constructUrl($serverID,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
| 220 | + public function constructUrl($serverID, $getParams=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
| 221 | 221 | { |
| 222 | - return $this->getRequest()->constructUrl($this->getID(),$serverID,$getParams,$encodeAmpersand,$encodeGetItems); |
|
| 222 | + return $this->getRequest()->constructUrl($this->getID(), $serverID, $getParams, $encodeAmpersand, $encodeGetItems); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -255,13 +255,13 @@ discard block |
||
| 255 | 255 | if($serverClass===null) |
| 256 | 256 | $serverClass=self::DEFAULT_SOAP_SERVER; |
| 257 | 257 | Prado::using($serverClass); |
| 258 | - $className=($pos=strrpos($serverClass,'.'))!==false?substr($serverClass,$pos+1):$serverClass; |
|
| 259 | - if($className!==self::DEFAULT_SOAP_SERVER && !is_subclass_of($className,self::DEFAULT_SOAP_SERVER)) |
|
| 260 | - throw new TConfigurationException('soapservice_server_invalid',$serverClass); |
|
| 258 | + $className=($pos=strrpos($serverClass, '.'))!==false ? substr($serverClass, $pos + 1) : $serverClass; |
|
| 259 | + if($className!==self::DEFAULT_SOAP_SERVER && !is_subclass_of($className, self::DEFAULT_SOAP_SERVER)) |
|
| 260 | + throw new TConfigurationException('soapservice_server_invalid', $serverClass); |
|
| 261 | 261 | $server=new $className; |
| 262 | 262 | $server->setID($this->_serverID); |
| 263 | 263 | foreach($properties as $name=>$value) |
| 264 | - $server->setSubproperty($name,$value); |
|
| 264 | + $server->setSubproperty($name, $value); |
|
| 265 | 265 | return $server; |
| 266 | 266 | } |
| 267 | 267 | |
@@ -273,21 +273,21 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | public function run() |
| 275 | 275 | { |
| 276 | - Prado::trace("Running SOAP service",'Prado\Web\Services\TSoapService'); |
|
| 276 | + Prado::trace("Running SOAP service", 'Prado\Web\Services\TSoapService'); |
|
| 277 | 277 | $server=$this->createServer(); |
| 278 | 278 | $this->getResponse()->setContentType('text/xml'); |
| 279 | 279 | $this->getResponse()->setCharset($server->getEncoding()); |
| 280 | 280 | if($this->getIsWsdlRequest()) |
| 281 | 281 | { |
| 282 | 282 | // server WSDL file |
| 283 | - Prado::trace("Generating WSDL",'Prado\Web\Services\TSoapService'); |
|
| 283 | + Prado::trace("Generating WSDL", 'Prado\Web\Services\TSoapService'); |
|
| 284 | 284 | $this->getResponse()->clear(); |
| 285 | 285 | $this->getResponse()->write($server->getWsdl()); |
| 286 | 286 | } |
| 287 | 287 | else |
| 288 | 288 | { |
| 289 | 289 | // provide SOAP service |
| 290 | - Prado::trace("Handling SOAP request",'Prado\Web\Services\TSoapService'); |
|
| 290 | + Prado::trace("Handling SOAP request", 'Prado\Web\Services\TSoapService'); |
|
| 291 | 291 | $server->run(); |
| 292 | 292 | } |
| 293 | 293 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | /** |
| 105 | 105 | * Prefix of Pages used for instantiating new pages |
| 106 | 106 | */ |
| 107 | - const PAGE_NAMESPACE_PREFIX = 'Application\\Pages\\'; |
|
| 107 | + const PAGE_NAMESPACE_PREFIX='Application\\Pages\\'; |
|
| 108 | 108 | /** |
| 109 | 109 | * @var string root path of pages |
| 110 | 110 | */ |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function init($config) |
| 156 | 156 | { |
| 157 | - Prado::trace("Initializing TPageService",'\Prado\Web\Services\TPageService'); |
|
| 157 | + Prado::trace("Initializing TPageService", '\Prado\Web\Services\TPageService'); |
|
| 158 | 158 | |
| 159 | 159 | $pageConfig=$this->loadPageConfig($config); |
| 160 | 160 | |
@@ -192,15 +192,15 @@ discard block |
||
| 192 | 192 | // external configurations |
| 193 | 193 | foreach($config->getExternalConfigurations() as $filePath=>$params) |
| 194 | 194 | { |
| 195 | - list($configPagePath,$condition)=$params; |
|
| 195 | + list($configPagePath, $condition)=$params; |
|
| 196 | 196 | if($condition!==true) |
| 197 | 197 | $condition=$this->evaluateExpression($condition); |
| 198 | 198 | if($condition) |
| 199 | 199 | { |
| 200 | - if(($path=Prado::getPathOfNamespace($filePath,Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
| 201 | - throw new TConfigurationException('pageservice_includefile_invalid',$filePath); |
|
| 200 | + if(($path=Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) |
|
| 201 | + throw new TConfigurationException('pageservice_includefile_invalid', $filePath); |
|
| 202 | 202 | $c=new TPageConfiguration($pagePath); |
| 203 | - $c->loadFromFile($path,$configPagePath); |
|
| 203 | + $c->loadFromFile($path, $configPagePath); |
|
| 204 | 204 | $this->applyConfiguration($c); |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | if($config!==null) |
| 235 | 235 | { |
| 236 | 236 | if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
| 237 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
| 237 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
| 238 | 238 | else |
| 239 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
| 239 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
| 240 | 240 | } |
| 241 | 241 | $pageConfig->loadFromFiles($this->getBasePath()); |
| 242 | 242 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | $arr=$cache->get(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath); |
| 248 | 248 | if(is_array($arr)) |
| 249 | 249 | { |
| 250 | - list($pageConfig,$timestamps)=$arr; |
|
| 250 | + list($pageConfig, $timestamps)=$arr; |
|
| 251 | 251 | if($application->getMode()!==TApplicationMode::Performance) |
| 252 | 252 | { |
| 253 | 253 | foreach($timestamps as $fileName=>$timestamp) |
@@ -255,14 +255,14 @@ discard block |
||
| 255 | 255 | if($fileName===0) // application config file |
| 256 | 256 | { |
| 257 | 257 | $appConfigFile=$application->getConfigurationFile(); |
| 258 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
| 259 | - if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0])) |
|
| 258 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
| 259 | + if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0])) |
|
| 260 | 260 | $configCached=false; |
| 261 | 261 | } |
| 262 | 262 | else |
| 263 | 263 | { |
| 264 | 264 | $currentTimestamp[$fileName]=@filemtime($fileName); |
| 265 | - if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName])) |
|
| 265 | + if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName])) |
|
| 266 | 266 | $configCached=false; |
| 267 | 267 | } |
| 268 | 268 | } |
@@ -271,9 +271,9 @@ discard block |
||
| 271 | 271 | else |
| 272 | 272 | { |
| 273 | 273 | $configCached=false; |
| 274 | - $paths=explode('.',$pagePath); |
|
| 274 | + $paths=explode('.', $pagePath); |
|
| 275 | 275 | $configPath=$this->getBasePath(); |
| 276 | - $fileName = $this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
| 276 | + $fileName=$this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
| 277 | 277 | ? self::CONFIG_FILE_PHP |
| 278 | 278 | : self::CONFIG_FILE_XML; |
| 279 | 279 | foreach($paths as $path) |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | $configPath.=DIRECTORY_SEPARATOR.$path; |
| 284 | 284 | } |
| 285 | 285 | $appConfigFile=$application->getConfigurationFile(); |
| 286 | - $currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile); |
|
| 286 | + $currentTimestamp[0]=$appConfigFile===null ? 0 : @filemtime($appConfigFile); |
|
| 287 | 287 | } |
| 288 | 288 | if(!$configCached) |
| 289 | 289 | { |
@@ -291,12 +291,12 @@ discard block |
||
| 291 | 291 | if($config!==null) |
| 292 | 292 | { |
| 293 | 293 | if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
| 294 | - $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),''); |
|
| 294 | + $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), ''); |
|
| 295 | 295 | else |
| 296 | - $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),''); |
|
| 296 | + $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), ''); |
|
| 297 | 297 | } |
| 298 | 298 | $pageConfig->loadFromFiles($this->getBasePath()); |
| 299 | - $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath,array($pageConfig,$currentTimestamp)); |
|
| 299 | + $cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath, array($pageConfig, $currentTimestamp)); |
|
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | return $pageConfig; |
@@ -351,9 +351,9 @@ discard block |
||
| 351 | 351 | { |
| 352 | 352 | if($this->_pagePath===null) |
| 353 | 353 | { |
| 354 | - $this->_pagePath=strtr($this->determineRequestedPagePath(),'/\\','..'); |
|
| 354 | + $this->_pagePath=strtr($this->determineRequestedPagePath(), '/\\', '..'); |
|
| 355 | 355 | if(empty($this->_pagePath)) |
| 356 | - throw new THttpException(404,'pageservice_page_required'); |
|
| 356 | + throw new THttpException(404, 'pageservice_page_required'); |
|
| 357 | 357 | } |
| 358 | 358 | return $this->_pagePath; |
| 359 | 359 | } |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | { |
| 407 | 407 | $basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::FALLBACK_BASEPATH; |
| 408 | 408 | if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) |
| 409 | - throw new TConfigurationException('pageservice_basepath_invalid',$basePath); |
|
| 409 | + throw new TConfigurationException('pageservice_basepath_invalid', $basePath); |
|
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | return $this->_basePath; |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | if($this->_initialized) |
| 422 | 422 | throw new TInvalidOperationException('pageservice_basepath_unchangeable'); |
| 423 | 423 | else if(($path=Prado::getPathOfNamespace($value))===null || !is_dir($path)) |
| 424 | - throw new TConfigurationException('pageservice_basepath_invalid',$value); |
|
| 424 | + throw new TConfigurationException('pageservice_basepath_invalid', $value); |
|
| 425 | 425 | $this->_basePath=realpath($path); |
| 426 | 426 | } |
| 427 | 427 | |
@@ -470,9 +470,9 @@ discard block |
||
| 470 | 470 | */ |
| 471 | 471 | public function run() |
| 472 | 472 | { |
| 473 | - Prado::trace("Running page service",'Prado\Web\Services\TPageService'); |
|
| 473 | + Prado::trace("Running page service", 'Prado\Web\Services\TPageService'); |
|
| 474 | 474 | $this->_page=$this->createPage($this->getRequestedPagePath()); |
| 475 | - $this->runPage($this->_page,$this->_properties); |
|
| 475 | + $this->runPage($this->_page, $this->_properties); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | /** |
@@ -484,34 +484,34 @@ discard block |
||
| 484 | 484 | */ |
| 485 | 485 | protected function createPage($pagePath) |
| 486 | 486 | { |
| 487 | - $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath,'.',DIRECTORY_SEPARATOR); |
|
| 487 | + $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath, '.', DIRECTORY_SEPARATOR); |
|
| 488 | 488 | $hasTemplateFile=is_file($path.self::PAGE_FILE_EXT); |
| 489 | 489 | $hasClassFile=is_file($path.Prado::CLASS_FILE_EXT); |
| 490 | 490 | |
| 491 | 491 | if(!$hasTemplateFile && !$hasClassFile) |
| 492 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
| 492 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
| 493 | 493 | |
| 494 | 494 | if($hasClassFile) |
| 495 | 495 | { |
| 496 | 496 | $className=basename($path); |
| 497 | - $namespacedClassName = static::PAGE_NAMESPACE_PREFIX .str_replace('.', '\\', $pagePath); |
|
| 497 | + $namespacedClassName=static::PAGE_NAMESPACE_PREFIX.str_replace('.', '\\', $pagePath); |
|
| 498 | 498 | |
| 499 | - if(!class_exists($className,false) && !class_exists($namespacedClassName, false)) |
|
| 499 | + if(!class_exists($className, false) && !class_exists($namespacedClassName, false)) |
|
| 500 | 500 | include_once($path.Prado::CLASS_FILE_EXT); |
| 501 | 501 | |
| 502 | - if(!class_exists($className,false)) |
|
| 503 | - $className = $namespacedClassName; |
|
| 502 | + if(!class_exists($className, false)) |
|
| 503 | + $className=$namespacedClassName; |
|
| 504 | 504 | } |
| 505 | 505 | else |
| 506 | 506 | { |
| 507 | 507 | $className=$this->getBasePageClass(); |
| 508 | 508 | Prado::using($className); |
| 509 | - if(($pos=strrpos($className,'.'))!==false) |
|
| 510 | - $className=substr($className,$pos+1); |
|
| 509 | + if(($pos=strrpos($className, '.'))!==false) |
|
| 510 | + $className=substr($className, $pos + 1); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - if(!class_exists($className,false) || ($className!=='TPage' && !is_subclass_of($className,'TPage'))) |
|
| 514 | - throw new THttpException(404,'pageservice_page_unknown',$pagePath); |
|
| 513 | + if(!class_exists($className, false) || ($className!=='TPage' && !is_subclass_of($className, 'TPage'))) |
|
| 514 | + throw new THttpException(404, 'pageservice_page_unknown', $pagePath); |
|
| 515 | 515 | |
| 516 | 516 | $page=Prado::createComponent($className); |
| 517 | 517 | $page->setPagePath($pagePath); |
@@ -527,10 +527,10 @@ discard block |
||
| 527 | 527 | * @param TPage the page instance to be run |
| 528 | 528 | * @param array list of initial page properties |
| 529 | 529 | */ |
| 530 | - protected function runPage($page,$properties) |
|
| 530 | + protected function runPage($page, $properties) |
|
| 531 | 531 | { |
| 532 | 532 | foreach($properties as $name=>$value) |
| 533 | - $page->setSubProperty($name,$value); |
|
| 533 | + $page->setSubProperty($name, $value); |
|
| 534 | 534 | $page->run($this->getResponse()->createHtmlWriter()); |
| 535 | 535 | } |
| 536 | 536 | |
@@ -542,8 +542,8 @@ discard block |
||
| 542 | 542 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
| 543 | 543 | * @return string URL for the page and GET parameters |
| 544 | 544 | */ |
| 545 | - public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true) |
|
| 545 | + public function constructUrl($pagePath, $getParams=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
| 546 | 546 | { |
| 547 | - return $this->getRequest()->constructUrl($this->getID(),$pagePath,$getParams,$encodeAmpersand,$encodeGetItems); |
|
| 547 | + return $this->getRequest()->constructUrl($this->getID(), $pagePath, $getParams, $encodeAmpersand, $encodeGetItems); |
|
| 548 | 548 | } |
| 549 | 549 | } |
| 550 | 550 | \ No newline at end of file |