From c698ae5210a801df44649ecffe8a0eb35e8c708f Mon Sep 17 00:00:00 2001 From: mMarinetti Date: Fri, 30 Dec 2011 16:07:44 +0000 Subject: [PATCH] // Language class 1.5 git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11958 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/Language.php | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/classes/Language.php b/classes/Language.php index e26d8d760..8bb09a593 100644 --- a/classes/Language.php +++ b/classes/Language.php @@ -144,33 +144,39 @@ class LanguageCore extends ObjectModel rename(_PS_MODULE_DIR_.$moduleDir.'/'.$this->iso_code.'.php', _PS_MODULE_DIR_.$moduleDir.'/'.$newIso.'.php'); } - foreach ($this->_getThemesList() as $theme => $data) + foreach (Theme::getThemes() as $theme) { - if (file_exists(_PS_ALL_THEMES_DIR_.$theme.'/lang/'.$this->iso_code.'.php')) - rename(_PS_ALL_THEMES_DIR_.$theme.'/lang/'.$this->iso_code.'.php', _PS_ALL_THEMES_DIR_.$theme.'/lang/'.$newIso.'.php'); + $theme_dir = $theme->directory; + if (file_exists(_PS_ALL_THEMES_DIR_.$theme_dir.'/lang/'.$this->iso_code.'.php')) + rename(_PS_ALL_THEMES_DIR_.$theme_dir.'/lang/'.$this->iso_code.'.php', _PS_ALL_THEMES_DIR_.$theme_dir.'/lang/'.$newIso.'.php'); - if (file_exists(_PS_ALL_THEMES_DIR_.$theme.'/mails/'.$this->iso_code)) - rename(_PS_ALL_THEMES_DIR_.$theme.'/mails/'.$this->iso_code, _PS_ALL_THEMES_DIR_.$theme.'/mails/'.$newIso); + if (file_exists(_PS_ALL_THEMES_DIR_.$theme_dir.'/mails/'.$this->iso_code)) + rename(_PS_ALL_THEMES_DIR_.$theme_dir.'/mails/'.$this->iso_code, _PS_ALL_THEMES_DIR_.$theme_dir.'/mails/'.$newIso); foreach ($modulesList as $module) - if (file_exists(_PS_ALL_THEMES_DIR_.$theme.'/modules/'.$module.'/'.$this->iso_code.'.php')) - rename(_PS_ALL_THEMES_DIR_.$theme.'/modules/'.$module.'/'.$this->iso_code.'.php', _PS_ALL_THEMES_DIR_.$theme.'/modules/'.$module.'/'.$newIso.'.php'); - } + if (file_exists(_PS_ALL_THEMES_DIR_.$theme_dir.'/modules/'.$module.'/'.$this->iso_code.'.php')) + rename(_PS_ALL_THEMES_DIR_.$theme_dir.'/modules/'.$module.'/'.$this->iso_code.'.php', _PS_ALL_THEMES_DIR_.$theme_dir.'/modules/'.$module.'/'.$newIso.'.php'); + } } /** - * Return an array with themes and thumbnails + * Return an array of theme * - * @return array + * @return array([theme dir] => array('name' => [theme name])) + * @deprecated will be removed in 1.6 */ private function _getThemesList() { - $dir = opendir(_PS_ALL_THEMES_DIR_); - while ($folder = readdir($dir)) - if ($folder != '.' AND $folder != '..' AND file_exists(_PS_ALL_THEMES_DIR_.'/'.$folder.'/preview.jpg')) - $themes[$folder]['name'] = $folder; - closedir($dir); - return isset($themes) ? $themes : array(); + Tools::displayAsDeprecated(); + static $themes = array(); + + if (empty($themes)) + { + $installed_themes = Theme::getThemes(); + foreach($installed_themes as $theme) + $themes[$theme->directory] = array('name' => $theme->name); + } + return $themes; } public function add($autodate = true, $nullValues = false)