Public Member Functions | |
__construct ($uri=null) | |
getOriginalPathInfo () | |
getStoreCodeFromPath () | |
setPathInfo ($pathInfo=null) | |
isDirectAccessFrontendName ($code) | |
getDirectFrontNames () | |
getOriginalRequest () | |
getRequestString () | |
getBasePath () | |
getBaseUrl () | |
setRouteName ($route) | |
getRouteName () | |
getHttpHost ($trimPort=true) | |
setPost ($key, $value=null) | |
setControllerModule ($module) | |
getControllerModule () | |
Public Attributes | |
const | XML_NODE_DIRECT_FRONT_NAMES = 'global/request/direct_front_name' |
Protected Member Functions | |
_canBeStoreCodeInUrl () | |
Protected Attributes | |
$_originalPathInfo = '' | |
$_storeCode = null | |
$_requestString = '' | |
$_route | |
$_directFrontNames = array() | |
$_controllerModule = null |
Allows dispatching before and after events for each controller action
Definition at line 35 of file Http.php.
__construct | ( | $ | uri = null |
) |
Definition at line 52 of file Http.php.
00053 { 00054 parent::__construct($uri); 00055 $names = Mage::getConfig()->getNode(self::XML_NODE_DIRECT_FRONT_NAMES); 00056 if ($names) { 00057 $this->_directFrontNames = $names->asArray(); 00058 } 00059 }
_canBeStoreCodeInUrl | ( | ) | [protected] |
Check if can be store code as part of url
Definition at line 162 of file Http.php.
00163 { 00164 return Mage::isInstalled() && Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL); 00165 }
getBasePath | ( | ) |
Definition at line 202 of file Http.php.
00203 { 00204 $path = parent::getBasePath(); 00205 if (empty($path)) { 00206 $path = '/'; 00207 } else { 00208 $path = str_replace('\\', '/', $path); 00209 } 00210 return $path; 00211 }
getBaseUrl | ( | ) |
Definition at line 213 of file Http.php.
00214 { 00215 $url = parent::getBaseUrl(); 00216 $url = str_replace('\\', '/', $url); 00217 return $url; 00218 }
getControllerModule | ( | ) |
getDirectFrontNames | ( | ) |
getHttpHost | ( | $ | trimPort = true |
) |
Retrieve HTTP HOST
bool | $trimPort |
Definition at line 243 of file Http.php.
00244 { 00245 if (!isset($_SERVER['HTTP_HOST'])) { 00246 return false; 00247 } 00248 if ($trimPort) { 00249 $host = split(':', $_SERVER['HTTP_HOST']); 00250 return $host[0]; 00251 } 00252 return $_SERVER['HTTP_HOST']; 00253 }
getOriginalPathInfo | ( | ) |
Returns ORIGINAL_PATH_INFO. This value is calculated instead of reading PATH_INFO directly from $_SERVER due to cross-platform differences.
Definition at line 68 of file Http.php.
00069 { 00070 if (empty($this->_originalPathInfo)) { 00071 $this->setPathInfo(); 00072 } 00073 return $this->_originalPathInfo; 00074 }
getOriginalRequest | ( | ) |
Definition at line 190 of file Http.php.
00191 { 00192 $request = new Zend_Controller_Request_Http(); 00193 $request->setPathInfo($this->getOriginalPathInfo()); 00194 return $request; 00195 }
getRequestString | ( | ) |
getRouteName | ( | ) |
getStoreCodeFromPath | ( | ) |
Definition at line 76 of file Http.php.
00077 { 00078 if (!$this->_storeCode) { 00079 // get store view code 00080 if ($this->_canBeStoreCodeInUrl()) { 00081 $p = explode('/', trim($this->getPathInfo(), '/')); 00082 $storeCode = $p[0]; 00083 00084 $stores = Mage::app()->getStores(true, true); 00085 00086 if ($storeCode !== '' && isset($stores[$storeCode])) { 00087 array_shift($p); 00088 $this->setPathInfo(implode('/', $p)); 00089 $this->_storeCode = $storeCode; 00090 Mage::app()->setCurrentStore($storeCode); 00091 } 00092 else { 00093 $this->_storeCode = Mage::app()->getStore()->getCode(); 00094 } 00095 } else { 00096 $this->_storeCode = Mage::app()->getStore()->getCode(); 00097 } 00098 00099 } 00100 return $this->_storeCode; 00101 }
isDirectAccessFrontendName | ( | $ | code | ) |
Check if code declared as direct access frontend name this mean what this url can be used without store code
string | $code |
Definition at line 174 of file Http.php.
00175 { 00176 $names = $this->getDirectFrontNames(); 00177 return isset($names[$code]); 00178 }
setControllerModule | ( | $ | module | ) |
setPathInfo | ( | $ | pathInfo = null |
) |
Set the PATH_INFO string Set the ORIGINAL_PATH_INFO string
string|null | $pathInfo |
Definition at line 110 of file Http.php.
00111 { 00112 if ($pathInfo === null) { 00113 $requestUri = $this->getRequestUri(); 00114 if (null === $requestUri) { 00115 return $this; 00116 } 00117 00118 // Remove the query string from REQUEST_URI 00119 if ($pos = strpos($requestUri, '?')) { 00120 $requestUri = substr($requestUri, 0, $pos); 00121 } 00122 00123 $baseUrl = $this->getBaseUrl(); 00124 $pathInfo = substr($requestUri, strlen($baseUrl)); 00125 00126 if ((null !== $baseUrl) && (false === $pathInfo)) { 00127 $pathInfo = ''; 00128 } elseif (null === $baseUrl) { 00129 $pathInfo = $requestUri; 00130 } 00131 00132 if ($this->_canBeStoreCodeInUrl()) { 00133 $pathParts = explode('/', ltrim($pathInfo, '/'), 2); 00134 $storeCode = $pathParts[0]; 00135 00136 if (!$this->isDirectAccessFrontendName($storeCode)) { 00137 $stores = Mage::app()->getStores(true, true); 00138 if ($storeCode!=='' && isset($stores[$storeCode])) { 00139 Mage::app()->setCurrentStore($storeCode); 00140 $pathInfo = '/'.(isset($pathParts[1]) ? $pathParts[1] : ''); 00141 } 00142 elseif ($storeCode !== '') { 00143 $this->setActionName('noRoute'); 00144 } 00145 } 00146 } 00147 00148 $this->_originalPathInfo = (string) $pathInfo; 00149 00150 $this->_requestString = $pathInfo . ($pos!==false ? substr($requestUri, $pos) : ''); 00151 } 00152 00153 $this->_pathInfo = (string) $pathInfo; 00154 return $this; 00155 }
setPost | ( | $ | key, | |
$ | value = null | |||
) |
setRouteName | ( | $ | route | ) |
Definition at line 220 of file Http.php.
00221 { 00222 $this->_route = $route; 00223 $router = Mage::app()->getFrontController()->getRouterByRoute($route); 00224 if (!$router) return $this; 00225 $module = $router->getFrontNameByRoute($route); 00226 if ($module) { 00227 $this->setModuleName($module); 00228 } 00229 return $this; 00230 }
const XML_NODE_DIRECT_FRONT_NAMES = 'global/request/direct_front_name' |