added settings
This commit is contained in:
@@ -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
|
||||
|
||||
/**
|
||||
|
||||
@@ -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%;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
</div>
|
||||
<div id="banner"></div>
|
||||
<div id="navigation">
|
||||
<a href="">{l s='Menu item' mod='minicmailchimp'}</a>
|
||||
<a href="">{l s='Menu item' mod='minicmailchimp'}</a>
|
||||
<a href="">{l s='Menu item' mod='minicmailchimp'}</a>
|
||||
<a href="#settings" class="minic-open">{l s='Settings' mod='minicmailchimp'}</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Messages -->
|
||||
{include file="{$minic.admin_tpl_path}messages.tpl" id="global" text=$minic.message.text class=$minic.message.type}
|
||||
<!-- Settings -->
|
||||
{include file="{$minic.admin_tpl_path}settings.tpl"}
|
||||
<!-- feedback -->
|
||||
{include file="{$minic.admin_tpl_path}feedback.tpl"}
|
||||
<!-- bug report -->
|
||||
|
||||
32
views/templates/admin/settings.tpl
Normal file
32
views/templates/admin/settings.tpl
Normal file
@@ -0,0 +1,32 @@
|
||||
<div id="settings" class="minic-container">{debug}
|
||||
<form id="form-feed" class="" method="post" action="{$minic.form_action}">
|
||||
<div class="minic-top">
|
||||
<h3>{l s='Settings' mod='minicmailchimp'}
|
||||
<a href="#" target="_blank" class="help">{l s='help & tips' mod='minicmailchimp'}</a>
|
||||
</h3>
|
||||
<a href="#settings" class="minic-close">x</a>
|
||||
</div>
|
||||
<div class="minic-content">
|
||||
<div class="input-holder">
|
||||
<label>{l s='Mailchimp API Key' mod='minicmailchimp'}:</label>
|
||||
<input id="settings-key" class="apikey" type="text" name="apikey" value="{if $minic.settings.apikey}{$minic.settings.apikey}{/if}" />
|
||||
</div>
|
||||
<div class="switch-holder inline">
|
||||
<label>{l s='Use SSL'}: </label>
|
||||
<div class="switch small {if isset($minic.settings.ssl) && $minic.settings.ssl}active{else}inactive{/if}">
|
||||
<input type="radio" id="r-hover" class="" name="ssl" value="{if isset($minic.settings.ssl) && $minic.settings.ssl}1{else}0{/if}" checked="true" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="minic-comments">
|
||||
<h3>{l s='How to get your API key' mod='minicmailchimp'}</h3>
|
||||
<p>{l s='If you alredy have an API key click'} <a href="https://us6.admin.mailchimp.com/account/api-key-popup/" target="_blank">{l s='here' mod='minicmailchimp'}</a>, {l s='otherwise you can get a new one from'} <a href="https://us6.admin.mailchimp.com/account/api/" target="_blank">{l s='here' mod='minicmailchimp'}</a></p>
|
||||
<h3>{l s='Tutorial to get an API key' mod='minicmailchimp'}</h3>
|
||||
<p>{l s='You can find more info'} <a href="http://kb.mailchimp.com/article/where-can-i-find-my-api-key" target="_blank">{l s='here' mod='minicmailchimp'}</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="minic-bottom">
|
||||
<input type="submit" name="submitSettings" class="button-large green" value="{l s='Save' mod='minicmailchimp'}" />
|
||||
<a href="#settings" class="minic-close button-large lgrey">{l s='Close' mod='minicmailchimp'}</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user