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

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(
);
}
}
}