Mage_Core_Model_Url Class Reference

Inheritance diagram for Mage_Core_Model_Url:

Varien_Object Mage_Adminhtml_Model_Url

List of all members.

Public Member Functions

 parseUrl ($url)
 getDefaultControllerName ()
 setUseUrlCache ($flag)
 setUseSession ($useSession)
 setRouteFrontName ($name)
 getUseSession ()
 getDefaultActionName ()
 getConfigData ($key, $prefix=null)
 setRequest (Zend_Controller_Request_Http $request)
 getRequest ()
 getType ()
 getSecure ()
 setStore ($data)
 getStore ()
 getBaseUrl ($params=array())
 setRoutePath ($data)
 getActionPath ()
 getRoutePath ($routeParams=array())
 setRouteName ($data)
 getRouteFrontName ()
 getRouteName ()
 setControllerName ($data)
 getControllerName ()
 setActionName ($data)
 getActionName ()
 setRouteParams (array $data, $unsetOldParams=true)
 getRouteParams ()
 setRouteParam ($key, $data)
 getRouteParam ($key)
 getRouteUrl ($routePath=null, $routeParams=null)
 checkCookieDomains ()
 addSessionParam ()
 setQuery ($data)
 getQuery ($escape=false)
 setQueryParams (array $data, $useCurrent=false)
 getQueryParams ()
 setQueryParam ($key, $data)
 getQueryParam ($key)
 setFragment ($data)
 getFragment ()
 getUrl ($routePath=null, $routeParams=null)
 escape ($value)
 getDirectUrl ($url, $params=array())
 sessionUrlVar ($html)
 useSessionIdForUrl ($secure=false)
 sessionVarCallback ($match)

Public Attributes

const DEFAULT_CONTROLLER_NAME = 'index'
const DEFAULT_ACTION_NAME = 'index'
const XML_PATH_UNSECURE_URL = 'web/unsecure/base_url'
const XML_PATH_SECURE_URL = 'web/secure/base_url'
const XML_PATH_SECURE_IN_ADMIN = 'web/secure/use_in_adminhtml'
const XML_PATH_SECURE_IN_FRONT = 'web/secure/use_in_frontend'

Protected Member Functions

 _construct ()
 _prepareSessionUrl ($url)

Protected Attributes

 $_reservedRouteParams
 $_request
 $_useSession

Static Protected Attributes

static $_configDataCache
static $_encryptedSessionId


Detailed Description

Definition at line 79 of file Url.php.


Member Function Documentation

_construct (  )  [protected]

Enter description here...

Reimplemented from Varien_Object.

Definition at line 118 of file Url.php.

00119     {
00120         $this->setStore(null);
00121     }

_prepareSessionUrl ( url  )  [protected]

Check and add session id to URL

Parameters:
string $url
Returns:
Mage_Core_Model_Url

Definition at line 836 of file Url.php.

00837     {
00838         if (!$this->getUseSession()) {
00839             return $this;
00840         }
00841         $session = Mage::getSingleton('core/session');
00842         /* @var $session Mage_Core_Model_Session */
00843         if (Mage::app()->getUseSessionVar()) {
00844             // secure URL
00845             if ($this->getSecure()) {
00846                 $this->setQueryParam('___SID', 'S');
00847             }
00848             else {
00849                 $this->setQueryParam('___SID', 'U');
00850             }
00851         }
00852         else {
00853             if ($sessionId = $session->getSessionIdForHost($url)) {
00854                 $this->setQueryParam($session->getSessionIdQueryParam(), $sessionId);
00855             }
00856         }
00857         return $this;
00858     }

addSessionParam (  ) 

Definition at line 650 of file Url.php.

00651     {
00652         $session = Mage::getSingleton('core/session');
00653 
00654         if (!self::$_encryptedSessionId) {
00655             $helper = Mage::helper('core');
00656             if (!$helper) {
00657                 return $this;
00658             }
00659             self::$_encryptedSessionId = $session->getEncryptedSessionId();
00660         }
00661         $this->setQueryParam(
00662             $session->getSessionIdQueryParam(),
00663             self::$_encryptedSessionId
00664         );
00665         return $this;
00666     }

checkCookieDomains (  ) 

If the host was switched but session cookie won't recognize it - add session id to query

Returns:
unknown

Definition at line 628 of file Url.php.

