Skip to content

Commit

Permalink
[-] BO : fixed translations on templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Damien Metzger committed Dec 26, 2012
1 parent e442785 commit d02d595
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions controllers/admin/AdminTranslationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ protected function checkDirAndCreate($dest)
$path = dirname($dest);

// If folder wasn't already added
if (!Tools::file_exists_cache($path))
// Do not use Tools::file_exists_cache because it changes over time!
if (!file_exists($path))
if (!mkdir($path, 0777, true))
{
$bool &= false;
Expand Down Expand Up @@ -328,14 +329,27 @@ protected function writeTranslationFile($override_file = false)

public function submitCopyLang()
{
if (!($from_lang = strval(Tools::getValue('fromLang'))) || !($to_lang = strval(Tools::getValue('toLang'))))
if (!($from_lang = Tools::getValue('fromLang')) || !($to_lang = Tools::getValue('toLang')))
$this->errors[] = $this->l('You must select 2 languages in order to copy data from one to another');
else if (!($from_theme = strval(Tools::getValue('fromTheme'))) || !($to_theme = strval(Tools::getValue('toTheme'))))
else if (!($from_theme = Tools::getValue('fromTheme')) || !($to_theme = Tools::getValue('toTheme')))
$this->errors[] = $this->l('You must select 2 themes in order to copy data from one to another');
else if (!Language::copyLanguageData(Language::getIdByIso($from_lang), Language::getIdByIso($to_lang)))
$this->errors[] = $this->l('An error occurred while copying data');
else if ($from_lang == $to_lang && $from_theme == $to_theme)
$this->errors[] = $this->l('Nothing to copy! (same language and theme)');
else
{
$theme_exists = array('from_theme' => false, 'to_theme' => false);
foreach ($this->themes as $theme)
{
if ($theme->directory == $from_theme)
$theme_exists['from_theme'] = true;
if ($theme->directory == $to_theme)
$theme_exists['to_theme'] = true;
}
if ($theme_exists['from_theme'] == false || $theme_exists['to_theme'] == false)
$this->errors[] = $this->l('Theme(s) not found');
}
if (count($this->errors))
return;

Expand Down Expand Up @@ -1080,7 +1094,16 @@ public function getInformations()

// Get folder name of theme
if (($theme = Tools::getValue('theme')) && !is_array($theme))
$this->theme_selected = Tools::safeOutput($theme);
{
$theme_exists = false;
foreach ($this->themes as $existing_theme)
if ($existing_theme->directory == $theme)
$theme_exists = true;
if ($theme_exists)
$this->theme_selected = Tools::safeOutput($theme);
else
throw new PrestaShopException(sprintf(Tools::displayError('Invalid theme "%s"'), $theme));
}
else
$this->theme_selected = self::DEFAULT_THEME_NAME;

Expand Down

0 comments on commit d02d595

Please sign in to comment.