Beispiel #1
0
 /**
  * Generate url
  * @param string $value
  * @throws InvalidArgumentException
  * @return Mage_Core_Model_Abstract|boolean
  */
 public function process($value)
 {
     if (false === is_array($value) || !isset($value['path'])) {
         throw new InvalidArgumentException('Passed value has incorrect format');
     }
     $params = array_key_exists('params', $value) ? $value['params'] : null;
     return $this->_urlModel->getUrl($value['path'], $params);
 }
Beispiel #2
0
 /**
  * Generate url
  * @param string $value
  * @throws InvalidArgumentException
  * @return Mage_Core_Model_Abstract|boolean
  */
 public function process($value)
 {
     if (false === is_array($value) || (!isset($value['path']) || !isset($value['params']))) {
         throw new InvalidArgumentException('Passed value has incorrect format');
     }
     $path = $value['path'];
     $params = $value['params'];
     return $this->_urlModel->getUrl($path, $params);
 }
Beispiel #3
0
 public function getUrl($routePath = null, $routeParams = null)
 {
     //        $this->_escape = isset($routeParams['_escape']) ? $routeParams['_escape'] :
     //            (isset($routeParams['_m_escape']) ? $routeParams['_m_escape'] : $this->_escape);
     $this->_routeParams = $routeParams;
     if ($this->_isValidPageType($routePath) && (isset($routeParams['_use_rewrite']) || $routePath == 'catalogsearch/result')) {
         /* @var $seo Mana_Seo_Helper_Data */
         $seo = Mage::helper('mana_seo');
         if ($this->_schema = $seo->getActiveSchema($this->getStore()->getId())) {
             $this->_routePath = $this->_populateCurrentRouteFromRequest($routePath);
             $query = null;
             if (isset($this->_routeParams['_query'])) {
                 $this->purgeQueryParams();
                 $query = $this->_routeParams['_query'];
                 unset($this->_routeParams['_query']);
             }
             $this->_query = $query;
             if ($this->_pageType = $this->_getPageType($this->_routePath)) {
                 $this->_suffix = $this->_pageType->getCurrentSuffix();
                 $this->_pageUrlKey = $this->_pageType->getUrlKey($this);
                 if (Mage::getStoreConfig('web/default/front') == 'cms' && $this->_pageUrlKey == Mage::getStoreConfig('web/default/cms_home_page')) {
                     $this->_routePath = 'cms/index/index';
                     unset($this->_routeParams['page_id']);
                     $this->_pageType = $this->_getPageType($this->_routePath);
                     $this->_suffix = $this->_pageType->getCurrentSuffix();
                     $this->_pageUrlKey = $this->_pageType->getUrlKey($this);
                 }
             }
         }
     }
     return parent::getUrl($routePath, $this->_routeParams);
 }
Beispiel #4
0
 /**
  * Note: isolation flushes the URL memory cache
  * @magentoAppIsolation enabled
  *
  * @dataProvider consequentCallsDataProvider
  *
  * @param string $firstCallUrl
  * @param string $secondCallUrl
  * @param array $firstRouteParams
  * @param array $secondRouteParams
  * @param string $firstExpectedUrl
  * @param string $secondExpectedUrl
  * @covers Mage_Core_Model_Url::getUrl
  */
 public function testGetUrlOnConsequentCalls($firstCallUrl, $secondCallUrl, $firstRouteParams, $secondRouteParams, $firstExpectedUrl, $secondExpectedUrl)
 {
     $result = $this->_model->getUrl($firstCallUrl, $firstRouteParams);
     $this->assertEquals($firstExpectedUrl, $result);
     $result = $this->_model->getUrl($secondCallUrl, $secondRouteParams);
     $this->assertEquals($secondExpectedUrl, $result);
 }