00629     {
00630         $hostArr = explode(':', $this->getRequest()->getServer('HTTP_HOST'));
00631         if ($hostArr[0]!==$this->getHost()) {
00632             $session = Mage::getSingleton('core/session');
00633             if (!$session->isValidForHost($this->getHost())) {
00634                 if (!self::$_encryptedSessionId) {
00635                     $helper = Mage::helper('core');
00636                     if (!$helper) {
00637                         return $this;
00638                     }
00639                     self::$_encryptedSessionId = $session->getEncryptedSessionId();
00640                 }
00641                 $this->setQueryParam(
00642                     $session->getSessionIdQueryParam(),
00643                     self::$_encryptedSessionId
00644                 );
00645             }
00646         }
00647         return $this;
00648     }

escape ( value  ) 

Escape (enclosure) URL string

Parameters:
string $value
Returns:
string

Definition at line 866 of file Url.php.

00867     {
00868         $value = str_replace('"', '%22', $value);
00869         $value = str_replace("'", '%27', $value);
00870         $value = str_replace('>', '%3E', $value);
00871         $value = str_replace('<', '%3C', $value);
00872         return $value;
00873     }

getActionName (  ) 

Definition at line 503 of file Url.php.

00504     {
00505         return $this->_getData('action_name');
00506     }

getActionPath (  ) 

Definition at line 386 of file Url.php.

00387     {
00388         if (!$this->getRouteName()) {
00389             return '';
00390         }
00391 
00392         $hasParams = (bool)$this->getRouteParams();
00393         $path = $this->getRouteFrontName() . '/';
00394 
00395         if ($this->getControllerName()) {
00396             $path .= $this->getControllerName() . '/';
00397         } elseif ($hasParams) {
00398             $path .= $this->getDefaultControllerName() . '/';
00399         }
00400         if ($this->getActionName()) {
00401             $path .= $this->getActionName() . '/';
00402         } elseif ($hasParams) {
00403             $path .= $this->getDefaultActionName() . '/';
00404         }
00405 
00406         return $path;
00407     }

getBaseUrl ( params = array()  ) 

Retrieve Base URL

Parameters:
array $params
Returns:
string

Add availability support urls without store code

Definition at line 306 of file Url.php.

00307     {
00308         if (isset($params['_store'])) {
00309             $this->setStore($params['_store']);
00310         }
00311         if (isset($params['_type'])) {
00312             $this->setType($params['_type']);
00313         }
00314         if (isset($params['_secure'])) {
00315             $this->setSecure($params['_secure']);
00316         }
00317 
00318         /**
00319          * Add availability support urls without store code
00320          */
00321         if ($this->getType() == Mage_Core_Model_Store::URL_TYPE_LINK
00322             && Mage::app()->getRequest()->isDirectAccessFrontendName($this->getRouteFrontName())) {
00323             $this->setType(Mage_Core_Model_Store::URL_TYPE_DIRECT_LINK);
00324         }
00325 
00326         return $this->getStore()->getBaseUrl($this->getType(), $this->getSecure());
00327     }

getConfigData ( key,
prefix = null 
)

Definition at line 207 of file Url.php.

00208     {
00209         if (is_null($prefix)) {
00210             $prefix = 'web/'.($this->getSecure() ? 'secure' : 'unsecure').'/';
00211         }
00212         $path = $prefix.$key;
00213 
00214         $cacheId = $this->getStore()->getCode().'/'.$path;
00215         if (!isset(self::$_configDataCache[$cacheId])) {
00216             $data = $this->getStore()->getConfig($path);
00217             self::$_configDataCache[$cacheId] = $data;
00218         }
00219 
00220         return self::$_configDataCache[$cacheId];
00221     }

getControllerName (  ) 

Definition at line 482 of file Url.php.

00483     {
00484         return $this->_getData('controller_name');
00485     }

getDefaultActionName (  ) 

Retrieve default action name

Returns:
string

Definition at line 202 of file Url.php.

00203     {
00204         return self::DEFAULT_ACTION_NAME;
00205     }

getDefaultControllerName (  ) 

Retrieve default controller name

Returns:
string

Definition at line 155 of file Url.php.

00156     {
00157         return self::DEFAULT_CONTROLLER_NAME;
00158     }

getDirectUrl ( url,
params = array() 
)

Build url by direct url and parameters

Parameters:
string $url
array $params
Returns:
string

Definition at line 882 of file Url.php.

