first commit

This commit is contained in:
2024-11-05 12:22:50 +01:00
commit e5682a3912
19641 changed files with 2948548 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,315 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 BtmegamenuGroup extends ObjectModel
{
public $title;
public $title_fo;
public $active;
public $hook;
public $position;
public $id_shop;
public $params;
//DONGD:: check call via appagebuilder
public $active_ap;
public $randkey;
public $data = array();
public $form_id;
const GROUP_STATUS_DISABLE = '0';
const GROUP_STATUS_ENABLE = '1';
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'btmegamenu_group',
'primary' => 'id_btmegamenu_group',
'multilang' => true,
'fields' => array(
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
//'hook' => array('type' => self::TYPE_STRING, 'lang' => false, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 64),
'hook' => array('type' => self::TYPE_STRING, 'lang' => false, 'validate' => 'isCleanHtml', 'size' => 64),
'position' => array('type' => self::TYPE_INT),
'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),
'form_id' => array('type' => self::TYPE_STRING, 'lang' => false, 'size' => 255),
# Lang fields
'title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255),
'title_fo' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
)
);
public function add($autodate = true, $null_values = false)
{
$res = parent::add($autodate, $null_values);
return $res;
}
public static function groupExists($id_group, $id_shop = null)
{
$req = 'SELECT gr.`id_btmegamenu_group` as id_group
FROM `'._DB_PREFIX_.'btmegamenu_group` gr
WHERE gr.`id_btmegamenu_group` = '.(int)$id_group;
if ($id_shop != null) {
$req .= ' AND gr.`id_shop` = '.(int)$id_shop;
}
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($req);
return ($row);
}
public static function getGroups()
{
$context = Context::getContext();
$id_shop = $context->shop->id;
$id_lang = $context->language->id;
$cacheId = 'leobootstrapmenu_classes_BtmegamenuGroup.php_____getGroups()_' . md5($id_shop.$id_lang);
if (!Cache::isStored($cacheId)) {
$sql = 'SELECT * FROM `'._DB_PREFIX_.'btmegamenu_group` gr
LEFT JOIN '._DB_PREFIX_.'btmegamenu_group_lang grl ON gr.id_btmegamenu_group = grl.id_btmegamenu_group AND grl.id_lang = '.(int)$id_lang.'
WHERE (`id_shop` = '.(int)$id_shop.')';
$result = Db::getInstance()->executes($sql);
Cache::store($cacheId, $result);
} else {
$result = Cache::retrieve($cacheId);
}
return $result;
}
/**
* $key : field in db
* $value : value in db
* $one : default return one record
*/
public static function cacheGroupsByFields($params = array(), $one = false)
{
$result = array();
$groups = self::getGroups();
foreach ($groups as $group) {
$check_field = true;
foreach ($params as $key => $value) {
if ($group[$key] != $value) {
$check_field = false;
break;
}
}
if ($check_field) {
if ($one === false) {
$result = $group;
break;
} else {
$result[] = $group;
}
}
}
return $result;
}
public function delete()
{
$res = true;
$sql = 'DELETE FROM `'._DB_PREFIX_.'btmegamenu_group` '
.'WHERE `id_btmegamenu_group` = '.(int)$this->id;
$res &= Db::getInstance()->execute($sql);
$sql = 'DELETE FROM `'._DB_PREFIX_.'btmegamenu_group_lang` '
.'WHERE `id_btmegamenu_group` = '.(int)$this->id;
$res &= Db::getInstance()->execute($sql);
$sql = 'SELECT bt.`id_btmegamenu` as id
FROM `'._DB_PREFIX_.'btmegamenu` bt
WHERE bt.`id_group` = '.(int)$this->id;
$btmegamenu = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if ($btmegamenu) {
$where = '';
foreach ($btmegamenu as $bt) {
$where .= $where ? ','.(int)$bt['id'] : (int)$bt['id'];
}
$sql = 'DELETE FROM `'._DB_PREFIX_.'btmegamenu` '
.'WHERE `id_btmegamenu` IN ('.$where.')';
Db::getInstance()->execute($sql);
$sql = 'DELETE FROM `'._DB_PREFIX_.'btmegamenu_lang` '
.'WHERE `id_btmegamenu` IN ('.$where.')';
Db::getInstance()->execute($sql);
$sql = 'DELETE FROM `'._DB_PREFIX_.'btmegamenu_shop` '
.'WHERE `id_btmegamenu` IN ('.$where.')';
Db::getInstance()->execute($sql);
}
$res &= parent::delete();
return $res;
}
/**
* Get group to frontend
*/
public static function getActiveGroupByHook($hook_name = '', $active = 1)
{
$id_shop = Context::getContext()->shop->id;
$id_lang = Context::getContext()->language->id;
$sql = '
SELECT *
FROM '._DB_PREFIX_.'btmegamenu_group gr
LEFT JOIN '._DB_PREFIX_.'btmegamenu_group_lang grl ON gr.id_btmegamenu_group = grl.id_btmegamenu_group AND grl.id_lang = '.(int)$id_lang.'
WHERE gr.id_shop = '.(int)$id_shop.'
AND gr.hook = "'.pSQL($hook_name).'"'.
($active ? ' AND gr.`active` = 1' : ' ').'
ORDER BY gr.position';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}
/**
* Get group to preview
*/
public static function getGroupByID($id_group)
{
$sql = '
SELECT *
FROM '._DB_PREFIX_.'btmegamenu_group gr
WHERE gr.id_btmegamenu_group = '.(int)$id_group;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
}
public function count()
{
$sql = 'SELECT id_btmegamenu_group FROM '._DB_PREFIX_.'btmegamenu_group';
$groups = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
$number_groups = count($groups);
return $number_groups;
}
// get last position of group
public static function getLastPosition($id_shop)
{
return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.'btmegamenu_group` WHERE `id_shop` = '.(int)$id_shop));
}
// get all menu of group
public static function getMenuByGroup($id_group)
{
$sql = 'SELECT `id_btmegamenu`,`id_parent` FROM `'._DB_PREFIX_.'btmegamenu`
WHERE `id_group` = '.(int)$id_group.'
ORDER BY `id_parent` ASC';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}
// get all menu parent of group
public static function getMenuParentByGroup($id_group)
{
$sql = 'SELECT `id_btmegamenu`,`id_parent` FROM `'._DB_PREFIX_.'btmegamenu`
WHERE `id_group` = '.(int)$id_group.' AND `id_parent` = 0';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}
// set data for group when import
public static function setDataForGroup($group, $content, $override)
{
$languages = Language::getLanguages();
$lang_list = array();
foreach ($languages as $lang) {
# module validation
$lang_list[$lang['iso_code']] = $lang['id_lang'];
}
if (is_array($content['title'])) {
foreach ($content['title'] as $key => $title_item) {
if (isset($lang_list[$key])) {
$group->title[$lang_list[$key]] = $title_item;
}
}
} else {
foreach ($languages as $lang) {
$group->title[$lang['id_lang']] = $content['title'];
}
}
if (is_array($content['title_fo'])) {
foreach ($content['title_fo'] as $key => $title_item) {
if (isset($lang_list[$key])) {
$group->title_fo[$lang_list[$key]] = $title_item;
}
}
} else {
$group_title_fo = '';
foreach ($languages as $lang) {
if ($lang['iso_code'] == 'en') {
$group_title_fo = 'Categories';
}
if ($lang['iso_code'] == 'es') {
$group_title_fo = 'Categorías';
}
if ($lang['iso_code'] == 'fr') {
$group_title_fo = 'Catégories';
}
if ($lang['iso_code'] == 'de') {
$group_title_fo = 'Kategorien';
}
if ($lang['iso_code'] == 'it') {
$group_title_fo = 'Categorie';
}
if ($lang['iso_code'] == 'ar') {
$group_title_fo = 'ال<D8A7>?ئات';
}
$group->title_fo[$lang['id_lang']] = $group_title_fo;
}
}
$group->id_shop = Context::getContext()->shop->id;
$group->hook = $content['hook'];
if (!$override) {
$group->position = self::getLastPosition(Context::getContext()->shop->id);
include_once(_PS_MODULE_DIR_.'leobootstrapmenu/libs/Helper.php');
$group->randkey = LeoBtmegamenuHelper::genKey();
}
$group->active = $content['active'];
$group->params = $content['params'];
$group->active_ap = $content['active_ap'];
return $group;
}
public static function autoCreateKey()
{
$sql = 'SELECT '.self::$definition['primary'].' FROM '._DB_PREFIX_.bqSQL(self::$definition['table']).
' WHERE randkey IS NULL OR randkey = ""';
$rows = Db::getInstance()->executes($sql);
foreach ($rows as $row) {
$mod_group = new BtmegamenuGroup((int)$row[self::$definition['primary']]);
include_once(_PS_MODULE_DIR_.'leobootstrapmenu/libs/Helper.php');
$mod_group->randkey = LeoBtmegamenuHelper::genKey();
$mod_group->update();
}
}
}

View File

@@ -0,0 +1,36 @@
<?php
/*
* 2007-2012 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-2012 PrestaShop SA
* @version Release: $Revision: 13573 $
* @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,301 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* DISCLAIMER
*
* @author leotheme <leotheme@gmail.com>
* @copyright 2007-2015 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
if (!defined('_PS_VERSION_')) {
# module validation
exit;
}
if (!class_exists('LeoWidget')) {
/**
* LeoFooterBuilderWidget Model Class
*/
class LeoWidget extends ObjectModel
{
public $name;
public $type;
public $params;
public $key_widget;
public $id_shop;
private $widgets = array();
public $modName = 'leobootstrapmenu';
public $theme = '';
public $langID = 1;
public $engines = array();
public $engineTypes = array();
public function setTheme($theme)
{
$this->theme = $theme;
return $this;
}
public static $definition = array(
'table' => 'btmegamenu_widgets',
'primary' => 'id_btmegamenu_widgets',
'fields' => array(
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255, 'required' => true),
'type' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
'params' => array('type' => self::TYPE_HTML, 'validate' => 'isString'),
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt', 'required' => true),
'key_widget' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt', 'size' => 11)
)
);
/**
* Get translation for a given module text
*
* Note: $specific parameter is mandatory for library files.
* Otherwise, translation key will not match for Module library
* when module is loaded with eval() Module::getModulesOnDisk()
*
* @param string $string String to translate
* @param boolean|string $specific filename to use in translation key
* @return string Translation
*/
public function l($string, $specific = false)
{
return Translate::getModuleTranslation($this->modName, $string, ($specific) ? $specific : $this->modName);
}
public function update($null_values = false)
{
// validate module
unset($null_values);
return Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'btmegamenu_widgets SET `name`= "'.pSQL($this->name).'", `type`= "'.pSQL($this->type).'", `params`= "'.pSQL($this->params).'", `id_shop` = '.(int)$this->id_shop.', `key_widget` = '.(int)$this->key_widget.' WHERE `id_btmegamenu_widgets` = '.(int)$this->id.' AND `id_shop` = '.(int)Context::getContext()->shop->id);
}
public function delete()
{
$this->clearCaches();
return parent::delete();
}
public function loadEngines()
{
if (!$this->engines) {
$wds = glob(dirname(__FILE__).'/widget/*.php');
foreach ($wds as $w) {
if (basename($w) == 'index.php') {
continue;
}
require_once($w);
$f = str_replace('.php', '', basename($w));
//DOGNND:: validate module
$validate_class = str_replace('_', '', $f);
$class = 'LeoWidget'.Tools::ucfirst($validate_class);
if (class_exists($class)) {
$this->engines[$f] = new $class;
$this->engines[$f]->id_shop = Context::getContext()->shop->id;
$this->engines[$f]->langID = Context::getContext()->language->id;
$this->engineTypes[$f] = $this->engines[$f]->getWidgetInfo();
$this->engineTypes[$f]['type'] = $f;
$this->engineTypes[$f]['for'] = $this->engines[$f]->for_module;
}
}
}
}
/**
* get list of supported widget types.
*/
public function getTypes()
{
return $this->engineTypes;
}
/**
* get list of widget rows.
*/
public function getWidgets()
{
$context = Context::getContext();
$id_shop = $context->shop->id;
$id_lang = $context->language->id;
$cacheId = 'leobootstrapmenu_classes_widget.php_____getWidgets()_' . md5($id_shop.$id_lang);
if (!Cache::isStored($cacheId)) {
$sql = ' SELECT * FROM '._DB_PREFIX_.'btmegamenu_widgets WHERE `id_shop` = '.(int)Context::getContext()->shop->id;
$result = Db::getInstance()->executes($sql);
Cache::store($cacheId, $result);
} else {
$result = Cache::retrieve($cacheId);
}
return $result;
}
/**
* get widget data row by id
*/
public function getWidetById($id, $id_shop)
{
$output = array(
'id' => '',
'id_btmegamenu_widgets' => '',
'name' => '',
'params' => '',
'type' => '',
);
if (!$id) {
# validate module
return $output;
}
$sql = ' SELECT * FROM '._DB_PREFIX_.'btmegamenu_widgets WHERE id_btmegamenu_widgets='.(int)$id.' AND id_shop='.(int)$id_shop;
$row = Db::getInstance()->getRow($sql);
if ($row) {
$output = array_merge($output, $row);
$output['params'] = Tools::jsonDecode(call_user_func('base64'.'_decode', $output['params']), true);
$output['id'] = $output['id_btmegamenu_widgets'];
}
return $output;
}
/**
* get widget data row by id
*/
public function getWidetByKey($key, $id_shop)
{
$output = array(
'id' => '',
'id_btmegamenu_widgets' => '',
'name' => '',
'params' => '',
'type' => '',
'key_widget' => '',
);
if (!$key) {
# validate module
return $output;
}
$sql = ' SELECT * FROM '._DB_PREFIX_.'btmegamenu_widgets WHERE key_widget='.(int)$key.' AND id_shop='.(int)$id_shop;
$row = Db::getInstance()->getRow($sql);
if ($row) {
$output = array_merge($output, $row);
$output['params'] = Tools::jsonDecode(call_user_func('base64'.'_decode', $output['params']), true);
$output['id'] = $output['id_btmegamenu_widgets'];
}
return $output;
}
/**
* render widget Links Form.
*/
public function getWidgetInformationForm($args, $data)
{
$fields = array(
'html' => array('type' => 'textarea', 'value' => '', 'lang' => 1, 'values' => array(), 'attrs' => 'cols="40" rows="6"')
);
unset($args);
return $this->_renderFormByFields($fields, $data);
}
public function renderWidgetSubcategoriesContent($args, $setting)
{
# validate module
unset($args);
$t = array(
'category_id' => '',
'limit' => '12'
);
$setting = array_merge($t, $setting);
$category = new Category($setting['category_id'], $this->langID);
$subCategories = $category->getSubCategories($this->langID);
$setting['title'] = $category->name;
$setting['subcategories'] = $subCategories;
$output = array('type' => 'sub_categories', 'data' => $setting);
return $output;
}
/**
* general function to render FORM
*
* @param String $type is form type.
* @param Array default data values for inputs.
*
* @return Text.
*/
public function getForm($type, $data = array())
{
if (isset($this->engines[$type])) {
$args = array();
$this->engines[$type]->types = $this->getTypes();
return $this->engines[$type]->renderForm($args, $data);
}
return $this->l('Sorry, Form Setting is not avairiable for this type');
}
public function getWidgetContent($type, $data)
{
$args = array();
$data = Tools::jsonDecode(call_user_func('base64'.'_decode', $data), true);
$data['widget_heading'] = isset($data['widget_title_'.$this->langID]) ? Tools::stripslashes($data['widget_title_'.$this->langID]) : '';
if (isset($this->engines[$type])) {
$args = array();
return $this->engines[$type]->renderContent($args, $data);
}
return false;
}
public function renderContent($id)
{
$output = array('id' => $id, 'type' => '', 'data' => '');
if (isset($this->widgets[$id])) {
# validate module
$output = $this->getWidgetContent($this->widgets[$id]['type'], $this->widgets[$id]['params']);
}
return $output;
}
public function loadWidgets()
{
if (empty($this->widgets)) {
$widgets = $this->getWidgets();
foreach ($widgets as $widget) {
$widget['id'] = $widget['id_btmegamenu_widgets'];
$this->widgets[$widget['key_widget']] = $widget;
}
}
}
public function clearCaches()
{
if (file_exists(_PS_MODULE_DIR_.'leobootstrapmenu/leobootstrapmenu.php')) {
require_once(_PS_MODULE_DIR_.'leobootstrapmenu/leobootstrapmenu.php');
$leobootstrapmenu = new leobootstrapmenu();
$leobootstrapmenu->clearCache();
}
if (file_exists(_PS_MODULE_DIR_.'leomenusidebar/leomenusidebar.php')) {
require_once(_PS_MODULE_DIR_.'leomenusidebar/leomenusidebar.php');
$leomenusidebar = new leomenusidebar();
$leomenusidebar->clearCache();
}
if (file_exists(_PS_MODULE_DIR_.'leomanagewidgets/leomanagewidgets.php')) {
require_once(_PS_MODULE_DIR_.'leomanagewidgets/leomanagewidgets.php');
$leomanagewidgets = new LeoManagewidgets();
$leomanagewidgets->clearHookCache();
}
}
}
}

