/**
  * Parameters ::= Parameter {ParameterSeparator Parameter } .
  * @param Mana_Seo_Model_ParsedUrl $token
  * @return bool
  */
 protected function _parseParameters($token)
 {
     if (!$token->getTextToBeParsed()) {
         return $this->_setResult($token);
     }
     // split by "/", add correction for token beginning with "/"
     if ($tokens = $this->_scanUntilSeparator($token, $this->_schema->getParamSeparator())) {
         foreach ($tokens as $token) {
             // process token parameter and then continue parsing all parameters in nextToken.
             // Return if exact match found
             if ($this->_parseParameter($token)) {
                 return true;
             }
         }
     }
     return false;
 }
Beispiel #2
0
 public function getRoutePath($routeParams = array())
 {
     if ($this->_pageUrlKey === null) {
         if ($this->_query) {
             $this->setData('query_params', $this->_query);
         }
         return parent::getRoutePath($routeParams);
     }
     /* @var $core Mana_Core_Helper_Data */
     $core = Mage::helper('mana_core');
     if (!$this->hasData('route_path')) {
         $query = $this->_query;
         if ($query !== null) {
             if (is_string($query)) {
                 $this->setQuery($query);
             } elseif (is_array($query)) {
                 $this->setQueryParams($query, !empty($routeParams['_current']));
             }
             if ($query === false) {
                 $this->setQueryParams(array());
             }
         }
         $queryParams = $this->getQueryParams();
         $seoParams = array();
         foreach ($this->getQueryParams() as $key => $value) {
             $path = false;
             if ($key == 'p' && $value == 1) {
                 unset($queryParams[$key]);
                 continue;
             }
             if ($value !== null) {
                 if ($url = $this->_getParameterUrl($key)) {
                     $position = $url->getPosition();
                     $attribute_id = $url->getAttributeId();
                     $category_id = null;
                     switch ($url->getType()) {
                         case Mana_Seo_Model_ParsedUrl::PARAMETER_ATTRIBUTE:
                             $path = $this->_generateAttributeParameter($url, $value);
                             break;
                         case Mana_Seo_Model_ParsedUrl::PARAMETER_CATEGORY:
                             list($path, $category_id) = $this->_generateCategoryParameter($url, $value);
                             break;
                         case Mana_Seo_Model_ParsedUrl::PARAMETER_PRICE:
                             $path = $this->_generatePriceParameter($url, $value);
                             break;
                         case Mana_Seo_Model_ParsedUrl::PARAMETER_TOOLBAR:
                             $path = $this->_generateToolbarParameter($url, $value);
                             break;
                         default:
                             throw new Exception('Not implemented');
                     }
                 }
             }
             if ($path) {
                 $seoParams[$key] = compact('path', 'position', 'attribute_id', 'category_id');
                 unset($queryParams[$key]);
             }
         }
         $this->_redirectToSubcategory($seoParams);
         uasort($seoParams, array($this, '_compareSeoParams'));
         $routePath = $this->_encode($this->_pageUrlKey);
         $first = true;
         foreach ($seoParams as $path) {
             if ($first) {
                 if ($routePath) {
                     $routePath .= $this->_schema->getQuerySeparator();
                 }
                 $first = false;
             } else {
                 $routePath .= $this->_schema->getParamSeparator();
             }
             $routePath .= $path['path'];
         }
         if ($routePath) {
             $routePath .= $core->addDotToSuffix($this->_suffix);
         }
         $this->setData('query_params', $queryParams);
         $this->setData('route_path', $routePath);
     }
     return $this->_getData('route_path');
 }