00882                                                           {
00883         $params['_direct'] = $url;
00884         return $this->getUrl('', $params);
00885     }

getFragment (  ) 

Definition at line 758 of file Url.php.

00759     {
00760         return $this->_getData('fragment');
00761     }

getQuery ( escape = false  ) 

Definition at line 683 of file Url.php.

00684     {
00685         if (!$this->hasData('query')) {
00686             $query = '';
00687             if (is_array($this->getQueryParams())) {
00688                 $query = http_build_query($this->getQueryParams(), '', $escape ? '&amp;' : '&');
00689             }
00690             $this->setData('query', $query);
00691         }
00692         return $this->_getData('query');
00693     }

getQueryParam ( key  ) 

Definition at line 739 of file Url.php.

00740     {
00741         if (!$this->hasData('query_params')) {
00742             $this->getQueryParams();
00743         }
00744         return $this->_getData('query_params', $key);
00745     }

getQueryParams (  ) 

Definition at line 713 of file Url.php.

00714     {
00715         if (!$this->hasData('query_params')) {
00716             $params = array();
00717             if ($this->_getData('query')) {
00718                 foreach (explode('&', $this->_getData('query')) as $param) {
00719                     $paramArr = explode('=', $param);
00720                     $params[$paramArr[0]] = urldecode($paramArr[1]);
00721                 }
00722             }
00723             $this->setData('query_params', $params);
00724         }
00725         return $this->_getData('query_params');
00726     }

getRequest (  ) 

Zend request object

Returns:
Zend_Controller_Request_Http

Definition at line 234 of file Url.php.

00235     {
00236         if (!$this->_request) {
00237             $this->_request = Mage::app()->getRequest();
00238         }
00239         return $this->_request;
00240     }

getRouteFrontName (  ) 

Definition at line 448 of file Url.php.

00449     {
00450         if (!$this->hasData('route_front_name')) {
00451             $routeName = $this->getRouteName();
00452             $route = Mage::app()->getFrontController()->getRouterByRoute($routeName);
00453             $frontName = $route->getFrontNameByRoute($routeName);
00454 
00455             $this->setRouteFrontName($frontName);
00456         }
00457 
00458         return $this->_getData('route_front_name');
00459     }

getRouteName (  ) 

Definition at line 461 of file Url.php.

00462     {
00463         return $this->_getData('route_name');
00464     }

getRouteParam ( key  ) 

Definition at line 599 of file Url.php.

00600     {
00601         return $this->_getData('route_params', $key);
00602     }

getRouteParams (  ) 

Definition at line 583 of file Url.php.

00584     {
00585         return $this->_getData('route_params');
00586     }

getRoutePath ( routeParams = array()  ) 

Definition at line 409 of file Url.php.

00410     {
00411         if (!$this->hasData('route_path')) {
00412             $routePath = $this->getRequest()->getAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS);
00413             if (!empty($routeParams['_use_rewrite'])
00414                 && ($routePath !== null)) {
00415                 $this->setData('route_path', $routePath);
00416                 return $routePath;
00417             }
00418             $routePath = $this->getActionPath();
00419             if ($this->getRouteParams()) {
00420                 foreach ($this->getRouteParams() as $key=>$value) {
00421                     if (is_null($value) || false===$value || ''===$value || !is_scalar($value)) {
00422                         continue;
00423                     }
00424                     $routePath .= $key.'/'.$value.'/';
00425                 }
00426             }
00427             if ($routePath != '' && substr($routePath, -1, 1) !== '/') {
00428                 $routePath.= '/';
00429             }
00430             $this->setData('route_path', $routePath);
00431         }
00432         return $this->_getData('route_path');
00433     }

getRouteUrl ( routePath = null,
routeParams = null 
)

Definition at line 604 of file Url.php.

00605     {
00606         $this->unsetData('route_params');
00607 
00608         if (isset($routeParams['_direct'])) {
00609             return $this->getBaseUrl().$routeParams['_direct'];
00610         }
00611 
00612         if (!is_null($routePath)) {
00613             $this->setRoutePath($routePath);
00614         }
00615         if (is_array($routeParams)) {
00616             $this->setRouteParams($routeParams, false);
00617         }
00618 
00619         $url = $this->getBaseUrl().$this->getRoutePath($routeParams);
00620         return $url;
00621     }

getSecure (  ) 

Retrieve is secure mode URL