View File

@@ -0,0 +1,152 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 LeoWidgetAlert extends LeoWidgetBase
{
public $name = 'alert';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('Alert'), 'explain' => $this->l('Create a Alert Message Box Based on Bootstrap 3 typo'));
}
public function renderForm($args, $data)
{
# validate module
unset($args);
$helper = $this->getFormHelper();
$types = array();
$types[] = array(
'value' => 'alert-success',
'text' => $this->l('Alert Success')
);
$types[] = array(
'value' => 'alert-info',
'text' => $this->l('Alert Info')
);
$types[] = array(
'value' => 'alert-warning',
'text' => $this->l('Alert Warning')
);
$types[] = array(
'value' => 'alert-danger',
'text' => $this->l('Alert Danger')
);
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form.'),
),
'input' => array(
array(
'type' => 'textarea',
'label' => $this->l('Content'),
'name' => 'htmlcontent',
'cols' => 40,
'rows' => 10,
'value' => true,
'lang' => true,
'default' => '',
'autoload_rte' => true,
),
array(
'type' => 'select',
'label' => $this->l('Alert Type'),
'name' => 'alert_type',
'options' => array('query' => $types,
'id' => 'value',
'name' => 'text'),
'default' => '1',
'desc' => $this->l('Select a alert style')
),
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues($data),
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang
);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
# validate module
unset($args);
$t = array(
'name' => '',
'html' => '',
'alert_type' => ''
);
$setting = array_merge($t, $setting);
// $html = '';
$languageID = Context::getContext()->language->id;
$languageID = Context::getContext()->language->id;
$setting['html'] = isset($setting['htmlcontent_'.$languageID]) ? html_entity_decode($setting['htmlcontent_'.$languageID], ENT_QUOTES, 'UTF-8') : '';
$output = array('type' => 'alert', 'data' => $setting);
return $output;
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
if ($multi_lang == 0) {
return array(
'alert_type',
);
} elseif ($multi_lang == 1) {
return array(
'htmlcontent',
);
} elseif ($multi_lang == 2) {
return array(
);
}
}
}

View File

