Merge branch 'master' of https://github.com/thelia/thelia
Conflicts: templates/default/login.html
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user