@@ -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 |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | abstract class TJsonResponse extends \Prado\TApplicationComponent |
| 28 | 28 | { |
| 29 | - private $_id = ''; |
|
| 29 | + private $_id=''; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Initializes the feed. |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function setID($value) |
| 51 | 51 | { |
| 52 | - $this->_id = $value; |
|
| 52 | + $this->_id=$value; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -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 | } |
@@ -63,17 +63,17 @@ discard block |
||
| 63 | 63 | /** |
| 64 | 64 | * const string base api provider class which every API must extend |
| 65 | 65 | */ |
| 66 | - const BASE_API_PROVIDER = 'TRpcApiProvider'; |
|
| 66 | + const BASE_API_PROVIDER='TRpcApiProvider'; |
|
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * const string base RPC server implementation |
| 70 | 70 | */ |
| 71 | - const BASE_RPC_SERVER = 'TRpcServer'; |
|
| 71 | + const BASE_RPC_SERVER='TRpcServer'; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * @var array containing mimetype to protocol handler mappings |
| 75 | 75 | */ |
| 76 | - protected $protocolHandlers = [ |
|
| 76 | + protected $protocolHandlers=[ |
|
| 77 | 77 | 'application/json' => 'TJsonRpcProtocol', |
| 78 | 78 | 'text/xml' => 'TXmlRpcProtocol' |
| 79 | 79 | ]; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * @var array containing API provider and their configured properties |
| 83 | 83 | */ |
| 84 | - protected $apiProviders = []; |
|
| 84 | + protected $apiProviders=[]; |
|
| 85 | 85 | |
| 86 | 86 | // methods |
| 87 | 87 | |
@@ -92,27 +92,27 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function createApiProvider(TRpcProtocol $protocolHandler, $providerId) |
| 94 | 94 | { |
| 95 | - $_properties = $this->apiProviders[$providerId]; |
|
| 95 | + $_properties=$this->apiProviders[$providerId]; |
|
| 96 | 96 | |
| 97 | - if(($_providerClass = $_properties->remove('class')) === null) |
|
| 97 | + if(($_providerClass=$_properties->remove('class'))===null) |
|
| 98 | 98 | throw new TConfigurationException('rpcservice_apiprovider_required'); |
| 99 | 99 | |
| 100 | 100 | Prado::using($_providerClass); |
| 101 | 101 | |
| 102 | - $_providerClassName = ($_pos = strrpos($_providerClass, '.')) !== false ? substr($_providerClass, $_pos + 1) : $_providerClass; |
|
| 102 | + $_providerClassName=($_pos=strrpos($_providerClass, '.'))!==false ? substr($_providerClass, $_pos + 1) : $_providerClass; |
|
| 103 | 103 | if(!is_subclass_of($_providerClassName, self::BASE_API_PROVIDER)) |
| 104 | 104 | throw new TConfigurationException('rpcservice_apiprovider_invalid'); |
| 105 | 105 | |
| 106 | - if(($_rpcServerClass = $_properties->remove('server')) === null) |
|
| 107 | - $_rpcServerClass = self::BASE_RPC_SERVER; |
|
| 106 | + if(($_rpcServerClass=$_properties->remove('server'))===null) |
|
| 107 | + $_rpcServerClass=self::BASE_RPC_SERVER; |
|
| 108 | 108 | |
| 109 | 109 | Prado::using($_rpcServerClass); |
| 110 | 110 | |
| 111 | - $_rpcServerClassName = ($_pos = strrpos($_rpcServerClass, '.')) !== false ? substr($_rpcServerClass, $_pos + 1) : $_rpcServerClass; |
|
| 112 | - if($_rpcServerClassName !== self::BASE_RPC_SERVER && !is_subclass_of($_rpcServerClassName, self::BASE_RPC_SERVER)) |
|
| 111 | + $_rpcServerClassName=($_pos=strrpos($_rpcServerClass, '.'))!==false ? substr($_rpcServerClass, $_pos + 1) : $_rpcServerClass; |
|
| 112 | + if($_rpcServerClassName!==self::BASE_RPC_SERVER && !is_subclass_of($_rpcServerClassName, self::BASE_RPC_SERVER)) |
|
| 113 | 113 | throw new TConfigurationException('rpcservice_rpcserver_invalid'); |
| 114 | 114 | |
| 115 | - $_apiProvider = new $_providerClassName(new $_rpcServerClassName($protocolHandler)); |
|
| 115 | + $_apiProvider=new $_providerClassName(new $_rpcServerClassName($protocolHandler)); |
|
| 116 | 116 | $_apiProvider->setId($providerId); |
| 117 | 117 | |
| 118 | 118 | foreach($_properties as $_key => $_value) |
@@ -138,15 +138,15 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | foreach($xml->getElementsByTagName('rpcapi') as $_apiProviderXml) |
| 140 | 140 | { |
| 141 | - $_properties = $_apiProviderXml->getAttributes(); |
|
| 141 | + $_properties=$_apiProviderXml->getAttributes(); |
|
| 142 | 142 | |
| 143 | - if(($_id = $_properties->remove('id')) === null || $_id == "") |
|
| 143 | + if(($_id=$_properties->remove('id'))===null || $_id=="") |
|
| 144 | 144 | throw new TConfigurationException('rpcservice_apiproviderid_required'); |
| 145 | 145 | |
| 146 | 146 | if(isset($this->apiProviders[$_id])) |
| 147 | 147 | throw new TConfigurationException('rpcservice_apiproviderid_duplicated'); |
| 148 | 148 | |
| 149 | - $this->apiProviders[$_id] = $_properties; |
|
| 149 | + $this->apiProviders[$_id]=$_properties; |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
@@ -155,26 +155,26 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function run() |
| 157 | 157 | { |
| 158 | - $_request = $this->getRequest(); |
|
| 158 | + $_request=$this->getRequest(); |
|
| 159 | 159 | |
| 160 | - if(($_providerId = $_request->getServiceParameter()) == "") |
|
| 160 | + if(($_providerId=$_request->getServiceParameter())=="") |
|
| 161 | 161 | throw new THttpException(400, 'RPC API-Provider id required'); |
| 162 | 162 | |
| 163 | - if(($_method = $_request->getRequestType()) != 'POST') |
|
| 164 | - throw new THttpException(405, 'Invalid request method "' . $_method . '"!'); // TODO Exception muss "Allow POST" Header setzen |
|
| 163 | + if(($_method=$_request->getRequestType())!='POST') |
|
| 164 | + throw new THttpException(405, 'Invalid request method "'.$_method.'"!'); // TODO Exception muss "Allow POST" Header setzen |
|
| 165 | 165 | |
| 166 | - if(($_mimeType = $_request->getContentType()) === null) |
|
| 166 | + if(($_mimeType=$_request->getContentType())===null) |
|
| 167 | 167 | throw new THttpException(406, 'Content-Type is missing!'); // TODO Exception muss gültige Content-Type werte zurück geben |
| 168 | 168 | |
| 169 | 169 | if(!in_array($_mimeType, array_keys($this->protocolHandlers))) |
| 170 | 170 | throw new THttpException(406, 'Unsupported Content-Type!'); // TODO see previous |
| 171 | 171 | |
| 172 | - $_protocolHandlerClass = $this->protocolHandlers[$_mimeType]; |
|
| 173 | - $_protocolHandler = new $_protocolHandlerClass; |
|
| 172 | + $_protocolHandlerClass=$this->protocolHandlers[$_mimeType]; |
|
| 173 | + $_protocolHandler=new $_protocolHandlerClass; |
|
| 174 | 174 | |
| 175 | - if(($_result = $this->createApiProvider($_protocolHandler, $_providerId)->processRequest()) !== null) |
|
| 175 | + if(($_result=$this->createApiProvider($_protocolHandler, $_providerId)->processRequest())!==null) |
|
| 176 | 176 | { |
| 177 | - $_response = $this->getResponse(); |
|
| 177 | + $_response=$this->getResponse(); |
|
| 178 | 178 | $_protocolHandler->createResponseHeaders($_response); |
| 179 | 179 | $_response->write($_result); |
| 180 | 180 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | class TFeedService extends \Prado\TService |
| 66 | 66 | { |
| 67 | - private $_feeds = []; |
|
| 67 | + private $_feeds=[]; |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * Initializes this module. |
@@ -73,20 +73,20 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function init($config) |
| 75 | 75 | { |
| 76 | - if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 76 | + if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 77 | 77 | { |
| 78 | 78 | if(is_array($config)) |
| 79 | 79 | { |
| 80 | 80 | foreach($config as $id => $feed) |
| 81 | - $this->_feeds[$id] = $feed; |
|
| 81 | + $this->_feeds[$id]=$feed; |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | else |
| 85 | 85 | { |
| 86 | 86 | foreach($config->getElementsByTagName('feed') as $feed) |
| 87 | 87 | { |
| 88 | - if(($id = $feed->getAttributes()->remove('id')) !== null) |
|
| 89 | - $this->_feeds[$id] = $feed; |
|
| 88 | + if(($id=$feed->getAttributes()->remove('id'))!==null) |
|
| 89 | + $this->_feeds[$id]=$feed; |
|
| 90 | 90 | else |
| 91 | 91 | throw new TConfigurationException('feedservice_id_required'); |
| 92 | 92 | } |
@@ -107,19 +107,19 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function run() |
| 109 | 109 | { |
| 110 | - $id = $this->getRequest()->getServiceParameter(); |
|
| 110 | + $id=$this->getRequest()->getServiceParameter(); |
|
| 111 | 111 | if(isset($this->_feeds[$id])) |
| 112 | 112 | { |
| 113 | - $feedConfig = $this->_feeds[$id]; |
|
| 114 | - $properties = []; |
|
| 115 | - $feed = null; |
|
| 116 | - if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 113 | + $feedConfig=$this->_feeds[$id]; |
|
| 114 | + $properties=[]; |
|
| 115 | + $feed=null; |
|
| 116 | + if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 117 | 117 | { |
| 118 | 118 | if(isset($feedConfig['class'])) |
| 119 | 119 | { |
| 120 | - $feed = Prado::createComponent($feedConfig['class']); |
|
| 120 | + $feed=Prado::createComponent($feedConfig['class']); |
|
| 121 | 121 | if($service instanceof IFeedContentProvider) |
| 122 | - $properties = isset($feedConfig['properties'])?$feedConfig['properties']:[]; |
|
| 122 | + $properties=isset($feedConfig['properties']) ? $feedConfig['properties'] : []; |
|
| 123 | 123 | else |
| 124 | 124 | throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
| 125 | 125 | } |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | else |
| 130 | 130 | { |
| 131 | - $properties = $feedConfig->getAttributes(); |
|
| 132 | - if(($class = $properties->remove('class')) !== null) |
|
| 131 | + $properties=$feedConfig->getAttributes(); |
|
| 132 | + if(($class=$properties->remove('class'))!==null) |
|
| 133 | 133 | { |
| 134 | - $feed = Prado::createComponent($class); |
|
| 134 | + $feed=Prado::createComponent($class); |
|
| 135 | 135 | if(!($feed instanceof IFeedContentProvider)) |
| 136 | 136 | throw new TConfigurationException('feedservice_feedtype_invalid', $id); |
| 137 | 137 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $feed->setSubproperty($name, $value); |
| 145 | 145 | $feed->init($feedConfig); |
| 146 | 146 | |
| 147 | - $content = $feed->getFeedContent(); |
|
| 147 | + $content=$feed->getFeedContent(); |
|
| 148 | 148 | //$this->getResponse()->setContentType('application/rss+xml'); |
| 149 | 149 | $this->getResponse()->setContentType($feed->getContentType()); |
| 150 | 150 | $this->getResponse()->write($content); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | class TJsonRpcProtocol extends TRpcProtocol |
| 28 | 28 | { |
| 29 | 29 | protected $_id; |
| 30 | - protected $_specificationVersion = 1.0; |
|
| 30 | + protected $_specificationVersion=1.0; |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Handles the RPC request |
@@ -38,33 +38,33 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | try |
| 40 | 40 | { |
| 41 | - $_request = $this->decode($requestPayload); |
|
| 41 | + $_request=$this->decode($requestPayload); |
|
| 42 | 42 | |
| 43 | 43 | if(isset($_request['jsonrpc'])) |
| 44 | 44 | { |
| 45 | - $this->_specificationVersion = $_request['jsonrpc']; |
|
| 45 | + $this->_specificationVersion=$_request['jsonrpc']; |
|
| 46 | 46 | if($this->_specificationVersion > 2.0) |
| 47 | 47 | throw new TRpcException('Unsupported specification version', '-32600'); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | if(isset($_request['id'])) |
| 51 | - $this->_id = $_request['id']; |
|
| 51 | + $this->_id=$_request['id']; |
|
| 52 | 52 | |
| 53 | 53 | if(!isset($_request['method'])) |
| 54 | 54 | throw new TRpcException('Missing request method', '-32600'); |
| 55 | 55 | |
| 56 | 56 | if(!isset($_request['params'])) |
| 57 | - $parameters = []; |
|
| 57 | + $parameters=[]; |
|
| 58 | 58 | else |
| 59 | - $parameters = $_request['params']; |
|
| 59 | + $parameters=$_request['params']; |
|
| 60 | 60 | |
| 61 | 61 | if(!is_array($parameters)) |
| 62 | - $parameters = [$parameters]; |
|
| 62 | + $parameters=[$parameters]; |
|
| 63 | 63 | |
| 64 | 64 | // a request without an id is a notification that doesn't need a response |
| 65 | - if($this->_id !== null) |
|
| 65 | + if($this->_id!==null) |
|
| 66 | 66 | { |
| 67 | - if($this->_specificationVersion == 2.0) |
|
| 67 | + if($this->_specificationVersion==2.0) |
|
| 68 | 68 | { |
| 69 | 69 | return $this->encode([ |
| 70 | 70 | 'jsonrpc' => '2.0', |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function createErrorResponse(TRpcException $exception) |
| 103 | 103 | { |
| 104 | - if($this->_specificationVersion == 2.0) |
|
| 104 | + if($this->_specificationVersion==2.0) |
|
| 105 | 105 | { |
| 106 | 106 | return $this->encode([ |
| 107 | 107 | 'id' => $this->_id, |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | public function decode($data) |
| 143 | 143 | { |
| 144 | - $s = json_decode($data, true); |
|
| 144 | + $s=json_decode($data, true); |
|
| 145 | 145 | self::checkJsonError(); |
| 146 | 146 | return $s; |
| 147 | 147 | } |
@@ -153,15 +153,15 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function encode($data) |
| 155 | 155 | { |
| 156 | - $s = json_encode($data); |
|
| 156 | + $s=json_encode($data); |
|
| 157 | 157 | self::checkJsonError(); |
| 158 | 158 | return $s; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | private static function checkJsonError() |
| 162 | 162 | { |
| 163 | - $errnum = json_last_error(); |
|
| 164 | - if($errnum != JSON_ERROR_NONE) |
|
| 163 | + $errnum=json_last_error(); |
|
| 164 | + if($errnum!=JSON_ERROR_NONE) |
|
| 165 | 165 | throw new \Exception("JSON error: $msg", $err); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | public function callApiMethod($methodName, $parameters) |
| 176 | 176 | { |
| 177 | 177 | if(!isset($this->rpcMethods[$methodName])) |
| 178 | - throw new TRpcException('Method "' . $methodName . '" not found', '-32601'); |
|
| 178 | + throw new TRpcException('Method "'.$methodName.'" not found', '-32601'); |
|
| 179 | 179 | |
| 180 | 180 | return call_user_func_array($this->rpcMethods[$methodName]['method'], $parameters); |
| 181 | 181 | } |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | class TSoapService extends \Prado\TService |
| 98 | 98 | { |
| 99 | - const DEFAULT_SOAP_SERVER = 'Prado\Web\Services\TSoapServer'; |
|
| 100 | - private $_servers = []; |
|
| 99 | + const DEFAULT_SOAP_SERVER='Prado\Web\Services\TSoapServer'; |
|
| 100 | + private $_servers=[]; |
|
| 101 | 101 | private $_configFile; |
| 102 | - private $_wsdlRequest = false; |
|
| 102 | + private $_wsdlRequest=false; |
|
| 103 | 103 | private $_serverID; |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function init($config) |
| 121 | 121 | { |
| 122 | - if($this->_configFile !== null) |
|
| 122 | + if($this->_configFile!==null) |
|
| 123 | 123 | { |
| 124 | 124 | if(is_file($this->_configFile)) |
| 125 | 125 | { |
| 126 | - $dom = new TXmlDocument; |
|
| 126 | + $dom=new TXmlDocument; |
|
| 127 | 127 | $dom->loadFromFile($this->_configFile); |
| 128 | 128 | $this->loadConfig($dom); |
| 129 | 129 | } |
@@ -144,15 +144,15 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | protected function resolveRequest() |
| 146 | 146 | { |
| 147 | - $serverID = $this->getRequest()->getServiceParameter(); |
|
| 148 | - if(($pos = strrpos($serverID, '.wsdl')) === strlen($serverID) - 5) |
|
| 147 | + $serverID=$this->getRequest()->getServiceParameter(); |
|
| 148 | + if(($pos=strrpos($serverID, '.wsdl'))===strlen($serverID) - 5) |
|
| 149 | 149 | { |
| 150 | - $serverID = substr($serverID, 0, $pos); |
|
| 151 | - $this->_wsdlRequest = true; |
|
| 150 | + $serverID=substr($serverID, 0, $pos); |
|
| 151 | + $this->_wsdlRequest=true; |
|
| 152 | 152 | } |
| 153 | 153 | else |
| 154 | - $this->_wsdlRequest = false; |
|
| 155 | - $this->_serverID = $serverID; |
|
| 154 | + $this->_wsdlRequest=false; |
|
| 155 | + $this->_serverID=$serverID; |
|
| 156 | 156 | if(!isset($this->_servers[$serverID])) |
| 157 | 157 | throw new THttpException(400, 'soapservice_request_invalid', $serverID); |
| 158 | 158 | } |
@@ -164,16 +164,16 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | private function loadConfig($config) |
| 166 | 166 | { |
| 167 | - if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 167 | + if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 168 | 168 | { |
| 169 | 169 | if(is_array($config)) |
| 170 | 170 | { |
| 171 | 171 | foreach($config['soap'] as $id => $server) |
| 172 | 172 | { |
| 173 | - $properties = isset($server['properties'])?$server['properties']:[]; |
|
| 173 | + $properties=isset($server['properties']) ? $server['properties'] : []; |
|
| 174 | 174 | if(isset($this->_servers[$id])) |
| 175 | 175 | throw new TConfigurationException('soapservice_serverid_duplicated', $id); |
| 176 | - $this->_servers[$id] = $properties; |
|
| 176 | + $this->_servers[$id]=$properties; |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -181,12 +181,12 @@ discard block |
||
| 181 | 181 | { |
| 182 | 182 | foreach($config->getElementsByTagName('soap') as $serverXML) |
| 183 | 183 | { |
| 184 | - $properties = $serverXML->getAttributes(); |
|
| 185 | - if(($id = $properties->remove('id')) === null) |
|
| 184 | + $properties=$serverXML->getAttributes(); |
|
| 185 | + if(($id=$properties->remove('id'))===null) |
|
| 186 | 186 | throw new TConfigurationException('soapservice_serverid_required'); |
| 187 | 187 | if(isset($this->_servers[$id])) |
| 188 | 188 | throw new TConfigurationException('soapservice_serverid_duplicated', $id); |
| 189 | - $this->_servers[$id] = $properties; |
|
| 189 | + $this->_servers[$id]=$properties; |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public function setConfigFile($value) |
| 208 | 208 | { |
| 209 | - if(($this->_configFile = Prado::getPathOfNamespace($value, Prado::getApplication()->getConfigurationFileExt())) === null) |
|
| 209 | + if(($this->_configFile=Prado::getPathOfNamespace($value, Prado::getApplication()->getConfigurationFileExt()))===null) |
|
| 210 | 210 | throw new TConfigurationException('soapservice_configfile_invalid', $value); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * @param boolean whether to encode the GET parameters (their names and values), defaults to true. |
| 219 | 219 | * @return string URL for the page and GET parameters |
| 220 | 220 | */ |
| 221 | - public function constructUrl($serverID, $getParams = null, $encodeAmpersand = true, $encodeGetItems = true) |
|
| 221 | + public function constructUrl($serverID, $getParams=null, $encodeAmpersand=true, $encodeGetItems=true) |
|
| 222 | 222 | { |
| 223 | 223 | return $this->getRequest()->constructUrl($this->getID(), $serverID, $getParams, $encodeAmpersand, $encodeGetItems); |
| 224 | 224 | } |
@@ -247,19 +247,19 @@ discard block |
||
| 247 | 247 | */ |
| 248 | 248 | protected function createServer() |
| 249 | 249 | { |
| 250 | - $properties = $this->_servers[$this->_serverID]; |
|
| 251 | - $serverClass = null; |
|
| 252 | - if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP && isset($config['class'])) |
|
| 253 | - $serverClass = $config['class']; |
|
| 254 | - elseif($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML) |
|
| 255 | - $serverClass = $properties->remove('class'); |
|
| 256 | - if($serverClass === null) |
|
| 257 | - $serverClass = self::DEFAULT_SOAP_SERVER; |
|
| 250 | + $properties=$this->_servers[$this->_serverID]; |
|
| 251 | + $serverClass=null; |
|
| 252 | + if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP && isset($config['class'])) |
|
| 253 | + $serverClass=$config['class']; |
|
| 254 | + elseif($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_XML) |
|
| 255 | + $serverClass=$properties->remove('class'); |
|
| 256 | + if($serverClass===null) |
|
| 257 | + $serverClass=self::DEFAULT_SOAP_SERVER; |
|
| 258 | 258 | Prado::using($serverClass); |
| 259 | - $className = ($pos = strrpos($serverClass, '.')) !== false?substr($serverClass, $pos + 1):$serverClass; |
|
| 260 | - if($className !== self::DEFAULT_SOAP_SERVER && !is_subclass_of($className, self::DEFAULT_SOAP_SERVER)) |
|
| 259 | + $className=($pos=strrpos($serverClass, '.'))!==false ?substr($serverClass, $pos + 1) : $serverClass; |
|
| 260 | + if($className!==self::DEFAULT_SOAP_SERVER && !is_subclass_of($className, self::DEFAULT_SOAP_SERVER)) |
|
| 261 | 261 | throw new TConfigurationException('soapservice_server_invalid', $serverClass); |
| 262 | - $server = new $className; |
|
| 262 | + $server=new $className; |
|
| 263 | 263 | $server->setID($this->_serverID); |
| 264 | 264 | foreach($properties as $name => $value) |
| 265 | 265 | $server->setSubproperty($name, $value); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | public function run() |
| 276 | 276 | { |
| 277 | 277 | Prado::trace("Running SOAP service", 'Prado\Web\Services\TSoapService'); |
| 278 | - $server = $this->createServer(); |
|
| 278 | + $server=$this->createServer(); |
|
| 279 | 279 | $this->getResponse()->setContentType('text/xml'); |
| 280 | 280 | $this->getResponse()->setCharset($server->getEncoding()); |
| 281 | 281 | if($this->getIsWsdlRequest()) |
@@ -31,18 +31,18 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | class TSoapServer extends \Prado\TApplicationComponent |
| 33 | 33 | { |
| 34 | - const WSDL_CACHE_PREFIX = 'wsdl.'; |
|
| 34 | + const WSDL_CACHE_PREFIX='wsdl.'; |
|
| 35 | 35 | |
| 36 | 36 | private $_id; |
| 37 | 37 | private $_provider; |
| 38 | 38 | |
| 39 | - private $_version = ''; |
|
| 40 | - private $_actor = ''; |
|
| 41 | - private $_encoding = ''; |
|
| 42 | - private $_uri = ''; |
|
| 39 | + private $_version=''; |
|
| 40 | + private $_actor=''; |
|
| 41 | + private $_encoding=''; |
|
| 42 | + private $_uri=''; |
|
| 43 | 43 | private $_classMap; |
| 44 | - private $_persistent = false; |
|
| 45 | - private $_wsdlUri = ''; |
|
| 44 | + private $_persistent=false; |
|
| 45 | + private $_wsdlUri=''; |
|
| 46 | 46 | |
| 47 | 47 | private $_requestedMethod; |
| 48 | 48 | |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function setID($id) |
| 64 | 64 | { |
| 65 | - if(strrpos($this->_id, '.wsdl') === strlen($this->_id) - 5) |
|
| 65 | + if(strrpos($this->_id, '.wsdl')===strlen($this->_id) - 5) |
|
| 66 | 66 | throw new TInvalidDataValueException('soapserver_id_invalid', $id); |
| 67 | - $this->_id = $id; |
|
| 67 | + $this->_id=$id; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -72,25 +72,25 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function run() |
| 74 | 74 | { |
| 75 | - if(($provider = $this->getProvider()) !== null) |
|
| 75 | + if(($provider=$this->getProvider())!==null) |
|
| 76 | 76 | { |
| 77 | 77 | Prado::using($provider); |
| 78 | - $providerClass = ($pos = strrpos($provider, '.')) !== false?substr($provider, $pos + 1):$provider; |
|
| 78 | + $providerClass=($pos=strrpos($provider, '.'))!==false ?substr($provider, $pos + 1) : $provider; |
|
| 79 | 79 | $this->guessMethodCallRequested($providerClass); |
| 80 | - $server = $this->createServer(); |
|
| 80 | + $server=$this->createServer(); |
|
| 81 | 81 | $server->setClass($providerClass, $this); |
| 82 | 82 | if($this->_persistent) |
| 83 | 83 | $server->setPersistence(SOAP_PERSISTENCE_SESSION); |
| 84 | 84 | } |
| 85 | 85 | else |
| 86 | - $server = $this->createServer(); |
|
| 86 | + $server=$this->createServer(); |
|
| 87 | 87 | try |
| 88 | 88 | { |
| 89 | 89 | $server->handle(); |
| 90 | 90 | } |
| 91 | - catch (\Exception $e) |
|
| 91 | + catch(\Exception $e) |
|
| 92 | 92 | { |
| 93 | - if($this->getApplication()->getMode() === TApplicationMode::Debug) |
|
| 93 | + if($this->getApplication()->getMode()===TApplicationMode::Debug) |
|
| 94 | 94 | $this->fault($e->getMessage(), $e->__toString()); |
| 95 | 95 | else |
| 96 | 96 | $this->fault($e->getMessage()); |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | * @param string actors |
| 106 | 106 | * @param string message name |
| 107 | 107 | */ |
| 108 | - public function fault($title, $details = '', $code = 'SERVER', $actor = '', $name = '') |
|
| 108 | + public function fault($title, $details='', $code='SERVER', $actor='', $name='') |
|
| 109 | 109 | { |
| 110 | - Prado::trace('SOAP-Fault ' . $code . ' ' . $title . ' : ' . $details, 'Prado\Web\Services\TSoapService'); |
|
| 110 | + Prado::trace('SOAP-Fault '.$code.' '.$title.' : '.$details, 'Prado\Web\Services\TSoapService'); |
|
| 111 | 111 | $this->_server->fault($code, $title, $actor, $details, $name); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -118,14 +118,14 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | protected function guessMethodCallRequested($class) |
| 120 | 120 | { |
| 121 | - $namespace = $class . 'wsdl'; |
|
| 122 | - $message = file_get_contents("php://input"); |
|
| 123 | - $matches = []; |
|
| 124 | - if(preg_match('/xmlns:([^=]+)="urn:' . $namespace . '"/', $message, $matches)) |
|
| 121 | + $namespace=$class.'wsdl'; |
|
| 122 | + $message=file_get_contents("php://input"); |
|
| 123 | + $matches=[]; |
|
| 124 | + if(preg_match('/xmlns:([^=]+)="urn:'.$namespace.'"/', $message, $matches)) |
|
| 125 | 125 | { |
| 126 | - if(preg_match('/<' . $matches[1] . ':([a-zA-Z_]+[a-zA-Z0-9_]+)/', $message, $method)) |
|
| 126 | + if(preg_match('/<'.$matches[1].':([a-zA-Z_]+[a-zA-Z0-9_]+)/', $message, $method)) |
|
| 127 | 127 | { |
| 128 | - $this->_requestedMethod = $method[1]; |
|
| 128 | + $this->_requestedMethod=$method[1]; |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -145,11 +145,11 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | protected function createServer() |
| 147 | 147 | { |
| 148 | - if($this->_server === null) |
|
| 148 | + if($this->_server===null) |
|
| 149 | 149 | { |
| 150 | - if($this->getApplication()->getMode() === TApplicationMode::Debug) |
|
| 150 | + if($this->getApplication()->getMode()===TApplicationMode::Debug) |
|
| 151 | 151 | ini_set("soap.wsdl_cache_enabled", 0); |
| 152 | - $this->_server = new \SoapServer($this->getWsdlUri(), $this->getOptions()); |
|
| 152 | + $this->_server=new \SoapServer($this->getWsdlUri(), $this->getOptions()); |
|
| 153 | 153 | } |
| 154 | 154 | return $this->_server; |
| 155 | 155 | } |
@@ -159,21 +159,21 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | protected function getOptions() |
| 161 | 161 | { |
| 162 | - $options = []; |
|
| 163 | - if($this->_version === '1.1') |
|
| 164 | - $options['soap_version'] = SOAP_1_1; |
|
| 165 | - elseif($this->_version === '1.2') |
|
| 166 | - $options['soap_version'] = SOAP_1_2; |
|
| 162 | + $options=[]; |
|
| 163 | + if($this->_version==='1.1') |
|
| 164 | + $options['soap_version']=SOAP_1_1; |
|
| 165 | + elseif($this->_version==='1.2') |
|
| 166 | + $options['soap_version']=SOAP_1_2; |
|
| 167 | 167 | if(!empty($this->_actor)) |
| 168 | - $options['actor'] = $this->_actor; |
|
| 168 | + $options['actor']=$this->_actor; |
|
| 169 | 169 | if(!empty($this->_encoding)) |
| 170 | - $options['encoding'] = $this->_encoding; |
|
| 170 | + $options['encoding']=$this->_encoding; |
|
| 171 | 171 | if(!empty($this->_uri)) |
| 172 | - $options['uri'] = $this->_uri; |
|
| 172 | + $options['uri']=$this->_uri; |
|
| 173 | 173 | if(is_string($this->_classMap)) |
| 174 | 174 | { |
| 175 | 175 | foreach(preg_split('/\s*,\s*/', $this->_classMap) as $className) |
| 176 | - $options['classmap'][$className] = $className; //complex type uses the class name in the wsdl |
|
| 176 | + $options['classmap'][$className]=$className; //complex type uses the class name in the wsdl |
|
| 177 | 177 | } |
| 178 | 178 | return $options; |
| 179 | 179 | } |
@@ -187,18 +187,18 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function getWsdl() |
| 189 | 189 | { |
| 190 | - if($this->_wsdlUri === '') |
|
| 190 | + if($this->_wsdlUri==='') |
|
| 191 | 191 | { |
| 192 | - $provider = $this->getProvider(); |
|
| 193 | - $providerClass = ($pos = strrpos($provider, '.')) !== false?substr($provider, $pos + 1):$provider; |
|
| 192 | + $provider=$this->getProvider(); |
|
| 193 | + $providerClass=($pos=strrpos($provider, '.'))!==false ?substr($provider, $pos + 1) : $provider; |
|
| 194 | 194 | Prado::using($provider); |
| 195 | - if($this->getApplication()->getMode() === TApplicationMode::Performance && ($cache = $this->getApplication()->getCache()) !== null) |
|
| 195 | + if($this->getApplication()->getMode()===TApplicationMode::Performance && ($cache=$this->getApplication()->getCache())!==null) |
|
| 196 | 196 | { |
| 197 | - $wsdl = $cache->get(self::WSDL_CACHE_PREFIX . $providerClass); |
|
| 197 | + $wsdl=$cache->get(self::WSDL_CACHE_PREFIX.$providerClass); |
|
| 198 | 198 | if(is_string($wsdl)) |
| 199 | 199 | return $wsdl; |
| 200 | - $wsdl = WsdlGenerator::generate($providerClass, $this->getUri(), $this->getEncoding()); |
|
| 201 | - $cache->set(self::WSDL_CACHE_PREFIX . $providerClass, $wsdl); |
|
| 200 | + $wsdl=WsdlGenerator::generate($providerClass, $this->getUri(), $this->getEncoding()); |
|
| 201 | + $cache->set(self::WSDL_CACHE_PREFIX.$providerClass, $wsdl); |
|
| 202 | 202 | return $wsdl; |
| 203 | 203 | } |
| 204 | 204 | else |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public function getWsdlUri() |
| 217 | 217 | { |
| 218 | - if($this->_wsdlUri === '') |
|
| 219 | - return $this->getRequest()->getBaseUrl() . $this->getService()->constructUrl($this->getID() . '.wsdl', false); |
|
| 218 | + if($this->_wsdlUri==='') |
|
| 219 | + return $this->getRequest()->getBaseUrl().$this->getService()->constructUrl($this->getID().'.wsdl', false); |
|
| 220 | 220 | else |
| 221 | 221 | return $this->_wsdlUri; |
| 222 | 222 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | public function setWsdlUri($value) |
| 228 | 228 | { |
| 229 | - $this->_wsdlUri = $value; |
|
| 229 | + $this->_wsdlUri=$value; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -234,8 +234,8 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | public function getUri() |
| 236 | 236 | { |
| 237 | - if($this->_uri === '') |
|
| 238 | - return $this->getRequest()->getBaseUrl() . $this->getService()->constructUrl($this->getID(), false); |
|
| 237 | + if($this->_uri==='') |
|
| 238 | + return $this->getRequest()->getBaseUrl().$this->getService()->constructUrl($this->getID(), false); |
|
| 239 | 239 | else |
| 240 | 240 | return $this->_uri; |
| 241 | 241 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public function setUri($uri) |
| 247 | 247 | { |
| 248 | - $this->_uri = $uri; |
|
| 248 | + $this->_uri=$uri; |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | public function setProvider($provider) |
| 263 | 263 | { |
| 264 | - $this->_provider = $provider; |
|
| 264 | + $this->_provider=$provider; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
@@ -278,8 +278,8 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | public function setVersion($value) |
| 280 | 280 | { |
| 281 | - if($value === '1.1' || $value === '1.2' || $value === '') |
|
| 282 | - $this->_version = $value; |
|
| 281 | + if($value==='1.1' || $value==='1.2' || $value==='') |
|
| 282 | + $this->_version=$value; |
|
| 283 | 283 | else |
| 284 | 284 | throw new TInvalidDataValueException('soapserver_version_invalid', $value); |
| 285 | 285 | } |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | public function setActor($value) |
| 299 | 299 | { |
| 300 | - $this->_actor = $value; |
|
| 300 | + $this->_actor=$value; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | public function setEncoding($value) |
| 315 | 315 | { |
| 316 | - $this->_encoding = $value; |
|
| 316 | + $this->_encoding=$value; |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | public function setSessionPersistent($value) |
| 331 | 331 | { |
| 332 | - $this->_persistent = TPropertyValue::ensureBoolean($value); |
|
| 332 | + $this->_persistent=TPropertyValue::ensureBoolean($value); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -345,6 +345,6 @@ discard block |
||
| 345 | 345 | */ |
| 346 | 346 | public function setClassMaps($classes) |
| 347 | 347 | { |
| 348 | - $this->_classMap = $classes; |
|
| 348 | + $this->_classMap=$classes; |
|
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | \ No newline at end of file |
@@ -36,23 +36,23 @@ discard block |
||
| 36 | 36 | /** |
| 37 | 37 | * @var array list of application configurations |
| 38 | 38 | */ |
| 39 | - private $_appConfigs = []; |
|
| 39 | + private $_appConfigs=[]; |
|
| 40 | 40 | /** |
| 41 | 41 | * @var array list of page initial property values |
| 42 | 42 | */ |
| 43 | - private $_properties = []; |
|
| 43 | + private $_properties=[]; |
|
| 44 | 44 | /** |
| 45 | 45 | * @var TAuthorizationRuleCollection list of authorization rules |
| 46 | 46 | */ |
| 47 | - private $_rules = []; |
|
| 47 | + private $_rules=[]; |
|
| 48 | 48 | /** |
| 49 | 49 | * @var array list of included configurations |
| 50 | 50 | */ |
| 51 | - private $_includes = []; |
|
| 51 | + private $_includes=[]; |
|
| 52 | 52 | /** |
| 53 | 53 | * @var string the currently request page in the format of Path.To.PageName |
| 54 | 54 | */ |
| 55 | - private $_pagePath = ''; |
|
| 55 | + private $_pagePath=''; |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Constructor. |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function __construct($pagePath) |
| 62 | 62 | { |
| 63 | - $this->_pagePath = $pagePath; |
|
| 63 | + $this->_pagePath=$pagePath; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -107,24 +107,24 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function loadFromFiles($basePath) |
| 109 | 109 | { |
| 110 | - $paths = explode('.', $this->_pagePath); |
|
| 111 | - $page = array_pop($paths); |
|
| 112 | - $path = $basePath; |
|
| 113 | - $configPagePath = ''; |
|
| 114 | - $fileName = Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP |
|
| 110 | + $paths=explode('.', $this->_pagePath); |
|
| 111 | + $page=array_pop($paths); |
|
| 112 | + $path=$basePath; |
|
| 113 | + $configPagePath=''; |
|
| 114 | + $fileName=Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP |
|
| 115 | 115 | ? TPageService::CONFIG_FILE_PHP |
| 116 | 116 | : TPageService::CONFIG_FILE_XML; |
| 117 | 117 | foreach($paths as $p) |
| 118 | 118 | { |
| 119 | - $this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath); |
|
| 120 | - $path .= DIRECTORY_SEPARATOR . $p; |
|
| 121 | - if($configPagePath === '') |
|
| 122 | - $configPagePath = $p; |
|
| 119 | + $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath); |
|
| 120 | + $path.=DIRECTORY_SEPARATOR.$p; |
|
| 121 | + if($configPagePath==='') |
|
| 122 | + $configPagePath=$p; |
|
| 123 | 123 | else |
| 124 | - $configPagePath .= '.' . $p; |
|
| 124 | + $configPagePath.='.'.$p; |
|
| 125 | 125 | } |
| 126 | - $this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath); |
|
| 127 | - $this->_rules = new TAuthorizationRuleCollection($this->_rules); |
|
| 126 | + $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath); |
|
| 127 | + $this->_rules=new TAuthorizationRuleCollection($this->_rules); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | if(empty($fname) || !is_file($fname)) |
| 139 | 139 | return; |
| 140 | 140 | |
| 141 | - if(Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 141 | + if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 142 | 142 | { |
| 143 | - $fcontent = include $fname; |
|
| 143 | + $fcontent=include $fname; |
|
| 144 | 144 | $this->loadFromPhp($fcontent, dirname($fname), $configPagePath); |
| 145 | 145 | } |
| 146 | 146 | else |
| 147 | 147 | { |
| 148 | - $dom = new TXmlDocument; |
|
| 148 | + $dom=new TXmlDocument; |
|
| 149 | 149 | if($dom->loadFromFile($fname)) |
| 150 | 150 | $this->loadFromXml($dom, dirname($fname), $configPagePath); |
| 151 | 151 | else |
@@ -175,9 +175,9 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | public function loadApplicationConfigurationFromPhp($config, $configPath) |
| 177 | 177 | { |
| 178 | - $appConfig = new TApplicationConfiguration; |
|
| 178 | + $appConfig=new TApplicationConfiguration; |
|
| 179 | 179 | $appConfig->loadFromPhp($config, $configPath); |
| 180 | - $this->_appConfigs[] = $appConfig; |
|
| 180 | + $this->_appConfigs[]=$appConfig; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -187,9 +187,9 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function loadApplicationConfigurationFromXml($dom, $configPath) |
| 189 | 189 | { |
| 190 | - $appConfig = new TApplicationConfiguration; |
|
| 190 | + $appConfig=new TApplicationConfiguration; |
|
| 191 | 191 | $appConfig->loadFromXml($dom, $configPath); |
| 192 | - $this->_appConfigs[] = $appConfig; |
|
| 192 | + $this->_appConfigs[]=$appConfig; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | public function loadPageConfigurationFromPhp($config, $configPath, $configPagePath) |
@@ -197,32 +197,32 @@ discard block |
||
| 197 | 197 | // authorization |
| 198 | 198 | if(isset($config['authorization']) && is_array($config['authorization'])) |
| 199 | 199 | { |
| 200 | - $rules = []; |
|
| 200 | + $rules=[]; |
|
| 201 | 201 | foreach($config['authorization'] as $authorization) |
| 202 | 202 | { |
| 203 | - $patterns = isset($authorization['pages'])?$authorization['pages']:''; |
|
| 204 | - $ruleApplies = false; |
|
| 205 | - if(empty($patterns) || trim($patterns) === '*') // null or empty string |
|
| 206 | - $ruleApplies = true; |
|
| 203 | + $patterns=isset($authorization['pages']) ? $authorization['pages'] : ''; |
|
| 204 | + $ruleApplies=false; |
|
| 205 | + if(empty($patterns) || trim($patterns)==='*') // null or empty string |
|
| 206 | + $ruleApplies=true; |
|
| 207 | 207 | else |
| 208 | 208 | { |
| 209 | 209 | foreach(explode(',', $patterns) as $pattern) |
| 210 | 210 | { |
| 211 | - if(($pattern = trim($pattern)) !== '') |
|
| 211 | + if(($pattern=trim($pattern))!=='') |
|
| 212 | 212 | { |
| 213 | 213 | // we know $configPagePath and $this->_pagePath |
| 214 | - if($configPagePath !== '') // prepend the pattern with ConfigPagePath |
|
| 215 | - $pattern = $configPagePath . '.' . $pattern; |
|
| 216 | - if(strcasecmp($pattern, $this->_pagePath) === 0) |
|
| 214 | + if($configPagePath!=='') // prepend the pattern with ConfigPagePath |
|
| 215 | + $pattern=$configPagePath.'.'.$pattern; |
|
| 216 | + if(strcasecmp($pattern, $this->_pagePath)===0) |
|
| 217 | 217 | { |
| 218 | - $ruleApplies = true; |
|
| 218 | + $ruleApplies=true; |
|
| 219 | 219 | break; |
| 220 | 220 | } |
| 221 | - if($pattern[strlen($pattern) - 1] === '*') // try wildcard matching |
|
| 221 | + if($pattern[strlen($pattern) - 1]==='*') // try wildcard matching |
|
| 222 | 222 | { |
| 223 | - if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0) |
|
| 223 | + if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1)===0) |
|
| 224 | 224 | { |
| 225 | - $ruleApplies = true; |
|
| 225 | + $ruleApplies=true; |
|
| 226 | 226 | break; |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -231,40 +231,40 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | if($ruleApplies) |
| 233 | 233 | { |
| 234 | - $action = isset($authorization['action'])?$authorization['action']:''; |
|
| 235 | - $users = isset($authorization['users'])?$authorization['users']:''; |
|
| 236 | - $roles = isset($authorization['roles'])?$authorization['roles']:''; |
|
| 237 | - $verb = isset($authorization['verb'])?$authorization['verb']:''; |
|
| 238 | - $ips = isset($authorization['ips'])?$authorization['ips']:''; |
|
| 239 | - $rules[] = new TAuthorizationRule($action, $users, $roles, $verb, $ips); |
|
| 234 | + $action=isset($authorization['action']) ? $authorization['action'] : ''; |
|
| 235 | + $users=isset($authorization['users']) ? $authorization['users'] : ''; |
|
| 236 | + $roles=isset($authorization['roles']) ? $authorization['roles'] : ''; |
|
| 237 | + $verb=isset($authorization['verb']) ? $authorization['verb'] : ''; |
|
| 238 | + $ips=isset($authorization['ips']) ? $authorization['ips'] : ''; |
|
| 239 | + $rules[]=new TAuthorizationRule($action, $users, $roles, $verb, $ips); |
|
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | - $this->_rules = array_merge($rules, $this->_rules); |
|
| 242 | + $this->_rules=array_merge($rules, $this->_rules); |
|
| 243 | 243 | } |
| 244 | 244 | // pages |
| 245 | 245 | if(isset($config['pages']) && is_array($config['pages'])) |
| 246 | 246 | { |
| 247 | 247 | if(isset($config['pages']['properties'])) |
| 248 | 248 | { |
| 249 | - $this->_properties = array_merge($this->_properties, $config['pages']['properties']); |
|
| 249 | + $this->_properties=array_merge($this->_properties, $config['pages']['properties']); |
|
| 250 | 250 | unset($config['pages']['properties']); |
| 251 | 251 | } |
| 252 | 252 | foreach($config['pages'] as $id => $page) |
| 253 | 253 | { |
| 254 | - $properties = []; |
|
| 254 | + $properties=[]; |
|
| 255 | 255 | if(isset($page['properties'])) |
| 256 | 256 | { |
| 257 | - $properties = $page['properties']; |
|
| 257 | + $properties=$page['properties']; |
|
| 258 | 258 | unset($page['properties']); |
| 259 | 259 | } |
| 260 | - $matching = false; |
|
| 261 | - $id = ($configPagePath === '')?$id:$configPagePath . '.' . $id; |
|
| 262 | - if(strcasecmp($id, $this->_pagePath) === 0) |
|
| 263 | - $matching = true; |
|
| 264 | - elseif($id[strlen($id) - 1] === '*') // try wildcard matching |
|
| 265 | - $matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0; |
|
| 260 | + $matching=false; |
|
| 261 | + $id=($configPagePath==='') ? $id : $configPagePath.'.'.$id; |
|
| 262 | + if(strcasecmp($id, $this->_pagePath)===0) |
|
| 263 | + $matching=true; |
|
| 264 | + elseif($id[strlen($id) - 1]==='*') // try wildcard matching |
|
| 265 | + $matching=strncasecmp($this->_pagePath, $id, strlen($id) - 1)===0; |
|
| 266 | 266 | if($matching) |
| 267 | - $this->_properties = array_merge($this->_properties, $properties); |
|
| 267 | + $this->_properties=array_merge($this->_properties, $properties); |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
@@ -273,14 +273,14 @@ discard block |
||
| 273 | 273 | { |
| 274 | 274 | foreach($config['includes'] as $include) |
| 275 | 275 | { |
| 276 | - $when = isset($include['when'])?true:false; |
|
| 276 | + $when=isset($include['when']) ?true:false; |
|
| 277 | 277 | if(!isset($include['file'])) |
| 278 | 278 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
| 279 | - $filePath = $include['file']; |
|
| 279 | + $filePath=$include['file']; |
|
| 280 | 280 | if(isset($this->_includes[$filePath])) |
| 281 | - $this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')']; |
|
| 281 | + $this->_includes[$filePath]=[$configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')']; |
|
| 282 | 282 | else |
| 283 | - $this->_includes[$filePath] = [$configPagePath,$when]; |
|
| 283 | + $this->_includes[$filePath]=[$configPagePath, $when]; |
|
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | } |
@@ -294,34 +294,34 @@ discard block |
||
| 294 | 294 | public function loadPageConfigurationFromXml($dom, $configPath, $configPagePath) |
| 295 | 295 | { |
| 296 | 296 | // authorization |
| 297 | - if(($authorizationNode = $dom->getElementByTagName('authorization')) !== null) |
|
| 297 | + if(($authorizationNode=$dom->getElementByTagName('authorization'))!==null) |
|
| 298 | 298 | { |
| 299 | - $rules = []; |
|
| 299 | + $rules=[]; |
|
| 300 | 300 | foreach($authorizationNode->getElements() as $node) |
| 301 | 301 | { |
| 302 | - $patterns = $node->getAttribute('pages'); |
|
| 303 | - $ruleApplies = false; |
|
| 304 | - if(empty($patterns) || trim($patterns) === '*') // null or empty string |
|
| 305 | - $ruleApplies = true; |
|
| 302 | + $patterns=$node->getAttribute('pages'); |
|
| 303 | + $ruleApplies=false; |
|
| 304 | + if(empty($patterns) || trim($patterns)==='*') // null or empty string |
|
| 305 | + $ruleApplies=true; |
|
| 306 | 306 | else |
| 307 | 307 | { |
| 308 | 308 | foreach(explode(',', $patterns) as $pattern) |
| 309 | 309 | { |
| 310 | - if(($pattern = trim($pattern)) !== '') |
|
| 310 | + if(($pattern=trim($pattern))!=='') |
|
| 311 | 311 | { |
| 312 | 312 | // we know $configPagePath and $this->_pagePath |
| 313 | - if($configPagePath !== '') // prepend the pattern with ConfigPagePath |
|
| 314 | - $pattern = $configPagePath . '.' . $pattern; |
|
| 315 | - if(strcasecmp($pattern, $this->_pagePath) === 0) |
|
| 313 | + if($configPagePath!=='') // prepend the pattern with ConfigPagePath |
|
| 314 | + $pattern=$configPagePath.'.'.$pattern; |
|
| 315 | + if(strcasecmp($pattern, $this->_pagePath)===0) |
|
| 316 | 316 | { |
| 317 | - $ruleApplies = true; |
|
| 317 | + $ruleApplies=true; |
|
| 318 | 318 | break; |
| 319 | 319 | } |
| 320 | - if($pattern[strlen($pattern) - 1] === '*') // try wildcard matching |
|
| 320 | + if($pattern[strlen($pattern) - 1]==='*') // try wildcard matching |
|
| 321 | 321 | { |
| 322 | - if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0) |
|
| 322 | + if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1)===0) |
|
| 323 | 323 | { |
| 324 | - $ruleApplies = true; |
|
| 324 | + $ruleApplies=true; |
|
| 325 | 325 | break; |
| 326 | 326 | } |
| 327 | 327 | } |
@@ -329,44 +329,44 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | if($ruleApplies) |
| 332 | - $rules[] = new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips')); |
|
| 332 | + $rules[]=new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips')); |
|
| 333 | 333 | } |
| 334 | - $this->_rules = array_merge($rules, $this->_rules); |
|
| 334 | + $this->_rules=array_merge($rules, $this->_rules); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | // pages |
| 338 | - if(($pagesNode = $dom->getElementByTagName('pages')) !== null) |
|
| 338 | + if(($pagesNode=$dom->getElementByTagName('pages'))!==null) |
|
| 339 | 339 | { |
| 340 | - $this->_properties = array_merge($this->_properties, $pagesNode->getAttributes()->toArray()); |
|
| 340 | + $this->_properties=array_merge($this->_properties, $pagesNode->getAttributes()->toArray()); |
|
| 341 | 341 | // at the page folder |
| 342 | 342 | foreach($pagesNode->getElementsByTagName('page') as $node) |
| 343 | 343 | { |
| 344 | - $properties = $node->getAttributes(); |
|
| 345 | - $id = $properties->remove('id'); |
|
| 344 | + $properties=$node->getAttributes(); |
|
| 345 | + $id=$properties->remove('id'); |
|
| 346 | 346 | if(empty($id)) |
| 347 | 347 | throw new TConfigurationException('pageserviceconf_page_invalid', $configPath); |
| 348 | - $matching = false; |
|
| 349 | - $id = ($configPagePath === '')?$id:$configPagePath . '.' . $id; |
|
| 350 | - if(strcasecmp($id, $this->_pagePath) === 0) |
|
| 351 | - $matching = true; |
|
| 352 | - elseif($id[strlen($id) - 1] === '*') // try wildcard matching |
|
| 353 | - $matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0; |
|
| 348 | + $matching=false; |
|
| 349 | + $id=($configPagePath==='') ? $id : $configPagePath.'.'.$id; |
|
| 350 | + if(strcasecmp($id, $this->_pagePath)===0) |
|
| 351 | + $matching=true; |
|
| 352 | + elseif($id[strlen($id) - 1]==='*') // try wildcard matching |
|
| 353 | + $matching=strncasecmp($this->_pagePath, $id, strlen($id) - 1)===0; |
|
| 354 | 354 | if($matching) |
| 355 | - $this->_properties = array_merge($this->_properties, $properties->toArray()); |
|
| 355 | + $this->_properties=array_merge($this->_properties, $properties->toArray()); |
|
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | // external configurations |
| 360 | 360 | foreach($dom->getElementsByTagName('include') as $node) |
| 361 | 361 | { |
| 362 | - if(($when = $node->getAttribute('when')) === null) |
|
| 363 | - $when = true; |
|
| 364 | - if(($filePath = $node->getAttribute('file')) === null) |
|
| 362 | + if(($when=$node->getAttribute('when'))===null) |
|
| 363 | + $when=true; |
|
| 364 | + if(($filePath=$node->getAttribute('file'))===null) |
|
| 365 | 365 | throw new TConfigurationException('pageserviceconf_includefile_required'); |
| 366 | 366 | if(isset($this->_includes[$filePath])) |
| 367 | - $this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')']; |
|
| 367 | + $this->_includes[$filePath]=[$configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')']; |
|
| 368 | 368 | else |
| 369 | - $this->_includes[$filePath] = [$configPagePath,$when]; |
|
| 369 | + $this->_includes[$filePath]=[$configPagePath, $when]; |
|
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | \ No newline at end of file |