public function renderDefault(array $param = array(), $status = 200) { $data = array(); foreach (LangQuery::create()->find() as $lang) { $data[LangUrlForm::LANG_PREFIX . $lang->getId()] = $lang->getUrl(); } $langUrlForm = $this->createForm(AdminForm::LANG_URL, 'form', $data); $this->getParserContext()->addForm($langUrlForm); return $this->render('languages', array_merge($param, array('lang_without_translation' => ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), 'one_domain_per_lang' => ConfigQuery::isMultiDomainActivated())), $status); }
public function renderDefault(array $param = array()) { $data = array(); foreach (LangQuery::create()->find() as $lang) { $data[LangUrlForm::LANG_PREFIX . $lang->getId()] = $lang->getUrl(); } $langUrlForm = new LangUrlForm($this->getRequest(), 'form', $data); $this->getParserContext()->addForm($langUrlForm); return $this->render('languages', array_merge($param, array('lang_without_translation' => ConfigQuery::getDefaultLangWhenNoTranslationAvailable(), 'one_domain_per_lang' => ConfigQuery::read("one_domain_foreach_lang", false)))); }
public function getProduct(ConnectionInterface $con = null, $locale = null) { $product = parent::getProduct($con); $translation = $product->getTranslation($locale); if ($translation->isNew()) { if (ConfigQuery::getDefaultLangWhenNoTranslationAvailable()) { $locale = Lang::getDefaultLanguage()->getLocale(); } } $product->setLocale($locale); return $product; }
/** * @param ModelCriteria $search * @param $requestedLocale * @param array $columns * @param null $foreignTable * @param string $foreignKey * @param bool $forceReturn * @param string $forceReturn */ public static function getFrontEndI18n(ModelCriteria &$search, $requestedLocale, $columns, $foreignTable, $foreignKey, $forceReturn = false, $localeAlias = null) { if (!empty($columns)) { if ($foreignTable === null) { $foreignTable = $search->getTableMap()->getName(); $aliasPrefix = ''; } else { $aliasPrefix = $foreignTable . '_'; } if ($localeAlias === null) { $localeAlias = $search->getTableMap()->getName(); } $defaultLangWithoutTranslation = ConfigQuery::getDefaultLangWhenNoTranslationAvailable(); $requestedLocaleI18nAlias = $aliasPrefix . 'requested_locale_i18n'; $defaultLocaleI18nAlias = $aliasPrefix . 'default_locale_i18n'; if ($defaultLangWithoutTranslation == Lang::STRICTLY_USE_REQUESTED_LANGUAGE) { $requestedLocaleJoin = new Join(); $requestedLocaleJoin->addExplicitCondition($localeAlias, $foreignKey, null, $foreignTable . '_i18n', 'ID', $requestedLocaleI18nAlias); $requestedLocaleJoin->setJoinType($forceReturn === false ? Criteria::INNER_JOIN : Criteria::LEFT_JOIN); $defaultLocaleJoin = new Join(); $defaultLocaleJoin->addExplicitCondition($localeAlias, $foreignKey, null, $foreignTable . '_i18n', 'ID', $defaultLocaleI18nAlias); $search->addJoinObject($requestedLocaleJoin, $requestedLocaleI18nAlias)->addJoinCondition($requestedLocaleI18nAlias, '`' . $requestedLocaleI18nAlias . '`.LOCALE = ?', $requestedLocale, null, \PDO::PARAM_STR); $search->addJoinObject($defaultLocaleJoin, $defaultLocaleI18nAlias)->addJoinCondition($defaultLocaleI18nAlias, '`' . $defaultLocaleI18nAlias . '`.LOCALE <> ?', $requestedLocale, null, \PDO::PARAM_STR); $search->withColumn('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED'); foreach ($columns as $column) { $search->withColumn('`' . $requestedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column); } } else { $defaultLocale = Lang::getDefaultLanguage()->getLocale(); $defaultLocaleJoin = new Join(); $defaultLocaleJoin->addExplicitCondition($localeAlias, $foreignKey, null, $foreignTable . '_i18n', 'ID', $defaultLocaleI18nAlias); $defaultLocaleJoin->setJoinType(Criteria::LEFT_JOIN); $search->addJoinObject($defaultLocaleJoin, $defaultLocaleI18nAlias)->addJoinCondition($defaultLocaleI18nAlias, '`' . $defaultLocaleI18nAlias . '`.LOCALE = ?', $defaultLocale, null, \PDO::PARAM_STR); $requestedLocaleJoin = new Join(); $requestedLocaleJoin->addExplicitCondition($localeAlias, $foreignKey, null, $foreignTable . '_i18n', 'ID', $requestedLocaleI18nAlias); $requestedLocaleJoin->setJoinType(Criteria::LEFT_JOIN); $search->addJoinObject($requestedLocaleJoin, $requestedLocaleI18nAlias)->addJoinCondition($requestedLocaleI18nAlias, '`' . $requestedLocaleI18nAlias . '`.LOCALE = ?', $requestedLocale, null, \PDO::PARAM_STR); $search->withColumn('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED'); 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); } } } }