This commit is contained in:
Nolwenn 2016-06-22 16:12:58 +02:00
parent 6c7a4b5a5f
commit 2b02823a2c
43 changed files with 2187 additions and 3 deletions

1
.gitignore vendored
View File

@ -82,3 +82,4 @@ adm/export/*
adm/import/*
themes/toutpratique/cache/*
modules/blocknewsletter/*.csv
modules/*/config_.xml

1
modules/advconstructor/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea/

View File

@ -0,0 +1 @@
#TODO:

View File

@ -0,0 +1,334 @@
<?php
if (!defined('_CAN_LOAD_FILES_'))
exit;
include_once dirname(__FILE__).'/classes/AdvConstructorBlock.php';
include_once dirname(__FILE__).'/classes/AdvConstructorHook.php';
class AdvConstructor extends Module
{
public function __construct()
{
$this->name = 'advconstructor';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = 'Antadis';
$this->need_instance = 0;
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Générateur de bloc');
$this->description = $this->l('Générer n\'importe quel type de bloc');
}
/***********************/
/******* Install *******/
/***********************/
public function install()
{
$this->installDb();
$this->createTab();
$this->createFolder();
if ( !parent::install() ) {
$this->uninstallDb();
$this->deleteTab();
$this->uninstall();
return false;
}
Configuration::updateValue('ADVCONSTRUCTOR_HOOKS', '');
Configuration::updateValue('ADVCONSTRUCTOR_TYPE', 'alert,edito,footer,nav,seo');
Configuration::updateValue('ADVCONSTRUCTOR_ICON', 'loupe,message,rouage');
return true;
}
public function uninstall()
{
if ( !parent::uninstall() ) {
return false;
}
Configuration::deleteByName('ADVCONSTRUCTOR_HOOKS');
Configuration::deleteByName('ADVCONSTRUCTOR_TYPE');
Configuration::deleteByName('ADVCONSTRUCTOR_ICON');
$this->uninstallDb();
$this->deleteTab();
return true;
}
public function installDb()
{
$sql = array();
$sql[] =
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advconstructor` (
`id_advconstructor` int(10) unsigned NOT NULL auto_increment,
`skin` varchar(255) NOT NULL,
`active` int(11),
`icon` varchar(255) NOT NULL,
`external` int(10) unsigned NOT NULL,
`date_from` datetime NOT NULL,
`date_to` datetime NOT NULL,
`date_add` datetime NOT NULL DEFAULT "0000-00-00 00:00:00",
`date_upd` datetime NOT NULL DEFAULT "0000-00-00 00:00:00",
PRIMARY KEY (`id_advconstructor`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
$sql[] =
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advconstructor_lang` (
`id_advconstructor` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL,
`title` varchar(255) NOT NULL,
`subtitle` varchar(255) NOT NULL,
`link` varchar(255),
`content` text,
PRIMARY KEY (`id_advconstructor`,`id_lang`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
$sql[] =
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advconstructor_shop` (
`id_advconstructor` int(10) unsigned NOT NULL,
`id_shop` int(10) unsigned NOT NULL,
`type` varchar(255) NOT NULL,
PRIMARY KEY (`id_advconstructor`,`id_shop`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
$sql[] =
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advconstructor_category` (
`id_advconstructor` int(10) unsigned NOT NULL,
`id_category` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_advconstructor`,`id_category`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
$sql[] =
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advconstructor_product` (
`id_advconstructor` int(10) unsigned NOT NULL,
`id_product` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_advconstructor`,`id_product`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
$sql[] =
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advconstructor_hook` (
`id_advconstructor_hook` int(10) unsigned NOT NULL auto_increment,
`id_advconstructor` int(10) unsigned NOT NULL,
`id_hook` int(10) unsigned NOT NULL,
`id_category` int(10) unsigned,
`position` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_advconstructor_hook`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
return $this->uninstallDb() && $this->updateDb($sql);
}
public function uninstallDb()
{
$sql = array();
$sql[] = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'advconstructor` ;';
$sql[] = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'advconstructor_lang` ;';
$sql[] = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'advconstructor_shop` ;';
$sql[] = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'advconstructor_category` ;';
$sql[] = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'advconstructor_product` ;';
$sql[] = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'advconstructor_hook` ;';
return $this->updateDb($sql);
}
public function updateDb( $sqls )
{
foreach ( $sqls as $sql ) {
if ( !Db::getInstance()->execute($sql) ) {
return false;
}
}
return true;
}
public function createFolder()
{
$img_dir = _PS_IMG_DIR_ . 'constructor';
$folder = is_dir($img_dir);
if (!$folder)
{
$folder = mkdir($img_dir, 0755, true);
}
return $folder;
}
public function createTab()
{
$languages = Language::getLanguages();
$new_tab = new Tab();
$new_tab->class_name = 'AdminAdvConstructor';
$new_tab->id_parent = Tab::getCurrentParentId();
$new_tab->module = $this->name;
foreach ( $languages as $language ) {
$new_tab->name[$language['id_lang']] = 'Générateur de bloc';
}
$new_tab->add();
$id_tab_parent = $new_tab->id;
$new_tab = new Tab();
$new_tab->class_name = 'AdminAdvConstructorPosition';
$new_tab->id_parent = $id_tab_parent;
$new_tab->module = $this->name;
foreach ( $languages as $language ) {
$new_tab->name[$language['id_lang']] = 'Positions des blocs';
}
$new_tab->add();
}
public function deleteTab()
{
$idTab = Tab::getIdFromClassName('AdminAdvConstructor');
if ( $idTab ) {
$tab = new Tab($idTab);
$tab->delete();
}
$idTab = Tab::getIdFromClassName('AdminAdvConstructorPosition');
if ( $idTab ) {
$tab = new Tab($idTab);
$tab->delete();
}
}
/************************/
/********* HOOK *********/
/************************/
public function __call( $name, $args = array() )
{
$hookName = str_replace('hook', '', $name);
$id_hook = (int)Hook::getIdByName($hookName);
$hooks_id = explode( ",", Configuration::get('ADVCONSTRUCTOR_HOOKS') );
if (in_array($id_hook, $hooks_id)) {
$html = '';
$id_category = false;
if (Tools::getValue('controller') == 'category') {
$id_category = (int) Tools::getValue('id_category');
}
if ( $blocks = AdvConstructorBlock::getBlocksByHookID($id_hook, $id_category) ) {
foreach ($blocks as $block) {
$this->smarty->assign(
array(
'block' => $block,
'linkimg' =>'modules/advconstructor/img/',
)
);
$html .= $this->display(__FILE__, $block->skin.'.tpl');
}
}
return $html;
}
return NULL;
}
/*********************************/
/********* CONFIGURATION *********/
/*********************************/
public function getContent()
{
$this->_postProcess();
$this->_html = '';
$this->_html .= $this->renderForm();
return $this->_html;
}
protected function _postProcess()
{
if ( Tools::isSubmit('submitConfiguration') )
{
$this->unHook();
$hooks = Tools::getValue('hookBox');
foreach ($hooks as $hook) {
$this->registerHook(Hook::getNameById($hook));
}
$res = Configuration::updateValue('ADVCONSTRUCTOR_TYPE', Tools::getValue('ADVCONSTRUCTOR_TYPE'));
$res &= Configuration::updateValue('ADVCONSTRUCTOR_ICON', Tools::getValue('ADVCONSTRUCTOR_ICON'));
$res &= Configuration::updateValue('ADVCONSTRUCTOR_HOOKS', implode($hooks,','));
if (!$res) {
$errors[] = $this->displayError($this->l('The configuration could not be updated.'));
} else {
Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true).'&conf=6&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name);
}
}
}
public function renderForm()
{
$hooks = array();
$hooks_configuration = explode( ",", Configuration::get('ADVCONSTRUCTOR_HOOKS') );
foreach ( Hook::getHooks() as $hook ) {
$hook['selected'] = (bool) in_array($hook['id_hook'], $hooks_configuration);
$hooks[] = $hook;
}
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Configuration'),
'icon' => 'icon-plus-sign-alt'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Types de blocs'),
'name' => 'ADVCONSTRUCTOR_TYPE',
'value' => Configuration::get('ADVCONSTRUCTOR_TYPE')
),
array(
'type' => 'text',
'label' => $this->l('Icones de blocs'),
'name' => 'ADVCONSTRUCTOR_ICON',
'value' => Configuration::get('ADVCONSTRUCTOR_ICON')
),
array(
'type' => 'hook',
'label' => $this->l('Hooks à afficher'),
'name' => 'hookBox',
'values' => $hooks,
'col' => '9'
)
),
'submit' => array(
'title' => $this->l('Sauvegarder'),
)
),
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$this->fields_form = array();
$helper->module = $this;
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitConfiguration';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues()
);
$helper->override_folder = '/';
return $helper->generateForm(array($fields_form));
}
public function getConfigFieldsValues()
{
$id_shop_group = Shop::getContextShopGroupID();
$id_shop = Shop::getContextShopID();
return array(
'ADVCONSTRUCTOR_TYPE' => Configuration::get('ADVCONSTRUCTOR_TYPE'),
'ADVCONSTRUCTOR_ICON' => Configuration::get('ADVCONSTRUCTOR_ICON')
);
}
protected function unHook()
{
$sql = 'SELECT `id_hook` FROM `'._DB_PREFIX_.'hook_module` WHERE `id_module` = '.(int)$this->id;
$result = Db::getInstance()->executeS($sql);
foreach ($result as $row) {
$this->unregisterHook((int)$row['id_hook']);
$this->unregisterExceptions((int)$row['id_hook']);
}
}
}

