From dfc9aab4dc15d13c649aa3fb54f041e5e03ee085 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 7 Aug 2023 14:46:44 +0530 Subject: [PATCH 1/2] Revert PR #471 --- .../admin/AdminPPreferencesController.php | 23 ---- install/data/theme.sql | 2 - install/data/xml/configuration.xml | 6 - .../wkhotelfilterblock/wkhotelfilterblock.php | 119 +++++++++++++++++- 4 files changed, 118 insertions(+), 32 deletions(-) diff --git a/controllers/admin/AdminPPreferencesController.php b/controllers/admin/AdminPPreferencesController.php index 1ea8b3f50..9d9e77aee 100644 --- a/controllers/admin/AdminPPreferencesController.php +++ b/controllers/admin/AdminPPreferencesController.php @@ -391,29 +391,6 @@ public function __construct() // 'bottom' => '', // 'submit' => array('title' => $this->l('Save')) // ), - 'fo_search_filters' => array( - 'title' => $this->l('Search Results Page Filters'), - 'icon' => 'icon-search', - 'fields' => array( - 'SHOW_AMENITIES_FILTER' => array( - 'title' => $this->l('Show Amenities filter'), - 'hint' => $this->l('Enable to display Amenities filter.'), - 'validation' => 'isBool', - 'cast' => 'intval', - 'required' => false, - 'type' => 'bool', - ), - 'SHOW_PRICE_FILTER' => array( - 'title' => $this->l('Show Price filter'), - 'hint' => $this->l('Enable to display Price filter.'), - 'validation' => 'isBool', - 'cast' => 'intval', - 'required' => false, - 'type' => 'bool', - ), - ), - 'submit' => array('title' => $this->l('Save')) - ), ); } diff --git a/install/data/theme.sql b/install/data/theme.sql index ec71efd71..9ce4b813b 100644 --- a/install/data/theme.sql +++ b/install/data/theme.sql @@ -3,8 +3,6 @@ SET NAMES 'utf8'; UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_CONDITIONS'; UPDATE `PREFIX_configuration` SET value = '12' WHERE name = 'PS_PRODUCTS_PER_PAGE'; UPDATE `PREFIX_configuration` SET value = '9' WHERE name = 'PS_HOTEL_IMAGES_PER_PAGE'; -UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SHOW_AMENITIES_FILTER'; -UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SHOW_PRICE_FILTER'; UPDATE `PREFIX_configuration` SET value = '0' WHERE name = 'PS_PRODUCTS_ORDER_WAY'; UPDATE `PREFIX_configuration` SET value = '4' WHERE name = 'PS_PRODUCTS_ORDER_BY'; UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_DISPLAY_QTIES'; diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml index 935de20ba..34b3c3d2e 100644 --- a/install/data/xml/configuration.xml +++ b/install/data/xml/configuration.xml @@ -62,12 +62,6 @@ 9 - - 1 - - - 1 - 0 diff --git a/modules/wkhotelfilterblock/wkhotelfilterblock.php b/modules/wkhotelfilterblock/wkhotelfilterblock.php index e2fa40f38..bbb2e4b84 100644 --- a/modules/wkhotelfilterblock/wkhotelfilterblock.php +++ b/modules/wkhotelfilterblock/wkhotelfilterblock.php @@ -42,12 +42,117 @@ public function __construct() $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); } + public function getContent() + { + $this->html = ''; + if (Tools::isSubmit('btnConfigSubmit')) { + $this->postProcess(); + } else { + $this->html .= '
'; + } + + $this->html .= $this->renderForm(); + + return $this->html; + } + + public function renderForm() + { + $fields_form = array(); + $fields_form['form'] = array( + 'legend' => array( + 'icon' => 'icon-cog', + 'title' => $this->l('Search Results Filter Configuration'), + ), + 'input' => array( + array( + 'type' => 'switch', + 'label' => $this->l('Show Amenities filter'), + 'name' => 'SHOW_AMENITIES_FILTER', + 'is_bool' => true, + 'values' => array( + array( + 'id' => 'active_on', + 'value' => 1, + ), + array( + 'id' => 'active_off', + 'value' => 0, + ), + ), + 'hint' => $this->l('Enable to display Amenities filter.'), + ), + array( + 'type' => 'switch', + 'label' => $this->l('Show Price filter'), + 'name' => 'SHOW_PRICE_FILTER', + 'is_bool' => true, + 'values' => array( + array( + 'id' => 'active_on', + 'value' => 1, + ), + array( + 'id' => 'active_off', + 'value' => 0, + ), + ), + 'hint' => $this->l('Enable to display Price filter.'), + ), + ), + 'submit' => array( + 'title' => $this->l('Save'), + 'name' => 'submit_conf_filter', + ), + ); + + $helper = new HelperForm(); + $helper->show_toolbar = false; + $helper->table = $this->table; + $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT')); + $helper->default_form_language = $lang->id; + $this->fields_form = array(); + $helper->identifier = $this->identifier; + $helper->submit_action = 'btnConfigSubmit'; + $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false). + '&configure='.$this->name.'&module_name='.$this->name; + $helper->token = Tools::getAdminTokenLite('AdminModules'); + + $helper->tpl_vars = array( + 'fields_value' => $this->getConfigFieldsValues(), + 'languages' => $this->context->controller->getLanguages(), + 'id_language' => $this->context->language->id, + ); + + return $helper->generateForm(array($fields_form)); + } + + public function postProcess() + { + if (Tools::isSubmit('btnConfigSubmit')) { + Configuration::updateValue( + 'SHOW_AMENITIES_FILTER', + Tools::getValue('SHOW_AMENITIES_FILTER') + ); + Configuration::updateValue('SHOW_PRICE_FILTER', Tools::getValue('SHOW_PRICE_FILTER')); + + // redirect after saving the configuration + Tools::redirectAdmin( + $this->context->link->getAdminLink('AdminModules').'&configure='.$this->name.'&tab_module='.$this->tab. + '&module_name='.$this->name.'&conf=4' + ); + } + } + public function install() { if (!parent::install() || !$this->registerHook('header') || !$this->registerHook('addOtherModuleSetting') - || !$this->registerHook('displayLeftColumn')) { + || !$this->registerHook('displayLeftColumn') + || !Configuration::updateValue('SHOW_AMENITIES_FILTER', 1) + || !Configuration::updateValue('SHOW_PRICE_FILTER', 1) + ) { return false; } @@ -155,4 +260,16 @@ public function getConfigFieldsValues() 'SHOW_PRICE_FILTER' => Configuration::get('SHOW_PRICE_FILTER'), ); } + + public function uninstall() + { + if (!parent::uninstall() + || !Configuration::deleteByName('SHOW_AMENITIES_FILTER') + || !Configuration::deleteByName('SHOW_PRICE_FILTER') + ) { + return false; + } + + return true; + } } From dbaf23c9abeb0ebcfa996a981eeaef066d09157a Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 9 Feb 2024 13:19:40 +0530 Subject: [PATCH 2/2] Text update --- modules/wkhotelfilterblock/wkhotelfilterblock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/wkhotelfilterblock/wkhotelfilterblock.php b/modules/wkhotelfilterblock/wkhotelfilterblock.php index bbb2e4b84..da5254bc1 100644 --- a/modules/wkhotelfilterblock/wkhotelfilterblock.php +++ b/modules/wkhotelfilterblock/wkhotelfilterblock.php @@ -62,7 +62,7 @@ public function renderForm() $fields_form['form'] = array( 'legend' => array( 'icon' => 'icon-cog', - 'title' => $this->l('Search Results Filter Configuration'), + 'title' => $this->l('Search Results Page Filters'), ), 'input' => array( array(