@@ -0,0 +1,391 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 LeoWidgetCategoryimage extends LeoWidgetBase
{
public $widget_name = 'category_image';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('Images of categories'), 'explain' => 'Chosing images for categories');
}
public function renderForm($args, $data)
{
# validate module
unset($args);
$helper = $this->getFormHelper();
$root = Category::getRootCategory();
$selected_cat = array();
$selected_cates = '';
$selected_images = '';
// $themeName = Context::getContext()->shop->getTheme();
$themeName = Context::getContext()->shop->theme->getName();
$image_path = 'themes/'.$themeName.'/assets/img/modules/leobootstrapmenu/icontab/';
if (!file_exists(_PS_ALL_THEMES_DIR_.$themeName.'/assets/img/modules/leobootstrapmenu/icontab/') && !is_dir(_PS_ALL_THEMES_DIR_.$themeName.'/assets/img/modules/leobootstrapmenu/icontab/')) {
@mkdir(_PS_ALL_THEMES_DIR_.$themeName.'/modules/', 0777, true);
@mkdir(_PS_ALL_THEMES_DIR_.$themeName.'/modules/leobootstrapmenu/', 0777, true);
if (!file_exists(_PS_ALL_THEMES_DIR_.$themeName.'/modules/leobootstrapmenu/index.php') && file_exists(_PS_IMG_DIR_.'index.php')) {
@copy(_PS_IMG_DIR_.'index.php', _PS_ALL_THEMES_DIR_.$themeName.'/modules/leobootstrapmenu/index.php');
}
@mkdir(_PS_ALL_THEMES_DIR_.$themeName.'/modules/leobootstrapmenu/img/', 0777, true);
if (!file_exists(_PS_ALL_THEMES_DIR_.$themeName.'/modules/leobootstrapmenu/img/index.php') && file_exists(_PS_IMG_DIR_.'index.php')) {
@copy(_PS_IMG_DIR_.'index.php', _PS_ALL_THEMES_DIR_.$themeName.'/modules/leobootstrapmenu/img/index.php');
}
@mkdir(_PS_ALL_THEMES_DIR_.$themeName.'/assets/img/modules/leobootstrapmenu/icontab/', 0777, true);
if (!file_exists(_PS_ALL_THEMES_DIR_.$themeName.'/assets/img/modules/leobootstrapmenu/icontab/index.php') && file_exists(_PS_IMG_DIR_.'index.php')) {
@copy(_PS_IMG_DIR_.'index.php', _PS_ALL_THEMES_DIR_.$themeName.'/assets/img/modules/leobootstrapmenu/icontab/index.php');
}
}
$imageList = $this->getImages($image_path);
if ($data) {
if ($data['params'] && isset($data['params']['categoryBox']) && $data['params']['categoryBox']) {
$selected_cat = $data['params']['categoryBox'];
}
if ($data['params'] && isset($data['params']['category_img']) && $data['params']['category_img']) {
//$selected_images = Tools::jsonDecode($data['params']['category_val'], true);
$selected_images = $data['params']['category_img'];
}
if ($data['params'] && isset($data['params']['selected_cates']) && $data['params']['selected_cates']) {
$selected_cates = $data['params']['selected_cates'];
}
}
// $cate = new Category(13);
// $result = $cate-> getParentsCategories();
$tree = new HelperTreeCategories('image_cate_tree', 'All Categories');
$tree->setRootCategory($root->id)->setUseCheckBox(true)->setUseSearch(true)->setSelectedCategories($selected_cat);
// $list_image = array('default.gif', 'leo.gif');
$orderby = array(
array(
'order' => 'position',
'name' => $this->l('Position')
),
array(
'order' => 'depth',
'name' => $this->l('Depth')
),
array(
'order' => 'name',
'name' => $this->l('Name')
)
);
$showicons = array(
array(
'show' => '1',
'name' => $this->l('Yes')
),
array(
'show' => '2',
'name' => $this->l('Level 1 categories')
),
array(
'show' => '0',
'name' => $this->l('No')
)
);
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form.'),
),
'input' => array(
array(
'type' => 'img_cat',
'name' => 'img_cat',
'imageList' => $imageList,
'selected_images' => $selected_images,
'selected_cates' => $selected_cates,
'lang' => true,
'tree' => $tree->render(),
'default' => '',
'desc' => $this->l('Please create and upload images to the folder: themes/[your_current_themename]/assets/img/modules/leobootstrapmenu/icontab/'),
),
array(
'type' => 'text',
'label' => $this->l('Depth'),
'name' => 'cate_depth',
'default' => '1',
),
array(
'type' => 'select',
'label' => $this->l('Order By:'),
'name' => 'orderby',
'default' => 'position',
'options' => array(
'query' => $orderby,
'id' => 'order',
'name' => 'name'
)
),
array(
'type' => 'select',
'label' => $this->l('Show icons:'),
'name' => 'showicons',
'default' => '1',
'options' => array(
'query' => $showicons,
'id' => 'show',
'name' => 'name'
)
),
array(
'type' => 'text',
'label' => $this->l('Limit'),
'name' => 'limit',
'default' => '5',
),
array(
'type' => 'hidden',
'name' => 'id_root',
'default' => '2',
),
array(
'type' => 'hidden',
'name' => 'id_lang',
'default' => '1',
),
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right sub_categories',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right sub_categories',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$data_form = $this->getConfigFieldsValues($data);
$data_form['id_root'] = $root->id;
$data_form['id_lang'] = Context::getContext()->employee->id_lang;
$helper->tpl_vars = array(
'fields_value' => $data_form,
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang,
);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
# validate module
unset($args);
// $category = new Category(3, 1 );
// $subCategories = $category->getSubCategories(1);
$images = array();
if (isset($setting['category_img']) && $setting['category_img']) {
# validate module
$images = Tools::jsonDecode($setting['category_img'], true);
}
$sql_filter = '';
$sql_sort = '';
if (isset($setting['orderby']) && $setting['orderby']) {
if ($setting['orderby'] == 'depth') {
$sql_sort = ' ORDER BY c.`level_depth` ASC';
}
if ($setting['orderby'] == 'position') {
$sql_sort = ' ORDER BY c.`level_depth` ASC, category_shop.`position` ASC';
}
if ($setting['orderby'] == 'name') {
$sql_sort = ' ORDER BY c.`level_depth` ASC, cl.`name` ASC';
}
}
$catids = (isset($setting['categoryBox']) && $setting['categoryBox']) ? ($setting['categoryBox']) : array();
$result = array();
$limit = (isset($setting['limit']) && $setting['limit']) ? $setting['limit'] : 5;
foreach ($catids as $cate_id) {
if (isset($setting['cate_depth']) && ($setting['cate_depth'] || $setting['cate_depth'] == '0')) {
# validate module
$sql_filter = ' AND c.`level_depth` <= '.(int)$setting['cate_depth'].' + (select c.`level_depth` from `'._DB_PREFIX_.'category` c where c.id_category ='.(int)$cate_id.')';
}
if ($limit) {
$result_cate = $this->getNestedCategories($images, $cate_id, Context::getContext()->language->id, true, null, true, $sql_filter, $sql_sort, $limit);
}
$result[] = $result_cate;
}
$setting['categories'] = $result;
$output = array('type' => 'category_image', 'data' => $setting);
return $output;
}
public function getImages($image_folder)
{
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
$url = Tools::htmlentitiesutf8($protocol.$_SERVER['HTTP_HOST'].__PS_BASE_URI__);
$path = _PS_ROOT_DIR_.'/'.$image_folder.'/';
$path = str_replace('//', '/', $path);
$oimages = array();
if (is_dir($path)) {
$images = glob($path.'*.*');
$exts = array('jpg', 'gif', 'png');
foreach ($images as $key => $image) {
# validate module
unset($key);
$ext = Tools::substr($image, Tools::strlen($image) - 3, Tools::strlen($image));
if (in_array(Tools::strtolower($ext), $exts)) {
$i = str_replace('\\', '/', $image_folder.'/'.basename($image));
$i = str_replace('//', '/', $i);
$aimage = array();
$aimage['path'] = $url.$i;
$aimage['name'] = basename($image);
$oimages[] = $aimage;
}
}
}
return $oimages;
}
public static function getNestedCategories($images, $root_category = null, $id_lang = false, $active = true, $groups = null, $use_shop_restriction = true, $sql_filter = '', $sql_sort = '', $sql_limit = '')
{
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
$url = Tools::htmlentitiesutf8($protocol.$_SERVER['HTTP_HOST'].__PS_BASE_URI__);
// $themeName = Context::getContext()->shop->getTheme();
$themeName = Context::getContext()->shop->theme->getName();
$image_path = 'themes/'.$themeName.'/assets/img/modules/leobootstrapmenu/icontab/';
if (isset($root_category) && !Validate::isInt($root_category)) {
die(Tools::displayError());
}
if (!Validate::isBool($active)) {
die(Tools::displayError());
}
if (isset($groups) && Group::isFeatureActive() && !is_array($groups)) {
$groups = (array)$groups;
}
$cache_id = 'Category::getNestedCategories_'.md5((int)$root_category.(int)$id_lang.(int)$active.(int)$active.(isset($groups) && Group::isFeatureActive() ? implode('', $groups) : ''));
if (!Cache::isStored($cache_id)) {
if ($sql_limit) {
$sql = '
(SELECT c.*, cl.*
FROM `'._DB_PREFIX_.'category` c
'.($use_shop_restriction ? Shop::addSqlAssociation('category', 'c') : '').'
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').'
WHERE c.`id_category`='.(int)$root_category.'
AND `id_lang`='.(int)$id_lang.($active ? ' AND c.`active` = 1' : '').') UNION';
}
$sql .= '
(SELECT c.*, cl.*
FROM `'._DB_PREFIX_.'category` c
'.($use_shop_restriction ? Shop::addSqlAssociation('category', 'c') : '').'
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').'
'.(isset($groups) && Group::isFeatureActive() ? 'LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON c.`id_category` = cg.`id_category`' : '').'
'.(isset($root_category) ? 'RIGHT JOIN `'._DB_PREFIX_.'category` c2 ON c2.`id_category` = '.(int)$root_category.' AND c.`nleft` >= c2.`nleft` AND c.`nright` <= c2.`nright`' : '').'
WHERE 1 '.$sql_filter.' '.($id_lang ? 'AND `id_lang` = '.(int)$id_lang : '').'
'.($active ? ' AND c.`active` = 1' : '');
if ($sql_limit) {
$sql .= ' AND c.`id_category`<>'.(int)$root_category;
}
$sql .= (isset($groups) && Group::isFeatureActive() ? ' AND cg.`id_group` IN ('.pSQL(implode(',', array_map('intval', $groups))).')' : '').'
'.(!$id_lang || (isset($groups) && Group::isFeatureActive()) ? ' GROUP BY c.`id_category`' : '').'
'.($sql_sort != '' ? $sql_sort : ' ORDER BY c.`level_depth` ASC').'
'.($sql_sort == '' && $use_shop_restriction ? ', category_shop.`position` ASC' : '');
if ($sql_limit) {
if ($sql_limit > 0) {
$sql_limit--;
}
$sql .= ' LIMIT 0,'.(int)$sql_limit;
}
$sql .= ')';
$result = Db::getInstance()->executeS($sql);
$categories = array();
$buff = array();
if (!isset($root_category)) {
$root_category = 1;
}
foreach ($result as $row) {
//add image to a category
if (array_key_exists($row['id_category'], $images)) {
# validate module
$row['image'] = $url.$image_path.$images[$row['id_category']];
}
$current = &$buff[$row['id_category']];
$current = $row;
if ($row['id_category'] == $root_category) {
# validate module
$categories[$row['id_category']] = &$current;
} else {
# validate module
$buff[$row['id_parent']]['children'][$row['id_category']] = &$current;
}
}
Cache::store($cache_id, $categories);
}
return Cache::retrieve($cache_id);
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
if ($multi_lang == 0) {
return array(
'categoryBox',
'category_img',
'cate_depth',
'orderby',
'showicons',
'limit',
'id_root',
'id_lang',
);
} elseif ($multi_lang == 1) {
return array(
);
} elseif ($multi_lang == 2) {
return array(
);
}
}
}

View File

@@ -0,0 +1,236 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 LeoWidgetFacebook extends LeoWidgetBase
{
public $name = 'facebook';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('Facebook'), 'explain' => 'Facebook Like Box');
}
public function renderForm($args, $data)
{
# validate module
unset($args);
$helper = $this->getFormHelper();
$soption = array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
);
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form.'),
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Page URL'),
'name' => 'page_url',
'default' => 'https://www.facebook.com/LeoTheme',
),
// array(
// 'type' => 'switch',
// 'label' => $this->l('Is Border'),
// 'name' => 'border',
// 'values' => $soption,
// 'default' => '1',
// ),
// array(
// 'type' => 'select',
// 'label' => $this->l('Color'),
// 'name' => 'target',
// 'options' => array('query' => array(
// array('id' => 'dark', 'name' => $this->l('Dark')),
// array('id' => 'light', 'name' => $this->l('Light')),
// ),
// 'id' => 'id',
// 'name' => 'name'),
// 'default' => '_self',
// ),
array(
'type' => 'checkbox',
'label' => $this->l('Tab Display'),
'name' => 'tabdisplay',
'multiple' => true,
'values' => array(
'query' => array(
array('key' => 'timeline', 'name' => $this->l('Timeline')),
array('key' => 'events', 'name' => $this->l('Events')),
array('key' => 'messages', 'name' => $this->l('Messages')),
),
'id' => 'key',
'name' => 'name'
),
'default' => '',
),
array(
'type' => 'text',
'label' => $this->l('Width'),
'name' => 'width',
'default' => '340',
'desc' => $this->l('Min: 180 and Max: 500. Default: 340')
),
array(
'type' => 'text',
'label' => $this->l('Height'),
'name' => 'height',
'default' => '500',
'desc' => $this->l('Min: 70. Default: 500')
),
// array(
// 'type' => 'switch',
// 'label' => $this->l('Show Stream'),
// 'name' => 'show_stream',
// 'values' => $soption,
// 'default' => '0',
// ),
array(
'type' => 'switch',
'label' => $this->l('Show Faces'),
'name' => 'show_faces',
'values' => $soption,
'default' => '1',
),
array(
'type' => 'switch',
'label' => $this->l('Hide Cover'),
'name' => 'hide_cover',
'values' => $soption,
'default' => '0',
),
array(
'type' => 'switch',
'label' => $this->l('Small Header'),
'name' => 'small_header',
'values' => $soption,
'default' => '0',
),
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues($data),
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang
);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
$tabdisplay = array();
//update for new plugin facebook like
if ($setting['tabdisplay_timeline'] != '') {
array_push($tabdisplay, 'timeline');
}
//update for new plugin facebook like
if ($setting['tabdisplay_events'] != '') {
array_push($tabdisplay, 'events');
}
//update for new plugin facebook like
if ($setting['tabdisplay_messages'] != '') {
array_push($tabdisplay, 'messages');
}
$tabdisplay = implode(",", $tabdisplay);
# validate module
unset($args);
$t = array(
'name' => '',
'application_id' => '',
'page_url' => 'https://www.facebook.com/LeoTheme',
// 'border' => 0,
// 'color' => 'light',
// 'tabdisplay_timeline',
// 'tabdisplay_events',
// 'tabdisplay_messages',
'tabdisplay' => $tabdisplay,
'width' => 290,
'height' => 200,
// 'show_stream' => 0,
'show_faces' => 1,
'hide_cover' => 0,
'small_header' => 0,
'displaylanguage' => 'en_US'
);
$setting = array_merge($t, $setting);
$output = array('type' => 'facebook', 'data' => $setting);
return $output;
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
if ($multi_lang == 0) {
return array(
'page_url',
// 'border',
// 'target',
'tabdisplay_timeline',
'tabdisplay_events',
'tabdisplay_messages',
'width',
'height',
// 'show_stream',
'show_faces',
'hide_cover',
'small_header',
);
} elseif ($multi_lang == 1) {
return array(
);
} elseif ($multi_lang == 2) {
return array(
);
}
}
}

View File

@@ -0,0 +1,123 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 LeoWidgetHtml extends LeoWidgetBase
{
public $name = 'html';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('HTML'), 'explain' => $this->l('Create HTML With multiple Language'));
}
public function renderForm($args, $data)
{
#validate module
unset($args);
$helper = $this->getFormHelper();
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form.'),
),
'input' => array(
array(
'type' => 'textarea',
'label' => $this->l('Content'),
'name' => 'htmlcontent',
'cols' => 40,
'rows' => 10,
'value' => true,
'lang' => true,
'default' => '',
'autoload_rte' => true,
),
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues($data),
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang
);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
#validate module
unset($args);
$t = array(
'name' => '',
'html' => '',
);
$setting = array_merge($t, $setting);
$languageID = Context::getContext()->language->id;
$setting['html'] = isset($setting['htmlcontent_'.$languageID]) ? Tools::stripslashes($setting['htmlcontent_'.$languageID]) : '';
//update dynamic url
if (strpos($setting['html'], '_AP_IMG_DIR') !== false) {
// validate module
$setting['html'] = str_replace('_AP_IMG_DIR/', $this->theme_img_module, $setting['html']);
}
$output = array('type' => 'html', 'data' => $setting);
return $output;
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
if ($multi_lang == 0) {
return array(
);
} elseif ($multi_lang == 1) {
return array(
'htmlcontent',
);
} elseif ($multi_lang == 2) {
return array(
);
}
}
}

