[-] BO : Fix error returned when first import of a localisation pack
This commit is contained in:
@@ -24,9 +24,9 @@
|
||||
*}
|
||||
|
||||
<div class="width4">
|
||||
{$localization_form}
|
||||
{if isset($localization_form)}{$localization_form}{/if}
|
||||
</div>
|
||||
<br />
|
||||
<div class="width4">
|
||||
{$localization_options}
|
||||
{if isset($localization_options)}{$localization_options}{/if}
|
||||
</div>
|
||||
+17
-4
@@ -111,18 +111,22 @@ class LanguageCore extends ObjectModel
|
||||
$iso_code = $newIso ? $newIso : $this->iso_code;
|
||||
|
||||
if (!file_exists(_PS_TRANSLATIONS_DIR_.$iso_code))
|
||||
mkdir(_PS_TRANSLATIONS_DIR_.$iso_code);
|
||||
{
|
||||
if (@mkdir(_PS_TRANSLATIONS_DIR_.$iso_code))
|
||||
@chmod(_PS_TRANSLATIONS_DIR_.$iso_code, 0777);
|
||||
}
|
||||
|
||||
foreach ($this->translationsFilesAndVars as $file => $var)
|
||||
{
|
||||
$path_file = _PS_TRANSLATIONS_DIR_.$iso_code.'/'.$file.'.php';
|
||||
if (!file_exists($path_file))
|
||||
if ($file != 'tabs')
|
||||
file_put_contents($path_file, '<?php
|
||||
@file_put_contents($path_file, '<?php
|
||||
global $'.$var.';
|
||||
$'.$var.' = array();
|
||||
?>');
|
||||
else
|
||||
file_put_contents($path_file, '<?php
|
||||
@file_put_contents($path_file, '<?php
|
||||
$'.$var.' = array();
|
||||
return $'.$var.';
|
||||
?>');
|
||||
@@ -784,13 +788,22 @@ class LanguageCore extends ObjectModel
|
||||
$lang_pack_ok = false;
|
||||
$errors = array();
|
||||
$file = _PS_TRANSLATIONS_DIR_.$iso.'.gzip';
|
||||
|
||||
if (!$lang_pack_link = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.$version.'&iso_lang='.Tools::strtolower($iso)))
|
||||
$errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.');
|
||||
elseif (!$lang_pack = Tools::jsonDecode($lang_pack_link))
|
||||
$errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.');
|
||||
elseif ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/'.$lang_pack->version.'/'.Tools::strtolower($lang_pack->iso_code.'.gzip')))
|
||||
if (!@file_put_contents($file, $content))
|
||||
$errors[] = Tools::displayError('Server does not have permissions for writing.');
|
||||
{
|
||||
if (is_writable(dirname($file)))
|
||||
{
|
||||
@unlink($file);
|
||||
@file_put_contents($file, $content);
|
||||
}
|
||||
elseif (!is_writable($file))
|
||||
$errors[] = Tools::displayError('Server does not have permissions for writing.').' ('.$file.')';
|
||||
}
|
||||
if (file_exists($file))
|
||||
{
|
||||
$gz = new Archive_Tar($file, true);
|
||||
|
||||
@@ -726,6 +726,8 @@ class AdminControllerCore extends Controller
|
||||
*/
|
||||
public function processAdd()
|
||||
{
|
||||
if (!isset($this->className) || empty($this->className))
|
||||
return false;
|
||||
/* Checking fields validity */
|
||||
$this->validateRules();
|
||||
if (count($this->errors) <= 0)
|
||||
@@ -1142,6 +1144,8 @@ class AdminControllerCore extends Controller
|
||||
*/
|
||||
protected function loadObject($opt = false)
|
||||
{
|
||||
if (!isset($this->className) || empty($this->className))
|
||||
return true;
|
||||
$id = (int)Tools::getValue($this->identifier);
|
||||
if ($id && Validate::isUnsignedId($id))
|
||||
{
|
||||
@@ -2400,7 +2404,7 @@ class AdminControllerCore extends Controller
|
||||
public function getFieldValue($obj, $key, $id_lang = null)
|
||||
{
|
||||
if ($id_lang)
|
||||
$default_value = ($obj->id && isset($obj->{$key}[$id_lang])) ? $obj->{$key}[$id_lang] : false;
|
||||
$default_value = (isset($obj->id) && $obj->id && isset($obj->{$key}[$id_lang])) ? $obj->{$key}[$id_lang] : false;
|
||||
else
|
||||
$default_value = isset($obj->{$key}) ? $obj->{$key} : false;
|
||||
|
||||
|
||||
@@ -28,9 +28,6 @@ class AdminLocalizationControllerCore extends AdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->fields_options = array(
|
||||
|
||||
@@ -581,7 +581,9 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
if (preg_match('#^translations\/'.$iso_code.'\/tabs.php#Ui', $file['filename'], $matches) && Validate::isLanguageIsoCode($iso_code))
|
||||
{
|
||||
// Include array width new translations tabs
|
||||
$tabs = include _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$file['filename'];
|
||||
$tabs = array();
|
||||
if (Tools::file_exists_cache(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$file['filename']))
|
||||
$tabs = include_once(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$file['filename']);
|
||||
|
||||
foreach ($tabs as $class_name => $translations)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user