@@ -40,7 +40,7 @@ |
||
40 | 40 | { |
41 | 41 | parent::addAttributesToRender($writer); |
42 | 42 | if(($scope = $this->getScope()) !== TTableHeaderScope::NotSet) |
43 | - $writer->addAttribute('scope', $scope === TTableHeaderScope::Row?'row':'col'); |
|
43 | + $writer->addAttribute('scope', $scope === TTableHeaderScope::Row ? 'row' : 'col'); |
|
44 | 44 | if(($text = $this->getAbbreviatedText()) !== '') |
45 | 45 | $writer->addAttribute('abbr', $text); |
46 | 46 | if(($text = $this->getCategoryText()) !== '') |
@@ -364,8 +364,9 @@ discard block |
||
364 | 364 | $content = ''; |
365 | 365 | if(strlen($header)) |
366 | 366 | $content .= $header . "<br/>\n"; |
367 | - foreach($messages as $message) |
|
368 | - $content .= "$message<br/>\n"; |
|
367 | + foreach($messages as $message) { |
|
368 | + $content .= "$message<br/>\n"; |
|
369 | + } |
|
369 | 370 | $writer->write($content); |
370 | 371 | } |
371 | 372 | |
@@ -380,8 +381,9 @@ discard block |
||
380 | 381 | $header = $this->getHeaderText(); |
381 | 382 | $messages = $this->getErrorMessages(); |
382 | 383 | $content = $header; |
383 | - foreach($messages as $message) |
|
384 | - $content .= ' ' . $message; |
|
384 | + foreach($messages as $message) { |
|
385 | + $content .= ' ' . $message; |
|
386 | + } |
|
385 | 387 | $writer->write($content); |
386 | 388 | } |
387 | 389 | |
@@ -399,8 +401,9 @@ discard block |
||
399 | 401 | if(count($messages) > 0) |
400 | 402 | { |
401 | 403 | $content .= "<ul>\n"; |
402 | - foreach($messages as $message) |
|
403 | - $content .= '<li>' . $message . "</li>\n"; |
|
404 | + foreach($messages as $message) { |
|
405 | + $content .= '<li>' . $message . "</li>\n"; |
|
406 | + } |
|
404 | 407 | $content .= "</ul>\n"; |
405 | 408 | } |
406 | 409 | $writer->write($content); |
@@ -119,7 +119,7 @@ |
||
119 | 119 | |
120 | 120 | private function generateTokenHash($token) |
121 | 121 | { |
122 | - for($h = 0,$i = strlen($token) - 1;$i >= 0;--$i) |
|
122 | + for($h = 0, $i = strlen($token) - 1; $i >= 0; --$i) |
|
123 | 123 | $h += ord($token[$i]); |
124 | 124 | return $h; |
125 | 125 | } |
@@ -108,8 +108,7 @@ discard block |
||
108 | 108 | { |
109 | 109 | $options['TokenHash'] = $this->generateTokenHash($control->getToken()); |
110 | 110 | $options['CaseSensitive'] = true; |
111 | - } |
|
112 | - else |
|
111 | + } else |
|
113 | 112 | { |
114 | 113 | $options['TokenHash'] = $this->generateTokenHash(strtoupper($control->getToken())); |
115 | 114 | $options['CaseSensitive'] = false; |
@@ -119,8 +118,9 @@ discard block |
||
119 | 118 | |
120 | 119 | private function generateTokenHash($token) |
121 | 120 | { |
122 | - for($h = 0,$i = strlen($token) - 1;$i >= 0;--$i) |
|
123 | - $h += ord($token[$i]); |
|
121 | + for($h = 0,$i = strlen($token) - 1;$i >= 0;--$i) { |
|
122 | + $h += ord($token[$i]); |
|
123 | + } |
|
124 | 124 | return $h; |
125 | 125 | } |
126 | 126 | } |
@@ -78,23 +78,22 @@ discard block |
||
78 | 78 | if(is_array($value)) |
79 | 79 | { |
80 | 80 | $name = urlencode($name . '[]'); |
81 | - foreach($value as $v) |
|
82 | - $url .= $amp . $name . '=' . urlencode($v); |
|
83 | - } |
|
84 | - else |
|
81 | + foreach($value as $v) { |
|
82 | + $url .= $amp . $name . '=' . urlencode($v); |
|
83 | + } |
|
84 | + } else |
|
85 | 85 | $url .= $amp . urlencode($name) . '=' . urlencode($value); |
86 | 86 | } |
87 | - } |
|
88 | - else |
|
87 | + } else |
|
89 | 88 | { |
90 | 89 | foreach($getItems as $name => $value) |
91 | 90 | { |
92 | 91 | if(is_array($value)) |
93 | 92 | { |
94 | - foreach($value as $v) |
|
95 | - $url .= $amp . $name . '[]=' . $v; |
|
96 | - } |
|
97 | - else |
|
93 | + foreach($value as $v) { |
|
94 | + $url .= $amp . $name . '[]=' . $v; |
|
95 | + } |
|
96 | + } else |
|
98 | 97 | $url .= $amp . $name . '=' . $value; |
99 | 98 | } |
100 | 99 | } |
@@ -147,14 +146,12 @@ discard block |
||
147 | 146 | $getVariables[substr($name, 0, $pos)][] = $value; |
148 | 147 | else |
149 | 148 | $getVariables[$name] = $value; |
150 | - } |
|
151 | - else |
|
149 | + } else |
|
152 | 150 | $getVariables[$path] = ''; |
153 | 151 | } |
154 | 152 | } |
155 | 153 | return $getVariables; |
156 | - } |
|
157 | - else |
|
154 | + } else |
|
158 | 155 | return []; |
159 | 156 | } |
160 | 157 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems) |
68 | 68 | { |
69 | 69 | $url = $serviceID . '=' . urlencode($serviceParam); |
70 | - $amp = $encodeAmpersand?'&':'&'; |
|
70 | + $amp = $encodeAmpersand ? '&' : '&'; |
|
71 | 71 | $request = $this->getRequest(); |
72 | 72 | if(is_array($getItems) || $getItems instanceof \Traversable) |
73 | 73 | { |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | switch($request->getUrlFormat()) |
104 | 104 | { |
105 | 105 | case THttpRequestUrlFormat::Path: |
106 | - return $request->getApplicationUrl() . '/' . strtr($url, [$amp => '/','?' => '/','=' => $request->getUrlParamSeparator()]); |
|
106 | + return $request->getApplicationUrl() . '/' . strtr($url, [$amp => '/', '?' => '/', '=' => $request->getUrlParamSeparator()]); |
|
107 | 107 | case THttpRequestUrlFormat::HiddenPath: |
108 | - return rtrim(dirname($request->getApplicationUrl()), '/') . '/' . strtr($url, [$amp => '/','?' => '/','=' => $request->getUrlParamSeparator()]); |
|
108 | + return rtrim(dirname($request->getApplicationUrl()), '/') . '/' . strtr($url, [$amp => '/', '?' => '/', '=' => $request->getUrlParamSeparator()]); |
|
109 | 109 | default: |
110 | 110 | return $request->getApplicationUrl() . '?' . $url; |
111 | 111 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | if(!$this->_started) |
141 | 141 | { |
142 | 142 | if($this->_customStorage) |
143 | - session_set_save_handler([$this,'_open'], [$this,'_close'], [$this,'_read'], [$this,'_write'], [$this,'_destroy'], [$this,'_gc']); |
|
143 | + session_set_save_handler([$this, '_open'], [$this, '_close'], [$this, '_read'], [$this, '_write'], [$this, '_destroy'], [$this, '_gc']); |
|
144 | 144 | if($this->_cookie !== null) |
145 | 145 | session_set_cookie_params($this->_cookie->getExpire(), $this->_cookie->getPath(), $this->_cookie->getDomain(), $this->_cookie->getSecure(), $this->_cookie->getHttpOnly()); |
146 | 146 | if(ini_get('session.auto_start') !== '1') |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | else |
406 | 406 | { |
407 | 407 | $value = TPropertyValue::ensureBoolean($value); |
408 | - if ($value && $this->getCookieMode() == THttpSessionCookieMode::Only) |
|
408 | + if($value && $this->getCookieMode() == THttpSessionCookieMode::Only) |
|
409 | 409 | throw new TInvalidOperationException('httpsession_transid_cookieonly'); |
410 | - ini_set('session.use_trans_sid', $value?'1':'0'); |
|
410 | + ini_set('session.use_trans_sid', $value ? '1' : '0'); |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 |
@@ -318,13 +318,11 @@ discard block |
||
318 | 318 | { |
319 | 319 | ini_set('session.use_cookies', '0'); |
320 | 320 | ini_set('session.use_only_cookies', '0'); |
321 | - } |
|
322 | - elseif($value === THttpSessionCookieMode::Allow) |
|
321 | + } elseif($value === THttpSessionCookieMode::Allow) |
|
323 | 322 | { |
324 | 323 | ini_set('session.use_cookies', '1'); |
325 | 324 | ini_set('session.use_only_cookies', '0'); |
326 | - } |
|
327 | - else |
|
325 | + } else |
|
328 | 326 | { |
329 | 327 | ini_set('session.use_cookies', '1'); |
330 | 328 | ini_set('session.use_only_cookies', '1'); |
@@ -377,8 +375,7 @@ discard block |
||
377 | 375 | { |
378 | 376 | ini_set('session.gc_probability', $value); |
379 | 377 | ini_set('session.gc_divisor', '100'); |
380 | - } |
|
381 | - else |
|
378 | + } else |
|
382 | 379 | throw new TInvalidDataValueException('httpsession_gcprobability_invalid', $value); |
383 | 380 | } |
384 | 381 | } |
@@ -570,8 +567,7 @@ discard block |
||
570 | 567 | $value = $_SESSION[$key]; |
571 | 568 | unset($_SESSION[$key]); |
572 | 569 | return $value; |
573 | - } |
|
574 | - else |
|
570 | + } else |
|
575 | 571 | return null; |
576 | 572 | } |
577 | 573 | |
@@ -580,8 +576,9 @@ discard block |
||
580 | 576 | */ |
581 | 577 | public function clear() |
582 | 578 | { |
583 | - foreach(array_keys($_SESSION) as $key) |
|
584 | - unset($_SESSION[$key]); |
|
579 | + foreach(array_keys($_SESSION) as $key) { |
|
580 | + unset($_SESSION[$key]); |
|
581 | + } |
|
585 | 582 | } |
586 | 583 | |
587 | 584 | /** |
@@ -232,8 +232,7 @@ discard block |
||
232 | 232 | $port = $_SERVER['SERVER_PORT']; |
233 | 233 | if(($port != 80 && !$secure) || ($port != 443 && $secure)) |
234 | 234 | $url .= ':' . $port; |
235 | - } |
|
236 | - else |
|
235 | + } else |
|
237 | 236 | $url .= $_SERVER['HTTP_HOST']; |
238 | 237 | $url .= $this->getRequestUri(); |
239 | 238 | $this->_url = new TUri($url); |
@@ -341,8 +340,7 @@ discard block |
||
341 | 340 | { |
342 | 341 | $this->_urlManager = new TUrlManager; |
343 | 342 | $this->_urlManager->init(null); |
344 | - } |
|
345 | - else |
|
343 | + } else |
|
346 | 344 | { |
347 | 345 | $this->_urlManager = $this->getApplication()->getModule($this->_urlManagerID); |
348 | 346 | if($this->_urlManager === null) |
@@ -462,8 +460,7 @@ discard block |
||
462 | 460 | |
463 | 461 | if($result === null && function_exists('apache_request_headers')) { |
464 | 462 | $result = apache_request_headers(); |
465 | - } |
|
466 | - elseif($result === null) { |
|
463 | + } elseif($result === null) { |
|
467 | 464 | $result = []; |
468 | 465 | foreach($_SERVER as $key => $value) { |
469 | 466 | if(strncasecmp($key, 'HTTP_', 5) !== 0) continue; |
@@ -575,8 +572,7 @@ discard block |
||
575 | 572 | try |
576 | 573 | { |
577 | 574 | return get_browser(); |
578 | - } |
|
579 | - catch(TPhpErrorException $e) |
|
575 | + } catch(TPhpErrorException $e) |
|
580 | 576 | { |
581 | 577 | throw new TConfigurationException('httprequest_browscap_required'); |
582 | 578 | } |
@@ -679,11 +675,11 @@ discard block |
||
679 | 675 | if(($value = $sm->validateData($value)) !== false) |
680 | 676 | $this->_cookies->add(new THttpCookie($key, $value)); |
681 | 677 | } |
682 | - } |
|
683 | - else |
|
678 | + } else |
|
684 | 679 | { |
685 | - foreach($_COOKIE as $key => $value) |
|
686 | - $this->_cookies->add(new THttpCookie($key, $value)); |
|
680 | + foreach($_COOKIE as $key => $value) { |
|
681 | + $this->_cookies->add(new THttpCookie($key, $value)); |
|
682 | + } |
|
687 | 683 | } |
688 | 684 | } |
689 | 685 | return $this->_cookies; |
@@ -766,8 +762,9 @@ discard block |
||
766 | 762 | { |
767 | 763 | Prado::trace("Resolving request from " . $_SERVER['REMOTE_ADDR'], 'Prado\Web\THttpRequest'); |
768 | 764 | $getParams = $this->parseUrl(); |
769 | - foreach($getParams as $name => $value) |
|
770 | - $_GET[$name] = $value; |
|
765 | + foreach($getParams as $name => $value) { |
|
766 | + $_GET[$name] = $value; |
|
767 | + } |
|
771 | 768 | $this->_items = array_merge($_GET, $_POST); |
772 | 769 | $this->_requestResolved = true; |
773 | 770 | foreach($serviceIDs as $serviceID) |
@@ -897,8 +894,7 @@ discard block |
||
897 | 894 | $value = $this->_items[$key]; |
898 | 895 | unset($this->_items[$key]); |
899 | 896 | return $value; |
900 | - } |
|
901 | - else |
|
897 | + } else |
|
902 | 898 | return null; |
903 | 899 | } |
904 | 900 | |
@@ -907,8 +903,9 @@ discard block |
||
907 | 903 | */ |
908 | 904 | public function clear() |
909 | 905 | { |
910 | - foreach(array_keys($this->_items) as $key) |
|
911 | - $this->remove($key); |
|
906 | + foreach(array_keys($this->_items) as $key) { |
|
907 | + $this->remove($key); |
|
908 | + } |
|
912 | 909 | } |
913 | 910 | |
914 | 911 | /** |
@@ -180,7 +180,7 @@ 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 | 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'])); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function stripSlashes(&$data) |
216 | 216 | { |
217 | - return is_array($data)?array_map([$this,'stripSlashes'], $data):stripslashes($data); |
|
217 | + return is_array($data) ?array_map([$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']; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | { |
278 | 278 | $dependencies = null; |
279 | 279 | if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
280 | - if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
|
280 | + if($manager instanceof TUrlMapping && $fn = $manager->getConfigFile()) |
|
281 | 281 | { |
282 | 282 | $fn = Prado::getPathOfNamespace($fn, $this->getApplication()->getConfigurationFileExt()); |
283 | 283 | $dependencies = new TFileCacheDependency($fn); |
@@ -402,7 +402,7 @@ 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 | /** |
@@ -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 | /** |
@@ -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 | |
@@ -510,7 +510,7 @@ discard block |
||
510 | 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 | /** |
@@ -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 | /** |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | */ |
564 | 564 | public function getServerSoftware() |
565 | 565 | { |
566 | - return isset($_SERVER['SERVER_SOFTWARE'])?$_SERVER['SERVER_SOFTWARE']:null; |
|
566 | + return isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : null; |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | { |
577 | 577 | return get_browser(); |
578 | 578 | } |
579 | - catch(TPhpErrorException $e) |
|
579 | + catch (TPhpErrorException $e) |
|
580 | 580 | { |
581 | 581 | throw new TConfigurationException('httprequest_browscap_required'); |
582 | 582 | } |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | */ |
588 | 588 | public function getUserAgent() |
589 | 589 | { |
590 | - return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null; |
|
590 | + return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | /** |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | */ |
596 | 596 | public function getUserHostAddress() |
597 | 597 | { |
598 | - return isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null; |
|
598 | + return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | */ |
604 | 604 | public function getUserHost() |
605 | 605 | { |
606 | - return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null; |
|
606 | + return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null; |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | /** |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | public function getAcceptTypes() |
613 | 613 | { |
614 | 614 | // TBD: break it into array?? |
615 | - return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null; |
|
615 | + return isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null; |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | /** |
@@ -732,11 +732,11 @@ discard block |
||
732 | 732 | */ |
733 | 733 | public function constructUrl($serviceID, $serviceParam, $getItems = null, $encodeAmpersand = true, $encodeGetItems = true) |
734 | 734 | { |
735 | - if ($this->_cookieOnly === null) |
|
736 | - $this->_cookieOnly = (int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies'); |
|
735 | + if($this->_cookieOnly === null) |
|
736 | + $this->_cookieOnly = (int) ini_get('session.use_cookies') && (int) ini_get('session.use_only_cookies'); |
|
737 | 737 | $url = $this->getUrlManagerModule()->constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems); |
738 | 738 | if(defined('SID') && SID != '' && !$this->_cookieOnly) |
739 | - return $url . (strpos($url, '?') === false? '?' : ($encodeAmpersand?'&':'&')) . SID; |
|
739 | + return $url . (strpos($url, '?') === false ? '?' : ($encodeAmpersand ? '&' : '&')) . SID; |
|
740 | 740 | else |
741 | 741 | return $url; |
742 | 742 | } |
@@ -59,8 +59,7 @@ discard block |
||
59 | 59 | parent::insertAt($index, $item); |
60 | 60 | if($this->_o instanceof THttpResponse) |
61 | 61 | $this->_o->addCookie($item); |
62 | - } |
|
63 | - else |
|
62 | + } else |
|
64 | 63 | throw new TInvalidDataTypeException('httpcookiecollection_httpcookie_required'); |
65 | 64 | } |
66 | 65 | |
@@ -98,9 +97,10 @@ discard block |
||
98 | 97 | */ |
99 | 98 | public function findCookieByName($name) |
100 | 99 | { |
101 | - foreach($this as $cookie) |
|
102 | - if($cookie->getName() === $name) |
|
100 | + foreach($this as $cookie) { |
|
101 | + if($cookie->getName() === $name) |
|
103 | 102 | return $cookie; |
103 | + } |
|
104 | 104 | return null; |
105 | 105 | } |
106 | 106 | } |
107 | 107 | \ No newline at end of file |
@@ -364,10 +364,10 @@ discard block |
||
364 | 364 | $params = explode('/', $matches['urlparams']); |
365 | 365 | if ($this->_separator === '/') |
366 | 366 | { |
367 | - while($key = array_shift($params)) |
|
368 | - $matches[$key] = ($value = array_shift($params)) ? $value : ''; |
|
369 | - } |
|
370 | - else |
|
367 | + while($key = array_shift($params)) { |
|
368 | + $matches[$key] = ($value = array_shift($params)) ? $value : ''; |
|
369 | + } |
|
370 | + } else |
|
371 | 371 | { |
372 | 372 | array_pop($params); |
373 | 373 | foreach($params as $param) |
@@ -381,8 +381,9 @@ discard block |
||
381 | 381 | |
382 | 382 | if(count($matches) > 0 && $this->_constants) |
383 | 383 | { |
384 | - foreach($this->_constants->toArray() as $key => $value) |
|
385 | - $matches[$key] = $value; |
|
384 | + foreach($this->_constants->toArray() as $key => $value) { |
|
385 | + $matches[$key] = $value; |
|
386 | + } |
|
386 | 387 | } |
387 | 388 | |
388 | 389 | return $matches; |
@@ -543,8 +544,9 @@ discard block |
||
543 | 544 | if(count($extra) > 0) |
544 | 545 | { |
545 | 546 | if ($this->_urlFormat === THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { |
546 | - foreach ($extra as $name => $value) |
|
547 | - $url .= '/' . $name . $this->_separator . ($encodeGetItems?rawurlencode($value):$value); |
|
547 | + foreach ($extra as $name => $value) { |
|
548 | + $url .= '/' . $name . $this->_separator . ($encodeGetItems?rawurlencode($value):$value); |
|
549 | + } |
|
548 | 550 | return $url; |
549 | 551 | } |
550 | 552 | |
@@ -557,23 +559,22 @@ discard block |
||
557 | 559 | if(is_array($value)) |
558 | 560 | { |
559 | 561 | $name = rawurlencode($name . '[]'); |
560 | - foreach($value as $v) |
|
561 | - $url2 .= $amp . $name . '=' . rawurlencode($v); |
|
562 | - } |
|
563 | - else |
|
562 | + foreach($value as $v) { |
|
563 | + $url2 .= $amp . $name . '=' . rawurlencode($v); |
|
564 | + } |
|
565 | + } else |
|
564 | 566 | $url2 .= $amp . rawurlencode($name) . '=' . rawurlencode($value); |
565 | 567 | } |
566 | - } |
|
567 | - else |
|
568 | + } else |
|
568 | 569 | { |
569 | 570 | foreach($extra as $name => $value) |
570 | 571 | { |
571 | 572 | if(is_array($value)) |
572 | 573 | { |
573 | - foreach($value as $v) |
|
574 | - $url2 .= $amp . $name . '[]=' . $v; |
|
575 | - } |
|
576 | - else |
|
574 | + foreach($value as $v) { |
|
575 | + $url2 .= $amp . $name . '[]=' . $v; |
|
576 | + } |
|
577 | + } else |
|
577 | 578 | $url2 .= $amp . $name . '=' . $value; |
578 | 579 | } |
579 | 580 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | { |
201 | 201 | $params = []; |
202 | 202 | $values = []; |
203 | - if ($this->_parameters) |
|
203 | + if($this->_parameters) |
|
204 | 204 | { |
205 | 205 | foreach($this->_parameters as $key => $value) |
206 | 206 | { |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $values[] = '(?P<' . $key . '>' . $value . ')'; |
209 | 209 | } |
210 | 210 | } |
211 | - if ($this->getIsWildCardPattern()) |
|
211 | + if($this->getIsWildCardPattern()) |
|
212 | 212 | { |
213 | 213 | $params[] = '{*}'; |
214 | 214 | // service parameter must not contain '=' and '/' |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $params[] = '/'; |
218 | 218 | $values[] = '\\/'; |
219 | 219 | $regexp = str_replace($params, $values, trim($this->getPattern(), '/') . '/'); |
220 | - if ($this->_urlFormat === THttpRequestUrlFormat::Get) |
|
220 | + if($this->_urlFormat === THttpRequestUrlFormat::Get) |
|
221 | 221 | $regexp = '/^' . $regexp . '$/u'; |
222 | 222 | else |
223 | 223 | $regexp = '/^' . $regexp . '(?P<urlparams>.*)$/u'; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | */ |
313 | 313 | public function getParameters() |
314 | 314 | { |
315 | - if (!$this->_parameters) |
|
315 | + if(!$this->_parameters) |
|
316 | 316 | { |
317 | 317 | $this->_parameters = new TAttributeCollection; |
318 | 318 | $this->_parameters->setCaseSensitive(true); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | */ |
335 | 335 | public function getConstants() |
336 | 336 | { |
337 | - if (!$this->_constants) |
|
337 | + if(!$this->_constants) |
|
338 | 338 | { |
339 | 339 | $this->_constants = new TAttributeCollection; |
340 | 340 | $this->_constants->setCaseSensitive(true); |
@@ -359,10 +359,10 @@ discard block |
||
359 | 359 | if($this->getIsWildCardPattern() && isset($matches[$this->_serviceID])) |
360 | 360 | $matches[$this->_serviceID] = str_replace('*', $matches[$this->_serviceID], $this->_serviceParameter); |
361 | 361 | |
362 | - if (isset($matches['urlparams'])) |
|
362 | + if(isset($matches['urlparams'])) |
|
363 | 363 | { |
364 | 364 | $params = explode('/', $matches['urlparams']); |
365 | - if ($this->_separator === '/') |
|
365 | + if($this->_separator === '/') |
|
366 | 366 | { |
367 | 367 | while($key = array_shift($params)) |
368 | 368 | $matches[$key] = ($value = array_shift($params)) ? $value : ''; |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | { |
487 | 487 | if(!$this->_customUrl || $this->getPattern() === null) |
488 | 488 | return false; |
489 | - if ($this->_parameters) |
|
489 | + if($this->_parameters) |
|
490 | 490 | { |
491 | 491 | foreach($this->_parameters as $key => $value) |
492 | 492 | { |
@@ -495,13 +495,13 @@ discard block |
||
495 | 495 | } |
496 | 496 | } |
497 | 497 | |
498 | - if ($this->_constants) |
|
498 | + if($this->_constants) |
|
499 | 499 | { |
500 | 500 | foreach($this->_constants->toArray() as $key => $value) |
501 | 501 | { |
502 | - if (!isset($getItems[$key])) |
|
502 | + if(!isset($getItems[$key])) |
|
503 | 503 | return false; |
504 | - if ($getItems[$key] != $value) |
|
504 | + if($getItems[$key] != $value) |
|
505 | 505 | return false; |
506 | 506 | } |
507 | 507 | } |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | */ |
519 | 519 | public function constructUrl($getItems, $encodeAmpersand, $encodeGetItems) |
520 | 520 | { |
521 | - if ($this->_constants) |
|
521 | + if($this->_constants) |
|
522 | 522 | { |
523 | 523 | foreach($this->_constants->toArray() as $key => $value) |
524 | 524 | { |
@@ -542,14 +542,14 @@ discard block |
||
542 | 542 | // for the rest of the GET variables, put them in the query string |
543 | 543 | if(count($extra) > 0) |
544 | 544 | { |
545 | - if ($this->_urlFormat === THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { |
|
546 | - foreach ($extra as $name => $value) |
|
547 | - $url .= '/' . $name . $this->_separator . ($encodeGetItems?rawurlencode($value):$value); |
|
545 | + if($this->_urlFormat === THttpRequestUrlFormat::Path && $this->getIsWildCardPattern()) { |
|
546 | + foreach($extra as $name => $value) |
|
547 | + $url .= '/' . $name . $this->_separator . ($encodeGetItems ?rawurlencode($value) : $value); |
|
548 | 548 | return $url; |
549 | 549 | } |
550 | 550 | |
551 | 551 | $url2 = ''; |
552 | - $amp = $encodeAmpersand?'&':'&'; |
|
552 | + $amp = $encodeAmpersand ? '&' : '&'; |
|
553 | 553 | if($encodeGetItems) |
554 | 554 | { |
555 | 555 | foreach($extra as $name => $value) |
@@ -137,15 +137,13 @@ discard block |
||
137 | 137 | { |
138 | 138 | $config = include $this->_configFile; |
139 | 139 | $this->loadUrlMappings($dom); |
140 | - } |
|
141 | - else |
|
140 | + } else |
|
142 | 141 | { |
143 | 142 | $dom = new TXmlDocument; |
144 | 143 | $dom->loadFromFile($this->_configFile); |
145 | 144 | $this->loadUrlMappings($dom); |
146 | 145 | } |
147 | - } |
|
148 | - else |
|
146 | + } else |
|
149 | 147 | throw new TConfigurationException('urlmapping_configfile_inexistent', $this->_configFile); |
150 | 148 | } |
151 | 149 | |
@@ -252,8 +250,7 @@ discard block |
||
252 | 250 | $this->buildUrlMapping($class, $properties, $url); |
253 | 251 | } |
254 | 252 | } |
255 | - } |
|
256 | - else |
|
253 | + } else |
|
257 | 254 | { |
258 | 255 | foreach($config->getElementsByTagName('url') as $url) |
259 | 256 | { |
@@ -270,8 +267,9 @@ discard block |
||
270 | 267 | $pattern = Prado::createComponent($class, $this); |
271 | 268 | if(!($pattern instanceof TUrlMappingPattern)) |
272 | 269 | throw new TConfigurationException('urlmapping_urlmappingpattern_required'); |
273 | - foreach($properties as $name => $value) |
|
274 | - $pattern->setSubproperty($name, $value); |
|
270 | + foreach($properties as $name => $value) { |
|
271 | + $pattern->setSubproperty($name, $value); |
|
272 | + } |
|
275 | 273 | |
276 | 274 | if($url instanceof TXmlElement) { |
277 | 275 | $text = $url -> getValue(); |
@@ -367,8 +365,7 @@ discard block |
||
367 | 365 | if($rule->supportCustomUrl($getItems)) |
368 | 366 | return $rule->constructUrl($getItems, $encodeAmpersand, $encodeGetItems); |
369 | 367 | } |
370 | - } |
|
371 | - elseif(isset($this->_constructRules[$wildCardKey])) |
|
368 | + } elseif(isset($this->_constructRules[$wildCardKey])) |
|
372 | 369 | { |
373 | 370 | foreach($this->_constructRules[$wildCardKey] as $rule) |
374 | 371 | { |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | { |
248 | 248 | foreach($config['urls'] as $url) |
249 | 249 | { |
250 | - $class = isset($url['class'])?$url['class']:$defaultClass; |
|
251 | - $properties = isset($url['properties'])?$url['properties']:[]; |
|
250 | + $class = isset($url['class']) ? $url['class'] : $defaultClass; |
|
251 | + $properties = isset($url['properties']) ? $url['properties'] : []; |
|
252 | 252 | $this->buildUrlMapping($class, $properties, $url); |
253 | 253 | } |
254 | 254 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | if(is_string($key)) |
320 | 320 | $params[$key] = $value; |
321 | 321 | } |
322 | - if (!$pattern->getIsWildCardPattern()) |
|
322 | + if(!$pattern->getIsWildCardPattern()) |
|
323 | 323 | $params[$pattern->getServiceID()] = $pattern->getServiceParameter(); |
324 | 324 | return $params; |
325 | 325 | } |