View File

@@ -0,0 +1,188 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 LeoWidgetImage extends LeoWidgetBase
{
public $name = 'image';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('Images Gallery Folder'), 'explain' => $this->l('Create Images Mini Gallery From Folder'));
}
public function renderForm($args, $data)
{
# validate module
unset($args);
$helper = $this->getFormHelper();
// $soption = array(
// array(
// 'id' => 'active_on',
// 'value' => 1,
// 'label' => $this->l('Enabled')
// ),
// array(
// 'id' => 'active_off',
// 'value' => 0,
// 'label' => $this->l('Disabled')
// )
// );
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form.'),
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Image Folder Path'),
'name' => 'image_folder_path',
'default' => 'youfoldername/yoursubfoldername',
'desc' => $this->l('Put image folder in the image folder ROOT_SHOP_DIR/. Example: You have a image folder with address http://yourshopdomain.com/yourfoldername/yoursubfoldername You need enter: youfoldername/yoursubfoldername ')
),
array(
'type' => 'text',
'label' => $this->l('Width'),
'name' => 'width',
'desc' => 'Enter a number',
'default' => '',
),
array(
'type' => 'text',
'label' => $this->l('Limit'),
'name' => 'limit',
'default' => '12',
),
array(
'type' => 'select',
'label' => $this->l('Columns'),
'name' => 'columns',
'options' => array('query' => array(
array('id' => '1', 'name' => $this->l('1 Column')),
array('id' => '2', 'name' => $this->l('2 Columns')),
array('id' => '3', 'name' => $this->l('3 Columns')),
array('id' => '4', 'name' => $this->l('4 Columns')),
array('id' => '6', 'name' => $this->l('6 Columns')),
),
'id' => 'id',
'name' => 'name'),
'default' => '4',
),
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues($data),
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang
);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
# validate module
unset($args);
$t = array(
'name' => '',
'image_folder_path' => '',
'limit' => 12,
'columns' => 4,
);
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
$url = Tools::htmlentitiesutf8($protocol.$_SERVER['HTTP_HOST'].__PS_BASE_URI__);
$setting = array_merge($t, $setting);
$oimages = array();
if ($setting['image_folder_path']) {
$path = _PS_ROOT_DIR_.'/'.trim($setting['image_folder_path']).'/';
$path = str_replace('//', '/', $path);
if (is_dir($path)) {
$images = glob($path.'*.*');
$exts = array('jpg', 'gif', 'png');
foreach ($images as $cnt => $image) {
$ext = Tools::substr($image, Tools::strlen($image) - 3, Tools::strlen($image));
if (in_array(Tools::strtolower($ext), $exts)) {
if ($cnt < (int)$setting['limit']) {
$i = str_replace('\\', '/', ''.$setting['image_folder_path'].'/'.basename($image));
$i = str_replace('//', '/', $i);
$oimages[] = $url.$i;
}
}
}
}
}
$images = array();
$setting['images'] = $oimages;
$output = array('type' => 'image', 'data' => $setting);
return $output;
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
if ($multi_lang == 0) {
return array(
'image_folder_path',
'width',
'limit',
'columns',
);
} elseif ($multi_lang == 1) {
return array(
);
} elseif ($multi_lang == 2) {
return array(
);
}
}
}

View File

@@ -0,0 +1,293 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 LeoWidgetImageProduct extends LeoWidgetBase
{
public $name = 'imageproduct';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('Images Gallery Product'), 'explain' => $this->l('Create Images Mini Generalallery From Product'));
}
public function renderForm($args, $data)
{
# validate module
unset($args);
$helper = $this->getFormHelper();
$source = array(
array(
'value' => 'ip_pcategories', // The value of the 'value' attribute of the <option> tag.
'name' => $this->l('Category') // The value of the text content of the <option> tag.
),
array(
'value' => 'ip_pproductids',
'name' => $this->l('Product Ids')
));
$pimagetypes = $this->getImageTypes();
$selected_cat = array();
if ($data) {
if ($data['params'] && isset($data['params']['categories']) && $data['params']['categories']) {
$selected_cat = $data['params']['categories'];
}
}
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form.'),
),
'input' => array(
array(
'type' => 'select',
'label' => $this->l('Source'),
'name' => 'ip_source',
'class' => 'group',
'default' => '',
'options' => array(
'query' => $source,
'id' => 'value',
'name' => 'name'
)
),
array(
'type' => 'categories',
'label' => $this->l('Categories'),
'name' => 'categories',
'default' => '',
'tree' => array(
'id' => 'ip_pcategories',
'title' => 'Categories',
'selected_categories' => $selected_cat,
'use_search' => true,
'use_checkbox' => true
)
),
array(
'type' => 'text',
'label' => $this->l('Product Ids'),
'name' => 'ip_pproductids',
'default' => '',
'desc' => $this->l('Enter Product Ids with format id1,id2,...')
),
array(
'type' => 'select',
'label' => $this->l('Small image'),
'name' => 'smallimage',
'class' => 'group',
'id' => 'psmallimagetypes',
'default' => '',
'options' => array(
'query' => $pimagetypes,
'id' => 'name',
'name' => 'name'
)
),
array(
'type' => 'select',
'label' => $this->l('Thick image'),
'name' => 'thickimage',
'id' => 'pthickimagetypes',
'default' => '',
'options' => array(
'query' => $pimagetypes,
'id' => 'name',
'name' => 'name'
)
),
array(
'type' => 'text',
'label' => $this->l('Limit'),
'name' => 'ip_limit',
'default' => '12',
'desc' => $this->l('Enter a number')
),
array(
'type' => 'select',
'label' => $this->l('Columns'),
'name' => 'columns',
'options' => array('query' => array(
array('id' => '1', 'name' => $this->l('1 Column')),
array('id' => '2', 'name' => $this->l('2 Columns')),
array('id' => '3', 'name' => $this->l('3 Columns')),
array('id' => '4', 'name' => $this->l('4 Columns')),
array('id' => '5', 'name' => $this->l('5 Columns')),
),
'id' => 'id',
'name' => 'name'),
'default' => '4',
),
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues($data),
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang
);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
# validate module
unset($args);
$smallimage = ($setting['smallimage']) ? ($setting['smallimage']) : 'small'.'_default';
$thickimage = ($setting['thickimage']) ? ($setting['thickimage']) : 'thickbox'.'_default';
switch ($setting['ip_source']) {
case 'ip_pproductids':
if (empty($setting['ip_pproductids'])) {
return false;
}
if ($pproductids = $setting['ip_pproductids']) {
$results = $this->getImagesByProductId($pproductids, 0, $setting['ip_limit'], (int)Context::getContext()->language->id);
$setting['images'] = $results;
}
break;
case 'ip_pcategories':
$catids = (isset($setting['categories']) && $setting['categories']) ? ($setting['categories']) : array();
if ($catids) {
$categories = implode(',', array_map('intval', $catids));
$results = $this->getImagesByCategory($categories, 0, $setting['ip_limit'], (int)Context::getContext()->language->id);
$setting['images'] = $results;
}
break;
}
$setting['thickimage'] = $thickimage;
$setting['smallimage'] = $smallimage;
$output = array('type' => 'imageproduct', 'data' => $setting);
return $output;
}
# them
public function getImageTypes()
{
$pimagetypes = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT tp.`id_image_type`,tp.`name`
FROM `'._DB_PREFIX_.'image_type` tp
WHERE tp.`products` = 1
ORDER BY tp.`name` ASC');
return $pimagetypes;
}
public function getImagesByProductId($productids, $start, $limit, $id_lang, $id_shop = null)
{
if (is_null($id_shop)) {
$id_shop = Context::getContext()->shop->id;
}
$sql = 'SELECT i.`id_image`, pl.`link_rewrite`
FROM `'._DB_PREFIX_.'image` i
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON(i.`id_image` = il.`id_image`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON(i.`id_product` = pl.`id_product`)';
$sql .= ' WHERE i.`id_product` IN ('.pSQL($productids).') AND il.`id_lang` ='.(int)$id_lang.
' AND pl.`id_lang` ='.(int)$id_lang.
' AND pl.`id_shop` ='.(int)$id_shop.
' AND i.cover = 1 ORDER BY i.`position` ASC'
.($limit > 0 ? ' LIMIT '.(int)$start.','.(int)$limit : '');
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
return $results;
}
public static function getImagesByCategory($categories, $start, $limit, $id_lang, Context $context = null)
{
if (!$context) {
$context = Context::getContext();
}
$front = true;
if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) {
$front = false;
}
$sql_groups = '';
if (Group::isFeatureActive()) {
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups = 'AND cg.`id_group` '.(count($groups) ? 'IN ('.pSQL(implode(',', array_map('intval', $groups))).')' : '= 1');
}
$sql = 'SELECT i.`id_image`, pl.`link_rewrite` FROM `'._DB_PREFIX_.'image` i
INNER JOIN `'._DB_PREFIX_.'image_lang` il ON(i.`id_image` = il.`id_image`)
INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON(i.`id_product` = pl.`id_product`)
INNER JOIN `'._DB_PREFIX_.'image_shop` ish ON (i.`id_image` = ish.`id_image`)';
$sql .= 'WHERE i.`id_product` IN (SELECT cp.`id_product`
FROM `'._DB_PREFIX_.'category_product` cp
'.(Group::isFeatureActive() ? 'INNER JOIN `'._DB_PREFIX_.'category_group` cg ON cp.`id_category` = cg.`id_category`' : '').'
INNER JOIN `'._DB_PREFIX_.'category` c ON cp.`id_category` = c.`id_category`
INNER JOIN `'._DB_PREFIX_.'product` p ON cp.`id_product` = p.`id_product`
'.Shop::addSqlAssociation('product', 'p', false).'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.Shop::addSqlRestrictionOnLang('pl').')
WHERE c.`active` = 1
AND product_shop.`active` = 1
'.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').'
'.pSQL($sql_groups).
' AND cp.id_category in ('.pSQL($categories).')'.
' AND pl.id_lang ='.(int)$id_lang.') AND il.`id_lang` ='.(int)$id_lang.
' AND pl.id_lang = '.(int)$id_lang.
' AND pl.id_shop = '.(int)$context->shop->id.
' AND ish.id_shop = '.(int)$context->shop->id.
' AND ish.cover = 1 ORDER BY i.`position` ASC'.($limit > 0 ? ' LIMIT '.(int)$start.','.(int)$limit : '');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
if ($multi_lang == 0) {
return array(
'ip_source',
'categories',
'ip_pproductids',
'smallimage',
'thickimage',
'ip_limit',
'columns',
);
} elseif ($multi_lang == 1) {
return array();
} elseif ($multi_lang == 2) {
return array();
}
}
}

View 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;

View File