Beispiel #5
0
 public function getUrl($routePath = null, $routeParams = null)
 {
     $route = Mage::helper('blog')->getRoute();
     if (!empty($route)) {
         $isUseCategoryUrl = Mage::helper('blog')->isCategoryUrl();
         $category = Mage::getSingleton('blog/cat');
         $post = Mage::getSingleton('blog/post');
         $tag = $this->getRequest()->getParam('tag', false);
         if ($isUseCategoryUrl && $category->getCatId()) {
             $route .= '/' . Smartwave_Blog_Helper_Data::CATEGORY_URI_PARAM . '/' . $category->getIdentifier();
         }
         if ($post->getIdentifier()) {
             if ($isUseCategoryUrl && $category->getCatId()) {
                 $route .= '/' . Smartwave_Blog_Helper_Data::POST_URI_PARAM . '/' . $post->getIdentifier();
             } else {
                 $route .= '/' . $post->getIdentifier();
             }
         }
         if ($tag) {
             $route .= '/' . Smartwave_Blog_Helper_Data::TAG_URI_PARAM . '/' . $tag;
         }
         $routePath = $route;
     }
     return parent::getUrl($routePath, $routeParams);
 }
Beispiel #6
0
 /**
  * Retrieve link on product rss feed tagged with loaded tag
  *
  * @return bool|string
  */
 public function getLinkUrl()
 {
     if ($this->_isRssEnabled && $this->_tagId) {
         /** @var $tagModel Mage_Tag_Model_Tag */
         $this->_tagModel->load($this->_tagId);
         if ($this->_tagModel && $this->_tagModel->getId()) {
             return $this->_coreUrlModel->getUrl('rss/catalog/tag', array('tagName' => urlencode($this->_tagModel->getName())));
         }
     }
     return false;
 }
Beispiel #7
0
 public function getUrl($routePath = null, $routeParams = null)
 {
     $forceVendorUrl = !empty($routeParams['_current']);
     if ($forceVendorUrl) {
         Mage::app()->getStore()->useVendorUrl(true);
     }
     $url = parent::getUrl($routePath, $routeParams);
     if ($forceVendorUrl) {
         Mage::app()->getStore()->resetUseVendorUrl();
     }
     return $url;
 }