Returns:
bool

Mage.getStoreConfigFlag(self.XML_PATH_SECURE_IN_ADMIN, $this->getStore()->getId())

Mage.getStoreConfigFlag(self.XML_PATH_SECURE_IN_FRONT

Reimplemented in Mage_Adminhtml_Model_Url.

Definition at line 255 of file Url.php.

00256     {
00257         if ($this->hasData('secure_is_forced')) {
00258             return $this->getData('secure');
00259         }
00260 
00261         $store = $this->getStore();
00262 
00263         if ($store->isAdmin() && !$store->isAdminUrlSecure()) { //!Mage::getStoreConfigFlag(self::XML_PATH_SECURE_IN_ADMIN, $this->getStore()->getId())
00264             return false;
00265         }
00266         if (!$store->isAdmin() && !$store->isFrontUrlSecure()) {//!Mage::getStoreConfigFlag(self::XML_PATH_SECURE_IN_FRONT
00267             return false;
00268         }
00269 
00270         if (!$this->hasData('secure')) {
00271             if ($this->getType() == Mage_Core_Model_Store::URL_TYPE_LINK) {
00272                 $pathSecure = Mage::getConfig()->shouldUrlBeSecure('/'.$this->getActionPath());
00273                 $this->setData('secure', $pathSecure);
00274             } else {
00275                 $this->setData('secure', $store->isCurrentlySecure());
00276             }
00277         }
00278         return $this->getData('secure');
00279     }

getStore (  ) 

Get current store for the url instance

Returns:
Mage_Core_Model_Store

Definition at line 292 of file Url.php.

00293     {
00294         if (!$this->hasData('store')) {
00295             $this->setStore(null);
00296         }
00297         return $this->_getData('store');
00298     }

getType (  ) 

Definition at line 242 of file Url.php.

00243     {
00244         if (!$this->hasData('type')) {
00245             $this->setData('type', Mage_Core_Model_Store::URL_TYPE_LINK);
00246         }
00247         return $this->_getData('type');
00248     }

getUrl ( routePath = null,
routeParams = null 
)

Build url by requested path and parameters

Parameters:
string $routePath
array $routeParams
Returns:
string

All system params should be unseted before we call getRouteUrl this method has condition for ading default controller anr actions names in case when we have params

Apply query params, need call after getRouteUrl for rewrite _current values

Reimplemented in Mage_Adminhtml_Model_Url.

Definition at line 770 of file Url.php.

00771     {
00772         $escapeQuery = false;
00773 
00774         /**
00775          * All system params should be unseted before we call getRouteUrl
00776          * this method has condition for ading default controller anr actions names
00777          * in case when we have params
00778          */
00779         if (isset($routeParams['_fragment'])) {
00780             $this->setFragment($routeParams['_fragment']);
00781             unset($routeParams['_fragment']);
00782         }
00783 
00784         if (isset($routeParams['_escape'])) {
00785             $escapeQuery = $routeParams['_escape'];
00786             unset($routeParams['_escape']);
00787         }
00788 
00789         $query = null;
00790         if (isset($routeParams['_query'])) {
00791             $query = $routeParams['_query'];
00792             unset($routeParams['_query']);
00793         }
00794 
00795         $noSid = null;
00796         if (isset($routeParams['_nosid'])) {
00797             $noSid = (bool)$routeParams['_nosid'];
00798             unset($routeParams['_nosid']);
00799         }
00800         $url = $this->getRouteUrl($routePath, $routeParams);
00801         /**
00802          * Apply query params, need call after getRouteUrl for rewrite _current values
00803          */
00804         if ($query !== null) {
00805             if (is_string($query)) {
00806                 $this->setQuery($query);
00807             } elseif (is_array($query)) {
00808                 $this->setQueryParams($query, !empty($routeParams['_current']));
00809             }
00810             if ($query === false) {
00811                 $this->setQueryParams(array());
00812             }
00813         }
00814 
00815         if ($noSid !== true) {
00816             $this->_prepareSessionUrl($url);
00817         }
00818 
00819         if ($query = $this->getQuery($escapeQuery)) {
00820             $url .= '?'.$query;
00821         }
00822 
00823         if ($this->getFragment()) {
00824             $url .= '#'.$this->getFragment();
00825         }
00826 
00827         return $this->escape($url);
00828     }

getUseSession (  ) 

Retrieve use session rule

Returns:
bool

Definition at line 189 of file Url.php.

00190     {
00191         if (is_null($this->_useSession)) {
00192             $this->_useSession = Mage::app()->getUseSessionInUrl();
00193         }
00194         return $this->_useSession;
00195     }

parseUrl ( url  ) 

Initialize object data from retrieved url

Parameters:
string $url
Returns:
Mage_Core_Model_Url

Definition at line 129 of file Url.php.

00130     {
00131         $data   = parse_url($url);
00132         $parts  = array(
00133             'scheme'=>'setScheme',
00134             'host'  =>'setHost',
00135             'port'  =>'setPort',
00136             'user'  =>'setUser',
00137             'pass'  =>'setPassword',
00138             'path'  =>'setPath',
00139             'query' =>'setQuery',
00140             'fragment'=>'setFragment');
00141 
00142         foreach ($parts as $component=>$method) {
00143             if (isset($data[$component])) {
00144                 $this->$method($data[$component]);
00145             }
00146         }
00147         return $this;
00148     }

sessionUrlVar ( html  ) 

Replace Session ID value in URL

Parameters:
string $html
Returns:
string

Definition at line 893 of file Url.php.

00894     {
00895         return preg_replace_callback('#(\?|&amp;|&)___SID=([SU])(&amp;|&)?#', array($this, "sessionVarCallback"), $html);
00896     }

sessionVarCallback ( match  ) 

Callback function for session replace

Parameters:
array $match
Returns:
string

Definition at line 927 of file Url.php.

00928     {
00929         if ($this->useSessionIdForUrl($match[2] == 'S' ? true : false)) {
00930             $session = Mage::getSingleton('core/session');
00931             /* @var $session Mage_Core_Model_Session */
00932             return $match[1]
00933                 . $session->getSessionIdQueryParam()
00934                 . '=' . $session->getEncryptedSessionId()
00935                 . (isset($match[3]) ? $match[3] : '');
00936         }
00937         else {
00938             if ($match[1] == '?' && isset($match[3])) {
00939                 return '?';
00940             }
00941             elseif ($match[1] == '?' && !isset($match[3])) {
00942                 return '';
00943             }
00944             elseif (($match[1] == '&amp;' || $match[1] == '&') && !isset($match[3])) {
00945                 return '';
00946             }
00947             elseif (($match[1] == '&amp;' || $match[1] == '&') && isset($match[3])) {
00948                 return $match[3];
00949             }
00950         }
00951         return '';
00952     }

setActionName ( data  ) 

Set Action name Reseted route path if action name has change

Parameters:
string $data
Returns:
Mage_Core_Model_Url

Definition at line 494 of file Url.php.

00495     {
00496         if ($this->_getData('action_name') == $data) {
00497             return $this;
00498         }
00499         $this->unsetData('route_path');
00500         return $this->setData('action_name', $data)->unsetData('secure');
00501     }

setControllerName ( data  ) 

Set Controller Name Reset action name and route path if has change

Parameters:
string $data
Returns:
Mage_Core_Model_Url

Definition at line 473 of file Url.php.

00474     {
00475         if ($this->_getData('controller_name')==$data) {
00476             return $this;
00477         }
00478         $this->unsetData('route_path')->unsetData('action_name')->unsetData('secure');
00479         return $this->setData('controller_name', $data);
00480     }

setFragment ( data  ) 

Set fragment to URL

Parameters:
string $data
Returns:
Mage_Core_Model_Url

Definition at line 753 of file Url.php.

00754     {
00755         return $this->setData('fragment', $data);
00756     }

setQuery ( data  ) 

Set URL query param(s)

Parameters:
mixed $data
Returns:
Mage_Core_Model_Url

Definition at line 674 of file Url.php.

00675     {
00676         if ($this->_getData('query') == $data) {
00677             return $this;
00678         }
00679         $this->unsetData('query_params');
00680         return $this->setData('query', $data);
00681     }

setQueryParam ( key,
data 
)

Definition at line 728 of file Url.php.

00729     {
00730         $params = $this->getQueryParams();
00731         if (isset($params[$key]) && $params[$key]==$data) {
00732             return $this;
00733         }
00734         $params[$key] = $data;
00735         $this->unsetData('query');
00736         return $this->setData('query_params', $params);
00737     }

setQueryParams ( array data,
useCurrent = false 
)

Definition at line 695 of file Url.php.

00696     {
00697         $this->unsetData('query');
00698         if ($useCurrent) {
00699             $params = $this->_getData('query_params');
00700             foreach ($data as $param => $value) {
00701                 $params[$param] = $value;
00702             }
00703             $this->setData('query_params', $params);
00704             return $this;
00705         }
00706 
00707         if ($this->_getData('query_params')==$data) {
00708             return $this;
00709         }
00710         return $this->setData('query_params', $data);
00711     }

setRequest ( Zend_Controller_Request_Http $  request  ) 

Definition at line 223 of file Url.php.

00224     {
00225         $this->_request = $request;
00226         return $this;
00227     }

setRouteFrontName ( name  ) 

Definition at line 178 of file Url.php.

00179     {
00180         $this->setData('route_front_name', $name);
00181         return $this;
00182     }

setRouteName ( data  ) 

Definition at line 435 of file Url.php.

00436     {
00437         if ($this->_getData('route_name')==$data) {
00438             return $this;
00439         }
00440         $this->unsetData('route_front_name')
00441             ->unsetData('route_path')
00442             ->unsetData('controller_name')
00443             ->unsetData('action_name')
00444             ->unsetData('secure');
00445         return $this->setData('route_name', $data);
00446     }

setRouteParam ( key,
data 
)

Definition at line 588 of file Url.php.

00589     {
00590         $params = $this->_getData('route_params');
00591         if (isset($params[$key]) && $params[$key]==$data) {
00592             return $this;
00593         }
00594         $params[$key] = $data;
00595         $this->unsetData('route_path');
00596         return $this->setData('route_params', $params);
00597     }

setRouteParams ( array data,
unsetOldParams = true 
)

Reimplemented in Mage_Adminhtml_Model_Url.

Definition at line 508 of file Url.php.

00509     {
00510         if (isset($data['_type'])) {
00511             $this->setType($data['_type']);
00512             unset($data['_type']);
00513         }
00514 
00515         if (isset($data['_store'])) {
00516             $this->setStore($data['_store']);
00517             unset($data['_store']);
00518         }
00519 
00520         if (isset($data['_forced_secure'])) {
00521             $this->setSecure((bool)$data['_forced_secure']);
00522             $this->setSecureIsForced(true);
00523             unset($data['_forced_secure']);
00524         } else {
00525             if (isset($data['_secure'])) {
00526                 $this->setSecure((bool)$data['_secure']);
00527                 unset($data['_secure']);
00528             }
00529         }
00530 
00531         if (isset($data['_absolute'])) {
00532             unset($data['_absolute']);
00533         }
00534 
00535         if ($unsetOldParams) {
00536             $this->unsetData('route_params');
00537         }
00538 
00539         $this->setUseUrlCache(true);
00540         if (isset($data['_current'])) {
00541             if (is_array($data['_current'])) {
00542                 foreach ($data['_current'] as $key) {
00543                     if (array_key_exists($key, $data) || !$this->getRequest()->getUserParam($key)) {
00544                         continue;
00545                     }
00546                     $data[$key] = $this->getRequest()->getUserParam($key);
00547                 }
00548             } elseif ($data['_current']) {
00549                 foreach ($this->getRequest()->getUserParams() as $key=>$value) {
00550                     if (array_key_exists($key, $data) || $this->getRouteParam($key)) {
00551                         continue;
00552                     }
00553                     $data[$key] = $value;
00554                 }
00555                 foreach ($this->getRequest()->getQuery() as $key=>$value) {
00556                     $this->setQueryParam($key, $value);
00557                 }
00558                 $this->setUseUrlCache(false);
00559             }
00560             unset($data['_current']);
00561         }
00562 
00563         if (isset($data['_use_rewrite'])) {
00564             unset($data['_use_rewrite']);
00565         }
00566 
00567         if (isset($data['_store_to_url']) && (bool)$data['_store_to_url'] === true) {
00568             if (!Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL, $this->getStore())
00569                 && !Mage::app()->isSingleStoreMode()
00570             ) {
00571                 $this->setQueryParam('___store', $this->getStore()->getCode());
00572             }
00573             unset($data['_store_to_url']);
00574         }
00575 
00576         foreach ($data as $k=>$v) {
00577             $this->setRouteParam($k, $v);
00578         }
00579 
00580         return $this;
00581     }