View File

@ -0,0 +1,245 @@
<?php
class AdvConstructorBlock extends ObjectModel
{
public $id_advconstructor;
public $title;
public $subtitle;
public $icon;
public $link;
public $external;
public $content;
public $skin;
public $date_from = "0000-00-00 00:00:00";
public $date_to = "0000-00-00 00:00:00";
public $active = true;
public $date_add;
public $date_upd;
public $hooks;
public $categories;
public static $definition = array(
'table' => 'advconstructor',
'primary' => 'id_advconstructor',
'multilang' => true,
'fields' => array(
'title' => array(
'type' => ObjectModel :: TYPE_STRING,
'lang' => true,
'validate' => 'isString',
'required' => TRUE
),
'subtitle' => array(
'type' => ObjectModel :: TYPE_STRING,
'lang' => true,
'validate' => 'isString'
),
'icon' => array(
'type' => ObjectModel :: TYPE_STRING,
'validate' => 'isString'
),
'content' => array(
'type' => ObjectModel :: TYPE_HTML,
'lang' => true,
'validate' => 'isString'
),
'link' => array(
'type' => ObjectModel :: TYPE_STRING,
'lang' => true,
'validate' => 'isString'
),
'external' => array(
'type' => ObjectModel :: TYPE_INT,
'validate' => 'isBool'
),
'skin' => array(
'type' => ObjectModel :: TYPE_STRING,
'validate' => 'isString'
),
'active' => array(
'type' => ObjectModel :: TYPE_INT,
'validate' => 'isBool'
),
'date_from' => array(
'type' => ObjectModel :: TYPE_DATE
),
'date_to' => array(
'type' => ObjectModel :: TYPE_DATE
),
'date_add' => array(
'type' => ObjectModel :: TYPE_DATE
),
'date_upd' => array(
'type' => ObjectModel :: TYPE_DATE
)
)
);
public function getHooks()
{
if (!isset($this->hooks)) {
$this->hooks = array();
foreach (Db::getInstance()->executeS('
SELECT `id_hook`
FROM `' . _DB_PREFIX_ . 'advconstructor_hook`
WHERE `id_advconstructor` = ' . $this->id . '
') as $hook) {
$this->hooks[] = $hook['id_hook'];
}
}
return $this->hooks;
}
public function getCategory()
{
if (!isset($this->categories)) {
$this->categories = array();
foreach (Db::getInstance()->executeS('
SELECT `id_category`
FROM `' . _DB_PREFIX_ . 'advconstructor_category`
WHERE `id_advconstructor` = ' . $this->id . '
') as $category) {
$this->categories[] = $category['id_category'];
}
}
return $this->categories;
}
public function addHooksAssociation( $hooks )
{
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'advconstructor_hook`
WHERE `id_advconstructor` = '.(int) $this->id.'
AND id_hook NOT IN ('.implode(',',$hooks).')
');
foreach ( $hooks as $hook ) {
if ( !AdvConstructorHook::associationHookExist( $this->id, $hook ) ) {
$advconstructor_hook = new AdvConstructorHook();
$advconstructor_hook->id_advconstructor = (int) $this->id;
$advconstructor_hook->id_hook = (int) $hook;
$advconstructor_hook->add();
$advconstructor_hook->refreshPositions();
}
}
}
public function addCategoryAssociation( $categories )
{
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'advconstructor_category`
WHERE `id_advconstructor` = '.(int) $this->id.'
');
foreach ( $categories as $category ) {
if ( !$this->associationCategoryExist( $category ) ) {
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'advconstructor_category`
(`id_advconstructor`,`id_category`)
VALUES ('.(int) $this->id.','.$category.')
');
}
}
}
public static function getBlocksByHookID( $id_hook, $id_category )
{
$now = date('Y-m-d H:i:s');
$sql = 'SELECT id_advconstructor, position FROM `' . _DB_PREFIX_ . 'advconstructor_hook` WHERE id_hook ='.(int)$id_hook;
if ( $blocks_id = Db::getInstance()->executeS($sql) ) {
$blocks = array();
foreach ($blocks_id as $block_id) {
$blocks[] = $block_id['id_advconstructor'];
}
$collection = new Collection('AdvConstructorBlock', Context::getContext()->language->id);
$collection->Sqlwhere('a0.date_from <= IF(a0.date_from = "0000-00-00 00:00:00","0000-00-00 00:00:00","' . $now . '")' );
$collection->Sqlwhere('a0.date_to >= IF(a0.date_to = "0000-00-00 00:00:00","0000-00-00 00:00:00","' . $now . '")' );
$collection->Sqlwhere('a0.id_advconstructor IN ('.implode(',',$blocks).')' );
if (Shop::isFeatureActive()) {
$collection->Sqlwhere('a0.`id_advconstructor` IN (
SELECT sa.`id_advconstructor`
FROM `' . _DB_PREFIX_ . 'advconstructor_shop` sa
WHERE sa.id_shop IN (' . implode(', ', Shop::getContextListShopID()) . ')
)');
}
$res = $collection->getAll();
$temp = array();
foreach ( $res as $row ) {
foreach ($blocks_id as $block_id) {
if ( $block_id['id_advconstructor'] == $row->id ) {
$show = false;
if ( !self::existInOneCategory( $row->id ) ) {
$show = true;
} else {
if ( $id_category && self::testCategoryAssociation( $row->id, $id_category ) ) {
$show = true;
}
}
if ( $show ){
$temp[$block_id['position']] = $row;
}
}
}
}
ksort($temp);
return $temp;
} else {
return false;
}
}
public static function getBlocksByHookIDLite( $id_hook )
{
$sql = 'SELECT id_advconstructor FROM `' . _DB_PREFIX_ . 'advconstructor_hook` WHERE id_hook ='.(int)$id_hook.' ORDER BY position ASC';
if ( $blocks_id = Db::getInstance()->executeS($sql) ) {
$blocks = array();
foreach ($blocks_id as $block_id) {
$blocks[] = $block_id['id_advconstructor'];
}
return $blocks;
} else {
return false;
}
}
public function associationCategoryExist( $id_category )
{
$sql = 'SELECT `id_advconstructor`
FROM `'._DB_PREFIX_.'advconstructor_category`
WHERE `id_category` = '.(int) $id_category.'
AND `id_advconstructor` = '.(int) $this->id;
if (!$id = Db::getInstance()->getRow($sql)) {
return false;
} else {
return true;
}
}
public static function existInOneCategory( $id_advconstructor ){
$sql = 'SELECT `id_advconstructor`
FROM `'._DB_PREFIX_.'advconstructor_category`
WHERE `id_advconstructor` = '.(int) $id_advconstructor;
if (!$id = Db::getInstance()->getRow($sql)) {
return false;
} else {
return true;
}
}
public static function testCategoryAssociation( $id_advconstructor, $id_category ){
$sql = 'SELECT `id_advconstructor`
FROM `'._DB_PREFIX_.'advconstructor_category`
WHERE `id_category` = '.$id_category.' AND
`id_advconstructor` = '.(int) $id_advconstructor;
if (!$id = Db::getInstance()->getRow($sql)) {
return false;
} else {
return true;
}
}
}

View File

@ -0,0 +1,94 @@
<?php
class AdvConstructorHook extends ObjectModel
{
public $id_advconstructor_hook;
public $id_advconstructor;
public $id_hook;
public $position = 0;
public static $definition = array(
'table' => 'advconstructor_hook',
'primary' => 'id_advconstructor_hook',
'fields' => array(
'id_advconstructor' => array(
'type' => ObjectModel :: TYPE_INT
),
'id_hook' => array(
'type' => ObjectModel :: TYPE_INT
),
'position' => array(
'type' => ObjectModel :: TYPE_INT
)
)
);
public function updatePosition($way, $position)
{
$sql = 'SELECT `position`, `id_advconstructor_hook`
FROM `'._DB_PREFIX_.'advconstructor_hook`
WHERE `id_hook` = '.(int)$this->id_hook.'
ORDER BY `position` ASC';
$res = Db::getInstance()->executeS($sql);
if (!$res)
return false;
foreach ($res as $row)
if ((int)$row['id_advconstructor_hook'] == (int)$this->id)
$moved_row = $row;
if (!isset($moved_row) || !isset($position))
return false;
// < and > statements rather than BETWEEN operator
// since BETWEEN is treated differently according to databases
$res = Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'advconstructor_hook`
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
WHERE `id_hook` = '.(int)$this->id_hook.'
AND `position`
'.($way
? '> '.(int)$moved_row['position'].' AND `position` <= '.(int)$position
: '< '.(int)$moved_row['position'].' AND `position` >= '.(int)$position)
)
&& Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'advconstructor_hook`
SET `position` = '.(int)$position.'
WHERE `id_advconstructor_hook`='.(int)$moved_row['id_advconstructor_hook']
);
$this->refreshPositions();
return $res;
}
public function refreshPositions(){
$sql = 'SELECT `id_advconstructor_hook`
FROM `'._DB_PREFIX_.'advconstructor_hook`
WHERE `id_hook` = '.(int)$this->id_hook.'
ORDER BY `position` ASC';
if (!$blocks = Db::getInstance()->executeS($sql))
return false;
$pos=0;
foreach ($blocks as $block) {
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'advconstructor_hook`
SET `position` = '.(int)$pos.'
WHERE `id_advconstructor_hook`='.(int)$block['id_advconstructor_hook']);
$pos++;
}
}
public static function associationHookExist( $id_advconstructor, $id_hook )
{
$sql = 'SELECT `id_advconstructor_hook`
FROM `'._DB_PREFIX_.'advconstructor_hook`
WHERE `id_hook` = '.(int) $id_hook.'
AND `id_advconstructor` = '.(int) $id_advconstructor;
if (!$id = Db::getInstance()->getRow($sql)) {
return false;
} else {
return $id['id_advconstructor_hook'];
}
}
}

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>advconstructor</name>
<displayName><![CDATA[G&eacute;n&eacute;rateur de bloc]]></displayName>
<version><![CDATA[1.0]]></version>
<description><![CDATA[G&eacute;n&eacute;rer n&#039;importe quel type de bloc]]></description>
<author><![CDATA[Antadis]]></author>
<tab><![CDATA[front_office_features]]></tab>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@ -0,0 +1,420 @@
<?php
include_once dirname(__FILE__).'/../../classes/AdvConstructorBlock.php';
include_once dirname(__FILE__).'/../../classes/AdvConstructorHook.php';
class AdminAdvConstructorController extends ModuleAdminController
{
public function __construct()
{
$this->table = 'advconstructor';
$this->className = 'AdvConstructorBlock';
$this->identifier = 'id_advconstructor';
$this->lang = true;
$this->deleted = false;
$this->bootstrap = true;
$this->explicitSelect = true;
$this->context = Context::getContext();
$this->_defaultOrderBy = 'id_advconstructor';
if ( Tools::getValue('hookid') ) {
$blocks = AdvConstructorBlock::getBlocksByHookIDLite(Tools::getValue('hookid'));
$blocks_id = "0";
if($blocks){
$blocks_id = implode(',',$blocks);
}
$this->_where = ' AND a.`id_advconstructor` IN ('.$blocks_id.')';
}
parent::__construct();
$this->fields_list = array(
'id_advconstructor' => array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 25,
'filter_key' => 'a!id_advconstructor'
),
'title' => array(
'title' => $this->l('Nom')
),
'skin' => array(
'title' => $this->l('Apparence')
),
'active' => array(
'title' => $this->l('Activé'),
'active' => 'status',
'filter_key' => 'a!active',
'align' => 'text-center',
'type' => 'bool',
'class' => 'fixed-width-sm',
'orderby' => false
),
);
$this->actions = array('edit','delete');
$this->bulk_actions = array(
'delete' => array(
'text' => $this->l('Supprimer la liste'),
'icon' => 'icon-trash',
'confirm' => $this->l('Supprimer les blocs selectionné?')
)
);
$this->specificConfirmDelete = false;
}
public function initPageHeaderToolbar()
{
parent::initPageHeaderToolbar();
if ($this->display == 'edit' || $this->display == 'add') {
$this->page_header_toolbar_btn['back_to_list'] = array(
'href' => self::$currentIndex.'&token='.$this->token,
'desc' => $this->l('Retour à la liste', null, null, false),
'icon' => 'process-icon-back'
);
}
$this->page_header_toolbar_btn['new_constructor'] = array(
'href' => self::$currentIndex.'&addadvconstructor&token='.$this->token,
'desc' => $this->l('Ajouter un nouveau bloc', null, null, false),
'icon' => 'process-icon-new'
);
$this->page_header_toolbar_btn['position'] = array(
'href' => $this->context->link->getAdminLink('AdminAdvConstructorPosition'),
'desc' => $this->l('Gérer les positions', null, null, false),
'icon' => 'process-icon-modules-list'
);
}
public function renderForm()
{
if (!($obj = $this->loadObject(true))) {
return;
}
$context = Context::getContext();
$hooks_id = explode( ",", Configuration::get('ADVCONSTRUCTOR_HOOKS') );
$hooks = array();
foreach ($hooks_id as $hook_id) {
$hook = new Hook($hook_id, $context->language->id);
$hooks[] = array(
'id_hook' => $hook->id,
'name' => $hook->name,
'title' => $hook->title,
);
}
$block_hooks = array();
if (!empty($this->object->id)) {
$block_hooks = $this->object->getHooks();
}
foreach ($hooks as $key => $hook) {
$hook['selected'] = (bool) in_array($hook['id_hook'], $block_hooks);
$hooks[$key] = $hook;
}
$skins = array();
foreach ( explode(',', Configuration::get('ADVCONSTRUCTOR_TYPE')) as $skin ) {
$skins[] = array(
'id' => $skin,
'name' => $skin
);
}
$icons = array();
$icons[] = array('id' => '', 'name' => 'Standard');
foreach ( explode(',', Configuration::get('ADVCONSTRUCTOR_ICON')) as $key => $icon ) {
$icons[] = array(
'id' => $key+1,
'name' => ucfirst($icon)
);
}
if ( Tools::isSubmit('id_advconstructor') ) {
$id_advconstructor = (int)Tools::getValue('id_advconstructor');
$image = __PS_BASE_URI__.'img/constructor/image/'.$id_advconstructor ;
$hover = __PS_BASE_URI__.'img/constructor/hover/'.$id_advconstructor ;
} else {
$image = "noimg" ;
$hover = "noimg" ;
}
$selected_categories = !empty($this->object->id) ? $this->object->getCategory() : array();
$this->fields_form = array(
'multilang' => true,
'tinymce' => true,
'legend' => array(
'title' => $this->l('Bloc'),
),
'submit' => array(
'name' => 'submitBlock',
'title' => $this->l('Enregistrer')
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Titre'),
'name' => 'title',
'lang' => true,
'required' => true,
'form_group_class' => 'fieldhide input_info',
'size' => 255
),
array(
'type' => 'text',
'label' => $this->l('Label du lien'),
'name' => 'subtitle',
'lang' => true,
'form_group_class' => 'fieldhide input_info',
'size' => 255
),
array(
'type' => 'text',
'label' => $this->l('Lien'),
'name' => 'link',
'lang' => true,
'form_group_class' => 'fieldhide input_info',
'size' => 255
),
array(
'type' => 'switch',
'label' => $this->l('Lien externe'),
'name' => 'external',
'required' => false,
'is_bool' => true,
'form_group_class' => 'fieldhide input_info',
'values' => array(
array(
'id' => 'external_on',
'value' => 1,
'label' => $this->l('Yes')
),
array(
'id' => 'external_off',
'value' => 0,
'label' => $this->l('No')
)
)
),
array(
'type' => 'textarea',
'label' => $this->l('Contenu'),
'name' => 'content',
'form_group_class' => 'fieldhide input_info',
'autoload_rte' => true,
'lang' => true,
'cols' => 60,
'rows' => 120
),
array(
'type' => 'datetime',
'label' => $this->l('Date de début'),
'name' => 'date_from',
'form_group_class' => 'fieldhide input_dates',
'size' => 33,
),
array(
'type' => 'datetime',
'label' => $this->l('Date de fin'),
'name' => 'date_to',
'form_group_class' => 'fieldhide input_dates',
'size' => 33,
),
array(
'type' => 'select',
'label' => $this->l('Apparence du bloc'),
'name' => 'skin',
'required' => true,
'form_group_class' => 'fieldhide input_association',
'options' => array(
'query' => $skins,
'id' => 'id',
'name' => 'name'
)
),
array(
'type' => 'hook',
'label' => $this->l('Hook'),
'name' => 'hookBox',
'required' => true,
'form_group_class' => 'fieldhide input_association',
'values' => $hooks,
'col' => '9',
),
array(
'type' => 'categories',
'label' => $this->l('Parent category'),
'name' => 'categoryBox',
'tree' => array(
'id' => 'categories-tree',
'selected_categories' => $selected_categories,
'use_checkbox' => true,
'root_category' => $context->shop->getCategory()
),
'col' => '9',
'form_group_class' => 'fieldhide input_association'
),
array(
'type' => 'select',
'label' => $this->l('Type d\'affichage'),
'name' => 'icon',
'required' => FALSE,
'form_group_class' => 'fieldhide input_img',
'options' => array(
'query' => $icons,
'id' => 'id',
'name' => 'name'
)
),
array(
'type' => 'file',
'label' => $this->l('Choisisser une image'),
'name' => 'image',
'form_group_class' => 'fieldhide input_img',
'url' => $image
),
array(
'type' => 'switch',
'label' => $this->l('Actif'),
'name' => 'active',
'required' => false,
'class' => 't',
'form_group_class' => 'fieldhide input_info',
'is_bool' => true,
'values' => array(
array(
'id' => 'active_on',
'value' => 1
),
array(
'id' => 'active_off',
'value' => 0
)
),
),
)
);
if (Shop::isFeatureActive()) {
$this->fields_form['input'][] = array(
'type' => 'shop',
'label' => $this->l('Boutique'),
'name' => 'checkBoxShopAsso',
'form_group_class' => 'fieldhide input_association'
);
}
return parent::renderForm();
}
public function init()
{
parent::init();
if (Shop::getContext() == Shop::CONTEXT_SHOP) {
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_. $this->table .'_shop` sa ON (a.`' . $this->identifier . '` = sa.`' . $this->identifier . '` AND sa.id_shop = '.(int)$this->context->shop->id.') ';
}
if (Shop::getContext() == Shop::CONTEXT_SHOP && Shop::isFeatureActive()) {
$this->_where = ' AND sa.`id_shop` = '.(int)Context::getContext()->shop->id;
}
}
public function postProcess()
{
$result = parent::postProcess();
if ( Validate::isLoadedObject($result) ) {
$this->generatePicture($result);
$result->addHooksAssociation(Tools::getValue('hookBox'));
$result->addCategoryAssociation(Tools::getValue('categoryBox'));
$this->redirect_after = self::$currentIndex.'&id_advconstructor='.(int)$result->id.'&update'.$this->table.'&token='.$this->token;
}
return $result;
}
public function generatePicture($object)
{
$languages = Language::getLanguages(false);
foreach ($languages as $language) {
$tabimgs = array(
"image",
"hover"
);
foreach ( $tabimgs as $tabimg ) {
$namePost = $tabimg.'_'.$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' ) {
if(!is_dir(_PS_IMG_DIR_.'constructor/'.$tabimg)) {
mkdir(_PS_IMG_DIR_.'constructor/'.$tabimg, 0775);
}
$res = move_uploaded_file($fileTemp, _PS_IMG_DIR_.'constructor/'.$tabimg.'/'. $object->id . '_'.$language['id_lang'].'.jpg');
if(!$res)
$this->errors[] = sprintf(Tools::displayError('An error occured during upload of file %s'), $object->id . '.jpg');
else
$this->confirmations[] = sprintf($this->l('File %s has been uploaded'), $object->id . '.jpg');
} else
$this->errors[] = sprintf(Tools::displayError('File %s have not good extension, only .jpg or .png'), $object->id . '.jpg');
}
}
}
}
protected function updateAssoShop($id_object)
{
if (!Shop::isFeatureActive()) {
return;
}
$assos_data = $this->getSelectedAssoShop($this->table, $id_object);
$exclude_ids = $assos_data;
foreach (Db::getInstance()->executeS('SELECT id_shop FROM ' . _DB_PREFIX_ . 'shop') as $row) {
if (!$this->context->employee->hasAuthOnShop($row['id_shop'])) {
$exclude_ids[] = $row['id_shop'];
}
}
Db::getInstance()->delete($this->table . '_shop', '`' . $this->identifier . '` = ' . (int) $id_object . ($exclude_ids ? ' AND id_shop NOT IN (' . implode(', ', $exclude_ids) . ')' : ''));
$insert = array();
foreach ($assos_data as $id_shop) {
$insert[] = array(
$this->identifier => $id_object,
'id_shop' => (int) $id_shop,
);
}
return Db::getInstance()->insert($this->table . '_shop', $insert, FALSE, TRUE, Db::INSERT_IGNORE);
}
protected function getSelectedAssoShop($table)
{
if (!Shop::isFeatureActive()) {
return array();
}
$shops = Shop::getShops(TRUE, NULL, TRUE);
if (count($shops) == 1 && isset($shops[0])) {
return array($shops[0], 'shop');
}
$assos = array();
if (Tools::isSubmit('checkBoxShopAsso_' . $table)) {
foreach (Tools::getValue('checkBoxShopAsso_' . $table) as $id_shop => $value) {
$assos[] = (int) $id_shop;
}
} else if (Shop::getTotalShops(FALSE) == 1) {
// if we do not have the checkBox multishop, we can have an admin with only one shop and being in multishop
$assos[] = (int) Shop::getContextShopID();
}
return $assos;
}
}

