public function match($pathInfo) { $identifier = trim($pathInfo, '/'); $parts = explode('/', $identifier); if (count($parts) == 1) { $parts[0] = $this->getUrlKeyWithoutSuffix($parts[0]); } if (isset($parts[0]) && !isset($this->config2[$parts[0]])) { return false; } $module = $this->config2[$parts[0]]; if (!$this->isEnabled($module)) { return false; } if (count($parts) > 1) { unset($parts[0]); $urlKey = implode('/', $parts); $urlKey = urldecode($urlKey); $urlKey = $this->getUrlKeyWithoutSuffix($urlKey); } else { $urlKey = ''; } # check on static urls (urls for static pages, ex. lists) $type = $rewrite = false; foreach ($this->config[$module] as $t => $key) { if ($key === $urlKey) { if ($t == '_BASEPATH') { continue; } $type = $t; break; } } # check on dynamic urls (ex. urls of products, categories etc) if (!$type) { $collection = Mage::getModel('mstcore/urlrewrite')->getCollection()->addFieldToFilter('url_key', $urlKey)->addFieldToFilter('module', $module); if ($collection->count()) { $rewrite = $collection->getFirstItem(); $type = $rewrite->getType(); } else { return false; } } if ($type) { $action = $this->config2[$module . '_' . $type]['ACTION']; $params = $this->config2[$module . '_' . $type]['PARAMS']; $result = new Varien_Object(); $actionParts = explode('_', $action); $result->setRouteName($actionParts[0])->setModuleName($actionParts[0])->setControllerName($actionParts[1])->setActionName($actionParts[2])->setActionParams($params); if ($rewrite) { $result->setEntityId($rewrite->getEntityId()); } return $result; } return false; }
public function match($pathInfo) { $identifier = trim($pathInfo, '/'); $parts = explode('/', $identifier); if (count($parts) == 1) { $parts[0] = $this->getUrlKeyWithoutSuffix($parts[0]); } if (isset($parts[0]) && !isset($this->config2[$parts[0]])) { return false; } $module = $this->config2[$parts[0]]; if (!$this->isEnabled($module)) { return false; } if (count($parts) > 1) { unset($parts[0]); $urlKey = implode('/', $parts); $urlKey = urldecode($urlKey); $urlKey = $this->getUrlKeyWithoutSuffix($urlKey); } else { $urlKey = ''; } //пÑовеÑÑем на ÑÑаÑиÑеÑкие ÑÑÐ»Ñ (ÑÑÐ»Ñ Ð¿Ð¾ÑÑоÑннÑÑ ÑÑÑаниÑ, напÑÐ¸Ð¼ÐµÑ ÑпиÑков) $type = $rewrite = false; foreach ($this->config[$module] as $t => $key) { if ($key === $urlKey) { $type = $t; break; } } // пÑовеÑÑем на динамиÑеÑкие ÑÑÐ»Ñ (ÑÑÐ»Ñ Ð¿ÑодÑкÑов, каÑегоÑий и Ñд) if (!$type) { $collection = Mage::getModel('mstcore/urlrewrite')->getCollection()->addFieldToFilter('url_key', $urlKey)->addFieldToFilter('module', $module); if ($collection->count()) { $rewrite = $collection->getFirstItem(); $type = $rewrite->getType(); } else { return false; } } if ($type) { $action = $this->config2[$module . '_' . $type]; $result = new Varien_Object(); $actionParts = explode('_', $action); $result->setRouteName($actionParts[0])->setModuleName($actionParts[0])->setControllerName($actionParts[1])->setActionName($actionParts[2]); if ($rewrite) { $result->setEntityId($rewrite->getEntityId()); } return $result; } return false; }