Merge branch 'ticket/r13756-slider' into 'master'
Ticket/r13756 slider See merge request !3
This commit is contained in:
commit
d29ac65cee
173
modules/advslider/advslider.php
Normal file
173
modules/advslider/advslider.php
Normal file
@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_CAN_LOAD_FILES_'))
|
||||
exit;
|
||||
|
||||
include_once(dirname(__FILE__) . '/classes/AdvSlide.php');
|
||||
|
||||
class AdvSlider extends Module
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'advslider';
|
||||
$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('Slider avancé');
|
||||
$this->description = $this->l('Gestion du slider avec spécificités PrivilegeDeMarque');
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
$sql[] =
|
||||
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advslider` (
|
||||
`id_slide` int(10) unsigned NOT NULL auto_increment,
|
||||
`position` INT(11) UNSIGNED NOT NULL default 0,
|
||||
`active` INT(11) UNSIGNED NOT NULL default 1,
|
||||
`light` INT(11) UNSIGNED NOT NULL default 1,
|
||||
PRIMARY KEY (`id_slide`)
|
||||
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
|
||||
|
||||
$sql[] =
|
||||
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advslider_lang` (
|
||||
`id_slide` int(10) unsigned NOT NULL,
|
||||
`id_lang` int(10) unsigned NOT NULL,
|
||||
`title` varchar(255) NOT NULL,
|
||||
`subtitle` varchar(255) NOT NULL,
|
||||
`label` varchar(255) NOT NULL,
|
||||
`url` varchar(255),
|
||||
`description` TEXT,
|
||||
PRIMARY KEY (`id_slide`,`id_lang`)
|
||||
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
|
||||
|
||||
$sql[] =
|
||||
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advslider_shop` (
|
||||
`id_slide` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_shop` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_slide`, `id_shop`)
|
||||
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
|
||||
|
||||
$sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advslider_group` (
|
||||
`id_slide` int(11) NOT NULL,
|
||||
`id_group` int(11) NOT NULL
|
||||
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
|
||||
|
||||
$sql[] = "ALTER TABLE `ps_advslider` ADD `start_at` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `light`,
|
||||
ADD `end_at` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `start_at`;";
|
||||
|
||||
foreach ($sql as $_sql) {
|
||||
Db::getInstance()->Execute($_sql);
|
||||
}
|
||||
|
||||
$tab = new Tab();
|
||||
$tab->class_name = 'AdminAdvSlider';
|
||||
$tab->id_parent = Tab::getCurrentParentId();
|
||||
$tab->module = $this->name;
|
||||
$languages = Language::getLanguages();
|
||||
foreach ($languages as $language) {
|
||||
$tab->name[$language['id_lang']] = 'Slider';
|
||||
}
|
||||
|
||||
$img_dir = _PS_IMG_DIR_ . 'slider';
|
||||
$folder = is_dir($img_dir);
|
||||
if (!$folder) {
|
||||
$folder = mkdir($img_dir, 0755, true);
|
||||
}
|
||||
|
||||
return parent::install()
|
||||
&& $tab->add()
|
||||
&& $this->registerHook('displaySlider')
|
||||
&& $this->registerHook('displayHeader')
|
||||
&& $this->registerHook('actionRefreshSlider')
|
||||
&& $folder;
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
$sql = 'DROP TABLE IF EXISTS
|
||||
`' . _DB_PREFIX_ . 'advslider_lang`,
|
||||
`' . _DB_PREFIX_ . 'advslider_shop`,
|
||||
`' . _DB_PREFIX_ . 'advslider`,
|
||||
`' . _DB_PREFIX_ . 'advslider_group`
|
||||
';
|
||||
|
||||
Db::getInstance()->Execute($sql);
|
||||
|
||||
$idTab = Tab::getIdFromClassName('AdminAdvSlider');
|
||||
if ($idTab) {
|
||||
$tab = new Tab($idTab);
|
||||
$tab->delete();
|
||||
}
|
||||
|
||||
return parent::uninstall();
|
||||
}
|
||||
|
||||
public function getHookController($hook_name)
|
||||
{
|
||||
// Include the controller file
|
||||
require_once(dirname(__FILE__).'/controllers/hook/'. $hook_name.'.php');
|
||||
|
||||
// Build dynamically the controller name
|
||||
$controller_name = $this->name.$hook_name.'Controller';
|
||||
|
||||
// Instantiate controller
|
||||
$controller = new $controller_name($this, __FILE__, $this->_path);
|
||||
|
||||
// Return the controller
|
||||
return $controller;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
$ajax_hook = Tools::getValue('ajax_hook');
|
||||
if ($ajax_hook != '') {
|
||||
$ajax_method = 'hook'.ucfirst($ajax_hook);
|
||||
if (method_exists($this, $ajax_method)) {
|
||||
die($this->{$ajax_method}(array()));
|
||||
}
|
||||
}
|
||||
|
||||
$controller = $this->getHookController('getContent');
|
||||
return $controller->run();
|
||||
}
|
||||
|
||||
public function hookDisplaySlider($params)
|
||||
{
|
||||
if (!$this->isCached('advslider.tpl', $this->getCacheId())) {
|
||||
$slides = AdvSlide::getSlides();
|
||||
|
||||
if (!$slides) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->smarty->assign('slides', $slides);
|
||||
}
|
||||
|
||||
return $this->display(__FILE__, 'advslider.tpl', $this->getCacheId());
|
||||
}
|
||||
|
||||
public function hookHeader($params)
|
||||
{
|
||||
$jsFiles = $this->context->controller->js_files;
|
||||
foreach($jsFiles as $jsFile) {
|
||||
if(strpos($jsFile, 'flexslider') !== false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->context->controller->addJS($this->_path.'js/flexslider.js');
|
||||
}
|
||||
|
||||
public function hookActionRefreshSlider()
|
||||
{
|
||||
$this->_clearCache('advslider');
|
||||
}
|
||||
|
||||
}
|
253
modules/advslider/classes/AdvSlide.php
Normal file
253
modules/advslider/classes/AdvSlide.php
Normal file
@ -0,0 +1,253 @@
|
||||
<?php
|
||||
|
||||
class AdvSlide extends ObjectModel
|
||||
{
|
||||
public $id_slide;
|
||||
public $position;
|
||||
public $active;
|
||||
|
||||
public $title;
|
||||
public $subtitle;
|
||||
public $label;
|
||||
public $url;
|
||||
public $description;
|
||||
public $light;
|
||||
public $start_at;
|
||||
public $end_at;
|
||||
|
||||
public static $definition = array(
|
||||
'table' => 'advslider',
|
||||
'primary' => 'id_slide',
|
||||
'multilang' => TRUE,
|
||||
'fields' => array(
|
||||
'id_slide' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
|
||||
'position' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
|
||||
'active' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
|
||||
'light' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
|
||||
'start_at' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
'end_at' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
|
||||
// Lang fields
|
||||
'title' => array('type' => self::TYPE_STRING, 'lang' => TRUE, 'validate' => 'isGenericName', 'size' => 255),
|
||||
'subtitle' => array('type' => self::TYPE_HTML, 'lang' => TRUE, 'validate' => 'isCleanHtml', 'size' => 255),
|
||||
'label' => array('type' => self::TYPE_STRING, 'lang' => TRUE, 'validate' => 'isGenericName', 'size' => 255),
|
||||
'url' => array('type' => self::TYPE_STRING, 'lang' => TRUE, 'validate' => 'isUrl', 'size' => 255),
|
||||
'description' => array('type' => self::TYPE_STRING, 'lang' => TRUE, 'validate' => 'isCleanHtml')
|
||||
),
|
||||
'associations' => array(
|
||||
'groups' => array('type' => self::HAS_MANY, 'field' => 'id_group', 'object' => 'Group', 'association' => 'advslider_group'),
|
||||
),
|
||||
);
|
||||
|
||||
public function __construct($id = NULL, $id_lang = NULL, $id_shop = NULL)
|
||||
{
|
||||
parent::__construct($id, $id_lang, $id_shop);
|
||||
|
||||
$this->image_dir = _PS_IMG_DIR_ . 'slider/';
|
||||
|
||||
if (!file_exists(_PS_TMP_IMG_DIR_)) {
|
||||
mkdir(_PS_TMP_IMG_DIR_, 755);
|
||||
}
|
||||
}
|
||||
|
||||
public function add($null_values = false, $autodate = true)
|
||||
{
|
||||
$result = parent::add($null_values, $autodate);
|
||||
Hook::exec('actionRefreshSlider');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function update($null_values = FALSE)
|
||||
{
|
||||
$result = parent::update($null_values);
|
||||
Hook::exec('actionRefreshSlider');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function updateGroups($data)
|
||||
{
|
||||
$dataToInsert = array();
|
||||
if (count($data) > 0) {
|
||||
// Reset
|
||||
Db::getInstance()->delete('advslider_group', 'id_slide='.(int)$this->id);
|
||||
// Prepare update
|
||||
foreach($data as $k => $v) {
|
||||
$dataToInsert[] = array(
|
||||
'id_slide' => $this->id,
|
||||
'id_group' => $v,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($dataToInsert) > 0) {
|
||||
Db::getInstance()->insert('advslider_group', $dataToInsert);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($null_values = FALSE)
|
||||
{
|
||||
$result = parent::delete($null_values);
|
||||
Hook::exec('actionRefreshSlider');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getSlides()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
|
||||
$sql = 'SELECT * FROM `'._DB_PREFIX_.'advslider` adv
|
||||
JOIN `'._DB_PREFIX_.'advslider_lang` advl ON (adv.`id_slide` = advl.`id_slide` AND id_lang='. (int)$context->language->id .')
|
||||
WHERE adv.`active` = 1';
|
||||
|
||||
// Check user group
|
||||
if (Configuration::get('ADVSLIDER_RESTRICT_GROUP')) {
|
||||
$groups = Customer::getGroupsStatic($context->customer->id);
|
||||
if ($context->customer->logged == 0) {
|
||||
$groups = array(Configuration::get('ADVSLIDER_DEFAULT_GROUP'));
|
||||
}
|
||||
|
||||
$sql.= ' AND EXISTS(SELECT * FROM `'._DB_PREFIX_.'advslider_group` ag WHERE ag.id_group IN('.join(',', $groups).'))';
|
||||
}
|
||||
|
||||
// Check date
|
||||
if (Configuration::get('ADVSLIDER_RESTRICT_DATE')) {
|
||||
$sql.= ' AND adv.`start_at` < NOW() AND adv.`end_at` > NOW() ';
|
||||
}
|
||||
|
||||
$sql.= ' ORDER BY `position` ASC';
|
||||
|
||||
$slides = Db::getInstance()->executeS($sql);
|
||||
|
||||
// Remove slider without image
|
||||
if (count($slides) > 0) {
|
||||
foreach($slides as $key => $slide) {
|
||||
if(!file_exists(_PS_IMG_DIR_ . 'slider/' . $slide['id_slide'] . '.jpg')) {
|
||||
unset($slides[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $slides;
|
||||
}
|
||||
|
||||
public static function getGroupsFormatted($id_slide)
|
||||
{
|
||||
$groups = array();
|
||||
$result = Db::getInstance()->executeS('SELECT `id_group` FROM `'._DB_PREFIX_.'advslider_group` WHERE `id_slide`=');
|
||||
if (count($result) > 0) {
|
||||
foreach($result as $r) {
|
||||
$groups[] = $r['id_group'];
|
||||
}
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
public function getGroups()
|
||||
{
|
||||
$groups = Db::getInstance()->executeS('SELECT `id_group` FROM `'._DB_PREFIX_.'advslider_group` WHERE `id_slide`='.(int)$this->id);
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
public function deleteImage($force_delete = false)
|
||||
{
|
||||
if (!$this->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$imgToDelete = Tools::getValue('imgName', false);
|
||||
|
||||
if ($imgToDelete === false) {
|
||||
return parent::deleteImage($force_delete = false);
|
||||
}
|
||||
|
||||
if ($force_delete || !$this->hasMultishopEntries()) {
|
||||
/* Deleting object images and thumbnails (cache) */
|
||||
|
||||
if ($this->image_dir) {
|
||||
if (file_exists($this->image_dir.$this->id.'-'.$imgToDelete.'.'.$this->image_format)
|
||||
&& !unlink($this->image_dir.$this->id.'-'.$imgToDelete.'.'.$this->image_format)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (file_exists(_PS_TMP_IMG_DIR_.$this->def['table'].'_'.$this->id.'-'.$imgToDelete.'.'.$this->image_format)
|
||||
&& !unlink(_PS_TMP_IMG_DIR_.$this->def['table'].'_'.$this->id.'-'.$imgToDelete.'.'.$this->image_format)) {
|
||||
return false;
|
||||
}
|
||||
if (file_exists(_PS_TMP_IMG_DIR_.$this->def['table'].'_mini_'.$this->id.'-'.$imgToDelete.'.'.$this->image_format)
|
||||
&& !unlink(_PS_TMP_IMG_DIR_.$this->def['table'].'_mini_'.$this->id.'-'.$imgToDelete.'.'.$this->image_format)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function cleanPositions()
|
||||
{
|
||||
return Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'advslider`
|
||||
SET `position`= `position` - 1
|
||||
WHERE `id_slide` = '.(int)$this->id_slide.'
|
||||
AND `position` > '.(int)$this->position);
|
||||
}
|
||||
|
||||
public function updatePosition($way, $position)
|
||||
{
|
||||
$sql = 'SELECT `position`, `id_slide`
|
||||
FROM `'._DB_PREFIX_.'advslider`
|
||||
ORDER BY `position` ASC';
|
||||
if (!$res = Db::getInstance()->executeS($sql))
|
||||
return false;
|
||||
|
||||
foreach ($res as $row)
|
||||
if ((int)$row['id_slide'] == (int)$this->id_slide)
|
||||
$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_.'advslider`
|
||||
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
||||
WHERE `position`
|
||||
'.($way
|
||||
? '> '.(int)$moved_row['position'].' AND `position` <= '.(int)$position
|
||||
: '< '.(int)$moved_row['position'].' AND `position` >= '.(int)$position)
|
||||
)
|
||||
&& Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'advslider`
|
||||
SET `position` = '.(int)$position.'
|
||||
WHERE `id_slide`='.(int)$moved_row['id_slide']
|
||||
);
|
||||
$this->refreshPositions();
|
||||
|
||||
Hook::exec('actionRefreshSlider');
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function refreshPositions()
|
||||
{
|
||||
$sql = 'SELECT `id_slide`
|
||||
FROM `'._DB_PREFIX_.'advslider`
|
||||
ORDER BY `position` ASC';
|
||||
if (!$blocks = Db::getInstance()->executeS($sql))
|
||||
return false;
|
||||
|
||||
$pos=0;
|
||||
foreach ($blocks as $block) {
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'advslider`
|
||||
SET `position` = '.(int)$pos.'
|
||||
WHERE `id_slide`='.(int)$block['id_slide']);
|
||||
$pos++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
395
modules/advslider/controllers/admin/AdminAdvSlider.php
Normal file
395
modules/advslider/controllers/admin/AdminAdvSlider.php
Normal file
@ -0,0 +1,395 @@
|
||||
<?php
|
||||
include_once dirname(__FILE__).'/../../classes/AdvSlide.php';
|
||||
|
||||
class AdminAdvSliderController extends ModuleAdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'advslider';
|
||||
$this->className = 'AdvSlide';
|
||||
$this->identifier = 'id_slide';
|
||||
$this->lang = true;
|
||||
$this->deleted = false;
|
||||
$this->bootstrap = true;
|
||||
$this->fieldImageSettings = array(
|
||||
'name' => 'image',
|
||||
'dir' => 'slider'
|
||||
);
|
||||
$this->position_identifier = 'id_slide';
|
||||
$this->_defaultOrderBy = 'position';
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->actions = array('edit', 'delete');
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_slide' => array(
|
||||
'title' => 'ID',
|
||||
'width' => 25
|
||||
),
|
||||
'image_desktop' => array(
|
||||
'title' => $this->module->l('Image'),
|
||||
'image' => $this->fieldImageSettings['dir'],
|
||||
'width' => 75
|
||||
),
|
||||
'title' => array(
|
||||
'title' => $this->module->l('Titre'),
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->module->l('Actif'),
|
||||
'type' => 'bool',
|
||||
),
|
||||
'start_at' => array(
|
||||
'title' => $this->module->l('Début'),
|
||||
),
|
||||
'end_at' => array(
|
||||
'title' => $this->module->l('Fin'),
|
||||
),
|
||||
'url' => array(
|
||||
'title' => $this->module->l('Url'),
|
||||
'width' => 45,
|
||||
),
|
||||
'position' => array(
|
||||
'title' => $this->l('Position'),
|
||||
'align' => 'center',
|
||||
'position' => 'position',
|
||||
'filter_key' => 'a!position'
|
||||
),
|
||||
);
|
||||
|
||||
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL){
|
||||
$this->_join .= 'JOIN `'._DB_PREFIX_.'advslider_shop` as ashop ON a.`id_slide` = ashop.`id_slide` AND ashop.`id_shop` IN ('.implode(', ', Shop::getContextListShopID()).') ';
|
||||
$this->_group .= 'GROUP BY ashop.`id_slide`';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function initPageHeaderToolbar()
|
||||
{
|
||||
parent::initPageHeaderToolbar();
|
||||
|
||||
if ($this->display != 'edit' && $this->display != 'add') {
|
||||
$this->page_header_toolbar_btn['new_link'] = array(
|
||||
'href' => self::$currentIndex.'&id_parent='.(int)Tools::getValue('id_slide').'&addadvslider&token='.$this->token,
|
||||
'desc' => $this->l('Ajouter une nouvelle slide', NULL, NULL, FALSE),
|
||||
'icon' => 'process-icon-new'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function renderView()
|
||||
{
|
||||
return $this->renderList();
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'tinymce' => TRUE,
|
||||
'legend' => array(
|
||||
'title' => $this->className,
|
||||
),
|
||||
'submit' => array(
|
||||
'name' => 'submitAdvSlider',
|
||||
'title' => $this->l('Save'),
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Titre'),
|
||||
'name' => 'title',
|
||||
'lang' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Sous-titre'),
|
||||
'name' => 'subtitle',
|
||||
'lang' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Activé'),
|
||||
'name' => 'active',
|
||||
'required' => FALSE,
|
||||
'is_bool' => TRUE,
|
||||
'default' => 1,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'active_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'active_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'datetime',
|
||||
'label' => $this->l('Date de début'),
|
||||
'name' => 'start_at',
|
||||
'lang' => false,
|
||||
),
|
||||
array(
|
||||
'type' => 'datetime',
|
||||
'label' => $this->l('Date de fin'),
|
||||
'name' => 'end_at',
|
||||
'lang' => false,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'label' => $this->l('Groupe(s) d\'utilisateur'),
|
||||
'name' => 'groups',
|
||||
'values' => array(
|
||||
'query' => array(
|
||||
array('id_group' => 3, 'name' => 'Particulier'),
|
||||
array('id_group' => 4, 'name' => 'Pro'),
|
||||
),
|
||||
'id' => 'id_group',
|
||||
'name' => 'name',
|
||||
),
|
||||
'expand' => array(
|
||||
'default' => 'show',
|
||||
'show' => array('text' => $this->l('show'), 'icon' => 'plus-sign-alt'),
|
||||
'hide' => array('text' => $this->l('hide'), 'icon' => 'minus-sign-alt')
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Texte foncé ?'),
|
||||
'name' => 'light',
|
||||
'required' => FALSE,
|
||||
'is_bool' => TRUE,
|
||||
'default' => 1,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'light_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'light_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Label lien'),
|
||||
'name' => 'label',
|
||||
'lang' => TRUE
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Lien'),
|
||||
'name' => 'url',
|
||||
'lang' => TRUE
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Description'),
|
||||
'name' => 'description',
|
||||
'autoload_rte' => TRUE,
|
||||
'lang' => TRUE
|
||||
),
|
||||
array(
|
||||
'type' => 'shop',
|
||||
'label' => $this->l('Shop'),
|
||||
'form_group_class' => 'fieldhide input_association',
|
||||
'name' => 'checkBoxShopAsso_advslider'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
$selectedGroups = array();
|
||||
|
||||
$image = false;
|
||||
$image_url = '';
|
||||
$image_size = '';
|
||||
|
||||
$image_mobile = false;
|
||||
$image_url_mobile = '';
|
||||
$image_size_mobile = '';
|
||||
|
||||
if($obj) {
|
||||
// Groupes
|
||||
$selectedGroups = $obj->getGroups();
|
||||
if (count($selectedGroups) > 0) {
|
||||
foreach ($selectedGroups as $id) {
|
||||
$this->fields_value['groups_'.$id['id_group']] = 'on';
|
||||
}
|
||||
}
|
||||
|
||||
// Images
|
||||
$image = _PS_IMG_DIR_ . 'slider/' . $obj->id.'.jpg';
|
||||
$image_url = ImageManager::thumbnail($image, $this->table.'_'.(int)$obj->id.'.'.$this->imageType, 350, $this->imageType, true, true);
|
||||
$image_size = file_exists($image) ? filesize($image) / 1000 : false;
|
||||
|
||||
$image_mobile = _PS_IMG_DIR_ . 'slider/' . $obj->id.'-mobile.jpg';
|
||||
$image_url_mobile = ImageManager::thumbnail($image_mobile, $this->table.'_'.(int)$obj->id.'-image_mobile.'.$this->imageType, 350, $this->imageType, true, true);
|
||||
$image_size_mobile = file_exists($image_mobile) ? filesize($image_mobile) / 1000 : false;
|
||||
}
|
||||
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'file',
|
||||
'label' => $this->l('Image'),
|
||||
'desc' => $this->l('Image - type: jpg,png - size: 940 x 300 px'),
|
||||
'name' => 'image',
|
||||
'display_image' => true,
|
||||
'lang' => true,
|
||||
'required' => true,
|
||||
'image' => $image_url,
|
||||
'size' => $image_size,
|
||||
'delete_url' => self::$currentIndex.'&'.$this->identifier.'='.$this->object->id.'&token='.$this->token.'&deleteImage=1'
|
||||
);
|
||||
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'file',
|
||||
'label' => $this->l('Image Mobile'),
|
||||
'desc' => $this->l('Image - type: jpg,png - size: 300 x 200 px'),
|
||||
'name' => 'image_mobile',
|
||||
'display_image' => true,
|
||||
'lang' => true,
|
||||
'required' => true,
|
||||
'image' => $image_url_mobile,
|
||||
'size' => $image_size_mobile,
|
||||
'delete_url' => self::$currentIndex.'&'.$this->identifier.'='.$this->object->id.'&token='.$this->token.'&deleteImage=1&imgName=image_mobile'
|
||||
);
|
||||
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
protected function copyFromPost(&$object, $table)
|
||||
{
|
||||
parent::copyFromPost($object, $table);
|
||||
|
||||
if(Shop::isFeatureActive()) {
|
||||
$object->id_shop_list = array();
|
||||
foreach (Tools::getValue('checkBoxShopAsso_advslider') as $id_shop => $value) {
|
||||
$object->id_shop_list[] = $id_shop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::getValue('deleteImage')) {
|
||||
$this->processForceDeleteImage();
|
||||
$this->refreshPreview();
|
||||
}
|
||||
|
||||
parent::postProcess();
|
||||
|
||||
$obj = $this->loadObject(TRUE);
|
||||
|
||||
// Groupes
|
||||
$groupsData = array();
|
||||
foreach ($_POST as $pKey => $pValue) {
|
||||
$groupKey = 'groups_';
|
||||
if (substr($pKey, 0, strlen($groupKey)) == $groupKey && $pValue == 'on') {
|
||||
$groupsData[] = substr($pKey, strlen($groupKey));
|
||||
}
|
||||
}
|
||||
if (count($groupsData) > 0) {
|
||||
$obj->updateGroups($groupsData);
|
||||
}
|
||||
|
||||
// Images
|
||||
$images = array(
|
||||
'image_mobile' => 'mobile',
|
||||
);
|
||||
foreach($images as $imageName => $suffix) {
|
||||
if(isset($_FILES[$imageName]) && !empty($_FILES[$imageName]['tmp_name'])) {
|
||||
$fileTemp = $_FILES[$imageName]['tmp_name'];
|
||||
$fileParts = pathinfo($_FILES[$imageName]['name']);
|
||||
$extension = $fileParts['extension'];
|
||||
|
||||
if(file_exists(_PS_IMG_DIR_.'slider/'.$obj->id.'-'.$suffix.'.'.$extension)) {
|
||||
unlink(_PS_IMG_DIR_.'slider/'.$obj->id.'-'.$suffix.'.'.$extension);
|
||||
}
|
||||
|
||||
if(in_array($extension, array('jpg', 'png'))) {
|
||||
$res = move_uploaded_file($fileTemp, _PS_IMG_DIR_.'slider/'.$obj->id.'-'.$suffix.'.'.$extension);
|
||||
if(!$res) {
|
||||
$this->errors[] = sprintf(Tools::displayError('An error occured during upload of file %s'), $obj->id.'.'.$extension);
|
||||
}
|
||||
else {
|
||||
if($extension == 'png') {
|
||||
ImageManager::resize(_PS_IMG_DIR_.'slider/'.$obj->id.'-'.$suffix.'.'.$extension, _PS_IMG_DIR_.'slider/'.$obj->id.'-'.$suffix.'.jpg');
|
||||
}
|
||||
$this->confirmations[] = sprintf($this->l('File %s has been uploaded'), $obj->id.'.'.$extension);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->errors[] = sprintf(Tools::displayError('File %s have not good extension, only .jpg or .png'), $obj->id.'.'.$extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function processForceDeleteImage()
|
||||
{
|
||||
$link = $this->loadObject(true);
|
||||
|
||||
if (Validate::isLoadedObject($link)) {
|
||||
$link->deleteImage(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected function postImage($id)
|
||||
{
|
||||
$ret = parent::postImage($id);
|
||||
$this->refreshPreview();
|
||||
|
||||
if (isset($_FILES) && count($_FILES) && $_FILES['image']['name'] != NULL && !empty($this->object->id) ) {
|
||||
return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function refreshPreview()
|
||||
{
|
||||
$current_preview = _PS_TMP_IMG_DIR_.'advslider_mini_'.$this->object->id_slide.'_'.$this->context->shop->id.'.jpg';
|
||||
|
||||
if (file_exists($current_preview)) {
|
||||
unlink($current_preview);
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessUpdatePositions()
|
||||
{
|
||||
$way = (int)(Tools::getValue('way'));
|
||||
$id = (int)(Tools::getValue('id'));
|
||||
$positions = Tools::getValue('slide');
|
||||
$obj = 'advslider';
|
||||
|
||||
if (is_array($positions)) {
|
||||
foreach ($positions as $position => $value) {
|
||||
$pos = explode('_', $value);
|
||||
|
||||
if (isset($pos[2]) && (int)$pos[2] === $id) {
|
||||
$menu_obj = new AdvSlide((int)$pos[2]);
|
||||
|
||||
if (Validate::isLoadedObject($menu_obj)) {
|
||||
if (isset($position) && $menu_obj->updatePosition($way, $position)) {
|
||||
echo 'ok position '.(int)$position.' for '.$obj.' '.(int)$pos[2]."\r\n";
|
||||
}
|
||||
else {
|
||||
echo '{"hasError" : true, "errors" : "Can not update '.$obj.' '.(int)$id.' to position '.(int)$position.' "}';
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo '{"hasError" : true, "errors" : "This '.$obj.' ('.(int)$id.') cannot be loaded"}';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
126
modules/advslider/controllers/hook/getContent.php
Normal file
126
modules/advslider/controllers/hook/getContent.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
class AdvSliderGetContentController
|
||||
{
|
||||
public function __construct($module, $file, $path)
|
||||
{
|
||||
$this->file = $file;
|
||||
$this->module = $module;
|
||||
$this->context = Context::getContext();
|
||||
$this->_path = $path;
|
||||
}
|
||||
|
||||
public function processConfiguration()
|
||||
{
|
||||
if (Tools::isSubmit('submitAdvsliderconfig')) {
|
||||
$enable_date = Tools::getValue('enable_date');
|
||||
$enable_groups = Tools::getValue('enable_groups');
|
||||
$default_group = Tools::getValue('default_group');
|
||||
Configuration::updateValue('ADVSLIDER_RESTRICT_DATE', $enable_date);
|
||||
Configuration::updateValue('ADVSLIDER_RESTRICT_GROUP', $enable_groups);
|
||||
Configuration::updateValue('ADVSLIDER_DEFAULT_GROUP', $default_group);
|
||||
$this->context->smarty->assign('confirmation', 'ok');
|
||||
}
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
$groups = Group::getGroups($this->context->language->id);
|
||||
$optionGroups = array();
|
||||
if (count($groups) > 0) {
|
||||
foreach ($groups as $group) {
|
||||
if (in_array($group['id_group'], array(1,2))) {
|
||||
continue;
|
||||
}
|
||||
$optionGroups[] = array(
|
||||
'id_group' => $group['id_group'],
|
||||
'name' => $group['name'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$fields_form = array(
|
||||
'form' => array(
|
||||
'legend' => array(
|
||||
'title' => $this->module->l('AdvSlider configuration'),
|
||||
'icon' => 'icon-envelope'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->module->l('Enable Date restriction:'),
|
||||
'name' => 'enable_date',
|
||||
'desc' => $this->module->l('Enable restriction by date.'),
|
||||
'values' => array(
|
||||
array('id' => 'enable_date_1', 'value' => 1, 'label' => $this->module->l('Enabled')),
|
||||
array('id' => 'enable_date_0', 'value' => 0, 'label' => $this->module->l('Disabled'))
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->module->l('Enable Groups Restriction:'),
|
||||
'name' => 'enable_groups',
|
||||
'desc' => $this->module->l('Enable restriction by user groups.'),
|
||||
'values' => array(
|
||||
array('id' => 'enable_groups_1', 'value' => 1, 'label' => $this->module->l('Enabled')),
|
||||
array('id' => 'enable_groups_0', 'value' => 0, 'label' => $this->module->l('Disabled'))
|
||||
),
|
||||
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'label' => $this->module->l('User group to display for restriction'),
|
||||
'name' => 'groups',
|
||||
'values' => array(
|
||||
'query' => $optionGroups,
|
||||
'id' => 'id_group',
|
||||
'name' => 'name',
|
||||
),
|
||||
'expand' => array(
|
||||
'default' => 'show',
|
||||
'show' => array('text' => $this->module->l('show'), 'icon' => 'plus-sign-alt'),
|
||||
'hide' => array('text' => $this->module->l('hide'), 'icon' => 'minus-sign-alt')
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->module->l('Default group to display:'),
|
||||
'name' => 'default_group',
|
||||
'desc' => $this->module->l('Set a Default group to display slider with unauthenticated user.'),
|
||||
'options' => array(
|
||||
'query' => $optionGroups,
|
||||
'id' => 'id_group',
|
||||
'name' => 'name',
|
||||
),
|
||||
),
|
||||
),
|
||||
'submit' => array('title' => $this->module->l('Save')),
|
||||
)
|
||||
);
|
||||
|
||||
$helper = new HelperForm();
|
||||
$helper->table = 'advslider';
|
||||
$helper->default_form_language = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
$helper->allow_employee_form_lang = (int)Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG');
|
||||
$helper->submit_action = 'submitAdvsliderconfig';
|
||||
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->module->name.'&tab_module='.$this->module->tab.'&module_name='.$this->module->name;
|
||||
$helper->token = Tools::getAdminTokenLite('AdminModules');
|
||||
$helper->tpl_vars = array(
|
||||
'fields_value' => array(
|
||||
'enable_date' => Tools::getValue('enable_date', Configuration::get('ADVSLIDER_RESTRICT_DATE')),
|
||||
'enable_groups' => Tools::getValue('enable_groups', Configuration::get('ADVSLIDER_RESTRICT_GROUP')),
|
||||
'default_group' => Tools::getValue('default_group', Configuration::get('ADVSLIDER_DEFAULT_GROUP')),
|
||||
),
|
||||
'languages' => $this->context->controller->getLanguages()
|
||||
);
|
||||
|
||||
return $helper->generateForm(array($fields_form));
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->processConfiguration();
|
||||
$html_confirmation_message = $this->module->display($this->file, 'getContent.tpl');
|
||||
$html_form = $this->renderForm();
|
||||
return $html_confirmation_message.$html_form;
|
||||
}
|
||||
}
|
35
modules/advslider/index.php
Normal file
35
modules/advslider/index.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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-2014 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;
|
5
modules/advslider/js/flexslider.js
Normal file
5
modules/advslider/js/flexslider.js
Normal file
File diff suppressed because one or more lines are too long
BIN
modules/advslider/logo.gif
Normal file
BIN
modules/advslider/logo.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/advslider/logo.png
Normal file
BIN
modules/advslider/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
@ -0,0 +1,69 @@
|
||||
{if strpos($name, 'multilang') === false}
|
||||
{include file='helpers/uploader/simple.tpl'}
|
||||
{else}
|
||||
{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">
|
||||
|
||||
{foreach $files as $file}
|
||||
{if isset($file.image) && $file.type == 'image'}
|
||||
<div>
|
||||
{if !empty($file.image[$language['id_lang']])}
|
||||
{if Validate::isUrl($file.image[$language['id_lang']])}<img src="{$file.image[$language['id_lang']]}" class="img-thumbnail" />{else}{$file.image[$language['id_lang']]}{/if}
|
||||
{if isset($file.delete_url[$language['id_lang']])}<a href="{$file.delete_url[$language['id_lang']]}">{l s='Supprimer'}</a>{/if}
|
||||
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
<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'}
|
||||
</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>
|
||||
|
||||
{/if}
|
1
modules/advslider/views/templates/hook/advslider.tpl
Normal file
1
modules/advslider/views/templates/hook/advslider.tpl
Normal file
@ -0,0 +1 @@
|
||||
{$slides|p}
|
3
modules/advslider/views/templates/hook/getContent.tpl
Normal file
3
modules/advslider/views/templates/hook/getContent.tpl
Normal file
@ -0,0 +1,3 @@
|
||||
{if isset($confirmation)}
|
||||
<div class="alert alert-success">{l s='Settings updated' mod='advslider'}</div>
|
||||
{/if}
|
@ -50,10 +50,24 @@ class privatesaleshomeModuleFrontController extends ModuleFrontController {
|
||||
$this->setTemplate('privatesales-home.tpl');
|
||||
|
||||
// 12613 - Optimisation
|
||||
$sale_cache = new SaleCache($this->context, "home", 7200, $news); // 2 Hours
|
||||
if ($sale_cache->isCached($this->template)) {
|
||||
$this->setCacheHtml($sale_cache->getCache());
|
||||
return;
|
||||
if(Configuration::get('PS_SMARTY_CACHE') == 1) {
|
||||
$lifetime = 7200;
|
||||
switch (Configuration::get('PS_SMARTY_FORCE_COMPILE')) {
|
||||
case 0:
|
||||
case 1:
|
||||
$lifetime = 7200;
|
||||
break;
|
||||
case 2:
|
||||
$lifetime = 0;
|
||||
break;
|
||||
}
|
||||
if ($lifetime > 0) {
|
||||
$sale_cache = new SaleCache($this->context, "home", $lifetime, $news);
|
||||
if ($sale_cache->isCached($this->template)) {
|
||||
$this->setCacheHtml($sale_cache->getCache());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 12613 - End optimisation
|
||||
|
||||
|
@ -32,7 +32,13 @@ class SaleCache
|
||||
$this->cache_id = md5("private_sales_".$cache_prefix."_".$d->format('Ymd'));
|
||||
|
||||
$this->max_filemtime = $d->getTimestamp() - $lifetime;
|
||||
$this->path_cache_file = __DIR__.'/../cache/'.$this->cache_id;
|
||||
|
||||
$path_cache = _PS_CACHE_DIR_.'smarty/cache/privatesales';
|
||||
if (!file_exists($path_cache)) {
|
||||
mkdir($path_cache, 0755);
|
||||
}
|
||||
$this->path_cache_file = $path_cache.'/'.$this->cache_id;
|
||||
|
||||
$this->smarty = $context->smarty;
|
||||
}
|
||||
|
||||
@ -64,7 +70,7 @@ class SaleCache
|
||||
|
||||
static function clearAll()
|
||||
{
|
||||
foreach(glob(__DIR__.'/../cache/*') as $path_file) {
|
||||
foreach(glob(_PS_CACHE_DIR_.'smarty/cache/privatesales/*') as $path_file) {
|
||||
if (preg_match('/index\.php$/', $path_file)===1) {
|
||||
continue;
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
{if $slides|@count > 0}
|
||||
<div class="row slider-ctn">
|
||||
{*desktop*}
|
||||
<div id="slider_home" class="clearfix snotmobile">
|
||||
<div class="clearfix owl">
|
||||
{foreach from=$slides item=slide key=key name=slider}
|
||||
<div class="col-sm-12 slide-home item" style="height:300px;background: url('{$img_ps_dir}slider/{$slide.id_slide}.jpg') no-repeat left top; background-size: 100% auto;">
|
||||
{if isset($slide.url) && $slide.url}
|
||||
<a href="{$slide.url}" style="width:100%;height: 100%;display: block;" {if isset($slide.title) && $slide.title}title="{$slide.title}"{/if}></a>
|
||||
{/if}
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
{*mobile*}
|
||||
<div id="slider_home_mobile" class="clearfix smobile">
|
||||
<div class="clearfix owl">
|
||||
{foreach from=$slides item=slide key=key name=slider}
|
||||
<div class="col-sm-12 slide-home item" style="height:200px;background: url('{$img_ps_dir}slider/{$slide.id_slide}-mobile.jpg') no-repeat center top; background-size: contain;">
|
||||
{if isset($slide.url) && $slide.url}
|
||||
<a {if !$cookie->logged}onclick="window.location.href='{$link->getPageLink('authentication', true)|escape:'html':'UTF-8'}';"{else}href="{$slide.url}"{/if} style="width:100%;height: 100%;display: block;" {if isset($slide.title) && $slide.title}title="{$slide.title}"{/if}></a>
|
||||
{/if}
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
@ -52,11 +52,15 @@ $(document).ready(function() {
|
||||
<div class="carrier_discount_ctn">
|
||||
<p>{l s='LIVRAISON GRATUITE' mod='privatesales'|escape:'html':'UTF-8'}<span>{l s='à partir de 79€ ttc en Point Relais' mod='privatesales'|escape:'html':'UTF-8'}</span><p>
|
||||
</div>
|
||||
|
||||
<h3 class="sale-title-type col-xs-12 smobile"><span>{l s='Nos ventes en cours' mod='privatesales'}</span></h3>
|
||||
{if $currentsales|count > 0}
|
||||
<div class="privatesales-slider">
|
||||
{*hook h='displaySlider' mod='advslider'*}
|
||||
</div>
|
||||
{assign var=i value=0}
|
||||
{foreach $currentsales as $sale}
|
||||
{if isset($slider_active) && $slider_active && ($currentsales|count == 1 || $i == 0)}
|
||||
{if isset($slider_active) && $slider_active && ($currentsales|count == 1 || $i == 0)}
|
||||
<div class="row slider-ctn">
|
||||
{*desktop*}
|
||||
<div id="slider_home" class="clearfix snotmobile">
|
||||
@ -84,7 +88,6 @@ $(document).ready(function() {
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{capture name=img_sale}{$base_dir}{$link_img}{$sale->id}/current/{$sale->id}_{$cookie->id_lang}.jpg{/capture}
|
||||
{if !$sale->news}
|
||||
{if strtotime($sale->date_end) < (strtotime(date('Y-m-d H:i:s')) + (3600 * 24 * 2))}
|
||||
|
Loading…
Reference in New Issue
Block a user