Beispiel #8
0
 public function getUrl($routePath = null, $routeParams = null)
 {
     $url = parent::getUrl($routePath, $routeParams);
     if (substr($url, -1) != "/") {
         if (strpos($url, "?") !== false) {
             if (substr($url, strpos($url, "?") - 1, 1) != "/") {
                 $url = substr_replace($url, "/?", strpos($url, "?"), 1);
             }
         } else {
             $url .= "/";
         }
     }
     return $url;
 }
 public function getUrl($routePath = null, $routeParams = null)
 {
     $this->_escape = isset($routeParams['_escape']) ? $routeParams['_escape'] : isset($routeParams['_m_escape']);
     $result = $this->encodeUrl($routePath, parent::getUrl($routePath, $routeParams));
     $result = preg_replace('#\\/[-_\\w\\d]+\\/\\.#', '.', $result);
     if (strpos($result, '/.html') !== false) {
         $currentUrl = parent::getUrl('*/*/*', array('_current' => true, '_use_rewrite' => true, '_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()));
         Mage::log("Wrong URL {$result} on page {$currentUrl}", Zend_Log::DEBUG, 'seo_errors.log');
         try {
             throw new Exception();
         } catch (Exception $e) {
             Mage::log("{$e->getMessage()}\n{$e->getTraceAsString()}", Zend_Log::DEBUG, 'seo_errors.log');
         }
     }
     return $result;
 }
Beispiel #10
0
 public function getUrl($routePath = null, $routeParams = null)
 {
     $url = parent::getUrl($routePath, $routeParams);
     if ($subD = Mage::registry('current_subdomain')) {
         $urlParts = parse_url($url);
         $urlHostParts = explode('.', $urlParts['host']);
         // Custom case for dev server
         if ('dev.bloomnation.com' == $urlParts['host']) {
             $urlParts['host'] = 'lapremier.dev.bloomnation.com';
         } else {
             $urlHostParts[0] = $subD;
             $urlParts['host'] = implode('.', $urlHostParts);
         }
         $url = (isset($urlParts["scheme"]) ? $urlParts["scheme"] . "://" : "") . (isset($urlParts["user"]) ? $urlParts["user"] . ":" : "") . (isset($urlParts["pass"]) ? $urlParts["pass"] . "@" : "") . (isset($urlParts["host"]) ? $urlParts["host"] : "") . (isset($urlParts["port"]) ? ":" . $urlParts["port"] : "") . (isset($urlParts["path"]) ? $urlParts["path"] : "") . (isset($urlParts["query"]) ? "?" . $urlParts["query"] : "") . (isset($urlParts["fragment"]) ? "#" . $urlParts["fragment"] : "");
     }
     return $url;
 }
Beispiel #11
0
 /**
  * Custom logic to retrieve Urls
  *
  * @param string $routePath
  * @param array $routeParams
  * @return string
  */
 public function getUrl($routePath = null, $routeParams = null)
 {
     $result = parent::getUrl($routePath, $routeParams);
     if (!$this->useSecretKey()) {
         return $result;
     }
     $_route = $this->getRouteName() ? $this->getRouteName() : '*';
     $_controller = $this->getControllerName() ? $this->getControllerName() : $this->getDefaultControllerName();
     $_action = $this->getActionName() ? $this->getActionName() : $this->getDefaultActionName();
     $secret = array(self::SECRET_KEY_PARAM_NAME => $this->getSecretKey($_controller, $_action));
     if (is_array($routeParams)) {
         $routeParams = array_merge($secret, $routeParams);
     } else {
         $routeParams = $secret;
     }
     if (is_array($this->getRouteParams())) {
         $routeParams = array_merge($this->getRouteParams(), $routeParams);
     }
     return parent::getUrl("{$_route}/{$_controller}/{$_action}", $routeParams);
 }
Beispiel #12
0
 /**
  * Retrieve store URL directive
  * Support url and direct_url properties
  *
  * @param array $construction
  * @return string
  */
 public function storeDirective($construction)
 {
     $params = $this->_getIncludeParameters($construction[2]);
     if (!isset($params['_query'])) {
         $params['_query'] = array();
     }
     foreach ($params as $k => $v) {
         if (strpos($k, '_query_') === 0) {
             $params['_query'][substr($k, 7)] = $v;
             unset($params[$k]);
         }
     }
     $params['_absolute'] = $this->_useAbsoluteLinks;
     if ($this->_useSessionInUrl === false) {
         $params['_nosid'] = true;
     }
     if (isset($params['direct_url'])) {
         $path = '';
         $params['_direct'] = $params['direct_url'];
         unset($params['direct_url']);
     } else {
         $path = $params['url'];
         unset($params['url']);
     }
     if (!self::$_urlInstance) {
         self::$_urlInstance = Mage::getModel('core/url')->setStore(Mage::app()->getStore(Mage::getDesign()->getStore())->getId());
     }
     $_urlInstanceOldStore = null;
     if (!empty($path) && !Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL) && !Mage::app()->isSingleStoreMode()) {
         $params['_query']['___store'] = Mage::app()->getStore(Mage::getDesign()->getStore())->getCode();
     } elseif (!empty($path) && Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL) && !Mage::app()->isSingleStoreMode()) {
         $_urlInstanceOldStore = self::$_urlInstance->getStore();
         self::$_urlInstance->setStore(Mage::app()->getStore(Mage::getDesign()->getStore())->getCode());
     }
     $url = self::$_urlInstance->getUrl($path, $params);
     if (null == !$_urlInstanceOldStore) {
         self::$_urlInstance->setStore($_urlInstanceOldStore);
     }
     return $url;
 }