setRoutePath ( data  ) 

Set Route Parameters

Parameters:
array $data
Returns:
Mage_Core_Model_Url

Definition at line 335 of file Url.php.

00336     {
00337         if ($this->_getData('route_path')==$data) {
00338             return $this;
00339         }
00340 
00341         $a = explode('/', $data);
00342 
00343         $route = array_shift($a);
00344         if ('*'===$route) {
00345             $route = $this->getRequest()->getRouteName();
00346         }
00347         $this->setRouteName($route);
00348         $routePath = $route.'/';
00349 
00350         if (!empty($a)) {
00351             $controller = array_shift($a);
00352             if ('*'===$controller) {
00353                 $controller = $this->getRequest()->getControllerName();
00354             }
00355             $this->setControllerName($controller);
00356             $routePath .= $controller.'/';
00357         }
00358 
00359         if (!empty($a)) {
00360             $action = array_shift($a);
00361             if ('*'===$action) {
00362                 $action = $this->getRequest()->getActionName();
00363             }
00364             $this->setActionName($action);
00365             $routePath .= $action.'/';
00366         }
00367 
00368         if (!empty($a)) {
00369             $this->unsetData('route_params');
00370             while (!empty($a)) {
00371                 $key = array_shift($a);
00372                 if (!empty($a)) {
00373                     $value = array_shift($a);
00374                     $this->setRouteParam($key, $value);
00375                     #$routePath .= $key.'/'.urlencode($value).'/';
00376                     $routePath .= $key.'/'.$value.'/';
00377                 }
00378             }
00379         }
00380 
00381         #$this->setData('route_path', $routePath);
00382 
00383         return $this;
00384     }

