From ffb3a1ae018acbed35a216424b4c1df30c1180cb Mon Sep 17 00:00:00 2001 From: minic studio Date: Mon, 8 Apr 2013 13:08:57 +0300 Subject: [PATCH] added settings --- minicmailchimp.php | 39 +++++++++++++++++++++++- views/css/admin.css | 3 +- views/css/buttons.css | 5 +++ views/templates/admin/minicmailchimp.tpl | 8 +++-- views/templates/admin/settings.tpl | 32 +++++++++++++++++++ 5 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 views/templates/admin/settings.tpl diff --git a/minicmailchimp.php b/minicmailchimp.php index 48622ad..40a5552 100644 --- a/minicmailchimp.php +++ b/minicmailchimp.php @@ -53,6 +53,10 @@ class MinicMailchimp extends Module $this->front_tpl_path = _PS_MODULE_DIR_.$this->name.'/views/templates/front/'; $this->hooks_tpl_path = _PS_MODULE_DIR_.$this->name.'/views/templates/hooks/'; + $this->message = array( + 'text' => '', + 'type' => 'conf' + ); } /** @@ -102,9 +106,16 @@ class MinicMailchimp extends Module */ public function getContent() { + if(Tools::isSubmit('submitSettings')) + $this->saveSettings(); + + + // Smarty for admin $this->smarty->assign('minic', array( 'first_start' => Configuration::get(strtoupper($this->name).'_START'), + // Settings + 'settings' => unserialize(Configuration::get('MINIC_MAILCHIMP_SETTINGS')), 'admin_tpl_path' => $this->admin_tpl_path, 'front_tpl_path' => $this->front_tpl_path, @@ -125,7 +136,9 @@ class MinicMailchimp extends Module 'today' => date('Y-m-d'), 'module' => $this->name, 'context' => (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') == 0) ? 1 : ($this->context->shop->getTotalShops() != 1) ? $this->context->shop->getContext() : 1, - ) + ), + 'form_action' => 'index.php?tab=AdminModules&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&tab_module='. $this->tab .'&module_name='.$this->name, + 'message' => $this->message, )); // Change first start @@ -135,6 +148,30 @@ class MinicMailchimp extends Module return $this->display(__FILE__, 'views/templates/admin/minicmailchimp.tpl'); } + /** + * Save settings into PS Configuration + */ + public function saveSettings() + { + $settings = array(); + + if(!Tools::isSubmit('apikey') || !Tools::getValue('apikey')){ + $this->message = array('text' => $this->l('API Key is empty!'), 'type' => 'error'); + return; + } + if(!Tools::getValue('ssl') && Tools::getValue('ssl') != 0){ + $this->message = array('text' => $this->l('SSL save failed!'), 'type' => 'error'); + return; + } + + $settings['apikey'] = Tools::getValue('apikey'); + $settings['ssl'] = (int)Tools::getValue('ssl'); + + Configuration::updateValue('MINIC_MAILCHIMP_SETTINGS', serialize($settings)); + + $this->message['text'] = $this->l('Saved!'); + } + // BACK OFFICE HOOKS /** diff --git a/views/css/admin.css b/views/css/admin.css index 4645800..32ecf10 100644 --- a/views/css/admin.css +++ b/views/css/admin.css @@ -276,7 +276,8 @@ padding: 50px 3%; } /* minic content -> input cotnainers */ - .minic-content > div.input-holder{ + .minic-content > div.input-holder, + .minic-content > div.switch-holder{ float: left; clear: both; width: 45%; diff --git a/views/css/buttons.css b/views/css/buttons.css index 1ee3de3..4a7419d 100644 --- a/views/css/buttons.css +++ b/views/css/buttons.css @@ -100,6 +100,11 @@ background-position: 0 -100px; } /* ON/OFF switch */ +.switch-holder.inline > label{ + float: left !important; + line-height: 26px; + margin-right: 10px; +} .switch{ -webkit-transition: all 0.4s ease-in-out; -moz-transition: all 0.4s ease-in-out; diff --git a/views/templates/admin/minicmailchimp.tpl b/views/templates/admin/minicmailchimp.tpl index dd6a9a2..e39540b 100644 --- a/views/templates/admin/minicmailchimp.tpl +++ b/views/templates/admin/minicmailchimp.tpl @@ -19,11 +19,13 @@ + + {include file="{$minic.admin_tpl_path}messages.tpl" id="global" text=$minic.message.text class=$minic.message.type} + + {include file="{$minic.admin_tpl_path}settings.tpl"} {include file="{$minic.admin_tpl_path}feedback.tpl"} diff --git a/views/templates/admin/settings.tpl b/views/templates/admin/settings.tpl new file mode 100644 index 0000000..98b878a --- /dev/null +++ b/views/templates/admin/settings.tpl @@ -0,0 +1,32 @@ +
{debug} +
+
+

{l s='Settings' mod='minicmailchimp'} + {l s='help & tips' mod='minicmailchimp'} +

+ x +
+
+
+ + +
+
+ +
+ +
+
+
+

{l s='How to get your API key' mod='minicmailchimp'}

+

{l s='If you alredy have an API key click'} {l s='here' mod='minicmailchimp'}, {l s='otherwise you can get a new one from'} {l s='here' mod='minicmailchimp'}

+

{l s='Tutorial to get an API key' mod='minicmailchimp'}

+

{l s='You can find more info'} {l s='here' mod='minicmailchimp'}

+
+
+ +
+
\ No newline at end of file