5 const SCHEME_HTTP = 'http';
6 const SCHEME_HTTPS = 'https';
8 protected $_requestUri;
11 protected $_pathInfo = '';
12 protected $_controller;
16 public function get($key)
19 case isset($_GET[$key]):
21 case isset($_POST[$key]):
23 case isset($_COOKIE[$key]):
24 return $_COOKIE[$key];
25 case isset($_SERVER[$key]):
26 return $_SERVER[$key];
32 protected function parseURL()
34 $uri = explode('?', $this->getServer('REQUEST_URI'))[0];
35 $uri = substr($uri, strlen(Application::get()->getBaseURL()));
37 $parts = explode('/', $uri);
38 if (count($parts) > 0)
39 $this->_controller = $parts[0];
40 if (count($parts) > 2) {
41 $this->_tour = $parts[1];
42 $this->_action = $parts[2];
43 } elseif (count($parts) > 1) {
44 $this->_action = $parts[1];
48 public function getControllerName()
50 if (is_null($this->_controller))
53 return $this->_controller;
56 public function getActionName()
58 return $this->_action;
61 public function getTourName()
66 public function getPost($key = null, $default = null)
72 return isset($_POST[$key]) ? $_POST[$key] : $default;
75 public function getServer($key = null, $default = null)
81 return isset($_SERVER[$key]) ? $_SERVER[$key] : $default;
84 public function getScheme()
86 return ($this->getServer('HTTPS') === 'on') ? self::SCHEME_HTTPS : self::SCHEME_HTTP;
89 public function getHttpHost()
91 $host = $this->getServer('HTTP_HOST');
96 $scheme = $this->getScheme();
97 $name = $this->getServer('SERVER_NAME');
98 $port = $this->getServer('SERVER_PORT');
100 if ($name === null) {
102 } elseif (($scheme == self::SCHEME_HTTP && $port == 80) || ($scheme == self::SCHEME_HTTPS && $port == 443)) {
106 return $name . ':' . $port;
109 public function isPost()
111 return $this->getServer('REQUEST_METHOD') == 'POST';
114 public function isAjax()
116 return !empty($this->getServer('HTTP_X_REQUESTED_WITH'))
117 && strtolower($this->getServer('HTTP_X_REQUESTED_WITH')) == 'xmlhttprequest';