setStore ( data  ) 

Definition at line 281 of file Url.php.

00282     {
00283         $this->setData('store', Mage::app()->getStore($data));
00284         return $this;
00285     }

setUseSession ( useSession  ) 

Set use session rule

Parameters:
bool $useSession
Returns:
Mage_Core_Model_Url

Definition at line 172 of file Url.php.

00173     {
00174         $this->_useSession = (bool)$useSession;
00175         return $this;
00176     }

setUseUrlCache ( flag  ) 

Definition at line 160 of file Url.php.

00161     {
00162         $this->setData('use_url_cache', $flag);
00163         return $this;
00164     }

useSessionIdForUrl ( secure = false  ) 

Check and return use SID for URL

Parameters:
bool $secure
Returns:
bool

Definition at line 904 of file Url.php.

00905     {
00906         $key = 'use_session_id_for_url_' . (int)$secure;
00907         if (is_null($this->getData($key))) {
00908             $httpHost = Mage::app()->getFrontController()->getRequest()->getHttpHost();
00909             $urlHost = parse_url(Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, $secure), PHP_URL_HOST);
00910 
00911             if ($httpHost != $urlHost) {
00912                 $this->setData($key, true);
00913             }
00914             else {
00915                 $this->setData($key, false);
00916             }
00917         }
00918         return $this->getData($key);
00919     }


