当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Core_Model_Store::getCurrentUrl方法代码示例

本文整理汇总了PHP中Mage_Core_Model_Store::getCurrentUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Store::getCurrentUrl方法的具体用法?PHP Mage_Core_Model_Store::getCurrentUrl怎么用?PHP Mage_Core_Model_Store::getCurrentUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Core_Model_Store的用法示例。


在下文中一共展示了Mage_Core_Model_Store::getCurrentUrl方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCurrentUrl

 public function getCurrentUrl($fromStore = true)
 {
     $sidQueryParam = $this->_getSession()->getSessionIdQueryParam();
     $storeUrl = Mage::app()->getStore()->isCurrentlySecure() ? $this->getUrl('', array('_secure' => true)) : $this->getUrl('');
     $storeParsedUrl = parse_url($storeUrl);
     $params = array('_current' => true, '_m_escape' => '', '_use_rewrite' => true, '_secure' => Mage::app()->getFrontController()->getRequest()->isSecure());
     $currentUrl = Mage::getUrl('*/*/*', $params);
     if (($pos = strpos($currentUrl, '?')) !== false) {
         $currentUrl = substr($currentUrl, 0, $pos);
     }
     $requestString = ltrim(Mage::app()->getRequest()->getRequestString(), '/');
     $storeParsedQuery = array();
     if (isset($storeParsedUrl['query'])) {
         parse_str($storeParsedUrl['query'], $storeParsedQuery);
     }
     $currQuery = Mage::app()->getRequest()->getQuery();
     if (isset($currQuery[$sidQueryParam]) && !empty($currQuery[$sidQueryParam]) && $this->_getSession()->getSessionIdForHost($storeUrl) != $currQuery[$sidQueryParam]) {
         unset($currQuery[$sidQueryParam]);
     }
     foreach ($currQuery as $k => $v) {
         $storeParsedQuery[$k] = $v;
     }
     if (!Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL, $this->getCode())) {
         $storeParsedQuery['___store'] = $this->getCode();
     }
     //if ($fromStore !== false) {
     $storeParsedQuery['___from_store'] = $fromStore === true ? Mage::app()->getStore()->getCode() : $fromStore;
     //}
     return $storeParsedUrl['scheme'] . '://' . $storeParsedUrl['host'] . (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '') . $storeParsedUrl['path'] . $requestString . ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
     return Mage::helper('mana_filters')->markLayeredNavigationUrl(Mage::getUrl('*/*/*', $params), '*/*/*', $params);
     /* @var $url Mana_Seo_Rewrite_Url */
     $url = Mage::getSingleton('core/url');
     return $url->getUrl('*/*/*', parent::getCurrentUrl($fromStore));
 }
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:34,代码来源:Mana_Seo_Rewrite_Store.php

示例2: getCurrentUrl

 public function getCurrentUrl($fromStore = true)
 {
     /** @var $core Mana_Core_Helper_Data */
     /** @var ManaPro_FilterSeoLinks_Model_Url $coreUrl */
     $core = Mage::helper('mana_core');
     $coreUrl = Mage::getSingleton('core/url');
     $conditionalWord = $core->getStoreConfig('mana_filters/seo/conditional_word');
     $request = Mage::app()->getRequest();
     $currentPath = $request->getRouteName() . '/' . $request->getControllerName() . '/' . $request->getActionName();
     $currentUrl = parent::getCurrentUrl($fromStore);
     // delete SEO friendly filters from url path in catalog
     if ($currentPath == 'catalog/category/view' && ($position = strpos($currentUrl, $conditionalWord)) !== false) {
         $parts = parse_url($currentUrl);
         $currentUrl = substr($currentUrl, 0, $position - 1) . '?' . $parts['query'];
     }
     return $coreUrl->setEscape(true)->encodeUrl('*/*/*', $currentUrl);
 }
开发者ID:popovsergiy,项目名称:magento-seo,代码行数:17,代码来源:Store.php

示例3: getCurrentUrl

 /**
  * This method is used to generate URL for store switcher (or language switcher) blocks, typically located in page header
  * or page footer. `$this` is store to which the URL should switch our user, whereas `Mage::app()->getRequest()` represents
  * current user location in current store.
  * @param bool $fromStore
  * @return string
  */
 public function getCurrentUrl($fromStore = true)
 {
     // we only change generation of store URLs on layered navigation enabled pages
     if ($parsedUrl = Mage::registry('m_parsed_url')) {
         // get instance of a model which can generate URL for target store
         $urlModel = Mage::getModel('core/url');
         $urlModel->setStore($this);
         // set basic URL generation parameters
         $params = array_merge(array('_use_rewrite' => true, '_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()), $parsedUrl->getImplodedParameters());
         // add URL query parameters (all applied filters, toolbar parameters and other arbitrary parameters)
         $query = count($parsedUrl->getQueryParameters()) ? $parsedUrl->getImplodedQueryParameters() : array();
         // get array of URL query parameters applied to the current page. The resulting array may contain applied filters in non-
         // SEO-friendly form (added by Mana_Seo_Router) like [ "price" => "0,100" ] and other arbitrary parameters like
         // [ "qq" => "pp" ].
         $currQuery = Mage::app()->getRequest()->getQuery();
         // get base URL of this store
         $storeUrl = Mage::app()->getStore()->isCurrentlySecure() ? $this->getUrl('', array('_secure' => true)) : $this->getUrl('');
         // retrieve name of session id URL query parameter, typically "SID"
         $sidQueryParam = $this->_getSession()->getSessionIdQueryParam();
         // in case session id is in URL and not in cookie we may remove it from current URL query parameters so, that would
         // basically start new session after store is switched
         if (!empty($currQuery[$sidQueryParam])) {
             if ($this->_getSession()->getSessionIdForHost($storeUrl) != $currQuery[$sidQueryParam]) {
                 $params['_nosid'] = true;
             }
         }
         // add source and target store to target URL query
         $fromStoreCode = $fromStore === true ? Mage::app()->getStore()->getCode() : $fromStore;
         if ($this->getCode() != $fromStoreCode) {
             if (!Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL, $this->getCode())) {
                 $query['___store'] = $this->getCode();
             }
             $query['___from_store'] = $fromStore === true ? Mage::app()->getStore()->getCode() : $fromStore;
         }
         // add URL query parameters (if any) to URL generation parameters
         if (count($query)) {
             $params['_query'] = $query;
         }
         // generate and return URL for target store
         $url = $urlModel->getUrl($parsedUrl->getRoute(), $params);
         return $url;
     } else {
         return parent::getCurrentUrl($fromStore);
     }
 }
开发者ID:xiaoguizhidao,项目名称:cupboardglasspipes.ecomitize.com,代码行数:52,代码来源:Store.php

示例4: testGetCurrentUrl

 public function testGetCurrentUrl()
 {
     $this->_model->expects($this->any())->method('getUrl')->will($this->returnValue('http://localhost/index.php'));
     $this->assertStringEndsWith('default', $this->_model->getCurrentUrl());
     $this->assertStringEndsNotWith('default', $this->_model->getCurrentUrl(false));
 }
开发者ID:relue,项目名称:magento2,代码行数:6,代码来源:StoreTest.php

示例5: getCurrentUrl

 public function getCurrentUrl($fromStore = true)
 {
     return Mage::getSingleton('core/url')->setEscape(true)->encodeUrl('*/*/*', parent::getCurrentUrl($fromStore));
 }
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:4,代码来源:ManaPro_FilterSeoLinks_Model_Store.php


注:本文中的Mage_Core_Model_Store::getCurrentUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。