// Another fix for installation with safe_mode

This commit is contained in:
Rémi Gaillard
2013-03-22 15:20:40 +01:00
parent 36d2e58a90
commit ecf433b9b8
3 changed files with 25 additions and 18 deletions
+6 -3
View File
@@ -190,11 +190,14 @@ class LanguageCore extends ObjectModel
return $themes; return $themes;
} }
public function add($autodate = true, $nullValues = false) public function add($autodate = true, $nullValues = false, $only_add = false)
{ {
if (!parent::add($autodate)) if (!parent::add($autodate))
return false; return false;
if ($only_add)
return true;
// create empty files if they not exists // create empty files if they not exists
$this->_generateFiles(); $this->_generateFiles();
@@ -681,7 +684,7 @@ class LanguageCore extends ObjectModel
return Tools::generateHtaccess(); return Tools::generateHtaccess();
} }
public static function checkAndAddLanguage($iso_code, $lang_pack = false) public static function checkAndAddLanguage($iso_code, $lang_pack = false, $only_add = false)
{ {
if (Language::getIdByIso($iso_code)) if (Language::getIdByIso($iso_code))
return true; return true;
@@ -703,7 +706,7 @@ class LanguageCore extends ObjectModel
else else
return false; return false;
if (!$lang->add()) if (!$lang->add(true, false, $only_add))
return false; return false;
$flag = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/flags/jpeg/'.$iso_code.'.jpg'); $flag = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/flags/jpeg/'.$iso_code.'.jpg');
+2 -1
View File
@@ -53,7 +53,8 @@ class TranslateCore
$iso = Context::getContext()->language->iso_code; $iso = Context::getContext()->language->iso_code;
if (empty($iso)) if (empty($iso))
$iso = Language::getIsoById((int)(Configuration::get('PS_LANG_DEFAULT'))); $iso = Language::getIsoById((int)(Configuration::get('PS_LANG_DEFAULT')));
include_once(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php'); if (file_exists(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php'))
include_once(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
} }
if (isset($modules_tabs[strtolower($class)])) if (isset($modules_tabs[strtolower($class)]))
+17 -14
View File
@@ -307,7 +307,11 @@ class InstallModelInstall extends InstallAbstractModel
if (!$xml = @simplexml_load_file(_PS_INSTALL_LANGS_PATH_.$iso.'/language.xml')) if (!$xml = @simplexml_load_file(_PS_INSTALL_LANGS_PATH_.$iso.'/language.xml'))
throw new PrestashopInstallerException($this->language->l('File "language.xml" not valid for language iso "%s"', $iso)); throw new PrestashopInstallerException($this->language->l('File "language.xml" not valid for language iso "%s"', $iso));
Language::downloadAndInstallLanguagePack($iso, _PS_INSTALL_VERSION_); if (InstallSession::getInstance()->safe_mode)
Language::checkAndAddLanguage($iso, false, true);
else
Language::downloadAndInstallLanguagePack($iso, _PS_INSTALL_VERSION_);
if (!$id_lang = Language::getIdByIso($iso)) if (!$id_lang = Language::getIdByIso($iso))
throw new PrestashopInstallerException($this->language->l('Cannot install language "%s"', ($xml->name) ? $xml->name : $iso)); throw new PrestashopInstallerException($this->language->l('Cannot install language "%s"', ($xml->name) ? $xml->name : $iso));
$languages[$id_lang] = $iso; $languages[$id_lang] = $iso;
@@ -601,20 +605,19 @@ class InstallModelInstall extends InstallAbstractModel
*/ */
public function installModules($module = null) public function installModules($module = null)
{ {
if (InstallSession::getInstance()->safe_mode)
return true;
$modules = $module ? array($module) : $this->getModulesList(); $modules = $module ? array($module) : $this->getModulesList();
$addons_modules = $this->getAddonsModulesList(); if (!InstallSession::getInstance()->safe_mode)
{
foreach($addons_modules as $addons_module) $addons_modules = $this->getAddonsModulesList();
if (file_put_contents(_PS_MODULE_DIR_.$addons_module['name'].'.zip', Tools::addonsRequest('module', array('id_module' => $addons_module['id_module']))))
if (Tools::ZipExtract(_PS_MODULE_DIR_.$addons_module['name'].'.zip', _PS_MODULE_DIR_)) foreach($addons_modules as $addons_module)
{ if (file_put_contents(_PS_MODULE_DIR_.$addons_module['name'].'.zip', Tools::addonsRequest('module', array('id_module' => $addons_module['id_module']))))
$modules[] = (string)$addons_module['name'];//if the module has been unziped we add the name in the modules list to install if (Tools::ZipExtract(_PS_MODULE_DIR_.$addons_module['name'].'.zip', _PS_MODULE_DIR_))
unlink(_PS_MODULE_DIR_.$addons_module['name'].'.zip'); {
} $modules[] = (string)$addons_module['name'];//if the module has been unziped we add the name in the modules list to install
unlink(_PS_MODULE_DIR_.$addons_module['name'].'.zip');
}
}
$errors = array(); $errors = array();
foreach ($modules as $module_name) foreach ($modules as $module_name)
{ {