From 3e535273cd656a0d6ebca1cb34aed7e620f2c648 Mon Sep 17 00:00:00 2001 From: tpeigne Date: Thu, 25 Jul 2013 00:19:21 +0200 Subject: [PATCH] Add the possibility to enable or not the ajax cart --- modules/responsivetopbar/responsivetopbar.php | 51 ++++++++++++++++++- modules/responsivetopbar/translations/fr.php | 9 +++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/modules/responsivetopbar/responsivetopbar.php b/modules/responsivetopbar/responsivetopbar.php index e7d1d31..7646b57 100644 --- a/modules/responsivetopbar/responsivetopbar.php +++ b/modules/responsivetopbar/responsivetopbar.php @@ -27,7 +27,51 @@ public function __construct() public function install() { - return (parent::install() AND $this->registerHook('top') AND $this->registerHook('header')); + // Install Module + if (!parent::install() OR !$this->registerHook('top') OR !$this->registerHook('header')) + return false; + + //configuration update + if (Configuration::updateValue('RESPONSIVE_BLOCK_CART_AJAX', 1) == false) + return false; + + return true; + } + + public function getContent() + { + $output = '

'.$this->displayName.'

'; + if (Tools::isSubmit('submitResponsiveBlockCart')) + { + $ajax = Tools::getValue('cart_ajax'); + if ($ajax != 0 && $ajax != 1) + $output .= '
'.$this->l('Ajax : Invalid choice.').'
'; + else + Configuration::updateValue('RESPONSIVE_BLOCK_CART_AJAX', (int)($ajax)); + $output .= '
'.$this->l('Settings updated').'
'; + } + return $output.$this->displayForm(); + } + + public function displayForm() + { + return ' +
+
+ '.$this->l('Settings').' + + +
+ + + + +

'.$this->l('Activate AJAX mode for cart (compatible with the default theme)').'

+
+ +
+
+
'; } public function hookTop($params) @@ -171,7 +215,10 @@ public function assignContentVars(&$params) public function hookHeader($params) { $this->context->controller->addCSS(($this->_path).'responsivetopbar.css'); - $this->context->controller->addJs(($this->_path).'ajax-cart.js'); + + if ((int)(Configuration::get('RESPONSIVE_BLOCK_CART_AJAX'))) { + $this->context->controller->addJs(($this->_path).'ajax-cart.js'); + } } } diff --git a/modules/responsivetopbar/translations/fr.php b/modules/responsivetopbar/translations/fr.php index ff9dab6..4fb4c13 100644 --- a/modules/responsivetopbar/translations/fr.php +++ b/modules/responsivetopbar/translations/fr.php @@ -4,7 +4,14 @@ $_MODULE = array(); $_MODULE['<{responsivetopbar}prestashop>responsivetopbar_a51a9d164f0ded9abd07025c620bf9e2'] = 'Responsive top bar'; $_MODULE['<{responsivetopbar}prestashop>responsivetopbar_e227615234794355a6009819491515d3'] = 'Ajoute une top barre menu en haut de votre site'; -$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_c26dfd7d0b30d8437cf4ef7dd8f3b7cf'] = 'Pour activer le panier ajax, vous devez placer le module blockcart dans votre dossier modules.'; +$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_eb4ae207521bbe6403f7fe9564d38cda'] = 'Ajax : choix non valable.'; +$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_c888438d14855d7d96a2724ee9c306bd'] = 'Paramètres mis à jour'; +$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_f4f70727dc34561dfde1a3c529b6205c'] = 'Paramètres'; +$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_614a8820aa4ac08ce2ee398a41b10778'] = 'Panier Ajax'; +$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Activé'; +$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_b9f5c797ebbf55adccdd8539a65a0241'] = 'Désactivé'; +$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_dba281afb9a38e654ea9dab4cd6cb0ca'] = 'Activer le mode Ajax du panier (compatible avec le thème par défaut)'; +$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_c9cc8cce247e49bae79f15173ce97354'] = 'Enregistrer'; $_MODULE['<{responsivetopbar}prestashop>responsivetopbar_20351b3328c35ab617549920f5cb4939'] = 'Personnalisation n°'; $_MODULE['<{responsivetopbar}prestashop>responsivetopbar_ed6e9a09a111035684bb23682561e12d'] = 'supprimer cet article du panier'; $_MODULE['<{responsivetopbar}prestashop>responsivetopbar_c6995d6cc084c192bc2e742f052a5c74'] = 'Livraison gratuite !';