@@ -0,0 +1,539 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 LeoWidgetLinks extends LeoWidgetBase
{
public $name = 'link';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('Block Links'), 'explain' => $this->l('Create List Block Links'));
}
public function renderForm($args, $data)
{
# validate module
$id_lang = Context::getContext()->language->id;
unset($args);
$helper = $this->getFormHelper();
$languages = Language::getLanguages();
$list_id_lang = array();
foreach ($languages as $languages_val) {
array_push($list_id_lang, $languages_val['id_lang']);
}
$categories = LeoBtmegamenuHelper::getCategories();
$manufacturers = Manufacturer::getManufacturers(false, $id_lang, true);
$suppliers = Supplier::getSuppliers(false, $id_lang, true);
$cmss = CMS::listCms($id_lang, false, true);
$page_controller = array();
foreach (Meta::getPages() as $page) {
if (strpos($page, 'module') === false) {
$array_tmp = array();
$array_tmp['link'] = $page;
$array_tmp['name'] = $page;
array_push($page_controller, $array_tmp);
}
}
//get list link id
if (isset($data['params']['list_id_link'])) {
$list_id_link = array_filter(explode(',', $data['params']['list_id_link']));
} else {
$list_id_link = array();
}
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form.'),
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Text Link'),
'name' => 'text_link_0',
'default' => '',
'lang' => true,
'class' => 'tmp',
'required' => true,
),
array(
'type' => 'select',
'label' => $this->l('Link Type'),
'name' => 'link_type_0',
'id' => 'link_type_0',
'desc' => $this->l('Select a link type and fill data for following input'),
'options' => array('query' => array(
array('id' => 'url', 'name' => $this->l('Url')),
array('id' => 'category', 'name' => $this->l('Category')),
array('id' => 'product', 'name' => $this->l('Product')),
array('id' => 'manufacture', 'name' => $this->l('Manufacture')),
array('id' => 'supplier', 'name' => $this->l('Supplier')),
array('id' => 'cms', 'name' => $this->l('Cms')),
array('id' => 'controller', 'name' => $this->l('Page Controller'))
),
'id' => 'id',
'name' => 'name'),
'default' => 'url',
'class' => 'tmp',
),
array(
'type' => 'text',
'label' => $this->l('Product ID'),
'name' => 'product_type_0',
'id' => 'product_type_0',
'class' => 'link_type_group tmp',
'default' => '',
),
array(
'type' => 'select',
'label' => $this->l('CMS Type'),
'name' => 'cms_type_0',
'id' => 'cms_type_0',
'options' => array('query' => $cmss,
'id' => 'id_cms',
'name' => 'meta_title'),
'default' => '',
'class' => 'link_type_group tmp',
),
array(
'type' => 'text',
'label' => $this->l('URL'),
'name' => 'url_type_0',
'id' => 'url_type_0',
'lang' => true,
'class' => 'url-type-group-lang tmp',
'default' => '#',
),
array(
'type' => 'select',
'label' => $this->l('Category Type'),
'name' => 'category_type_0',
'id' => 'category_type_0',
'options' => array('query' => $categories,
'id' => 'id_category',
'name' => 'name'),
'default' => '',
'class' => 'link_type_group tmp',
),
array(
'type' => 'select',
'label' => $this->l('Manufacture Type'),
'name' => 'manufacture_type_0',
'id' => 'manufacture_type_0',
'options' => array('query' => $manufacturers,
'id' => 'id_manufacturer',
'name' => 'name'),
'default' => '',
'class' => 'link_type_group tmp',
),
array(
'type' => 'select',
'label' => $this->l('Supplier Type'),
'name' => 'supplier_type_0',
'id' => 'supplier_type_0',
'options' => array('query' => $suppliers,
'id' => 'id_supplier',
'name' => 'name'),
'default' => '',
'class' => 'link_type_group tmp',
),
array(
'type' => 'select',
'label' => $this->l('List Page Controller'),
'name' => 'controller_type_0',
'id' => 'controller_type_0',
'options' => array('query' => $page_controller,
'id' => 'link',
'name' => 'name'),
'default' => '',
'class' => 'link_type_group tmp',
),
array(
'type' => 'text',
'label' => $this->l('Parameter of page controller'),
'name' => 'controller_type_parameter_0',
'id' => 'controller_type_parameter_0',
'default' => '',
'lang' => true,
'class' => 'controller-type-group-lang tmp',
'desc' => 'Eg: ?a=1&b=2',
),
array(
'type' => 'html',
'name' => 'add-new-link',
'html_content' => '<button class="add-new-link btn btn-default">
<i class="process-icon-new"></i>
<span>'.$this->l('Add New Link').'</span>
</button>',
'default' => '',
),
array(
'type' => 'hidden',
'name' => 'total_link',
'default' => count($list_id_link),
),
array(
'type' => 'hidden',
'name' => 'list_field',
'default' => '',
),
array(
'type' => 'hidden',
'name' => 'list_field_lang',
'default' => '',
),
array(
'type' => 'hidden',
'name' => 'list_id_link',
'default' => '',
),
array(
'type' => 'html',
'name' => 'default_html',
'html_content' => "<script>var list_id_lang = '".Tools::jsonEncode($list_id_lang)."';
var copy_lang_button_text = '".$this->l('Copy to other languages')."';
var copy_lang_button_text_done = '".$this->l('Copy to other languages ... DONE')."';
var remove_button_text = '".$this->l('Remove Link')."';
var duplicate_button_text = '".$this->l('Duplicate Link')."';
var id_lang = ".$id_lang.";
</script>",
'default' => '',
),
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
if (count($list_id_link) > 0) {
foreach ($list_id_link as $list_id_link_val) {
$text_link = array(
'type' => 'text',
'label' => $this->l('Text Link'),
'name' => 'text_link_'.$list_id_link_val,
'default' => '',
'lang' => true,
'class' => 'tmp element element-lang',
'required' => true,
);
$link_type = array(
'type' => 'select',
'label' => $this->l('Link Type'),
'name' => 'link_type_'.$list_id_link_val,
'id' => 'link_type_'.$list_id_link_val,
'desc' => $this->l('Select a link type and fill data for following input'),
'options' => array(
'query' => array(
array('id' => 'url', 'name' => $this->l('Url')),
array('id' => 'category', 'name' => $this->l('Category')),
array('id' => 'product', 'name' => $this->l('Product')),
array('id' => 'manufacture', 'name' => $this->l('Manufacture')),
array('id' => 'supplier', 'name' => $this->l('Supplier')),
array('id' => 'cms', 'name' => $this->l('Cms')),
array('id' => 'controller', 'name' => $this->l('Page Controller'))
),
'id' => 'id',
'name' => 'name'),
'default' => '',
'class' => 'tmp element',
);
$product_type = array(
'type' => 'text',
'label' => $this->l('Product ID'),
'name' => 'product_type_'.$list_id_link_val,
'id' => 'product_type_'.$list_id_link_val,
'class' => 'link_type_group_'.$list_id_link_val.' tmp element',
'default' => '',
);
$cms_type = array(
'type' => 'select',
'label' => $this->l('CMS Type'),
'name' => 'cms_type_'.$list_id_link_val,
'id' => 'cms_type_'.$list_id_link_val,
'options' => array('query' => $cmss,
'id' => 'id_cms',
'name' => 'meta_title'),
'default' => '',
'class' => 'link_type_group_'.$list_id_link_val.' tmp element',
);
$url_type = array(
'type' => 'text',
'label' => $this->l('URL'),
'name' => 'url_type_'.$list_id_link_val,
'id' => 'url_type_'.$list_id_link_val,
'lang' => true,
'class' => 'url-type-group-lang tmp element element-lang',
'default' => '#',
);
$category_type = array(
'type' => 'select',
'label' => $this->l('Category Type'),
'name' => 'category_type_'.$list_id_link_val,
'id' => 'category_type_'.$list_id_link_val,
'options' => array(
'query' => $categories,
'id' => 'id_category',
'name' => 'name'),
'default' => '',
'class' => 'link_type_group_'.$list_id_link_val.' tmp element',
);
$manufacture_type = array(
'type' => 'select',
'label' => $this->l('Manufacture Type'),
'name' => 'manufacture_type_'.$list_id_link_val,
'id' => 'manufacture_type_'.$list_id_link_val,
'options' => array(
'query' => $manufacturers,
'id' => 'id_manufacturer',
'name' => 'name'),
'default' => '',
'class' => 'link_type_group_'.$list_id_link_val.' tmp element',
);
$supplier_type = array(
'type' => 'select',
'label' => $this->l('Supplier Type'),
'name' => 'supplier_type_'.$list_id_link_val,
'id' => 'supplier_type_'.$list_id_link_val,
'options' => array(
'query' => $suppliers,
'id' => 'id_supplier',
'name' => 'name'),
'default' => '',
'class' => 'link_type_group_'.$list_id_link_val.' tmp element',
);
$controller_type = array(
'type' => 'select',
'label' => $this->l('List Page Controller'),
'name' => 'controller_type_'.$list_id_link_val,
'id' => 'controller_type_'.$list_id_link_val,
'options' => array(
'query' => $page_controller,
'id' => 'link',
'name' => 'name'),
'default' => '',
'class' => 'link_type_group_'.$list_id_link_val.' tmp element',
);
$controller_type_parameter = array(
'type' => 'text',
'label' => $this->l('Parameter of page controller'),
'name' => 'controller_type_parameter_'.$list_id_link_val,
'id' => 'controller_type_parameter_'.$list_id_link_val,
'default' => '',
'lang' => true,
'class' => 'controller-type-group-lang tmp element element-lang',
'desc' => 'Eg: ?a=1&b=2',
);
array_push($this->fields_form[1]['form']['input'], $text_link, $link_type, $product_type, $cms_type, $url_type, $category_type, $manufacture_type, $supplier_type, $controller_type, $controller_type_parameter);
}
}
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues($data),
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang
);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
# validate module
unset($args);
$t = array(
'name' => '',
'html' => '',
);
$setting = array_merge($t, $setting);
$ac = array();
$languageID = Context::getContext()->language->id;
$text_link = $link = '';
// for ($i = 1; $i <= 10; $i++) {
// if (isset($setting['text_link_'.$i.'_'.$languageID]) && trim($setting['text_link_'.$i.'_'.$languageID])) {
// $text_link = isset($setting['text_link_'.$i.'_'.$languageID]) ? html_entity_decode($setting['text_link_'.$i.'_'.$languageID], ENT_QUOTES, 'UTF-8') : 'No Link Title';
// if (isset($setting['link_'.$i.'_'.$languageID])) {
// $link = trim($setting['link_'.$i.'_'.$languageID]);
// } else {
// $link = trim($setting['link_'.$i]);
// }
// $ac[] = array('text' => Tools::stripslashes($text_link), 'link' => $link);
// }
// }
$list_id_link = array_filter(explode(',', $setting['list_id_link']));
if (count($list_id_link) > 0) {
foreach ($list_id_link as $list_id_link_val) {
if (isset($setting['text_link_'.$list_id_link_val.'_'.$languageID]) && trim($setting['text_link_'.$list_id_link_val.'_'.$languageID])) {
$text_link = isset($setting['text_link_'.$list_id_link_val.'_'.$languageID]) ? html_entity_decode($setting['text_link_'.$list_id_link_val.'_'.$languageID], ENT_QUOTES, 'UTF-8') : 'No Link Title';
// if (isset($setting['link_'.$i.'_'.$languageID])) {
// $link = trim($setting['link_'.$i.'_'.$languageID]);
// } else {
// $link = trim($setting['link_'.$i]);
// }
$link = $this->getLink($setting, $list_id_link_val);
$ac[] = array('text' => Tools::stripslashes($text_link), 'link' => $link);
}
}
}
$setting['id'] = rand();
$setting['links'] = $ac;
$output = array('type' => 'links', 'data' => $setting);
return $output;
}
//get link from link type
public function getLink($setting, $id_link = null)
{
// $value = (int)$menu['item'];
$result = '';
$link = new Link();
$id_lang = Context::getContext()->language->id;
$id_shop = Context::getContext()->shop->id;
switch ($setting['link_type_'.$id_link]) {
case 'product':
$value = $setting['product_type_'.$id_link];
if (Validate::isLoadedObject($obj_pro = new Product($value, true, $id_lang))) {
# validate module
$result = $link->getProductLink((int)$obj_pro->id, $obj_pro->link_rewrite, null, null, $id_lang, null, (int)Product::getDefaultAttribute((int)$obj_pro->id), false, false, true);
}
break;
case 'category':
$value = $setting['category_type_'.$id_link];
if (Validate::isLoadedObject($obj_cate = new Category($value, $id_lang))) {
# validate module
$result = $link->getCategoryLink((int)$obj_cate->id, $obj_cate->link_rewrite, $id_lang);
}
break;
case 'cms':
$value = $setting['cms_type_'.$id_link];
if (Validate::isLoadedObject($obj_cms = new CMS($value, $id_lang))) {
# validate module
$result = $link->getCMSLink((int)$obj_cms->id, $obj_cms->link_rewrite, $id_lang);
}
break;
case 'url':
// MENU TYPE : URL
if (preg_match('/http:\/\//', $setting['url_type_'.$id_link.'_'.$id_lang]) || preg_match('/https:\/\//', $setting['url_type_'.$id_link.'_'.$id_lang])) {
// ABSOLUTE LINK : default
} else {
// RELATIVE LINK : auto insert host
$host_name = LeoBtmegamenuHelper::getBaseLink().LeoBtmegamenuHelper::getLangLink();
$setting['url_type_'.$id_link.'_'.$id_lang] = $host_name.$setting['url_type_'.$id_link.'_'.$id_lang];
}
$value = $setting['url_type_'.$id_link.'_'.$id_lang];
$regex = '((https?|ftp)\:\/\/)?'; // SCHEME
$regex .= '([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?'; // User and Pass
$regex .= '([a-z0-9-.]*)\.([a-z]{2,3})'; // Host or IP
$regex .= '(\:[0-9]{2,5})?'; // Port
$regex .= '(\/([a-z0-9+\$_-]\.?)+)*\/?'; // Path
$regex .= '(\?[a-z+&\$_.-][a-z0-9;:@&%=+\/\$_.-]*)?'; // GET Query
$regex .= '(#[a-z_.-][a-z0-9+\$_.-]*)?'; // Anchor
if ($value == 'index' || $value == 'index.php') {
$result = $link->getPageLink('index.php', false, $id_lang);
break;
} elseif ($value == '#' || preg_match("/^$regex$/", $value)) {
$result = $value;
break;
} else {
$result = $value;
}
break;
case 'manufacture':
$value = $setting['manufacture_type_'.$id_link];
if (Validate::isLoadedObject($obj_manu = new Manufacturer($value, $id_lang))) {
# validate module
$result = $link->getManufacturerLink((int)$obj_manu->id, $obj_manu->link_rewrite, $id_lang);
}
break;
case 'supplier':
$value = $setting['supplier_type_'.$id_link];
if (Validate::isLoadedObject($obj_supp = new Supplier($value, $id_lang))) {
# validate module
$result = $link->getSupplierLink((int)$obj_supp->id, $obj_supp->link_rewrite, $id_lang);
}
break;
case 'controller':
//getPageLink('history', true, Context::getContext()->language->id, null, false, $id_shop);
$value = $setting['controller_type_'.$id_link];
$result = $link->getPageLink($value, null, $id_lang, null, false, $id_shop);
if ($setting['controller_type_parameter_'.$id_link.'_'.$id_lang] != '') {
$result .= $setting['controller_type_parameter_'.$id_link.'_'.$id_lang];
}
break;
default:
$result = '#';
break;
}
return $result;
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
if ($multi_lang == 0) {
return array(
);
} elseif ($multi_lang == 1) {
// $number_html = 10;
// $array = array();
// for ($i = 1; $i <= $number_html; $i++) {
// $array[] = 'text_link_'.$i;
// $array[] = 'link_'.$i;
// }
// return $array;
return array(
);
} elseif ($multi_lang == 2) {
return array(
);
}
}
}

