Beispiel #1
0
 /**
  * @return bool
  */
 protected function matchForwardShort()
 {
     $pageId = $this->request->getPathInfo();
     $pageId = $this->getUrlHelper()->checkRemoveSuffix($pageId);
     $pageId = trim($pageId, '/');
     $p = strrpos($pageId, '/');
     if ($p) {
         $cat = substr($pageId, 0, $p);
         $params = substr($pageId, $p);
     } else {
         $cat = '';
         $params = $pageId;
     }
     /** @var Amasty_Shopby_Model_Url_Parser $shortParser */
     $shortParser = Mage::getModel('amshopby/url_parser');
     $query = $shortParser->parseParams($params);
     if ($query === false) {
         return false;
     }
     $query = array_merge($this->request->getQuery(), $query);
     $this->request->setQuery($query);
     if (strlen($cat)) {
         // normal category
         try {
             $this->forwardCategory($cat);
         } catch (Mage_Core_Controller_Varien_Exception $e) {
             return false;
         }
     } else {
         // root category
         $this->forwardShopby();
     }
     return true;
 }
Beispiel #2
0
 /**
  * @return bool
  */
 protected function matchForwardShort()
 {
     $pageId = $this->request->getPathInfo();
     $pageId = $this->getUrlHelper()->checkRemoveSuffix($pageId);
     $pageId = trim($pageId, '/');
     $p = strrpos($pageId, '/');
     if ($p) {
         $cat = substr($pageId, 0, $p);
         $params = substr($pageId, $p);
     } else {
         $cat = '';
         $params = $pageId;
     }
     /** @var Amasty_Shopby_Model_Url_Parser $shortParser */
     $shortParser = Mage::getModel('amshopby/url_parser');
     $queryDelta = $shortParser->parseParams($params);
     if (is_array($queryDelta)) {
         $query = $this->request->getQuery();
         $query = array_merge($query, $queryDelta);
         $this->request->setQuery($query);
         if (strlen($cat)) {
             // normal category
             $result = $this->forwardCategory($cat);
         } else {
             // root category
             $this->forwardShopby();
             $result = true;
         }
         return $result;
     }
     return false;
 }
Beispiel #3
0
 public function getRequestParameters()
 {
     if ($this->request->isPost()) {
         return $this->request->getPost();
     } else {
         return $this->request->getQuery();
     }
 }
Beispiel #4
0
 public function testSetRequestUri()
 {
     $this->_request->setRequestUri('/archives/past/4?set=this&unset=that');
     $this->assertEquals('/archives/past/4?set=this&unset=that', $this->_request->getRequestUri());
     $this->assertEquals('this', $this->_request->getQuery('set'));
     $this->assertEquals('that', $this->_request->getQuery('unset'));
 }
 /**
  * Implement logic of custom rewrites
  *
  * @return bool
  */
 protected function _rewriteDb()
 {
     if (null === $this->_rewrite->getStoreId() || false === $this->_rewrite->getStoreId()) {
         $this->_rewrite->setStoreId($this->_app->getStore()->getId());
     }
     $requestCases = $this->_getRequestCases();
     $this->_rewrite->loadByRequestPath($requestCases);
     $fromStore = $this->_request->getQuery('___from_store');
     if (!$this->_rewrite->getId() && $fromStore) {
         $stores = $this->_app->getStores(false, true);
         if (!empty($stores[$fromStore])) {
             /** @var $store Mage_Core_Model_Store */
             $store = $stores[$fromStore];
             $fromStoreId = $store->getId();
         } else {
             return false;
         }
         $this->_rewrite->setStoreId($fromStoreId)->loadByRequestPath($requestCases);
         if (!$this->_rewrite->getId()) {
             return false;
         }
         // Load rewrite by id_path
         $currentStore = $this->_app->getStore();
         $this->_rewrite->setStoreId($currentStore->getId())->loadByIdPath($this->_rewrite->getIdPath());
         $this->_setStoreCodeCookie($currentStore->getCode());
         $targetUrl = $currentStore->getBaseUrl() . $this->_rewrite->getRequestPath();
         $this->_sendRedirectHeaders($targetUrl, true);
     }
     if (!$this->_rewrite->getId()) {
         return false;
     }
     $this->_request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $this->_rewrite->getRequestPath());
     $this->_processRedirectOptions();
     return true;
 }
Beispiel #6
0
 /**
  * Возвращает массив опций для построения постраничной навигации
  * Необходимо дергать сразу после выполнения SQL-запроса с SQL_CAL_FOUND_ROWS
  * 
  * @param array $options - Массив опций
  * 
  * @return object
  */
 function getPaginator($options = array())
 {
     $Paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Null($this->_db->fetchOne('SELECT FOUND_ROWS()')));
     $Paginator->setItemCountPerPage(isset($options['perpage']) ? $options['perpage'] : $this->getPerPage());
     if (isset($options['widgetid'])) {
         $Paginator->setCurrentPageNumber($this->getCurrentPage($options['widgetid']));
     } else {
         $Paginator->setCurrentPageNumber($this->getCurrentPage());
     }
     $out = $Paginator->getPages();
     $pageidentity = $this->getPageIdentity();
     // Кроме стандартных параметров Zend_Paginator::getPages() возвращаем доп. параметры
     // Полный путь без GET-запроса
     $UrlInfo = parse_url($this->_request->getRequestUri());
     $out->ClearUrl = $UrlInfo['path'];
     // Обрабатываем GET-запрос
     $query = $this->_request->getQuery();
     if (isset($query[$pageidentity])) {
         unset($query[$pageidentity]);
     }
     if (isset($query['widget'])) {
         unset($query['widget']);
     }
     // Строим строку выражения
     if (!empty($query)) {
         $out->Query = http_build_query($query);
     }
     // Фактически, ссылку на первую страницу (без page и widget)
     $out->FullUrl = isset($out->Query) ? $out->ClearUrl . '?' . $out->Query : $out->ClearUrl;
     // Добавляем к выражению Id виджета
     $widget = isset($options['widgetid']) ? 'widget=' . (int) $options['widgetid'] . '&' : '';
     // Полную ссылку к которой в конце надо только добавить номер страницы
     $out->PageUrl = isset($out->Query) ? $out->FullUrl . '&' . $widget . $pageidentity . '=' : $out->FullUrl . '?' . $widget . $pageidentity . '=';
     return $out;
 }
