From 17f182aa5e2d2e33f2377aa46a0427ebb278d2af Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 4 Apr 2023 16:44:36 +0530 Subject: [PATCH] updated variables translations for js --- classes/Tools.php | 5 +- classes/Translate.php | 8 +-- classes/module/Module.php | 4 +- .../classes/HotelHelper.php | 22 ++++---- .../admin/AdminAddHotelController.php | 4 +- .../AdminHotelGeneralSettingsController.php | 2 +- .../AdminHotelRoomsBookingController.php | 52 +++++++++---------- modules/qlohotelreview/qlohotelreview.php | 2 +- .../AdminAboutHotelBlockSettingController.php | 2 +- .../AdminFeaturesModuleSettingController.php | 2 +- .../wkhotelfilterblock/wkhotelfilterblock.php | 2 +- .../wkroomsearchblock/wkroomsearchblock.php | 40 +++++++------- ...minTestimonialsModuleSettingController.php | 2 +- 13 files changed, 75 insertions(+), 72 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index 8212ec4b0..f71f8c4a4 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -957,7 +957,7 @@ class ToolsCore * @param string $string Error message * @param bool $htmlentities By default at true for parsing error message with htmlentities */ - public static function displayError($string = 'Fatal error', $htmlentities = true, Context $context = null) + public static function displayError($string = 'Fatal error', $htmlentities = true, Context $context = null, $addslashes = false) { global $_ERRORS; @@ -975,6 +975,9 @@ class ToolsCore } $key = md5(str_replace('\'', '\\\'', $string)); $str = (isset($_ERRORS) && is_array($_ERRORS) && array_key_exists($key, $_ERRORS)) ? $_ERRORS[$key] : $string; + if ($addslashes) { + $str = addslashes($str); + } return $htmlentities ? Tools::htmlentitiesUTF8(stripslashes($str)) : $str; } diff --git a/classes/Translate.php b/classes/Translate.php index 810fcf0f3..fbd62ce8a 100644 --- a/classes/Translate.php +++ b/classes/Translate.php @@ -126,7 +126,7 @@ class TranslateCore * @param string $source * @return string */ - public static function getModuleTranslation($module, $string, $source, $sprintf = null, $js = false, $language = null) + public static function getModuleTranslation($module, $string, $source, $sprintf = null, $addslashes = false, $language = null) { global $_MODULES, $_MODULE, $_LANGADM; @@ -210,10 +210,10 @@ class TranslateCore $ret = Translate::checkAndReplaceArgs($ret, $sprintf); } - if ($js) { + + $ret = htmlspecialchars($ret, ENT_COMPAT, 'UTF-8'); + if ($addslashes) { $ret = addslashes($ret); - } else { - $ret = htmlspecialchars($ret, ENT_COMPAT, 'UTF-8'); } if ($sprintf === null) { diff --git a/classes/module/Module.php b/classes/module/Module.php index 5a0a591a6..04c4a2cbe 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -2124,13 +2124,13 @@ abstract class ModuleCore * @param bool|string $specific filename to use in translation key * @return string Translation */ - public function l($string, $specific = false) + public function l($string, $specific = false, $addslashes = false) { if (self::$_generate_config_xml_mode) { return $string; } - return Translate::getModuleTranslation($this, $string, ($specific) ? $specific : $this->name); + return Translate::getModuleTranslation($this, $string, ($specific) ? $specific : $this->name, null, $addslashes); } /* diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 97cbb5398..b3d60de77 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -24,17 +24,17 @@ class HotelHelper { $objModule = new HotelreservationSystem(); $jsVars = array( - 'display_name' => $objModule->l('Display', 'HotelHelper'), - 'records_name' => $objModule->l('records per page', 'HotelHelper'), - 'no_product' => $objModule->l('No records found', 'HotelHelper'), - 'show_page' => $objModule->l('Showing page', 'HotelHelper'), - 'show_of' => $objModule->l('of', 'HotelHelper'), - 'no_record' => $objModule->l('No records available', 'HotelHelper'), - 'filter_from' => $objModule->l('filtered from', 'HotelHelper'), - 't_record' => $objModule->l('total records', 'HotelHelper'), - 'search_item' => $objModule->l('Search', 'HotelHelper'), - 'p_page' => $objModule->l('Previous', 'HotelHelper'), - 'n_page' => $objModule->l('Next', 'HotelHelper'), + 'display_name' => $objModule->l('Display', 'HotelHelper', fasle, true), + 'records_name' => $objModule->l('records per page', 'HotelHelper', fasle, true), + 'no_product' => $objModule->l('No records found', 'HotelHelper', fasle, true), + 'show_page' => $objModule->l('Showing page', 'HotelHelper', fasle, true), + 'show_of' => $objModule->l('of', 'HotelHelper', fasle, true), + 'no_record' => $objModule->l('No records available', 'HotelHelper', fasle, true), + 'filter_from' => $objModule->l('filtered from', 'HotelHelper', fasle, true), + 't_record' => $objModule->l('total records', 'HotelHelper', fasle, true), + 'search_item' => $objModule->l('Search', 'HotelHelper', fasle, true), + 'p_page' => $objModule->l('Previous', 'HotelHelper', fasle, true), + 'n_page' => $objModule->l('Next', 'HotelHelper', fasle, true), ); Media::addJsDef($jsVars); diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index 4fdb1bdec..30ffa5075 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -724,11 +724,11 @@ class AdminAddHotelController extends ModuleAdminController Media::addJsDef( array( - 'filesizeError' => $this->l('File exceeds maximum size.'), + 'filesizeError' => $this->l('File exceeds maximum size.', null, true), 'maxSizeAllowed' => Tools::getMaxUploadSize(), 'sortRowsUrl' => $this->context->link->getAdminLink('AdminAddHotel'), 'primaryHotelId' => Configuration::get('WK_PRIMARY_HOTEL'), - 'disableHotelMsg' => $this->l('Primary hotel for website will be updated to first available active hotel.'), + 'disableHotelMsg' => $this->l('Primary hotel for website will be updated to first available active hotel.', null, true), ) ); // GOOGLE MAP diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php index e51f9911f..74e120141 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php @@ -419,7 +419,7 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController parent::setMedia(); Media::addJsDef( array( - 'filesizeError' => $this->l('File exceeds maximum size.'), + 'filesizeError' => $this->l('File exceeds maximum size.', null, true), 'maxSizeAllowed' => Tools::getMaxUploadSize(), ) ); diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 62f0baaea..1aff766be 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -807,33 +807,33 @@ class AdminHotelRoomsBookingController extends ModuleAdminController 'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'), 'occupancy_required_for_booking' => $occupancyRequiredForBooking, 'rooms_booking_url' => $this->context->link->getAdminLink('AdminHotelRoomsBooking'), - 'opt_select_all' => $this->l('All Types'), - 'slt_another_htl' => $this->l('Select Another Hotel'), - 'product_type_cond' => $this->l('Product type is required'), - 'from_date_cond' => $this->l('From date is required'), - 'to_date_cond' => $this->l('To date is required'), - 'hotel_name_cond' => $this->l('Hotel Name is required'), - 'num_rooms_cond' => $this->l('Number of Rooms is required'), - 'add_to_cart' => $this->l('Add To Cart'), - 'remove' => $this->l('Remove'), - 'noRoomTypeAvlTxt' => $this->l('No room type available.'), - 'no_rm_avail_txt' => $this->l('No rooms available.'), - 'slct_rm_err' => $this->l('Please select a room first.'), - 'product_added_cart_txt' => $this->l('Product added in cart'), + 'opt_select_all' => $this->l('All Types', null, true), + 'slt_another_htl' => $this->l('Select Another Hotel', null, true), + 'product_type_cond' => $this->l('Product type is required', null, true), + 'from_date_cond' => $this->l('From date is required', null, true), + 'to_date_cond' => $this->l('To date is required', null, true), + 'hotel_name_cond' => $this->l('Hotel Name is required', null, true), + 'num_rooms_cond' => $this->l('Number of Rooms is required', null, true), + 'add_to_cart' => $this->l('Add To Cart', null, true), + 'remove' => $this->l('Remove', null, true), + 'noRoomTypeAvlTxt' => $this->l('No room type available.', null, true), + 'no_rm_avail_txt' => $this->l('No rooms available.', null, true), + 'slct_rm_err' => $this->l('Please select a room first.', null, true), + 'product_added_cart_txt' => $this->l('Product added in cart', null, true), 'info_icon_path' => _MODULE_DIR_.$this->module->name.'/views/img/Slices/info-icon.svg', - 'select_age_txt' => 'Select age', - 'under_1_age' => 'Under 1', - 'room_txt' => 'Room', - 'rooms_txt' => 'Rooms', - 'remove_txt' => 'Remove', - 'adult_txt' => 'Adults', - 'adults_txt' => 'Adults', - 'child_txt' => 'Child', - 'children_txt' => 'Children', - 'below_txt' => 'Below', - 'years_txt' => 'years', - 'all_children_txt' => 'All Children', - 'invalid_occupancy_txt' => 'Invalid occupancy(adults/children) found.', + 'select_age_txt' => $this->l('Select age', null, true), + 'under_1_age' => $this->l('Under 1', null, true), + 'room_txt' => $this->l('Room', null, true), + 'rooms_txt' => $this->l('Rooms', null, true), + 'remove_txt' => $this->l('Remove', null, true), + 'adult_txt' => $this->l('Adults', null, true), + 'adults_txt' => $this->l('Adults', null, true), + 'child_txt' => $this->l('Child', null, true), + 'children_txt' => $this->l('Children', null, true), + 'below_txt' => $this->l('Below', null, true), + 'years_txt' => $this->l('years', null, true), + 'all_children_txt' => $this->l('All Children', null, true), + 'invalid_occupancy_txt' => $this->l('Invalid occupancy(adults/children) found.', null, true), // 'check_calender_var' => $check_calender_var, ); if (Configuration::get('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS ) { diff --git a/modules/qlohotelreview/qlohotelreview.php b/modules/qlohotelreview/qlohotelreview.php index a0319941e..2185bd243 100644 --- a/modules/qlohotelreview/qlohotelreview.php +++ b/modules/qlohotelreview/qlohotelreview.php @@ -171,7 +171,7 @@ class QloHotelReview extends Module 'admin_approval_enabled' => (int) Configuration::get('QHR_ADMIN_APPROVAL_ENABLED'), 'texts' => array( 'num_files' => sprintf( - $this->l('You can upload a maximum of %d images.'), + $this->l('You can upload a maximum of %d images.', false, true), (int) Configuration::get('QHR_MAX_IMAGES_PER_REVIEW') ), ), diff --git a/modules/wkabouthotelblock/controllers/admin/AdminAboutHotelBlockSettingController.php b/modules/wkabouthotelblock/controllers/admin/AdminAboutHotelBlockSettingController.php index f6c973b30..8ffe12603 100644 --- a/modules/wkabouthotelblock/controllers/admin/AdminAboutHotelBlockSettingController.php +++ b/modules/wkabouthotelblock/controllers/admin/AdminAboutHotelBlockSettingController.php @@ -397,7 +397,7 @@ class AdminAboutHotelBlockSettingController extends ModuleAdminController parent::setMedia(); Media::addJsDef( array( - 'filesizeError' => $this->l('File exceeds maximum size.'), + 'filesizeError' => $this->l('File exceeds maximum size.', null, true), 'maxSizeAllowed' => Tools::getMaxUploadSize(), ) ); diff --git a/modules/wkhotelfeaturesblock/controllers/admin/AdminFeaturesModuleSettingController.php b/modules/wkhotelfeaturesblock/controllers/admin/AdminFeaturesModuleSettingController.php index 5577e9fc0..510e448c7 100644 --- a/modules/wkhotelfeaturesblock/controllers/admin/AdminFeaturesModuleSettingController.php +++ b/modules/wkhotelfeaturesblock/controllers/admin/AdminFeaturesModuleSettingController.php @@ -428,7 +428,7 @@ class AdminFeaturesModuleSettingController extends ModuleAdminController parent::setMedia(); Media::addJsDef( array( - 'filesizeError' => $this->l('File exceeds maximum size.'), + 'filesizeError' => $this->l('File exceeds maximum size.', null, true), 'maxSizeAllowed' => Tools::getMaxUploadSize(), ) ); diff --git a/modules/wkhotelfilterblock/wkhotelfilterblock.php b/modules/wkhotelfilterblock/wkhotelfilterblock.php index 21d094a29..8f6dafcd6 100644 --- a/modules/wkhotelfilterblock/wkhotelfilterblock.php +++ b/modules/wkhotelfilterblock/wkhotelfilterblock.php @@ -66,7 +66,7 @@ class wkhotelfilterblock extends Module $htl_id_category = Tools::getValue('id_category'); if (Validate::isLoadedObject($objCategory = new Category((int) $htl_id_category))) { if ($objCategory->hasParent(Configuration::get('PS_LOCATIONS_CATEGORY'))) { - Media::addJsDef(array('noRoomAvailTxt' => $this->l('No room available'))); + Media::addJsDef(array('noRoomAvailTxt' => $this->l('No room available', false, true))); $this->context->controller->addJS($this->_path.'/views/js/wkhotelfilterblock.js'); $this->context->controller->addCSS($this->_path.'/views/css/wkhotelfilterblock.css'); diff --git a/modules/wkroomsearchblock/wkroomsearchblock.php b/modules/wkroomsearchblock/wkroomsearchblock.php index 256d0d15f..e959bf65d 100644 --- a/modules/wkroomsearchblock/wkroomsearchblock.php +++ b/modules/wkroomsearchblock/wkroomsearchblock.php @@ -61,26 +61,26 @@ class WkRoomSearchBlock extends Module 'wkroomsearchblock', 'autocompletesearch' ), - 'no_results_found_cond' => $this->l('No results found for this search'), - 'hotel_name_cond' => $this->l('Please select a hotel name'), - 'check_in_time_cond' => $this->l('Please enter Check In time'), - 'check_out_time_cond' => $this->l('Please enter Check Out time'), - 'less_checkin_date' => $this->l('Check In date can not be before current date.'), - 'more_checkout_date' => $this->l('Check Out date must be greater than Check In date.'), - 'select_htl_txt' => $this->l('Select Hotel'), - 'select_age_txt' => $this->l('Select age'), - 'under_1_age' => $this->l('Under 1'), - 'room_txt' => $this->l('Room'), - 'rooms_txt' => $this->l('Rooms'), - 'remove_txt' => $this->l('Remove'), - 'adult_txt' => $this->l('Adult'), - 'adults_txt' => $this->l('Adults'), - 'child_txt' => $this->l('Child'), - 'children_txt' => $this->l('Children'), - 'below_txt' => $this->l('Below'), - 'years_txt' => $this->l('years'), - 'all_children_txt' => $this->l('All Children'), - 'invalid_occupancy_txt' => $this->l('Invalid occupancy(adults/children) found.'), + 'no_results_found_cond' => $this->l('No results found for this search', false, true), + 'hotel_name_cond' => $this->l('Please select a hotel name', false, true), + 'check_in_time_cond' => $this->l('Please enter Check In time', false, true), + 'check_out_time_cond' => $this->l('Please enter Check Out time', false, true), + 'less_checkin_date' => $this->l('Check In date can not be before current date.', false, true), + 'more_checkout_date' => $this->l('Check Out date must be greater than Check In date.', false, true), + 'select_htl_txt' => $this->l('Select Hotel', false, true), + 'select_age_txt' => $this->l('Select age', false, true), + 'under_1_age' => $this->l('Under 1', false, true), + 'room_txt' => $this->l('Room', false, true), + 'rooms_txt' => $this->l('Rooms', false, true), + 'remove_txt' => $this->l('Remove', false, true), + 'adult_txt' => $this->l('Adult', false, true), + 'adults_txt' => $this->l('Adults', false, true), + 'child_txt' => $this->l('Child', false, true), + 'children_txt' => $this->l('Children', false, true), + 'below_txt' => $this->l('Below', false, true), + 'years_txt' => $this->l('years', false, true), + 'all_children_txt' => $this->l('All Children', false, true), + 'invalid_occupancy_txt' => $this->l('Invalid occupancy(adults/children) found.', false, true), ) ); } diff --git a/modules/wktestimonialblock/controllers/admin/AdminTestimonialsModuleSettingController.php b/modules/wktestimonialblock/controllers/admin/AdminTestimonialsModuleSettingController.php index 83c2c9c19..2bffd0fd9 100644 --- a/modules/wktestimonialblock/controllers/admin/AdminTestimonialsModuleSettingController.php +++ b/modules/wktestimonialblock/controllers/admin/AdminTestimonialsModuleSettingController.php @@ -406,7 +406,7 @@ class AdminTestimonialsModuleSettingController extends ModuleAdminController parent::setMedia(); Media::addJsDef( array( - 'filesizeError' => $this->l('File exceeds maximum size.'), + 'filesizeError' => $this->l('File exceeds maximum size.', null, true), 'maxSizeAllowed' => Tools::getMaxUploadSize(), ) );