View File

@@ -0,0 +1,135 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 LeoWidgetManufacture extends LeoWidgetBase
{
public $name = 'Manufacture';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('Manufacture Logos'), 'explain' => $this->l('Manufacture Logo'));
}
public function renderForm($args, $data)
{
# validate module
unset($args);
$helper = $this->getFormHelper();
$imagesTypes = ImageType::getImagesTypes('manufacturers');
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form.'),
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Limit'),
'name' => 'limit',
'default' => 10,
),
array(
'type' => 'select',
'label' => $this->l('Image:'),
'desc' => $this->l('Select type image for manufacture.'),
'name' => 'image',
'default' => 'small'.'_default',
'options' => array(
'query' => $imagesTypes,
'id' => 'name',
'name' => 'name'
)
)
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues($data),
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang
);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
# validate module
unset($args);
$t = array(
'name' => '',
'html' => '',
);
$setting = array_merge($t, $setting);
$plimit = ($setting['limit']) ? (int)($setting['limit']) : 10;
$image_type = ($setting['image']) ? ($setting['image']) : 'small'.'_default';
$data = Manufacturer::getManufacturers(true, Context::getContext()->language->id, true, 1, $plimit, false);
foreach ($data as &$item) {
// $id_images = (!file_exists(_PS_MANU_IMG_DIR_.'/'.$item['id_manufacturer'].'-'.$image_type.'.jpg')) ? Language::getIsoById(Context::getContext()->language->id).'-default' : $item['id_manufacturer'];
// $item['image'] = _THEME_MANU_DIR_.$id_images.'-'.$image_type.'.jpg';
$item['image'] = Context::getContext()->link->getManufacturerImageLink($item['id_manufacturer'], $image_type);
}
$setting['manufacturers'] = $data;
$output = array('type' => 'manufacture', 'data' => $setting);
return $output;
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
if ($multi_lang == 0) {
return array(
'limit',
'image',
);
} elseif ($multi_lang == 1) {
return array(
);
} elseif ($multi_lang == 2) {
return array(
);
}
}
}

View File

@@ -0,0 +1,380 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* DISCLAIMER
*
* @author leotheme <leotheme@gmail.com>
* @copyright 2007-2015 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
if (!defined('_PS_VERSION_')) {
# module validation
exit;
}
use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter;
use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever;
use PrestaShop\PrestaShop\Core\Product\ProductListingPresenter;
use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever;
class LeoWidgetProductlist extends LeoWidgetBase
{
public $name = 'product_list';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('Product List'), 'explain' => $this->l('Create Products List'));
}
public function renderForm($args, $data)
{
$helper = $this->getFormHelper();
$types = array();
$types[] = array(
'value' => 'newest',
'text' => $this->l('Products Newest')
);
$types[] = array(
'value' => 'bestseller',
'text' => $this->l('Products Bestseller')
);
$types[] = array(
'value' => 'special',
'text' => $this->l('Products Special')
);
$types[] = array(
'value' => 'featured',
'text' => $this->l('Products Featured')
);
$types[] = array(
'value' => 'random',
'text' => $this->l('Products Random')
);
$source = array(
array(
'value' => 'pcategories', // The value of the 'value' attribute of the <option> tag.
'name' => $this->l('Category') // The value of the text content of the <option> tag.
),
array(
'value' => 'ptype',
'name' => $this->l('Product')
),
array(
'value' => 'pmanufacturers',
'name' => $this->l('Manufacturers')
),
array(
'value' => 'pproductids',
'name' => $this->l('Product Ids')
));
$orderby = array(
array(
'order' => 'date_add', // The value of the 'value' attribute of the <option> tag.
'name' => $this->l('Date Add') // The value of the text content of the <option> tag.
),
array(
'order' => 'date_upd', // The value of the 'value' attribute of the <option> tag.
'name' => $this->l('Date Update') // The value of the text content of the <option> tag.
),
array(
'order' => 'name',
'name' => $this->l('Name')
),
array(
'order' => 'id_product',
'name' => $this->l('Product Id')
),
array(
'order' => 'price',
'name' => $this->l('Price')
),
);
$orderway = array(
array(
'orderway' => 'ASC', // The value of the 'value' attribute of the <option> tag.
'name' => $this->l('Ascending') // The value of the text content of the <option> tag.
),
array(
'orderway' => 'DESC', // The value of the 'value' attribute of the <option> tag.
'name' => $this->l('Descending') // The value of the text content of the <option> tag.
),
);
$pmanufacturers = $this->getManufacturers(Context::getContext()->shop->id);
$selected_cat = array();
if ($data) {
if ($data['params'] && isset($data['params']['categories']) && $data['params']['categories']) {
$selected_cat = $data['params']['categories'];
}
if ($data['params'] && isset($data['params']['pmanufacturer']) && $data['params']['pmanufacturer']) {
$data['params']['pmanufacturer[]'] = $data['params']['pmanufacturer'];
}
}
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form.'),
),
'input' => array(
array(
'type' => 'select',
'label' => $this->l('Source:'),
//'desc' => $this->l('The maximum number of products in each page Carousel (default: 3).'),
'name' => 'source',
'class' => 'group',
'default' => 'date_add',
'options' => array(
'query' => $source,
'id' => 'value',
'name' => 'name'
)
),
array(
'type' => 'categories',
'label' => $this->l('Categories'),
'name' => 'categories',
'default' => '',
'tree' => array(
'id' => 'pcategories',
'title' => 'Categories',
'selected_categories' => $selected_cat,
'use_search' => true,
'use_checkbox' => true
)
),
array(
'type' => 'select',
'label' => $this->l('Products List Type'),
'name' => 'ptype',
'options' => array('query' => $types,
'id' => 'value',
'name' => 'text'),
'default' => 'newest',
'desc' => $this->l('Select a Product List Type')
),
array(
'type' => 'text',
'label' => $this->l('Product Ids'),
'name' => 'pproductids',
'default' => '',
),
array(
'type' => 'select',
'label' => $this->l('Manufacturer:'),
'name' => 'pmanufacturer[]',
'id' => 'pmanufacturers',
'default' => '',
'multiple' => true,
'options' => array(
'query' => $pmanufacturers,
'id' => 'id_manufacturer',
'name' => 'name'
)
),
array(
'type' => 'text',
'label' => $this->l('Limit'),
'name' => 'limit',
'default' => 6,
),
array(
'type' => 'select',
'label' => $this->l('Order By:'),
'desc' => $this->l('The maximum number of products in each page Carousel (default: 3).'),
'name' => 'orderby',
'default' => 'date_add',
'options' => array(
'query' => $orderby,
'id' => 'order',
'name' => 'name'
)
),
array(
'type' => 'select',
'label' => $this->l('Order Way:'),
'desc' => $this->l('The maximum number of products in each page Carousel (default: 3).'),
'name' => 'orderway',
'default' => 'date_add',
'options' => array(
'query' => $orderway,
'id' => 'orderway',
'name' => 'name'
)
),
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues($data),
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang
);
unset($args);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
$t = array(
'ptype' => '',
'limit' => 12,
'image_width' => '200',
'image_height' => '200',
);
$products = array();
$setting = array_merge($t, $setting);
$orderby = ($setting['orderby']) ? ($setting['orderby']) : 'position';
$orderway = ($setting['orderway']) ? ($setting['orderway']) : 'ASC';
$plimit = ($setting['limit']) ? (int)($setting['limit']) : 6;
switch ($setting['source']) {
case 'ptype':
switch ($setting['ptype']) {
case 'newest':
$products = Product::getNewProducts($this->langID, 0, $plimit, false, $orderby, $orderway);
break;
case 'featured':
$category = new Category(Context::getContext()->shop->getCategory(), $this->langID);
// $nb = (int)$setting['limit'];
$products = $category->getProducts((int)$this->langID, 1, $plimit, $orderby, $orderway);
break;
case 'bestseller':
$products = ProductSale::getBestSalesLight((int)$this->langID, 0, $plimit);
break;
case 'special':
$products = Product::getPricesDrop($this->langID, 0, $plimit, false, $orderby, $orderway);
break;
case 'random':
$random = true;
$products = $this->getProducts('WHERE p.id_product > 0', (int)Context::getContext()->language->id, 1, $plimit, $orderby, $orderway, false, true, $random, $plimit);
Configuration::updateValue('BTMEGAMENU_CURRENT_RANDOM_CACHE', '1');
break;
}
break;
case 'pproductids':
$where = '';
if (empty($setting['pproductids'])) {
return false;
}
if ($pproductids = $setting['pproductids']) {
$where = 'WHERE p.id_product IN ('.pSQL($pproductids).')';
}
$products = $this->getProducts($where, (int)Context::getContext()->language->id, 1, $plimit, $orderby, $orderway);
break;
case 'pcategories':
$where = '';
$catids = (isset($setting['categories']) && $setting['categories']) ? ($setting['categories']) : array();
if ($catids) {
$categorys = implode(',', $catids);
$where = 'WHERE cp.id_category IN ('.pSQL($categorys).')';
}
$products = $this->getProducts($where, (int)Context::getContext()->language->id, 1, $plimit, $orderby, $orderway);
break;
case 'pmanufacturers':
$where = '';
$manufacturers = ($setting['pmanufacturer']) ? ($setting['pmanufacturer']) : array();
if ($manufacturers) {
$manufacturers = implode(',', $manufacturers);
$where = 'WHERE p.id_manufacturer IN ('.pSQL($manufacturers).')';
}
$products = $this->getProducts($where, (int)Context::getContext()->language->id, 1, $plimit, $orderby, $orderway);
break;
}
//Context::getContext()->controller->addColorsToProductList($products);
#1.7
$assembler = new ProductAssembler(Context::getContext());
$presenterFactory = new ProductPresenterFactory(Context::getContext());
$presentationSettings = $presenterFactory->getPresentationSettings();
$presenter = new ProductListingPresenter(
new ImageRetriever(
Context::getContext()->link
),
Context::getContext()->link,
new PriceFormatter(),
new ProductColorsRetriever(),
Context::getContext()->getTranslator()
);
$products_for_template = array();
if (isset($products) && is_array($products)) {
foreach ($products as $rawProduct) {
$products_for_template[] = $presenter->present(
$presentationSettings,
$assembler->assembleProduct($rawProduct),
Context::getContext()->language
);
}
}
$setting['products'] = $products_for_template;
$currency = array();
$fields = array('name', 'iso_code', 'iso_code_num', 'sign');
foreach ($fields as $field_name) {
$currency[$field_name] = Context::getContext()->currency->{$field_name};
}
$setting['currency'] = $currency;
// $setting['products'] = $products;
$setting['homeSize'] = Image::getSize(ImageType::getFormattedName('home'));
$output = array('type' => 'product_list', 'data' => $setting);
unset($args);
return $output;
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
if ($multi_lang == 0) {
return array(
'source',
'categories',
'ptype',
'pproductids',
'limit',
'orderby',
'orderway',
);
} elseif ($multi_lang == 1) {
return array(
);
} elseif ($multi_lang == 2) {
return array(
);
}
}
}