Beispiel #13
0
 /**
  * Build url by requested path and parameters
  *
  * @param   string $routePath
  * @param   array $routeParams
  * @return  string
  */
 public function getUrl($routePath = null, $routeParams = null, $getOriginalData = false)
 {
     if (!Mage::getSingleton('Flagbit_Typo3connect/Core')->isEnabled() || $getOriginalData) {
         return parent::getUrl($routePath, $routeParams);
     }
     $escapeQuery = false;
     if (isset($routeParams['_fragment'])) {
         $this->setFragment($routeParams['_fragment']);
         unset($routeParams['_fragment']);
     }
     if (isset($routeParams['_escape'])) {
         $escapeQuery = $routeParams['_escape'];
         unset($routeParams['_escape']);
     }
     $url = $this->getRouteUrl($routePath, $routeParams);
     $params = array("route" => $this->getRouteName(), "controller" => $this->getControllerName(), "action" => $this->getActionName());
     if ($routeParams) {
         $params = array_merge($params, $routeParams);
     }
     if (is_array($routeParams['_query'])) {
         $params = array_merge($params, $routeParams['_query']);
     }
     unset($params['_query']);
     unset($params['_use_rewrite']);
     if ($params['_current']) {
         unset($params['_current']);
         $url = Mage::getSingleton('Flagbit_Typo3connect/Core')->getTypolinkKeepPIvars($params);
     } else {
         $url = Mage::getSingleton('Flagbit_Typo3connect/Core')->getTypolink($params);
     }
     // Complete the typolink URL absolute using the base url
     if (strpos($url, 'http') !== 0) {
         $urlComponents = parse_url($this->getBaseUrl());
         $url = $urlComponents['scheme'] . '://' . rtrim($urlComponents['host'], '/') . '/' . ltrim($url, '/');
     }
     // save last URL in Response for the _isUrlInternal workaround
     Mage::getSingleton('Flagbit_Typo3connect/Core')->getResponse()->lastUrl = $url;
     return $url;
 }
Beispiel #14
0
 /**
  * Build url by requested path and parameters
  *
  * @param   string|null $routePath
  * @param   array|null $routeParams
  * @return  string
  */
 public function getUrl($routePath = null, $routeParams = null)
 {
     /*
              use https
              if url show in web browser start with https, all urls in the webpage must be start with https,
              for example: if main page is https, but ajax request send in this page is http, then ajax request will fail
                           if main page is http, but ajax request send in this page is https, then ajax request will fail also
     */
     //use https
     if (isset($_SERVER['SERVER_PORT']) && 443 == $_SERVER['SERVER_PORT']) {
         //if it has set $routeParams,then add  '_secure' => true
         if (is_array($routeParams)) {
             if (!isset($routeParams['_secure'])) {
                 $routeParams['_secure'] = true;
             }
         } else {
             //set $routeParams to use https
             $routeParams = array('_secure' => true);
         }
     }
     return parent::getUrl($routePath, $routeParams);
 }
Beispiel #15
0
 /**
  * Generate url by route and parameters
  *
  * @param   string $route
  * @param   array $params
  * @return  string
  */
 public function getUrl($route = '', $params = array())
 {
     return $this->_urlBuilder->getUrl($route, $params);
 }
Beispiel #16
0
 /**
  * Note: isolation flushes the URL memory cache
  * @magentoAppIsolation enabled
  */
 public function testGetUrl()
 {
     $result = $this->_model->getUrl('catalog/product/view', array('_fragment' => 'anchor', '_escape' => 1, '_query' => 'foo=bar', '_nosid' => 1, 'id' => 100));
     $this->assertEquals('http://localhost/index.php/catalog/product/view/id/100/?foo=bar#anchor', $result);
 }
