yieldify
This commit is contained in:
parent
dad8aecefb
commit
3f4ce1821d
167
modules/yieldify/controllers/admin/AdminPreferenceYieldify.php
Normal file
167
modules/yieldify/controllers/admin/AdminPreferenceYieldify.php
Normal file
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
class AdminPreferenceYieldifyController extends ModuleAdminController {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct(){
|
||||
$this->context = Context::getContext();
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
$this->bootstrap = true;
|
||||
|
||||
$imagepopup_home = _THEME_IMG_DIR_.'home/popup_home.png';
|
||||
$imagepopup_promo = _THEME_IMG_DIR_.'home/popup_promo.png';
|
||||
|
||||
$fields = array(
|
||||
'popup_home' => array(
|
||||
'YIELDIFY_CUSTOMER_YIELD' => array(
|
||||
'title' => $this->l('Activer la popup de la home'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool',
|
||||
'default' => Configuration::get('YIELDIFY_CUSTOMER_YIELD'),
|
||||
),
|
||||
array(
|
||||
'title' => $this->l('Image popup'),
|
||||
'type' => 'file',
|
||||
'label' => $this->l('Image popup'),
|
||||
'name' => 'imagepopup_home',
|
||||
'form_group_class' => 'fieldhide input_img',
|
||||
'url' => $imagepopup_home,
|
||||
'desc' => 'dimension 500px x 500px'
|
||||
),
|
||||
'YIELDIFY_CUSTOMER_YIELD_LINK' => array(
|
||||
'title' => $this->l('Lien de la popup'),
|
||||
'type' => 'text',
|
||||
'default' => Configuration::get('YIELDIFY_CUSTOMER_YIELD_LINK'),
|
||||
),
|
||||
'YIELDIFY_CUSTOMER_YIELD_TEXT' => array(
|
||||
'title' => $this->l('Texte du lien'),
|
||||
'type' => 'text',
|
||||
'default' => Configuration::get('YIELDIFY_CUSTOMER_YIELD_TEXT'),
|
||||
),
|
||||
),
|
||||
|
||||
'popup_promo' => array(
|
||||
'YIELDIFY_PROMO_YIELD' => array(
|
||||
'title' => $this->l('Activer la popup de la home (promo)'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool',
|
||||
'default' => Configuration::get('YIELDIFY_PROMO_YIELD'),
|
||||
'desc' => 'La popup s\'affichera une seule fois par jour',
|
||||
),
|
||||
array(
|
||||
'title' => $this->l('Image popup'),
|
||||
'type' => 'file',
|
||||
'label' => $this->l('Image popup'),
|
||||
'name' => 'imagepopup_promo',
|
||||
'form_group_class' => 'fieldhide input_img',
|
||||
'url' => $imagepopup_promo,
|
||||
'desc' => 'dimension 500px x 500px'
|
||||
),
|
||||
'YIELDIFY_PROMO_YIELD_LINK' => array(
|
||||
'title' => $this->l('Lien de la popup'),
|
||||
'type' => 'text',
|
||||
'default' => Configuration::get('YIELDIFY_PROMO_YIELD_LINK'),
|
||||
),
|
||||
'YIELDIFY_PROMO_YIELD_TEXT' => array(
|
||||
'title' => $this->l('Texte du lien'),
|
||||
'type' => 'text',
|
||||
'default' => Configuration::get('YIELDIFY_PROMO_YIELD_TEXT'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->fields_options = array(
|
||||
/*'popup_home' => array(
|
||||
'title' => $this->l('POPUP HOME (popup entrée de site)'),
|
||||
'icon' => 'tab-preferences',
|
||||
'fields' => $fields['popup_home'],
|
||||
'submit' => array(
|
||||
'name' => 'submitPopupHome',
|
||||
'title' => $this->l('Enregistrer'),
|
||||
),
|
||||
),*/
|
||||
'popup_promo' => array(
|
||||
'title' => $this->l('POPUP HOME (popup entrée de site, promo)'),
|
||||
'icon' => 'tab-preferences',
|
||||
'fields' => $fields['popup_promo'],
|
||||
'submit' => array(
|
||||
'name' => 'submitPopupPromo',
|
||||
'title' => $this->l('Enregistrer'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess(){
|
||||
parent::postProcess();
|
||||
|
||||
if (Tools::isSubmit('submitPopupHome')) {
|
||||
Configuration::updateValue('YIELDIFY_CUSTOMER_YIELD', Tools::getValue('YIELDIFY_CUSTOMER_YIELD'));
|
||||
Configuration::updateValue('YIELDIFY_CUSTOMER_YIELD_LINK', Tools::getValue('YIELDIFY_CUSTOMER_YIELD_LINK'));
|
||||
Configuration::updateValue('YIELDIFY_CUSTOMER_YIELD_TEXT', Tools::getValue('YIELDIFY_CUSTOMER_YIELD_TEXT'));
|
||||
|
||||
$languages = Language::getLanguages(false);
|
||||
foreach ($languages as $language) {
|
||||
$namePost = 'imagepopup_home_'.$language['id_lang'];
|
||||
|
||||
if(isset($_FILES[$namePost]) && !empty($_FILES[$namePost]['tmp_name']) ){
|
||||
|
||||
$fileTemp = $_FILES[$namePost]['tmp_name'];
|
||||
$fileParts = pathinfo($_FILES[$namePost]['name']);
|
||||
|
||||
if($fileParts['extension'] == 'jpg' || $fileParts['extension'] == 'png'){
|
||||
$res = move_uploaded_file($fileTemp, _PS_THEME_DIR_.'img/home/popup_home.png');
|
||||
if(!$res) {
|
||||
$this->errors[] = sprintf(Tools::displayError('An error occured during upload of file %s'), 'popup_home.png');
|
||||
} else {
|
||||
$this->confirmations[] = sprintf($this->l('File %s has been uploaded'), 'popup_home.png');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = sprintf(Tools::displayError('File %s have not good extension, only .jpg or .png'), 'popup_home.png');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Tools::isSubmit('submitPopupPromo')) {
|
||||
Configuration::updateValue('YIELDIFY_PROMO_YIELD', Tools::getValue('YIELDIFY_PROMO_YIELD'));
|
||||
Configuration::updateValue('YIELDIFY_PROMO_YIELD_LINK', Tools::getValue('YIELDIFY_PROMO_YIELD_LINK'));
|
||||
Configuration::updateValue('YIELDIFY_PROMO_YIELD_TEXT', Tools::getValue('YIELDIFY_PROMO_YIELD_TEXT'));
|
||||
|
||||
$languages = Language::getLanguages(false);
|
||||
foreach ($languages as $language) {
|
||||
$namePost = 'imagepopup_promo_'.$language['id_lang'];
|
||||
|
||||
if(isset($_FILES[$namePost]) && !empty($_FILES[$namePost]['tmp_name']) ){
|
||||
|
||||
$fileTemp = $_FILES[$namePost]['tmp_name'];
|
||||
$fileParts = pathinfo($_FILES[$namePost]['name']);
|
||||
|
||||
if($fileParts['extension'] == 'jpg' || $fileParts['extension'] == 'png'){
|
||||
$res = move_uploaded_file($fileTemp, _PS_THEME_DIR_.'img/home/popup_promo.png');
|
||||
if(!$res) {
|
||||
$this->errors[] = sprintf(Tools::displayError('An error occured during upload of file %s'), 'popup_promo.png');
|
||||
} else {
|
||||
$this->confirmations[] = sprintf($this->l('File %s has been uploaded'), 'popup_promo.png');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = sprintf(Tools::displayError('File %s have not good extension, only .jpg or .png'), 'popup_promo.png');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitOtherPopups')){
|
||||
Configuration::updateValue('YIELDIFY_CART_YIELD', Tools::getValue('YIELDIFY_CART_YIELD'));
|
||||
Configuration::updateValue('YIELDIFY_PRODUCT_YIELD', Tools::getValue('YIELDIFY_PRODUCT_YIELD'));
|
||||
Configuration::updateValue('YIELDIFY_CONCOURS_YIELD', Tools::getValue('YIELDIFY_CONCOURS_YIELD'));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
{assign var=languages value=Language::getLanguages(false)}
|
||||
{if !isset($defaultFormLanguage)}
|
||||
{assign var=defaultFormLanguage value=$languages[0].id_lang}
|
||||
{/if}
|
||||
<div class="row">
|
||||
{foreach from=$languages item=language}
|
||||
{if $languages|count > 1}
|
||||
<div class="translatable-field lang-{$language.id_lang}" {if $language.id_lang != $defaultFormLanguage}style="display:none"{/if}>
|
||||
{/if}
|
||||
<div class="col-lg-6">
|
||||
{if $url != "noimg"
|
||||
&& $name != "imagepopup_home"
|
||||
&& $name != "imagepopup_promo"}
|
||||
<img src="{$url}_{$language.id_lang}.jpg" class="img-thumbnail" />
|
||||
{/if}
|
||||
{if $name == "imagebg"
|
||||
|| $name == "imagepopup_home"
|
||||
|| $name == "imagepopup_promo"}
|
||||
<img src="{$url}" class="img-thumbnail" />
|
||||
{/if}
|
||||
<input id="{$name}_{$language.id_lang}" type="file" name="{$name}_{$language.id_lang}" class="hide" />
|
||||
<div class="dummyfile input-group">
|
||||
<span class="input-group-addon"><i class="icon-file"></i></span>
|
||||
<input id="{$name}_{$language.id_lang}-name" type="text" class="disabled" name="filename" readonly />
|
||||
<span class="input-group-btn">
|
||||
<button id="{$name}_{$language.id_lang}-selectbutton" type="button" name="submitAddAttachments" class="btn btn-default">
|
||||
<i class="icon-folder-open"></i> {l s='Choose a file' mod='privatesales'}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{if $languages|count > 1}
|
||||
<div class="col-lg-2">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" tabindex="-1" data-toggle="dropdown">
|
||||
{$language.iso_code}
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
{foreach from=$languages item=lang}
|
||||
<li><a href="javascript:hideOtherLanguage({$lang.id_lang});" tabindex="-1">{$lang.name}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
{if $languages|count > 1}
|
||||
</div>
|
||||
{/if}
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$('#{$name}_{$language.id_lang}-selectbutton').click(function(e){
|
||||
$('#{$name}_{$language.id_lang}').trigger('click');
|
||||
});
|
||||
$('#{$name}_{$language.id_lang}').change(function(e){
|
||||
var val = $(this).val();
|
||||
var file = val.split(/[\\/]/);
|
||||
$('#{$name}_{$language.id_lang}-name').val(file[file.length-1]);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/foreach}
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user