first commit
This commit is contained in:
133
modules/leoslideshow/classes/LeoSlideshowConfig.php
Normal file
133
modules/leoslideshow/classes/LeoSlideshowConfig.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Leotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Adds image, text or video to your homepage.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author leotheme <leotheme@gmail.com>
|
||||
* @copyright 2007-2015 Leotheme
|
||||
* @license http://leotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!class_exists('LeoSlideshowConfig')) {
|
||||
|
||||
class LeoSlideshowConfig
|
||||
{
|
||||
const DISABLE = '0';
|
||||
const ENABLE = '1';
|
||||
|
||||
public static function getArrayOptions($ids = array(), $names = array())
|
||||
{
|
||||
$res = array();
|
||||
foreach ($names as $key => $val) {
|
||||
# module validation
|
||||
unset($val);
|
||||
|
||||
$res[] = array(
|
||||
'id' => $ids[$key],
|
||||
'name' => $names[$key],
|
||||
);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
const IVIEW_TIMER_360BAR = '360Bar';
|
||||
const IVIEW_TIMER_BAR = 'Bar';
|
||||
const IVIEW_TIMER_PIE = 'Pie';
|
||||
|
||||
public static function getTimerStyle()
|
||||
{
|
||||
$ids = array(self::IVIEW_TIMER_360BAR, self::IVIEW_TIMER_BAR, self::IVIEW_TIMER_PIE);
|
||||
$names = array('360Bar', 'Bar', 'Pie');
|
||||
return self::getArrayOptions($ids, $names);
|
||||
}
|
||||
|
||||
public static function getTimerPosition()
|
||||
{
|
||||
$ids = array('top-left', 'top-right', 'top-center', 'middle', 'bottom-left', 'bottom-right', 'bottom-center');
|
||||
$names = array('Top Left', 'Top Right', 'Top Center', 'Middle', 'Bottom Left', 'Bottom Right', 'Bottom Center');
|
||||
return self::getArrayOptions($ids, $names);
|
||||
}
|
||||
|
||||
public static function getTimerBarStrokeStyle()
|
||||
{
|
||||
$ids = array('solid', 'none', 'hidden', 'dotted', 'dashed', 'double', 'groove', 'ridge', 'inset', 'outset', 'initial');
|
||||
$names = array('Solid', 'None', 'Hidden', 'Dotted', 'Dashed', 'Double', 'Groove', 'Ridge', 'Inset', 'Outset', 'Initial');
|
||||
return self::getArrayOptions($ids, $names);
|
||||
}
|
||||
const IVIEW_NAV_THUMBNAIL = 'thumbnail';
|
||||
const IVIEW_NAV_BULLET = 'bullet';
|
||||
|
||||
public static function getNavigatorType()
|
||||
{
|
||||
$ids = array(self::IVIEW_NAV_THUMBNAIL, self::IVIEW_NAV_BULLET);
|
||||
$names = array('Thumbnail', 'Bullet',);
|
||||
return self::getArrayOptions($ids, $names);
|
||||
}
|
||||
|
||||
public static function getFx()
|
||||
{
|
||||
/*
|
||||
$ids = array('random', 'left-curtain', 'right-curtain', 'top-curtain', 'bottom-curtain', 'strip-down-right', 'strip-down-left',
|
||||
'strip-up-right', 'strip-up-left', 'strip-up-down', 'strip-up-down-left', 'strip-left-right', 'strip-left-right-down', 'slide-in-right',
|
||||
'slide-in-left', 'slide-in-up', 'slide-in-down', 'fade', 'block-random', 'block-fade', 'block-fade-reverse', 'block-expand',
|
||||
'block-expand-reverse', 'block-expand-random', 'zigzag-top', 'zigzag-bottom', 'zigzag-grow-top', 'zigzag-grow-bottom', 'zigzag-drop-top',
|
||||
'zigzag-drop-bottom', 'strip-left-fade', 'strip-right-fade', 'strip-top-fade', 'strip-bottom-fade', 'block-drop-random');
|
||||
$names = array('Random', 'Left Curtain', 'Right Curtain', 'Top Curtain', 'Bottom Curtain', 'Strip Down Right', 'Strip Down Left',
|
||||
'Strip Up Right', 'Strip Up Left', 'Strip Up Down', 'Strip Up Down Left', 'Strip Left Right', 'Strip Left Right Down', 'Slide In Right',
|
||||
'Slide In Left', 'Slide In Up', 'Slide In Down', 'Fade', 'Block Random', 'Block Fade', 'Block Fade Reverse', 'Block Expand',
|
||||
'Block Expand Reverse', 'Block Expand Random', 'Zigzag Top', 'Zigzag Bottom', 'Zigzag Grow Top', 'Zigzag Grow Bottom', 'Zigzag Drop Top',
|
||||
'Zigzag Drop Bottom', 'Strip Left Fade', 'Strip Right Fade', 'Strip Top Fade', 'Strip Bottom Fade', 'Block Drop Random');
|
||||
*/
|
||||
$ids = array('random', 'left-curtain', 'right-curtain', 'top-curtain', 'bottom-curtain', 'strip-down-right', 'strip-down-left',
|
||||
'strip-up-right', 'strip-up-left', 'strip-up-down', 'strip-up-down-left', 'strip-left-right', 'strip-left-right-down', 'slide-in-right',
|
||||
'slide-in-left', 'slide-in-up', 'slide-in-down', 'fade', 'strip-left-fade', 'strip-right-fade', 'strip-top-fade', 'strip-bottom-fade');
|
||||
$names = array('Random', 'Left Curtain', 'Right Curtain', 'Top Curtain', 'Bottom Curtain', 'Strip Down Right', 'Strip Down Left',
|
||||
'Strip Up Right', 'Strip Up Left', 'Strip Up Down', 'Strip Up Down Left', 'Strip Left Right', 'Strip Left Right Down', 'Slide In Right',
|
||||
'Slide In Left', 'Slide In Up', 'Slide In Down', 'Fade', 'Strip Left Fade', 'Strip Right Fade', 'Strip Top Fade', 'Strip Bottom Fade');
|
||||
return self::getArrayOptions($ids, $names);
|
||||
}
|
||||
|
||||
public static function getCaptionTransition()
|
||||
{
|
||||
$ids = array('wipeLeft', 'wipeRight', 'wipeTop', 'wipeBottom', 'expandLeft', 'expandRight', 'expandTop', 'expandBottom', 'fade');
|
||||
$names = array('Wipe Left', 'Wipe Right', 'Wipe Top', 'Wipe Bottom', 'Expand Left', 'Expand Right', 'Expand Top', 'Expand Bottom', 'Fade');
|
||||
return self::getArrayOptions($ids, $names);
|
||||
}
|
||||
const TIMER_HIDE_AUTO = '1';
|
||||
const TIMER_HIDE_STOP = '2';
|
||||
const TIMER_SHOW_AUTO = '3';
|
||||
const TIMER_SHOW_STOP = '4';
|
||||
|
||||
public static function getTimerOption()
|
||||
{
|
||||
$ids = array(self::TIMER_SHOW_AUTO, self::TIMER_HIDE_AUTO, self::TIMER_HIDE_STOP);
|
||||
$names = array('Show and Autorun', 'Hide and Autorun', 'Hide and no Autorun');
|
||||
|
||||
return self::getArrayOptions($ids, $names);
|
||||
}
|
||||
|
||||
public static function test()
|
||||
{
|
||||
$ids = array('', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
|
||||
$names = array('', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
|
||||
return self::getArrayOptions($ids, $names);
|
||||
}
|
||||
|
||||
const VERSION_FREE = '0';
|
||||
const VERSION_PRO = '1';
|
||||
const VERSION_CURRENT = '1';
|
||||
|
||||
public static function getPermission()
|
||||
{
|
||||
if (self::VERSION_CURRENT == self::VERSION_PRO) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
261
modules/leoslideshow/classes/LeoSlideshowGroup.php
Normal file
261
modules/leoslideshow/classes/LeoSlideshowGroup.php
Normal file
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Leotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Adds image, text or video to your homepage.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author leotheme <leotheme@gmail.com>
|
||||
* @copyright 2007-2015 Leotheme
|
||||
* @license http://leotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class LeoSlideshowGroup extends ObjectModel
|
||||
{
|
||||
|
||||
public $title;
|
||||
public $active;
|
||||
public $hook;
|
||||
public $id_shop;
|
||||
public $params;
|
||||
public $active_ap;
|
||||
public $data = array();
|
||||
public $randkey;
|
||||
public $leo_module = null;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public function setModule($module)
|
||||
{
|
||||
$this->leo_module = $module;
|
||||
}
|
||||
|
||||
public static $definition = array(
|
||||
'table' => 'leoslideshow_groups',
|
||||
'primary' => 'id_leoslideshow_groups',
|
||||
'fields' => array(
|
||||
'title' => array('type' => self::TYPE_STRING, 'lang' => false, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 255),
|
||||
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
|
||||
'hook' => array('type' => self::TYPE_STRING, 'lang' => false, 'validate' => 'isCleanHtml', 'size' => 64),
|
||||
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt', 'required' => true),
|
||||
'params' => array('type' => self::TYPE_HTML, 'lang' => false),
|
||||
'active_ap' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'randkey' => array('type' => self::TYPE_STRING, 'lang' => false, 'size' => 255),
|
||||
)
|
||||
);
|
||||
|
||||
public function add($autodate = true, $null_values = false)
|
||||
{
|
||||
$res = parent::add($autodate, $null_values);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function groupExists($id_group)
|
||||
{
|
||||
$req = 'SELECT gr.`id_leoslideshow_groups` as id_group
|
||||
FROM `' . _DB_PREFIX_ . 'leoslideshow_groups` gr
|
||||
WHERE gr.`id_leoslideshow_groups` = ' . (int) $id_group;
|
||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($req);
|
||||
return ($row);
|
||||
}
|
||||
|
||||
public function getGroups($active, $id_shop)
|
||||
{
|
||||
$this->context = Context::getContext();
|
||||
if (!isset($id_shop)) {
|
||||
$id_shop = $this->context->shop->id;
|
||||
}
|
||||
$req = 'SELECT * FROM `' . _DB_PREFIX_ . 'leoslideshow' . '_groups` gr
|
||||
WHERE (`id_shop` = ' . (int) $id_shop . ')' . ($active ? ' AND gr.`active` = 1' : ' ');
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($req);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delele all Slides follow id_group
|
||||
*/
|
||||
public static function deleteAllSlider($id_group)
|
||||
{
|
||||
$sql = 'SELECT sl.`id_leoslideshow_slides` as id
|
||||
FROM `' . _DB_PREFIX_ . 'leoslideshow_slides` sl
|
||||
WHERE sl.`id_group` = ' . (int) $id_group;
|
||||
$sliders = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
if ($sliders) {
|
||||
$where = '';
|
||||
foreach ($sliders as $sli) {
|
||||
# module validation
|
||||
$where .= $where ? ',' . (int) $sli['id'] : (int) $sli['id'];
|
||||
}
|
||||
|
||||
# SLIDE
|
||||
$sql = 'DELETE FROM `' . _DB_PREFIX_ . 'leoslideshow_slides` '
|
||||
. 'WHERE `id_leoslideshow_slides` IN (' . $where . ')';
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
# SLIDE_LANG
|
||||
$sql = 'DELETE FROM `' . _DB_PREFIX_ . 'leoslideshow_slides_lang` '
|
||||
. 'WHERE `id_leoslideshow_slides` IN (' . $where . ')';
|
||||
Db::getInstance()->execute($sql);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$res = parent::delete();
|
||||
|
||||
if ($res) {
|
||||
$this->deleteAllSlider((int) $this->id);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and validate StartWithSlide field.
|
||||
*/
|
||||
public static function showStartWithSlide($start_with_slide = 0, $slider = array())
|
||||
{
|
||||
$result = 1;
|
||||
if (is_array($slider)) {
|
||||
$start_with_slide = (int) $start_with_slide;
|
||||
$slider_num = count($slider);
|
||||
// 1 <= $start_with_slide <= $slider_num
|
||||
if (1 <= $start_with_slide && $start_with_slide <= $slider_num) {
|
||||
$result = $start_with_slide;
|
||||
}
|
||||
}
|
||||
|
||||
$result--; // index begin from 0
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getDelay()
|
||||
{
|
||||
$temp_result = Tools::jsonDecode(LeoSlideshowSlide::base64Decode($this->params), true);
|
||||
$result = $temp_result['delay'];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getGroupOption()
|
||||
{
|
||||
$result = array();
|
||||
$mod_group = new LeoSlideshowGroup();
|
||||
$groups = $mod_group->getGroups(null, null);
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$temp = array();
|
||||
$temp['id'] = $group['id_leoslideshow_groups'];
|
||||
$temp['name'] = $group['title'];
|
||||
$result[] = $temp;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get group to frontend
|
||||
*/
|
||||
public static function getActiveGroupByHook($hook_name = '', $active = 1)
|
||||
{
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
$sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'leoslideshow_groups gr
|
||||
WHERE gr.id_shop = ' . (int) $id_shop . ' AND gr.hook = "' . pSQL($hook_name) . '"' . ($active ? ' AND gr.`active` = 1' : ' ') . '
|
||||
ORDER BY gr.id_leoslideshow_groups';
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get group to preview
|
||||
*/
|
||||
public static function getGroupByID($id_group)
|
||||
{
|
||||
$sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'leoslideshow_groups gr
|
||||
WHERE gr.id_leoslideshow_groups = ' . (int) $id_group;
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
}
|
||||
|
||||
public function setData($data = array())
|
||||
{
|
||||
if (is_array($data)) {
|
||||
$this->data = $data;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function beforeLoad()
|
||||
{
|
||||
$data = $this->data;
|
||||
|
||||
#Timer
|
||||
if ($data['timer_show'] == LeoSlideshowConfig::TIMER_HIDE_AUTO) {
|
||||
$data['autoAdvance'] = 1;
|
||||
} elseif ($data['timer_show'] == LeoSlideshowConfig::TIMER_HIDE_STOP) {
|
||||
$data['autoAdvance'] = 0;
|
||||
} elseif ($data['timer_show'] == LeoSlideshowConfig::TIMER_SHOW_AUTO) {
|
||||
$data['autoAdvance'] = 1;
|
||||
} elseif ($data['timer_show'] == LeoSlideshowConfig::TIMER_SHOW_STOP) {
|
||||
$data['autoAdvance'] = 0;
|
||||
}
|
||||
|
||||
# Navigator
|
||||
if ($data['navigator_type'] == LeoSlideshowConfig::IVIEW_NAV_THUMBNAIL) {
|
||||
$data['controlNavThumbs'] = 1;
|
||||
} elseif ($data['navigator_type'] == LeoSlideshowConfig::IVIEW_NAV_BULLET) {
|
||||
$data['controlNavThumbs'] = 0;
|
||||
}
|
||||
|
||||
# Multi language
|
||||
$data['playLabel'] = $this->leo_module->l('Play');
|
||||
$data['pauseLabel'] = $this->leo_module->l('Pause');
|
||||
$data['closeLabel'] = $this->leo_module->l('Close');
|
||||
$data['nextLabel'] = $this->leo_module->l('Next');
|
||||
$data['previousLabel'] = $this->leo_module->l('Previous');
|
||||
|
||||
$this->data = $data;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function loadFrontEnd()
|
||||
{
|
||||
return $this->getData();
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
$sql = 'SELECT id_leoslideshow_groups FROM ' . _DB_PREFIX_ . 'leoslideshow_groups';
|
||||
$groups = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
$number_groups = count($groups);
|
||||
return $number_groups;
|
||||
}
|
||||
|
||||
public static function autoCreateKey()
|
||||
{
|
||||
$sql = 'SELECT ' . self::$definition['primary'] . ' FROM ' . _DB_PREFIX_ . self::$definition['table'] .
|
||||
' WHERE randkey IS NULL OR randkey = ""';
|
||||
|
||||
$rows = Db::getInstance()->executes($sql);
|
||||
foreach ($rows as $row) {
|
||||
$mod_group = new LeoSlideshowGroup((int) $row[self::$definition['primary']]);
|
||||
include_once(_PS_MODULE_DIR_ . 'leoslideshow/libs/Helper.php');
|
||||
$mod_group->randkey = LeoSlideshowHelper::genKey();
|
||||
$mod_group->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
436
modules/leoslideshow/classes/LeoSlideshowSlide.php
Normal file
436
modules/leoslideshow/classes/LeoSlideshowSlide.php
Normal file
@@ -0,0 +1,436 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Leotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Adds image, text or video to your homepage.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author leotheme <leotheme@gmail.com>
|
||||
* @copyright 2007-2015 Leotheme
|
||||
* @license http://leotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class LeoSlideshowSlide extends ObjectModel
|
||||
{
|
||||
|
||||
public $title;
|
||||
public $link;
|
||||
public $image;
|
||||
public $id_group;
|
||||
public $position;
|
||||
public $active;
|
||||
public $params;
|
||||
public $thumbnail;
|
||||
public $video;
|
||||
public $layersparams;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'leoslideshow_slides',
|
||||
'primary' => 'id_leoslideshow_slides',
|
||||
'multilang' => true,
|
||||
'fields' => array(
|
||||
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
|
||||
'id_group' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt', 'required' => true),
|
||||
'position' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt', 'required' => true),
|
||||
# Lang fields
|
||||
'title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 255),
|
||||
'link' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isUrl', 'required' => false, 'size' => 255),
|
||||
'image' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml'),
|
||||
'thumbnail' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml'),
|
||||
'params' => array('type' => self::TYPE_HTML, 'lang' => false),
|
||||
'video' => array('type' => self::TYPE_HTML, 'lang' => true),
|
||||
'layersparams' => array('type' => self::TYPE_HTML, 'lang' => true)
|
||||
)
|
||||
);
|
||||
|
||||
public function add($autodate = true, $null_values = false)
|
||||
{
|
||||
$res = parent::add($autodate, $null_values);
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$res = true;
|
||||
|
||||
// $images = $this->image;
|
||||
// foreach ($images as $image) {
|
||||
// if (preg_match('/sample/', $image) === 0)
|
||||
// if ($image && file_exists(dirname(__FILE__).'/images/'.$image))
|
||||
// $res &= @unlink(dirname(__FILE__).'/images/'.$image);
|
||||
// }
|
||||
|
||||
$res &= $this->reOrderPositions();
|
||||
|
||||
$sql = 'DELETE FROM `' . _DB_PREFIX_ . 'leoslideshow_slides`
|
||||
WHERE `id_leoslideshow_slides` = ' . (int) $this->id;
|
||||
$res &= Db::getInstance()->execute($sql);
|
||||
|
||||
$res &= parent::delete();
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function sliderExist($id_slider)
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('SELECT gr.`id_leoslideshow_slides` as id
|
||||
FROM `' . _DB_PREFIX_ . 'leoslideshow_slides` gr
|
||||
WHERE gr.`id_leoslideshow_slides` = ' . (int) $id_slider);
|
||||
}
|
||||
|
||||
public function reOrderPositions()
|
||||
{
|
||||
$id_slide = $this->id;
|
||||
|
||||
$sql = 'SELECT MAX(hss.`position`) as position
|
||||
FROM `' . _DB_PREFIX_ . 'leoslideshow_slides` hss
|
||||
WHERE hss.`id_group` = ' . (int) $this->id_group;
|
||||
$max = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
if ((int) $max == (int) $id_slide) {
|
||||
# module validation
|
||||
return true;
|
||||
}
|
||||
|
||||
$sql = 'SELECT hss.`position` as position, hss.`id_leoslideshow_slides` as id_slide
|
||||
FROM `' . _DB_PREFIX_ . 'leoslideshow_slides` hss
|
||||
WHERE hss.`id_group` = ' . (int) $this->id_group . ' AND hss.`position` > ' . (int) $this->position;
|
||||
$rows = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$current_slide = new LeoSlideshowSlide($row['id_slide']);
|
||||
--$current_slide->position;
|
||||
$current_slide->update();
|
||||
unset($current_slide);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDelay()
|
||||
{
|
||||
$temp_result = Tools::jsonDecode(LeoSlideshowSlide::base64Decode($this->params), true);
|
||||
$result = $temp_result['delay'];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* System get Delay value from GROUP when SLIDER's Delay <= 0
|
||||
*/
|
||||
public static function showDelay($slide_id = 0, $delay = null, $group_delay = null)
|
||||
{
|
||||
$default = 9000;
|
||||
|
||||
# Get Delay form SLIDER
|
||||
if ($delay > 0) {
|
||||
# module validation
|
||||
return $delay;
|
||||
}
|
||||
|
||||
if (!empty($slide_id)) {
|
||||
$mod_slide = new LeoSlideshowSlide($slide_id);
|
||||
$s_delay = $mod_slide->getDelay();
|
||||
if ($s_delay > 0) {
|
||||
# module validation
|
||||
return $s_delay;
|
||||
}
|
||||
}
|
||||
# Get Delay form GROUP
|
||||
if ($group_delay > 0) {
|
||||
# module validation
|
||||
return $group_delay;
|
||||
}
|
||||
|
||||
if (!empty($slide_id)) {
|
||||
$mod_slide = new LeoSlideshowSlide($slide_id);
|
||||
$mod_group = new LeoSlideshowGroup($mod_slide->id_group);
|
||||
$g_delay = $mod_group->getDelay();
|
||||
if ($g_delay > 0) {
|
||||
# module validation
|
||||
return $g_delay;
|
||||
}
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
public static function renderTarget($target = '')
|
||||
{
|
||||
$html = '_self';
|
||||
if (!empty($target)) {
|
||||
if (LeoSlideshowStatus::SLIDER_TARGET_SAME == $target) {
|
||||
# module validation
|
||||
$html = '_self';
|
||||
} elseif (LeoSlideshowStatus::SLIDER_TARGET_NEW == $target) {
|
||||
$html = '_blank';
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function mergeData($data = array())
|
||||
{
|
||||
if (is_array($data)) {
|
||||
foreach ($data as $key => $value) {
|
||||
# module validation
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function mergeSlider($data = array())
|
||||
{
|
||||
return $this->mergeData($data);
|
||||
}
|
||||
|
||||
public function mergeParams($pattern)
|
||||
{
|
||||
$params_data = array_merge($pattern, Tools::jsonDecode(LeoSlideshowSlide::base64Decode($this->params), true));
|
||||
$this->mergeData($params_data);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function validate($module)
|
||||
{
|
||||
$start_timestamp = strtotime($this->start_date_time);
|
||||
$end_timestamp = strtotime($this->end_date_time);
|
||||
|
||||
if ($end_timestamp == 0 && $start_timestamp == 0) {
|
||||
# module validation
|
||||
// $end_timestamp, $start_timestamp are valid
|
||||
} elseif ($end_timestamp > $start_timestamp && $end_timestamp != 0 && $start_timestamp != 0) {
|
||||
# module validation
|
||||
// $end_timestamp, $start_timestamp are valid
|
||||
} else {
|
||||
# module validation
|
||||
throw new Exception($module->l("'Start End Time' must be equal or more than 'Start Date Time'"));
|
||||
}
|
||||
}
|
||||
|
||||
public function getStatusTime()
|
||||
{
|
||||
$timestamp = time();
|
||||
$start_date_time = strtotime($this->start_date_time);
|
||||
$end_date_time = strtotime($this->end_date_time);
|
||||
|
||||
if ($this->active == LeoSlideshowStatus::SLIDER_STATUS_DISABLE) {
|
||||
# module validation
|
||||
return LeoSlideshowStatus::SLIDER_STATUS_DISABLE;
|
||||
}
|
||||
|
||||
# NOT SET TIME
|
||||
if ($this->active == LeoSlideshowStatus::SLIDER_STATUS_ENABLE && $start_date_time == 0 && $end_date_time == 0) {
|
||||
# module validation
|
||||
return LeoSlideshowStatus::SLIDER_STATUS_ENABLE;
|
||||
}
|
||||
|
||||
// HAVE SET TIME
|
||||
if ($this->active == LeoSlideshowStatus::SLIDER_STATUS_ENABLE && $start_date_time <= $timestamp && $timestamp <= $end_date_time) {
|
||||
# module validation
|
||||
return LeoSlideshowStatus::SLIDER_STATUS_ENABLE;
|
||||
}
|
||||
|
||||
if ($this->active == LeoSlideshowStatus::SLIDER_STATUS_ENABLE && $timestamp < $start_date_time) {
|
||||
# module validation
|
||||
return LeoSlideshowStatus::SLIDER_STATUS_COMING;
|
||||
}
|
||||
|
||||
# DEFAULT
|
||||
return LeoSlideshowStatus::SLIDER_STATUS_DISABLE;
|
||||
}
|
||||
|
||||
public static function filterSlider($sliders = array(), $slider_data = array())
|
||||
{
|
||||
// echo '<pre>';
|
||||
// print_r($sliders);
|
||||
// echo '============';
|
||||
foreach ($sliders as $key => $slider) {
|
||||
$mod_slide = new LeoSlideshowSlide();
|
||||
$mod_slide->mergeSlider($slider)->mergeParams($slider_data);
|
||||
if ($mod_slide->getStatusTime() == LeoSlideshowStatus::SLIDER_STATUS_ENABLE) {
|
||||
# module validation
|
||||
# data is valid
|
||||
} else {
|
||||
unset($sliders[$key]);
|
||||
# module validation
|
||||
}
|
||||
}
|
||||
// echo '<pre>';
|
||||
// print_r($sliders);die();
|
||||
|
||||
return $sliders;
|
||||
}
|
||||
|
||||
public static function base64Decode($data)
|
||||
{
|
||||
return call_user_func('base64_decode', $data);
|
||||
}
|
||||
|
||||
public static function base64Encode($data)
|
||||
{
|
||||
return call_user_func('base64_encode', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* remove data follow language : delete layer in Deleting Language
|
||||
*/
|
||||
public function completeDatabase($param = array())
|
||||
{
|
||||
if (isset($param['lang']) && !empty($param['lang'])) {
|
||||
$languages = Context::getContext()->controller->getLanguages();
|
||||
$lang_arr = array();
|
||||
foreach ($languages as $lang) {
|
||||
# module validation
|
||||
$lang_arr[] = $lang['id_lang'];
|
||||
}
|
||||
|
||||
foreach ($this->layersparams as $key => $value) {
|
||||
if (!in_array($key, $lang_arr)) {
|
||||
unset($this->title[$key]);
|
||||
unset($this->link[$key]);
|
||||
unset($this->image[$key]);
|
||||
unset($this->thumbnail[$key]);
|
||||
unset($this->video[$key]);
|
||||
unset($this->layersparams[$key]);
|
||||
}
|
||||
# module validation
|
||||
unset($value);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function debug()
|
||||
{
|
||||
$languages = Context::getContext()->controller->getLanguages();
|
||||
|
||||
# layersparams_debug
|
||||
$this->layersparams_debug = array();
|
||||
foreach ($this->layersparams as $key => $value) {
|
||||
$lang_iso = '';
|
||||
foreach ($languages as $lang) {
|
||||
if ($lang['id_lang'] == $key) {
|
||||
$lang_iso = $lang['iso_code'];
|
||||
}
|
||||
}
|
||||
$this->layersparams_debug['lang_id_' . $key . '_' . $lang_iso] = Tools::jsonDecode(LeoSlideshowSlide::base64Decode($value), true);
|
||||
}
|
||||
unset($this->layersparams);
|
||||
|
||||
# params_debug
|
||||
$this->params_debug = array();
|
||||
foreach ($this->params as $key => $value) {
|
||||
$lang_iso = '';
|
||||
foreach ($languages as $lang) {
|
||||
if ($lang['id_lang'] == $key) {
|
||||
$lang_iso = $lang['iso_code'];
|
||||
}
|
||||
}
|
||||
$this->params_debug['lang_id_' . $key . '_' . $lang_iso] = Tools::jsonDecode(LeoSlideshowSlide::base64Decode($value), true);
|
||||
}
|
||||
unset($this->params);
|
||||
|
||||
# video_debug
|
||||
$this->video_debug = array();
|
||||
foreach ($this->params as $key => $value) {
|
||||
$lang_iso = '';
|
||||
foreach ($languages as $lang) {
|
||||
if ($lang['id_lang'] == $key) {
|
||||
$lang_iso = $lang['iso_code'];
|
||||
}
|
||||
}
|
||||
$this->video_debug['lang_id_' . $key . '_' . $lang_iso] = Tools::jsonDecode(LeoSlideshowSlide::base64Decode($value), true);
|
||||
}
|
||||
unset($this->video);
|
||||
unset($this->def);
|
||||
unset($this->fieldsRequired);
|
||||
unset($this->fieldsSize);
|
||||
unset($this->fieldsValidate);
|
||||
unset($this->fieldsRequiredLang);
|
||||
unset($this->fieldsSizeLang);
|
||||
unset($this->webserviceParameters);
|
||||
unset($this->fieldsValidateLang);
|
||||
unset($this->tables);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Background-color, or image
|
||||
*/
|
||||
public static function getBackground($group = array(), &$slider = array())
|
||||
{
|
||||
if (isset($group['background_image']) && $group['background_image'] == '1') {
|
||||
# BACKGROUND IS IMAGE
|
||||
$slider['background_type'] = 'image';
|
||||
$slider['background_color'] = '';
|
||||
|
||||
if (isset($slider['image']) && $slider['image'] != '') {
|
||||
# module validation
|
||||
// get form slide
|
||||
} elseif (isset($group['background_url']) && $group['background_url'] != '') {
|
||||
# module validation
|
||||
$slider['image'] = $group['background_url']; // get image from group
|
||||
} else {
|
||||
// slide and group dont have image
|
||||
$slider['background_type'] = 'image';
|
||||
$slider['image'] = 'views/img/blank.gif';
|
||||
}
|
||||
} elseif (isset($group['background_image']) && $group['background_image'] == '0') {
|
||||
# BACKGROUND IS COLOR
|
||||
$slider['background_type'] = 'color';
|
||||
$slider['image'] = 'views/img/blank.gif';
|
||||
|
||||
if (isset($slider['video']['background_color']) && $slider['video']['background_color'] != '') {
|
||||
# module validation
|
||||
// get form slide
|
||||
} elseif (isset($group['background_color']) && $group['background_color'] != '') {
|
||||
# module validation
|
||||
$slider['image'] = $group['background_color']; // get image from group
|
||||
} else {
|
||||
// Slide and Group dont have image
|
||||
$slider['background_type'] = 'image';
|
||||
$slider['image'] = 'img/blank.gif';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function showBulletCustomHTML($slide_params, $sliders)
|
||||
{
|
||||
if ($slide_params['navigator_type'] == LeoSlideshowConfig::IVIEW_NAV_BULLET && $slide_params['enable_custom_html_bullet'] == LeoSlideshowConfig::ENABLE) {
|
||||
foreach ($sliders as $key => &$slider) {
|
||||
$slider['enable_custom_html_bullet'] = LeoSlideshowConfig::ENABLE;
|
||||
$slider['bullet_class'] = $slider['params']['bullet_class'];
|
||||
unset($slider['params']['bullet_class']);
|
||||
$slider['bullet_description'] = isset($slider['video']['bullet_description']) ? $slider['video']['bullet_description'] : '';
|
||||
unset($slider['video']['bullet_description']);
|
||||
unset($key);
|
||||
}
|
||||
} else {
|
||||
foreach ($sliders as $key => &$slider) {
|
||||
# module validation
|
||||
$slider['enable_custom_html_bullet'] = LeoSlideshowConfig::DISABLE;
|
||||
}
|
||||
}
|
||||
return $sliders;
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
$sql = 'SELECT id_leoslideshow_slides FROM ' . _DB_PREFIX_ . 'leoslideshow_slides';
|
||||
$groups = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
$number_groups = count($groups);
|
||||
return $number_groups;
|
||||
}
|
||||
}
|
||||
48
modules/leoslideshow/classes/LeoSlideshowStatus.php
Normal file
48
modules/leoslideshow/classes/LeoSlideshowStatus.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Leotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Adds image, text or video to your homepage.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author leotheme <leotheme@gmail.com>
|
||||
* @copyright 2007-2015 Leotheme
|
||||
* @license http://leotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class LeoSlideshowStatus extends Module
|
||||
{
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance()
|
||||
{
|
||||
if (self::$instance == null) {
|
||||
# module validation
|
||||
self::$instance = new LeoSlideshowStatus();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
const SLIDER_TARGET_SAME = 'same';
|
||||
const SLIDER_TARGET_NEW = 'new';
|
||||
|
||||
public function getSliderTargetOption()
|
||||
{
|
||||
return array(
|
||||
array('id' => self::SLIDER_TARGET_SAME, 'name' => $this->l('Same Window')),
|
||||
array('id' => self::SLIDER_TARGET_NEW, 'name' => $this->l('New Window')),
|
||||
);
|
||||
}
|
||||
const SLIDER_STATUS_DISABLE = '0';
|
||||
const SLIDER_STATUS_ENABLE = '1';
|
||||
const SLIDER_STATUS_COMING = '2';
|
||||
const GROUP_STATUS_DISABLE = '0';
|
||||
const GROUP_STATUS_ENABLE = '1';
|
||||
}
|
||||
35
modules/leoslideshow/classes/index.php
Normal file
35
modules/leoslideshow/classes/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;
|
||||
Reference in New Issue
Block a user