Beispiel #17
0
 /**
  * Custom logic to retrieve Urls
  *
  * @param string $routePath
  * @param array $routeParams
  * @return string
  */
 public function getUrl($routePath = null, $routeParams = null)
 {
     $cacheSecretKey = false;
     if (is_array($routeParams) && isset($routeParams['_cache_secret_key'])) {
         unset($routeParams['_cache_secret_key']);
         $cacheSecretKey = true;
     }
     $result = parent::getUrl($routePath, $routeParams);
     if (!$this->useSecretKey()) {
         return $result;
     }
     $routeName = $this->getRouteName() ? $this->getRouteName() : '*';
     $controllerName = $this->getControllerName() ? $this->getControllerName() : $this->getDefaultControllerName();
     $actionName = $this->getActionName() ? $this->getActionName() : $this->getDefaultActionName();
     if ($cacheSecretKey) {
         $secret = array(self::SECRET_KEY_PARAM_NAME => "\${$routeName}/{$controllerName}/{$actionName}\$");
     } else {
         $secret = array(self::SECRET_KEY_PARAM_NAME => $this->getSecretKey($routeName, $controllerName, $actionName));
     }
     if (is_array($routeParams)) {
         $routeParams = array_merge($secret, $routeParams);
     } else {
         $routeParams = $secret;
     }
     if (is_array($this->getRouteParams())) {
         $routeParams = array_merge($this->getRouteParams(), $routeParams);
     }
     return parent::getUrl("{$routeName}/{$controllerName}/{$actionName}", $routeParams);
 }
Beispiel #18
0
 /**
  * Custom logic to retrieve Urls
  *
  * @param string $routePath
  * @param array $routeParams
  * @return string
  */
 public function getUrl($routePath = null, $routeParams = null)
 {
     $cacheSecretKey = false;
     // automatically persist http/https state based on current state
     // this is is overridden if the secure flag has been explicitly
     // set in the params
     if (!isset($routeParams['_secure'])) {
         $routeParams['_secure'] = $this->getSecure();
     }
     if (is_array($routeParams) && isset($routeParams['_cache_secret_key'])) {
         unset($routeParams['_cache_secret_key']);
         $cacheSecretKey = true;
     }
     $result = parent::getUrl($routePath, $routeParams);
     if (!$this->useSecretKey()) {
         return $result;
     }
     $_route = $this->getRouteName() ? $this->getRouteName() : '*';
     $_controller = $this->getControllerName() ? $this->getControllerName() : $this->getDefaultControllerName();
     $_action = $this->getActionName() ? $this->getActionName() : $this->getDefaultActionName();
     if ($cacheSecretKey) {
         $secret = array(self::SECRET_KEY_PARAM_NAME => "\${$_controller}/{$_action}\$");
     } else {
         $secret = array(self::SECRET_KEY_PARAM_NAME => $this->getSecretKey($_controller, $_action));
     }
     if (is_array($routeParams)) {
         $routeParams = array_merge($secret, $routeParams);
     } else {
         $routeParams = $secret;
     }
     if (is_array($this->getRouteParams())) {
         $routeParams = array_merge($this->getRouteParams(), $routeParams);
     }
     return parent::getUrl("{$_route}/{$_controller}/{$_action}", $routeParams);
 }
Beispiel #19
0
 protected function setOriginalUrl($routePath = null, $routeParams = null)
 {
     // Get the original URLs from the registry
     $original_urls = Mage::registry('original_urls');
     // If this value is empty, it is not yet initialized
     if (empty($original_urls)) {
         return parent::getUrl($routePath, $routeParams);
     }
     // Fetch the result from this method
     $rt = parent::getUrl($routePath, $routeParams);
     // Replace the current URL with the original URL
     $store = Mage::app()->getStore();
     if ($store->getConfig('web/secure/use_in_frontend') == 1 && isset($original_urls['web/secure/base_url'])) {
         $rt = str_replace($store->getConfig('web/secure/base_url'), $original_urls['web/secure/base_url'], $rt);
     } elseif (isset($original_urls['web/unsecure/base_url'])) {
         $rt = str_replace($store->getConfig('web/unsecure/base_url'), $original_urls['web/unsecure/base_url'], $rt);
     }
     return $rt;
 }