Conflicts:
	templates/default/login.html
This commit is contained in:
franck
2013-08-30 19:48:26 +02:00
29 changed files with 532 additions and 175 deletions

View File

@@ -4,6 +4,7 @@ namespace Thelia\Model;
use Thelia\Model\Base\Category as BaseCategory;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Tools\URL;
class Category extends BaseCategory
{
@@ -15,8 +16,9 @@ class Category extends BaseCategory
return CategoryQuery::countChild($this->getId());
}
public function getUrl()
public function getUrl($locale)
{
return URL::retrieve('category', $this->getId(), $locale);
}
/**
@@ -74,4 +76,4 @@ class Category extends BaseCategory
return $countProduct;
}
}
}

View File

@@ -22,4 +22,14 @@ class ConfigQuery extends BaseConfigQuery {
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

View File

@@ -3,11 +3,12 @@
namespace Thelia\Model;
use Thelia\Model\Base\Content as BaseContent;
use Thelia\Tools\URL;
class Content extends BaseContent
{
public function getUrl()
public function getUrl($locale)
{
return URL::retrieve('content', $this->getId(), $locale);
}
}

View File

@@ -3,6 +3,7 @@
namespace Thelia\Model;
use Thelia\Model\Base\Folder as BaseFolder;
use Thelia\Tools\URL;
class Folder extends BaseFolder
{
@@ -14,9 +15,9 @@ class Folder extends BaseFolder
return FolderQuery::countChild($this->getId());
}
public function getUrl()
public function getUrl($locale)
{
return URL::retrieve('folder', $this->getId(), $locale);
}
/**

View File

@@ -162,9 +162,9 @@ class RewritingUrlTableMap extends TableMap
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('URL', 'Url', 'VARCHAR', true, 255, null);
$this->addColumn('VIEW', 'View', 'VARCHAR', false, 255, null);
$this->addColumn('VIEW', 'View', 'VARCHAR', true, 255, null);
$this->addColumn('VIEW_ID', 'ViewId', 'VARCHAR', false, 255, null);
$this->addColumn('VIEW_LOCALE', 'ViewLocale', 'VARCHAR', false, 255, null);
$this->addColumn('VIEW_LOCALE', 'ViewLocale', 'VARCHAR', true, 255, null);
$this->addForeignKey('REDIRECTED', 'Redirected', 'INTEGER', 'rewriting_url', 'ID', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);

View File

@@ -3,12 +3,12 @@
namespace Thelia\Model;
use Thelia\Model\Base\Product as BaseProduct;
use Thelia\Model\ProductSaleElements;
use Thelia\Tools\URL;
class Product extends BaseProduct
{
public function getUrl()
public function getUrl($locale)
{
return URL::retrieve('product', $this->getId(), $locale);
}
}

View File

@@ -24,7 +24,7 @@ class ModelCriteriaTools
* @param null $foreignTable
* @param string $foreignKey
*/
public static function getFrontEndI18n(ModelCriteria &$search, $requestedLocale, $columns, $foreignTable, $foreignKey)
public static function getFrontEndI18n(ModelCriteria &$search, $requestedLocale, $columns, $foreignTable, $foreignKey, $forceReturn = false)
{
if($foreignTable === null) {
$foreignTable = $search->getTableMap()->getName();
@@ -33,16 +33,16 @@ class ModelCriteriaTools
$aliasPrefix = $foreignTable . '_';
}
$defaultLangWithoutTranslation = ConfigQuery::read("default_lang_without_translation", 1);
$defaultLangWithoutTranslation = ConfigQuery::getDefaultLangWhenNoTranslationAvailable();
$requestedLocaleI18nAlias = 'requested_locale_i18n';
$defaultLocaleI18nAlias = 'default_locale_i18n';
if (!$defaultLangWithoutTranslation == 0) {
$requestedLocaleI18nAlias = $aliasPrefix . 'requested_locale_i18n';
$defaultLocaleI18nAlias = $aliasPrefix . 'default_locale_i18n';
if($defaultLangWithoutTranslation == 0) {
$requestedLocaleJoin = new Join();
$requestedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $requestedLocaleI18nAlias);
$requestedLocaleJoin->setJoinType(Criteria::INNER_JOIN);
$requestedLocaleJoin->setJoinType($forceReturn === false ? Criteria::INNER_JOIN : Criteria::LEFT_JOIN);
$search->addJoinObject($requestedLocaleJoin, $requestedLocaleI18nAlias)
->addJoinCondition($requestedLocaleI18nAlias ,'`' . $requestedLocaleI18nAlias . '`.LOCALE = ?', $requestedLocale, null, \PDO::PARAM_STR);
@@ -71,7 +71,9 @@ class ModelCriteriaTools
$search->withColumn('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED');
$search->where('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.ID)')->_or()->where('NOT ISNULL(`' . $defaultLocaleI18nAlias . '`.ID)');
if($forceReturn === false) {
$search->where('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.ID)')->_or()->where('NOT ISNULL(`' . $defaultLocaleI18nAlias . '`.ID)');
}
foreach($columns as $column) {
$search->withColumn('CASE WHEN NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.ID) THEN `' . $requestedLocaleI18nAlias . '`.`' . $column . '` ELSE `' . $defaultLocaleI18nAlias . '`.`' . $column . '` END', $aliasPrefix . 'i18n_' . $column);
@@ -79,7 +81,7 @@ class ModelCriteriaTools
}
}
public static function getBackEndI18n(ModelCriteria &$search, $requestedLocale, $columns, $foreignTable, $foreignKey)
public static function getBackEndI18n(ModelCriteria &$search, $requestedLocale, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID')
{
if($foreignTable === null) {
$foreignTable = $search->getTableMap()->getName();
@@ -104,7 +106,7 @@ class ModelCriteriaTools
}
}
public static function getI18n($backendContext, $requestedLangId, ModelCriteria &$search, $currentLocale, $columns, $foreignTable, $foreignKey)
public static function getI18n($backendContext, $requestedLangId, ModelCriteria &$search, $currentLocale, $columns, $foreignTable, $foreignKey, $forceReturn = false)
{
// If a lang has been requested, find the related Lang object, and get the locale
if ($requestedLangId !== null) {
@@ -125,7 +127,9 @@ class ModelCriteriaTools
if ($backendContext) {
self::getBackEndI18n($search, $locale, $columns, $foreignTable, $foreignKey);
} else {
self::getFrontEndI18n($search, $locale, $columns, $foreignTable, $foreignKey);
self::getFrontEndI18n($search, $locale, $columns, $foreignTable, $foreignKey, $forceReturn);
}
return $locale;
}
}