Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage
  • Mage_Adminhtml_Block_Html_Date
  • Mage_Adminhtml_Block_Html_Select
  • Mage_Api_Model_Wsdl_Config_Element
  • Mage_Captcha_Adminhtml_RefreshController
  • Mage_Captcha_RefreshController
  • Mage_Core_AjaxController
  • Mage_Core_Block_Abstract
  • Mage_Core_Block_Flush
  • Mage_Core_Block_Html_Calendar
  • Mage_Core_Block_Html_Date
  • Mage_Core_Block_Html_Link
  • Mage_Core_Block_Html_Select
  • Mage_Core_Block_Messages
  • Mage_Core_Block_Profiler
  • Mage_Core_Block_Store_Switcher
  • Mage_Core_Block_Template
  • Mage_Core_Block_Template_Facade
  • Mage_Core_Block_Template_Smarty
  • Mage_Core_Block_Template_Zend
  • Mage_Core_Block_Text
  • Mage_Core_Block_Text_List
  • Mage_Core_Block_Text_List_Item
  • Mage_Core_Block_Text_List_Link
  • Mage_Core_Block_Text_Tag
  • Mage_Core_Block_Text_Tag_Css
  • Mage_Core_Block_Text_Tag_Css_Admin
  • Mage_Core_Block_Text_Tag_Debug
  • Mage_Core_Block_Text_Tag_Js
  • Mage_Core_Block_Text_Tag_Meta
  • Mage_Core_Controller_Front_Action
  • Mage_Core_Controller_Front_Router
  • Mage_Core_Controller_Request_Http
  • Mage_Core_Controller_Response_Http
  • Mage_Core_Controller_Varien_Action
  • Mage_Core_Controller_Varien_Front
  • Mage_Core_Controller_Varien_Router_Abstract
  • Mage_Core_Controller_Varien_Router_Admin
  • Mage_Core_Controller_Varien_Router_Default
  • Mage_Core_Controller_Varien_Router_Standard
  • Mage_Core_Helper_Abstract
  • Mage_Core_Helper_Cookie
  • Mage_Core_Helper_Data
  • Mage_Core_Helper_File_Storage
  • Mage_Core_Helper_File_Storage_Database
  • Mage_Core_Helper_Hint
  • Mage_Core_Helper_Http
  • Mage_Core_Helper_Js
  • Mage_Core_Helper_String
  • Mage_Core_Helper_Translate
  • Mage_Core_Helper_Url
  • Mage_Core_Helper_Url_Rewrite
  • Mage_Core_IndexController
  • Mage_Core_Model_Abstract
  • Mage_Core_Model_App
  • Mage_Core_Model_App_Area
  • Mage_Core_Model_App_Emulation
  • Mage_Core_Model_Cache
  • Mage_Core_Model_Calculator
  • Mage_Core_Model_Config
  • Mage_Core_Model_Config_Base
  • Mage_Core_Model_Config_Data
  • Mage_Core_Model_Config_Element
  • Mage_Core_Model_Config_Options
  • Mage_Core_Model_Config_System
  • Mage_Core_Model_Cookie
  • Mage_Core_Model_Date
  • Mage_Core_Model_Design
  • Mage_Core_Model_Design_Package
  • Mage_Core_Model_Design_Source_Design
  • Mage_Core_Model_Email
  • Mage_Core_Model_Email_Info
  • Mage_Core_Model_Email_Template
  • Mage_Core_Model_Email_Template_Filter
  • Mage_Core_Model_Email_Template_Mailer
  • Mage_Core_Model_Email_Transport
  • Mage_Core_Model_Encryption
  • Mage_Core_Model_File_Storage
  • Mage_Core_Model_File_Storage_Abstract
  • Mage_Core_Model_File_Storage_Database
  • Mage_Core_Model_File_Storage_Database_Abstract
  • Mage_Core_Model_File_Storage_Directory_Database
  • Mage_Core_Model_File_Storage_File
  • Mage_Core_Model_File_Storage_Flag
  • Mage_Core_Model_File_Uploader
  • Mage_Core_Model_File_Validator_AvailablePath
  • Mage_Core_Model_File_Validator_NotProtectedExtension
  • Mage_Core_Model_Flag
  • Mage_Core_Model_Input_Filter
  • Mage_Core_Model_Input_Filter_MaliciousCode
  • Mage_Core_Model_Language
  • Mage_Core_Model_Layout
  • Mage_Core_Model_Layout_Data
  • Mage_Core_Model_Layout_Element
  • Mage_Core_Model_Layout_Update
  • Mage_Core_Model_Locale
  • Mage_Core_Model_Locale_Config
  • Mage_Core_Model_Log_Adapter
  • Mage_Core_Model_Magento_Api
  • Mage_Core_Model_Magento_Api_V2
  • Mage_Core_Model_Message
  • Mage_Core_Model_Message_Abstract
  • Mage_Core_Model_Message_Collection
  • Mage_Core_Model_Message_Error
  • Mage_Core_Model_Message_Notice
  • Mage_Core_Model_Message_Success
  • Mage_Core_Model_Message_Warning
  • Mage_Core_Model_Mysql4_Abstract
  • Mage_Core_Model_Mysql4_Cache
  • Mage_Core_Model_Mysql4_Collection_Abstract
  • Mage_Core_Model_Mysql4_Config
  • Mage_Core_Model_Mysql4_Config_Data
  • Mage_Core_Model_Mysql4_Config_Data_Collection
  • Mage_Core_Model_Mysql4_Design
  • Mage_Core_Model_Mysql4_Design_Collection
  • Mage_Core_Model_Mysql4_Design_Package_Collection
  • Mage_Core_Model_Mysql4_Design_Theme
  • Mage_Core_Model_Mysql4_Email_Template
  • Mage_Core_Model_Mysql4_Email_Template_Collection
  • Mage_Core_Model_Mysql4_File_Storage_Abstract
  • Mage_Core_Model_Mysql4_File_Storage_Database
  • Mage_Core_Model_Mysql4_File_Storage_Directory_Database
  • Mage_Core_Model_Mysql4_File_Storage_File
  • Mage_Core_Model_Mysql4_Flag
  • Mage_Core_Model_Mysql4_Language
  • Mage_Core_Model_Mysql4_Language_Collection
  • Mage_Core_Model_Mysql4_Layout
  • Mage_Core_Model_Mysql4_Resource
  • Mage_Core_Model_Mysql4_Session
  • Mage_Core_Model_Mysql4_Store
  • Mage_Core_Model_Mysql4_Store_Collection
  • Mage_Core_Model_Mysql4_Store_Group
  • Mage_Core_Model_Mysql4_Store_Group_Collection
  • Mage_Core_Model_Mysql4_Translate
  • Mage_Core_Model_Mysql4_Translate_String
  • Mage_Core_Model_Mysql4_Url_Rewrite
  • Mage_Core_Model_Mysql4_Url_Rewrite_Collection
  • Mage_Core_Model_Mysql4_Variable
  • Mage_Core_Model_Mysql4_Variable_Collection
  • Mage_Core_Model_Mysql4_Website
  • Mage_Core_Model_Mysql4_Website_Collection
  • Mage_Core_Model_Observer
  • Mage_Core_Model_Resource
  • Mage_Core_Model_Resource_Abstract
  • Mage_Core_Model_Resource_Cache
  • Mage_Core_Model_Resource_Config
  • Mage_Core_Model_Resource_Config_Data
  • Mage_Core_Model_Resource_Config_Data_Collection
  • Mage_Core_Model_Resource_Db_Abstract
  • Mage_Core_Model_Resource_Db_Collection_Abstract
  • Mage_Core_Model_Resource_Design
  • Mage_Core_Model_Resource_Design_Collection
  • Mage_Core_Model_Resource_Design_Package_Collection
  • Mage_Core_Model_Resource_Email_Template
  • Mage_Core_Model_Resource_Email_Template_Collection
  • Mage_Core_Model_Resource_Entity_Abstract
  • Mage_Core_Model_Resource_Entity_Table
  • Mage_Core_Model_Resource_File_Storage_Abstract
  • Mage_Core_Model_Resource_File_Storage_Database
  • Mage_Core_Model_Resource_File_Storage_Directory_Database
  • Mage_Core_Model_Resource_File_Storage_File
  • Mage_Core_Model_Resource_Flag
  • Mage_Core_Model_Resource_Helper_Abstract
  • Mage_Core_Model_Resource_Helper_Mysql4
  • Mage_Core_Model_Resource_Iterator
  • Mage_Core_Model_Resource_Language
  • Mage_Core_Model_Resource_Language_Collection
  • Mage_Core_Model_Resource_Layout
  • Mage_Core_Model_Resource_Resource
  • Mage_Core_Model_Resource_Session
  • Mage_Core_Model_Resource_Setup
  • Mage_Core_Model_Resource_Setup_Query_Modifier
  • Mage_Core_Model_Resource_Store
  • Mage_Core_Model_Resource_Store_Collection
  • Mage_Core_Model_Resource_Store_Group
  • Mage_Core_Model_Resource_Store_Group_Collection
  • Mage_Core_Model_Resource_Transaction
  • Mage_Core_Model_Resource_Translate
  • Mage_Core_Model_Resource_Translate_String
  • Mage_Core_Model_Resource_Type_Abstract
  • Mage_Core_Model_Resource_Type_Db
  • Mage_Core_Model_Resource_Type_Db_Mysqli
  • Mage_Core_Model_Resource_Type_Db_Mysqli_Setup
  • Mage_Core_Model_Resource_Type_Db_Pdo_Mysql
  • Mage_Core_Model_Resource_Url_Rewrite
  • Mage_Core_Model_Resource_Url_Rewrite_Collection
  • Mage_Core_Model_Resource_Variable
  • Mage_Core_Model_Resource_Variable_Collection
  • Mage_Core_Model_Resource_Website
  • Mage_Core_Model_Resource_Website_Collection
  • Mage_Core_Model_Session
  • Mage_Core_Model_Session_Abstract
  • Mage_Core_Model_Session_Abstract_Varien
  • Mage_Core_Model_Session_Abstract_Zend
  • Mage_Core_Model_Source_Email_Variables
  • Mage_Core_Model_Store
  • Mage_Core_Model_Store_Api
  • Mage_Core_Model_Store_Api_V2
  • Mage_Core_Model_Store_Group
  • Mage_Core_Model_Template
  • Mage_Core_Model_Translate
  • Mage_Core_Model_Translate_Expr
  • Mage_Core_Model_Translate_Inline
  • Mage_Core_Model_Translate_String
  • Mage_Core_Model_Url
  • Mage_Core_Model_Url_Rewrite
  • Mage_Core_Model_Url_Validator
  • Mage_Core_Model_Variable
  • Mage_Core_Model_Variable_Config
  • Mage_Core_Model_Variable_Observer
  • Mage_Core_Model_Website
  • Mage_Page_Block_Switch
  • Mage_Page_Block_Template_Container
  • Mage_Page_Block_Template_Links
  • Mage_Page_Block_Template_Links_Block
  • Mage_Sales_Model_Quote_Address_Total_Collector