View File

@@ -0,0 +1,135 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 LeoWidgetRawhtml extends LeoWidgetBase
{
public $name = 'raw_html';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('Raw HTML'), 'explain' => $this->l('Put Raw HTML Code'));
}
public function renderForm($args, $data)
{
$helper = $this->getFormHelper();
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form.'),
),
'input' => array(
array(
'type' => 'textarea',
'label' => $this->l('Content'),
'name' => 'raw_html',
'cols' => 40,
'rows' => 10,
'value' => true,
'lang' => true,
'default' => '',
'autoload_rte' => false,
'desc' => $this->l('Enter HTML CODE in here')
),
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues($data),
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang
);
unset($args);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
$t = array(
'name' => '',
'raw_html' => '',
);
$setting = array_merge($t, $setting);
if (isset($setting['raw_html']) && $setting['raw_html'] != '') {
//keep backup
$html = $setting['raw_html'];
$html = html_entity_decode(Tools::stripslashes($html), ENT_QUOTES, 'UTF-8');
} else {
//change raw html to use multi lang
$languageID = Context::getContext()->language->id;
$setting['raw_html'] = isset($setting['raw_html_'.$languageID]) ? html_entity_decode(Tools::stripslashes($setting['raw_html_'.$languageID]), ENT_QUOTES, 'UTF-8') : '';
//update dynamic url
if (strpos($setting['raw_html'], '_AP_IMG_DIR') !== false) {
// validate module
$setting['raw_html'] = str_replace('_AP_IMG_DIR/', $this->theme_img_module, $setting['raw_html']);
}
}
// $header = '';
// $content = $html;
$output = array('type' => 'raw_html', 'data' => $setting);
unset($args);
return $output;
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
//change raw html to use multi lang
if ($multi_lang == 0) {
return array(
);
} elseif ($multi_lang == 1) {
return array(
'raw_html',
);
} elseif ($multi_lang == 2) {
return array();
}
}
}

View File

@@ -0,0 +1,122 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 LeoWidgetSubcategories extends LeoWidgetBase
{
public $name = 'sub_categories';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('Sub Categories In Parent'), 'explain' => $this->l('Show List Of Categories Links Of Parent'));
}
public function renderForm($args, $data)
{
# validate module
unset($args);
$helper = $this->getFormHelper();
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form.'),
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Parent Category ID'),
'name' => 'category_id',
'default' => '6',
),
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues($data),
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang
);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
# validate module
unset($args);
$t = array(
'category_id' => '',
);
$setting = array_merge($t, $setting);
$category = new Category($setting['category_id'], $this->langID);
//check if category id not exists
if ($category->id != '') {
$subCategories = $category->getSubCategories($this->langID);
$setting['subcategories'] = $subCategories;
} else {
$setting['subcategories'] = array();
}
$setting['title'] = $category->name;
$setting['cat'] = $category;
$output = array('type' => 'sub_categories', 'data' => $setting);
return $output;
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
if ($multi_lang == 0) {
return array(
'category_id',
);
} elseif ($multi_lang == 1) {
return array(
);
} elseif ($multi_lang == 2) {
return array(
);
}
}
}

View File

@@ -0,0 +1,157 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 LeoWidgetTabHTML extends LeoWidgetBase
{
public $name = 'tabhtml';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('HTML Tab'), 'explain' => $this->l('Create HTML Tab'));
}
public function renderForm($args, $data)
{
# validate module
unset($args);
$helper = $this->getFormHelper();
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form'),
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Number of HTML Tab'),
'name' => 'nbtabhtml',
'default' => 5,
'desc' => $this->l('Enter a number greater 0')
)
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
if (!isset($data['params']['nbtabhtml']) || !$data['params']['nbtabhtml']) {
$nbtabhtml = 5;
} else {
$nbtabhtml = $data['params']['nbtabhtml'];
}
for ($i = 1; $i <= $nbtabhtml; $i++) {
$tmpArray = array(
'type' => 'text',
'label' => $this->l('Title '.$i),
'name' => 'title_'.$i,
'default' => 'Title Sample '.$i,
'lang' => true
);
$this->fields_form[1]['form']['input'][] = $tmpArray;
$tmpArray = array(
'type' => 'textarea',
'label' => $this->l('Content '.$i),
'name' => 'content_'.$i,
'default' => 'Content Sample '.$i,
'cols' => 40,
'rows' => 10,
'value' => true,
'lang' => true,
'autoload_rte' => true,
'desc' => $this->l('Enter Content '.$i)
);
$this->fields_form[1]['form']['input'][] = $tmpArray;
}
//$this->fields_form[1]['form']['input'][] = $tmpArray;
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues($data),
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang
);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
# validate module
unset($args);
$content = '';
$tabs = array();
$languageID = Context::getContext()->language->id;
for ($i = 1; $i <= $setting['nbtabhtml']; $i++) {
$title = isset($setting['title_'.$i.'_'.$languageID]) ? Tools::stripslashes($setting['title_'.$i.'_'.$languageID]) : '';
if (!empty($title)) {
$content = isset($setting['content_'.$i.'_'.$languageID]) ? Tools::stripslashes($setting['content_'.$i.'_'.$languageID]) : '';
$tabs[] = array('title' => trim($title), 'content' => trim($content));
}
}
$setting['tabhtmls'] = $tabs;
$setting['id'] = rand() + count($tabs);
$output = array('type' => 'tabhtml', 'data' => $setting);
return $output;
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
if ($multi_lang == 0) {
return array(
'nbtabhtml',
);
} elseif ($multi_lang == 1) {
$number_html = Tools::getValue('nbtabhtml');
$array = array();
for ($i = 1; $i <= $number_html; $i++) {
$array[] = 'title_'.$i;
$array[] = 'content_'.$i;
}
return $array;
} elseif ($multi_lang == 2) {
return array(
);
}
}
}

View File

@@ -0,0 +1,268 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 LeoWidgetTwitter extends LeoWidgetBase
{
public $name = 'twitter';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('Twitter Widget'), 'explain' => $this->l('Get Latest Twitter TimeLife'));
}
public function renderForm($args, $data)
{
# validate module
unset($args);
$helper = $this->getFormHelper();
$soption = array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
);
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form.'),
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Twitter'),
'name' => 'twidget_id',
'default' => '578806287158251521',
'desc' => $this->l('Please go to the page https://twitter.com/settings/widgets/new, then create a widget, and get data-widget-id to input in this param.')
),
array(
'type' => 'text',
'label' => $this->l('Count'),
'name' => 'count',
'default' => 2,
'desc' => $this->l('If the param is empty or equal 0, the widget will show scrollbar when more items. Or you can input number from 1-20. Default NULL.')
),
array(
'type' => 'text',
'label' => $this->l('User'),
'name' => 'username',
'default' => 'prestashop',
),
array(
'type' => 'color',
'label' => $this->l('Border Color'),
'name' => 'border_color',
'default' => '#000',
),
array(
'type' => 'color',
'label' => $this->l('Link Color'),
'name' => 'link_color',
'default' => '#000',
),
array(
'type' => 'color',
'label' => $this->l('Text Color'),
'name' => 'text_color',
'default' => '#000',
),
array(
'type' => 'color',
'label' => $this->l('Name Color'),
'name' => 'name_color',
'default' => '#000',
),
array(
'type' => 'color',
'label' => $this->l('Nick name Color'),
'name' => 'mail_color',
'default' => '#000',
),
array(
'type' => 'text',
'label' => $this->l('Width'),
'name' => 'width',
'default' => 180,
),
array(
'type' => 'text',
'label' => $this->l('Height'),
'name' => 'height',
'default' => 200,
),
array(
'type' => 'switch',
'label' => $this->l('Show background'),
'name' => 'transparent',
'values' => $soption,
'default' => 0,
),
array(
'type' => 'switch',
'label' => $this->l('Show Replies'),
'name' => 'show_replies',
'values' => $soption,
'default' => 0,
),
array(
'type' => 'switch',
'label' => $this->l('Show Header'),
'name' => 'show_header',
'values' => $soption,
'default' => 0,
),
array(
'type' => 'switch',
'label' => $this->l('Show Footer'),
'name' => 'show_footer',
'values' => $soption,
'default' => 0,
),
array(
'type' => 'switch',
'label' => $this->l('Show Border'),
'name' => 'show_border',
'values' => $soption,
'default' => 0,
),
array(
'type' => 'switch',
'label' => $this->l('Show Scrollbar'),
'name' => 'show_scrollbar',
'values' => $soption,
'default' => 0,
),
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues($data),
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang
);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
# validate module
unset($args);
$t = array(
'name' => '',
'twidget_id' => '578806287158251521',
'count' => 2,
'username' => 'prestashop',
'theme' => 'light',
'border_color' => '#000',
'link_color' => '#000',
'text_color' => '#000',
'name_color' => '#000',
'mail_color' => '#000',
'width' => 180,
'height' => 200,
'show_replies' => 0,
'show_header' => 0,
'show_footer' => 0,
'show_border' => 0,
'show_scrollbar' => 0,
'transparent' => 0,
);
$setting = array_merge($t, $setting);
$setting['chrome'] = '';
if (isset($setting['show_header']) && $setting['show_header'] == 0) {
$setting['chrome'] .= 'noheader ';
}
if ($setting['show_footer'] == 0) {
$setting['chrome'] .= 'nofooter ';
}
if ($setting['show_border'] == 0) {
$setting['chrome'] .= 'noborders ';
}
if ($setting['transparent'] == 0) {
$setting['chrome'] .= 'transparent';
}
$setting['iso_code'] = Context::getContext()->language->iso_code;
$output = array('type' => 'twitter', 'data' => $setting);
return $output;
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
if ($multi_lang == 0) {
return array(
'twidget_id',
'count',
'username',
'border_color',
'link_color',
'text_color',
'name_color',
'mail_color',
'width',
'height',
'transparent',
'show_replies',
'show_header',
'show_footer',
'show_border',
'show_scrollbar',
);
} elseif ($multi_lang == 1) {
return array(
);
} elseif ($multi_lang == 2) {
return array(
);
}
}
}

View File

