/** * Clean URL pattern * * @return string */ protected function getCleanURLPattern() { return '/^' . \XLite\Core\Converter::getCleanURLAllowedCharsPattern() . '$/S'; }
/** * Get canonical URL by clean URL * * @param string $path Clean url * * @return string */ public function getURLByCleanURL($path) { $cleanURL = null; if (preg_match('/(' . \XLite\Core\Converter::getCleanURLAllowedCharsPattern() . ')\\.html?$/Si', $path, $parts)) { $product = \XLite\Core\Database::getRepo('XLite\\Model\\Product')->findOneByCleanURL($parts[1]); if (isset($product)) { $cleanURL = $this->buildCleanURL('product', '', array('product_id' => $product->getProductId())); } } else { $parts = preg_split('\'/\'', $path, 2, PREG_SPLIT_NO_EMPTY); $category = \XLite\Core\Database::getRepo('XLite\\Model\\Category')->findOneByCleanURL($parts[0]); if (isset($category)) { $params = array('category_id' => $category->getCategoryId()); if (!empty($parts[1])) { $query = \Includes\Utils\Converter::parseQuery($parts[1], '-', '/'); if (is_array($query)) { $params += $query; } } $cleanURL = $this->buildCleanURL('category', '', $params); } } return $cleanURL; }