diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index 572c338fe..74d3a5b85 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -446,11 +446,11 @@
{include - file="controllers/products/textarea_lang.tpl" + file="controllers/normal_products/textarea_lang.tpl" languages=$languages input_name='description_short' input_value=$product->description_short - max=$PS_SHORT_DESC_LIMIT} + maxlength=$PS_SHORT_DESC_LIMIT}
{*
diff --git a/classes/Configuration.php b/classes/Configuration.php index 8b3392b25..85d5f0828 100644 --- a/classes/Configuration.php +++ b/classes/Configuration.php @@ -43,6 +43,8 @@ class ConfigurationCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; + const PS_SHORT_DESC_LIMIT = 400; + /** * @see ObjectModel::$definition */ diff --git a/classes/Product.php b/classes/Product.php index 2d8a1370d..b323c5226 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -947,12 +947,10 @@ class ProductCore extends ObjectModel if ($field == 'description_short') { $limit = (int)Configuration::get('PS_SHORT_DESC_LIMIT'); if ($limit <= 0) { - $limit = 800; + $limit = Configuration::PS_SHORT_DESC_LIMIT; } - $size_without_html = Tools::strlen(strip_tags($value)); - $size_with_html = Tools::strlen($value); - $this->def['fields']['description_short']['size'] = $limit + $size_with_html - $size_without_html; + $this->def['fields']['description_short']['size'] = $limit; } return parent::validateField($field, $value, $id_lang, $skip, $human_errors); } diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 6cba4767f..66dc1c963 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -657,7 +657,7 @@ class AdminNormalProductsControllerCore extends AdminController } $limit = (int)Configuration::get('PS_SHORT_DESC_LIMIT'); if ($limit <= 0) { - $limit = 400; + $limit = Configuration::PS_SHORT_DESC_LIMIT; } $className = 'Product'; foreach (Language::getLanguages(true) as $language) { @@ -2180,7 +2180,7 @@ class AdminNormalProductsControllerCore extends AdminController // Check description short size without html $limit = (int)Configuration::get('PS_SHORT_DESC_LIMIT'); if ($limit <= 0) { - $limit = 400; + $limit = Configuration::PS_SHORT_DESC_LIMIT; } foreach ($languages as $language) { if ($this->isProductFieldUpdated('description_short', $language['id_lang']) && ($value = Tools::getValue('description_short_'.$language['id_lang']))) { @@ -3545,7 +3545,7 @@ class AdminNormalProductsControllerCore extends AdminController 'token' => $this->token, 'currency' => $currency, 'link' => $this->context->link, - 'PS_SHORT_DESC_LIMIT' => Configuration::get('PS_SHORT_DESC_LIMIT') ? Configuration::get('PS_SHORT_DESC_LIMIT') : 400 + 'PS_SHORT_DESC_LIMIT' => Configuration::get('PS_SHORT_DESC_LIMIT') ? Configuration::get('PS_SHORT_DESC_LIMIT') : Configuration::PS_SHORT_DESC_LIMIT )); $data->assign($this->tpl_form_vars); diff --git a/controllers/admin/AdminPreferencesController.php b/controllers/admin/AdminPreferencesController.php index d6110e269..a97ec7b54 100644 --- a/controllers/admin/AdminPreferencesController.php +++ b/controllers/admin/AdminPreferencesController.php @@ -193,7 +193,7 @@ class AdminPreferencesControllerCore extends AdminController 'type' => 'text', 'suffix' => $this->l('characters'), 'class' => 'fixed-width-xl', - 'desc' => $this->l('If set to 0, the maximum limit will be 400 characters.') + 'desc' => sprintf($this->l('If set to 0, the maximum limit will be %d characters.'), Configuration::PS_SHORT_DESC_LIMIT) ), // 'PS_DISPLAY_SUPPLIERS' => array( // 'title' => $this->l('Display suppliers and manufacturers'), diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 43a3ed50a..c3eda7cbe 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -815,7 +815,7 @@ class AdminProductsControllerCore extends AdminController $room_type_info = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($id_product_old); $limit = (int)Configuration::get('PS_SHORT_DESC_LIMIT'); if ($limit <= 0) { - $limit = 400; + $limit = Configuration::PS_SHORT_DESC_LIMIT; } $className = 'Product'; if ($room_type_info && $room_type_info['id_hotel'] == $id_hotel_new) { @@ -2190,7 +2190,7 @@ class AdminProductsControllerCore extends AdminController // Check description short size without html $limit = (int)Configuration::get('PS_SHORT_DESC_LIMIT'); if ($limit <= 0) { - $limit = 400; + $limit = Configuration::PS_SHORT_DESC_LIMIT; } foreach ($languages as $language) { if ($this->isProductFieldUpdated('description_short', $language['id_lang']) && ($value = Tools::getValue('description_short_'.$language['id_lang']))) { @@ -4387,7 +4387,7 @@ class AdminProductsControllerCore extends AdminController 'token' => $this->token, 'currency' => $currency, 'link' => $this->context->link, - 'PS_SHORT_DESC_LIMIT' => Configuration::get('PS_SHORT_DESC_LIMIT') ? Configuration::get('PS_SHORT_DESC_LIMIT') : 400, + 'PS_SHORT_DESC_LIMIT' => Configuration::get('PS_SHORT_DESC_LIMIT') ? Configuration::get('PS_SHORT_DESC_LIMIT') : Configuration::PS_SHORT_DESC_LIMIT, 'category_position' => Tools::getValue('category_position', $product->getPositionInCategory()), )); $data->assign($this->tpl_form_vars); diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php index 17d388b7f..172ed2e61 100644 --- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php +++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php @@ -1194,12 +1194,10 @@ class HotelBranchInformation extends ObjectModel if ($field == 'short_description') { $limit = (int)Configuration::get('PS_SHORT_DESC_LIMIT'); if ($limit <= 0) { - $limit = 400; + $limit = Configuration::PS_SHORT_DESC_LIMIT; } - $size_without_html = Tools::strlen(strip_tags($value)); - $size_with_html = Tools::strlen($value); - $this->def['fields']['short_description']['size'] = $limit + $size_with_html - $size_without_html; + $this->def['fields']['short_description']['size'] = $limit; } return parent::validateField($field, $value, $id_lang, $skip, $human_errors); diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index 0065efa52..402635d74 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -124,6 +124,9 @@ class AdminAddHotelController extends ModuleAdminController $smartyVars['defaultCurrency'] = Configuration::get('PS_CURRENCY_DEFAULT'); $smartyVars['PS_SHORT_DESC_LIMIT'] = Configuration::get('PS_SHORT_DESC_LIMIT'); + if (!$smartyVars['PS_SHORT_DESC_LIMIT']) { + $smartyVars['PS_SHORT_DESC_LIMIT'] = Configuration::PS_SHORT_DESC_LIMIT; + } $countries = Country::getCountries($this->context->language->id, true); $smartyVars['country_var'] = $countries; @@ -265,7 +268,7 @@ class AdminAddHotelController extends ModuleAdminController $map_formated_address = Tools::getValue('locformatedAddr'); $map_input_text = Tools::getValue('googleInputField'); $hotelFeatures = Tools::getValue('id_features', array()); - $shortDescriptionMaxChar = Configuration::get('PS_SHORT_DESC_LIMIT') ? Configuration::get('PS_SHORT_DESC_LIMIT') : 400; + $shortDescriptionMaxChar = Configuration::get('PS_SHORT_DESC_LIMIT') ? Configuration::get('PS_SHORT_DESC_LIMIT') : Configuration::PS_SHORT_DESC_LIMIT; // check if field is atleast in default language. Not available in default prestashop $defaultLangId = Configuration::get('PS_LANG_DEFAULT'); @@ -282,51 +285,53 @@ class AdminAddHotelController extends ModuleAdminController $this->errors[] = $this->l('Invalid Hotel name in ').$lang['name']; } } - if ($shortDescription = html_entity_decode(Tools::getValue('short_description_'.$lang['id_lang']))) { - if (!Validate::isCleanHtml($shortDescription)) { - $this->errors[] = sprintf($this->l('Short description is not valid in %s'), $lang['name']); - } + } + } - $shortDescriptionLength = Tools::strlen($shortDescription); - $shortDescriptionHtmlLength = $shortDescriptionLength - Tools::strlen(strip_tags($shortDescription)); - if ($shortDescriptionLength > ($shortDescriptionMaxChar + $shortDescriptionHtmlLength)) { - $this->errors[] = sprintf($this->l('Short description cannot exceed %s characters in '), $shortDescriptionMaxChar).$lang['name']; - } - } - if ($description = html_entity_decode(Tools::getValue('description_'.$lang['id_lang']))) { - if (!Validate::isCleanHtml($description)) { - $this->errors[] = sprintf($this->l('Description is not valid in %s'), $lang['name']); - } - } - if ($policies = html_entity_decode(Tools::getValue('policies_'.$lang['id_lang']))) { - if (!Validate::isCleanHtml($policies)) { - $this->errors[] = sprintf($this->l('policies are not valid in %s'), $lang['name']); - } + foreach ($languages as $lang) { + if ($shortDescription = html_entity_decode(Tools::getValue('short_description_'.$lang['id_lang']))) { + if (!Validate::isCleanHtml($shortDescription)) { + $this->errors[] = sprintf($this->l('Short description is not valid in %s'), $lang['name']); } - if ($metaTitle = trim(Tools::getValue('meta_title_'.$lang['id_lang']))) { - if (!Validate::isGenericName($metaTitle)) { - $this->errors[] = $this->l('Invalid Meta title in ').$lang['name']; - } else if (Tools::strlen($metaTitle) > 128) { - $this->errors[] = $this->l('Meta title cannot exceed 128 characters in ').$lang['name']; - } + $shortDescriptionLength = Tools::strlen($shortDescription); + if ($shortDescriptionLength > $shortDescriptionMaxChar) { + $this->errors[] = sprintf($this->l('Short description cannot exceed %s characters in '), $shortDescriptionMaxChar).$lang['name']; } + } - if ($metaDescription = trim(Tools::getValue('meta_description_'.$lang['id_lang']))) { - if (!Validate::isGenericName($metaDescription)) { - $this->errors[] = $this->l('Invalid Meta description in ').$lang['name']; - } else if (Tools::strlen($metaDescription) > 255) { - $this->errors[] = $this->l('Meta description cannot exceed 128 characters in ').$lang['name']; - } + if ($description = html_entity_decode(Tools::getValue('description_'.$lang['id_lang']))) { + if (!Validate::isCleanHtml($description)) { + $this->errors[] = sprintf($this->l('Description is not valid in %s'), $lang['name']); } + } + if ($policies = html_entity_decode(Tools::getValue('policies_'.$lang['id_lang']))) { + if (!Validate::isCleanHtml($policies)) { + $this->errors[] = sprintf($this->l('policies are not valid in %s'), $lang['name']); + } + } - if ($metaKeyWords = trim(Tools::getValue('meta_keywords_'.$lang['id_lang']))) { - if (!Validate::isGenericName($metaKeyWords)) { - $this->errors[] = $this->l('Invalid Meta keywords in ').$lang['name']; - } else if (Tools::strlen($metaKeyWords) > 255) { - $this->errors[] = $this->l('Meta keywords cannot exceed 128 characters in ').$lang['name']; - } + if ($metaTitle = trim(Tools::getValue('meta_title_'.$lang['id_lang']))) { + if (!Validate::isGenericName($metaTitle)) { + $this->errors[] = $this->l('Invalid Meta title in ').$lang['name']; + } else if (Tools::strlen($metaTitle) > 128) { + $this->errors[] = $this->l('Meta title cannot exceed 128 characters in ').$lang['name']; + } + } + if ($metaDescription = trim(Tools::getValue('meta_description_'.$lang['id_lang']))) { + if (!Validate::isGenericName($metaDescription)) { + $this->errors[] = $this->l('Invalid Meta description in ').$lang['name']; + } else if (Tools::strlen($metaDescription) > 255) { + $this->errors[] = $this->l('Meta description cannot exceed 128 characters in ').$lang['name']; + } + } + + if ($metaKeyWords = trim(Tools::getValue('meta_keywords_'.$lang['id_lang']))) { + if (!Validate::isGenericName($metaKeyWords)) { + $this->errors[] = $this->l('Invalid Meta keywords in ').$lang['name']; + } else if (Tools::strlen($metaKeyWords) > 255) { + $this->errors[] = $this->l('Meta keywords cannot exceed 128 characters in ').$lang['name']; } } }