Mage_Core_Controller_Request_Http Class Reference

List of all members.

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


Detailed Description

Custom Zend_Controller_Request_Http class (formally)

Allows dispatching before and after events for each controller action

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 35 of file Http.php.


Constructor & Destructor Documentation

__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     }


Member Function Documentation

_canBeStoreCodeInUrl (  )  [protected]

Check if can be store code as part of url

Returns:
bool

Definition at line 162 of file Http.php.

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 (  ) 

Get module name of currently used controller

Returns:
string

Definition at line 291 of file Http.php.

00292     {
00293         return $this->_controllerModule;
00294     }

getDirectFrontNames (  ) 

Get list of front names available with access without store code

Returns:
array

Definition at line 185 of file Http.php.

00186     {
00187         return $this->_directFrontNames;
00188     }

getHttpHost ( trimPort = true  ) 

Retrieve HTTP HOST

Parameters:
bool $trimPort
Returns:
string

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.

Returns:
string

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 (  ) 

Definition at line 197 of file Http.php.

00198     {
00199         return $this->_requestString;
00200     }

getRouteName (  ) 

Definition at line 232 of file Http.php.

00233     {
00234         return $this->_route;
00235     }

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

Parameters:
string $code
Returns:
bool

Definition at line 174 of file Http.php.

00175     {
00176         $names = $this->getDirectFrontNames();
00177         return isset($names[$code]);
00178     }

setControllerModule ( module  ) 

Specify module name where was found currently used controller

Parameters:
string $module
Returns:
Mage_Core_Controller_Request_Http

Definition at line 280 of file Http.php.

00281     {
00282         $this->_controllerModule = $module;
00283         return $this;
00284     }

setPathInfo ( pathInfo = null  ) 

Set the PATH_INFO string Set the ORIGINAL_PATH_INFO string

Parameters:
string|null $pathInfo
Returns:
Zend_Controller_Request_Http

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 
)

Set a member of the $_POST superglobal

Parameters:
striing|array $key
mixed $value
Returns:
Mage_Core_Controller_Request_Http

Definition at line 263 of file Http.php.

00264     {
00265         if (is_array($key)) {
00266             $_POST = $key;
00267         }
00268         else {
00269             $_POST[$key] = $value;
00270         }
00271         return $this;
00272     }

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     }


Member Data Documentation

$_controllerModule = null [protected]

Definition at line 50 of file Http.php.

$_directFrontNames = array() [protected]

Definition at line 49 of file Http.php.

$_originalPathInfo = '' [protected]

Definition at line 43 of file Http.php.

$_requestString = '' [protected]

Definition at line 45 of file Http.php.

$_route [protected]

Definition at line 47 of file Http.php.

$_storeCode = null [protected]

Definition at line 44 of file Http.php.

const XML_NODE_DIRECT_FRONT_NAMES = 'global/request/direct_front_name'

Definition at line 37 of file Http.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:54 2009 for Magento by  doxygen 1.5.8