Member Data Documentation

$_configDataCache [static, protected]

Definition at line 90 of file Url.php.

$_encryptedSessionId [static, protected]

Definition at line 91 of file Url.php.

$_request [protected]

Definition at line 109 of file Url.php.

$_reservedRouteParams [protected]

Initial value:

 array(
        '_store', '_type', '_secure', '_forced_secure', '_use_rewrite', '_nosid',
        '_absolute', '_current', '_direct', '_fragment', '_escape', '_query',
        '_store_to_url'
    )

Definition at line 98 of file Url.php.

$_useSession [protected]

Definition at line 116 of file Url.php.

const DEFAULT_ACTION_NAME = 'index'

Definition at line 82 of file Url.php.

const DEFAULT_CONTROLLER_NAME = 'index'

Definition at line 81 of file Url.php.

const XML_PATH_SECURE_IN_ADMIN = 'web/secure/use_in_adminhtml'

Definition at line 87 of file Url.php.

const XML_PATH_SECURE_IN_FRONT = 'web/secure/use_in_frontend'

Definition at line 88 of file Url.php.

const XML_PATH_SECURE_URL = 'web/secure/base_url'

Definition at line 85 of file Url.php.

const XML_PATH_UNSECURE_URL = 'web/unsecure/base_url'

Definition at line 84 of file Url.php.


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

Generated on Sat Jul 4 17:24:01 2009 for Magento by  doxygen 1.5.8