@@ -0,0 +1,122 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* 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 LeoWidgetVideocode extends LeoWidgetBase
{
public $name = 'video_code';
public $for_module = 'all';
public function getWidgetInfo()
{
return array('label' => $this->l('Video Code'), 'explain' => $this->l('Make Video widget via putting Youtube Code, Vimeo Code'));
}
public function renderForm($args, $data)
{
# validate module
unset($args);
$helper = $this->getFormHelper();
$this->fields_form[1]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Form.'),
),
'input' => array(
array(
'type' => 'textarea',
'label' => $this->l('Content'),
'name' => 'video_code',
'cols' => 40,
'rows' => 10,
'value' => true,
'default' => '',
'autoload_rte' => false,
'desc' => $this->l('Copy Video CODE from youtube, vimeo and put here')
),
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues($data),
'languages' => Context::getContext()->controller->getLanguages(),
'id_language' => $default_lang
);
return $helper->generateForm($this->fields_form);
}
public function renderContent($args, $setting)
{
# validate module
unset($args);
$t = array(
'name' => '',
'video_code' => '',
);
$setting = array_merge($t, $setting);
$html = $setting['video_code'];
$html = html_entity_decode(Tools::stripslashes($html), ENT_QUOTES, 'UTF-8');
// $header = '';
// $content = $html;
$output = array('type' => 'video', 'data' => $setting);
return $output;
}
/**
* 0 no multi_lang
* 1 multi_lang follow id_lang
* 2 multi_lnag follow code_lang
*/
public function getConfigKey($multi_lang = 0)
{
if ($multi_lang == 0) {
return array(
'video_code',
);
} elseif ($multi_lang == 1) {
return array(
);
} elseif ($multi_lang == 2) {
return array(
);
}
}
}

View File

@@ -0,0 +1,377 @@
<?php
/**
* 2007-2015 Leotheme
*
* NOTICE OF LICENSE
*
* Leo Bootstrap Menu
*
* DISCLAIMER
*
* @author leotheme <leotheme@gmail.com>
* @copyright 2007-2015 Leotheme
* @license http://leotheme.com - prestashop template provider
*/
if (!defined('_PS_VERSION_')) {
# module validation
exit;
}
if (!class_exists('LeoWidgetBase')) {
abstract class LeoWidgetBase
{
public $widget_name = 'base';
public $name = 'leobootstrapmenu';
public $id_shop = 0;
public $fields_form = array();
public $types = array();
public $theme_img_module;
// public $translator = Context::getContext()->getTranslator();
//add parameter
public function __construct()
{
$this->theme_img_module = _THEME_IMG_DIR_.'modules/leobootstrapmenu/';
}
/**
* abstract method to return html widget form
*/
public function getWidgetInfo()
{
return array('key' => 'base', 'label' => 'Widget Base');
}
/**
* abstract method to return html widget form
*/
public function renderForm($args, $data)
{
# validate module
unset($args);
unset($data);
return false;
}
/**
* abstract method to return widget data
*/
public function renderContent($args, $data)
{
# validate module
unset($args);
unset($data);
return false;
}
/**
* Get translation for a given module text
*
* Note: $specific parameter is mandatory for library files.
* Otherwise, translation key will not match for Module library
* when module is loaded with eval() Module::getModulesOnDisk()
*
* @param string $string String to translate
* @param boolean|string $specific filename to use in translation key
* @return string Translation
*/
public function l($string, $specific = false)
{
return Translate::getModuleTranslation($this->name, $string, ($specific) ? $specific : $this->name);
}
/**
* Asign value for each input of Data form
*/
public function getConfigFieldsValues($data = null)
{
$languages = Language::getLanguages(false);
$fields_values = array();
$obj = isset($data['params']) ? $data['params'] : array();
foreach ($this->fields_form as $k => $f) {
foreach ($f['form']['input'] as $j => $input) {
if (isset($input['lang'])) {
foreach ($languages as $lang) {
$fields_values[$input['name']][$lang['id_lang']] = isset($obj[$input['name'].'_'.$lang['id_lang']]) ? Tools::stripslashes($obj[$input['name'].'_'.$lang['id_lang']]) : $input['default'];
}
} else {
if (isset($obj[trim($input['name'])])) {
$value = $obj[trim($input['name'])];
if ($input['name'] == 'image' && $value) {
$thumb = __PS_BASE_URI__.'modules/'.$this->name.'/img/'.$value;
$this->fields_form[$k]['form']['input'][$j]['thumb'] = $thumb;
}
$fields_values[$input['name']] = Tools::stripslashes($value);
} else {
$v = Tools::getValue($input['name'], Configuration::get($input['name']));
$fields_values[$input['name']] = $v ? $v : $input['default'];
}
}
}
}
if (isset($data['id_btmegamenu_widgets'])) {
$fields_values['id_btmegamenu_widgets'] = $data['id_btmegamenu_widgets'];
}
//update for new plugin facebook like
if (isset($data['params']['tabdisplay_timeline'])) {
$fields_values['tabdisplay_timeline'] = $data['params']['tabdisplay_timeline'];
}
//update for new plugin facebook like
if (isset($data['params']['tabdisplay_events'])) {
$fields_values['tabdisplay_events'] = $data['params']['tabdisplay_events'];
}
//update for new plugin facebook like
if (isset($data['params']['tabdisplay_messages'])) {
$fields_values['tabdisplay_messages'] = $data['params']['tabdisplay_messages'];
}
return $fields_values;
}
public function getFormHelper()
{
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$this->fields_form[0]['form'] = array(
'legend' => array(
'title' => $this->l('Widget Info.'),
),
'input' => array(
array(
'type' => 'hidden',
'label' => $this->l('Megamenu ID'),
'name' => 'id_btmegamenu_widgets',
'default' => 0,
),
array(
'type' => 'text',
'label' => $this->l('Widget Name'),
'name' => 'widget_name',
'default' => '',
'required' => true,
'desc' => $this->l('Using for show in Listing Widget Management')
),
array(
'type' => 'text',
'label' => $this->l('Widget Title'),
'name' => 'widget_title',
'default' => '',
'lang' => true,
'desc' => $this->l('This tile will be showed as header of widget block. Empty to disable')
),
array(
'type' => 'select',
'label' => $this->l('Widget Type'),
'id' => 'widget_type',
'name' => 'widget_type',
'options' => array('query' => $this->types,
'id' => 'type',
'name' => 'label'
),
'default' => Tools::getValue('wtype'),
'desc' => $this->l('Select a alert style')
),
),
'buttons' => array(
array(
'title' => $this->l('Save And Stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveandstayleowidget'
),
array(
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'type' => 'submit',
'name' => 'saveleowidget'
),
)
);
$helper = new HelperForm();
$helper->show_cancel_button = true;
$helper->module = $this;
$helper->name_controller = $this->name;
$helper->identifier = $this->name;
$helper->token = Tools::getAdminTokenLite('AdminLeoWidgets');
foreach (Language::getLanguages(false) as $lang) {
$helper->languages[] = array(
'id_lang' => $lang['id_lang'],
'iso_code' => $lang['iso_code'],
'name' => $lang['name'],
'is_default' => ($default_lang == $lang['id_lang'] ? 1 : 0)
);
}
$helper->currentIndex = AdminController::$currentIndex.'&widgets=1&rand='.rand().'&wtype='.Tools::getValue('wtype');
$helper->default_form_language = $default_lang;
$helper->allow_employee_form_lang = $default_lang;
$helper->toolbar_scroll = true;
$helper->title = $this->name;
$helper->submit_action = 'addbtmegamenu_widgets';
# validate module
// $liveeditorURL = AdminController::$currentIndex.'&edit=1&token='.Tools::getAdminTokenLite('AdminLeotempcpWidgets');
$helper->toolbar_btn = array(
'back' =>
array(
'desc' => $this->l('Back'),
'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminLeoWidgets').'&widgets=1&rand='.rand(),
),
);
return $helper;
}
public function getManufacturers($id_shop)
{
if (!$id_shop) {
$id_shop = $this->context->shop->id;
}
$pmanufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT m.`id_manufacturer`,m.`name`
FROM `'._DB_PREFIX_.'manufacturer` m
LEFT JOIN `'._DB_PREFIX_.'manufacturer_shop` ms ON (m.`id_manufacturer` = ms.`id_manufacturer` AND ms.`id_shop` = '.(int)$id_shop.')');
return $pmanufacturers;
}
public function getProducts($where, $id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $random = false, $random_number_products = 1, $check_access = true, Context $context = null)
{
# validate module
unset($check_access);
if (!$context) {
$context = Context::getContext();
}
$front = true;
if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) {
$front = false;
}
if ($p < 1) {
$p = 1;
}
if (empty($order_by)) {
$order_by = 'position';
} else {
/* Fix for all modules which are now using lowercase values for 'orderBy' parameter */
$order_by = Tools::strtolower($order_by);
}
if (empty($order_way)) {
$order_way = 'ASC';
}
if ($order_by == 'id_product' || $order_by == 'date_add' || $order_by == 'date_upd') {
$order_by_prefix = 'p';
} elseif ($order_by == 'name') {
$order_by_prefix = 'pl';
} elseif ($order_by == 'manufacturer') {
$order_by_prefix = 'm';
$order_by = 'name';
} elseif ($order_by == 'position') {
$order_by_prefix = 'cp';
}
if ($order_by == 'price') {
$order_by = 'orderprice';
}
if (!Validate::isBool($active) || !Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) {
die(Tools::displayError());
}
$id_supplier = (int)Tools::getValue('id_supplier');
/* Return only the number of products */
if ($get_total) {
$sql = 'SELECT COUNT(cp.`id_product`) AS total
FROM `'._DB_PREFIX_.'product` p
'.Shop::addSqlAssociation('product', 'p').'
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product`
'.pSQL($where).'
'.pSQL($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '').
pSQL($active ? ' AND product_shop.`active` = 1' : '').
pSQL($id_supplier ? 'AND p.id_supplier = '.(int)$id_supplier : '');
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
$sql = 'SELECT DISTINCT p.id_product, p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, product_attribute_shop.`id_product_attribute`, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`,
pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, image_shop.`id_image`,
il.`legend`, m.`name` AS manufacturer_name, cl.`name` AS category_default,
DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(),
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).'
DAY)) > 0 AS new, product_shop.price AS orderprice
FROM `'._DB_PREFIX_.'category_product` cp
LEFT JOIN `'._DB_PREFIX_.'product` p
ON p.`id_product` = cp.`id_product`
'.Shop::addSqlAssociation('product', 'p').'
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
ON (p.`id_product` = pa.`id_product`)
'.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1').'
'.Product::sqlStock('p', 'product_attribute_shop', false, $context->shop).'
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
ON (product_shop.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
ON (p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'image` i
ON (i.`id_product` = p.`id_product`)'.
Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
LEFT JOIN `'._DB_PREFIX_.'image_lang` il
ON (image_shop.`id_image` = il.`id_image`
AND il.`id_lang` = '.(int)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m
ON m.`id_manufacturer` = p.`id_manufacturer`
'.$where.'
AND product_shop.`id_shop` = '.(int)$context->shop->id.'
AND (pa.id_product_attribute IS NULL OR product_attribute_shop.id_shop='.(int)$context->shop->id.')
AND (i.id_image IS NULL OR image_shop.id_shop='.(int)$context->shop->id.')
'.($active ? ' AND product_shop.`active` = 1' : '')
.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '')
.($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '');
if ($random === true) {
$sql .= ' ORDER BY RAND()';
$sql .= ' LIMIT 0, '.(int)$random_number_products;
} else {
$order_way = Validate::isOrderWay($order_way) ? Tools::strtoupper($order_way) : 'ASC'; // $order_way Validate::isOrderWay()
$sql .= ' ORDER BY '.(isset($order_by_prefix) ? '`'.pSQL($order_by_prefix).'`.' : '').'`'.bqSQL($order_by).'` '.pSQL($order_way).'
LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n;
}
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if ($order_by == 'orderprice') {
Tools::orderbyPrice($result, $order_way);
}
if (!$result) {
return array();
}
/* Modify SQL result */
return Product::getProductsProperties($id_lang, $result);
}
public static function getImageList($path)
{
if (!file_exists($path) && !is_dir($path)) {
@mkdir($path, 0777, true);
}
$items = array();
$handle = opendir($path);
if (!$handle) {
return $items;
}
while (false !== ($file = readdir($handle))) {
//if (is_dir($path . $file))
$items[$file] = $file;
}
unset($items['.'], $items['..'], $items['.svn']);
return $items;
}
}
}