start rewriting
This commit is contained in:
@@ -218,10 +218,10 @@ abstract class BaseLoop
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \ModelCriteria $search
|
* @param ModelCriteria $search
|
||||||
* @param $pagination
|
* @param $pagination
|
||||||
*
|
*
|
||||||
* @return array|\PropelModelPager
|
* @return array|\Propel\Runtime\Util\PropelModelPager
|
||||||
*/
|
*/
|
||||||
protected function searchWithPagination(ModelCriteria $search, &$pagination)
|
protected function searchWithPagination(ModelCriteria $search, &$pagination)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class Attribute extends BaseLoop
|
|||||||
$lang = $this->getLang();
|
$lang = $this->getLang();
|
||||||
|
|
||||||
/* manage translations */
|
/* manage translations */
|
||||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||||
|
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class AttributeAvailability extends BaseLoop
|
|||||||
$lang = $this->getLang();
|
$lang = $this->getLang();
|
||||||
|
|
||||||
/* manage translations */
|
/* manage translations */
|
||||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||||
|
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class AttributeCombination extends BaseLoop
|
|||||||
/* manage attribute translations */
|
/* manage attribute translations */
|
||||||
ModelCriteriaTools::getFrontEndI18n(
|
ModelCriteriaTools::getFrontEndI18n(
|
||||||
$search,
|
$search,
|
||||||
ConfigQuery::read("default_lang_without_translation", 1),
|
ConfigQuery::getDefaultLangWhenNoTranslationAvailable(),
|
||||||
$this->request->getSession()->getLocale(),
|
$this->request->getSession()->getLocale(),
|
||||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||||
AttributeTableMap::TABLE_NAME,
|
AttributeTableMap::TABLE_NAME,
|
||||||
@@ -91,7 +91,7 @@ class AttributeCombination extends BaseLoop
|
|||||||
/* manage attributeAv translations */
|
/* manage attributeAv translations */
|
||||||
ModelCriteriaTools::getFrontEndI18n(
|
ModelCriteriaTools::getFrontEndI18n(
|
||||||
$search,
|
$search,
|
||||||
ConfigQuery::read("default_lang_without_translation", 1),
|
ConfigQuery::getDefaultLangWhenNoTranslationAvailable(),
|
||||||
$this->request->getSession()->getLocale(),
|
$this->request->getSession()->getLocale(),
|
||||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||||
AttributeAvTableMap::TABLE_NAME,
|
AttributeAvTableMap::TABLE_NAME,
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class Category extends BaseLoop
|
|||||||
$lang = $this->getLang();
|
$lang = $this->getLang();
|
||||||
|
|
||||||
/* manage translations */
|
/* manage translations */
|
||||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
$locale = ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||||
|
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ class Category extends BaseLoop
|
|||||||
->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION'))
|
->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION'))
|
||||||
->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||||
->set("PARENT", $category->getParent())
|
->set("PARENT", $category->getParent())
|
||||||
->set("URL", $category->getUrl())
|
->set("URL", $category->getUrl($locale))
|
||||||
->set("PRODUCT_COUNT", $category->countChild())
|
->set("PRODUCT_COUNT", $category->countChild())
|
||||||
->set("VISIBLE", $category->getVisible() ? "1" : "0")
|
->set("VISIBLE", $category->getVisible() ? "1" : "0")
|
||||||
->set("POSITION", $category->getPosition())
|
->set("POSITION", $category->getPosition())
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class Content extends BaseLoop
|
|||||||
$lang = $this->getLang();
|
$lang = $this->getLang();
|
||||||
|
|
||||||
/* manage translations */
|
/* manage translations */
|
||||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
$locale = ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||||
|
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ class Content extends BaseLoop
|
|||||||
->set("DESCRIPTION", $content->getVirtualColumn('i18n_DESCRIPTION'))
|
->set("DESCRIPTION", $content->getVirtualColumn('i18n_DESCRIPTION'))
|
||||||
->set("POSTSCRIPTUM", $content->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
->set("POSTSCRIPTUM", $content->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||||
->set("POSITION", $content->getPosition())
|
->set("POSITION", $content->getPosition())
|
||||||
->set("URL", $content->getUrl())
|
->set("URL", $content->getUrl($locale))
|
||||||
;
|
;
|
||||||
|
|
||||||
$loopResult->addRow($loopResultRow);
|
$loopResult->addRow($loopResultRow);
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class Country extends BaseLoop
|
|||||||
$lang = $this->getLang();
|
$lang = $this->getLang();
|
||||||
|
|
||||||
/* manage translations */
|
/* manage translations */
|
||||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||||
|
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class Currency extends BaseLoop
|
|||||||
$lang = $this->getLang();
|
$lang = $this->getLang();
|
||||||
|
|
||||||
/* manage translations */
|
/* manage translations */
|
||||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), array('NAME'));
|
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale(), array('NAME'));
|
||||||
|
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class Feature extends BaseLoop
|
|||||||
$lang = $this->getLang();
|
$lang = $this->getLang();
|
||||||
|
|
||||||
/* manage translations */
|
/* manage translations */
|
||||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||||
|
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class FeatureAvailability extends BaseLoop
|
|||||||
$lang = $this->getLang();
|
$lang = $this->getLang();
|
||||||
|
|
||||||
/* manage translations */
|
/* manage translations */
|
||||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||||
|
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class FeatureValue extends BaseLoop
|
|||||||
/* manage featureAv translations */
|
/* manage featureAv translations */
|
||||||
ModelCriteriaTools::getFrontEndI18n(
|
ModelCriteriaTools::getFrontEndI18n(
|
||||||
$search,
|
$search,
|
||||||
ConfigQuery::read("default_lang_without_translation", 1),
|
ConfigQuery::getDefaultLangWhenNoTranslationAvailable(),
|
||||||
$this->request->getSession()->getLocale(),
|
$this->request->getSession()->getLocale(),
|
||||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||||
FeatureAvTableMap::TABLE_NAME,
|
FeatureAvTableMap::TABLE_NAME,
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class Folder extends BaseLoop
|
|||||||
$lang = $this->getLang();
|
$lang = $this->getLang();
|
||||||
|
|
||||||
/* manage translations */
|
/* manage translations */
|
||||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
$locale = ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||||
|
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ class Folder extends BaseLoop
|
|||||||
->set("DESCRIPTION", $folder->getVirtualColumn('i18n_DESCRIPTION'))
|
->set("DESCRIPTION", $folder->getVirtualColumn('i18n_DESCRIPTION'))
|
||||||
->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||||
->set("PARENT", $folder->getParent())
|
->set("PARENT", $folder->getParent())
|
||||||
->set("URL", $folder->getUrl())
|
->set("URL", $folder->getUrl($locale))
|
||||||
->set("CONTENT_COUNT", $folder->countChild())
|
->set("CONTENT_COUNT", $folder->countChild())
|
||||||
->set("VISIBLE", $folder->getVisible() ? "1" : "0")
|
->set("VISIBLE", $folder->getVisible() ? "1" : "0")
|
||||||
->set("POSITION", $folder->getPosition())
|
->set("POSITION", $folder->getPosition())
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ class Image extends BaseLoop
|
|||||||
|
|
||||||
$search->joinWithI18n(
|
$search->joinWithI18n(
|
||||||
$this->request->getSession()->getLocale(),
|
$this->request->getSession()->getLocale(),
|
||||||
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
(ConfigQuery::getDefaultLangWhenNoTranslationAvailable()) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
|
||||||
);
|
);
|
||||||
|
|
||||||
$results = $this->search($search, $pagination);
|
$results = $this->search($search, $pagination);
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class Product extends BaseLoop
|
|||||||
$lang = $this->getLang();
|
$lang = $this->getLang();
|
||||||
|
|
||||||
/* manage translations */
|
/* manage translations */
|
||||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale());
|
$locale = ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale());
|
||||||
|
|
||||||
$attributeNonStrictMatch = $this->getAttribute_non_strict_match();
|
$attributeNonStrictMatch = $this->getAttribute_non_strict_match();
|
||||||
$isPSELeftJoinList = array();
|
$isPSELeftJoinList = array();
|
||||||
@@ -520,7 +520,7 @@ class Product extends BaseLoop
|
|||||||
->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO'))
|
->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO'))
|
||||||
->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION'))
|
->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION'))
|
||||||
->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||||
->set("URL", $product->getUrl())
|
->set("URL", $product->getUrl($locale))
|
||||||
->set("BEST_PRICE", $product->getVirtualColumn('real_lowest_price'))
|
->set("BEST_PRICE", $product->getVirtualColumn('real_lowest_price'))
|
||||||
->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo'))
|
->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo'))
|
||||||
->set("IS_NEW", $product->getVirtualColumn('main_product_is_new'))
|
->set("IS_NEW", $product->getVirtualColumn('main_product_is_new'))
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class Title extends BaseLoop
|
|||||||
$lang = $this->getLang();
|
$lang = $this->getLang();
|
||||||
|
|
||||||
/* manage translations */
|
/* manage translations */
|
||||||
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::read("default_lang_without_translation", 1), $this->request->getSession()->getLocale(), array('SHORT', 'LONG'));
|
ModelCriteriaTools::getI18n($backendContext, $lang, $search, ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), $this->request->getSession()->getLocale(), array('SHORT', 'LONG'));
|
||||||
|
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Thelia\Model;
|
|||||||
|
|
||||||
use Thelia\Model\Base\Category as BaseCategory;
|
use Thelia\Model\Base\Category as BaseCategory;
|
||||||
use Propel\Runtime\ActiveQuery\Criteria;
|
use Propel\Runtime\ActiveQuery\Criteria;
|
||||||
|
use Thelia\Tools\URL;
|
||||||
|
|
||||||
class Category extends BaseCategory
|
class Category extends BaseCategory
|
||||||
{
|
{
|
||||||
@@ -15,8 +16,9 @@ class Category extends BaseCategory
|
|||||||
return CategoryQuery::countChild($this->getId());
|
return CategoryQuery::countChild($this->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUrl()
|
public function getUrl($locale)
|
||||||
{
|
{
|
||||||
|
return URL::retrieve('category', $this->getId(), $locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,4 +22,14 @@ class ConfigQuery extends BaseConfigQuery {
|
|||||||
|
|
||||||
return $value ? $value->getValue() : $default;
|
return $value ? $value->getValue() : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getDefaultLangWhenNoTranslationAvailable()
|
||||||
|
{
|
||||||
|
return ConfigQuery::read("default_lang_without_translation", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isRewritingEnable()
|
||||||
|
{
|
||||||
|
return self::read("rewriting_enable") == 1;
|
||||||
|
}
|
||||||
} // ConfigQuery
|
} // ConfigQuery
|
||||||
|
|||||||
@@ -3,11 +3,12 @@
|
|||||||
namespace Thelia\Model;
|
namespace Thelia\Model;
|
||||||
|
|
||||||
use Thelia\Model\Base\Content as BaseContent;
|
use Thelia\Model\Base\Content as BaseContent;
|
||||||
|
use Thelia\Tools\URL;
|
||||||
|
|
||||||
class Content extends BaseContent
|
class Content extends BaseContent
|
||||||
{
|
{
|
||||||
public function getUrl()
|
public function getUrl($locale)
|
||||||
{
|
{
|
||||||
|
return URL::retrieve('content', $this->getId(), $locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Thelia\Model;
|
namespace Thelia\Model;
|
||||||
|
|
||||||
use Thelia\Model\Base\Folder as BaseFolder;
|
use Thelia\Model\Base\Folder as BaseFolder;
|
||||||
|
use Thelia\Tools\URL;
|
||||||
|
|
||||||
class Folder extends BaseFolder
|
class Folder extends BaseFolder
|
||||||
{
|
{
|
||||||
@@ -14,9 +15,9 @@ class Folder extends BaseFolder
|
|||||||
return FolderQuery::countChild($this->getId());
|
return FolderQuery::countChild($this->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUrl()
|
public function getUrl($locale)
|
||||||
{
|
{
|
||||||
|
return URL::retrieve('folder', $this->getId(), $locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
namespace Thelia\Model;
|
namespace Thelia\Model;
|
||||||
|
|
||||||
use Thelia\Model\Base\Product as BaseProduct;
|
use Thelia\Model\Base\Product as BaseProduct;
|
||||||
use Thelia\Model\ProductSaleElements;
|
use Thelia\Tools\URL;
|
||||||
|
|
||||||
class Product extends BaseProduct
|
class Product extends BaseProduct
|
||||||
{
|
{
|
||||||
public function getUrl()
|
public function getUrl($locale)
|
||||||
{
|
{
|
||||||
|
return URL::retrieve('product', $this->getId(), $locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,10 +109,14 @@ class ModelCriteriaTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$askedLocale = $lang === null ? $currentLocale : $localeSearch->getLocale();
|
||||||
|
|
||||||
if($backendContext) {
|
if($backendContext) {
|
||||||
self::getBackEndI18n($search, $lang === null ? $currentLocale : $localeSearch->getLocale(), $columns, $foreignTable, $foreignKey);
|
self::getBackEndI18n($search, $askedLocale, $columns, $foreignTable, $foreignKey);
|
||||||
} else {
|
} else {
|
||||||
self::getFrontEndI18n($search, $defaultLangWithoutTranslation, $lang === null ? $currentLocale : $localeSearch->getLocale(), $columns, $foreignTable, $foreignKey);
|
self::getFrontEndI18n($search, $defaultLangWithoutTranslation, $askedLocale, $columns, $foreignTable, $foreignKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $askedLocale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
35
core/lib/Thelia/Rewriting/RewritingResolver.php
Executable file
35
core/lib/Thelia/Rewriting/RewritingResolver.php
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
namespace Thelia\Rewriting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RewritingResolver
|
||||||
|
* @package Thelia\Rewriting
|
||||||
|
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||||
|
*
|
||||||
|
* This class provides methods to resolve rewritten URL as a query
|
||||||
|
*/
|
||||||
|
class RewritingResolver
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
56
core/lib/Thelia/Rewriting/RewritingRetriever.php
Executable file
56
core/lib/Thelia/Rewriting/RewritingRetriever.php
Executable file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
namespace Thelia\Rewriting;
|
||||||
|
|
||||||
|
use Propel\Runtime\ActiveQuery\Criteria;
|
||||||
|
use Thelia\Model\Base\RewritingUrlQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RewritingRetriever
|
||||||
|
* @package Thelia\Rewriting
|
||||||
|
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||||
|
*
|
||||||
|
* This class provides methods to retrieve a rewritten URL from a query
|
||||||
|
*/
|
||||||
|
class RewritingRetriever
|
||||||
|
{
|
||||||
|
public function getViewUrl($view, $viewId, $viewLocale)
|
||||||
|
{
|
||||||
|
$url = RewritingUrlQuery::create()
|
||||||
|
->joinRewritingArgument('ra', Criteria::LEFT_JOIN)
|
||||||
|
->where('ISNULL(`ra`.REWRITING_URL_ID)')
|
||||||
|
->filterByView($view)
|
||||||
|
->filterByViewId($viewId)
|
||||||
|
->filterByViewLocale($viewLocale)
|
||||||
|
->filterByRedirected(null)
|
||||||
|
->orderByUpdatedAt(Criteria::DESC)
|
||||||
|
->findOne();
|
||||||
|
|
||||||
|
return $url === null ? null : $url->getUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public function getSpecificUrl($view, $viewId, $viewLocale, $viewOtherParameters = array())
|
||||||
|
{
|
||||||
|
|
||||||
|
}*/
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
namespace Thelia\Tools;
|
namespace Thelia\Tools;
|
||||||
|
|
||||||
use Thelia\Model\ConfigQuery;
|
use Thelia\Model\ConfigQuery;
|
||||||
|
use Thelia\Rewriting\RewritingRetriever;
|
||||||
|
|
||||||
class URL
|
class URL
|
||||||
{
|
{
|
||||||
@@ -101,4 +102,15 @@ class URL
|
|||||||
|
|
||||||
return self::absoluteUrl($path, $parameters);
|
return self::absoluteUrl($path, $parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function retrieve($view, $viewId, $viewLocale)
|
||||||
|
{
|
||||||
|
$rewrittenUrl = null;
|
||||||
|
if(ConfigQuery::isRewritingEnable()) {
|
||||||
|
$retriever = new RewritingRetriever();
|
||||||
|
$rewrittenUrl = $retriever->getViewUrl($view, $viewId, $viewLocale);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rewrittenUrl === null ? self::viewUrl($view, array($view . '_id' => $viewId, 'locale' => $viewLocale)) : $rewrittenUrl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`by_default`,`created_at`,
|
|||||||
INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES
|
INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES
|
||||||
('session_config.default', '1', 1, 1, NOW(), NOW()),
|
('session_config.default', '1', 1, 1, NOW(), NOW()),
|
||||||
('verifyStock', '1', 1, 0, NOW(), NOW()),
|
('verifyStock', '1', 1, 0, NOW(), NOW()),
|
||||||
|
('default_lang_without_translation', '1', 1, 0, NOW(), NOW()),
|
||||||
|
('rewriting_enable', '0', 1, 0, NOW(), NOW()),
|
||||||
('imagine_graphic_driver', 'gd', 1, 0, NOW(), NOW()),
|
('imagine_graphic_driver', 'gd', 1, 0, NOW(), NOW()),
|
||||||
('default_images_quality_percent', '75', 1, 0, NOW(), NOW()),
|
('default_images_quality_percent', '75', 1, 0, NOW(), NOW()),
|
||||||
('original_image_delivery_mode', 'symlink', 1, 0, NOW(), NOW()),
|
('original_image_delivery_mode', 'symlink', 1, 0, NOW(), NOW()),
|
||||||
|
|||||||
@@ -1095,24 +1095,19 @@
|
|||||||
</table>
|
</table>
|
||||||
<table name="rewriting_url" namespace="Thelia\Model">
|
<table name="rewriting_url" namespace="Thelia\Model">
|
||||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||||
<column name="url" required="true" size="255" type="VARCHAR" />
|
|
||||||
<column name="view" size="255" type="VARCHAR" />
|
<column name="view" size="255" type="VARCHAR" />
|
||||||
<column name="view_id" size="255" type="VARCHAR" />
|
<column name="view_id" size="255" type="VARCHAR" />
|
||||||
<column name="view_locale" size="255" type="VARCHAR" />
|
<column name="url" required="true" size="255" type="VARCHAR" />
|
||||||
<column name="redirected" type="INTEGER" />
|
|
||||||
<foreign-key foreignTable="rewriting_url" name="fk_rewriting_url_redirected" onDelete="RESTRICT" onUpdate="RESTRICT">
|
|
||||||
<reference foreign="id" local="redirected" />
|
|
||||||
</foreign-key>
|
|
||||||
<unique name="url_UNIQUE">
|
<unique name="url_UNIQUE">
|
||||||
<unique-column name="url" />
|
<unique-column name="url" />
|
||||||
</unique>
|
</unique>
|
||||||
<index name="idx_view_id">
|
<index name="idx_view_id">
|
||||||
<index-column name="view_id" />
|
<index-column name="view_id" />
|
||||||
</index>
|
</index>
|
||||||
<index name="idx_rewriting_url_redirected">
|
|
||||||
<index-column name="redirected" />
|
|
||||||
</index>
|
|
||||||
<behavior name="timestampable" />
|
<behavior name="timestampable" />
|
||||||
|
<behavior name="i18n">
|
||||||
|
<parameter name="i18n_columns" value="url" />
|
||||||
|
</behavior>
|
||||||
</table>
|
</table>
|
||||||
<table name="rewriting_argument" namespace="Thelia\Model">
|
<table name="rewriting_argument" namespace="Thelia\Model">
|
||||||
<column name="rewriting_url_id" primaryKey="true" required="true" type="INTEGER" />
|
<column name="rewriting_url_id" primaryKey="true" required="true" type="INTEGER" />
|
||||||
@@ -1126,4 +1121,16 @@
|
|||||||
</index>
|
</index>
|
||||||
<behavior name="timestampable" />
|
<behavior name="timestampable" />
|
||||||
</table>
|
</table>
|
||||||
|
<table name="rewriting_old_url" namespace="Thelia\Model">
|
||||||
|
<column name="rewriting_url_id" required="true" type="INTEGER" />
|
||||||
|
<column name="url" primaryKey="true" required="true" size="255" type="VARCHAR" />
|
||||||
|
<column name="locale" required="true" size="5" type="VARCHAR" />
|
||||||
|
<foreign-key foreignTable="rewriting_url" name="fk_rewriting_old_url_rewriting_url_id">
|
||||||
|
<reference foreign="id" local="rewriting_url_id" />
|
||||||
|
</foreign-key>
|
||||||
|
<index name="idx_rewriting_old_url_rewriting_url_id">
|
||||||
|
<index-column name="rewriting_url_id" />
|
||||||
|
</index>
|
||||||
|
<behavior name="timestampable" />
|
||||||
|
</table>
|
||||||
</database>
|
</database>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
{loop name="product" type="product" category="#ID"}
|
{loop name="product" type="product" category="#ID"}
|
||||||
<div style="border: dashed 2px red; padding: 20px; margin: 10px;">
|
<div style="border: dashed 2px red; padding: 20px; margin: 10px;">
|
||||||
<h3><a name="#REF">PRODUCT : #REF (#LOOP_COUNT / #LOOP_TOTAL)</a></h3>
|
<h3><a name="#REF" href="#URL">PRODUCT #ID : #REF (#LOOP_COUNT / #LOOP_TOTAL)</a></h3>
|
||||||
<h4>#TITLE</h4>
|
<h4>#TITLE</h4>
|
||||||
<p>#DESCRIPTION</p>
|
<p>#DESCRIPTION</p>
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
{loop name="product" type="product" category="#ID"}
|
{loop name="product" type="product" category="#ID"}
|
||||||
|
|
||||||
<div style="border: solid 1px green; padding: 20px; margin: 10px;">
|
<div style="border: solid 1px green; padding: 20px; margin: 10px;">
|
||||||
<h3><a name="#REF">PRODUCT : #REF (#LOOP_COUNT / #LOOP_TOTAL)</a></h3>
|
<h3><a name="#REF" href="#URL">PRODUCT #ID : #REF (#LOOP_COUNT / #LOOP_TOTAL)</a></h3>
|
||||||
<h4>#TITLE</h4>
|
<h4>#TITLE</h4>
|
||||||
<p>#DESCRIPTION</p>
|
<p>#DESCRIPTION</p>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user