diff --git a/classes/Language.php b/classes/Language.php index e90700112..ce3762ab2 100644 --- a/classes/Language.php +++ b/classes/Language.php @@ -691,6 +691,7 @@ class LanguageCore extends ObjectModel // Initialize the language $lang = new Language(); $lang->iso_code = $iso_code; + $lang->language_code = $iso_code; $lang->active = true; // If the language pack has not been provided, retrieve it from prestashop.com @@ -700,13 +701,15 @@ class LanguageCore extends ObjectModel // If a language pack has been found or provided, prefill the language object with the value if ($lang_pack) foreach (get_object_vars($lang_pack) as $key => $value) - $lang->$key = $value; + if ($key != 'iso_code' && isset(Language::$definition['fields'][$key])) + $lang->$key = $value; // Use the values given in parameters to override the data retrieved automatically if ($params_lang !== null && is_array($params_lang)) foreach ($params_lang as $key => $value) - $lang->$key = $value; - + if ($key != 'iso_code' && isset(Language::$definition['fields'][$key])) + $lang->$key = $value; + if (!$lang->add(true, false, $only_add)) return false; @@ -724,7 +727,7 @@ class LanguageCore extends ObjectModel } else Language::_copyNoneFlag((int)$lang->id); - + $files_copy = array( '/en.jpg', '/en-default-'.ImageType::getFormatedName('thickbox').'.jpg', @@ -734,7 +737,7 @@ class LanguageCore extends ObjectModel '/en-default-'.ImageType::getFormatedName('small').'.jpg', '/en-default-'.ImageType::getFormatedName('scene').'.jpg' ); - + foreach (array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_) as $to) foreach ($files_copy as $file) @copy(dirname(__FILE__).'/../img/l'.$file, $to.str_replace('/en', '/'.$iso_code, $file)); diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 0c8fe2920..102f63027 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -928,7 +928,7 @@ class AdminImportControllerCore extends AdminController $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $category_to_create->name[$default_language_id], - (isset($category_to_create->id) ? $category_to_create->id : 'null') + (isset($category_to_create->id) && !empty($category_to_create->id))? $category_to_create->id : 'null' ); $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); @@ -961,7 +961,7 @@ class AdminImportControllerCore extends AdminController $this->warnings[] = sprintf( Tools::displayError('Rewrite link for %1$s (ID: %2$s) was re-written as %3$s.'), $bak, - (isset($info['id']) ? $info['id'] : 'null'), + (isset($info['id']) && !empty($info['id']))? $info['id'] : 'null', $category->link_rewrite[$default_language_id] ); $res = false; @@ -1009,8 +1009,8 @@ class AdminImportControllerCore extends AdminController { $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), - (isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'), - (isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID') + (isset($info['name']) && !empty($info['name']))? Tools::safeOutput($info['name']) : 'No Name', + (isset($info['id']) && !empty($info['id']))? Tools::safeOutput($info['id']) : 'No ID' ); $error_tmp = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').Db::getInstance()->getMsgError(); if ($error_tmp != '') @@ -1138,7 +1138,7 @@ class AdminImportControllerCore extends AdminController $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $manufacturer->name, - (isset($manufacturer->id) ? $manufacturer->id : 'null') + (isset($manufacturer->id) && !empty($manufacturer->id))? $manufacturer->id : 'null' ); $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); @@ -1169,7 +1169,7 @@ class AdminImportControllerCore extends AdminController $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $supplier->name, - (isset($supplier->id) ? $supplier->id : 'null') + (isset($supplier->id) && !empty($supplier->id))? $supplier->id : 'null' ); $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); @@ -1215,7 +1215,7 @@ class AdminImportControllerCore extends AdminController $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $category_to_create->name[$default_language_id], - (isset($category_to_create->id) ? $category_to_create->id : 'null') + (isset($category_to_create->id) && !empty($category_to_create->id))? $category_to_create->id : 'null' ); $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); @@ -1247,7 +1247,7 @@ class AdminImportControllerCore extends AdminController $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $category_to_create->name[$default_language_id], - (isset($category_to_create->id) ? $category_to_create->id : 'null') + (isset($category_to_create->id) && !empty($category_to_create->id))? $category_to_create->id : 'null' ); $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); @@ -1274,11 +1274,11 @@ class AdminImportControllerCore extends AdminController $this->warnings[] = sprintf( Tools::displayError('Rewrite link for %1$s (ID: %2$s) was re-written as %3$s.'), $product->name[$id_lang], - (isset($info['id']) ? $info['id'] : 'null'), + (isset($info['id']) && !empty($info['id']))? $info['id'] : 'null', $link_rewrite ); - if (!Tools::getValue('match_ref') || !(is_array($product->link_rewrite) && count($product->link_rewrite))) + if (!Tools::getValue('match_ref') || !(is_array($product->link_rewrite) && count($product->link_rewrite) && !empty($product->link_rewrite[$id_lang]))) $product->link_rewrite = AdminImportController::createMultiLangField($link_rewrite); // replace the value of separator by coma @@ -1357,8 +1357,8 @@ class AdminImportControllerCore extends AdminController { $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), - (isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'), - (isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID') + (isset($info['name']) && !empty($info['name']))? Tools::safeOutput($info['name']) : 'No Name', + (isset($info['id']) && !empty($info['id']))? Tools::safeOutput($info['id']) : 'No ID' ); $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); @@ -1964,7 +1964,7 @@ class AdminImportControllerCore extends AdminController $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $info['email'], - (isset($info['id']) ? $info['id'] : 'null') + (isset($info['id']) && !empty($info['id']))? $info['id'] : 'null' ); $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); @@ -2061,7 +2061,7 @@ class AdminImportControllerCore extends AdminController Tools::displayError('%1$s does not exist in database %2$s (ID: %3$s) cannot be saved'), Db::getInstance()->getMsgError(), $address->customer_email, - (isset($info['id']) ? $info['id'] : 'null') + (isset($info['id']) && !empty($info['id']))? $info['id'] : 'null' ); } else @@ -2110,7 +2110,7 @@ class AdminImportControllerCore extends AdminController $this->errors[] = Db::getInstance()->getMsgError().' '.sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $manufacturer->name, - (isset($manufacturer->id) ? $manufacturer->id : 'null') + (isset($manufacturer->id) && !empty($manufacturer->id))? $manufacturer->id : 'null' ); $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); @@ -2131,7 +2131,7 @@ class AdminImportControllerCore extends AdminController $this->errors[] = Db::getInstance()->getMsgError().' '.sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $supplier->name, - (isset($supplier->id) ? $supplier->id : 'null') + (isset($supplier->id) && !empty($supplier->id))? $supplier->id : 'null' ); $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); @@ -2160,7 +2160,7 @@ class AdminImportControllerCore extends AdminController $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $info['alias'], - (isset($info['id']) ? $info['id'] : 'null') + (isset($info['id']) && !empty($info['id']))? $info['id'] : 'null' ); } } @@ -2177,7 +2177,7 @@ class AdminImportControllerCore extends AdminController $this->errors[] = sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $info['alias'], - (isset($info['id']) ? $info['id'] : 'null') + (isset($info['id']) && !empty($info['id']))? $info['id'] : 'null' ); $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); @@ -2247,8 +2247,8 @@ class AdminImportControllerCore extends AdminController { $this->errors[] = Db::getInstance()->getMsgError().' '.sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), - (isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'), - (isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID') + (isset($info['name']) && !empty($info['name']))? Tools::safeOutput($info['name']) : 'No Name', + (isset($info['id']) && !empty($info['id']))? Tools::safeOutput($info['id']) : 'No ID' ); $this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''). Db::getInstance()->getMsgError(); @@ -2294,8 +2294,8 @@ class AdminImportControllerCore extends AdminController if (!$res) $this->errors[] = Db::getInstance()->getMsgError().' '.sprintf( Tools::displayError('%1$s (ID: %2$s) cannot be saved'), - (isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'), - (isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID') + (isset($info['name']) && !empty($info['name']))? Tools::safeOutput($info['name']) : 'No Name', + (isset($info['id']) && !empty($info['id']))? Tools::safeOutput($info['id']) : 'No ID' ); else { diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 03764fe67..cbc235f59 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -2023,7 +2023,7 @@ class AdminProductsControllerCore extends AdminController // Check multilingual fields validity foreach ($rules['validateLang'] as $fieldLang => $function) foreach ($languages as $language) - if ($this->isProductFieldUpdated('description_short', $language['id_lang']) && ($value = Tools::getValue($fieldLang.'_'.$language['id_lang']))) + if ($this->isProductFieldUpdated($fieldLang, $language['id_lang']) && ($value = Tools::getValue($fieldLang.'_'.$language['id_lang']))) if (!Validate::$function($value, (int)Configuration::get('PS_ALLOW_HTML_IFRAME'))) $this->errors[] = sprintf( Tools::displayError('The %1$s field (%2$s) is invalid.'), diff --git a/modules/productcomments/productcomments.tpl b/modules/productcomments/productcomments.tpl index f8fe9f111..0c5c3aecb 100644 --- a/modules/productcomments/productcomments.tpl +++ b/modules/productcomments/productcomments.tpl @@ -76,11 +76,13 @@ var moderation_active = {$moderation_active}; {/if} {/foreach} + {if (!$too_early AND ($logged OR $allow_guests))}

{l s='Write your review' mod='productcomments'} !

+ {/if} {else} - {if ($too_early == false AND ($logged OR $allow_guests))} + {if (!$too_early AND ($logged OR $allow_guests))}

{l s='Be the first to write your review' mod='productcomments'} !

diff --git a/themes/default/modules/productcomments/productcomments.tpl b/themes/default/modules/productcomments/productcomments.tpl index 3cb407777..bbd737670 100644 --- a/themes/default/modules/productcomments/productcomments.tpl +++ b/themes/default/modules/productcomments/productcomments.tpl @@ -76,11 +76,13 @@ var moderation_active = {$moderation_active}; {/if} {/foreach} + {if (!$too_early AND ($logged OR $allow_guests))}

{l s='Write your review' mod='productcomments'} !

+ {/if} {else} - {if ($too_early == false AND ($logged OR $allow_guests))} + {if (!$too_early AND ($logged OR $allow_guests))}

{l s='Be the first to write your review' mod='productcomments'} !

@@ -141,7 +143,7 @@ var moderation_active = {$moderation_active}; {/if}