Exceptions

  • Mage_Core_Controller_Varien_Exception
  • Mage_Core_Exception
  • Mage_Core_Model_Session_Exception
  • Mage_Core_Model_Store_Exception

Functions

  • destruct
  • is_dir_writeable
  • is_empty_date
  • mageCoreErrorHandler
  • mageDebugBacktrace
  • mageDelTree
  • mageFindClassFile
  • mageParseCsv
  • mageSendErrorFooter
  • mageSendErrorHeader
  • mageUndoMagicQuotes
  • now
  • sys_get_temp_dir
  • uc_words
  • Overview
  • Package
  • Class
  • Tree
   1: <?php
   2: /**
   3:  * Magento
   4:  *
   5:  * NOTICE OF LICENSE
   6:  *
   7:  * This source file is subject to the Open Software License (OSL 3.0)
   8:  * that is bundled with this package in the file LICENSE.txt.
   9:  * It is also available through the world-wide-web at this URL:
  10:  * http://opensource.org/licenses/osl-3.0.php
  11:  * If you did not receive a copy of the license and are unable to
  12:  * obtain it through the world-wide-web, please send an email
  13:  * to license@magentocommerce.com so we can send you a copy immediately.
  14:  *
  15:  * DISCLAIMER
  16:  *
  17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
  18:  * versions in the future. If you wish to customize Magento for your
  19:  * needs please refer to http://www.magentocommerce.com for more information.
  20:  *
  21:  * @category    Mage
  22:  * @package     Mage_Core
  23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
  24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  25:  */
  26: 
  27: /**
  28:  * URL
  29:  *
  30:  * Properties:
  31:  *
  32:  * - request
  33:  *
  34:  * - relative_url: true, false
  35:  * - type: 'link', 'skin', 'js', 'media'
  36:  * - store: instanceof Mage_Core_Model_Store
  37:  * - secure: true, false
  38:  *
  39:  * - scheme: 'http', 'https'
  40:  * - user: 'user'
  41:  * - password: 'password'
  42:  * - host: 'localhost'
  43:  * - port: 80, 443
  44:  * - base_path: '/dev/magento/'
  45:  * - base_script: 'index.php'
  46:  *
  47:  * - storeview_path: 'storeview/'
  48:  * - route_path: 'module/controller/action/param1/value1/param2/value2'
  49:  * - route_name: 'module'
  50:  * - controller_name: 'controller'
  51:  * - action_name: 'action'
  52:  * - route_params: array('param1'=>'value1', 'param2'=>'value2')
  53:  *
  54:  * - query: (?)'param1=value1&param2=value2'
  55:  * - query_array: array('param1'=>'value1', 'param2'=>'value2')
  56:  * - fragment: (#)'fragment-anchor'
  57:  *
  58:  * URL structure:
  59:  *
  60:  * https://user:password@host:443/base_path/[base_script][storeview_path]route_name/controller_name/action_name/param1/value1?query_param=query_value#fragment
  61:  *       \__________A___________/\____________________________________B_____________________________________/
  62:  * \__________________C___________________/              \__________________D_________________/ \_____E_____/
  63:  * \_____________F______________/                        \___________________________G______________________/
  64:  * \___________________________________________________H____________________________________________________/
  65:  *
  66:  * - A: authority
  67:  * - B: path
  68:  * - C: absolute_base_url
  69:  * - D: action_path
  70:  * - E: route_params
  71:  * - F: host_url
  72:  * - G: route_path
  73:  * - H: route_url
  74:  *
  75:  * @category   Mage
  76:  * @package    Mage_Core
  77:  * @author      Magento Core Team <core@magentocommerce.com>
  78:  */
  79: class Mage_Core_Model_Url extends Varien_Object
  80: {
  81:     /**
  82:      * Default controller name
  83:      */
  84:     const DEFAULT_CONTROLLER_NAME   = 'index';
  85: 
  86:     /**
  87:      * Default action name
  88:      */
  89:     const DEFAULT_ACTION_NAME       = 'index';
  90: 
  91:     /**
  92:      * Configuration paths
  93:      */
  94:     const XML_PATH_UNSECURE_URL     = 'web/unsecure/base_url';
  95:     const XML_PATH_SECURE_URL       = 'web/secure/base_url';
  96:     const XML_PATH_SECURE_IN_ADMIN  = 'default/web/secure/use_in_adminhtml';
  97:     const XML_PATH_SECURE_IN_FRONT  = 'web/secure/use_in_frontend';
  98: 
  99:     /**
 100:      * Configuration data cache
 101:      *
 102:      * @var array
 103:      */
 104:     static protected $_configDataCache;
 105: 
 106:     /**
 107:      * Encrypted session identifier
 108:      *
 109:      * @var string|null
 110:      */
 111:     static protected $_encryptedSessionId;
 112: 
 113:     /**
 114:      * Reserved Route parameter keys
 115:      *
 116:      * @var array
 117:      */
 118:     protected $_reservedRouteParams = array(
 119:         '_store', '_type', '_secure', '_forced_secure', '_use_rewrite', '_nosid',
 120:         '_absolute', '_current', '_direct', '_fragment', '_escape', '_query',
 121:         '_store_to_url'
 122:     );
 123: 
 124:     /**
 125:      * Controller request object
 126:      *
 127:      * @var Zend_Controller_Request_Http
 128:      */
 129:     protected $_request;
 130: 
 131:     /**
 132:      * Use Session ID for generate URL
 133:      *
 134:      * @var bool
 135:      */
 136:     protected $_useSession;
 137: 
 138:     /**
 139:      * Initialize object
 140:      */
 141:     protected function _construct()
 142:     {
 143:         $this->setStore(null);
 144:     }
 145: 
 146:     /**
 147:      * Initialize object data from retrieved url
 148:      *
 149:      * @param   string $url
 150:      * @return  Mage_Core_Model_Url
 151:      */
 152:     public function parseUrl($url)
 153:     {
 154:         $data = parse_url($url);
 155:         $parts = array(
 156:             'scheme'   => 'setScheme',
 157:             'host'     => 'setHost',
 158:             'port'     => 'setPort',
 159:             'user'     => 'setUser',
 160:             'pass'     => 'setPassword',
 161:             'path'     => 'setPath',
 162:             'query'    => 'setQuery',
 163:             'fragment' => 'setFragment');
 164: 
 165:         foreach ($parts as $component => $method) {
 166:             if (isset($data[$component])) {
 167:                 $this->$method($data[$component]);
 168:             }
 169:         }
 170:         return $this;
 171:     }
 172: 
 173:     /**
 174:      * Retrieve default controller name
 175:      *
 176:      * @return string
 177:      */
 178:     public function getDefaultControllerName()
 179:     {
 180:         return self::DEFAULT_CONTROLLER_NAME;
 181:     }
 182: 
 183:     /**
 184:      * Set use_url_cache flag
 185:      *
 186:      * @param boolean $flag
 187:      * @return Mage_Core_Model_Url
 188:      */
 189:     public function setUseUrlCache($flag)
 190:     {
 191:         $this->setData('use_url_cache', $flag);
 192:         return $this;
 193:     }
 194: 
 195:     /**
 196:      * Set use session rule
 197:      *
 198:      * @param bool $useSession
 199:      * @return Mage_Core_Model_Url
 200:      */
 201:     public function setUseSession($useSession)
 202:     {
 203:         $this->_useSession = (bool) $useSession;
 204:         return $this;
 205:     }
 206: 
 207:     /**
 208:      * Set route front name
 209:      *
 210:      * @param string $name
 211:      * @return Mage_Core_Model_Url
 212:      */
 213:     public function setRouteFrontName($name)
 214:     {
 215:         $this->setData('route_front_name', $name);
 216:         return $this;
 217:     }
 218: 
 219:     /**
 220:      * Retrieve use session rule
 221:      *
 222:      * @return bool
 223:      */
 224:     public function getUseSession()
 225:     {
 226:         if (is_null($this->_useSession)) {
 227:             $this->_useSession = Mage::app()->getUseSessionInUrl();
 228:         }
 229:         return $this->_useSession;
 230:     }
 231: 
 232:     /**
 233:      * Retrieve default action name
 234:      *
 235:      * @return string
 236:      */
 237:     public function getDefaultActionName()
 238:     {
 239:         return self::DEFAULT_ACTION_NAME;
 240:     }
 241: 
 242:     /**
 243:      * Retrieve configuration data
 244:      *
 245:      * @param string $key
 246:      * @param string|null $prefix
 247:      * @return string
 248:      */
 249:     public function getConfigData($key, $prefix = null)
 250:     {
 251:         if (is_null($prefix)) {
 252:             $prefix = 'web/' . ($this->getSecure() ? 'secure' : 'unsecure').'/';
 253:         }
 254:         $path = $prefix . $key;
 255: 
 256:         $cacheId = $this->getStore()->getCode() . '/' . $path;
 257:         if (!isset(self::$_configDataCache[$cacheId])) {
 258:             $data = $this->getStore()->getConfig($path);
 259:             self::$_configDataCache[$cacheId] = $data;
 260:         }
 261: 
 262:         return self::$_configDataCache[$cacheId];
 263:     }
 264: 
 265:     /**
 266:      * Set request
 267:      *
 268:      * @param Zend_Controller_Request_Http $request
 269:      * @return Mage_Core_Model_Url
 270:      */
 271:     public function setRequest(Zend_Controller_Request_Http $request)
 272:     {
 273:         $this->_request = $request;
 274:         return $this;
 275:     }
 276: 
 277:     /**
 278:      * Zend request object
 279:      *
 280:      * @return Zend_Controller_Request_Http
 281:      */
 282:     public function getRequest()
 283:     {
 284:         if (!$this->_request) {
 285:             $this->_request = Mage::app()->getRequest();
 286:         }
 287:         return $this->_request;
 288:     }
 289: 
 290:     /**
 291:      * Retrieve URL type
 292:      *
 293:      * @return string
 294:      */
 295:     public function getType()
 296:     {
 297:         if (!$this->hasData('type')) {
 298:             $this->setData('type', Mage_Core_Model_Store::URL_TYPE_LINK);
 299:         }
 300:         return $this->_getData('type');
 301:     }
 302: 
 303:     /**
 304:      * Retrieve is secure mode URL
 305:      *
 306:      * @return bool
 307:      */
 308:     public function getSecure()
 309:     {
 310:         if ($this->hasData('secure_is_forced')) {
 311:             return (bool)$this->getData('secure');
 312:         }
 313: 
 314:         $store = $this->getStore();
 315: 
 316:         if ($store->isAdmin() && !$store->isAdminUrlSecure()) {
 317:             return false;
 318:         }
 319:         if (!$store->isAdmin() && !$store->isFrontUrlSecure()) {
 320:             return false;
 321:         }
 322: 
 323:         if (!$this->hasData('secure')) {
 324:             if ($this->getType() == Mage_Core_Model_Store::URL_TYPE_LINK && !$store->isAdmin()) {
 325:                 $pathSecure = Mage::getConfig()->shouldUrlBeSecure('/' . $this->getActionPath());
 326:                 $this->setData('secure', $pathSecure);
 327:             } else {
 328:                 $this->setData('secure', true);
 329:             }
 330:         }
 331:         return $this->getData('secure');
 332:     }
 333: 
 334:     /**
 335:      * Set store entity
 336:      *
 337:      * @param mixed $data
 338:      * @return Mage_Core_Model_Url
 339:      */
 340:     public function setStore($data)
 341:     {
 342:         $this->setData('store', Mage::app()->getStore($data));
 343:         return $this;
 344:     }
 345: 
 346:     /**
 347:      * Get current store for the url instance
 348:      *
 349:      * @return Mage_Core_Model_Store
 350:      */
 351:     public function getStore()
 352:     {
 353:         if (!$this->hasData('store')) {
 354:             $this->setStore(null);
 355:         }
 356:         return $this->_getData('store');
 357:     }
 358: 
 359:     /**
 360:      * Retrieve Base URL
 361:      *
 362:      * @param array $params
 363:      * @return string
 364:      */
 365:     public function getBaseUrl($params = array())
 366:     {
 367:         if (isset($params['_store'])) {
 368:             $this->setStore($params['_store']);
 369:         }
 370:         if (isset($params['_type'])) {
 371:             $this->setType($params['_type']);
 372:         }
 373:         if (isset($params['_secure'])) {
 374:             $this->setSecure($params['_secure']);
 375:         }
 376: 
 377:         /**
 378:          * Add availability support urls without store code
 379:          */
 380:         if ($this->getType() == Mage_Core_Model_Store::URL_TYPE_LINK
 381:             && Mage::app()->getRequest()->isDirectAccessFrontendName($this->getRouteFrontName())) {
 382:             $this->setType(Mage_Core_Model_Store::URL_TYPE_DIRECT_LINK);
 383:         }
 384: 
 385:         return $this->getStore()->getBaseUrl($this->getType(), $this->getSecure());
 386:     }
 387: 
 388:     /**
 389:      * Set Route Parameters
 390:      *
 391:      * @param array $data
 392:      * @return Mage_Core_Model_Url
 393:      */
 394:     public function setRoutePath($data)
 395:     {
 396:         if ($this->_getData('route_path') == $data) {
 397:             return $this;
 398:         }
 399: 
 400:         $a = explode('/', $data);
 401: 
 402:         $route = array_shift($a);
 403:         if ('*' === $route) {
 404:             $route = $this->getRequest()->getRequestedRouteName();
 405:         }
 406:         $this->setRouteName($route);
 407:         $routePath = $route . '/';
 408: 
 409:         if (!empty($a)) {
 410:             $controller = array_shift($a);
 411:             if ('*' === $controller) {
 412:                 $controller = $this->getRequest()->getRequestedControllerName();
 413:             }
 414:             $this->setControllerName($controller);
 415:             $routePath .= $controller . '/';
 416:         }
 417: 
 418:         if (!empty($a)) {
 419:             $action = array_shift($a);
 420:             if ('*' === $action) {
 421:                 $action = $this->getRequest()->getRequestedActionName();
 422:             }
 423:             $this->setActionName($action);
 424:             $routePath .= $action . '/';
 425:         }
 426: 
 427:         if (!empty($a)) {
 428:             $this->unsetData('route_params');
 429:             while (!empty($a)) {
 430:                 $key = array_shift($a);
 431:                 if (!empty($a)) {
 432:                     $value = array_shift($a);
 433:                     $this->setRouteParam($key, $value);
 434:                     $routePath .= $key . '/' . $value . '/';
 435:                 }
 436:             }
 437:         }
 438: 
 439:         return $this;
 440:     }
 441: 
 442:     /**
 443:      * Retrieve action path
 444:      *
 445:      * @return string
 446:      */
 447:     public function getActionPath()
 448:     {
 449:         if (!$this->getRouteName()) {
 450:             return '';
 451:         }
 452: 
 453:         $hasParams = (bool) $this->getRouteParams();
 454:         $path = $this->getRouteFrontName() . '/';
 455: 
 456:         if ($this->getControllerName()) {
 457:             $path .= $this->getControllerName() . '/';
 458:         } elseif ($hasParams) {
 459:             $path .= $this->getDefaultControllerName() . '/';
 460:         }
 461:         if ($this->getActionName()) {
 462:             $path .= $this->getActionName() . '/';
 463:         } elseif ($hasParams) {
 464:             $path .= $this->getDefaultActionName() . '/';
 465:         }
 466: 
 467:         return $path;
 468:     }
 469: 
 470:     /**
 471:      * Retrieve route path
 472:      *
 473:      * @param array $routParams
 474:      * @return string
 475:      */
 476:     public function getRoutePath($routeParams = array())
 477:     {
 478:         if (!$this->hasData('route_path')) {
 479:             $routePath = $this->getRequest()->getAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS);
 480:             if (!empty($routeParams['_use_rewrite']) && ($routePath !== null)) {
 481:                 $this->setData('route_path', $routePath);
 482:                 return $routePath;
 483:             }
 484:             $routePath = $this->getActionPath();
 485:             if ($this->getRouteParams()) {
 486:                 foreach ($this->getRouteParams() as $key=>$value) {
 487:                     if (is_null($value) || false === $value || '' === $value || !is_scalar($value)) {
 488:                         continue;
 489:                     }
 490:                     $routePath .= $key . '/' . $value . '/';
 491:                 }
 492:             }
 493:             if ($routePath != '' && substr($routePath, -1, 1) !== '/') {
 494:                 $routePath .= '/';
 495:             }
 496:             $this->setData('route_path', $routePath);
 497:         }
 498:         return $this->_getData('route_path');
 499:     }
 500: 
 501:     /**
 502:      * Set route name
 503:      *
 504:      * @param string $data
 505:      * @return Mage_Core_Model_Url
 506:      */
 507:     public function setRouteName($data)
 508:     {
 509:         if ($this->_getData('route_name') == $data) {
 510:             return $this;
 511:         }
 512:         $this->unsetData('route_front_name')
 513:             ->unsetData('route_path')
 514:             ->unsetData('controller_name')
 515:             ->unsetData('action_name')
 516:             ->unsetData('secure');
 517:         return $this->setData('route_name', $data);
 518:     }
 519: 
 520:     /**
 521:      * Retrieve route front name
 522:      *
 523:      * @return string
 524:      */
 525:     public function getRouteFrontName()
 526:     {
 527:         if (!$this->hasData('route_front_name')) {
 528:             $routeName = $this->getRouteName();
 529:             $route = Mage::app()->getFrontController()->getRouterByRoute($routeName);
 530:             $frontName = $route->getFrontNameByRoute($routeName);
 531: 
 532:             $this->setRouteFrontName($frontName);
 533:         }
 534: 
 535:         return $this->_getData('route_front_name');
 536:     }
 537: 
 538:     /**
 539:      * Retrieve route name
 540:      *
 541:      * @return string|null
 542:      */
 543:     public function getRouteName()
 544:     {
 545:         return $this->_getData('route_name');
 546:     }
 547: 
 548:     /**
 549:      * Set Controller Name
 550:      *
 551:      * Reset action name and route path if has change
 552:      *
 553:      * @param string $data
 554:      * @return Mage_Core_Model_Url
 555:      */
 556:     public function setControllerName($data)
 557:     {
 558:         if ($this->_getData('controller_name') == $data) {
 559:             return $this;
 560:         }
 561:         $this->unsetData('route_path')->unsetData('action_name')->unsetData('secure');
 562:         return $this->setData('controller_name', $data);
 563:     }
 564: 
 565:     /**
 566:      * Retrieve controller name
 567:      *
 568:      * @return string|null
 569:      */
 570:     public function getControllerName()
 571:     {
 572:         return $this->_getData('controller_name');
 573:     }
 574: 
 575:     /**
 576:      * Set Action name
 577:      * Reseted route path if action name has change
 578:      *
 579:      * @param string $data
 580:      * @return Mage_Core_Model_Url
 581:      */
 582:     public function setActionName($data)
 583:     {
 584:         if ($this->_getData('action_name') == $data) {
 585:             return $this;
 586:         }
 587:         $this->unsetData('route_path');
 588:         return $this->setData('action_name', $data)->unsetData('secure');
 589:     }
 590: 
 591:     /**
 592:      * Retrieve action name
 593:      *
 594:      * @return string|null
 595:      */
 596:     public function getActionName()
 597:     {
 598:         return $this->_getData('action_name');
 599:     }
 600: 
 601:     /**
 602:      * Set route params
 603:      *
 604:      * @param array $data
 605:      * @param boolean $unsetOldParams
 606:      * @return Mage_Core_Model_Url
 607:      */
 608:     public function setRouteParams(array $data, $unsetOldParams = true)
 609:     {
 610:         if (isset($data['_type'])) {
 611:             $this->setType($data['_type']);
 612:             unset($data['_type']);
 613:         }
 614: 
 615:         if (isset($data['_store'])) {
 616:             $this->setStore($data['_store']);
 617:             unset($data['_store']);
 618:         }
 619: 
 620:         if (isset($data['_forced_secure'])) {
 621:             $this->setSecure((bool)$data['_forced_secure']);
 622:             $this->setSecureIsForced(true);
 623:             unset($data['_forced_secure']);
 624:         } elseif (isset($data['_secure'])) {
 625:             $this->setSecure((bool)$data['_secure']);
 626:             unset($data['_secure']);
 627:         }
 628: 
 629:         if (isset($data['_absolute'])) {
 630:             unset($data['_absolute']);
 631:         }
 632: 
 633:         if ($unsetOldParams) {
 634:             $this->unsetData('route_params');
 635:         }
 636: 
 637:         $this->setUseUrlCache(true);
 638:         if (isset($data['_current'])) {
 639:             if (is_array($data['_current'])) {
 640:                 foreach ($data['_current'] as $key) {
 641:                     if (array_key_exists($key, $data) || !$this->getRequest()->getUserParam($key)) {
 642:                         continue;
 643:                     }
 644:                     $data[$key] = $this->getRequest()->getUserParam($key);
 645:                 }
 646:             } elseif ($data['_current']) {
 647:                 foreach ($this->getRequest()->getUserParams() as $key => $value) {
 648:                     if (array_key_exists($key, $data) || $this->getRouteParam($key)) {
 649:                         continue;
 650:                     }
 651:                     $data[$key] = $value;
 652:                 }
 653:                 foreach ($this->getRequest()->getQuery() as $key => $value) {
 654:                     $this->setQueryParam($key, $value);
 655:                 }
 656:                 $this->setUseUrlCache(false);
 657:             }
 658:             unset($data['_current']);
 659:         }
 660: 
 661:         if (isset($data['_use_rewrite'])) {
 662:             unset($data['_use_rewrite']);
 663:         }
 664: 
 665:         if (isset($data['_store_to_url']) && (bool)$data['_store_to_url'] === true) {
 666:             if (!Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL, $this->getStore())
 667:                 && !Mage::app()->isSingleStoreMode()
 668:             ) {
 669:                 $this->setQueryParam('___store', $this->getStore()->getCode());
 670:             }
 671:         }
 672:         unset($data['_store_to_url']);
 673: 
 674:         foreach ($data as $k => $v) {
 675:             $this->setRouteParam($k, $v);
 676:         }
 677: 
 678:         return $this;
 679:     }
 680: 
 681:     /**
 682:      * Retrieve route params
 683:      *
 684:      * @return array
 685:      */
 686:     public function getRouteParams()
 687:     {
 688:         return $this->_getData('route_params');
 689:     }
 690: 
 691:     /**
 692:      * Set route param
 693:      *
 694:      * @param string $key
 695:      * @param mixed $data
 696:      * @return Mage_Core_Model_Url
 697:      */
 698:     public function setRouteParam($key, $data)
 699:     {
 700:         $params = $this->_getData('route_params');
 701:         if (isset($params[$key]) && $params[$key] == $data) {
 702:             return $this;
 703:         }
 704:         $params[$key] = $data;
 705:         $this->unsetData('route_path');
 706:         return $this->setData('route_params', $params);
 707:     }
 708: 
 709:     /**
 710:      * Retrieve route params
 711:      *
 712:      * @param string $key
 713:      * @return mixed
 714:      */
 715:     public function getRouteParam($key)
 716:     {
 717:         return $this->getData('route_params', $key);
 718:     }
 719: 
 720:     /**
 721:      * Retrieve route URL
 722:      *
 723:      * @param string $routePath
 724:      * @param array $routeParams
 725:      *
 726:      * @return string
 727:      */
 728:     public function getRouteUrl($routePath = null, $routeParams = null)
 729:     {
 730:         $this->unsetData('route_params');
 731: 
 732:         if (isset($routeParams['_direct'])) {
 733:             if (is_array($routeParams)) {
 734:                 $this->setRouteParams($routeParams, false);
 735:             }
 736:             return $this->getBaseUrl() . $routeParams['_direct'];
 737:         }
 738: 
 739:         if (!is_null($routePath)) {
 740:             $this->setRoutePath($routePath);
 741:         }
 742:         if (is_array($routeParams)) {
 743:             $this->setRouteParams($routeParams, false);
 744:         }
 745: 
 746:         $url = $this->getBaseUrl() . $this->getRoutePath($routeParams);
 747:         return $url;
 748:     }
 749: 
 750:     /**
 751:      * If the host was switched but session cookie won't recognize it - add session id to query
 752:      *
 753:      * @return Mage_Core_Model_Url
 754:      */
 755:     public function checkCookieDomains()
 756:     {
 757:         $hostArr = explode(':', $this->getRequest()->getServer('HTTP_HOST'));
 758:         if ($hostArr[0] !== $this->getHost()) {
 759:             $session = Mage::getSingleton('core/session');
 760:             if (!$session->isValidForHost($this->getHost())) {
 761:                 if (!self::$_encryptedSessionId) {
 762:                     $helper = Mage::helper('core');
 763:                     if (!$helper) {
 764:                         return $this;
 765:                     }
 766:                     self::$_encryptedSessionId = $session->getEncryptedSessionId();
 767:                 }
 768:                 $this->setQueryParam($session->getSessionIdQueryParam(), self::$_encryptedSessionId);
 769:             }
 770:         }
 771:         return $this;
 772:     }
 773: 
 774:     /**
 775:      * Add session param
 776:      *
 777:      * @return Mage_Core_Model_Url
 778:      */
 779:     public function addSessionParam()
 780:     {
 781:         $session = Mage::getSingleton('core/session');
 782: 
 783:         if (!self::$_encryptedSessionId) {
 784:             $helper = Mage::helper('core');
 785:             if (!$helper) {
 786:                 return $this;
 787:             }
 788:             self::$_encryptedSessionId = $session->getEncryptedSessionId();
 789:         }
 790:         $this->setQueryParam($session->getSessionIdQueryParam(), self::$_encryptedSessionId);
 791:         return $this;
 792:     }
 793: 
 794:     /**
 795:      * Set URL query param(s)
 796:      *
 797:      * @param mixed $data
 798:      * @return Mage_Core_Model_Url
 799:      */
 800:     public function setQuery($data)
 801:     {
 802:         if ($this->_getData('query') == $data) {
 803:             return $this;
 804:         }
 805:         $this->unsetData('query_params');
 806:         return $this->setData('query', $data);
 807:     }
 808: 
 809:     /**
 810:      * Get query params part of url
 811:      *
 812:      * @param bool $escape "&" escape flag
 813:      * @return string
 814:      */
 815:     public function getQuery($escape = false)
 816:     {
 817:         if (!$this->hasData('query')) {
 818:             $query = '';
 819:             $params = $this->getQueryParams();
 820:             if (is_array($params)) {
 821:                 ksort($params);
 822:                 $query = http_build_query($params, '', $escape ? '&amp;' : '&');
 823:             }
 824:             $this->setData('query', $query);
 825:         }
 826:         return $this->_getData('query');
 827:     }
 828: 
 829:     /**
 830:      * Set query Params as array
 831:      *
 832:      * @param array $data
 833:      * @return Mage_Core_Model_Url
 834:      */
 835:     public function setQueryParams(array $data)
 836:     {
 837:         $this->unsetData('query');
 838: 
 839:         if ($this->_getData('query_params') == $data) {
 840:             return $this;
 841:         }
 842: 
 843:         $params = $this->_getData('query_params');
 844:         if (!is_array($params)) {
 845:             $params = array();
 846:         }
 847:         foreach ($data as $param => $value) {
 848:             $params[$param] = $value;
 849:         }
 850:         $this->setData('query_params', $params);
 851: 
 852:         return $this;
 853:     }
 854: 
 855:     /**
 856:      * Purge Query params array
 857:      *
 858:      * @return Mage_Core_Model_Url
 859:      */
 860:     public function purgeQueryParams()
 861:     {
 862:         $this->setData('query_params', array());
 863:         return $this;
 864:     }
 865: 
 866:     /**
 867:      * Return Query Params
 868:      *
 869:      * @return array
 870:      */
 871:     public function getQueryParams()
 872:     {
 873:         if (!$this->hasData('query_params')) {
 874:             $params = array();
 875:             if ($this->_getData('query')) {
 876:                 foreach (explode('&', $this->_getData('query')) as $param) {
 877:                     $paramArr = explode('=', $param);
 878:                     $params[$paramArr[0]] = urldecode($paramArr[1]);
 879:                 }
 880:             }
 881:             $this->setData('query_params', $params);
 882:         }
 883:         return $this->_getData('query_params');
 884:     }
 885: 
 886:     /**
 887:      * Set query param
 888:      *
 889:      * @param string $key
 890:      * @param mixed $data
 891:      * @return Mage_Core_Model_Url
 892:      */
 893:     public function setQueryParam($key, $data)
 894:     {
 895:         $params = $this->getQueryParams();
 896:         if (isset($params[$key]) && $params[$key] == $data) {
 897:             return $this;
 898:         }
 899:         $params[$key] = $data;
 900:         $this->unsetData('query');
 901:         return $this->setData('query_params', $params);
 902:     }
 903: 
 904:     /**
 905:      * Retrieve query param
 906:      *
 907:      * @param string $key
 908:      * @return mixed
 909:      */
 910:     public function getQueryParam($key)
 911:     {
 912:         if (!$this->hasData('query_params')) {
 913:             $this->getQueryParams();
 914:         }
 915:         return $this->getData('query_params', $key);
 916:     }
 917: 
 918:     /**
 919:      * Set fragment to URL
 920:      *
 921:      * @param string $data
 922:      * @return Mage_Core_Model_Url
 923:      */
 924:     public function setFragment($data)
 925:     {
 926:         return $this->setData('fragment', $data);
 927:     }
 928: 
 929:     /**
 930:      * Retrieve URL fragment
 931:      *
 932:      * @return string|null
 933:      */
 934:     public function getFragment()
 935:     {
 936:         return $this->_getData('fragment');
 937:     }
 938: 
 939:     /**
 940:      * Build url by requested path and parameters
 941:      *
 942:      * @param   string|null $routePath
 943:      * @param   array|null $routeParams
 944:      * @return  string
 945:      */
 946:     public function getUrl($routePath = null, $routeParams = null)
 947:     {
 948:         $escapeQuery = false;
 949: 
 950:         /**
 951:          * All system params should be unset before we call getRouteUrl
 952:          * this method has condition for adding default controller and action names
 953:          * in case when we have params
 954:          */
 955:         if (isset($routeParams['_fragment'])) {
 956:             $this->setFragment($routeParams['_fragment']);
 957:             unset($routeParams['_fragment']);
 958:         }
 959: 
 960:         if (isset($routeParams['_escape'])) {
 961:             $escapeQuery = $routeParams['_escape'];
 962:             unset($routeParams['_escape']);
 963:         }
 964: 
 965:         $query = null;
 966:         if (isset($routeParams['_query'])) {
 967:             $this->purgeQueryParams();
 968:             $query = $routeParams['_query'];
 969:             unset($routeParams['_query']);
 970:         }
 971: 
 972:         $noSid = null;
 973:         if (isset($routeParams['_nosid'])) {
 974:             $noSid = (bool)$routeParams['_nosid'];
 975:             unset($routeParams['_nosid']);
 976:         }
 977:         $url = $this->getRouteUrl($routePath, $routeParams);
 978:         /**
 979:          * Apply query params, need call after getRouteUrl for rewrite _current values
 980:          */
 981:         if ($query !== null) {
 982:             if (is_string($query)) {
 983:                 $this->setQuery($query);
 984:             } elseif (is_array($query)) {
 985:                 $this->setQueryParams($query, !empty($routeParams['_current']));
 986:             }
 987:             if ($query === false) {
 988:                 $this->setQueryParams(array());
 989:             }
 990:         }
 991: 
 992:         if ($noSid !== true) {
 993:             $this->_prepareSessionUrl($url);
 994:         }
 995: 
 996:         $query = $this->getQuery($escapeQuery);
 997:         if ($query) {
 998:             $mark = (strpos($url, '?') === false) ? '?' : ($escapeQuery ? '&amp;' : '&');
 999:             $url .= $mark . $query;
1000:         }
1001: 
1002:         if ($this->getFragment()) {
1003:             $url .= '#' . $this->getFragment();
1004:         }
1005: 
1006:         return $this->escape($url);
1007:     }
1008: 
1009:     /**
1010:      * Check and add session id to URL
1011:      *
1012:      * @param string $url
1013:      *
1014:      * @return Mage_Core_Model_Url
1015:      */
1016:     protected function _prepareSessionUrl($url)
1017:     {
1018:         return $this->_prepareSessionUrlWithParams($url, array());
1019:     }
1020: 
1021:     /**
1022:      * Check and add session id to URL, session is obtained with parameters
1023:      *
1024:      * @param string $url
1025:      * @param array $params
1026:      *
1027:      * @return Mage_Core_Model_Url
1028:      */
1029:     protected function _prepareSessionUrlWithParams($url, array $params)
1030:     {
1031:         if (!$this->getUseSession()) {
1032:             return $this;
1033:         }
1034: 
1035:         /** @var $session Mage_Core_Model_Session */
1036:         $session = Mage::getSingleton('core/session', $params);
1037: 
1038:         $sessionId = $session->getSessionIdForHost($url);
1039:         if (Mage::app()->getUseSessionVar() && !$sessionId) {
1040:             $this->setQueryParam('___SID', $this->getSecure() ? 'S' : 'U'); // Secure/Unsecure
1041:         } else if ($sessionId) {
1042:             $this->setQueryParam($session->getSessionIdQueryParam(), $sessionId);
1043:         }
1044:         return $this;
1045:     }
1046: 
1047:     /**
1048:      * Rebuild URL to handle the case when session ID was changed
1049:      *
1050:      * @param string $url
1051:      * @return string
1052:      */
1053:     public function getRebuiltUrl($url)
1054:     {
1055:         $this->parseUrl($url);
1056:         $port = $this->getPort();
1057:         if ($port) {
1058:             $port = ':' . $port;
1059:         } else {
1060:             $port = '';
1061:         }
1062:         $url = $this->getScheme() . '://' . $this->getHost() . $port . $this->getPath();
1063: 
1064:         $this->_prepareSessionUrl($url);
1065: 
1066:         $query = $this->getQuery();
1067:         if ($query) {
1068:             $url .= '?' . $query;
1069:         }
1070: 
1071:         $fragment = $this->getFragment();
1072:         if ($fragment) {
1073:             $url .= '#' . $fragment;
1074:         }
1075: 
1076:         return $this->escape($url);
1077:     }
1078: 
1079:     /**
1080:      * Escape (enclosure) URL string
1081:      *
1082:      * @param string $value
1083:      * @return string
1084:      */
1085:     public function escape($value)
1086:     {
1087:         $value = str_replace('"', '%22', $value);
1088:         $value = str_replace("'", '%27', $value);
1089:         $value = str_replace('>', '%3E', $value);
1090:         $value = str_replace('<', '%3C', $value);
1091:         return $value;
1092:     }
1093: 
1094:     /**
1095:      * Build url by direct url and parameters
1096:      *
1097:      * @param string $url
1098:      * @param array $params
1099:      * @return string
1100:      */
1101:     public function getDirectUrl($url, $params = array()) {
1102:         $params['_direct'] = $url;
1103:         return $this->getUrl('', $params);
1104:     }
1105: 
1106:     /**
1107:      * Replace Session ID value in URL
1108:      *
1109:      * @param string $html
1110:      * @return string
1111:      */
1112:     public function sessionUrlVar($html)
1113:     {
1114:         return preg_replace_callback('#(\?|&amp;|&)___SID=([SU])(&amp;|&)?#',
1115:             array($this, "sessionVarCallback"), $html);
1116:     }
1117: 
1118:     /**
1119:      * Check and return use SID for URL
1120:      *
1121:      * @param bool $secure
1122:      * @return bool
1123:      */
1124:     public function useSessionIdForUrl($secure = false)
1125:     {
1126:         $key = 'use_session_id_for_url_' . (int) $secure;
1127:         if (is_null($this->getData($key))) {
1128:             $httpHost = Mage::app()->getFrontController()->getRequest()->getHttpHost();
1129:             $urlHost = parse_url(Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, $secure),
1130:                 PHP_URL_HOST);
1131: 
1132:             if ($httpHost != $urlHost) {
1133:                 $this->setData($key, true);
1134:             } else {
1135:                 $this->setData($key, false);
1136:             }
1137:         }
1138:         return $this->getData($key);
1139:     }
1140: 
1141:     /**
1142:      * Callback function for session replace
1143:      *
1144:      * @param array $match
1145:      * @return string
1146:      */
1147:     public function sessionVarCallback($match)
1148:     {
1149:         if ($this->useSessionIdForUrl($match[2] == 'S' ? true : false)) {
1150:             $session = Mage::getSingleton('core/session');
1151:             /* @var $session Mage_Core_Model_Session */
1152:             return $match[1]
1153:                 . $session->getSessionIdQueryParam()
1154:                 . '=' . $session->getEncryptedSessionId()
1155:                 . (isset($match[3]) ? $match[3] : '');
1156:         } else {
1157:             if ($match[1] == '?' && isset($match[3])) {
1158:                 return '?';
1159:             } elseif ($match[1] == '?' && !isset($match[3])) {
1160:                 return '';
1161:             } elseif (($match[1] == '&amp;' || $match[1] == '&') && !isset($match[3])) {
1162:                 return '';
1163:             } elseif (($match[1] == '&amp;' || $match[1] == '&') && isset($match[3])) {
1164:                 return $match[3];
1165:             }
1166:         }
1167:         return '';
1168:     }
1169: 
1170:     /**
1171:      * Check if users originated URL is one of the domain URLs assigned to stores
1172:      *
1173:      * @return boolean
1174:      */
1175:     public function isOwnOriginUrl()
1176:     {
1177:         $storeDomains = array();
1178:         $referer = parse_url(Mage::app()->getFrontController()->getRequest()->getServer('HTTP_REFERER'), PHP_URL_HOST);
1179:         foreach (Mage::app()->getStores() as $store) {
1180:             $storeDomains[] = parse_url($store->getBaseUrl(), PHP_URL_HOST);
1181:             $storeDomains[] = parse_url($store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true), PHP_URL_HOST);
1182:         }
1183:         $storeDomains = array_unique($storeDomains);
1184:         if (empty($referer) || in_array($referer, $storeDomains)) {
1185:             return true;
1186:         }
1187:         return false;
1188:     }
1189: 
1190:     /**
1191:      * Return frontend redirect URL with SID and other session parameters if any
1192:      *
1193:      * @param string $url
1194:      *
1195:      * @return string
1196:      */
1197:     public function getRedirectUrl($url)
1198:     {
1199:         $this->_prepareSessionUrlWithParams($url, array(
1200:             'name' => Mage_Core_Controller_Front_Action::SESSION_NAMESPACE
1201:         ));
1202: 
1203:         $query = $this->getQuery(false);
1204:         if ($query) {
1205:             $url .= (strpos($url, '?') === false ? '?' : '&') . $query;
1206:         }
1207: 
1208:         return $url;
1209:     }
1210: }
1211: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0