Beispiel #7
0
 /**
  * @access public
  * @param  string  $key     Key to search for in $_GET
  * @param  mixed   $default Default value if $key is not found in $_GET
  * @param  integer $filter  Filter definition
  * @param  array   $options Filter configuration
  * @return mixed
  */
 public function getQuery($key = null, $default = null, $filter = null, array $options = null)
 {
     $value = parent::getQuery($key, $default);
     if ($filter !== null || $options !== null) {
         $value = $this->_filter($value, $default, $filter, $options);
     }
     return $value;
 }
Beispiel #8
0
 /**
  * Redirect to startup page after logging in if request contains any params (except security key)
  *
  * @param Mage_Admin_Model_User $user
  * @param Zend_Controller_Request_Http $request
  * @param string|null $alternativeUrl
  * @return null|string
  */
 public function getRedirectUrl(Mage_Admin_Model_User $user, Zend_Controller_Request_Http $request = null, $alternativeUrl = null)
 {
     if (empty($request)) {
         return;
     }
     $countRequiredParams = $this->_urlModel->useSecretKey() && $request->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME) ? 1 : 0;
     $countGetParams = count($request->getUserParams()) + count($request->getQuery());
     return $countGetParams > $countRequiredParams ? $this->_urlModel->getUrl($user->getStartupPageUrl()) : $alternativeUrl;
 }
Beispiel #9
0
 /**
  * Do basic validation for request to be cached
  *
  * @param Zend_Controller_Request_Http $request
  * @return bool
  */
 public function canProcessRequest(Zend_Controller_Request_Http $request)
 {
     $res = $this->isAllowed();
     $res = $res && Mage::app()->useCache('full_page');
     if ($request->getParam('no_cache')) {
         $res = false;
     }
     if ($res) {
         $maxDepth = Mage::getStoreConfig(self::XML_PATH_ALLOWED_DEPTH);
         $queryParams = $request->getQuery();
         unset($queryParams[Enterprise_PageCache_Model_Cache::REQUEST_MESSAGE_GET_PARAM]);
         $res = count($queryParams) <= $maxDepth;
     }
     if ($res) {
         $multicurrency = Mage::getStoreConfig(self::XML_PATH_CACHE_MULTICURRENCY);
         if (!$multicurrency && !empty($_COOKIE['currency'])) {
             $res = false;
         }
     }
     return $res;
 }
Beispiel #10
0
 /**
  * 
  * @param Zend_Controller_Request_Http $request
  * @return string
  */
 protected function _getRequestParamsString(Zend_Controller_Request_Http $request)
 {
     $allRequestParameters = $request->getQuery();
     return count($allRequestParameters) ? http_build_query($allRequestParameters) : '';
 }
Beispiel #11
0
 /**
  * Retrieve protocol parameters from query string
  *
  * @return Mage_Oauth_Model_Server
  */
 protected function _fetchProtocolParamsFromQuery()
 {
     foreach ($this->_request->getQuery() as $queryParamName => $queryParamValue) {
         if ($this->_isProtocolParameter($queryParamName)) {
             $this->_protocolParams[$queryParamName] = $queryParamValue;
         }
     }
     return $this;
 }
 /**
  * 获取当前页页码
  *
  * @return integer
  */
 public function getCurrentPage()
 {
     if (null === $this->_currentPage) {
         $request = new Zend_Controller_Request_Http();
         $currentPage = $request->getQuery($this->getUriSegment());
         $this->setCurrentPage($currentPage);
     }
     return $this->_currentPage;
 }
Beispiel #13
0
 /**
  * Builds a new URL using an existing $request.
  *
  * @param string $scheme http or https
  * @param string $hostname
  * @param string $baseUrl
  * @param Zend_Controller_Request_Http $request
  * @return string
  */
 private function buildUrl($scheme, $hostname, $baseUrl, Zend_Controller_Request_Http $request)
 {
     $url = sprintf('%s://%s%s%s', $scheme, $hostname, $baseUrl, $request->getPathInfo());
     $query = $request->getQuery();
     if (!empty($query)) {
         $url .= '?' . http_build_query($query);
     }
     return $url;
 }
Beispiel #14
0
 public function getQuery($k = null, $default = null)
 {
     if (in_array('vars', $this->getParamSources())) {
         if (!$this->isGet()) {
             return $k === null ? array() : null;
         }
         if ($k === null) {
             return $this->_vars;
         } else {
             return isset($this->_vars[$k]) ? $this->_vars[$k] : $default;
         }
     } else {
         return parent::getQuery($k, $default);
     }
 }