View File

@ -0,0 +1,159 @@
<?php
include_once dirname(__FILE__).'/../../classes/AdvConstructorBlock.php';
include_once dirname(__FILE__).'/../../classes/AdvConstructorHook.php';
class AdminAdvConstructorPositionController extends ModuleAdminController
{
public $_step = 0;
public $_hook = 0;
public function __construct()
{
$this->bootstrap = true;
parent::__construct();
}
public function initPageHeaderToolbar()
{
parent::initPageHeaderToolbar();
$this->page_header_toolbar_btn['back_to_list'] = array(
'href' => $this->context->link->getAdminLink('AdminAdvConstructor'),
'desc' => $this->l('Retour à la liste de bloc', null, null, false),
'icon' => 'process-icon-back'
);
if ($this->display != 'edit' && $this->display != 'add') {
$this->page_header_toolbar_btn['back_to_choice'] = array(
'href' => $this->context->link->getAdminLink('AdminAdvConstructorPosition'),
'desc' => $this->l('Retour au choix du hook', null, null, false),
'icon' => 'process-icon-back'
);
}
}
public function renderForm()
{
$context = Context::getContext();
$hooks_id = explode( ",", Configuration::get('ADVCONSTRUCTOR_HOOKS') );
$hooks = array();
foreach ($hooks_id as $hook_id) {
$hook = new Hook($hook_id, $context->language->id);
$hooks[] = array(
'id' => $hook->id,
'name' => $hook->name
);
}
$this->fields_form = array(
'multilang' => true,
'tinymce' => true,
'legend' => array(
'title' => $this->l('Choissisez le hook'),
),
'submit' => array(
'name' => 'submitHook',
'title' => $this->l('Changer les positions')
),
'input' => array(
'icon' => array(
'type' => 'select',
'label' => $this->l('Hook'),
'name' => 'hook',
'required' => FALSE,
'options' => array(
'query' => $hooks,
'id' => 'id',
'name' => 'name'
)
)
)
);
return parent::renderForm();
}
public function renderList()
{
$context = Context::getContext();
$this->table = 'advconstructor_hook';
$this->className = 'AdvConstructorHook';
$this->identifier = 'id_advconstructor_hook';
$this->lang = false;
$this->deleted = false;
$this->bootstrap = true;
$this->explicitSelect = true;
$this->context = Context::getContext();
$this->_defaultOrderBy = 'position';
$this->position_identifier = 'ID';
$this->_select = "a.`id_advconstructor`, c.`title` AS `NAME`";
$this->_where = ' AND a.`id_hook` = '.$this->_hook;
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'advconstructor_lang` c ON (c.`id_advconstructor` = a.`id_advconstructor` AND c.`id_lang` = '.$context->language->id.') ';
$this->fields_list = array(
'id_advconstructor_hook' => array(
'title' => $this->l('ID de la position'),
'align' => 'center',
'width' => 25
),
'id_advconstructor' => array(
'title' => $this->l('ID du bloc'),
'align' => 'center',
'width' => 25
),
'NAME' => array(
'title' => $this->l('Nom du bloc'),
'align' => 'center'
),
'position' => array(
'title' => $this->l('Position'),
'align' => 'center',
'position' => 'position',
'filter_key' => 'a!position'
)
);
return parent::renderList();
}
public function postProcess()
{
if ( Tools::isSubmit("submitHook") ) {
$this->_step = 1;
$this->_hook = Tools::getValue('hook');
$this->display = 'list';
} else {
$this->display = 'add';
}
return parent::postProcess();
}
public function ajaxProcessUpdatePositions()
{
$way = (int)(Tools::getValue('way'));
$id = (int)(Tools::getValue('id'));
$positions = Tools::getValue('advconstructor_hook');
$page = (int)Tools::getValue('page');
$selected_pagination = (int)Tools::getValue('selected_pagination');
$obj = 'position hook';
if ( is_array($positions) ) {
foreach ($positions as $position => $value) {
$pos = explode('_', $value);
if (isset($pos[2]) && (int)$pos[2] === $id) {
$hook_position = new AdvConstructorHook((int)$pos[2]);
if (isset($position) && $hook_position->updatePosition( $way, $position ) ) {
die(true);
} else {
die('{"hasError" : true, errors : "Cannot update blocks position"}');
}
}
}
} else {
die('{"hasError" : true, errors : "Cannot update blocks position"}');
}
}
}

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,48 @@
{extends file="helpers/form/form.tpl"}
{block name="input"}
{if $input.type == 'hook'}
{assign var=hooks value=$input.values}
{if count($hooks) && isset($hooks)}
<div class="row">
<div class="col-lg-12">
<table class="table table-bordered">
<thead>
<tr>
<th class="fixed-width-xs">
<span class="title_box">
<input type="checkbox" name="checkme" id="checkme" onclick="checkDelBoxes(this.form, 'hookBox[]', this.checked)" />
</span>
</th>
<th class="fixed-width-xs"><span class="title_box">{l s='ID' mod='advconstructor'}</span></th>
<th>
<span class="title_box">
{l s='Nom du hook' mod='advconstructor'}
</span>
</th>
</tr>
</thead>
<tbody>
{foreach $hooks as $key => $hook}
<tr>
<td>
{assign var=id_checkbox value=hookBox|cat:'_'|cat:$hook['id_hook']}
<input type="checkbox" name="hookBox[]" class="hookBox" id="{$id_checkbox}" value="{$hook['id_hook']}" {if $hook['selected']}checked="checked"{/if} />
</td>
<td>{$hook['id_hook']}</td>
<td>
<label for="{$id_checkbox}">{$hook['name']} ({$hook['title']})</label>
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
</div>
{else}
<p>
{l s='Pas de hook' mod='advconstructor'}
</p>
{/if}
{/if}
{$smarty.block.parent}
{/block}

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,109 @@
{extends file="helpers/form/form.tpl"}
{block name="fieldset" prepend}
<div class="productTabs pvsaleadm">
<ul class="tab nav nav-tabs">
<li class="tab-row active">
<a class="tab-page" id="cart_rule_link_informations">
<i class="icon-info"></i> {l s='Informations' mod='advconstructor'}
</a>
</li>
<li class="tab-row">
<a class="tab-page" id="cart_rule_link_association">
<i class="icon-random"></i> {l s='Associations' mod='advconstructor'}
</a>
</li>
<li class="tab-row">
<a class="tab-page" id="cart_rule_link_images">
<i class="icon-picture"></i> {l s='Images' mod='advconstructor'}
</a>
</li>
<li class="tab-row">
<a class="tab-page" id="cart_rule_link_dates">
<i class="icon-calendar"></i> {l s='Dates' mod='advconstructor'}
</a>
</li>
</ul>
</div>
<script>
$(document).ready(function(){
$('.fieldhide').hide();
$('.input_info').show();
$('#cart_rule_link_images').click(function(){
$('.fieldhide').hide();
$('.input_img').show();
$('.tab-row').removeClass('active');
$(this).parent().addClass('active');
});
$('#cart_rule_link_informations').click(function(){
$('.fieldhide').hide();
$('.input_info').show();
$('.tab-row').removeClass('active');
$(this).parent().addClass('active');
});
$('#cart_rule_link_dates').click(function(){
$('.fieldhide').hide();
$('.input_dates').show();
$('.tab-row').removeClass('active');
$(this).parent().addClass('active');
});
$('#cart_rule_link_association').click(function(){
$('.fieldhide').hide();
$('.input_association').show();
$('.tab-row').removeClass('active');
$(this).parent().addClass('active');
});
});
</script>
{/block}
{block name="input"}
{if $input.type == 'hook'}
{assign var=hooks value=$input.values}
{if count($hooks) && isset($hooks)}
<div class="row">
<div class="col-lg-12">
<table class="table table-bordered">
<thead>
<tr>
<th class="fixed-width-xs">
<span class="title_box">
<input type="checkbox" name="checkme" id="checkme" onclick="checkDelBoxes(this.form, 'hookBox[]', this.checked)" />
</span>
</th>
<th class="fixed-width-xs"><span class="title_box">{l s='ID' mod='advconstructor'}</span></th>
<th>
<span class="title_box">
{l s='Nom du hook' mod='advconstructor'}
</span>
</th>
</tr>
</thead>
<tbody>
{foreach $hooks as $key => $hook}
<tr>
<td>
{assign var=id_checkbox value=hookBox|cat:'_'|cat:$hook['id_hook']}
<input type="checkbox" name="hookBox[]" class="hookBox" id="{$id_checkbox}" value="{$hook['id_hook']}" {if $hook['selected']}checked="checked"{/if} />
</td>
<td>{$hook['id_hook']}</td>
<td>
<label for="{$id_checkbox}">{$hook['name']} ({$hook['title']})</label>
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
</div>
{else}
<p>
{l s='Pas de hook' mod='advconstructor'}
</p>
{/if}
{/if}
{$smarty.block.parent}
{/block}

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,54 @@
{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"}
<img src="{$url}_{$language.id_lang}.jpg" 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>

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -0,0 +1,3 @@
<div class="col-xs-12">
<img src="{$base_dir}img/constructor/image/{$block->id}_{$cookie->id_lang}.jpg" />
</div>

View File

@ -0,0 +1,5 @@
<div class="col-xs-12">
<h1>{$block->title}</h1>
<h2>{$block->subtitle}</h2>
{$block->content}
</div>

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@ -280,7 +280,63 @@ body.content_only { margin: 0 }
}
}
/************ ADV CONSTRUCTOR *************/
#constructorLink {
margin-top: 30px;
}
#constructorLink div .inner {
background-color: #f5f0f1;
padding: 45px 0px 45px 30px;
overflow: hidden;
height: 270px;
}
#constructorLink div .inner .img { width: 168px; height: 100%;position: relative; position: relative;
float: right;}
#constructorLink div:nth-child(2) .inner { background-color: #edf4f3; }
#constructorLink div img { position: absolute; left: -5px;}
#constructorLink .btn { background-color: #464646; margin-top: 20px; font-size: 24px; line-height: 30px; }
#constructorLink .btn:hover { background-color: #e44e58; }
#constructorLink .title {
font-family: 'pompiere_regular';
font-size: 35px;
text-transform: uppercase;
margin-top: 0;
margin-bottom: 20px;
}
#constructorLink p {
color : #464646;
}
#best_sales .title {
text-align: center;
margin-bottom: 30px;
margin-top: 30px;
font-size: 36px;
border-bottom: 3px solid #333333;
padding-bottom: 10px;
}
#index #best_sales h2:not(.title) {display: none;}
@media(max-width: 1170px) {
#constructorLink div .inner { height: 350px; }
#constructorLink div .inner p { height: 110px; }
}
@media(max-width: 990px) {
#constructorLink div .inner .img { width: 120px; }
#constructorLink div .inner .img img { left: -30px; }
}
@media(max-width: 767px) {
#constructorLink .title { font-size: 30px; }
#constructorLink div .inner p { display: none; }
#constructorLink div .inner .img { height: 150px; float:none; margin: auto;}
#constructorLink div .inner .img img { max-width: 100%; width: 120px; float: none; margin: auto; left:0 ;}
#constructorLink div .inner { text-align: center; padding: 20px 15px 20px 15px; height: auto; }
#constructorLink .btn { margin: auto; }
}
@media(max-width: 500px) {
#constructorLink { display: none; }
}
#main_menu {
font-family: 'pt_sansbold';
@ -617,7 +673,7 @@ body .ac_results {
color: #222222;
font-family: 'vidaloka';
letter-spacing: -1px;
font-size: 48px;
font-size: 36px;
margin-top: 20px;
margin-bottom: 25px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@ -1,4 +1,5 @@
<div class="intro_top">
{*<div class="intro_top">
<div class="container">
<div class="intro_home">
<h1>{l s='Mes astuces en un clic'}</h1>
@ -9,8 +10,19 @@
</div>
</div>
</div>
</div>*}
<!-- Bloc constructor -->
<div id="constructorLink" class="container">
<div class="row">
{hook h='displayConstructorLink'}
</div>
</div>
<div class="container">
<div id="best_sales">
<h2 class="title">{l s='Les indispensables du moment'}</h2>
{hook h='displayHome' mod='blockbestsellers'}
</div>
</div>
<!-- Blocs -->
<main class="container">
<div class="pub pub_header">

View File

@ -0,0 +1,9 @@
<div class="encart animated-full">
<div class="inner" style="background-image: url('{$base_dir}img/constructor/image/{$block->id}_{$cookie->id_lang}.jpg')">
<a href="{$block->link}">
<div class="content">
<span>{$block->title}</span>
</div>
</a>
</div>
</div>

View File

@ -0,0 +1,13 @@
<div class="col-xs-6 col-xxs-12">
<div class="inner">
<div class="img">
<img src="{$base_dir}img/constructor/image/{$block->id}_{$cookie->id_lang}.jpg" />
</div>
<h2 class="title">{$block->title}</h2>
{$block->content}
<a href="{$block->link}" class="btn">
{$block->subtitle}
</a>
</div>
</div>

View File

@ -0,0 +1,13 @@
<div class="md6 animated-full">
<div class="inner">
<div class="content">
<span class="title">{$block->title}</span>
<div class="desc">
{$block->content}
</div>
</div>
{if !empty($block->link)}
<a class="btn" href="{$block->link}">{$block->subtitle}</a>
{/if}
</div>
</div>