first commit
This commit is contained in:
12
modules/appagebuilder/Readme.md
Normal file
12
modules/appagebuilder/Readme.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Ap Page Builder
|
||||
|
||||
## About
|
||||
Construction site: provide a method of building effective site, high flexibility, to create multi header and profile for the home page, product page.
|
||||
The module will provide a full range of widgets with user friendly features for building websites for your shop as optimized for SEO, responsive design, multi header...
|
||||
|
||||
version 2.3.6
|
||||
#add slick for thumb in mobile
|
||||
#convert cache to default prestashop cache type
|
||||
#fix random in product tab
|
||||
version 2.4.1
|
||||
add breadcrumb and otimization
|
||||
31
modules/appagebuilder/apadminajax.php
Normal file
31
modules/appagebuilder/apadminajax.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
require_once(dirname(__FILE__).'/../../config/config.inc.php');
|
||||
require_once(dirname(__FILE__).'/../../init.php');
|
||||
include_once(dirname(__FILE__).'/appagebuilder.php');
|
||||
|
||||
$module = APPageBuilder::getInstance();
|
||||
|
||||
//DONGND:: get product link for demo multi product detail
|
||||
if (Tools::getValue('action') == 'get-list-shortcode') {
|
||||
$result = '';
|
||||
$result = $module->getListShortCodeForEditor();
|
||||
die($result);
|
||||
}
|
||||
240
modules/appagebuilder/apajax.php
Normal file
240
modules/appagebuilder/apajax.php
Normal file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__).'/../../config/config.inc.php');
|
||||
require_once(dirname(__FILE__).'/../../init.php');
|
||||
include_once(dirname(__FILE__).'/appagebuilder.php');
|
||||
include_once(dirname(__FILE__).'/classes/shortcodes.php');
|
||||
include_once(dirname(__FILE__).'/classes/shortcodes/ApProductList.php');
|
||||
$module = APPageBuilder::getInstance();
|
||||
apPageHelper::setGlobalVariable(Context::getContext());
|
||||
|
||||
//DONGND:: get product link for demo multi product detail
|
||||
if (Tools::getValue('action') == 'get-product-link') {
|
||||
$result = '';
|
||||
|
||||
$sql = 'SELECT p.`id_product` FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').'
|
||||
AND product_shop.`visibility` IN ("both", "catalog")
|
||||
AND product_shop.`active` = 1
|
||||
ORDER BY p.`id_product` ASC';
|
||||
$first_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
$result = Context::getContext()->link->getProductLink($first_product['id_product'], null, null, null, null, null, (int)Product::getDefaultAttribute((int)$first_product['id_product']));
|
||||
die(Tools::jsonEncode($result));
|
||||
}
|
||||
|
||||
if (Tools::getValue('leoajax') == 1) {
|
||||
# process category
|
||||
$list_cat = Tools::getValue('cat_list');
|
||||
$product_list_image = Tools::getValue('product_list_image');
|
||||
$product_one_img = Tools::getValue('product_one_img');
|
||||
$product_attribute_one_img = Tools::getValue('product_attribute_one_img');
|
||||
$product_all_one_img = Tools::getValue('product_all_one_img');
|
||||
$leo_pro_cdown = Tools::getValue('pro_cdown');
|
||||
$leo_pro_color = Tools::getValue('pro_color');
|
||||
$tab_shortcode = Tools::getValue('tabshortcode');
|
||||
$tab_shortcode_key = Tools::getValue('tabshortcodekey');
|
||||
|
||||
// $ap_extra = Tools::getValue('product_apextra');
|
||||
//add function wishlist compare
|
||||
$wishlist_compare = Tools::getValue('wishlist_compare');
|
||||
|
||||
$result = array();
|
||||
if ($tab_shortcode) {
|
||||
$tab_content = explode("@|@", $tab_shortcode);
|
||||
$tab_content_key = explode("@|@", $tab_shortcode_key);
|
||||
$result['ajaxTab'] = array();
|
||||
for ($i = 0; $i < count($tab_content); $i++) {
|
||||
$shortcode = urldecode($tab_content[$i]);
|
||||
if (empty(ApShortCodesBuilder::$shortcode_tags)) {
|
||||
apPageHelper::loadShortCode(apPageHelper::getConfigDir('_PS_THEME_DIR_'));
|
||||
}
|
||||
$content = ApShortCodesBuilder::doShortcode($shortcode);
|
||||
$result['ajaxTab'][$tab_content_key[$i]] = $content;
|
||||
}
|
||||
}
|
||||
//get number product of compare + wishlist
|
||||
if ($wishlist_compare) {
|
||||
$wishlist_products = 0;
|
||||
if (Configuration::get('LEOFEATURE_ENABLE_PRODUCTWISHLIST') && isset(Context::getContext()->cookie->id_customer)) {
|
||||
$current_user = (int)Context::getContext()->cookie->id_customer;
|
||||
$list_wishlist = Db::getInstance()->executeS("SELECT id_wishlist FROM `"._DB_PREFIX_."leofeature_wishlist` WHERE id_customer = '" . (int)$current_user."'");
|
||||
foreach ($list_wishlist as $list_wishlist_item) {
|
||||
$number_product_wishlist = Db::getInstance()->getValue("SELECT COUNT(id_wishlist_product) FROM `"._DB_PREFIX_."leofeature_wishlist_product` WHERE id_wishlist = ".(int)$list_wishlist_item['id_wishlist']);
|
||||
$wishlist_products += $number_product_wishlist;
|
||||
}
|
||||
// $wishlist_products = Db::getInstance()->getValue("SELECT COUNT(id_wishlist_product) FROM `"._DB_PREFIX_."wishlist_product` WHERE id_wishlist = '$id_wishlist'");
|
||||
}
|
||||
|
||||
$compared_products = array();
|
||||
if (Configuration::get('LEOFEATURE_ENABLE_PRODUCTCOMPARE') && Configuration::get('LEOFEATURE_COMPARATOR_MAX_ITEM') > 0 && isset(Context::getContext()->cookie->id_compare)) {
|
||||
$compared_products = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT `id_product`
|
||||
FROM `'._DB_PREFIX_.'leofeature_compare` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'leofeature_compare_product` cp ON (cp.`id_compare` = c.`id_compare`)
|
||||
WHERE cp.`id_compare` = '.(int)(Context::getContext()->cookie->id_compare));
|
||||
}
|
||||
$result['wishlist_products'] = $wishlist_products;
|
||||
$result['compared_products'] = count($compared_products);
|
||||
}
|
||||
|
||||
if ($list_cat) {
|
||||
$list_cat = explode(',', $list_cat);
|
||||
$list_cat = array_filter($list_cat);
|
||||
$list_cat = array_unique($list_cat);
|
||||
$list_cat = array_map('intval', $list_cat); // fix sql injection
|
||||
$list_cat = implode(',', $list_cat);
|
||||
|
||||
$sql = 'SELECT COUNT(cp.`id_product`) AS total, cp.`id_category` FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product`
|
||||
WHERE cp.`id_category` IN ('.pSQL($list_cat).')
|
||||
AND product_shop.`visibility` IN ("both", "catalog")
|
||||
AND product_shop.`active` = 1
|
||||
GROUP BY cp.`id_category`';
|
||||
$cat = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
if ($cat) {
|
||||
$result['cat'] = $cat;
|
||||
}
|
||||
}
|
||||
|
||||
if ($leo_pro_cdown) {
|
||||
$leo_pro_cdown = explode(',', $leo_pro_cdown);
|
||||
$leo_pro_cdown = array_unique($leo_pro_cdown);
|
||||
$leo_pro_cdown = implode(',', $leo_pro_cdown);
|
||||
$result['pro_cdown'] = $module->hookProductCdown($leo_pro_cdown);
|
||||
}
|
||||
|
||||
if ($leo_pro_color) {
|
||||
$leo_pro_color = explode(',', $leo_pro_color);
|
||||
$leo_pro_color = array_unique($leo_pro_color);
|
||||
$leo_pro_color = implode(',', $leo_pro_color);
|
||||
$result['pro_color'] = $module->hookProductColor($leo_pro_color);
|
||||
}
|
||||
|
||||
if ($product_list_image) {
|
||||
$product_list_image = explode(',', $product_list_image);
|
||||
$product_list_image = array_unique($product_list_image);
|
||||
$product_list_image = implode(',', $product_list_image);
|
||||
|
||||
# $leocustomajax = new Leocustomajax();
|
||||
$result['product_list_image'] = $module->hookProductMoreImg($product_list_image);
|
||||
}
|
||||
|
||||
|
||||
if ($product_one_img) {
|
||||
$product_one_img = explode(',', $product_one_img);
|
||||
$product_one_img = array_unique($product_one_img);
|
||||
$product_one_img = implode(',', $product_one_img);
|
||||
|
||||
$result['product_one_img'] = $module->hookProductOneImg($product_one_img);
|
||||
}
|
||||
if ($product_attribute_one_img) {
|
||||
$product_attribute_one_img = explode(',', $product_attribute_one_img);
|
||||
$product_attribute_one_img = array_unique($product_attribute_one_img);
|
||||
$product_attribute_one_img = implode(',', $product_attribute_one_img);
|
||||
|
||||
$result['product_attribute_one_img'] = $module->hookProductAttributeOneImg($product_attribute_one_img);
|
||||
}
|
||||
if ($product_all_one_img) {
|
||||
$product_all_one_img = explode(',', $product_all_one_img);
|
||||
$product_all_one_img = array_unique($product_all_one_img);
|
||||
$product_all_one_img = implode(',', $product_all_one_img);
|
||||
|
||||
$result['product_all_one_img'] = $module->hookProductAllOneImg($product_all_one_img);
|
||||
}
|
||||
if (Tools::getIsset('product_size') || Tools::getIsset('product_attribute')) {
|
||||
$product_size = $product_attribute = array();
|
||||
if (Tools::getIsset('product_size') && Tools::getValue('product_size')) {
|
||||
$product_size = explode(',', Tools::getValue('product_size'));
|
||||
}
|
||||
if (Tools::getIsset('product_attribute') && Tools::getValue('product_attribute')) {
|
||||
$product_attribute = explode(',', Tools::getValue('product_attribute'));
|
||||
}
|
||||
|
||||
$result['product_attribute'] = $module->hookGetProductAttribute($product_attribute, $product_size);
|
||||
}
|
||||
if (Tools::getIsset('product_manufacture')) {
|
||||
$result['product_manufacture'] = $module->hookGetProductManufacture(Tools::getValue('product_manufacture'));
|
||||
}
|
||||
if ($result) {
|
||||
die(Tools::jsonEncode($result));
|
||||
}
|
||||
} elseif (Tools::getValue('widget') == 'ApImageGallery') {
|
||||
$show_number = Tools::getValue('show_number');
|
||||
$assign = Tools::getValue('assign', array());
|
||||
$assign = Tools::jsonDecode($assign, true);
|
||||
|
||||
$show_number_new = $show_number;
|
||||
$form_atts = $assign['formAtts'];
|
||||
|
||||
$limit = (int)$form_atts['limit'] + $show_number;
|
||||
$images = array();
|
||||
$link = new Link();
|
||||
$current_link = $link->getPageLink('', false, Context::getContext()->language->id);
|
||||
$path = _PS_ROOT_DIR_.'/'.str_replace($current_link, '', isset($form_atts['path']) ? $form_atts['path'] : '');
|
||||
$arr_exten = array('jpg', 'jpge', 'gif', 'png');
|
||||
|
||||
$count = 0;
|
||||
if ($path && is_dir($path)) {
|
||||
if ($handle = scandir($path)) {
|
||||
if (($key = array_search('.', $handle)) !== false) {
|
||||
unset($handle[$key]);
|
||||
}
|
||||
if (($key = array_search('..', $handle)) !== false) {
|
||||
unset($handle[$key]);
|
||||
}
|
||||
|
||||
foreach ($handle as $entry) {
|
||||
if ($entry != '.' && $entry != '..' && is_file($path.'/'.$entry)) {
|
||||
$ext = pathinfo($path.'/'.$entry, PATHINFO_EXTENSION);
|
||||
if (in_array($ext, $arr_exten)) {
|
||||
$url = __PS_BASE_URI__.'/'.str_replace($current_link, '', $form_atts['path']).'/'.$entry;
|
||||
$url = str_replace('//', '/', $url);
|
||||
|
||||
if ($count >= $show_number) {
|
||||
$images[] = $url;
|
||||
$show_number_new++;
|
||||
}
|
||||
$count++;
|
||||
if ($count == $limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$total = count($handle);
|
||||
$total_nerver_show = (int)( $total - $count );
|
||||
$c = (int)$form_atts['columns'];
|
||||
$assign['columns'] = $c > 0 ? $c : 4;
|
||||
|
||||
$result = array(
|
||||
'images' => array(),
|
||||
'show_number' => -1,
|
||||
'hasError' => 0,
|
||||
'errors' => array(),
|
||||
);
|
||||
|
||||
$result['images'] = $images;
|
||||
if ($total_nerver_show > 0) {
|
||||
$result['show_number'] = $show_number_new;
|
||||
}
|
||||
die(Tools::jsonEncode($result));
|
||||
} else {
|
||||
$obj = new ApProductList();
|
||||
$result = $obj->ajaxProcessRender($module);
|
||||
die(Tools::jsonEncode($result));
|
||||
}
|
||||
4091
modules/appagebuilder/appagebuilder.php
Normal file
4091
modules/appagebuilder/appagebuilder.php
Normal file
File diff suppressed because it is too large
Load Diff
169
modules/appagebuilder/classes/ApPageBuilderDetailsModel.php
Normal file
169
modules/appagebuilder/classes/ApPageBuilderDetailsModel.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/shortcodes.php');
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageSetting.php');
|
||||
|
||||
class ApPageBuilderDetailsModel extends ObjectModel
|
||||
{
|
||||
public $name;
|
||||
public $params;
|
||||
public $type;
|
||||
public $active;
|
||||
public $plist_key;
|
||||
public $class_detail;
|
||||
public $url_img_preview;
|
||||
public $active_mobile;
|
||||
public $active_tablet;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'appagebuilder_details',
|
||||
'primary' => 'id_appagebuilder_details',
|
||||
'multilang' => false,
|
||||
'multishop' => true,
|
||||
'fields' => array(
|
||||
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
'plist_key' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
'type' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'active' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
|
||||
'active_mobile' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
|
||||
'active_tablet' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
|
||||
'params' => array('type' => self::TYPE_HTML),
|
||||
'class_detail' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
'url_img_preview' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
)
|
||||
);
|
||||
|
||||
public function getAllProductProfileByShop()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$id_shop = $context->shop->id;
|
||||
$where = ' WHERE id_shop='.(int)$id_shop;
|
||||
$sql = 'SELECT p.*, ps.*
|
||||
FROM '._DB_PREFIX_.'appagebuilder_details p
|
||||
INNER JOIN '._DB_PREFIX_.'appagebuilder_details_shop ps ON (ps.id_appagebuilder_details = p.id_appagebuilder_details)'
|
||||
.$where;
|
||||
return Db::getInstance()->executes($sql);
|
||||
}
|
||||
|
||||
public function __construct($id = null, $id_lang = null, $id_shop = null, Context $context = null)
|
||||
{
|
||||
// validate module
|
||||
unset($context);
|
||||
parent::__construct($id, $id_lang, $id_shop);
|
||||
}
|
||||
|
||||
public function add($autodate = true, $null_values = false)
|
||||
{
|
||||
$id_shop = apPageHelper::getIDShop();
|
||||
$res = parent::add($autodate, $null_values);
|
||||
$res &= Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'appagebuilder_details_shop` (`id_shop`, `id_appagebuilder_details`)
|
||||
VALUES('.(int)$id_shop.', '.(int)$this->id.')');
|
||||
if (Db::getInstance()->getValue('SELECT COUNT(p.`id_appagebuilder_details`) AS total FROM `'
|
||||
._DB_PREFIX_.'appagebuilder_details` p INNER JOIN `'
|
||||
._DB_PREFIX_.'appagebuilder_details_shop` ps ON(p.id_appagebuilder_details = ps.id_appagebuilder_details) WHERE id_shop='
|
||||
.(int)$id_shop) <= 1) {
|
||||
$this->deActiveAll();
|
||||
} else if ($this->active) {
|
||||
$this->deActiveAll();
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function toggleStatus()
|
||||
{
|
||||
$this->deActiveAll();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function deActiveAll()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$id_shop = $context->shop->id;
|
||||
$sql = 'UPDATE '._DB_PREFIX_.'appagebuilder_details_shop SET active=0 where id_shop='.(int)$id_shop;
|
||||
Db::getInstance()->execute($sql);
|
||||
$where = ' WHERE ps.id_shop='.(int)$id_shop." AND ps.id_appagebuilder_details = '".(int)$this->id."'";
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_details_shop` ps set ps.active = 1 '.$where);
|
||||
}
|
||||
|
||||
public function toggleStatusMT($field)
|
||||
{
|
||||
$id_shop = apPageHelper::getIDShop();
|
||||
$where = ' WHERE id_shop='.$id_shop." AND id_appagebuilder_details = '".(int)$this->id."'";
|
||||
$where1 = ' WHERE id_appagebuilder_details = "'.(int)$this->id.'"';
|
||||
$result = Db::getInstance()->getRow('SELECT '.$field.' from `'._DB_PREFIX_.'appagebuilder_details_shop` '.$where);
|
||||
$value = $result[$field]==1?0:1;
|
||||
|
||||
if ($value == 1) {
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_details_shop` set '.$field.' = "0" WHERE id_shop="'.$id_shop.'"');
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_details` set '.$field.' = "0"');
|
||||
}
|
||||
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_details_shop` set '.$field.' = "'.$value.'" '.$where);
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_details` set '.$field.' = "'.$value.'" '.$where1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getActive()
|
||||
{
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
if (Tools::getIsset('plist_key') && Tools::getValue('plist_key')) {
|
||||
// validate module
|
||||
$where = " p.plist_key='".pSQL(Tools::getValue('plist_key'))."' and ps.id_shop=".(int)$id_shop;
|
||||
} else {
|
||||
// validate module
|
||||
$where = ' ps.active=1 and ps.id_shop='.(int)$id_shop;
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM '._DB_PREFIX_.'appagebuilder_details p
|
||||
INNER JOIN '._DB_PREFIX_.'appagebuilder_details_shop ps on(p.id_appagebuilder_details = ps.id_appagebuilder_details) WHERE '
|
||||
.pSQL($where);
|
||||
return Db::getInstance()->getRow($sql);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$result = parent::delete();
|
||||
|
||||
if ($result) {
|
||||
if (isset($this->def['multishop']) && $this->def['multishop'] == true) {
|
||||
# DELETE RECORD FORM TABLE _SHOP
|
||||
$id_shop_list = Shop::getContextListShopID();
|
||||
if (count($this->id_shop_list)) {
|
||||
$id_shop_list = $this->id_shop_list;
|
||||
}
|
||||
|
||||
$id_shop_list = array_map('intval', $id_shop_list);
|
||||
//DONGND:: fix sql
|
||||
$id_shop_list = implode(', ', $id_shop_list);
|
||||
|
||||
Db::getInstance()->delete($this->def['table'].'_shop', '`'.$this->def['primary'].'`='.
|
||||
(int)$this->id.' AND id_shop IN ('.pSQL($id_shop_list).')');
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
58
modules/appagebuilder/classes/ApPageBuilderHookModel.php
Normal file
58
modules/appagebuilder/classes/ApPageBuilderHookModel.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageBuilderProfilesModel.php');
|
||||
|
||||
class ApPageBuilderHookModel
|
||||
{
|
||||
public $profile_data;
|
||||
public $profile_param;
|
||||
public $hook;
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->profile_data = ApPageBuilderProfilesModel::getActiveProfile('index', 'model');
|
||||
$this->profile_param = Tools::jsonDecode($this->profile_data['params'], true);
|
||||
$this->fullwidth_index_hook = $this->fullwidthIndexHook();
|
||||
$this->fullwidth_other_hook = $this->fullwidthOtherHook();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fullwidthIndexHook()
|
||||
{
|
||||
return isset($this->profile_param['fullwidth_index_hook']) ? $this->profile_param['fullwidth_index_hook'] : ApPageSetting::getIndexHook(3);
|
||||
}
|
||||
|
||||
public function fullwidthOtherHook()
|
||||
{
|
||||
return isset($this->profile_param['fullwidth_other_hook']) ? $this->profile_param['fullwidth_other_hook'] : ApPageSetting::getOtherHook(3);
|
||||
}
|
||||
|
||||
public function fullwidthHook($hook_name, $page)
|
||||
{
|
||||
if ($page == 'index') {
|
||||
// validate module
|
||||
return isset($this->fullwidth_index_hook[$hook_name]) ? $this->fullwidth_index_hook[$hook_name] : 0;
|
||||
} else {
|
||||
# other page
|
||||
return isset($this->fullwidth_other_hook[$hook_name]) ? $this->fullwidth_other_hook[$hook_name] : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
404
modules/appagebuilder/classes/ApPageBuilderModel.php
Normal file
404
modules/appagebuilder/classes/ApPageBuilderModel.php
Normal file
@@ -0,0 +1,404 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/shortcodes.php');
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageSetting.php');
|
||||
|
||||
class ApPageBuilderModel extends ObjectModel
|
||||
{
|
||||
public $hook_name;
|
||||
public $params;
|
||||
public $id_appagebuilder_positions;
|
||||
public $id_appagebuilder_shortcode;
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'appagebuilder',
|
||||
'primary' => 'id_appagebuilder',
|
||||
'multilang' => true,
|
||||
'multishop' => true,
|
||||
'fields' => array(
|
||||
'hook_name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
'id_appagebuilder_positions' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'params' => array('type' => self::TYPE_HTML, 'lang' => true),
|
||||
'id_appagebuilder_shortcode' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
)
|
||||
);
|
||||
|
||||
public function __construct($id = null, $id_lang = null, $id_shop = null, Context $context = null)
|
||||
{
|
||||
# validate module
|
||||
unset($context);
|
||||
parent::__construct($id, $id_lang, $id_shop);
|
||||
}
|
||||
|
||||
//DONGND:: get id by id shortcode
|
||||
public static function getIdByIdShortCode($id_shortcode)
|
||||
{
|
||||
if (!$id_shortcode) {
|
||||
return false;
|
||||
}
|
||||
$sql = 'SELECT id_appagebuilder FROM '._DB_PREFIX_.'appagebuilder WHERE id_appagebuilder_shortcode = ' . (int)$id_shortcode;
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result['id_appagebuilder'];
|
||||
}
|
||||
|
||||
public function getIdbyHookName($hook_name, $position_id)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$id_shop = (int)$context->shop->id;
|
||||
$sql = 'SELECT p.id_appagebuilder
|
||||
FROM '._DB_PREFIX_.'appagebuilder p
|
||||
LEFT JOIN '._DB_PREFIX_.'appagebuilder_shop ps ON (ps.id_appagebuilder = p.id_appagebuilder)
|
||||
WHERE ps.id_shop = '.(int)$id_shop.'
|
||||
AND hook_name=\''.pSql($hook_name).'\'
|
||||
AND p.id_appagebuilder_positions='.(int)$position_id.' ORDER BY p.id_appagebuilder';
|
||||
$result = Db::getInstance()->executeS($sql);
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($result as $value) {
|
||||
$sql = 'DELETE FROM '._DB_PREFIX_.'appagebuilder_shop
|
||||
WHERE id_appagebuilder IN(SELECT id_appagebuilder
|
||||
FROM '._DB_PREFIX_.'appagebuilder
|
||||
WHERE hook_name=\''.pSql($hook_name).'\'
|
||||
AND id_appagebuilder_positions='.(int)$position_id.'
|
||||
AND id_appagebuilder != '.(int)$value['id_appagebuilder'].')';
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
$sql = 'DELETE FROM '._DB_PREFIX_.'appagebuilder
|
||||
WHERE hook_name=\''.pSql($hook_name).'\'
|
||||
AND id_appagebuilder_positions='.(int)$position_id.'
|
||||
AND id_appagebuilder != '.(int)$value['id_appagebuilder'];
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
return $value['id_appagebuilder'];
|
||||
}
|
||||
}
|
||||
|
||||
public function getIdbyHookNameAndProfile($hook_name, $profile, $id_lang)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$id_shop = (int)$context->shop->id;
|
||||
|
||||
//$id_lang = (int)$id_lang;
|
||||
if (!$profile->header && !$profile->content && !$profile->footer && !$profile->product) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$arr = array($profile->header, $profile->content, $profile->footer, $profile->product);
|
||||
|
||||
$sql = 'SELECT p.id_appagebuilder, pl.params
|
||||
FROM '._DB_PREFIX_.'appagebuilder p
|
||||
LEFT JOIN '._DB_PREFIX_.'appagebuilder_shop ps ON (ps.id_appagebuilder = p.id_appagebuilder AND id_shop='.(int)$id_shop.')
|
||||
LEFT JOIN '._DB_PREFIX_.'appagebuilder_lang pl ON (p.id_appagebuilder = pl.id_appagebuilder AND pl.id_lang='.(int)$id_lang.')
|
||||
WHERE p.`hook_name`=\''.$hook_name.'\'
|
||||
AND ps.id_shop='.(int)$id_shop.'
|
||||
AND pl.id_lang='.(int)$id_lang.'
|
||||
AND p.id_appagebuilder_positions IN ('. pSQL(implode(',', array_map('intval', $arr))).')
|
||||
ORDER BY p.id_appagebuilder';
|
||||
return Db::getInstance()->getRow($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* getListPositisionByType
|
||||
* @param type $type = {all, header, content, footer, product}
|
||||
* @return type
|
||||
*/
|
||||
public function getListPositisionByType($type = 'all', $id_shop = null)
|
||||
{
|
||||
$str = Tools::strtolower($type);
|
||||
$sql = 'SELECT p.* FROM `'._DB_PREFIX_.'appagebuilder_positions` p'
|
||||
.' INNER JOIN `'._DB_PREFIX_.'appagebuilder_positions_shop` ps ON (p.id_appagebuilder_positions = ps.id_appagebuilder_positions)';
|
||||
if ($type != 'all') {
|
||||
$sql .= ' WHERE p.position=\''.pSQL($str).'\' AND ps.id_shop='.(int)$id_shop;
|
||||
}
|
||||
|
||||
return Db::getInstance()->executeS($sql, 1);
|
||||
}
|
||||
|
||||
public function add($autodate = true, $null_values = false)
|
||||
{
|
||||
$id_shop = apPageHelper::getIDShop();
|
||||
$res = parent::add($autodate, $null_values);
|
||||
$res &= Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'appagebuilder_shop` (`id_shop`, `id_appagebuilder`)
|
||||
VALUES('.(int)$id_shop.', '.(int)$this->id.')');
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function save($null_values = false, $autodate = true)
|
||||
{
|
||||
# validate module
|
||||
unset($null_values);
|
||||
unset($autodate);
|
||||
$context = Context::getContext();
|
||||
$this->id_shop = $context->shop->id;
|
||||
return parent::save();
|
||||
}
|
||||
|
||||
public function parseData($hook_name, $data, $profile_param)
|
||||
{
|
||||
ApShortCodesBuilder::$is_front_office = 1;
|
||||
ApShortCodesBuilder::$is_gen_html = 1;
|
||||
ApShortCodesBuilder::$profile_param = $profile_param;
|
||||
$ap_helper = new ApShortCodesBuilder();
|
||||
ApShortCodesBuilder::$hook_name = $hook_name;
|
||||
$result = $ap_helper->parse($data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all item by position include information: hooks postion and data
|
||||
* @param type $pos
|
||||
* @param type $id_position
|
||||
* @param type $id_profile
|
||||
* @param type $is_font
|
||||
* @param type $id_lang
|
||||
* @return type
|
||||
*/
|
||||
public function getAllItemsByPosition($pos, $id_position, $id_profile = 0, $is_font = 0, $id_lang = 0)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$id_shop = (int)$context->shop->id;
|
||||
$id_position = (int)$id_position;
|
||||
$id_profile = (int)$id_profile;
|
||||
$where = ' WHERE ps.id_shop='.(int)$id_shop.' AND pp.id_appagebuilder_positions='.(int)$id_position;
|
||||
if ($id_profile) {
|
||||
$where .= ' AND ppr.id_appagebuilder_profiles='.(int)$id_profile;
|
||||
}
|
||||
if ($id_lang) {
|
||||
$where .= ' AND pl.id_lang = '.(int)$id_lang;
|
||||
} else {
|
||||
// $id_lang = $context->language->id; // default in admin account
|
||||
$id_lang = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
}
|
||||
$sql = 'SELECT p.*, pl.params, pl.id_lang
|
||||
FROM `'._DB_PREFIX_.'appagebuilder` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'appagebuilder_shop` ps ON (ps.id_appagebuilder = p.id_appagebuilder)
|
||||
LEFT JOIN `'._DB_PREFIX_.'appagebuilder_lang` pl ON (pl.id_appagebuilder = p.id_appagebuilder)
|
||||
LEFT JOIN `'._DB_PREFIX_.'appagebuilder_positions` pp ON (p.id_appagebuilder_positions=pp.id_appagebuilder_positions)
|
||||
LEFT JOIN `'._DB_PREFIX_.'appagebuilder_profiles` ppr ON (ppr.`'.bqSQL($pos).'`=pp.id_appagebuilder_positions)
|
||||
'.pSql($where).' ORDER BY p.id_appagebuilder';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
# FIX - Only get language data valid
|
||||
// $id_langs = Language::getLanguages(true, false, true);
|
||||
// foreach ($result as $key => $val) {
|
||||
// if (isset($val['id_lang']) && !in_array($val['id_lang'], $id_langs)) {
|
||||
// unset($result[$key]);
|
||||
// }
|
||||
// }
|
||||
|
||||
$data_lang = array();
|
||||
if ($is_font) {
|
||||
foreach ($result as $row) {
|
||||
$data_lang[$row['hook_name']] = $row['params'];
|
||||
}
|
||||
return $data_lang;
|
||||
}
|
||||
$ap_helper = new ApShortCodesBuilder();
|
||||
ApShortCodesBuilder::$is_front_office = $is_font;
|
||||
ApShortCodesBuilder::$is_gen_html = 1;
|
||||
foreach ($result as $row) {
|
||||
if (isset($data_lang[$row['id_appagebuilder']])) {
|
||||
$data_lang[$row['id_appagebuilder']]['params'][$row['id_lang']] = $row['params'];
|
||||
} else {
|
||||
$data_lang[$row['id_appagebuilder']] = array(
|
||||
'id' => $row['id_appagebuilder'],
|
||||
'hook_name' => $row['hook_name'],
|
||||
);
|
||||
$data_lang[$row['id_appagebuilder']]['params'][$row['id_lang']] = $row['params'];
|
||||
}
|
||||
}
|
||||
//$data_hook = array_flip(ApPageSetting::getHookHome());
|
||||
$hook_config = Configuration::get('APPAGEBUILDER_' . Tools::strtoupper($pos).'_HOOK');
|
||||
$hook_config = explode(',', $hook_config ? $hook_config : ApPageSetting::getHook($pos));
|
||||
$data_hook = array_flip($hook_config);
|
||||
foreach ($data_lang as $row) {
|
||||
//process params
|
||||
foreach ($row['params'] as $key => $value) {
|
||||
ApShortCodesBuilder::$lang_id = $key;
|
||||
if ($key == $id_lang) {
|
||||
ApShortCodesBuilder::$is_gen_html = 1;
|
||||
$row['content'] = $ap_helper->parse($value);
|
||||
} else {
|
||||
ApShortCodesBuilder::$is_gen_html = 0;
|
||||
$ap_helper->parse($value);
|
||||
}
|
||||
}
|
||||
$data_hook[$row['hook_name']] = $row;
|
||||
}
|
||||
return array('content' => $data_hook, 'dataForm' => ApShortCodesBuilder::$data_form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all items - datas of all hooks by shop Id, lang Id for front-end or back-end
|
||||
* @param type $list_pos_id array
|
||||
*/
|
||||
public function getAllItemsByPositionId($list_pos_id)
|
||||
{
|
||||
if ($list_pos_id) {
|
||||
$sql = 'SELECT DISTINCT(id_appagebuilder) as id FROM `'._DB_PREFIX_.'appagebuilder` p
|
||||
WHERE id_appagebuilder_positions IN('. pSQL(implode(',', array_map('intval', $list_pos_id))).')';
|
||||
return Db::getInstance()->executes($sql);
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all items - datas of all hooks by shop Id, lang Id for front-end or back-end
|
||||
* @param type $id_profiles
|
||||
* @param type $is_font (=0: for back-end; =1: for front-end)
|
||||
* @param type $id_lang
|
||||
* @return type
|
||||
*/
|
||||
public function getAllItems($profile, $is_font = 0, $id_lang = 0)
|
||||
{
|
||||
//print_r("Input: $id_profiles - $is_font - $id_lang"); 2-1-1
|
||||
$context = Context::getContext();
|
||||
// $id_profiles = (int)$profile['id_appagebuilder_profiles'];
|
||||
$id_shop = (int)$context->shop->id;
|
||||
$id_lang = $id_lang ? (int)$id_lang : (int)$context->language->id;
|
||||
if (!$profile['header'] && !$profile['content'] && !$profile['footer'] && !$profile['product']) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$arr = array($profile['header'], $profile['content'], $profile['footer'], $profile['product']);
|
||||
|
||||
$sql = 'SELECT p.*, pl.params, pl.id_lang
|
||||
FROM '._DB_PREFIX_.'appagebuilder p
|
||||
LEFT JOIN '._DB_PREFIX_.'appagebuilder_shop ps ON (ps.id_appagebuilder = p.id_appagebuilder AND id_shop='.(int)$id_shop.')
|
||||
LEFT JOIN '._DB_PREFIX_.'appagebuilder_lang pl ON (pl.id_appagebuilder = p.id_appagebuilder)
|
||||
WHERE
|
||||
pl.id_lang='.(int)$id_lang.'
|
||||
AND ps.id_shop='.(int)$id_shop.'
|
||||
AND p.id_appagebuilder_positions IN ('. pSQL(implode(',', array_map('intval', $arr))).')
|
||||
ORDER BY p.id_appagebuilder';
|
||||
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
$data_lang = array();
|
||||
if ($is_font) {
|
||||
foreach ($result as $row) {
|
||||
$data_lang[$row['hook_name']] = $row['params'];
|
||||
}
|
||||
return $data_lang;
|
||||
}
|
||||
$ap_helper = new ApShortCodesBuilder();
|
||||
ApShortCodesBuilder::$is_front_office = $is_font;
|
||||
ApShortCodesBuilder::$is_gen_html = 1;
|
||||
foreach ($result as $row) {
|
||||
if (isset($data_lang[$row['id_appagebuilder']])) {
|
||||
$data_lang[$row['id_appagebuilder']]['params'][$row['id_lang']] = $row['params'];
|
||||
} else {
|
||||
$data_lang[$row['id_appagebuilder']] = array(
|
||||
'id' => $row['id_appagebuilder'],
|
||||
'hook_name' => $row['hook_name'],
|
||||
);
|
||||
$data_lang[$row['id_appagebuilder']]['params'][$row['id_lang']] = $row['params'];
|
||||
}
|
||||
}
|
||||
$data_hook = array_flip(ApPageSetting::getHookHome());
|
||||
foreach ($data_lang as $row) {
|
||||
//process params
|
||||
foreach ($row['params'] as $key => $value) {
|
||||
ApShortCodesBuilder::$lang_id = $key;
|
||||
if ($key == $id_lang) {
|
||||
ApShortCodesBuilder::$is_gen_html = 1;
|
||||
$row['content'] = $ap_helper->parse($value);
|
||||
} else {
|
||||
ApShortCodesBuilder::$is_gen_html = 0;
|
||||
$ap_helper->parse($value);
|
||||
}
|
||||
}
|
||||
$data_hook[$row['hook_name']] = $row;
|
||||
}
|
||||
|
||||
return array('content' => $data_hook, 'dataForm' => ApShortCodesBuilder::$data_form);
|
||||
}
|
||||
|
||||
public function getAllStoreByShop()
|
||||
{
|
||||
return Store::getStores((int)Context::getContext()->language->id);
|
||||
// $context = Context::getContext();
|
||||
// $id_shop = (int)$context->shop->id;
|
||||
// $id_lang = (int)$context->language->id;
|
||||
// //$where = ' WHERE id_shop="'.$id_shop.'"';
|
||||
// $sql = '
|
||||
// SELECT a.*, cl.name country, st.name state
|
||||
// FROM '._DB_PREFIX_.'store a
|
||||
// LEFT JOIN '._DB_PREFIX_.'country_lang cl
|
||||
// ON (cl.id_country = a.id_country
|
||||
// AND cl.id_lang = '.(int)$id_lang.')
|
||||
// LEFT JOIN '._DB_PREFIX_.'state st
|
||||
// ON (st.id_state = a.id_state)
|
||||
// WHERE a.id_store IN (
|
||||
// SELECT sa.id_store
|
||||
// FROM '._DB_PREFIX_.'store_shop sa
|
||||
// WHERE sa.id_shop = '.(int)$id_shop.'
|
||||
// )';
|
||||
// return Db::getInstance()->executes($sql);
|
||||
}
|
||||
|
||||
public function findOtherProfileUsePosition($id_position, $id_profile)
|
||||
{
|
||||
$sql = 'SELECT * FROM '._DB_PREFIX_.'appagebuilder_profiles ap
|
||||
WHERE (ap.`header`='.(int)$id_position.' OR ap.`content`='.(int)$id_position.'
|
||||
OR ap.`footer`='.(int)$id_position.' OR ap.`product`='.(int)$id_position.')
|
||||
AND ap.`id_appagebuilder_profiles`<>'.(int)$id_profile;
|
||||
return Db::getInstance()->executes($sql);
|
||||
}
|
||||
|
||||
public function updateAppagebuilderLang($id, $id_lang, $params)
|
||||
{
|
||||
//can not use psql, because pramram is import function
|
||||
$data = array('params' => $params);
|
||||
Db::getInstance()->update('appagebuilder_lang', $data, 'id_appagebuilder='.(int)$id.' AND id_lang='.(int)$id_lang);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$result = parent::delete();
|
||||
|
||||
if ($result) {
|
||||
if (isset($this->def['multishop']) && $this->def['multishop'] == true) {
|
||||
# DELETE RECORD FORM TABLE _SHOP
|
||||
$id_shop_list = Shop::getContextListShopID();
|
||||
if (count($this->id_shop_list)) {
|
||||
$id_shop_list = $this->id_shop_list;
|
||||
}
|
||||
|
||||
$id_shop_list = array_map('intval', $id_shop_list);
|
||||
|
||||
Db::getInstance()->delete($this->def['table'].'_shop', '`'.$this->def['primary'].'`='.
|
||||
(int)$this->id.' AND id_shop IN ('. pSQL(implode(', ', $id_shop_list)).')');
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
148
modules/appagebuilder/classes/ApPageBuilderPositionsModel.php
Normal file
148
modules/appagebuilder/classes/ApPageBuilderPositionsModel.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/libs/Helper.php');
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/shortcodes.php');
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageSetting.php');
|
||||
|
||||
class ApPageBuilderPositionsModel extends ObjectModel
|
||||
{
|
||||
public $name;
|
||||
public $params;
|
||||
public $position;
|
||||
public $position_key;
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'appagebuilder_positions',
|
||||
'primary' => 'id_appagebuilder_positions',
|
||||
'multilang' => false,
|
||||
'multishop' => true,
|
||||
'fields' => array(
|
||||
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
'position' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
'position_key' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
'params' => array('type' => self::TYPE_HTML)
|
||||
)
|
||||
);
|
||||
|
||||
public function __construct($id = null, $id_lang = null, $id_shop = null, Context $context = null)
|
||||
{
|
||||
// validate module
|
||||
unset($context);
|
||||
parent::__construct($id, $id_lang, $id_shop);
|
||||
}
|
||||
|
||||
public static function getProfileUsingPosition($id)
|
||||
{
|
||||
$id = (int)$id;
|
||||
$sql = 'SELECT * FROM `'._DB_PREFIX_.'appagebuilder_profiles` P
|
||||
WHERE
|
||||
P.`header`='.(int)$id.'
|
||||
OR P.`content`='.(int)$id.'
|
||||
OR P.`footer`='.(int)$id.'
|
||||
OR P.`product`='.(int)$id;
|
||||
return Db::getInstance()->executes($sql);
|
||||
}
|
||||
|
||||
public function add($autodate = true, $null_values = false)
|
||||
{
|
||||
$id_shop = apPageHelper::getIDShop();
|
||||
$res = parent::add($autodate, $null_values);
|
||||
$res &= Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'appagebuilder_positions_shop` (`id_shop`, `id_appagebuilder_positions`)
|
||||
VALUES('.(int)$id_shop.', '.(int)$this->id.')');
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function addAuto($data)
|
||||
{
|
||||
$id_shop = apPageHelper::getIDShop();
|
||||
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'appagebuilder_positions` (name, position, position_key)
|
||||
VALUES("'.pSQL($data['name']).'", "'.pSQL($data['position']).'", "'.pSQL($data['position_key']).'")';
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
$id = Db::getInstance()->Insert_ID();
|
||||
|
||||
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'appagebuilder_positions_shop` (`id_shop`, `id_appagebuilder_positions`)
|
||||
VALUES('.(int)$id_shop.', '.(int)$id.')');
|
||||
return $id;
|
||||
}
|
||||
|
||||
public static function getAllPosition()
|
||||
{
|
||||
$sql = 'SELECT * FROM `'._DB_PREFIX_.'appagebuilder_positions`';
|
||||
return Db::getInstance()->getRow($sql);
|
||||
}
|
||||
|
||||
public static function getPositionById($id)
|
||||
{
|
||||
$sql = 'SELECT * FROM `'._DB_PREFIX_.'appagebuilder_positions` WHERE id_appagebuilder_positions='.(int)$id;
|
||||
return Db::getInstance()->getRow($sql);
|
||||
}
|
||||
|
||||
public static function updateName($id, $name)
|
||||
{
|
||||
$id = (int)$id;
|
||||
if ($id && $name) {
|
||||
$sql = 'UPDATE '._DB_PREFIX_.'appagebuilder_positions SET name=\''.pSQL($name).'\' WHERE id_appagebuilder_positions='.(int)$id;
|
||||
return Db::getInstance()->execute($sql);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$result = parent::delete();
|
||||
|
||||
if ($result) {
|
||||
if (isset($this->def['multishop']) && $this->def['multishop'] == true) {
|
||||
# DELETE RECORD FORM TABLE _SHOP
|
||||
$id_shop_list = Shop::getContextListShopID();
|
||||
if (count($this->id_shop_list)) {
|
||||
$id_shop_list = $this->id_shop_list;
|
||||
}
|
||||
|
||||
$id_shop_list = array_map('intval', $id_shop_list);
|
||||
|
||||
Db::getInstance()->delete($this->def['table'].'_shop', '`'.$this->def['primary'].'`='.
|
||||
(int)$this->id.' AND id_shop IN ('. pSQL(implode(', ', $id_shop_list)).')');
|
||||
}
|
||||
|
||||
# DELETE DATA AT OTHER TABLE
|
||||
$sql = 'SELECT id_appagebuilder FROM '._DB_PREFIX_.'appagebuilder WHERE id_appagebuilder_positions = ' . (int)$this->id;
|
||||
$rows = Db::getInstance()->executes($sql);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$obj = new ApPageBuilderModel($row['id_appagebuilder']);
|
||||
$obj->delete();
|
||||
}
|
||||
|
||||
# Profile not use this position
|
||||
if (in_array($this->position, array('header', 'content', 'footer', 'product'))) {
|
||||
$sql = 'UPDATE '._DB_PREFIX_.'appagebuilder_profiles SET `'.bqSQL($this->position).'`=0 WHERE `'.bqSQL($this->position).'`='.(int)$this->id;
|
||||
Db::getInstance()->execute($sql);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
182
modules/appagebuilder/classes/ApPageBuilderProductsModel.php
Normal file
182
modules/appagebuilder/classes/ApPageBuilderProductsModel.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/shortcodes.php');
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageSetting.php');
|
||||
|
||||
class ApPageBuilderProductsModel extends ObjectModel
|
||||
{
|
||||
public $name;
|
||||
public $params;
|
||||
public $type;
|
||||
public $active;
|
||||
public $plist_key;
|
||||
public $class;
|
||||
public $active_mobile;
|
||||
public $active_tablet;
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'appagebuilder_products',
|
||||
'primary' => 'id_appagebuilder_products',
|
||||
'multilang' => false,
|
||||
'multishop' => true,
|
||||
'fields' => array(
|
||||
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
'plist_key' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
'type' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'active' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
|
||||
'active_mobile' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
|
||||
'active_tablet' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
|
||||
'params' => array('type' => self::TYPE_HTML),
|
||||
'class' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
)
|
||||
);
|
||||
|
||||
public function getAllProductProfileByShop()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$id_shop = $context->shop->id;
|
||||
$where = ' WHERE id_shop='.(int)$id_shop;
|
||||
$sql = 'SELECT p.*, ps.*
|
||||
FROM '._DB_PREFIX_.'appagebuilder_products p
|
||||
INNER JOIN '._DB_PREFIX_.'appagebuilder_products_shop ps ON (ps.id_appagebuilder_products = p.id_appagebuilder_products)'
|
||||
.$where;
|
||||
return Db::getInstance()->executes($sql);
|
||||
}
|
||||
|
||||
public function __construct($id = null, $id_lang = null, $id_shop = null, Context $context = null)
|
||||
{
|
||||
// validate module
|
||||
unset($context);
|
||||
parent::__construct($id, $id_lang, $id_shop);
|
||||
}
|
||||
|
||||
public function add($autodate = true, $null_values = false)
|
||||
{
|
||||
$id_shop = apPageHelper::getIDShop();
|
||||
$res = parent::add($autodate, $null_values);
|
||||
$res &= Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'appagebuilder_products_shop` (`id_shop`, `id_appagebuilder_products`)
|
||||
VALUES('.(int)$id_shop.', '.(int)$this->id.')');
|
||||
if (Db::getInstance()->getValue('SELECT COUNT(p.`id_appagebuilder_products`) AS total FROM `'
|
||||
._DB_PREFIX_.'appagebuilder_products` p INNER JOIN `'
|
||||
._DB_PREFIX_.'appagebuilder_products_shop` ps ON(p.id_appagebuilder_products = ps.id_appagebuilder_products) WHERE id_shop='
|
||||
.(int)$id_shop) <= 1) {
|
||||
$this->deActiveAll();
|
||||
} else if ($this->active) {
|
||||
$this->deActiveAll();
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function toggleStatus()
|
||||
{
|
||||
$this->deActiveAll();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function deActiveAll()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$id_shop = $context->shop->id;
|
||||
$sql = 'UPDATE '._DB_PREFIX_.'appagebuilder_products_shop SET active=0 where id_shop='.(int)$id_shop;
|
||||
Db::getInstance()->execute($sql);
|
||||
$where = ' WHERE ps.id_shop='.(int)$id_shop." AND ps.id_appagebuilder_products = '".(int)$this->id."'";
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_products_shop` ps set ps.active = 1 '.$where);
|
||||
}
|
||||
|
||||
public function toggleStatusMT($field)
|
||||
{
|
||||
$id_shop = apPageHelper::getIDShop();
|
||||
$where = ' WHERE id_shop='.$id_shop." AND id_appagebuilder_products = '".(int)$this->id."'";
|
||||
$where1 = ' WHERE id_appagebuilder_products = "'.(int)$this->id.'"';
|
||||
$result = Db::getInstance()->getRow('SELECT '.$field.' from `'._DB_PREFIX_.'appagebuilder_products_shop` '.$where);
|
||||
$value = $result[$field]==1?0:1;
|
||||
|
||||
if ($value == 1) {
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_products_shop` set '.$field.' = "0" WHERE id_shop="'.$id_shop.'"');
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_products` set '.$field.' = "0";');
|
||||
}
|
||||
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_products_shop` set '.$field.' = "'.$value.'" '.$where);
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_products` set '.$field.' = "'.$value.'" '.$where1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getActive($use_mobile_theme = 0)
|
||||
{
|
||||
$id_shop = (int)Context::getContext()->shop->id;
|
||||
if (Tools::getIsset('plist_key') && Tools::getValue('plist_key')) {
|
||||
// validate module
|
||||
$where = " p.plist_key='".pSQL(Tools::getValue('plist_key'))."' and ps.id_shop=".(int)$id_shop;
|
||||
} else {
|
||||
// validate module
|
||||
$where = ' ps.active=1 and ps.id_shop='.(int)$id_shop;
|
||||
if ($use_mobile_theme) {
|
||||
if (Context::getContext()->isMobile()) {
|
||||
$where = ' ps.active_mobile=1 and ps.id_shop='.(int)$id_shop;
|
||||
}
|
||||
if (Context::getContext()->isTablet()) {
|
||||
$where = ' ps.active_tablet=1 and ps.id_shop='.(int)$id_shop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM '._DB_PREFIX_.'appagebuilder_products p
|
||||
INNER JOIN '._DB_PREFIX_.'appagebuilder_products_shop ps on(p.id_appagebuilder_products = ps.id_appagebuilder_products) WHERE '.$where;
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
|
||||
if ($use_mobile_theme) {
|
||||
if (!$result && Context::getContext()->isMobile() && Context::getContext()->isTablet()) {
|
||||
$where = ' ps.active=1 and ps.id_shop='.(int)$id_shop;
|
||||
$sql = 'SELECT * FROM '._DB_PREFIX_.'appagebuilder_products p
|
||||
INNER JOIN '._DB_PREFIX_.'appagebuilder_products_shop ps on(p.id_appagebuilder_products = ps.id_appagebuilder_products) WHERE '.$where;
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$result = parent::delete();
|
||||
|
||||
if ($result) {
|
||||
if (isset($this->def['multishop']) && $this->def['multishop'] == true) {
|
||||
# DELETE RECORD FORM TABLE _SHOP
|
||||
$id_shop_list = Shop::getContextListShopID();
|
||||
if (count($this->id_shop_list)) {
|
||||
$id_shop_list = $this->id_shop_list;
|
||||
}
|
||||
|
||||
$id_shop_list = array_map('intval', $id_shop_list);
|
||||
|
||||
Db::getInstance()->delete($this->def['table'].'_shop', '`'.$this->def['primary'].'`='.
|
||||
(int)$this->id.' AND id_shop IN ('.pSQL(implode(', ', $id_shop_list)).')');
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
523
modules/appagebuilder/classes/ApPageBuilderProfilesModel.php
Normal file
523
modules/appagebuilder/classes/ApPageBuilderProfilesModel.php
Normal file
@@ -0,0 +1,523 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/shortcodes.php');
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageSetting.php');
|
||||
|
||||
class ApPageBuilderProfilesModel extends ObjectModel
|
||||
{
|
||||
public $name;
|
||||
public $friendly_url;
|
||||
public $meta_title;
|
||||
public $meta_description;
|
||||
public $meta_keywords;
|
||||
public $group_box;
|
||||
public $params;
|
||||
public $page;
|
||||
public $profile_key;
|
||||
public $header;
|
||||
public $content;
|
||||
public $footer;
|
||||
public $product;
|
||||
public $active;
|
||||
public $active_mobile;
|
||||
public $active_tablet;
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'appagebuilder_profiles',
|
||||
'primary' => 'id_appagebuilder_profiles',
|
||||
'multilang' => true,
|
||||
'multishop' => true,
|
||||
'fields' => array(
|
||||
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
'friendly_url' => array('type' => self::TYPE_STRING, 'size' => 255, 'lang' => true, 'validate' => 'isLinkRewrite'),
|
||||
'meta_title' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255, 'lang' => true),
|
||||
'meta_description' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255, 'lang' => true),
|
||||
'meta_keywords' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255, 'lang' => true),
|
||||
'group_box' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
'page' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
'profile_key' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
'header' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'content' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'footer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'active' => array('type' => self::TYPE_BOOL, 'shop' => true),
|
||||
'active_mobile' => array('type' => self::TYPE_BOOL, 'shop' => true),
|
||||
'active_tablet' => array('type' => self::TYPE_BOOL, 'shop' => true),
|
||||
'params' => array('type' => self::TYPE_HTML)
|
||||
)
|
||||
);
|
||||
|
||||
public function loadDataShop()
|
||||
{
|
||||
if ($this->def['multishop'] == true) {
|
||||
$sql = 'SELECT * FROM ' ._DB_PREFIX_.$this->def['table'] . '_shop WHERE ' .$this->def['primary'] . ' =' .(int)$this->id;
|
||||
$this->data_shop = Db::getInstance()->getRow($sql);
|
||||
|
||||
if (isset($this->data_shop['active'])) {
|
||||
$this->active = $this->data_shop['active'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function toggleStatus()
|
||||
{
|
||||
$this->deActiveAll($this->page);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function deActiveAll($page)
|
||||
{
|
||||
// validate module
|
||||
unset($page);
|
||||
$id_shop = apPageHelper::getIDShop();
|
||||
//$where = ' WHERE ps.id_shop='.$id_shop." AND ps.id_appagebuilder_profiles != '".(int)$this->id."'";
|
||||
$where = ' WHERE ps.id_shop='.(int)$id_shop;
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_profiles_shop` ps set ps.active = 0 '.$where);
|
||||
$where = ' WHERE ps.id_shop='.$id_shop." AND ps.id_appagebuilder_profiles = '".(int)$this->id."'";
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_profiles_shop` ps set ps.active = 1 '.$where);
|
||||
}
|
||||
|
||||
public function toggleStatusMT($field)
|
||||
{
|
||||
$id_shop = apPageHelper::getIDShop();
|
||||
$where = ' WHERE id_shop='.$id_shop.' AND id_appagebuilder_profiles = "'.(int)$this->id.'"';
|
||||
$where1 = ' WHERE id_appagebuilder_profiles = "'.(int)$this->id.'"';
|
||||
$result = Db::getInstance()->getRow('SELECT '.$field.' from `'._DB_PREFIX_.'appagebuilder_profiles_shop` '.$where);
|
||||
$value = $result[$field]==1?0:1;
|
||||
|
||||
if ($value == 1) {
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_profiles_shop` set '.$field.' = "0" WHERE id_shop="'.$id_shop.'"');
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_profiles` set '.$field.' = "0"');
|
||||
}
|
||||
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_profiles_shop` set '.$field.' = "'.$value.'" '.$where);
|
||||
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'appagebuilder_profiles` set '.$field.' = "'.$value.'" '.$where1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getAllProfileByShop()
|
||||
{
|
||||
try {
|
||||
$context = Context::getContext();
|
||||
$id_shop = $context->shop->id;
|
||||
$id_lang = $context->language->id;
|
||||
|
||||
$cacheId = 'appagebuilder::getAllProfileByShop_' . md5(
|
||||
(int) $id_shop .
|
||||
(int) $id_lang
|
||||
);
|
||||
|
||||
if (!Cache::isStored($cacheId)) {
|
||||
$sql = 'SELECT p.*, ps.*,pl.*
|
||||
FROM '._DB_PREFIX_.'appagebuilder_profiles p
|
||||
INNER JOIN '._DB_PREFIX_.'appagebuilder_profiles_lang pl ON (p.id_appagebuilder_profiles = pl.id_appagebuilder_profiles)
|
||||
INNER JOIN '._DB_PREFIX_.'appagebuilder_profiles_shop ps ON (ps.id_appagebuilder_profiles = p.id_appagebuilder_profiles)
|
||||
WHERE id_shop='.(int)$id_shop.' AND id_lang='.(int)$id_lang;
|
||||
$result = Db::getInstance()->executes($sql);
|
||||
Cache::store($cacheId, $result);
|
||||
} else {
|
||||
$result = Cache::retrieve($cacheId);
|
||||
}
|
||||
return $result;
|
||||
} catch (Exception $exc) {
|
||||
return array(); // OLD MODULE, NOT NEED SHOW DATA
|
||||
}
|
||||
}
|
||||
|
||||
public function add($autodate = true, $null_values = false)
|
||||
{
|
||||
$id_shop = apPageHelper::getIDShop();
|
||||
$res = parent::add($autodate, $null_values);
|
||||
$res &= Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'appagebuilder_profiles_shop` (`id_shop`, `id_appagebuilder_profiles`)
|
||||
VALUES('.(int)$id_shop.', '.(int)$this->id.')');
|
||||
if (Db::getInstance()->getValue('SELECT COUNT(p.`id_appagebuilder_profiles`) AS total FROM `'._DB_PREFIX_.'appagebuilder_profiles` p
|
||||
INNER JOIN `'._DB_PREFIX_.'appagebuilder_profiles_shop` ps ON(p.id_appagebuilder_profiles = ps.id_appagebuilder_profiles)
|
||||
WHERE id_shop='.(int)$id_shop) <= 1) {
|
||||
$this->deActiveAll($this->page);
|
||||
} else if ($this->active) {
|
||||
$this->deActiveAll($this->page);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function update($null_values = false)
|
||||
{
|
||||
// validate module
|
||||
unset($null_values);
|
||||
if ($this->active) {
|
||||
$this->deActiveAll($this->page);
|
||||
}
|
||||
|
||||
return parent::update();
|
||||
}
|
||||
|
||||
public function getProfilesInPage($id = 0)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$id_shop = $context->shop->id;
|
||||
$where = ' WHERE ps.id_shop='.(int)$id_shop." AND p.page='".pSQL($this->page)."'";
|
||||
if ($id) {
|
||||
$where .= ' AND p.id_appagebuilder_profiles !='.(int)$id;
|
||||
}
|
||||
$inner_join = 'INNER JOIN `'._DB_PREFIX_.'appagebuilder_profiles_shop` ps ON (ps.id_appagebuilder_profiles = p.id_appagebuilder_profiles)';
|
||||
$sql = 'SELECT p.* from `'._DB_PREFIX_.'appagebuilder_profiles` p '.$inner_join.$where;
|
||||
return Db::getInstance()->executes($sql);
|
||||
}
|
||||
|
||||
public function getProfileById($all_profile, $id_profile)
|
||||
{
|
||||
foreach ($all_profile as $profile) {
|
||||
if ($profile['id_appagebuilder_profiles'] == $id_profile) {
|
||||
return $profile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getActiveProfile($page, $all_profile = array(), $use_mobile_theme = 0)
|
||||
{
|
||||
// validate module
|
||||
unset($page);
|
||||
|
||||
# Fix bug http://screencast.com/t/flCEjya6
|
||||
$updatePositions = Tools::getValue('action');
|
||||
$ajax = Tools::getValue('ajax');
|
||||
|
||||
if ($updatePositions == 'updatePositions' && $ajax == '1') {
|
||||
return null;
|
||||
}
|
||||
$result = array();
|
||||
|
||||
$context = Context::getContext();
|
||||
$is_use_co = Configuration::get('APPAGEBUILDER_COOKIE_PROFILE');
|
||||
//not apply for mobile view
|
||||
if ($context->isMobile()) {
|
||||
$is_use_co = 0;
|
||||
}
|
||||
|
||||
# ACCESS BY id_appagebuilder_profiles
|
||||
if (Tools::getIsset('id_appagebuilder_profiles') && Tools::getValue('id_appagebuilder_profiles')) {
|
||||
$id_profile = Tools::getValue('id_appagebuilder_profiles');
|
||||
foreach ($all_profile as $profile) {
|
||||
if ($profile['id_appagebuilder_profiles'] == $id_profile) {
|
||||
$result = $profile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# ACCESS BY friendly_url
|
||||
$linkRewrive = explode('/', $_SERVER['REQUEST_URI']);
|
||||
$linkRewrive = rtrim(end($linkRewrive), '.html');
|
||||
if (strpos($linkRewrive, '?')) {
|
||||
// REMOVE ? FROM URL
|
||||
$temp_str = explode("?", $linkRewrive);
|
||||
$linkRewrive = $temp_str[0];
|
||||
$linkRewrive = rtrim($linkRewrive, '.html');
|
||||
}
|
||||
if (!empty($linkRewrive)) {
|
||||
foreach ($all_profile as $profile) {
|
||||
if ($profile['friendly_url'] == $linkRewrive) {
|
||||
$result = $profile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//no 1: from cookie
|
||||
if ($is_use_co && $context->cookie->ap_profile) {
|
||||
foreach ($all_profile as $profile) {
|
||||
if ($profile['id_appagebuilder_profiles'] == $context->cookie->ap_profile) {
|
||||
$result = $profile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//no 2: from config in profile by group
|
||||
if (!$result) {
|
||||
# SET PROFILE FOLLOW GROUP_CUSTOMER
|
||||
$current_group_id = Group::getCurrent()->id;
|
||||
if (isset($current_group_id) && $current_group_id == 3) {
|
||||
$customer = Context::getContext()->customer;
|
||||
$sql = 'SELECT id_group FROM `'._DB_PREFIX_.'customer_group` WHERE id_customer='.(int)$customer->id;
|
||||
$array_group_id = Db::getInstance()->executeS($sql);
|
||||
foreach ($array_group_id as $group_id) {
|
||||
if ($group_id !=1 && $group_id !=2 && $group_id !=3) {
|
||||
$current_group_id = $group_id['id_group'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($all_profile as $profile) {
|
||||
$group_boxs = $profile['group_box'];
|
||||
$aray_group_box = explode(',', $group_boxs);
|
||||
foreach ($aray_group_box as $group_box) {
|
||||
if (isset($current_group_id) && $current_group_id == $group_box) {
|
||||
$result = $profile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//no 3 get from active profile and for mobile
|
||||
if (!$result) {
|
||||
$desktop = array();
|
||||
foreach ($all_profile as $profile) {
|
||||
if ($use_mobile_theme && $context->isMobile()) {
|
||||
if ($profile['active_mobile'] == 1) {
|
||||
$result = $profile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($use_mobile_theme && $context->isTablet()) {
|
||||
if ($profile['active_tablet'] == 1) {
|
||||
$result = $profile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($profile['active'] == 1) {
|
||||
$desktop = $profile;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$result) {
|
||||
$result = $desktop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_use_co) {
|
||||
$context->cookie->ap_profile = $result['id_appagebuilder_profiles'];
|
||||
}
|
||||
|
||||
//pass header in url
|
||||
foreach (array('header', 'content', 'footer', 'product') as $val) {
|
||||
$pos_key = 'ap_'.$val;
|
||||
if (Tools::getIsset($val)) {
|
||||
$result[$val] = Tools::getValue($val);
|
||||
|
||||
if (Tools::isSubmit('controller') && Tools::getValue('controller') === 'AdminNewsletterPro') {
|
||||
// Conflict with Newsletter Pro module
|
||||
} else {
|
||||
$context->cookie->{$pos_key} = $result[$val];
|
||||
}
|
||||
} else if ($is_use_co && $context->cookie->{$pos_key}) {
|
||||
$result[$val] = $context->cookie->{$pos_key};
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getProfile($id)
|
||||
{
|
||||
$sql = 'SELECT * FROM `'._DB_PREFIX_.'appagebuilder_profiles` WHERE id_appagebuilder_profiles='.(int)$id;
|
||||
$object = Db::getInstance()->getRow($sql);
|
||||
return $object ? $object : null;
|
||||
}
|
||||
|
||||
public function duplicateProfile($id, $name, $profile_key, $id_shop)
|
||||
{
|
||||
$new_id = 0;
|
||||
$sql = 'SELECT * FROM `'._DB_PREFIX_.'appagebuilder_profiles` WHERE id_appagebuilder_profiles='.(int)$id;
|
||||
$object_duplicated = Db::getInstance()->getRow($sql);
|
||||
if ($object_duplicated) {
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'appagebuilder_profiles`(name, profile_key, page) VALUES("'
|
||||
.pSQL($name).pSQL($object_duplicated['name']).'", "'.pSQL($profile_key).'", "index")';
|
||||
Db::getInstance()->execute($sql);
|
||||
$new_id = Db::getInstance()->Insert_ID();
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'appagebuilder_profiles_shop`(id_appagebuilder_profiles, id_shop, active) VALUES('
|
||||
.(int)$new_id.', '.(int)$id_shop.', 0)';
|
||||
Db::getInstance()->execute($sql);
|
||||
return $new_id;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function customDuplicateObject($message)
|
||||
{
|
||||
$object_duplicated = parent::duplicateObject();
|
||||
$object_duplicated->active = 0;
|
||||
$object_duplicated->name = $message.' '.$object_duplicated->name;
|
||||
return $object_duplicated;
|
||||
}
|
||||
|
||||
public function save($null_values = false, $autodate = true)
|
||||
{
|
||||
// validate module
|
||||
unset($null_values);
|
||||
unset($autodate);
|
||||
$context = Context::getContext();
|
||||
$this->id_shop = $context->shop->id;
|
||||
if ($this->active) {
|
||||
$this->deActiveAll($this->page);
|
||||
}
|
||||
|
||||
return parent::save();
|
||||
}
|
||||
|
||||
public static function deleteById($id)
|
||||
{
|
||||
$id = (int)$id;
|
||||
$sql = 'SELECT * FROM `'._DB_PREFIX_.'appagebuilder_profiles` WHERE id_appagebuilder_profiles='.(int)$id;
|
||||
$object_duplicated = Db::getInstance()->getRow($sql);
|
||||
if ($object_duplicated) {
|
||||
$sql = 'DELETE FROM `'._DB_PREFIX_.'appagebuilder_profiles` WHERE id_appagebuilder_profiles='.(int)$id;
|
||||
Db::getInstance()->execute($sql);
|
||||
$sql = 'DELETE FROM `'._DB_PREFIX_.'appagebuilder_profiles_lang` WHERE id_appagebuilder_profiles='.(int)$id;
|
||||
Db::getInstance()->execute($sql);
|
||||
$sql = 'DELETE FROM `'._DB_PREFIX_.'appagebuilder_profiles_shop` WHERE id_appagebuilder_profiles='.(int)$id;
|
||||
Db::getInstance()->execute($sql);
|
||||
return $object_duplicated;
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getPositionsForProfile($id_positions)
|
||||
{
|
||||
if ($id_positions) {
|
||||
$id_positions = implode(',', array_map('intval', $id_positions));
|
||||
$sql = 'SELECT * FROM `'._DB_PREFIX_.'appagebuilder_positions` WHERE id_appagebuilder_positions IN('.pSQL($id_positions).')';
|
||||
return Db::getInstance()->executes($sql);
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
public function delete($params = array())
|
||||
{
|
||||
$result = parent::delete();
|
||||
|
||||
if ($result) {
|
||||
if (isset($this->def['multishop']) && $this->def['multishop'] == true) {
|
||||
# DELETE RECORD FORM TABLE _SHOP
|
||||
$id_shop_list = Shop::getContextListShopID();
|
||||
if (count($this->id_shop_list)) {
|
||||
$id_shop_list = $this->id_shop_list;
|
||||
}
|
||||
|
||||
$id_shop_list = array_map('intval', $id_shop_list);
|
||||
|
||||
Db::getInstance()->delete($this->def['table'].'_shop', '`'.$this->def['primary'].'`='.
|
||||
(int)$this->id.' AND id_shop IN ('.pSQL(implode(', ', $id_shop_list)).')');
|
||||
|
||||
if (isset($params['import_sample']) && $params['import_sample'] == true) {
|
||||
$position = new ApPageBuilderPositionsModel((int)$this->header);
|
||||
$position->delete();
|
||||
$position = new ApPageBuilderPositionsModel((int)$this->content);
|
||||
$position->delete();
|
||||
$position = new ApPageBuilderPositionsModel((int)$this->footer);
|
||||
$position->delete();
|
||||
$position = new ApPageBuilderPositionsModel((int)$this->product);
|
||||
$position->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* $id_profile = ApPageBuilderProfilesModel::getIdProfileFromRewrite();
|
||||
*/
|
||||
public static function getIdProfileFromRewrite($linkRewrive = '')
|
||||
{
|
||||
static $id_appagebuilder_profiles = null;
|
||||
|
||||
if ($id_appagebuilder_profiles === null) {
|
||||
$context = Context::getContext();
|
||||
$id_shop = (int)$context->shop->id;
|
||||
$id_lang = (int)$context->language->id;
|
||||
|
||||
# ACCESS BY id_appagebuilder_profiles
|
||||
$id_temp = Tools::getIsset('id_appagebuilder_profiles') ? Tools::getValue('id_appagebuilder_profiles') : false;
|
||||
if ($id_temp !== false) {
|
||||
$id_appagebuilder_profiles = $id_temp;
|
||||
return $id_appagebuilder_profiles;
|
||||
}
|
||||
|
||||
# ACCESS BY friendly_url
|
||||
$linkRewrive = explode('/', $_SERVER['REQUEST_URI']);
|
||||
$linkRewrive = rtrim(end($linkRewrive), '.html');
|
||||
if (strpos($linkRewrive, '?')) {
|
||||
// REMOVE ? FROM URL
|
||||
$temp_str = explode("?", $linkRewrive);
|
||||
$linkRewrive = $temp_str[0];
|
||||
$linkRewrive = rtrim($linkRewrive, '.html');
|
||||
}
|
||||
if (!empty($linkRewrive)) {
|
||||
$sql = 'SELECT p.`id_appagebuilder_profiles` FROM `'._DB_PREFIX_.'appagebuilder_profiles` p';
|
||||
$sql .= ' INNER JOIN `'._DB_PREFIX_.'appagebuilder_profiles_lang` pl ON(pl.id_appagebuilder_profiles = p.id_appagebuilder_profiles AND pl.friendly_url=\''.pSQL($linkRewrive).'\' AND id_lang='.(int)$id_lang.' ) ';
|
||||
$sql .= ' INNER JOIN `'._DB_PREFIX_.'appagebuilder_profiles_shop` ps ON(ps.id_appagebuilder_profiles = p.id_appagebuilder_profiles AND ps.id_shop ='.(int)$id_shop.')';
|
||||
|
||||
$id_appagebuilder_profiles = Db::getInstance()->getValue($sql);
|
||||
return $id_appagebuilder_profiles;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# ACESS BY active_profile
|
||||
$where = ' WHERE ps.id_shop='.(int)$id_shop.' AND ps.active=1 ';
|
||||
|
||||
$inner_join = ' INNER JOIN `'._DB_PREFIX_.'appagebuilder_profiles_lang` pl ON (pl.id_appagebuilder_profiles = p.id_appagebuilder_profiles) AND id_lang='.(int)$id_lang;
|
||||
$inner_join .= ' INNER JOIN `'._DB_PREFIX_.'appagebuilder_profiles_shop` ps ON (ps.id_appagebuilder_profiles = p.id_appagebuilder_profiles)';
|
||||
$sql = 'SELECT p.id_appagebuilder_profiles, p.name, p.profile_key, pl.id_lang, ps.id_shop, ps.active from `'._DB_PREFIX_.'appagebuilder_profiles` p '.$inner_join.$where;
|
||||
|
||||
$active_profile = Db::getInstance()->getRow($sql);
|
||||
|
||||
if ($active_profile) {
|
||||
return $active_profile['id_appagebuilder_profiles'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return $id_appagebuilder_profiles;
|
||||
}
|
||||
|
||||
public static function getAllProfileRewrite($id_profile = null)
|
||||
{
|
||||
if ($id_profile) {
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
|
||||
if ($id_profile) {
|
||||
$where = ' WHERE ps.id_shop='.(int)$id_shop.' AND p.id_appagebuilder_profiles='.(int)$id_profile;
|
||||
}
|
||||
|
||||
$inner_join = ' INNER JOIN `'._DB_PREFIX_.'appagebuilder_profiles_lang` pl ON (pl.id_appagebuilder_profiles = p.id_appagebuilder_profiles)';
|
||||
$inner_join .= ' INNER JOIN `'._DB_PREFIX_.'appagebuilder_profiles_shop` ps ON (ps.id_appagebuilder_profiles = p.id_appagebuilder_profiles)';
|
||||
$sql = 'SELECT p.id_appagebuilder_profiles, p.name, pl.id_lang, pl.friendly_url from `'._DB_PREFIX_.'appagebuilder_profiles` p '.$inner_join.$where;
|
||||
$result = Db::getInstance()->executeS($sql);
|
||||
|
||||
foreach ($result as $key => $value) {
|
||||
$result[$key]['iso_code'] = Language::getIsoById($result[$key]['id_lang']);
|
||||
}
|
||||
// validate module
|
||||
unset($value);
|
||||
|
||||
return $result;
|
||||
}
|
||||
return array();
|
||||
}
|
||||
}
|
||||
266
modules/appagebuilder/classes/ApPageBuilderShortcodeModel.php
Normal file
266
modules/appagebuilder/classes/ApPageBuilderShortcodeModel.php
Normal file
@@ -0,0 +1,266 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageSetting.php');
|
||||
|
||||
class ApPageBuilderShortcodeModel extends ObjectModel
|
||||
{
|
||||
public $shortcode_key;
|
||||
// public $id_appagebuilder;
|
||||
public $shortcode_name;
|
||||
public $active = true;
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'appagebuilder_shortcode',
|
||||
'primary' => 'id_appagebuilder_shortcode',
|
||||
'multilang' => true,
|
||||
'multishop' => true,
|
||||
'fields' => array(
|
||||
'shortcode_key' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255),
|
||||
// 'id_appagebuilder' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
|
||||
'shortcode_name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 255, 'lang' => true, 'required' => true),
|
||||
|
||||
'active' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
|
||||
)
|
||||
);
|
||||
|
||||
public function __construct($id = null, $id_lang = null, $id_shop = null, Context $context = null)
|
||||
{
|
||||
// validate module
|
||||
unset($context);
|
||||
parent::__construct($id, $id_lang, $id_shop);
|
||||
}
|
||||
|
||||
public function add($autodate = true, $null_values = false)
|
||||
{
|
||||
$id_shop = apPageHelper::getIDShop();
|
||||
$res = parent::add($autodate, $null_values);
|
||||
|
||||
$res &= Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'appagebuilder_shortcode_shop` (`id_shop`, `id_appagebuilder_shortcode`, `active`)
|
||||
VALUES('.(int)$id_shop.', '.(int)$this->id.', '.(int)$this->active.')');
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function update($nullValues = false)
|
||||
{
|
||||
$id_shop = apPageHelper::getIDShop();
|
||||
$res = parent::update($nullValues);
|
||||
|
||||
$res &= Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'appagebuilder_shortcode_shop` ps set ps.active = '.(int)$this->active.' WHERE ps.id_shop='.(int)$id_shop.' AND ps.id_appagebuilder_shortcode = '.(int)$this->id);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$result = parent::delete();
|
||||
|
||||
if ($result) {
|
||||
if (isset($this->def['multishop']) && $this->def['multishop'] == true) {
|
||||
# DELETE RECORD FORM TABLE _SHOP
|
||||
$id_shop_list = Shop::getContextListShopID();
|
||||
if (count($this->id_shop_list)) {
|
||||
$id_shop_list = $this->id_shop_list;
|
||||
}
|
||||
|
||||
$id_shop_list = array_map('intval', $id_shop_list);
|
||||
|
||||
Db::getInstance()->delete($this->def['table'].'_shop', '`'.$this->def['primary'].'`='.
|
||||
(int)$this->id.' AND id_shop IN ('.pSQL(implode(', ', $id_shop_list)).')');
|
||||
}
|
||||
|
||||
//DONGND:: delete appagebuilder related shortcode
|
||||
$id_appagebuilder = ApPageBuilderModel::getIdByIdShortCode((int)$this->id);
|
||||
|
||||
if ($id_appagebuilder) {
|
||||
$obj = new ApPageBuilderModel($id_appagebuilder);
|
||||
$obj->delete();
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getShortCodeContent($id_appagebuilder = 0, $is_font = 0, $id_lang = 0)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$id_shop = (int)$context->shop->id;
|
||||
$where = ' WHERE ps.id_shop='.(int)$id_shop.' AND p.id_appagebuilder='.(int)$id_appagebuilder;
|
||||
|
||||
if ($id_lang) {
|
||||
$where .= ' AND pl.id_lang = '.(int)$id_lang;
|
||||
} else {
|
||||
$id_lang = $context->language->id;
|
||||
}
|
||||
$sql = 'SELECT p.*, pl.params, pl.id_lang
|
||||
FROM `'._DB_PREFIX_.'appagebuilder` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'appagebuilder_shop` ps ON (ps.id_appagebuilder = p.id_appagebuilder)
|
||||
LEFT JOIN `'._DB_PREFIX_.'appagebuilder_lang` pl ON (pl.id_appagebuilder = p.id_appagebuilder)
|
||||
LEFT JOIN `'._DB_PREFIX_.'appagebuilder_shortcode` pp ON (p.id_appagebuilder_shortcode = pp.id_appagebuilder_shortcode)
|
||||
|
||||
'.pSql($where).' ORDER BY p.id_appagebuilder';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
// # FIX - Only get language data valid
|
||||
// $id_langs = Language::getLanguages(true, false, true);
|
||||
// foreach ($result as $key => $val) {
|
||||
// if (isset($val['id_lang']) && !in_array($val['id_lang'], $id_langs)) {
|
||||
// unset($result[$key]);
|
||||
// }
|
||||
// }
|
||||
|
||||
$data_lang = array();
|
||||
if ($is_font) {
|
||||
foreach ($result as $row) {
|
||||
$data_lang[$row['hook_name']] = $row['params'];
|
||||
}
|
||||
return $data_lang;
|
||||
}
|
||||
$ap_helper = new ApShortCodesBuilder();
|
||||
ApShortCodesBuilder::$is_front_office = $is_font;
|
||||
ApShortCodesBuilder::$is_gen_html = 1;
|
||||
foreach ($result as $row) {
|
||||
if (isset($data_lang[$row['id_appagebuilder']])) {
|
||||
$data_lang[$row['id_appagebuilder']]['params'][$row['id_lang']] = $row['params'];
|
||||
} else {
|
||||
$data_lang[$row['id_appagebuilder']] = array(
|
||||
'id' => $row['id_appagebuilder'],
|
||||
'hook_name' => $row['hook_name'],
|
||||
);
|
||||
$data_lang[$row['id_appagebuilder']]['params'][$row['id_lang']] = $row['params'];
|
||||
}
|
||||
}
|
||||
$data_hook = array();
|
||||
foreach ($data_lang as $row) {
|
||||
//process params
|
||||
foreach ($row['params'] as $key => $value) {
|
||||
ApShortCodesBuilder::$lang_id = $key;
|
||||
if ($key == $id_lang) {
|
||||
ApShortCodesBuilder::$is_gen_html = 1;
|
||||
$row['content'] = $ap_helper->parse($value);
|
||||
} else {
|
||||
ApShortCodesBuilder::$is_gen_html = 0;
|
||||
$ap_helper->parse($value);
|
||||
}
|
||||
}
|
||||
$data_hook[$row['hook_name']] = $row;
|
||||
}
|
||||
|
||||
return array('content' => $data_hook, 'dataForm' => ApShortCodesBuilder::$data_form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all items - datas of all hooks by shop Id, lang Id for front-end or back-end
|
||||
* @param type $id_profiles
|
||||
* @param type $is_font (=0: for back-end; =1: for front-end)
|
||||
* @param type $id_lang
|
||||
* @return type
|
||||
*/
|
||||
public static function getAllItems($id_appagebuilder, $is_font = 0, $id_lang = 0)
|
||||
{
|
||||
//print_r("Input: $id_profiles - $is_font - $id_lang"); 2-1-1
|
||||
$context = Context::getContext();
|
||||
// $id_profiles = (int)$profile['id_appagebuilder_profiles'];
|
||||
$id_shop = (int)$context->shop->id;
|
||||
$id_lang = $id_lang ? (int)$id_lang : (int)$context->language->id;
|
||||
|
||||
$sql = 'SELECT p.*, pl.params, pl.id_lang
|
||||
FROM '._DB_PREFIX_.'appagebuilder p
|
||||
LEFT JOIN '._DB_PREFIX_.'appagebuilder_shop ps ON (ps.id_appagebuilder = p.id_appagebuilder AND id_shop='.(int)$id_shop.')
|
||||
LEFT JOIN '._DB_PREFIX_.'appagebuilder_lang pl ON (pl.id_appagebuilder = p.id_appagebuilder)
|
||||
LEFT JOIN `'._DB_PREFIX_.'appagebuilder_shortcode` pp ON (p.id_appagebuilder_shortcode = pp.id_appagebuilder_shortcode)
|
||||
WHERE
|
||||
pl.id_lang='.(int)$id_lang.'
|
||||
AND ps.id_shop='.(int)$id_shop.'
|
||||
AND p.id_appagebuilder = '.(int)$id_appagebuilder.'
|
||||
ORDER BY p.id_appagebuilder';
|
||||
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
//echo '<pre>';print_r($result);die;
|
||||
$data_lang = array();
|
||||
if ($is_font) {
|
||||
foreach ($result as $row) {
|
||||
$data_lang[$row['hook_name']] = $row['params'];
|
||||
}
|
||||
return $data_lang;
|
||||
}
|
||||
$ap_helper = new ApShortCodesBuilder();
|
||||
ApShortCodesBuilder::$is_front_office = $is_font;
|
||||
ApShortCodesBuilder::$is_gen_html = 1;
|
||||
foreach ($result as $row) {
|
||||
if (isset($data_lang[$row['id_appagebuilder']])) {
|
||||
$data_lang[$row['id_appagebuilder']]['params'][$row['id_lang']] = $row['params'];
|
||||
} else {
|
||||
$data_lang[$row['id_appagebuilder']] = array(
|
||||
'id' => $row['id_appagebuilder'],
|
||||
'hook_name' => $row['hook_name'],
|
||||
);
|
||||
$data_lang[$row['id_appagebuilder']]['params'][$row['id_lang']] = $row['params'];
|
||||
}
|
||||
}
|
||||
$data_hook = array_flip(ApPageSetting::getHookHome());
|
||||
foreach ($data_lang as $row) {
|
||||
//process params
|
||||
foreach ($row['params'] as $key => $value) {
|
||||
ApShortCodesBuilder::$lang_id = $key;
|
||||
if ($key == $id_lang) {
|
||||
ApShortCodesBuilder::$is_gen_html = 1;
|
||||
$row['content'] = $ap_helper->parse($value);
|
||||
} else {
|
||||
ApShortCodesBuilder::$is_gen_html = 0;
|
||||
$ap_helper->parse($value);
|
||||
}
|
||||
}
|
||||
$data_hook[$row['hook_name']] = $row;
|
||||
}
|
||||
|
||||
return array('content' => $data_hook, 'dataForm' => ApShortCodesBuilder::$data_form);
|
||||
}
|
||||
|
||||
public static function getShortCode($shortcode_key)
|
||||
{
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
|
||||
$sql = 'SELECT p.*, pp.`id_appagebuilder` FROM `'._DB_PREFIX_.'appagebuilder_shortcode` p
|
||||
INNER JOIN `'._DB_PREFIX_.'appagebuilder_shortcode_shop` ps on(p.`id_appagebuilder_shortcode` = ps.`id_appagebuilder_shortcode`)
|
||||
INNER JOIN `'._DB_PREFIX_.'appagebuilder` pp on(p.`id_appagebuilder_shortcode` = pp.`id_appagebuilder_shortcode`) WHERE
|
||||
p.`shortcode_key` = "'.pSQL($shortcode_key).'" AND ps.`active`= 1 AND ps.`id_shop` = '.(int)$id_shop;
|
||||
|
||||
return Db::getInstance()->getRow($sql);
|
||||
}
|
||||
|
||||
public static function getListShortCode()
|
||||
{
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
$sql = 'SELECT p.*, ps.*, pl.* FROM `'._DB_PREFIX_.'appagebuilder_shortcode` p
|
||||
INNER JOIN `'._DB_PREFIX_.'appagebuilder_shortcode_shop` ps on(p.`id_appagebuilder_shortcode` = ps.`id_appagebuilder_shortcode`)
|
||||
INNER JOIN `'._DB_PREFIX_.'appagebuilder_shortcode_lang` pl on(p.`id_appagebuilder_shortcode` = pl.`id_appagebuilder_shortcode`) WHERE
|
||||
ps.`id_shop` = '.(int)$id_shop.' AND pl.`id_lang` = '.(int)$id_lang;
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
}
|
||||
}
|
||||
1405
modules/appagebuilder/classes/ApPageSetting.php
Normal file
1405
modules/appagebuilder/classes/ApPageSetting.php
Normal file
File diff suppressed because it is too large
Load Diff
370
modules/appagebuilder/classes/ApShortCodesBuilder.php
Normal file
370
modules/appagebuilder/classes/ApShortCodesBuilder.php
Normal file
@@ -0,0 +1,370 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!class_exists('ApShortCodeBase')) {
|
||||
|
||||
class ApShortCodesBuilder
|
||||
{
|
||||
public static $shortcode_tags = array();
|
||||
public static $lang_id = 0;
|
||||
public static $is_front_office = 1;
|
||||
public static $is_gen_html = 1;
|
||||
public static $data_form = array();
|
||||
public static $shortcode_lang;
|
||||
public static $hook_name;
|
||||
public static $profile_param;
|
||||
|
||||
public static function addShortcode($tag, $func)
|
||||
{
|
||||
self::$shortcode_tags[$tag] = $func;
|
||||
}
|
||||
|
||||
public static function removeShortcode($tag)
|
||||
{
|
||||
unset(self::$shortcode_tags[$tag]);
|
||||
}
|
||||
|
||||
public static function shortcodeExists($tag)
|
||||
{
|
||||
return array_key_exists($tag, self::$shortcode_tags);
|
||||
}
|
||||
|
||||
public static function doShortcode($content)
|
||||
{
|
||||
if (false === strpos($content, '[')) {
|
||||
return $content;
|
||||
}
|
||||
$pattern = self::getShortcodeRegex();
|
||||
return preg_replace_callback("/$pattern/s", array(new ApShortCodesBuilder, 'doShortcodeTag'), $content);
|
||||
}
|
||||
|
||||
public static function getShortcodeRegex()
|
||||
{
|
||||
$tagnames = array_keys(self::$shortcode_tags);
|
||||
$tagregexp = join('|', array_map('preg_quote', $tagnames));
|
||||
return '\\[(\\[?)'."($tagregexp)"
|
||||
.'(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
|
||||
}
|
||||
|
||||
public static function doShortcodeTag($m)
|
||||
{
|
||||
$shortcode_tags = self::$shortcode_tags;
|
||||
// allow [[foo]] syntax for escaping a tag
|
||||
if ($m[1] == '[' && $m[6] == ']') {
|
||||
return Tools::substr($m[0], 1, -1);
|
||||
}
|
||||
$tag = $m[2];
|
||||
$attr = self::shortcodeParseAtts($m[3]);
|
||||
$function_call = self::$is_front_office ? 'fontContent' : 'adminContent';
|
||||
if (isset($m[5])) {
|
||||
return $m[1].call_user_func(array($shortcode_tags[$tag], $function_call), $attr, $m[5], $tag, self::$is_gen_html).$m[6];
|
||||
} else {
|
||||
// self-closing tag
|
||||
return $m[1].call_user_func(array($shortcode_tags[$tag], $function_call), $attr, null, $tag, self::$is_gen_html).$m[6];
|
||||
}
|
||||
}
|
||||
|
||||
public static function shortcodeParseAtts($text)
|
||||
{
|
||||
$pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
|
||||
$text = preg_replace('/[\x{00a0}\x{200b}]+/u', ' ', $text);
|
||||
$atts = array();
|
||||
if (preg_match_all($pattern, $text, $match, PREG_SET_ORDER)) {
|
||||
foreach ($match as $m) {
|
||||
if (!empty($m[1])) {
|
||||
$atts[Tools::strtolower($m[1])] = stripcslashes($m[2]);
|
||||
} elseif (!empty($m[3])) {
|
||||
$atts[Tools::strtolower($m[3])] = stripcslashes($m[4]);
|
||||
} elseif (!empty($m[5])) {
|
||||
$atts[Tools::strtolower($m[5])] = stripcslashes($m[6]);
|
||||
} elseif (isset($m[7]) && Tools::strlen($m[7])) {
|
||||
$atts[] = stripcslashes($m[7]);
|
||||
} elseif (isset($m[8])) {
|
||||
$atts[] = stripcslashes($m[8]);
|
||||
} else {
|
||||
$atts = ltrim($text);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $atts;
|
||||
}
|
||||
|
||||
public static function stripShortcodes($content)
|
||||
{
|
||||
$shortcode_tags = self::$shortcode_tags;
|
||||
if (empty($shortcode_tags) || !is_array($shortcode_tags)) {
|
||||
return $content;
|
||||
}
|
||||
$pattern = self::getShortcodeRegex();
|
||||
return preg_replace_callback("/$pattern/s", array(self, 'stripShortcodeTag'), $content);
|
||||
}
|
||||
|
||||
public static function stripShortcodeTag($m)
|
||||
{
|
||||
// allow [[foo]] syntax for escaping a tag
|
||||
if ($m[1] == '[' && $m[6] == ']') {
|
||||
return Tools::substr($m[0], 1, -1);
|
||||
}
|
||||
return $m[1].$m[6];
|
||||
}
|
||||
|
||||
public static function setShortCodeLang($type)
|
||||
{
|
||||
if (!isset(AdminApPageBuilderHomeController::$shortcode_lang[$type])) {
|
||||
$fileName = $type;
|
||||
if (strpos($type, 'apSub') !== false) {
|
||||
$fileName = str_replace('Sub', '', $type);
|
||||
}
|
||||
if (file_exists(_PS_MODULE_DIR_.'appagebuilder/classes/shortcodes/'.$fileName.'.php')) {
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/shortcodes/'.$fileName.'.php');
|
||||
}
|
||||
if ($fileName != $type) {
|
||||
$inputs = call_user_func(array(new $fileName, 'getConfigList'), 1);
|
||||
} else {
|
||||
$inputs = call_user_func(array(new $fileName, 'getConfigList'));
|
||||
}
|
||||
foreach ($inputs as $input) {
|
||||
if (isset($input['lang']) && $input['lang']) {
|
||||
if (self::$lang_id) {
|
||||
AdminApPageBuilderHomeController::$shortcode_lang[$type][$input['name']] = $input['name'].'_'.self::$lang_id;
|
||||
} else {
|
||||
foreach (AdminApPageBuilderHomeController::$language as $lang) {
|
||||
AdminApPageBuilderHomeController::$shortcode_lang[$type][$input['name'].'_'
|
||||
.$lang['iso_code']] = $input['name'].'_'.$lang['id_lang'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function converParamToAttr($params, $type, $theme_dir = '')
|
||||
{
|
||||
$attr = '';
|
||||
self::setShortCodeLang($type);
|
||||
|
||||
$lang_field = array();
|
||||
if (isset(AdminApPageBuilderHomeController::$shortcode_lang[$type])) {
|
||||
$lang_field = AdminApPageBuilderHomeController::$shortcode_lang[$type];
|
||||
}
|
||||
|
||||
//remove lang field first
|
||||
if ($lang_field) {
|
||||
foreach ($params as $key => $val) {
|
||||
if (false !== $arr_key = array_search($key, $lang_field)) {
|
||||
//do something
|
||||
$params[$arr_key] = $val;
|
||||
foreach ($params as $key => $val) {
|
||||
foreach (AdminApPageBuilderHomeController::$language as $lang) {
|
||||
unset($params[$arr_key.'_'.$lang['id_lang']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//DONGND:: fix data for ApBlockcarousel
|
||||
if ($type == 'ApBlockCarousel' && isset($params['total_slider']) && $params['total_slider'] != '') {
|
||||
$lang_field_special = array();
|
||||
$list = explode('|', $params['total_slider']);
|
||||
foreach ($list as $list_item) {
|
||||
$lang_field_special['tit_'.$list_item] = 'tit_'.$list_item.'_'.self::$lang_id;
|
||||
$lang_field_special['img_'.$list_item] = 'img_'.$list_item.'_'.self::$lang_id;
|
||||
$lang_field_special['link_'.$list_item] = 'link_'.$list_item.'_'.self::$lang_id;
|
||||
$lang_field_special['descript_'.$list_item] = 'descript_'.$list_item.'_'.self::$lang_id;
|
||||
};
|
||||
if ($lang_field_special) {
|
||||
foreach ($params as $key => $val) {
|
||||
if (false !== $arr_key = array_search($key, $lang_field_special)) {
|
||||
//do something
|
||||
$params[$arr_key.'_'.self::$lang_id] = $val;
|
||||
foreach ($params as $key => $val) {
|
||||
foreach (AdminApPageBuilderHomeController::$language as $lang) {
|
||||
if ($lang['id_lang'] != self::$lang_id) {
|
||||
unset($params[$arr_key.'_'.$lang['id_lang']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($params as $key => $val) {
|
||||
if ($key == 'override_folder' && $val) {
|
||||
//remove space
|
||||
$val = str_replace(' ', '', $val);
|
||||
//add new function override folder for widget
|
||||
self::processOverrideTpl($val, $type, $theme_dir);
|
||||
}
|
||||
$attr .= ($attr ? ' ' : '').$key.'="'.$val.'"';
|
||||
}
|
||||
return ($attr ? ' ' : '').$attr;
|
||||
}
|
||||
|
||||
|
||||
//DONGND:: clone function for Apshortcode
|
||||
public static function setShortCodeLang2($type)
|
||||
{
|
||||
if (!isset(AdminApPageBuilderShortcodeController::$shortcode_lang[$type])) {
|
||||
$fileName = $type;
|
||||
if (strpos($type, 'apSub') !== false) {
|
||||
$fileName = str_replace('Sub', '', $type);
|
||||
}
|
||||
if (file_exists(_PS_MODULE_DIR_.'appagebuilder/classes/shortcodes/'.$fileName.'.php')) {
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/shortcodes/'.$fileName.'.php');
|
||||
}
|
||||
if ($fileName != $type) {
|
||||
$inputs = call_user_func(array(new $fileName, 'getConfigList'), 1);
|
||||
} else {
|
||||
$inputs = call_user_func(array(new $fileName, 'getConfigList'));
|
||||
}
|
||||
foreach ($inputs as $input) {
|
||||
if (isset($input['lang']) && $input['lang']) {
|
||||
if (self::$lang_id) {
|
||||
AdminApPageBuilderShortcodeController::$shortcode_lang[$type][$input['name']] = $input['name'].'_'.self::$lang_id;
|
||||
} else {
|
||||
foreach (AdminApPageBuilderShortcodeController::$language as $lang) {
|
||||
AdminApPageBuilderShortcodeController::$shortcode_lang[$type][$input['name'].'_'
|
||||
.$lang['iso_code']] = $input['name'].'_'.$lang['id_lang'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//DONGND:: clone function for Apshortcode
|
||||
public static function converParamToAttr2($params, $type, $theme_dir = '')
|
||||
{
|
||||
$attr = '';
|
||||
self::setShortCodeLang2($type);
|
||||
|
||||
$lang_field = array();
|
||||
if (isset(AdminApPageBuilderShortcodeController::$shortcode_lang[$type])) {
|
||||
$lang_field = AdminApPageBuilderShortcodeController::$shortcode_lang[$type];
|
||||
}
|
||||
|
||||
//remove lang field first
|
||||
if ($lang_field) {
|
||||
foreach ($params as $key => $val) {
|
||||
if (false !== $arr_key = array_search($key, $lang_field)) {
|
||||
//do something
|
||||
$params[$arr_key] = $val;
|
||||
foreach ($params as $key => $val) {
|
||||
foreach (AdminApPageBuilderShortcodeController::$language as $lang) {
|
||||
unset($params[$arr_key.'_'.$lang['id_lang']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//fix data for ApBlockcarousel
|
||||
if ($type == 'ApBlockCarousel' && isset($params['total_slider']) && $params['total_slider'] != '') {
|
||||
$lang_field_special = array();
|
||||
$list = explode('|', $params['total_slider']);
|
||||
foreach ($list as $list_item) {
|
||||
$lang_field_special['tit_'.$list_item] = 'tit_'.$list_item.'_'.self::$lang_id;
|
||||
$lang_field_special['img_'.$list_item] = 'img_'.$list_item.'_'.self::$lang_id;
|
||||
$lang_field_special['link_'.$list_item] = 'link_'.$list_item.'_'.self::$lang_id;
|
||||
$lang_field_special['descript_'.$list_item] = 'descript_'.$list_item.'_'.self::$lang_id;
|
||||
};
|
||||
if ($lang_field_special) {
|
||||
foreach ($params as $key => $val) {
|
||||
if (false !== $arr_key = array_search($key, $lang_field_special)) {
|
||||
//do something
|
||||
$params[$arr_key.'_'.self::$lang_id] = $val;
|
||||
foreach ($params as $key => $val) {
|
||||
foreach (Language::getLanguages(false) as $lang) {
|
||||
if ($lang['id_lang'] != self::$lang_id) {
|
||||
unset($params[$arr_key.'_'.$lang['id_lang']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($params as $key => $val) {
|
||||
if ($key == 'override_folder' && $val) {
|
||||
//remove space
|
||||
$val = str_replace(' ', '', $val);
|
||||
//add new function override folder for widget
|
||||
self::processOverrideTpl($val, $type, $theme_dir);
|
||||
}
|
||||
$attr .= ($attr ? ' ' : '').$key.'="'.$val.'"';
|
||||
}
|
||||
return ($attr ? ' ' : '').$attr;
|
||||
}
|
||||
|
||||
public static function processOverrideTpl($val, $type, $theme_dir)
|
||||
{
|
||||
if (file_exists($theme_dir.'modules/appagebuilder/views/templates/hook/'.$val.'/'.$type.'.tpl')) {
|
||||
return;
|
||||
}
|
||||
|
||||
//create overide folder
|
||||
if (!is_dir($theme_dir.'modules/appagebuilder/')) {
|
||||
// validate module
|
||||
mkdir($theme_dir.'modules/appagebuilder/', 0755, true);
|
||||
}
|
||||
if (!is_dir($theme_dir.'modules/appagebuilder/views/')) {
|
||||
// validate module
|
||||
mkdir($theme_dir.'modules/appagebuilder/views/', 0755, true);
|
||||
}
|
||||
if (!is_dir($theme_dir.'modules/appagebuilder/views/templates/')) {
|
||||
// validate module
|
||||
mkdir($theme_dir.'modules/appagebuilder/views/templates/', 0755, true);
|
||||
}
|
||||
if (!is_dir($theme_dir.'modules/appagebuilder/views/templates/hook/')) {
|
||||
// validate module
|
||||
mkdir($theme_dir.'modules/appagebuilder/views/templates/hook/', 0755, true);
|
||||
}
|
||||
if (!is_dir($theme_dir.'modules/appagebuilder/views/templates/hook/'.$val)) {
|
||||
// validate module
|
||||
mkdir($theme_dir.'modules/appagebuilder/views/templates/hook/'.$val, 0755, true);
|
||||
}
|
||||
if (file_exists(_PS_MODULE_DIR_.'appagebuilder/views/templates/hook/'.$type.'.tpl')) {
|
||||
Tools::copy(_PS_MODULE_DIR_.'appagebuilder/views/templates/hook/'.$type.'.tpl', $theme_dir.'modules/appagebuilder/views/templates/hook/'.$val.'/'.$type.'.tpl');
|
||||
} else {
|
||||
$theme_dir_ori = _PS_THEME_DIR_;
|
||||
Tools::copy(_PS_MODULE_DIR_.'appagebuilder/views/templates/hook/ApGeneral.tpl', $theme_dir_ori.'modules/appagebuilder/views/templates/hook/'.$val.'/'.$type.'.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
public static function correctDeCodeData($data)
|
||||
{
|
||||
$function_name = 'base64_decode';
|
||||
//$functionName = 'b'.'a'.'s'.'e'.'6'.'4'.'_'.'decode';
|
||||
return call_user_func($function_name, $data);
|
||||
}
|
||||
|
||||
public static function correctEnCodeData($data)
|
||||
{
|
||||
$function_name = 'base64_encode';
|
||||
//$functionName = 'b'.'a'.'s'.'e'.'6'.'4'.'_'.'encode';
|
||||
return call_user_func($function_name, $data);
|
||||
}
|
||||
|
||||
public function parse($str)
|
||||
{
|
||||
return self::doShortcode($str);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
36
modules/appagebuilder/classes/index.php
Normal file
36
modules/appagebuilder/classes/index.php
Normal 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;
|
||||
635
modules/appagebuilder/classes/shortcodes.php
Normal file
635
modules/appagebuilder/classes/shortcodes.php
Normal file
@@ -0,0 +1,635 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!class_exists('ApShortCodeBase')) {
|
||||
require_once(_PS_MODULE_DIR_ . 'appagebuilder/libs/Helper.php');
|
||||
require_once(_PS_MODULE_DIR_ . 'appagebuilder/controllers/admin/AdminApPageBuilderShortcodes.php');
|
||||
require_once(_PS_MODULE_DIR_ . 'appagebuilder/classes/ApShortCodesBuilder.php');
|
||||
|
||||
abstract class ApShortCodeBase
|
||||
{
|
||||
/*
|
||||
* override it for each widget
|
||||
*/
|
||||
public $name = '';
|
||||
/**
|
||||
* override when using tinymcs
|
||||
*/
|
||||
public $tinymce = 0;
|
||||
public $module_name = 'appagebuilder';
|
||||
public $id_shop = 0;
|
||||
public $fields_form = array();
|
||||
public $types = array();
|
||||
public $config_list = array();
|
||||
public $str_search;
|
||||
public $str_relace;
|
||||
public $str_relace_html;
|
||||
public $str_relace_html_admin;
|
||||
public $theme_img_module;
|
||||
public $theme_dir;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->str_search = apPageHelper::getStrSearch();
|
||||
$this->str_relace = apPageHelper::getStrReplace();
|
||||
$this->str_relace_html = apPageHelper::getStrReplaceHtml();
|
||||
$this->str_relace_html_admin = apPageHelper::getStrReplaceHtmlAdmin();
|
||||
// Not run with multi_shop (ex block carousel cant get image in backend multi_shop)
|
||||
$this->theme_img_module = apPageHelper::getImgThemeUrl();
|
||||
$this->theme_dir = _PS_THEME_DIR_;
|
||||
}
|
||||
/*
|
||||
* if file is not exist in theme folder, will get it in module folder, this function only apply for font end
|
||||
*/
|
||||
|
||||
public function getDirOfFile($path_theme, $file, $path_module = '')
|
||||
{
|
||||
if (file_exists(_PS_THEME_DIR_ . $path_theme . '/' . $file)) {
|
||||
// validate module
|
||||
return _PS_THEME_DIR_ . $path_theme . '/' . $file;
|
||||
} else {
|
||||
if ($path_module) {
|
||||
return _PS_MODULE_DIR_ . 'appagebuilder/' . $path_module . $file;
|
||||
} else {
|
||||
return _PS_MODULE_DIR_ . 'appagebuilder/' . $path_theme . $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class name of product item by plistkey (using in widgets: ApProductList and ApProductCarousel)
|
||||
*/
|
||||
public function getProductClassByPListKey($plist = '')
|
||||
{
|
||||
// Against SQL injections
|
||||
// $plist = pSQL($plist ? $plist : '');
|
||||
$result = Db::getInstance()->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'appagebuilder_products WHERE plist_key="' . pSQL($plist) . '" LIMIT 1');
|
||||
if ($result) {
|
||||
return $result[0]['class'];
|
||||
}
|
||||
return 'profile-default';
|
||||
}
|
||||
|
||||
/**
|
||||
* abstract method to return html widget form
|
||||
*/
|
||||
public function getInfo()
|
||||
{
|
||||
return array(
|
||||
'key' => 'base',
|
||||
'label' => 'Widget Base'
|
||||
);
|
||||
}
|
||||
|
||||
public static function getUrlProfileEdit()
|
||||
{
|
||||
$id_profile = Tools::getIsset('id_appagebuilder_profiles') ? Tools::getValue('id_appagebuilder_profiles') : '';
|
||||
if (!$id_profile) {
|
||||
$profile = ApPageBuilderProfilesModel::getActiveProfile('index');
|
||||
$id_profile = $profile['id_appagebuilder_profiles'];
|
||||
}
|
||||
// $controller = 'AdminApPageBuilderHome';
|
||||
// $id_lang = Context::getContext()->language->id;
|
||||
// $params = array('token' => Tools::getAdminTokenLite($controller));
|
||||
//$url_profile_edit = $admin_dir.'/'.Dispatcher::getInstance()->createUrl($controller, $id_lang, $params, false);
|
||||
$url_profile_edit = Context::getContext()->link->getAdminLink('AdminApPageBuilderProfiles') . '&id_appagebuilder_profiles=' . $id_profile . '&updateappagebuilder_profiles';
|
||||
return $url_profile_edit;
|
||||
}
|
||||
|
||||
public static function getShortCodeInfos()
|
||||
{
|
||||
$shortcode_dir = _PS_MODULE_DIR_ . 'appagebuilder/classes/shortcodes/';
|
||||
$source_file = Tools::scandir($shortcode_dir);
|
||||
$short_code_list = array();
|
||||
$is_sub_tab = Tools::getValue('subTab');
|
||||
foreach ($source_file as $value) {
|
||||
$fileName = basename($value, '.php');
|
||||
if ($fileName == 'index' || $fileName == 'ApColumn' || $fileName == 'ApRow' || ($is_sub_tab && ($fileName == 'ApTabs' || $fileName == 'ApAjaxTabs' || $fileName == 'ApAccordions'))) {
|
||||
continue;
|
||||
}
|
||||
require_once($shortcode_dir . $value);
|
||||
$obj = new $fileName;
|
||||
$short_code_list[$fileName] = $obj->getInfo();
|
||||
}
|
||||
return $short_code_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* abstract method to return widget data
|
||||
*/
|
||||
public function renderContent($args, $data)
|
||||
{
|
||||
// validate module
|
||||
unset($args);
|
||||
unset($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getTranslator()
|
||||
{
|
||||
static $translator;
|
||||
if (!$translator) {
|
||||
// $translator = Context::getContext()->controller->module->getTranslator(); // Run at Backend
|
||||
// Run at Backend + Frontend. Test with ApGmap Widget
|
||||
$translator = Context::getContext()->getTranslator();
|
||||
}
|
||||
return $translator;
|
||||
}
|
||||
|
||||
protected function trans($id, array $parameters = array(), $domain = 'Modules.Appagebuilder.Admin', $locale = null)
|
||||
{
|
||||
return $this->getTranslator()->trans($id, $parameters, $domain, $locale);
|
||||
}
|
||||
|
||||
public function l($string, $specific = false)
|
||||
{
|
||||
if (Tools::getValue('type_shortcode')) {
|
||||
// FIX Translate in loading widget ajax
|
||||
return TranslateCore::getModuleTranslation($this->module_name, $string, ($specific) ? $specific : Tools::getValue('type_shortcode'));
|
||||
} else {
|
||||
# TRANSLATE FOR MODULE - CALL MODULE
|
||||
// return Module::getInstanceByName('APPageBuilder')->l($string, $specific);
|
||||
|
||||
# TRANSLATE FOR MODULE - CALL CORE
|
||||
// return TranslateCore::getModuleTranslation($this->module_name, $string, ($specific) ? $specific : $this->module_name);
|
||||
|
||||
# TRANSLATE FOR WIDGET
|
||||
$str = TranslateCore::getModuleTranslation($this->module_name, $string, $this->name);
|
||||
|
||||
if (Tools::getIsset('controller') && (Tools::getValue('controller') == 'AdminApPageBuilderHome' || Tools::getValue('controller') == 'AdminApPageBuilderShortcode')) {
|
||||
# FIX TRANSLATE FRANCE HAS ' -> error JS
|
||||
$str = str_replace('\'', ' ', $str);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
public function getInputValues($type, $value)
|
||||
{
|
||||
if ($type == 'switchYesNo') {
|
||||
return array(
|
||||
array(
|
||||
'id' => $value . '_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Yes')
|
||||
),
|
||||
array(
|
||||
'id' => $value . '_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('No')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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']]) ? $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;
|
||||
$thumb = apPageHelper::getImgThemeUrl() . $value;
|
||||
$this->fields_form[$k]['form']['input'][$j]['thumb'] = $thumb;
|
||||
}
|
||||
$fields_values[$input['name']] = $value;
|
||||
} else {
|
||||
$v = Tools::getValue($input['name'], Configuration::get($input['name']));
|
||||
$fields_values[$input['name']] = $v ? $v : $input['default'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($data['id_leowidgets'])) {
|
||||
$fields_values['id_leowidgets'] = $data['id_leowidgets'];
|
||||
}
|
||||
return $fields_values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return config value for each shortcode
|
||||
*/
|
||||
public function getConfigValue()
|
||||
{
|
||||
$config_val = array();
|
||||
//return addition config
|
||||
$a_config = $this->getAdditionConfig();
|
||||
if ($a_config) {
|
||||
$this->config_list = array_merge($this->config_list, $a_config);
|
||||
}
|
||||
foreach ($this->config_list as $config) {
|
||||
$config['lang'] = (isset($config['lang']) && $config['lang']) ? $config['lang'] : '';
|
||||
$config['name'] = (isset($config['name']) && $config['name']) ? $config['name'] : '';
|
||||
$config['default'] = (isset($config['default']) && $config['default']) ? $config['default'] : '';
|
||||
|
||||
if ($config['lang']) {
|
||||
$config_val[$config['name']] = array();
|
||||
foreach (Language::getLanguages(false) as $lang) {
|
||||
//$config_val[$config['name']] = Tools::getValue($config['name'], $config['default']);
|
||||
$config_val[$config['name']][$lang['id_lang']] = str_replace($this->str_search, $this->str_relace_html_admin, Tools::getValue($config['name'] . '_' . $lang['id_lang'], $config['default']));
|
||||
}
|
||||
} else if (false !== strpos($config['name'], '[]')) {
|
||||
$get_val_name = str_replace('[]', '', $config['name']);
|
||||
$config_val[$config['name']] = explode(',', Tools::getValue($get_val_name, $config['default']));
|
||||
} else {
|
||||
$config_val[$config['name']] = str_replace($this->str_search, $this->str_relace_html_admin, Tools::getValue($config['name'], $config['default']));
|
||||
}
|
||||
}
|
||||
//$config_val[$config['name']] = Tools::getValue($config['name'], $config['default']);
|
||||
$config_val['override_folder'] = Tools::getValue('override_folder', '');
|
||||
return $config_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override in each shource code to return config list
|
||||
*/
|
||||
public function getConfigList()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return AdditionConfig list, when you use override of input in helper
|
||||
*/
|
||||
public function getAdditionConfig()
|
||||
{
|
||||
}
|
||||
|
||||
public function preparaAdminContent($atts, $tag_name = null)
|
||||
{
|
||||
if ($tag_name == null) {
|
||||
$tag_name = $this->name;
|
||||
}
|
||||
//need reprocess
|
||||
if (is_array($atts)) {
|
||||
$atts = array_diff($atts, array(
|
||||
''
|
||||
));
|
||||
if (!isset(ApShortCodesBuilder::$shortcode_lang[$tag_name])) {
|
||||
$inputs = $this->getConfigList();
|
||||
$lang_field = array();
|
||||
foreach ($inputs as $input) {
|
||||
if (isset($input['lang']) && $input['lang']) {
|
||||
$lang_field[] = $input['name'];
|
||||
}
|
||||
}
|
||||
ApShortCodesBuilder::$shortcode_lang[$tag_name] = $lang_field;
|
||||
} else {
|
||||
$lang_field = ApShortCodesBuilder::$shortcode_lang[$tag_name];
|
||||
}
|
||||
foreach ($atts as $key => $val) {
|
||||
if ($lang_field && in_array($key, $lang_field)) {
|
||||
$key .= '_' . ApShortCodesBuilder::$lang_id;
|
||||
}
|
||||
if (!isset(ApShortCodesBuilder::$data_form[$atts['form_id']][$key])) {
|
||||
//find language fields
|
||||
// if (strpos($key, '_array') !== false) {
|
||||
// $key = str_replace ('_array', '[]', $key);
|
||||
// }
|
||||
ApShortCodesBuilder::$data_form[$atts['form_id']][$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content for normal short code - from shource controller
|
||||
*/
|
||||
public function adminContent($atts, $content = null, $tag_name = null, $is_gen_html = null)
|
||||
{
|
||||
// validate module
|
||||
unset($tag_name);
|
||||
$this->preparaAdminContent($atts);
|
||||
if ($is_gen_html) {
|
||||
foreach ($atts as $key => $val) {
|
||||
if (strpos($key, 'content') !== false || strpos($key, 'link') !== false || strpos($key, 'url') !== false || strpos($key, 'alt') !== false || strpos($key, 'tit') !== false || strpos($key, 'name') !== false || strpos($key, 'desc') !== false || strpos($key, 'itemscustom') !== false) {
|
||||
$atts[$key] = str_replace($this->str_search, $this->str_relace_html, $val);
|
||||
}
|
||||
}
|
||||
$assign = array();
|
||||
$assign['apContent'] = ApShortCodesBuilder::doShortcode($content);
|
||||
if (isset($atts['content_html'])) {
|
||||
$atts['content_html'] = str_replace($this->str_search, $this->str_relace_html, $atts['content_html']);
|
||||
}
|
||||
$assign['formAtts'] = $atts;
|
||||
$w_info = $this->getInfo();
|
||||
$w_info['name'] = $this->name;
|
||||
$assign['apInfo'] = $w_info;
|
||||
if ($this->name == 'ApColumn') {
|
||||
$assign['colClass'] = $this->convertColWidthToClass($atts);
|
||||
$assign['widthList'] = ApPageSetting::returnWidthList();
|
||||
}
|
||||
//DONGND:: add parameter to create animation for group/column
|
||||
if ($this->name == 'ApRow' || $this->name == 'ApColumn') {
|
||||
$assign['listAnimation'] = ApPageSetting::getAnimationsColumnGroup();
|
||||
}
|
||||
|
||||
$controller = new AdminApPageBuilderShortcodesController();
|
||||
return $controller->adminContent($assign, $this->name . '.tpl');
|
||||
} else {
|
||||
ApShortCodesBuilder::doShortcode($content);
|
||||
}
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
return $assign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content for normal short code - from shource controller
|
||||
*/
|
||||
public function fontContent($atts, $content = null)
|
||||
{
|
||||
$is_active = $this->isWidgetActive(array(
|
||||
'formAtts' => $atts
|
||||
));
|
||||
if (!$is_active) {
|
||||
return '';
|
||||
}
|
||||
$device = Context::getContext()->getDevice();
|
||||
if (($device == 1 && isset($atts['active_desktop']) && !$atts['active_desktop']) || ($device == 2 && isset($atts['active_tablet']) && !$atts['active_tablet']) ||($device == 4 && isset($atts['active_mobile']) && !$atts['active_mobile'])) {
|
||||
return '';
|
||||
}
|
||||
$assign = array();
|
||||
$assign['apContent'] = ApShortCodesBuilder::doShortcode($content);
|
||||
foreach ($atts as $key => $val) {
|
||||
if (strpos($key, 'content') !== false || strpos($key, 'link') !== false || strpos($key, 'url') !== false || strpos($key, 'alt') !== false || strpos($key, 'tit') !== false || strpos($key, 'name') !== false || strpos($key, 'desc') !== false || strpos($key, 'itemscustom') !== false) {
|
||||
$atts[$key] = str_replace($this->str_search, $this->str_relace_html, $val);
|
||||
if (strpos($atts[$key], '_AP_IMG_DIR') !== false) {
|
||||
// validate module
|
||||
$atts[$key] = str_replace('_AP_IMG_DIR/', $this->theme_img_module, $atts[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($atts['class'])) {
|
||||
$atts['class'] = '';
|
||||
}
|
||||
if (isset($atts['specific_type']) && $atts['specific_type']) {
|
||||
$current_page = apPageHelper::getPageName();
|
||||
|
||||
//$current_hook = ApShortCodesBuilder::$hook_name;
|
||||
if ($atts['specific_type'] == 'all') {
|
||||
$ex_page = explode(',', isset($atts['controller_pages']) ? $atts['controller_pages'] : '');
|
||||
$ex_page = array_map('trim', $ex_page);
|
||||
if (in_array($current_page, $ex_page)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
# Front modules controller fc=module module=... controller=...
|
||||
$current_page = Tools::getValue('fc') . '-' . Tools::getValue('module') . '-' . Tools::getValue('controller');
|
||||
if (in_array($current_page, $ex_page)) {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$ids = explode(',', $atts['controller_id']);
|
||||
$ids = array_map('trim', $ids);
|
||||
|
||||
if ($atts['specific_type'] == 'nocategory') {
|
||||
if ($current_page == 'category') {
|
||||
if (ApPageSetting::getControllerId($current_page, $ids)) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
} elseif ($atts['specific_type'] == 'nocategoryproduct') {
|
||||
if ($current_page == 'category') {
|
||||
if (ApPageSetting::getControllerId($current_page, $ids)) {
|
||||
return '';
|
||||
}
|
||||
} else if ($current_page == 'product') {
|
||||
$procate = Product::getProductCategoriesFull(Tools::getValue('id_product'));
|
||||
$procheck = 0;
|
||||
foreach ($procate as $proc) {
|
||||
if (in_array($proc['id_category'], $ids)) {
|
||||
$procheck = 1;
|
||||
}
|
||||
}
|
||||
if ($procheck == 1) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
} elseif ($atts['specific_type'] == 'categoryproduct') {
|
||||
if ($current_page == 'category') {
|
||||
if (!ApPageSetting::getControllerId($current_page, $ids)) {
|
||||
return '';
|
||||
}
|
||||
} else if ($current_page == 'product') {
|
||||
$procate = Product::getProductCategoriesFull(Tools::getValue('id_product'));
|
||||
$procheck = 0;
|
||||
foreach ($procate as $proc) {
|
||||
if (in_array($proc['id_category'], $ids)) {
|
||||
$procheck = 1;
|
||||
}
|
||||
}
|
||||
if ($procheck == 0) {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} elseif ($atts['specific_type'] == 'categoryproductmain') {
|
||||
if ($current_page == 'category') {
|
||||
if (!ApPageSetting::getControllerId($current_page, $ids)) {
|
||||
return '';
|
||||
}
|
||||
} else if ($current_page == 'product') {
|
||||
$proc = new Product(Tools::getValue('id_product'));
|
||||
if (!in_array($proc->id_category_default, $ids)) {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
if ($current_page != $atts['specific_type']) {
|
||||
return '';
|
||||
}
|
||||
if ($current_page == 'category' || $current_page == 'product' || $current_page == 'cms') {
|
||||
$ids = explode(',', $atts['controller_id']);
|
||||
$ids = array_map('trim', $ids);
|
||||
if ($atts['controller_id'] != '' && !ApPageSetting::getControllerId($current_page, $ids)) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->name == 'ApColumn') {
|
||||
$atts['class'] = $this->convertColWidthToClass($atts) . ' ' . $atts['class'];
|
||||
}
|
||||
$atts['class'] .= ' ' . $this->name;
|
||||
$atts['class'] = trim($atts['class']);
|
||||
$atts['rtl'] = Context::getContext()->language->is_rtl;
|
||||
$assign['formAtts'] = $atts;
|
||||
$assign['homeSize'] = Image::getSize(ImageType::getFormattedName('home'));
|
||||
$assign['mediumSize'] = Image::getSize(ImageType::getFormattedName('medium'));
|
||||
$module = APPageBuilder::getInstance();
|
||||
|
||||
# FIX 1.7 GLOBAL VARIABLE
|
||||
$assign['img_manu_dir'] = _THEME_MANU_DIR_;
|
||||
|
||||
$assign['comparator_max_item'] = (int) Configuration::get('PS_COMPARATOR_MAX_ITEM');
|
||||
$assign['compared_products'] = array();
|
||||
$assign['tpl_dir'] = _PS_THEME_DIR_;
|
||||
$assign['PS_CATALOG_MODE'] = (int) Configuration::get('PS_CATALOG_MODE');
|
||||
$assign['priceDisplay'] = ProductCore::getTaxCalculationMethod(Context::getContext()->cookie->id_customer);
|
||||
$assign['PS_STOCK_MANAGEMENT'] = Configuration::get('PS_STOCK_MANAGEMENT');
|
||||
$assign['page_name'] = apPageHelper::getPageName();
|
||||
$assign['leo_helper'] = apPageHelper::getInstance();
|
||||
isset($assign['formAtts']['override_folder']) ? true : $assign['formAtts']['override_folder'] = '';
|
||||
|
||||
$assign = $this->prepareFontContent($assign, $module);
|
||||
return $module->fontContent($assign, $this->name . '.tpl');
|
||||
}
|
||||
|
||||
public function isWidgetActive($assign)
|
||||
{
|
||||
$flag = true;
|
||||
|
||||
if (isset($assign['formAtts']['active']) && $assign['formAtts']['active'] == 0) {
|
||||
$flag = false;
|
||||
}
|
||||
|
||||
return $flag;
|
||||
}
|
||||
|
||||
public function convertColWidthToClass($atts)
|
||||
{
|
||||
$class = '';
|
||||
// 1.7 Update Module
|
||||
if (!array_key_exists('xl', $atts)) {
|
||||
$class .= 'col-xl-12';
|
||||
}
|
||||
foreach ($atts as $key => $val) {
|
||||
if ($key == 'xl' || $key == 'lg' || $key == 'md' || $key == 'sm' || $key == 'xs' || $key == 'sp') {
|
||||
$class .= ' col-' . $key . '-' . $val;
|
||||
}
|
||||
}
|
||||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return config form
|
||||
*/
|
||||
public function renderForm()
|
||||
{
|
||||
$helper = new HelperForm();
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = (isset($this->table) && $this->table) ? $this->table : '';
|
||||
$helper->name_controller = 'form_' . $this->name;
|
||||
$lang = new Language((int) Context::getContext()->language->id);
|
||||
$default_lang = $lang->id;
|
||||
$this->fields_form = array();
|
||||
$helper->identifier = (isset($this->identifier) && $this->identifier) ? $this->identifier : '';
|
||||
$helper->token = Tools::getAdminTokenLite('AdminModules');
|
||||
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->default_form_language = $default_lang;
|
||||
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
|
||||
$this->config_list = $this->getConfigList();
|
||||
//add code for override tpl folder
|
||||
if ($this->name != 'ApRow' && $this->name != 'ApColumn' && $this->name != 'ApModule') {
|
||||
$this->config_list[count($this->config_list)] = array(
|
||||
'type' => 'text',
|
||||
'name' => 'override_folder',
|
||||
'label' => $this->l('Override Folder', 'shortcodes'),
|
||||
'desc' => $this->l('[Developer Only] System will auto create folder, you can put tpl of this shortcode to the folder. You can use this function to show 2 different layout', 'shortcodes'),
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
);
|
||||
}
|
||||
|
||||
$w_info = $this->getInfo();
|
||||
$title_widget = array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="modal-widget-title">' . $w_info['label'] . '</div>'
|
||||
);
|
||||
array_unshift($this->config_list, $title_widget);
|
||||
$helper->submit_action = $this->name;
|
||||
$field_value = $this->getConfigValue();
|
||||
$this->addConfigList($field_value);
|
||||
$fields_form = array(
|
||||
'form' => array(
|
||||
'input' => $this->config_list,
|
||||
'name' => $this->name,
|
||||
'class' => $this->name,
|
||||
'tinymce' => $this->tinymce
|
||||
)
|
||||
);
|
||||
$helper->tpl_vars = array(
|
||||
'fields_value' => $field_value,
|
||||
'widthList' => ApPageSetting::returnWidthList()
|
||||
);
|
||||
|
||||
$this->helper = $helper;
|
||||
if (method_exists($this, $method_name = 'endRenderForm')) {
|
||||
$this->$method_name();
|
||||
}
|
||||
|
||||
return $this->helper->generateForm(array(
|
||||
$fields_form
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget can override this method and add more config at here
|
||||
*/
|
||||
public function addConfigList($field_value)
|
||||
{
|
||||
// validate module
|
||||
unset($field_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget can override this method and add more config at here
|
||||
*/
|
||||
public function displayModuleExceptionList()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function ajaxProcessRender($module)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
222
modules/appagebuilder/classes/shortcodes/ApAccordions.php
Normal file
222
modules/appagebuilder/classes/shortcodes/ApAccordions.php
Normal file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApAccordions extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApAccordions';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Accordions'),
|
||||
'position' => 5, 'desc' => $this->l('You can put widget in accordions'),
|
||||
'icon_class' => 'icon icon-align-justify',
|
||||
'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList($sub_tab = 0)
|
||||
{
|
||||
if (Tools::getIsset('subTab') || $sub_tab) {
|
||||
$input = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'lang' => 'true',
|
||||
'values' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'id',
|
||||
'label' => $this->l('ID Accordion'),
|
||||
'values' => ''
|
||||
)
|
||||
);
|
||||
$this->name = 'ApSubAccordion';
|
||||
} else {
|
||||
$input = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => '',
|
||||
),
|
||||
// array(
|
||||
// 'type' => 'select',
|
||||
// 'label' => $this->l('Accordion Type'),
|
||||
// 'name' => 'accordion_type',
|
||||
// 'options' => array(
|
||||
// 'query' => array(
|
||||
// array(
|
||||
// 'id' => 'vertical',
|
||||
// 'name' => $this->l('Vertical'),
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'horizontal',
|
||||
// 'name' => $this->l('Horizontal'),
|
||||
// )
|
||||
// ),
|
||||
// 'id' => 'id',
|
||||
// 'name' => 'name'
|
||||
// ),
|
||||
// ),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Showing Type'),
|
||||
'name' => 'active_type',
|
||||
'class' => 'form-action',
|
||||
'default' => 'hideall',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'set',
|
||||
'name' => $this->l('Set active'),
|
||||
),
|
||||
array(
|
||||
'id' => 'showall',
|
||||
'name' => $this->l('Show all'),
|
||||
),
|
||||
array(
|
||||
'id' => 'hideall',
|
||||
'name' => $this->l('Hide all'),
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'active_accordion',
|
||||
'label' => $this->l('Active Accordion'),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'active_type_sub active_type-set',
|
||||
),
|
||||
);
|
||||
}
|
||||
return $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* overide in tabs module
|
||||
*/
|
||||
public function adminContent($atts, $content = null, $tag_name = null, $is_gen_html = null)
|
||||
{
|
||||
$this->preparaAdminContent($atts, $tag_name);
|
||||
if ($is_gen_html) {
|
||||
$assign = array();
|
||||
$w_info = $this->getInfo();
|
||||
$w_info['name'] = $this->name;
|
||||
if ($tag_name == 'ApAccordion') {
|
||||
$assign['isSubTab'] = 1;
|
||||
$w_info['name'] = 'ApAccordion';
|
||||
} else {
|
||||
preg_match_all('/ parent_id="([^\"]+)"{0,1}/i', $content, $matches, PREG_OFFSET_CAPTURE);
|
||||
if (isset($matches['1']['0']['0'])) {
|
||||
$atts['id'] = $matches['1']['0']['0'];
|
||||
}
|
||||
}
|
||||
$assign['formAtts'] = $atts;
|
||||
$assign['apInfo'] = $w_info;
|
||||
$assign['apContent'] = ApShortCodesBuilder::doShortcode($content);
|
||||
$controller = new AdminApPageBuilderShortcodesController();
|
||||
return $controller->adminContent($assign, $this->name.'.tpl');
|
||||
} else {
|
||||
ApShortCodesBuilder::doShortcode($content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* overide in tabs module
|
||||
*/
|
||||
public function fontContent($atts, $content = null, $tag_name = null, $is_gen_html = null)
|
||||
{
|
||||
$is_active = $this->isWidgetActive(array('formAtts' => $atts));
|
||||
if (!$is_active) {
|
||||
return '';
|
||||
}
|
||||
|
||||
foreach ($atts as $key => $val) {
|
||||
if (strpos($key, 'content') !== false || strpos($key, 'link') !== false || strpos($key, 'url') !== false || strpos($key, 'alt') !== false || strpos($key, 'tit') !== false || strpos($key, 'name') !== false || strpos($key, 'desc') !== false || strpos($key, 'itemscustom') !== false) {
|
||||
$atts[$key] = str_replace($this->str_search, $this->str_relace_html, $val);
|
||||
if (strpos($atts[$key], '_AP_IMG_DIR') !== false) {
|
||||
// validate module
|
||||
$atts[$key] = str_replace('_AP_IMG_DIR/', $this->theme_img_module, $atts[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// validate module
|
||||
unset($is_gen_html);
|
||||
$assign = $w_info = array();
|
||||
$w_info['name'] = $this->name;
|
||||
if ($tag_name == 'ApAccordion') {
|
||||
$assign['isSubTab'] = 1;
|
||||
$w_info['name'] = 'ApAccordion';
|
||||
$assign['isWrapper'] = 0;
|
||||
} else {
|
||||
//DONGND:: check correct wrapper ApAccordion
|
||||
$assign['isWrapper'] = 1;
|
||||
preg_match_all('/ parent_id="([^\"]+)"{0,1}/i', $content, $matches, PREG_OFFSET_CAPTURE);
|
||||
if (isset($matches['1']['0']['0'])) {
|
||||
$atts['id'] = $matches['1']['0']['0'];
|
||||
}
|
||||
|
||||
if (!isset($atts['active_accordion'])) {
|
||||
$active_tab = 0;
|
||||
// validate module
|
||||
unset($active_tab);
|
||||
} else {
|
||||
# SET ACTIVE
|
||||
if (isset($atts['title']) && !empty($atts['title'])) {
|
||||
$atts['active_accordion'] = $atts['active_accordion'] + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
$content = ApShortCodesBuilder::doShortcode($content);
|
||||
$assign['apContent'] = $content;
|
||||
$assign['formAtts'] = $atts;
|
||||
$module = APPageBuilder::getInstance();
|
||||
return $module->fontContent($assign, $this->name.'.tpl');
|
||||
}
|
||||
}
|
||||
459
modules/appagebuilder/classes/shortcodes/ApAjaxTabs.php
Normal file
459
modules/appagebuilder/classes/shortcodes/ApAjaxTabs.php
Normal file
@@ -0,0 +1,459 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApAjaxTabs extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApAjaxTabs';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Ajax Tabs'), 'position' => 4,
|
||||
'desc' => $this->l('You can put widget in tab content will load in ajax'),
|
||||
'icon_class' => 'icon-html5', 'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList($sub_tab = 0)
|
||||
{
|
||||
$selected_categories = array();
|
||||
if (Tools::getIsset('categorybox')) {
|
||||
$category_box = Tools::getValue('categorybox');
|
||||
$selected_categories = explode(',', $category_box);
|
||||
}
|
||||
$id_root_category = Context::getContext()->shop->getCategory();
|
||||
Context::getContext()->smarty->assign('path_image', apPageHelper::getImgThemeUrl());
|
||||
$href = Context::getContext()->link->getAdminLink('AdminApPageBuilderImages').'&ajax=1&action=manageimage&imgDir=images';
|
||||
if (Tools::getIsset('subTab') || $sub_tab) {
|
||||
$input = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'lang' => 'true',
|
||||
'values' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'id',
|
||||
'label' => $this->l('ID Tab'),
|
||||
'values' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'css_class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'values' => '',
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Image'),
|
||||
'type' => 'selectImg',
|
||||
'href' => $href,
|
||||
'name' => 'image',
|
||||
'lang' => false,
|
||||
'show_image' => true,
|
||||
),
|
||||
);
|
||||
$this->name = 'ap_sub_tabs';
|
||||
} else {
|
||||
$input = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Select Type'),
|
||||
'name' => 'tab_type',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'tabs-top',
|
||||
'name' => $this->l('Tabs Top'),
|
||||
),
|
||||
array(
|
||||
'id' => 'tabs-below',
|
||||
'name' => $this->l('Tabs below'),
|
||||
),
|
||||
array(
|
||||
'id' => 'tabs-left',
|
||||
'name' => $this->l('Tabs Left'),
|
||||
),
|
||||
array(
|
||||
'id' => 'tabs-right',
|
||||
'name' => $this->l('Tabs Right'),
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Display Tab Title In Mobile'),
|
||||
'name' => 'tab_mobile_type',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'default',
|
||||
'name' => $this->l('Default Like Desktop'),
|
||||
),
|
||||
array(
|
||||
'id' => 'tabs-dropdown',
|
||||
'name' => $this->l('Dropdown'),
|
||||
),
|
||||
array(
|
||||
'id' => 'tabs-accordion',
|
||||
'name' => $this->l('Accordion'),
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'active_tab',
|
||||
'label' => $this->l('Active Tab'),
|
||||
'default' => '1',
|
||||
'desc' => $this->l('Input position(number) to show tab. If Blank, all tab default is inactive.'),
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Use Fade effect'),
|
||||
'name' => 'fade_effect',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('To make tabs fade in.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
),
|
||||
array(
|
||||
'type' => 'categories',
|
||||
'label' => $this->l('Select Category to show filter in tab (only run if tab content is product list)'),
|
||||
'name' => 'categorybox',
|
||||
'desc' => $this->l('You can select one or more, if not select we will not search by category'),
|
||||
'tree' => array(
|
||||
'root_category' => $id_root_category,
|
||||
'use_search' => false,
|
||||
'id' => 'categorybox',
|
||||
'use_checkbox' => true,
|
||||
'selected_categories' => $selected_categories,
|
||||
),
|
||||
'form_group_class' => 'value_by_categories',
|
||||
),
|
||||
);
|
||||
}
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function endRenderForm()
|
||||
{
|
||||
$this->helper->module = new $this->module_name();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overide in tabs module
|
||||
* @param type $atts
|
||||
* @param type $content
|
||||
* @param type $tag_name
|
||||
* @param type $is_gen_html
|
||||
* @return type
|
||||
*/
|
||||
public function adminContent($atts, $content = null, $tag_name = null, $is_gen_html = null)
|
||||
{
|
||||
$this->preparaAdminContent($atts, $tag_name);
|
||||
if ($is_gen_html) {
|
||||
$assign = array();
|
||||
$assign['formAtts'] = $atts;
|
||||
$w_info = $this->getInfo();
|
||||
$w_info['name'] = $this->name;
|
||||
$assign['apInfo'] = $w_info;
|
||||
if ($tag_name == 'ApAjaxTab') {
|
||||
$assign['tabID'] = $atts['id'];
|
||||
$assign['isSubTab'] = 1;
|
||||
$w_info['name'] = 'ApAjaxTab';
|
||||
} else {
|
||||
preg_match_all('/ApAjaxTab form_id="([^\"]+)" id\=\"([^\"]+)\" css_class\=\"([^\"]+){0,1}\" title\=\"([^\"]+)\"{0,1}/i', $content, $matches, PREG_OFFSET_CAPTURE);
|
||||
$sub_tab_content = array();
|
||||
$len = count($matches[0]);
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$title = $matches[4][$i][0];
|
||||
$title = str_replace($this->str_search, $this->str_relace_html, $title);
|
||||
$form_id = $matches[1][$i][0];
|
||||
$sub_tab_content[$form_id] = array(
|
||||
'form_id' => $form_id,
|
||||
'id' => $matches[2][$i][0],
|
||||
'css_class' => $matches[3][$i][0],
|
||||
'title' => $title,
|
||||
);
|
||||
}
|
||||
// validate module
|
||||
$pattern = '/ApAjaxTab form_id="([^\"]+)" id\=\"([^\"]+)\" css_class\=\"([^\"]+){0,1}\" ';
|
||||
$pattern .= 'override_folder\=\"([^\"]+){0,1}\" title\=\"([^\"]+)\"{0,1}/i';
|
||||
preg_match_all($pattern, $content, $matches2, PREG_OFFSET_CAPTURE);
|
||||
$sub_tab_content2 = array();
|
||||
$len2 = count($matches2[0]);
|
||||
for ($i = 0; $i < $len2; $i++) {
|
||||
$title2 = $matches2[5][$i][0];
|
||||
$title2 = str_replace($this->str_search, $this->str_relace_html, $title2);
|
||||
$form_id2 = $matches2[1][$i][0];
|
||||
$sub_tab_content2[$form_id2] = array(
|
||||
'form_id' => $form_id2,
|
||||
'id' => $matches2[2][$i][0],
|
||||
'css_class' => $matches2[3][$i][0],
|
||||
'title' => $title2,
|
||||
);
|
||||
}
|
||||
|
||||
$pattern = '/ApAjaxTab form_id="([^\"]+)" id\=\"([^\"]+)\" css_class\=\"([^\"]+){0,1}\" image\=\"([^\"]+){0,1}\" override_folder\=\"([^\"]+){0,1}\" title\=\"([^\"]+){0,1}\" sub_title\=\"([^\"]+){0,1}/i';
|
||||
preg_match_all($pattern, $content, $matches3, PREG_OFFSET_CAPTURE);
|
||||
$sub_tab_content3 = array();
|
||||
$len3 = count($matches3[0]);
|
||||
for ($i = 0; $i < $len3; $i++) {
|
||||
$title3 = isset($matches3[6][$i][0]) ? $matches3[6][$i][0] : '';
|
||||
$title3 = str_replace($this->str_search, $this->str_relace_html, $title3);
|
||||
$sub_title = isset($matches3[7][$i][0]) ? $matches3[7][$i][0] : '';
|
||||
$sub_title = str_replace($this->str_search, $this->str_relace_html, $sub_title);
|
||||
|
||||
$form_id3 = $matches3[1][$i][0];
|
||||
$sub_tab_content3[$form_id3] = array(
|
||||
'form_id' => $form_id3,
|
||||
'id' => $matches3[2][$i][0],
|
||||
'css_class' => $matches3[3][$i][0],
|
||||
'title' => $title3,
|
||||
'sub_title' => $sub_title,
|
||||
'count' => $i,
|
||||
);
|
||||
}
|
||||
$assign['subTabContent'] = array_merge($sub_tab_content, $sub_tab_content2, $sub_tab_content3);
|
||||
}
|
||||
$assign['apContent'] = ApShortCodesBuilder::doShortcode($content);
|
||||
$controller = new AdminApPageBuilderShortcodesController();
|
||||
return $controller->adminContent($assign, $this->name.'.tpl');
|
||||
} else {
|
||||
ApShortCodesBuilder::doShortcode($content);
|
||||
}
|
||||
//preg_match_all( '/ap_tab id="([^\"]+)"(\id\=\"([^\"]+)\"){0,1}/i', $content, $matches, PREG_OFFSET_CAPTURE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Overide in tabs module
|
||||
* @param type $atts
|
||||
* @param type $content
|
||||
* @param type $tag_name
|
||||
* @param type $is_gen_html
|
||||
* @return type
|
||||
*/
|
||||
public function fontContent($atts, $content = null, $tag_name = null, $is_gen_html = null)
|
||||
{
|
||||
$is_active = $this->isWidgetActive(array('formAtts' => $atts));
|
||||
if (!$is_active) {
|
||||
return '';
|
||||
}
|
||||
if (isset($atts['tab_mobile_type']) && $atts['tab_mobile_type'] == 'tabs-accordion') {
|
||||
if (!Configuration::get('APPAGEBUILDER_LOAD_TABCOLLAPSE')) {
|
||||
$atts['lib_has_error'] = true;
|
||||
$atts['lib_error'] = 'You are using function convert Tab to Accordion in Mobile. Please enable to load this Library';
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($atts as $key => $val) {
|
||||
if (strpos($key, 'content') !== false || strpos($key, 'link') !== false || strpos($key, 'url') !== false || strpos($key, 'alt') !== false || strpos($key, 'tit') !== false || strpos($key, 'name') !== false || strpos($key, 'desc') !== false || strpos($key, 'itemscustom') !== false) {
|
||||
$atts[$key] = str_replace($this->str_search, $this->str_relace_html, $val);
|
||||
if (strpos($atts[$key], '_AP_IMG_DIR') !== false) {
|
||||
// validate module
|
||||
$atts[$key] = str_replace('_AP_IMG_DIR/', $this->theme_img_module, $atts[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// validate module
|
||||
unset($is_gen_html);
|
||||
$assign = array();
|
||||
|
||||
if ($tag_name == 'ApAjaxTabs') {
|
||||
// ApAjaxTabs
|
||||
$assign['tab_name'] = 'ApAjaxTabs';
|
||||
preg_match_all('/ApAjaxTab form_id="([^\"]+)" id\=\"([^\"]+)\" css_class\=\"([^\"]+){0,1}\" image\=\"([^\"]+)\" title\=\"([^\"]+)\"{0,1}/i', $content, $matches, PREG_OFFSET_CAPTURE);
|
||||
$sub_tab_content = array();
|
||||
$len = count($matches[0]);
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$title = $matches[4][$i][0];
|
||||
$title = str_replace($this->str_search, $this->str_relace_html, $title);
|
||||
$sub_tab_content[] = array(
|
||||
'form_id' => $matches[1][$i][0],
|
||||
'id' => $matches[2][$i][0],
|
||||
'css_class' => $matches[3][$i][0],
|
||||
'title' => $title,
|
||||
);
|
||||
}
|
||||
$pattern = '/ApAjaxTab form_id="([^\"]+)" id\=\"([^\"]+)\" css_class\=\"([^\"]+){0,1}\" override_folder\=\"([^\"]+){0,1}\" title\=\"([^\"]+)\"{0,1}/i';
|
||||
preg_match_all($pattern, $content, $matches2, PREG_OFFSET_CAPTURE);
|
||||
$sub_tab_content2 = array();
|
||||
$len2 = count($matches2[0]);
|
||||
for ($i = 0; $i < $len2; $i++) {
|
||||
$title2 = $matches2[5][$i][0];
|
||||
$title2 = str_replace($this->str_search, $this->str_relace_html, $title2);
|
||||
$form_id2 = $matches2[1][$i][0];
|
||||
$sub_tab_content2[$form_id2] = array(
|
||||
'form_id' => $form_id2,
|
||||
'id' => $matches2[2][$i][0],
|
||||
'css_class' => $matches2[3][$i][0],
|
||||
'title' => $title2,
|
||||
);
|
||||
}
|
||||
|
||||
$pattern = '/ApAjaxTab form_id="([^\"]+)" id\=\"([^\"]+)\" css_class\=\"([^\"]+){0,1}\" image\=\"([^\"]+){0,1}\" override_folder\=\"([^\"]+){0,1}\" title\=\"([^\"]+){0,1}\" sub_title\=\"([^\"]+){0,1}/i';
|
||||
preg_match_all($pattern, $content, $matches3, PREG_OFFSET_CAPTURE);
|
||||
$sub_tab_content3 = array();
|
||||
$len3 = count($matches3[0]);
|
||||
|
||||
for ($i = 0; $i < $len3; $i++) {
|
||||
$title3 = isset($matches3[6][$i][0]) ? $matches3[6][$i][0] : '';
|
||||
$title3 = str_replace($this->str_search, $this->str_relace_html, $title3);
|
||||
$sub_title = isset($matches3[7][$i][0]) ? $matches3[7][$i][0] : '';
|
||||
$sub_title = str_replace($this->str_search, $this->str_relace_html, $sub_title);
|
||||
|
||||
$form_id3 = $matches3[1][$i][0];
|
||||
$sub_tab_content3[$form_id3] = array(
|
||||
'form_id' => $form_id3,
|
||||
'id' => $matches3[2][$i][0],
|
||||
'css_class' => $matches3[3][$i][0],
|
||||
'title' => $title3,
|
||||
'image' => $matches3[4][$i][0],
|
||||
'sub_title' => $sub_title,
|
||||
'nghia' => $i
|
||||
);
|
||||
}
|
||||
if (isset($atts['active_tab']) && $atts['active_tab'] != '') {
|
||||
$tab_count = substr_count($content, '[ApAjaxTab');
|
||||
$tab_active = (int)$atts['active_tab'];
|
||||
|
||||
if (($tab_active <= $tab_count) && ($tab_active >= 1)) {
|
||||
# ACTIVE TAB
|
||||
$atts['active_tab'] = $tab_active - 1;
|
||||
} elseif ($tab_active > $tab_count) {
|
||||
# ACTIVE LAST TAB
|
||||
$atts['active_tab'] = $tab_count - 1;
|
||||
} else {
|
||||
# ACTIVE FIRST TAB
|
||||
$atts['active_tab'] = 0;
|
||||
}
|
||||
} else {
|
||||
# BLANK
|
||||
$atts['active_tab'] = -1;
|
||||
}
|
||||
|
||||
$assign['subTabContent'] = array_merge($sub_tab_content, $sub_tab_content2, $sub_tab_content3);
|
||||
$atts['id'] = 'tab_'.ApPageSetting::getRandomNumber();
|
||||
$atts['class'] = ((isset($atts['class']) && $atts['class']) ? $atts['class'].' ' : '').(isset($atts['tab_type']) ? $atts['tab_type'] : '');
|
||||
$module = APPageBuilder::getInstance();
|
||||
|
||||
if (isset($atts['categorybox']) && $atts['categorybox']) {
|
||||
$atts['categorylist'] = $module->getCategories($atts['categorybox']);
|
||||
}
|
||||
$assign['formAtts'] = $atts;
|
||||
$assign['path'] = apPageHelper::getImgThemeUrl();
|
||||
$array = explode('[ApAjaxTab', $content);
|
||||
for ($i=1; $i<count($array); $i++) {
|
||||
if (($i-1) == $atts['active_tab']) {
|
||||
$array[$i] = ' active=1'.$array[$i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$content = implode('[ApAjaxTab', $array);
|
||||
$assign['apContent'] = ApShortCodesBuilder::doShortcode($content);
|
||||
return $module->fontContent($assign, $this->name.'.tpl');
|
||||
} else {
|
||||
// ApAjaxTab
|
||||
$assign['tabID'] = $atts['id'];
|
||||
$assign['tab_name'] = 'ApAjaxTab';
|
||||
$assign['isSubTab'] = 1;
|
||||
|
||||
$assign['formAtts'] = $atts;
|
||||
$assign['formAtts']['content'] = $content;
|
||||
$module = APPageBuilder::getInstance();
|
||||
if (isset($atts['active']) && $atts['active']) {
|
||||
$assign['apshortcode'] = urlencode($content);
|
||||
$assign['path'] = apPageHelper::getImgThemeUrl();
|
||||
$assign['apContent'] = ApShortCodesBuilder::doShortcode($content);
|
||||
} else {
|
||||
$assign['apContent'] = urlencode($content);
|
||||
}
|
||||
return $module->fontContent($assign, $this->name.'.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Override
|
||||
* Fixed css_class is empty -> cant set to $apHomeBuilder.process (json) in javascript
|
||||
*/
|
||||
public function preparaAdminContent($atts, $tag_name = null)
|
||||
{
|
||||
if ($tag_name == null) {
|
||||
$tag_name = $this->name;
|
||||
}
|
||||
if (is_array($atts)) {
|
||||
if (!isset(ApShortCodesBuilder::$shortcode_lang[$tag_name])) {
|
||||
$inputs = $this->getConfigList();
|
||||
$lang_field = array();
|
||||
foreach ($inputs as $input) {
|
||||
if (isset($input['lang']) && $input['lang']) {
|
||||
$lang_field[] = $input['name'];
|
||||
}
|
||||
}
|
||||
ApShortCodesBuilder::$shortcode_lang[$tag_name] = $lang_field;
|
||||
} else {
|
||||
$lang_field = ApShortCodesBuilder::$shortcode_lang[$tag_name];
|
||||
}
|
||||
foreach ($atts as $key => $val) {
|
||||
if ($lang_field && in_array($key, $lang_field)) {
|
||||
$key .= '_'.ApShortCodesBuilder::$lang_id;
|
||||
}
|
||||
if (!isset(ApShortCodesBuilder::$data_form[$atts['form_id']][$key])) {
|
||||
ApShortCodesBuilder::$data_form[$atts['form_id']][$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
99
modules/appagebuilder/classes/shortcodes/ApAlert.php
Normal file
99
modules/appagebuilder/classes/shortcodes/ApAlert.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApAlert extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApAlert';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Alert'),
|
||||
'position' => 5,
|
||||
'desc' => $this->l('Alert Message box'),
|
||||
'icon_class' => 'icon-info-sign',
|
||||
'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$types = array(
|
||||
array(
|
||||
'value' => 'alert-success',
|
||||
'text' => $this->l('Alert Success')
|
||||
),
|
||||
array(
|
||||
'value' => 'alert-info',
|
||||
'text' => $this->l('Alert Info')
|
||||
),
|
||||
array(
|
||||
'value' => 'alert-warning',
|
||||
'text' => $this->l('Alert Warning')
|
||||
),
|
||||
array(
|
||||
'value' => 'alert-danger',
|
||||
'text' => $this->l('Alert Danger')
|
||||
)
|
||||
);
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'lang' => true,
|
||||
'label' => $this->l('Content'),
|
||||
'name' => 'content_html',
|
||||
'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')
|
||||
)
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
}
|
||||
1030
modules/appagebuilder/classes/shortcodes/ApBlockCarousel.php
Normal file
1030
modules/appagebuilder/classes/shortcodes/ApBlockCarousel.php
Normal file
File diff suppressed because it is too large
Load Diff
479
modules/appagebuilder/classes/shortcodes/ApBlockLink.php
Normal file
479
modules/appagebuilder/classes/shortcodes/ApBlockLink.php
Normal file
@@ -0,0 +1,479 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApBlockLink extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApBlockLink';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Block Link'),
|
||||
'position' => 5,
|
||||
'desc' => $this->l('Create List Block Links'),
|
||||
'icon_class' => 'icon icon-list',
|
||||
'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$types = array(
|
||||
array(
|
||||
'value' => 'link-url',
|
||||
'text' => $this->l('URL')
|
||||
),
|
||||
array(
|
||||
'value' => 'link-category',
|
||||
'text' => $this->l('Category')
|
||||
),
|
||||
array(
|
||||
'value' => 'link-product',
|
||||
'text' => $this->l('Product')
|
||||
),
|
||||
array(
|
||||
'value' => 'link-manufacture',
|
||||
'text' => $this->l('Manufacture')
|
||||
),
|
||||
array(
|
||||
'value' => 'link-supplier',
|
||||
'text' => $this->l('Supplier')
|
||||
),
|
||||
array(
|
||||
'value' => 'link-cms',
|
||||
'text' => $this->l('CMS')
|
||||
),
|
||||
array(
|
||||
'value' => 'link-page',
|
||||
'text' => $this->l('Page Controller')
|
||||
),
|
||||
);
|
||||
|
||||
$target = array(
|
||||
array(
|
||||
'value' => '_blank',
|
||||
'text' => $this->l('Blank ( New Tab)')
|
||||
),
|
||||
array(
|
||||
'value' => '_self',
|
||||
'text' => $this->l('Self ( Same Tab)')
|
||||
),
|
||||
array(
|
||||
'value' => '_parent',
|
||||
'text' => $this->l('Parent')
|
||||
),
|
||||
array(
|
||||
'value' => '_top',
|
||||
'text' => $this->l('Top')
|
||||
),
|
||||
);
|
||||
$accordion_type = array(
|
||||
array(
|
||||
'value' => 'full',
|
||||
'text' => $this->l('Always Full')
|
||||
),
|
||||
array(
|
||||
'value' => 'accordion',
|
||||
'text' => $this->l('Always Accordion')
|
||||
),
|
||||
array(
|
||||
'value' => 'accordion_small_screen',
|
||||
'text' => $this->l('Accordion at small screen')
|
||||
),
|
||||
);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
# $sqlFilter : NOT SHOW ROOT CATEOGRY, ONLY SHOW FROM HOME
|
||||
$list_categories = Category::getAllCategoriesName(null, Context::getContext()->language->id, true, null, true, ' AND c.id_parent != 0 ');
|
||||
$languages = Language::getLanguages(true, Context::getContext()->shop->id);
|
||||
|
||||
$languages = Language::getLanguages();
|
||||
$list_id_lang = array();
|
||||
foreach ($languages as $languages_val) {
|
||||
array_push($list_id_lang, $languages_val['id_lang']);
|
||||
}
|
||||
|
||||
// Get value with keys special
|
||||
$languages = Language::getLanguages(false);
|
||||
$config_val = array();
|
||||
|
||||
$list_field = Tools::getValue('list_field');
|
||||
$list_field = array_filter(explode(',', $list_field));
|
||||
foreach ($list_field as $field) {
|
||||
$key = $field;
|
||||
$config_val[$key] = str_replace($this->str_search, $this->str_relace_html_admin, Tools::getValue($key));
|
||||
}
|
||||
|
||||
$list_field_lang = Tools::getValue('list_field_lang');
|
||||
$list_field_lang = array_filter(explode(',', $list_field_lang));
|
||||
foreach ($languages as $lang) {
|
||||
foreach ($list_field_lang as $field) {
|
||||
$key = $field.'_'.$lang['id_lang'];
|
||||
$config_val[$key] = str_replace($this->str_search, $this->str_relace_html_admin, Tools::getValue($key));
|
||||
}
|
||||
}
|
||||
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<script>var listData = '.Tools::jsonEncode($config_val).';</script>',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<script>
|
||||
var totalLanguage = "'.count($languages).'";
|
||||
var list_id_lang = \''.Tools::jsonEncode($list_id_lang).'\';
|
||||
var remove_button_text = "'.$this->l('Remove Link').'";
|
||||
var duplicate_button_text = "'.$this->l('Duplicate Link').'";
|
||||
</script>',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'total_link',
|
||||
'default' => '0',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'list_id_link',
|
||||
'default' => '',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'list_field',
|
||||
'default' => '',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'list_field_lang',
|
||||
'default' => '',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'blockLink',
|
||||
'name' => 'title',
|
||||
'lang' => 'true',
|
||||
'label' => $this->l('Title'),
|
||||
'default' => '',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Widget Title'),
|
||||
'hint' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Widget Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Accordion Type'),
|
||||
'name' => 'accordion_type',
|
||||
'options' => array(
|
||||
'query' => $accordion_type,
|
||||
'id' => 'value',
|
||||
'name' => 'text' ),
|
||||
'default' => 'full',
|
||||
'hint' => $this->l('Select a Accordion Type'),
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<button type="button" class="add-new-link btn btn-default">
|
||||
<i class="process-icon-new"></i> '.$this->l('Add new link').'</button>',
|
||||
'form_group_class' => 'frm-add-new-link',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Title'),
|
||||
'name' => 'link_title',
|
||||
'lang' => true,
|
||||
'default' => '',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Target Type'),
|
||||
'name' => 'target_type',
|
||||
'options' => array(
|
||||
'query' => $target,
|
||||
'id' => 'value',
|
||||
'name' => 'text' ),
|
||||
'default' => '_self',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Link Type'),
|
||||
'name' => 'link_type',
|
||||
'options' => array(
|
||||
'query' => $types,
|
||||
'id' => 'value',
|
||||
'name' => 'text' ),
|
||||
'default' => 'link-url',
|
||||
'class' => 'form-action tmp',
|
||||
'hint' => $this->l('Select a link type'),
|
||||
'form_group_class' => 'parent-tmp hidden',
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('URL'),
|
||||
'name' => 'link_url',
|
||||
'lang' => true,
|
||||
'default' => '',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'link_type_sub link_type-link-url parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('CMS'),
|
||||
'name' => 'cmspage_id',
|
||||
'options' => array('query' => CMS::listCms(Context::getContext()->language->id, false, true),
|
||||
'id' => 'id_cms',
|
||||
'name' => 'meta_title'),
|
||||
'default' => '',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'link_type_sub link_type-link-cms parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Categories'),
|
||||
'name' => 'category_id',
|
||||
'options' => array('query' => $list_categories,
|
||||
'id' => 'id_category',
|
||||
'name' => 'name'),
|
||||
'default' => '',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'link_type_sub link_type-link-category parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Product ID'),
|
||||
'name' => 'product_id',
|
||||
'default' => '',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'link_type_sub link_type-link-product parent-tmp hidden',
|
||||
'hint' => $this->l('Enter a product id'),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Manufacture'),
|
||||
'name' => 'manufacture_id',
|
||||
'options' => array('query' => Manufacturer::getManufacturers(false, Context::getContext()->language->id, true),
|
||||
'id' => 'id_manufacturer',
|
||||
'name' => 'name'),
|
||||
'default' => '',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'link_type_sub link_type-link-manufacture parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Supplier'),
|
||||
'name' => 'supplier_id',
|
||||
'options' => array('query' => Supplier::getSuppliers(false, Context::getContext()->language->id, true),
|
||||
'id' => 'id_supplier',
|
||||
'name' => 'name'),
|
||||
'default' => '',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'link_type_sub link_type-link-supplier parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Page'),
|
||||
'name' => 'page_id',
|
||||
'options' => array('query' => $page_controller,
|
||||
'id' => 'link',
|
||||
'name' => 'name'),
|
||||
'default' => '',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'link_type_sub link_type-link-page parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Parameter of page'),
|
||||
'name' => 'page_param',
|
||||
'default' => '',
|
||||
'hint' => $this->l('Param on URL. Example var=100&var2=110&var3=120'),
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'link_type_sub link_type-link-page parent-tmp hidden',
|
||||
),
|
||||
);
|
||||
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function getConfigValue()
|
||||
{
|
||||
$config_val = parent::getConfigValue();
|
||||
$config_val['target_type'] = '_self';
|
||||
return $config_val;
|
||||
}
|
||||
|
||||
public function endRenderForm()
|
||||
{
|
||||
$this->helper->module = new $this->module_name();
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
unset($module);
|
||||
$formAtts = $assign['formAtts'];
|
||||
$formAtts['links'] = array();
|
||||
|
||||
if (!isset($formAtts['list_id_link'])) {
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Can not show this Blocklink. Please remove it and create new Blocklink in Appbuilder Profile.';
|
||||
return $assign;
|
||||
}
|
||||
$id_forms = $formAtts['list_id_link'];
|
||||
$id_forms = array_filter(explode(',', $id_forms));
|
||||
|
||||
foreach ($id_forms as $id_form) {
|
||||
$index = '_'.$id_form;
|
||||
$indexlang = $index.'_'.Context::getContext()->language->id;
|
||||
$link = array();
|
||||
switch ($formAtts['link_type'.$index]) {
|
||||
case 'link-url':
|
||||
if (isset($formAtts['link_title'.$indexlang]) && $formAtts['link_title'.$indexlang]) {
|
||||
$link['title'] = (isset($formAtts['link_title'.$indexlang]) && $formAtts['link_title'.$indexlang]) ? $formAtts['link_title'.$indexlang] : $formAtts['link_url'.$indexlang];
|
||||
$link['link'] = isset($formAtts['link_url'.$indexlang]) ? $formAtts['link_url'.$indexlang] : '';
|
||||
$link['target_type'] = isset($formAtts['target_type'.$index]) ? $formAtts['target_type'.$index] : '_self';
|
||||
$formAtts['links'][] = $link;
|
||||
}
|
||||
break;
|
||||
case 'link-category':
|
||||
if (isset($formAtts['category_id'.$index]) && $formAtts['category_id'.$index]) {
|
||||
$category = new Category((int)$formAtts['category_id'.$index], Context::getContext()->language->id, Context::getContext()->shop->id);
|
||||
$link['title'] = (isset($formAtts['link_title'.$indexlang]) && $formAtts['link_title'.$indexlang]) ? $formAtts['link_title'.$indexlang] : $category->name;
|
||||
$link['link'] = Context::getContext()->link->getCategoryLink($category);
|
||||
$link['target_type'] = isset($formAtts['target_type'.$index]) ? $formAtts['target_type'.$index] : '_self';
|
||||
$formAtts['links'][] = $link;
|
||||
}
|
||||
break;
|
||||
case 'link-product':
|
||||
$product_id = isset($formAtts['product_id'.$index]) ? (int)$formAtts['product_id'.$index] : 0;
|
||||
$product = new Product($product_id, true, Context::getContext()->language->id, Context::getContext()->shop->id);
|
||||
$link['title'] = (isset($formAtts['link_title'.$indexlang]) && $formAtts['link_title'.$indexlang]) ? $formAtts['link_title'.$indexlang] : $product->name;
|
||||
if ((int)$product->id > 0) {
|
||||
$link['link'] = Context::getContext()->link->getProductLink($product);
|
||||
} else {
|
||||
$link['link'] = '';
|
||||
}
|
||||
$link['target_type'] = isset($formAtts['target_type'.$index]) ? $formAtts['target_type'.$index] : '_self';
|
||||
$formAtts['links'][] = $link;
|
||||
break;
|
||||
case 'link-manufacture':
|
||||
if (isset($assign['formAtts']['manufacture_id'.$index]) && $assign['formAtts']['manufacture_id'.$index]) {
|
||||
$manufacture = new Manufacturer($assign['formAtts']['manufacture_id'.$index], Context::getContext()->language->id);
|
||||
$link['title'] = (isset($formAtts['link_title'.$indexlang]) && $formAtts['link_title'.$indexlang]) ? $formAtts['link_title'.$indexlang] : $manufacture->name;
|
||||
$link['link'] = Context::getContext()->link->getManufacturerLink((int)$manufacture->id, $manufacture->link_rewrite, Context::getContext()->language->id);
|
||||
$link['target_type'] = isset($formAtts['target_type'.$index]) ? $formAtts['target_type'.$index] : '_self';
|
||||
$formAtts['links'][] = $link;
|
||||
}
|
||||
break;
|
||||
case 'link-supplier':
|
||||
$supplier = new Supplier($assign['formAtts']['supplier_id'], Context::getContext()->language->id);
|
||||
$link['title'] = (isset($formAtts['link_title'.$indexlang]) && $formAtts['link_title'.$indexlang]) ? $formAtts['link_title'.$indexlang] : $supplier->name;
|
||||
$link['link'] = Context::getContext()->link->getSupplierLink((int)$supplier->id, $supplier->link_rewrite, Context::getContext()->language->id);
|
||||
$link['target_type'] = isset($formAtts['target_type'.$index]) ? $formAtts['target_type'.$index] : '_self';
|
||||
$formAtts['links'][] = $link;
|
||||
break;
|
||||
case 'link-cms':
|
||||
if (isset($formAtts['cmspage_id'.$index]) && $formAtts['cmspage_id'.$index]) {
|
||||
$cms = new CMS((int)$formAtts['cmspage_id'.$index], Context::getContext()->language->id, Context::getContext()->shop->id);
|
||||
$link['title'] = (isset($formAtts['link_title'.$indexlang]) && $formAtts['link_title'.$indexlang]) ? $formAtts['link_title'.$indexlang] : $cms->meta_title;
|
||||
$link['link'] = Context::getContext()->link->getCMSLink($cms, $cms->link_rewrite, (bool)Configuration::get('PS_SSL_ENABLED'));
|
||||
$link['target_type'] = isset($formAtts['target_type'.$index]) ? $formAtts['target_type'.$index] : '_self';
|
||||
$formAtts['links'][] = $link;
|
||||
}
|
||||
break;
|
||||
case 'link-page':
|
||||
$param = isset($formAtts['page_param'.$index]) ? $formAtts['page_param'.$index] : '';
|
||||
// $front_link = $this->getFronTLink($formAtts['page_id'.$index]);
|
||||
// if ($front_link != false) {
|
||||
// $formAtts['page_id'.$index] = $front_link;
|
||||
// }
|
||||
$link['link'] = Context::getContext()->link->getPageLink($formAtts['page_id'.$index], null, Context::getContext()->language->id, $param);
|
||||
$link['title'] = (isset($formAtts['link_title'.$indexlang]) && $formAtts['link_title'.$indexlang]) ? $formAtts['link_title'.$indexlang] : Tools::ucfirst($formAtts['page_id'.$index]);
|
||||
$link['target_type'] = isset($formAtts['target_type'.$index]) ? $formAtts['target_type'.$index] : '_self';
|
||||
$formAtts['links'][] = $link;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$assign['formAtts']['links'] = $formAtts['links'];
|
||||
return $assign;
|
||||
}
|
||||
|
||||
public function getFronTLink($controller_param)
|
||||
{
|
||||
$controllers = Dispatcher::getControllers(array(_PS_FRONT_CONTROLLER_DIR_, _PS_OVERRIDE_DIR_.'controllers/front/'));
|
||||
$controllers['index'] = 'IndexController';
|
||||
if (isset($controllers['auth'])) {
|
||||
$controllers['authentication'] = $controllers['auth'];
|
||||
}
|
||||
if (isset($controllers['contact'])) {
|
||||
$controllers['contactform'] = $controllers['contact'];
|
||||
}
|
||||
if (!isset($controllers[Tools::strtolower($controller_param)])) {
|
||||
return false;
|
||||
}
|
||||
$controller_class = $controllers[Tools::strtolower($controller_param)];
|
||||
$controller_obj = Controller::getController($controller_class);
|
||||
return $controller_obj->php_self;
|
||||
}
|
||||
}
|
||||
1158
modules/appagebuilder/classes/shortcodes/ApBlog.php
Normal file
1158
modules/appagebuilder/classes/shortcodes/ApBlog.php
Normal file
File diff suppressed because it is too large
Load Diff
250
modules/appagebuilder/classes/shortcodes/ApButton.php
Normal file
250
modules/appagebuilder/classes/shortcodes/ApButton.php
Normal file
@@ -0,0 +1,250 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApButton extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApButton';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Buttons'),
|
||||
'position' => 5,
|
||||
'desc' => $this->l('Custom color, size and create a link for button'),
|
||||
'icon_class' => 'icon-edit',
|
||||
'tag' => 'content control');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'name',
|
||||
'label' => $this->l('Name'),
|
||||
'lang' => 'true',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => 'Button'
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Use Outline Button'),
|
||||
'class' => 'form-action',
|
||||
'name' => 'use_outline_button',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'no', 'name' => $this->l('No')),
|
||||
array('id' => 'yes', 'name' => $this->l('Yes')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => '0'
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Button Type'),
|
||||
'name' => 'button_type',
|
||||
'options' => array('query' => $this->getDataButtonType(),
|
||||
'id' => 'value',
|
||||
'name' => 'text'),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'use_outline_button_sub use_outline_button-no',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Button Type'),
|
||||
'name' => 'outline_button_type',
|
||||
'options' => array('query' => $this->getDataOutlineButtonType(),
|
||||
'id' => 'value',
|
||||
'name' => 'text'),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'use_outline_button_sub use_outline_button-yes',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Button Size'),
|
||||
'name' => 'button_size',
|
||||
'options' => array('query' => $this->getDataSize(),
|
||||
'id' => 'value',
|
||||
'name' => 'text'),
|
||||
'default' => 'btn-lg',
|
||||
'desc' => $this->l('Select a button size')
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Is Block'),
|
||||
'name' => 'is_block',
|
||||
'desc' => $this->l('If is block, will display width is full 100%'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0'
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<hr/>'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => $this->l('You can add code in ').'<a href="'.self::getUrlProfileEdit().'" target="_blank">here</a>'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'url',
|
||||
'label' => $this->l('Url'),
|
||||
'desc' => $this->l('Exmaple: http://prestashop.com'),
|
||||
'lang' => 'true',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Open new window'),
|
||||
'name' => 'is_blank',
|
||||
'desc' => $this->l('If is Yes, will open new tab with url when click'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0'
|
||||
),
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
|
||||
if ($assign['formAtts']['use_outline_button'] == 'yes') {
|
||||
$assign['formAtts']['button_type'] = $assign['formAtts']['outline_button_type'];
|
||||
}
|
||||
return $assign;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private function getDataButtonType()
|
||||
{
|
||||
$data = array(
|
||||
array(
|
||||
'value' => 'btn-primary',
|
||||
'text' => $this->l('Button Primary')
|
||||
),
|
||||
array(
|
||||
'value' => 'btn-secondary',
|
||||
'text' => $this->l('Button Secondary')
|
||||
),
|
||||
array(
|
||||
'value' => 'btn-success',
|
||||
'text' => $this->l('Button Success')
|
||||
),
|
||||
array(
|
||||
'value' => 'btn-info',
|
||||
'text' => $this->l('Button Info')
|
||||
),
|
||||
array(
|
||||
'value' => 'btn-warning',
|
||||
'text' => $this->l('Button Warning')
|
||||
),
|
||||
array(
|
||||
'value' => 'btn-danger',
|
||||
'text' => $this->l('Button Danger')
|
||||
),
|
||||
array(
|
||||
'value' => 'btn-link',
|
||||
'text' => $this->l('Button Link')
|
||||
)
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getDataOutlineButtonType()
|
||||
{
|
||||
$data = array(
|
||||
array(
|
||||
'value' => 'btn-outline-primary',
|
||||
'text' => $this->l('Button Outline Primary')
|
||||
),
|
||||
array(
|
||||
'value' => 'btn-outline-secondary',
|
||||
'text' => $this->l('Button Outline Secondary')
|
||||
),
|
||||
array(
|
||||
'value' => 'btn-outline-success',
|
||||
'text' => $this->l('Button Outline Success')
|
||||
),
|
||||
array(
|
||||
'value' => 'btn-outline-info',
|
||||
'text' => $this->l('Button Outline Info')
|
||||
),
|
||||
array(
|
||||
'value' => 'btn-outline-warning',
|
||||
'text' => $this->l('Button Outline Warning')
|
||||
),
|
||||
array(
|
||||
'value' => 'btn-outline-danger',
|
||||
'text' => $this->l('Button Outline Danger')
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getDataSize()
|
||||
{
|
||||
$data = array(
|
||||
array(
|
||||
'value' => 'btn-lg',
|
||||
'text' => $this->l('Size Large')
|
||||
),
|
||||
array(
|
||||
'value' => 'btn-sm',
|
||||
'text' => $this->l('Size Small')
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
314
modules/appagebuilder/classes/shortcodes/ApCategoryImage.php
Normal file
314
modules/appagebuilder/classes/shortcodes/ApCategoryImage.php
Normal file
@@ -0,0 +1,314 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2015 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApCategoryImage extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApCategoryImage';
|
||||
public $for_module = 'manage';
|
||||
public $module_name = 'appagebuilder';
|
||||
public $level = 4;
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Images of categories'),
|
||||
'position' => 5,
|
||||
'desc' => $this->l('Choosing images for categories'),
|
||||
'icon_class' => 'icon-picture',
|
||||
'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$root = Category::getRootCategory();
|
||||
$selected_cat = array();
|
||||
$selected_cates = '';
|
||||
$selected_images = '';
|
||||
// $image_list = $this->getImages();
|
||||
$image_list = array();
|
||||
if (Tools::getIsset('categorybox')) {
|
||||
$category_box = Tools::getValue('categorybox');
|
||||
$selected_cat = explode(',', $category_box);
|
||||
}
|
||||
if (Tools::getIsset('category_img')) {
|
||||
$selected_images = str_replace($this->str_search, $this->str_relace_html, Tools::getValue('category_img'));
|
||||
}
|
||||
if (Tools::getIsset('selected_cates')) {
|
||||
$selected_cates = Tools::getValue('selected_cates');
|
||||
}
|
||||
$tree = new HelperTreeCategories('categorybox', 'All Categories');
|
||||
// fix tree category with ps version 1.6.1 or newer
|
||||
if (version_compare(_PS_VERSION_, '1.6.1', '>=')) {
|
||||
$tree->setRootCategory($root->id)->setUseCheckBox(true)->setFullTree(true)->setSelectedCategories($selected_cat)->setInputName('categorybox');
|
||||
} else {
|
||||
$tree->setRootCategory($root->id)->setUseCheckBox(true)->setSelectedCategories($selected_cat)->setInputName('categorybox');
|
||||
}
|
||||
$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')
|
||||
)
|
||||
);
|
||||
$path_image = apPageHelper::getImgThemeUrl('icon');
|
||||
Context::getContext()->smarty->assign('path_image', $path_image);
|
||||
$href = Context::getContext()->link->getAdminLink('AdminApPageBuilderImages').'&ajax=1&action=manageimage&imgDir=icon';
|
||||
$tree_html = $tree->render();
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'img_cat',
|
||||
'name' => 'img_cat',
|
||||
'imageList' => $image_list,
|
||||
'selected_images' => $selected_images,
|
||||
'selected_cates' => $selected_cates,
|
||||
'lang' => true,
|
||||
'tree' => $tree_html,
|
||||
'href_image' => $href,
|
||||
'path_image' => $path_image,
|
||||
'default' => '',
|
||||
),
|
||||
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',
|
||||
)
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function endRenderForm()
|
||||
{
|
||||
$this->helper->module = new $this->module_name();
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
$form_atts = $assign['formAtts'];
|
||||
$images = array();
|
||||
if (isset($form_atts['category_img']) && $form_atts['category_img']) {
|
||||
$selected_images = str_replace($this->str_search, $this->str_relace_html, $form_atts['category_img']);
|
||||
$images = Tools::jsonDecode($selected_images, true);
|
||||
}
|
||||
$sql_filter = '';
|
||||
$sql_sort = '';
|
||||
if (isset($form_atts['orderby']) && $form_atts['orderby']) {
|
||||
if ($form_atts['orderby'] == 'depth') {
|
||||
$sql_sort = ' ORDER BY c.`level_depth` ASC';
|
||||
}
|
||||
if ($form_atts['orderby'] == 'position') {
|
||||
$sql_sort = ' ORDER BY c.`level_depth` ASC, category_shop.`position` ASC';
|
||||
}
|
||||
if ($form_atts['orderby'] == 'name') {
|
||||
$sql_sort = ' ORDER BY c.`level_depth` ASC, cl.`name` ASC';
|
||||
}
|
||||
}
|
||||
$catids = (isset($form_atts['categorybox']) && $form_atts['categorybox']) ? ($form_atts['categorybox']) : '';
|
||||
$catids = explode(',', $catids);
|
||||
$result = array();
|
||||
$this->level = (int)$form_atts['cate_depth'];
|
||||
$limit = (isset($form_atts['limit']) && $form_atts['limit']) ? ((int)$form_atts['limit']) : 0;
|
||||
$limit++;
|
||||
foreach ($catids as $cate_id) {
|
||||
if ($cate_id && Validate::isInt($cate_id)) {
|
||||
$result_cate = $this->getNestedCategories($cate_id, 1, $images, $limit);
|
||||
if ($result_cate) {
|
||||
$result[] = $result_cate;
|
||||
}
|
||||
}
|
||||
}
|
||||
$assign['categories'] = $result;
|
||||
$assign['random'] = 'categories-image-'.ApPageSetting::getRandomNumber();
|
||||
$assign['type'] = 'category_image';
|
||||
// validate module
|
||||
unset($sql_filter);
|
||||
unset($sql_sort);
|
||||
return $assign;
|
||||
}
|
||||
|
||||
public function getImages()
|
||||
{
|
||||
$oimages = array();
|
||||
|
||||
$img_theme_dir = apPageHelper::getImgThemeDir();
|
||||
$icon_theme_dir = apPageHelper::getImgThemeDir('icon');
|
||||
$icon_theme_url = apPageHelper::getImgThemeUrl('icon');
|
||||
|
||||
if (!file_exists($img_theme_dir)) {
|
||||
mkdir($img_theme_dir, 0755, true);
|
||||
}
|
||||
if (!file_exists($icon_theme_dir)) {
|
||||
mkdir($icon_theme_dir, 0755, true);
|
||||
}
|
||||
|
||||
if (is_dir($img_theme_dir) && is_dir($icon_theme_dir)) {
|
||||
$images = glob($icon_theme_dir.'*.*');
|
||||
$exts = array('jpg', 'gif', 'png');
|
||||
foreach ($images as $key => $image) {
|
||||
$ext = Tools::substr($image, Tools::strlen($image) - 3, Tools::strlen($image));
|
||||
if (in_array(Tools::strtolower($ext), $exts)) {
|
||||
$aimage = array();
|
||||
$aimage['path'] = $icon_theme_url.basename($image);
|
||||
$aimage['name'] = basename($image);
|
||||
$oimages[] = $aimage;
|
||||
}
|
||||
// validate module
|
||||
unset($key);
|
||||
}
|
||||
}
|
||||
return $oimages;
|
||||
}
|
||||
|
||||
public function getNestedCategories($parent, $level, $images, $limit)
|
||||
{
|
||||
$buff = array();
|
||||
if ($level <= $this->level) {
|
||||
$lang = Context::getContext()->language->id;
|
||||
$current = array();
|
||||
$child = array();
|
||||
// $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
|
||||
$image_path = apPageHelper::getImgThemeUrl('icon');
|
||||
$sql = '
|
||||
SELECT c.*, cl.*
|
||||
FROM `'._DB_PREFIX_.'category` c'.Shop::addSqlAssociation('category', 'c').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').'
|
||||
WHERE c.id_parent='.(int)$parent.' AND `id_lang` = '.(int)$lang.'
|
||||
AND c.`active` = 1
|
||||
ORDER BY c.`level_depth` ASC, category_shop.`position` ASC';
|
||||
$result = Db::getInstance()->executeS($sql);
|
||||
$current_category = Db::getInstance()->executeS('SELECT c.*, cl.*
|
||||
FROM `'._DB_PREFIX_.'category` c'.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)$parent.' AND `id_lang` = '.(int)$lang.'
|
||||
AND c.`active` = 1');
|
||||
if ($current_category) {
|
||||
if (array_key_exists($current_category[0]['id_category'], $images)) {
|
||||
$current_category[0]['image'] = ((strpos($images[$current_category[0]['id_category']], '/') !== false)?'':$image_path).$images[$current_category[0]['id_category']];
|
||||
}
|
||||
if ($result) {
|
||||
foreach ($result as &$row) {
|
||||
if ($row && isset($row['id_category'])) {
|
||||
$child = $this->getNestedCategories($row['id_category'], $level + 1, $images, $limit);
|
||||
if ($child) {
|
||||
foreach ($child as $item) {
|
||||
if (array_key_exists($item['id_category'], $images)) {
|
||||
$item['image'] = ((strpos($images[$item['id_category']], '/') !== false)?'':$image_path).$images[$item['id_category']];
|
||||
}
|
||||
$current[$row['id_category']] = $item;
|
||||
}
|
||||
}
|
||||
$buff[$row['id_parent']] = $current_category[0];
|
||||
if ($current) {
|
||||
$buff[$row['id_parent']]['children'] = &$current;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// validate module
|
||||
$buff[$parent] = $current_category[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $buff;
|
||||
}
|
||||
}
|
||||
295
modules/appagebuilder/classes/shortcodes/ApColumn.php
Normal file
295
modules/appagebuilder/classes/shortcodes/ApColumn.php
Normal file
@@ -0,0 +1,295 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApColumn extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApColumn';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Column'), 'position' => 2, 'desc' => $this->l('A column can have one or more widget'),
|
||||
'tag' => 'content structure');
|
||||
}
|
||||
|
||||
public function getAdditionConfig()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'type' => '',
|
||||
'name' => 'xl',
|
||||
'default' => '12'
|
||||
),
|
||||
array(
|
||||
'type' => '',
|
||||
'name' => 'lg',
|
||||
'default' => '12'
|
||||
),
|
||||
array(
|
||||
'type' => '',
|
||||
'name' => 'md',
|
||||
'default' => '12'
|
||||
),
|
||||
array(
|
||||
'type' => '',
|
||||
'name' => 'sm',
|
||||
'default' => '12'
|
||||
),
|
||||
array(
|
||||
'type' => '',
|
||||
'name' => 'xs',
|
||||
'default' => '12'
|
||||
),
|
||||
array(
|
||||
'type' => '',
|
||||
'name' => 'sp',
|
||||
'default' => '12'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$input = array(
|
||||
array(
|
||||
'type' => 'tabConfig',
|
||||
'name' => 'tabConfig',
|
||||
'values' => array(
|
||||
'aprow_general' => $this->l('General'),
|
||||
'aprow_style' => $this->l('Width'),
|
||||
// 'aprow_animation' => $this->l('Animation'),
|
||||
'aprow_exceptions' => $this->l('Exceptions'))
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'id',
|
||||
'label' => $this->l('ID'),
|
||||
'form_group_class' => 'aprow_general',
|
||||
'desc' => $this->l('Use for css and javascript'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'ApColumnclass',
|
||||
'name' => 'class',
|
||||
'leolabel' => $this->l('CSS Class'),
|
||||
'values' => '',
|
||||
'default' => '',
|
||||
'form_group_class' => 'aprow_general',
|
||||
),
|
||||
array(
|
||||
'type' => 'column_width',
|
||||
'name' => 'width',
|
||||
'values' => '',
|
||||
'columnGrids' => ApPageSetting::getColumnGrid(),
|
||||
'form_group_class' => 'aprow_style',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Specific Controller'),
|
||||
'name' => 'specific_type',
|
||||
'class' => 'form-action',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'all',
|
||||
'name' => $this->l('Show on all Page Controller'),
|
||||
),
|
||||
array(
|
||||
'id' => 'index',
|
||||
'name' => $this->l('Show on only Index'),
|
||||
),
|
||||
array(
|
||||
'id' => 'nocategory',
|
||||
'name' => $this->l('Category: Not Display In Category list'),
|
||||
),
|
||||
array(
|
||||
'id' => 'nocategoryproduct',
|
||||
'name' => $this->l('Category: Not Display In Category list and product of it'),
|
||||
),
|
||||
array(
|
||||
'id' => 'category',
|
||||
'name' => $this->l('Category: Display only Category list'),
|
||||
),
|
||||
array(
|
||||
'id' => 'categoryproduct',
|
||||
'name' => $this->l('Category: Display only Category list and product of Category'),
|
||||
),
|
||||
array(
|
||||
'id' => 'categoryproductmain',
|
||||
'name' => $this->l('Category: Display only Category list and product of Main Category'),
|
||||
),
|
||||
array(
|
||||
'id' => 'product',
|
||||
'name' => $this->l('Show on only Product'),
|
||||
),
|
||||
array(
|
||||
'id' => 'cms',
|
||||
'name' => $this->l('Show on only CMS'),
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'aprow_exceptions',
|
||||
'default' => 'all'
|
||||
),
|
||||
array(
|
||||
'type' => 'reloadControler',
|
||||
'label' => $this->l('AJAX Reload Controller'),
|
||||
'name' => 'reloadControler',
|
||||
'default' => '',
|
||||
'form_group_class' => 'aprow_exceptions specific_type_sub specific_type-all',
|
||||
'hint' => 'If website have new a Controller, click to generate Controller again.',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Controller ID'),
|
||||
'name' => 'controller_id',
|
||||
'desc' => $this->l('Example: 1,2,3'),
|
||||
'default' => '',
|
||||
'form_group_class' => 'aprow_exceptions specific_type_sub specific_type-category specific_type-nocategory specific_type-nocategoryproduct specific_type-categoryproduct specific_type-categoryproductmain specific_type-product specific_type-cms',
|
||||
),
|
||||
array(
|
||||
'type' => 'apExceptions',
|
||||
'name' => 'controller_pages',
|
||||
'form_group_class' => 'aprow_exceptions specific_type_sub specific_type-all',
|
||||
),
|
||||
);
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function endRenderForm()
|
||||
{
|
||||
$this->helper->module = new $this->module_name();
|
||||
$this->helper->tpl_vars['exception_list'] = $this->displayModuleExceptionList();
|
||||
}
|
||||
|
||||
public function displayModuleExceptionList()
|
||||
{
|
||||
$controllers = array();
|
||||
$controllers_modules = array();
|
||||
$controllers_modules['admin'] = array();
|
||||
$controllers_modules['front'] = array();
|
||||
|
||||
if (Tools::getValue('reloadControllerException')) {
|
||||
$controllers = Dispatcher::getControllers(_PS_FRONT_CONTROLLER_DIR_);
|
||||
$controllers_modules = array(
|
||||
'admin' => Dispatcher::getModuleControllers('admin'),
|
||||
'front' => Dispatcher::getModuleControllers('front'),
|
||||
);
|
||||
|
||||
Configuration::updateValue('AP_CACHE_FRONT_CONTROLLER_EXCEPTION', apPageHelper::correctEnCodeData(Tools::jsonEncode($controllers)));
|
||||
Configuration::updateValue('AP_CACHE_FRONT_MODULE_EXCEPTION', apPageHelper::correctEnCodeData(Tools::jsonEncode($controllers_modules['admin'])));
|
||||
Configuration::updateValue('AP_CACHE_ADMIN_MODULE_EXCEPTION', apPageHelper::correctEnCodeData(Tools::jsonEncode($controllers_modules['front'])));
|
||||
} else {
|
||||
if (Configuration::get('AP_CACHE_FRONT_CONTROLLER_EXCEPTION') === false) {
|
||||
# First Time : write to config
|
||||
$controllers = Dispatcher::getControllers(_PS_FRONT_CONTROLLER_DIR_);
|
||||
Configuration::updateValue('AP_CACHE_FRONT_CONTROLLER_EXCEPTION', apPageHelper::correctEnCodeData(Tools::jsonEncode($controllers)));
|
||||
} else {
|
||||
# Second Time : read from config
|
||||
$controllers = Tools::jsonDecode(apPageHelper::correctDeCodeData(Configuration::get('AP_CACHE_FRONT_CONTROLLER_EXCEPTION')), true);
|
||||
}
|
||||
|
||||
if (Configuration::get('AP_CACHE_FRONT_MODULE_EXCEPTION') === false) {
|
||||
# First Time : write to config
|
||||
$controllers_modules['admin'] = Dispatcher::getModuleControllers('admin');
|
||||
Configuration::updateValue('AP_CACHE_FRONT_MODULE_EXCEPTION', apPageHelper::correctEnCodeData(Tools::jsonEncode($controllers_modules['admin'])));
|
||||
} else {
|
||||
# Second Time : read from config
|
||||
$controllers_modules['admin'] = Tools::jsonDecode(apPageHelper::correctDeCodeData(Configuration::get('AP_CACHE_FRONT_MODULE_EXCEPTION')), true);
|
||||
}
|
||||
|
||||
if (Configuration::get('AP_CACHE_ADMIN_MODULE_EXCEPTION') === false) {
|
||||
# First Time : write to config
|
||||
$controllers_modules['front'] = Dispatcher::getModuleControllers('front');
|
||||
Configuration::updateValue('AP_CACHE_ADMIN_MODULE_EXCEPTION', apPageHelper::correctEnCodeData(Tools::jsonEncode($controllers_modules['front'])));
|
||||
} else {
|
||||
# Second Time : read from config
|
||||
$controllers_modules['front'] = Tools::jsonDecode(apPageHelper::correctDeCodeData(Configuration::get('AP_CACHE_ADMIN_MODULE_EXCEPTION')), true);
|
||||
}
|
||||
}
|
||||
|
||||
$controller = Tools::getValue('controller_pages');
|
||||
$arr_controllers = explode(',', $controller);
|
||||
$arr_controllers = array_map('trim', $arr_controllers);
|
||||
|
||||
$modules_controllers_type = array('front' => $this->l('Front modules controller'), 'admin' => $this->l('Admin modules controller'));
|
||||
Context::getContext()->smarty->assign(array(
|
||||
'_core_' => $this->l('________________________________________ CORE ________________________________________'),
|
||||
'controller' => $controller,
|
||||
'arr_controllers' => $arr_controllers,
|
||||
'controllers' => $controllers,
|
||||
'modules_controllers_type' => $modules_controllers_type,
|
||||
'controllers_modules' => $controllers_modules,
|
||||
));
|
||||
$content = Context::getContext()->smarty->fetch(apPageHelper::getShortcodeTemplatePath('ApColumn.tpl'));
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
if (!isset($assign['formAtts']['animation']) || $assign['formAtts']['animation'] == 'none') {
|
||||
$assign['formAtts']['animation'] = 'none';
|
||||
$assign['formAtts']['animation_delay'] = '';
|
||||
} elseif ($assign['formAtts']['animation'] != 'none') {
|
||||
// validate module
|
||||
//DONGND:: add more config for animation
|
||||
if ((int)$assign['formAtts']['animation_delay'] >= 0) {
|
||||
$assign['formAtts']['animation_delay'] .= 's';
|
||||
} else {
|
||||
$assign['formAtts']['animation_delay'] = '1s';
|
||||
}
|
||||
if (isset($assign['formAtts']['animation_duration']) && (int)$assign['formAtts']['animation_duration'] >= 0) {
|
||||
$assign['formAtts']['animation_duration'] .= 's';
|
||||
} else {
|
||||
$assign['formAtts']['animation_duration'] = '1s';
|
||||
}
|
||||
if (isset($assign['formAtts']['animation_iteration_count']) && (int)$assign['formAtts']['animation_iteration_count'] > 0) {
|
||||
$assign['formAtts']['animation_iteration_count'] = (int)$assign['formAtts']['animation_iteration_count'];
|
||||
} else {
|
||||
$assign['formAtts']['animation_iteration_count'] = 1;
|
||||
}
|
||||
};
|
||||
$assign['formAtts']['class'] = str_replace('.', '-', $assign['formAtts']['class']);
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
200
modules/appagebuilder/classes/shortcodes/ApCountdown.php
Normal file
200
modules/appagebuilder/classes/shortcodes/ApCountdown.php
Normal file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApCountdown extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApCountdown';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array(
|
||||
'label' => $this->l('Countdown'),
|
||||
'position' => 3,
|
||||
'desc' => $this->l('Show a __________________'),
|
||||
'icon_class' => 'icon-picture', 'tag' => 'content slider'
|
||||
);
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$html_content = "
|
||||
|
||||
<style rel='stylesheet' type='text/css'>
|
||||
.ui-datepicker.ui-widget-content{
|
||||
border: 1px solid #aaaaaa/*{borderColorContent}*/;
|
||||
background: #ffffff/*{bgColorContent}*/;
|
||||
color: #222222/*{fcContent}*/;
|
||||
}
|
||||
.ui-slider.ui-widget-content{
|
||||
border: 1px solid #aaaaaa/*{borderColorContent}*/;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<script>
|
||||
$('.datepicker').datetimepicker({
|
||||
prevText: '',
|
||||
nextText: '',
|
||||
dateFormat: 'yy-mm-dd',
|
||||
// Define a custom regional settings in order to use PrestaShop translation tools
|
||||
currentText: 'Now',
|
||||
closeText: 'Done',
|
||||
ampm: false,
|
||||
amNames: ['AM', 'A'],
|
||||
pmNames: ['PM', 'P'],
|
||||
timeFormat: 'hh:mm:ss tt',
|
||||
timeSuffix: '',
|
||||
timeOnlyTitle: 'Choose Time',
|
||||
timeText: 'Time',
|
||||
hourText: 'Hour',
|
||||
minuteText: 'Minute'
|
||||
});
|
||||
</script>
|
||||
|
||||
";
|
||||
|
||||
$input = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => 'container'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Time From'),
|
||||
'name' => 'time_from',
|
||||
'class' => 'datepicker',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Time To'),
|
||||
'name' => 'time_to',
|
||||
'default' => '',
|
||||
'class' => 'datepicker',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Open new tab'),
|
||||
'desc' => $this->l('Open new tab when click to link in slider'),
|
||||
'name' => 'new_tab',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '1',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'link_label',
|
||||
'label' => $this->l('Link Label'),
|
||||
'lang' => 'true',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'link',
|
||||
'label' => $this->l('Link'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
'class' => 'item-add-slide ignore-lang',
|
||||
'form_group_class' => 'apfullslider-row link-slide',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => $html_content,
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Widget Description'),
|
||||
'name' => 'description',
|
||||
'cols' => 40,
|
||||
'rows' => 10,
|
||||
'value' => true,
|
||||
'lang' => true,
|
||||
'default' => '',
|
||||
'class' => 'item-add-slide ignore-lang',
|
||||
'form_group_class' => 'apfullslider-row description-slide',
|
||||
),
|
||||
);
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function getListGroup($list)
|
||||
{
|
||||
|
||||
$result = array();
|
||||
foreach ($list as $item) {
|
||||
$status = ' ('.($item['active'] ? $this->l('Active') : $this->l('Deactive')).')';
|
||||
$result[] = array('id' => $item['id_leoslideshow_groups'], 'name' => $item['title'].$status);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
|
||||
$productCdown = Configuration::get('APPAGEBUILDER_LOAD_COUNT');
|
||||
if (!$productCdown) {
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Can not show Countdown Widget via Appagebuilder. Please enable AJAX Show Count Down Product.';
|
||||
return $assign;
|
||||
}
|
||||
|
||||
$from = strtotime($assign['formAtts']['time_from']);
|
||||
$now = time();
|
||||
$end = strtotime($assign['formAtts']['time_to']);
|
||||
|
||||
if (($from <= $now) && ($now < $end)) {
|
||||
$start = true;
|
||||
} else {
|
||||
$start = false;
|
||||
}
|
||||
|
||||
if ($start) {
|
||||
# RUNNING
|
||||
$assign['formAtts']['time_to'] = str_replace('-', '/', $assign['formAtts']['time_to']);
|
||||
$assign['formAtts']['active'] = 1;
|
||||
} else {
|
||||
$assign['formAtts']['active'] = 0;
|
||||
}
|
||||
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
275
modules/appagebuilder/classes/shortcodes/ApCounter.php
Normal file
275
modules/appagebuilder/classes/shortcodes/ApCounter.php
Normal file
@@ -0,0 +1,275 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApCounter extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApCounter';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Counter'),
|
||||
'position' => 5,
|
||||
'desc' => $this->l('Show Counter Box'),
|
||||
'icon_class' => 'icon icon-list',
|
||||
'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$languages = Language::getLanguages();
|
||||
$list_id_lang = array();
|
||||
foreach ($languages as $languages_val) {
|
||||
array_push($list_id_lang, $languages_val['id_lang']);
|
||||
}
|
||||
|
||||
// Get value with keys special
|
||||
$languages = Language::getLanguages(false);
|
||||
$config_val = array();
|
||||
|
||||
$list_field = Tools::getValue('list_field');
|
||||
$list_field = array_filter(explode(',', $list_field));
|
||||
foreach ($list_field as $field) {
|
||||
$key = $field;
|
||||
$config_val[$key] = str_replace($this->str_search, $this->str_relace_html_admin, Tools::getValue($key));
|
||||
}
|
||||
|
||||
$list_field_lang = Tools::getValue('list_field_lang');
|
||||
$list_field_lang = array_filter(explode(',', $list_field_lang));
|
||||
foreach ($languages as $lang) {
|
||||
foreach ($list_field_lang as $field) {
|
||||
$key = $field.'_'.$lang['id_lang'];
|
||||
$config_val[$key] = str_replace($this->str_search, $this->str_relace_html_admin, Tools::getValue($key));
|
||||
}
|
||||
}
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'leoalert',
|
||||
'name' => 'alertloadjs',
|
||||
'html_text' => $this->l('You have to turn on script numscroller-1.0 for Counter in back-office > ApPageBuilder > Ap Module Configuration'),
|
||||
'href' => 'index.php?controller=AdminModules&configure=appagebuilder&token='.Tools::getAdminTokenLite('AdminModules').'#APPAGEBUILDER_LOAD_IMAGEHOTPOT_on',
|
||||
'show' => !Configuration::get('APPAGEBUILDER_LOAD_NUMSCROLLER'),
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<script>var listData = '.Tools::jsonEncode($config_val).';</script>',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<script>
|
||||
var totalLanguage = "'.count($languages).'";
|
||||
var list_id_lang = \''.Tools::jsonEncode($list_id_lang).'\';
|
||||
var remove_button_text = "'.$this->l('Remove Counter').'";
|
||||
var duplicate_button_text = "'.$this->l('Duplicate Counter').'";
|
||||
</script>',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'total_link',
|
||||
'default' => '0',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'list_id_link',
|
||||
'default' => '',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'list_field',
|
||||
'default' => '',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'list_field_lang',
|
||||
'default' => '',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'counterbox',
|
||||
'name' => 'title',
|
||||
'lang' => 'true',
|
||||
'label' => $this->l('Title'),
|
||||
'default' => '',
|
||||
'form_group_class' => 'hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'widget_title',
|
||||
'label' => $this->l('Widget Title'),
|
||||
'hint' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Widget Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'widget_class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Title'),
|
||||
'name' => 'link_title',
|
||||
'lang' => true,
|
||||
'default' => '',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'min',
|
||||
'label' => $this->l('Starting Number'),
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => '1',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'max',
|
||||
'label' => $this->l('Ending Number'),
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => '10000',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'increment',
|
||||
'label' => $this->l('Increment Number'),
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => '50',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'delay',
|
||||
'label' => $this->l('Delay Time'),
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => '3',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'number_suffix',
|
||||
'label' => $this->l('Number Suffix'),
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => '+',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'bootom_html',
|
||||
'label' => $this->l('Counter Bootom Html'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'counterclass',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => '',
|
||||
'class' => 'tmp',
|
||||
'form_group_class' => 'parent-tmp hidden',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<button type="button" class="add-new-link btn btn-default">
|
||||
<i class="process-icon-new"></i> '.$this->l('Add new Counte').'</button>',
|
||||
'form_group_class' => 'frm-add-new-link',
|
||||
),
|
||||
);
|
||||
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function getConfigValue()
|
||||
{
|
||||
$config_val = parent::getConfigValue();
|
||||
$config_val['target_type'] = '_self';
|
||||
return $config_val;
|
||||
}
|
||||
|
||||
public function endRenderForm()
|
||||
{
|
||||
$this->helper->module = new $this->module_name();
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
unset($module);
|
||||
if (!Configuration::get('APPAGEBUILDER_LOAD_NUMSCROLLER')) {
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Please enable Numscroller-1.0 for Counter.';
|
||||
return $assign;
|
||||
}
|
||||
$formAtts = $assign['formAtts'];
|
||||
$formAtts['links'] = array();
|
||||
|
||||
if (!isset($formAtts['list_id_link'])) {
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Dont have any counter. Please create new';
|
||||
return $assign;
|
||||
}
|
||||
|
||||
$id_forms = $formAtts['list_id_link'];
|
||||
$id_forms = array_filter(explode(',', $id_forms));
|
||||
foreach ($id_forms as $id_form) {
|
||||
$index = '_'.$id_form;
|
||||
$indexlang = $index.'_'.Context::getContext()->language->id;
|
||||
$link = array();
|
||||
$link['link_title'] = (isset($formAtts['link_title'.$indexlang]) && $formAtts['link_title'.$indexlang]) ? $formAtts['link_title'.$indexlang] : '';
|
||||
$link['bootom_html'] = (isset($formAtts['bootom_html'.$indexlang]) && $formAtts['bootom_html'.$indexlang]) ? $formAtts['bootom_html'.$indexlang] : '';
|
||||
$link['min'] = $formAtts['min'.$index];
|
||||
$link['max'] = $formAtts['max'.$index];
|
||||
$link['delay'] = $formAtts['delay'.$index];
|
||||
$link['increment'] = $formAtts['increment'.$index];
|
||||
$link['number_suffix'] = str_replace($this->str_search, $this->str_relace_html, $formAtts['number_suffix'.$index]);
|
||||
$link['counterclass'] = isset($formAtts['counterclass'.$index])?$formAtts['counterclass'.$index]:'';
|
||||
$formAtts['links'][] = $link;
|
||||
}
|
||||
$assign['formAtts']['links'] = $formAtts['links'];
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
183
modules/appagebuilder/classes/shortcodes/ApFacebook.php
Normal file
183
modules/appagebuilder/classes/shortcodes/ApFacebook.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApFacebook extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApFacebook';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Facebook'),
|
||||
'position' => 5,
|
||||
'desc' => $this->l('You can config Facebook Like box'),
|
||||
'icon_class' => 'icon-facebook-sign',
|
||||
'tag' => 'social');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$soption = ApPageSetting::returnYesNo();
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'fb_lang',
|
||||
'label' => $this->l('Facebook_Lang'),
|
||||
'desc' => $this->l('"en_US"'),
|
||||
'lang' => true,
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => 'en_US'
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Page URL'),
|
||||
'name' => 'page_url',
|
||||
'class' => 'ap_facebook',
|
||||
'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' => 'text',
|
||||
'label' => $this->l('Width'),
|
||||
'name' => 'width',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Height'),
|
||||
'name' => 'height',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Tabs'),
|
||||
'name' => 'tabs',
|
||||
'desc' => 'The tabs will display: <b>timeline</b>, <b>events</b>, <b>messages</b>.
|
||||
Use a comma separated list to add multiple tabs, ie: <b>timeline</b>, <b>events</b>.',
|
||||
'default' => 'timeline',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Hide Cover'),
|
||||
'name' => 'hide_cover',
|
||||
'desc' => 'Hide cover photo in title.',
|
||||
'values' => $soption,
|
||||
'default' => '0',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Show Facepile'),
|
||||
'name' => 'show_facepile',
|
||||
'desc' => 'Show avatars when friends like this.',
|
||||
'values' => $soption,
|
||||
'default' => '1',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Hide Cta'),
|
||||
'name' => 'hide_cta',
|
||||
'desc' => 'Hide custom call to action button (if applicable).',
|
||||
'values' => $soption,
|
||||
'default' => '0',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Small Header'),
|
||||
'name' => 'small_header',
|
||||
'desc' => 'Use small titles instead.',
|
||||
'values' => $soption,
|
||||
'default' => '0',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Adapt Container Width'),
|
||||
'name' => 'adapt_container_width',
|
||||
'desc' => 'Try to adjust to the container width.',
|
||||
'values' => $soption,
|
||||
'default' => '1',
|
||||
),
|
||||
// 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('Show Header'),
|
||||
// 'name' => 'show_header',
|
||||
// 'values' => $soption,
|
||||
// 'default' => '0',
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'switch',
|
||||
// 'label' => $this->l('Show Border'),
|
||||
// 'name' => 'show_border',
|
||||
// 'values' => $soption,
|
||||
// 'default' => '0',
|
||||
// )
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
}
|
||||
173
modules/appagebuilder/classes/shortcodes/ApFontAwesome.php
Normal file
173
modules/appagebuilder/classes/shortcodes/ApFontAwesome.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApFontAwesome extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApFontAwesome';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Font Awesome'),
|
||||
'position' => 5,
|
||||
'desc' => $this->l('Add a font Awesome'),
|
||||
'icon_class' => 'icon icon-font',
|
||||
'tag' => 'content control');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$rotate = array(
|
||||
array(
|
||||
'value' => 'normal',
|
||||
'text' => $this->l('Normal')
|
||||
),
|
||||
array(
|
||||
'value' => 'icon-rotate-90',
|
||||
'text' => $this->l('Rotate Left')
|
||||
),
|
||||
array(
|
||||
'value' => 'icon-rotate-180',
|
||||
'text' => $this->l('Rotate Inverser')
|
||||
),
|
||||
array(
|
||||
'value' => 'icon-rotate-270',
|
||||
'text' => $this->l('Rotate Right')
|
||||
),
|
||||
array(
|
||||
'value' => 'icon-flip-horizontal',
|
||||
'text' => $this->l('Flip Horizontal')
|
||||
),
|
||||
array(
|
||||
'value' => 'icon-flip-vertical',
|
||||
'text' => $this->l('Flip Vertical')
|
||||
),
|
||||
);
|
||||
$sizes = array(
|
||||
array(
|
||||
'value' => 'size-default',
|
||||
'text' => $this->l('Size Default')
|
||||
),
|
||||
array(
|
||||
'value' => 'icon-large',
|
||||
'text' => $this->l('Size Large')
|
||||
),
|
||||
array(
|
||||
'value' => 'icon-2x',
|
||||
'text' => $this->l('Size 2x')
|
||||
),
|
||||
array(
|
||||
'value' => 'icon-3x',
|
||||
'text' => $this->l('Size 3x')
|
||||
),
|
||||
array(
|
||||
'value' => 'icon-4x',
|
||||
'text' => $this->l('Size 4x')
|
||||
)
|
||||
);
|
||||
$default_font = Tools::getIsset('font_name') ? Tools::getValue('font_name') : 'icon-font';
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<input type="text" name="font_name" id="font_name" value="'.$default_font.
|
||||
'"/><div class="box-list-font-awesome">'.$this->renderListFont($default_font).'</div>'
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<hr/><div class="preview-widget"><i class="icon '.$default_font.
|
||||
'" data-default="'.$default_font.'"></i></div>'
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Font Rotate'),
|
||||
'name' => 'font_type',
|
||||
'options' => array('query' => $rotate,
|
||||
'id' => 'value',
|
||||
'name' => 'text'),
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Font Size'),
|
||||
'name' => 'font_size',
|
||||
'options' => array('query' => $sizes,
|
||||
'id' => 'value',
|
||||
'name' => 'text'),
|
||||
'default' => 'size-default',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Is Spin'),
|
||||
'name' => 'is_spin',
|
||||
'options' => array('query' => array(
|
||||
array('value' => '', 'text' => $this->l('No spin')),
|
||||
array('value' => 'icon-spin', 'text' => $this->l('Spin')),
|
||||
),
|
||||
'id' => 'value',
|
||||
'name' => 'text'),
|
||||
'default' => 'btn-lg',
|
||||
),
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function renderListFont($default = 'icon-font')
|
||||
{
|
||||
$list = ApPageSetting::listFontAwesome();
|
||||
$result = '';
|
||||
foreach ($list as $item) {
|
||||
$cls = '';
|
||||
if ($default === $item['value']) {
|
||||
$cls = 'selected';
|
||||
}
|
||||
$result .= '<li class="'.$cls.'"><i class="icon '.$item['value'].'" data-default="'.$item['value'].'"></i>';
|
||||
}
|
||||
return "<ul class='list-font-awesome'>$result</ul>";
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
$assign['formAtts']['font_name'] = str_replace('icon', 'fa', $assign['formAtts']['font_name']);
|
||||
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
268
modules/appagebuilder/classes/shortcodes/ApFullSlider.php
Normal file
268
modules/appagebuilder/classes/shortcodes/ApFullSlider.php
Normal file
@@ -0,0 +1,268 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApFullSlider extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApFullSlider';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Full Slider'), 'position' => 6,
|
||||
'desc' => $this->l('You can create Inner slideshow'), 'icon_class' => 'icon icon-chevron-right',
|
||||
'tag' => 'content slider');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$href = Context::getContext()->link->getAdminLink('AdminApPageBuilderImages').'&ajax=1&action=manageimage&imgDir=images';
|
||||
$ad = __PS_BASE_URI__.basename(_PS_ADMIN_DIR_);
|
||||
$iso_tiny_mce = Context::getContext()->language->iso_code;
|
||||
$iso_tiny_mce = (file_exists(_PS_JS_DIR_.'tiny_mce/langs/'.$iso_tiny_mce.'.js') ? $iso_tiny_mce : 'en');
|
||||
$list_slider = '<button type="button" id="btn-add-slider" class="btn btn-default">
|
||||
<i class="icon-plus-sign-alt"></i> '.$this->l('Add slider').'</button><hr/>';
|
||||
$list_slider_button = '<div id="frm-slider" class="hide">
|
||||
<div class="form-group">
|
||||
<div class="col-lg-12 ">
|
||||
<button type="button" class="btn btn-primary btn-save-fullslider"
|
||||
data-error="'.$this->l('Please enter the title and description').'">'.$this->l('Save').'</button>
|
||||
<button type="button" class="btn btn-default btn-reset-fullslider">'.$this->l('Reset').'</button>
|
||||
<button type="button" class="btn btn-default btn-cancel-fullslider">'.$this->l('Cancel').'</button>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var ad = "'.$ad.'";
|
||||
var iso = "'.$iso_tiny_mce.'";
|
||||
</script>
|
||||
<hr/>
|
||||
</div>';
|
||||
$input = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => 'container'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Width slider'),
|
||||
'desc' => $this->l('Example: 100%, 1170px'),
|
||||
'name' => 'width',
|
||||
'default' => '100%'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Height slider'),
|
||||
'name' => 'height',
|
||||
'default' => '400px',
|
||||
'desc' => $this->l('Example: 100%, 400px'),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Interval'),
|
||||
'name' => 'interval',
|
||||
'default' => 2000,
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Display title in slider'),
|
||||
'name' => 'display_title',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '1',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Display indicators in slider'),
|
||||
'name' => 'display_indicators',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '1',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Open new tab'),
|
||||
'desc' => $this->l('Open new tab when click to link in slider'),
|
||||
'name' => 'is_open',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-info">'.$this->l('Next step: Add content for sliders').'</div>'
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => $list_slider
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Put image link (https)'),
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'name' => 'temp_image_link',
|
||||
'lang' => true,
|
||||
'desc' => 'If you select image bellow, This field will auto overrired',
|
||||
'form_group_class' => 'apfullslider-row image_link-slide'
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Image'),
|
||||
'type' => 'selectImg',
|
||||
'href' => $href,
|
||||
'name' => 'temp_image',
|
||||
'lang' => true,
|
||||
'class' => 'item-add-slide ignore-lang',
|
||||
'form_group_class' => 'apfullslider-row select-img',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'temp_title',
|
||||
'label' => $this->l('Title'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
'class' => 'item-add-slide ignore-lang',
|
||||
'form_group_class' => 'apfullslider-row title-slide',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'temp_link',
|
||||
'label' => $this->l('Link'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
'class' => 'item-add-slide ignore-lang',
|
||||
'form_group_class' => 'apfullslider-row link-slide',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Description'),
|
||||
'name' => 'temp_descript',
|
||||
'cols' => 40,
|
||||
'rows' => 10,
|
||||
'value' => true,
|
||||
'lang' => true,
|
||||
'default' => '',
|
||||
'class' => 'item-add-slide ignore-lang',
|
||||
'form_group_class' => 'apfullslider-row description-slide',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => $list_slider_button
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'total_slider',
|
||||
'default' => ''
|
||||
),
|
||||
);
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function endRenderForm()
|
||||
{
|
||||
$this->helper->module = new $this->module_name();
|
||||
}
|
||||
|
||||
public function addConfigList($values)
|
||||
{
|
||||
// Get value with keys special
|
||||
$config_val = array();
|
||||
$total = isset($values['total_slider']) ? $values['total_slider'] : '';
|
||||
$arr = explode('|', $total);
|
||||
$inputs = array('tit', 'image_link', 'img', 'link', 'descript');
|
||||
$languages = Language::getLanguages(false);
|
||||
foreach ($arr as $i) {
|
||||
foreach ($inputs as $config) {
|
||||
foreach ($languages as $lang) {
|
||||
$config_val[$config][$i][$lang['id_lang']] = str_replace($this->str_search, $this->str_relace_html_admin, Tools::getValue($config.'_'.$i.'_'.$lang['id_lang'], ''));
|
||||
// print_r($config_val);
|
||||
// echo '====';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context::getContext()->smarty->assign(array(
|
||||
'lang' => $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')),
|
||||
'default_lang' => $lang->id,
|
||||
'arr' => $arr,
|
||||
'languages' => $languages,
|
||||
'config_val' => $config_val,
|
||||
'path' => $this->theme_img_module,
|
||||
));
|
||||
$list_slider = Context::getContext()->smarty->fetch(apPageHelper::getShortcodeTemplatePath('ApFullSlider.tpl'));
|
||||
$input = array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => $list_slider
|
||||
);
|
||||
$this->config_list[] = $input;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
$total_slider = isset($assign['formAtts']['total_slider']) ? $assign['formAtts']['total_slider'] : '';
|
||||
$list = explode('|', $total_slider);
|
||||
$sliders = array();
|
||||
$lang = Language::getLanguage(Context::getContext()->language->id);
|
||||
$lang_default = $lang['id_lang'];
|
||||
foreach ($list as $item) {
|
||||
if ($item) {
|
||||
$temp = $item.'_'.$lang_default;
|
||||
$slider = array();
|
||||
$slider['id'] = $item;
|
||||
$slider['title'] = isset($assign['formAtts']['tit_'.$temp]) ? $assign['formAtts']['tit_'.$temp] : '';
|
||||
$slider['image_link'] = isset($assign['formAtts']['image_link_'.$temp]) ? $assign['formAtts']['image_link_'.$temp] : '';
|
||||
$slider['link'] = isset($assign['formAtts']['link_'.$temp]) ? $assign['formAtts']['link_'.$temp] : '';
|
||||
if (isset($assign['formAtts']['img_'.$temp]) && $assign['formAtts']['img_'.$temp]) {
|
||||
// validate module
|
||||
$slider['img'] = $this->theme_img_module.$assign['formAtts']['img_'.$temp];
|
||||
} else {
|
||||
// validate module
|
||||
$slider['img'] = '';
|
||||
}
|
||||
|
||||
$desc = isset($assign['formAtts']['descript_'.$temp]) ? $assign['formAtts']['descript_'.$temp] : '';
|
||||
$slider['descript'] = str_replace($this->str_search, $this->str_relace_html, $desc);
|
||||
//$slider['descript'] = $assign['formAtts']['descript_'.$temp];
|
||||
$sliders[] = $slider;
|
||||
}
|
||||
}
|
||||
$assign['formAtts']['is_open'] = isset($assign['formAtts']['is_open']) ? $assign['formAtts']['is_open'] : 0;
|
||||
$assign['formAtts']['slides'] = $sliders;
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
115
modules/appagebuilder/classes/shortcodes/ApGenCode.php
Normal file
115
modules/appagebuilder/classes/shortcodes/ApGenCode.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApGenCode extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApGenCode';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Generate Code'),
|
||||
'position' => 8,
|
||||
'desc' => $this->l('Generate Code for tpl file. This function for web developer'),
|
||||
'icon_class' => 'icon-edit',
|
||||
'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'value' => 'abcd',
|
||||
'name' => 'id_gencode',
|
||||
'default' => uniqid('id_gencode_').'_'.time(),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'content_html',
|
||||
'class' => 'ap_html_raw raw-'.time(),
|
||||
'rows' => '10',
|
||||
'label' => $this->l('Code'),
|
||||
'values' => '',
|
||||
'default' => '',
|
||||
'desc' => $this->l('Typing code for file tpl.'),
|
||||
),
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
$this->generateFile($assign, $module);
|
||||
|
||||
$file_name = $assign['formAtts']['id_gencode'].'.tpl';
|
||||
$profile_data = $module->getProfileData();
|
||||
$profile_folder = $profile_data['profile_key'];
|
||||
$file_url = apPageHelper::getConfigDir('theme_profiles').$profile_folder.'/'.$file_name;
|
||||
// check file tồn tại
|
||||
if (file_exists($file_url)) {
|
||||
$assign['formAtts']['tpl_file'] = $file_url;
|
||||
} else {
|
||||
$title = $assign['formAtts']['title'];
|
||||
$assign['formAtts']['error_file'] = '1';
|
||||
$assign['formAtts']['error_message'] = "ERROR!!! Generate Code
|
||||
'$title'. Physical file does not exist ".apPageHelper::getThemeName().'/'.$profile_folder.'/'.$file_name;
|
||||
}
|
||||
return $assign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create code file in profile folder
|
||||
*/
|
||||
public function generateFile($assign, $module = null)
|
||||
{
|
||||
$folder_profiles = apPageHelper::getConfigDir('theme_profiles');
|
||||
if (!is_dir($folder_profiles)) {
|
||||
mkdir($folder_profiles, 0755, true);
|
||||
}
|
||||
|
||||
$file = $assign['formAtts']['id_gencode'].'.tpl';
|
||||
$profile_data = $module->getProfileData();
|
||||
$folder = $folder_profiles.$profile_data['profile_key'];
|
||||
$value = isset($assign['formAtts']['content_html']) ? $assign['formAtts']['content_html'] : '';
|
||||
|
||||
if (!is_dir($folder)) {
|
||||
mkdir($folder, 0755, true);
|
||||
}
|
||||
|
||||
ApPageSetting::writeFile($folder, $file, apPageHelper::getLicenceTPL().$value);
|
||||
}
|
||||
}
|
||||
289
modules/appagebuilder/classes/shortcodes/ApGmap.php
Normal file
289
modules/appagebuilder/classes/shortcodes/ApGmap.php
Normal file
@@ -0,0 +1,289 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApGmap extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApGmap';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Google Map'),
|
||||
'position' => 5,
|
||||
'desc' => $this->l('Create a Google Map'),
|
||||
'icon_class' => 'icon-map-marker',
|
||||
'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$iselect = Tools::getValue('display_store');
|
||||
|
||||
if ($iselect === false) {
|
||||
$script_update_select = '<script>$("#display_store").removeAttr("checked");</script>';
|
||||
} elseif ($iselect == 1) {
|
||||
$script_update_select = '<script>$("#display_store").attr("checked", "checked");</script>';
|
||||
}
|
||||
// Get all store of shop
|
||||
$base_model = new ApPageBuilderModel();
|
||||
$data_list = $base_model->getAllStoreByShop();
|
||||
// Options for switch elements
|
||||
$zoom_option = array();
|
||||
for ($i = 1; $i <= 20; $i++) {
|
||||
$zoom_option[] = array('id' => $i, 'value' => $i);
|
||||
}
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Google Key'),
|
||||
'name' => 'gkey',
|
||||
'desc' => $this->l('Example: AIzaSyCWJmaoDNR_l3GVkP6uRnMzsGG5iuuU_AM'),
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Zoom'),
|
||||
'name' => 'zoom',
|
||||
'default' => '11',
|
||||
'options' => array(
|
||||
'query' => $zoom_option,
|
||||
'id' => 'id',
|
||||
'name' => 'value'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Width'),
|
||||
'name' => 'width',
|
||||
'desc' => $this->l('Example: 100%, 100px'),
|
||||
'default' => '100%',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Height'),
|
||||
'name' => 'height',
|
||||
'desc' => $this->l('Example: 100%, 100px'),
|
||||
'default' => '300px',
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'display',
|
||||
'label' => $this->l('Select display store on map'),
|
||||
'class' => 'checkbox-group',
|
||||
// 'desc' => $this->l('Uncheck is display all stores'),
|
||||
'values' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'store',
|
||||
'name' => $this->l('Select store'),
|
||||
'val' => '1'
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-info">'.$this->l('Uncheck to Display all stores').'</div>'.$script_update_select,
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('List stores'),
|
||||
'desc' => $this->l('Can select multi store'),
|
||||
'name' => 'store[]',
|
||||
'multiple' => true,
|
||||
'options' => array(
|
||||
'query' => $data_list,
|
||||
'id' => 'id_store',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'aprow_exceptions',
|
||||
'default' => 'all',
|
||||
'form_group_class' => 'display_store',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Show Store Menu'),
|
||||
'name' => 'is_display_list',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0'
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Enable Gmap at Our_Stores page'),
|
||||
'name' => 'stores',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0'
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Enable Gmap at Sitemap page'),
|
||||
'name' => 'sitemap',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0'
|
||||
)
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
// Get all store of shop
|
||||
$base_model = new ApPageBuilderModel();
|
||||
$data_list = $base_model->getAllStoreByShop();
|
||||
$form_atts = $assign['formAtts'];
|
||||
$not_all = (isset($form_atts['display_store']) && $form_atts['display_store']);
|
||||
$store_ids = explode(',', (isset($form_atts['store']) && $form_atts['store']) ? $form_atts['store'] : '');
|
||||
$assign['hasListStore'] = (isset($form_atts['is_display_list']) && $form_atts['is_display_list']) ? 'is_display_list' : '';
|
||||
$markers = array();
|
||||
if ($not_all) {
|
||||
foreach ($store_ids as $id) {
|
||||
foreach ($data_list as $store) {
|
||||
if ($id == $store['id_store']) {
|
||||
$markers[] = $store;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$markers = $data_list;
|
||||
}
|
||||
foreach ($markers as &$marker) {
|
||||
$address = $this->processStoreAddress($marker);
|
||||
$marker['other'] = $this->renderStoreWorkingHours($marker);
|
||||
$marker['address'] = $address;
|
||||
$marker['has_store_picture'] = file_exists(_PS_STORE_IMG_DIR_.(int)$marker['id_store'].'.jpg');
|
||||
}
|
||||
|
||||
$assign['marker_center'] = Tools::jsonEncode($this->getMarkerCenter($markers));
|
||||
$assign['marker_list'] = Tools::jsonEncode($markers);
|
||||
|
||||
$assign['apGMap'] = Tools::jsonEncode(array(
|
||||
'translation_5' => $this->l('Click to larger Map'),
|
||||
'logo_store' => Configuration::get('PS_STORES_ICON'),
|
||||
'img_store_dir' => _THEME_STORE_DIR_,
|
||||
'img_ps_dir' => _PS_IMG_,
|
||||
));
|
||||
|
||||
return $assign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get formatted string address
|
||||
*/
|
||||
protected function processStoreAddress($store)
|
||||
{
|
||||
$ignore_field = array(
|
||||
'firstname',
|
||||
'lastname'
|
||||
);
|
||||
$out_datas = array();
|
||||
$address_datas = AddressFormat::getOrderedAddressFields($store['id_country'], false, true);
|
||||
$state = (isset($store['id_state'])) ? new State($store['id_state']) : null;
|
||||
foreach ($address_datas as $data_line) {
|
||||
$data_fields = explode(' ', $data_line);
|
||||
$addr_out = array();
|
||||
$data_fields_mod = false;
|
||||
foreach ($data_fields as $field_item) {
|
||||
$field_item = trim($field_item);
|
||||
if (!in_array($field_item, $ignore_field) && !empty($store[$field_item])) {
|
||||
$addr_out[] = ($field_item == 'city' && $state && isset($state->iso_code) && Tools::strlen($state->iso_code)) ?
|
||||
$store[$field_item].', '.$state->iso_code : $store[$field_item];
|
||||
$data_fields_mod = true;
|
||||
}
|
||||
}
|
||||
if ($data_fields_mod) {
|
||||
$out_datas[] = implode(' ', $addr_out);
|
||||
}
|
||||
}
|
||||
$out = implode('<br />', $out_datas);
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function renderStoreWorkingHours($store)
|
||||
{
|
||||
$days = array();
|
||||
$days[1] = 'Monday';
|
||||
$days[2] = 'Tuesday';
|
||||
$days[3] = 'Wednesday';
|
||||
$days[4] = 'Thursday';
|
||||
$days[5] = 'Friday';
|
||||
$days[6] = 'Saturday';
|
||||
$days[7] = 'Sunday';
|
||||
|
||||
$hours_temp = $store['hours'];
|
||||
$hours_temp = Tools::jsonDecode($hours_temp);
|
||||
$hours = array();
|
||||
//DONGND:: fix when stores do not have the data of open time
|
||||
if (count($hours_temp) > 0) {
|
||||
foreach ($hours_temp as $h) {
|
||||
$hours[] = implode(' | ', $h);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($hours)) {
|
||||
$result = '';
|
||||
for ($i = 1; $i < 8; $i++) {
|
||||
if (isset($hours[(int)$i - 1])) {
|
||||
Context::getContext()->smarty->assign(array(
|
||||
'days' => $days,
|
||||
'hours' => $hours,
|
||||
'i' => $i,
|
||||
));
|
||||
|
||||
$file_name = _PS_MODULE_DIR_.'appagebuilder/views/templates/front/shortcodes/ApGmap.tpl';
|
||||
$result .= Context::getContext()->smarty->fetch($file_name);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getMarkerCenter($markers)
|
||||
{
|
||||
//'default lat/long = 21.010904,105.787736 is location of LeoTheme
|
||||
$lat = 21.010904;
|
||||
$long = 105.787736;
|
||||
return (is_array($markers) && count($markers) > 0) ? $markers[0] : array('latitude' => $lat, 'longitude' => $long);
|
||||
}
|
||||
}
|
||||
97
modules/appagebuilder/classes/shortcodes/ApHtml.php
Normal file
97
modules/appagebuilder/classes/shortcodes/ApHtml.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApHtml extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApHtml';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Html'), 'position' => 3, 'desc' => $this->l('You can put html'),
|
||||
'icon_class' => 'icon-html5', 'tag' => 'content structure');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$accordion_type = array(
|
||||
array(
|
||||
'value' => 'full',
|
||||
'text' => $this->l('Always Full')
|
||||
),
|
||||
array(
|
||||
'value' => 'accordion',
|
||||
'text' => $this->l('Always Accordion')
|
||||
),
|
||||
array(
|
||||
'value' => 'accordion_small_screen',
|
||||
'text' => $this->l('Accordion at small screen')
|
||||
),
|
||||
);
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'autoload_rte' => false,
|
||||
'values' => '',
|
||||
'class' => 'sub_title',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Accordion Type'),
|
||||
'name' => 'accordion_type',
|
||||
'options' => array(
|
||||
'query' => $accordion_type,
|
||||
'id' => 'value',
|
||||
'name' => 'text' ),
|
||||
'default' => 'full',
|
||||
'hint' => $this->l('Select a Accordion Type'),
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'content_html',
|
||||
'class' => 'ap_html',
|
||||
'rows' => '50',
|
||||
'lang' => true,
|
||||
'label' => $this->l('Html'),
|
||||
'values' => '',
|
||||
'autoload_rte' => true,
|
||||
'default' => "<div>\n</div>"
|
||||
),
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
}
|
||||
188
modules/appagebuilder/classes/shortcodes/ApImage.php
Normal file
188
modules/appagebuilder/classes/shortcodes/ApImage.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApImage extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApImage';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Image'),
|
||||
'position' => 5,
|
||||
'desc' => $this->l('Single Image'),
|
||||
'icon_class' => 'icon-image',
|
||||
'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
Context::getContext()->smarty->assign('path_image', apPageHelper::getImgThemeUrl());
|
||||
$href = Context::getContext()->link->getAdminLink('AdminApPageBuilderImages').'&ajax=1&action=manageimage&imgDir=images';
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Animations'),
|
||||
'name' => 'animation',
|
||||
'class' => 'animation-select',
|
||||
'options' => array(
|
||||
'optiongroup' => array(
|
||||
'label' => 'name',
|
||||
'query' => ApPageSetting::getAnimations(),
|
||||
),
|
||||
'options' => array(
|
||||
'id' => 'id',
|
||||
'name' => 'name',
|
||||
'query' => 'query',
|
||||
),
|
||||
),
|
||||
'form_group_class' => 'apimage_animation',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div id="animationSandbox">Prestashop.com</div>',
|
||||
'form_group_class' => 'apimage_animation animate_sub',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Delay'),
|
||||
'name' => 'animation_delay',
|
||||
'default' => '0.5',
|
||||
'suffix' => 's',
|
||||
'class' => 'fixed-width-xs',
|
||||
'form_group_class' => 'apimage_animation animate_sub',
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Put image link (https)'),
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'name' => 'image_link',
|
||||
'lang' => true,
|
||||
'desc' => 'If you select image bellow, This field will auto overrired'
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Image'),
|
||||
'type' => 'selectImg',
|
||||
'href' => $href,
|
||||
'name' => 'image',
|
||||
'lang' => true,
|
||||
'show_image' => true,
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'alt',
|
||||
'label' => $this->l('Alt'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'url',
|
||||
'label' => $this->l('Link to'),
|
||||
'lang' => true,
|
||||
'desc' => 'Example: http://prestashop.com',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Open new tab'),
|
||||
'name' => 'is_open',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'width',
|
||||
'label' => $this->l('Image size width'),
|
||||
'desc' => $this->l('Example: auto, 100%, 100px'),
|
||||
'default' => '100%'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'height',
|
||||
'label' => $this->l('Image size height'),
|
||||
'desc' => $this->l('Example: auto, 100%, 100px'),
|
||||
'default' => 'auto'
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Description'),
|
||||
'name' => 'description',
|
||||
'cols' => 40,
|
||||
'rows' => 10,
|
||||
'value' => true,
|
||||
'lang' => true,
|
||||
'default' => '',
|
||||
'autoload_rte' => true,
|
||||
)
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function endRenderForm()
|
||||
{
|
||||
$this->helper->module = new $this->module_name();
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
$assign['path'] = apPageHelper::getImgThemeUrl();
|
||||
|
||||
if (!isset($assign['formAtts']['animation']) || $assign['formAtts']['animation'] == 'none') {
|
||||
$assign['formAtts']['animation'] = 'none';
|
||||
$assign['formAtts']['animation_delay'] = '';
|
||||
} elseif ($assign['formAtts']['animation'] != 'none' && (int)$assign['formAtts']['animation_delay'] > 0) {
|
||||
// validate module
|
||||
$assign['formAtts']['animation_delay'] .= 's';
|
||||
} elseif ($assign['formAtts']['animation'] != 'none' && (int)$assign['formAtts']['animation_delay'] <= 0) {
|
||||
// Default delay
|
||||
$assign['formAtts']['animation_delay'] = '1s';
|
||||
}
|
||||
if (isset($assign['formAtts']['image'])) {
|
||||
$assign['formAtts']['image'] = trim($assign['formAtts']['image']);
|
||||
}
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
333
modules/appagebuilder/classes/shortcodes/ApImage360.php
Normal file
333
modules/appagebuilder/classes/shortcodes/ApImage360.php
Normal file
@@ -0,0 +1,333 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApImage360 extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApImage360';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Image 360'), 'position' => 20, 'desc' => $this->l('Adds multiple 360 images, rotating display objects'),
|
||||
'icon_class' => 'icon-image', 'tag' => 'content structure');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$href = Context::getContext()->link->getAdminLink('AdminApPageBuilderImages').'&ajax=1&action=manageimage&imgDir=images&widget=ApImage360';
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Spin'),
|
||||
'name' => 'spin',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'drag', 'name' => $this->l('Drag')),
|
||||
array('id' => 'hover', 'name' => $this->l('Hover')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'desc' => $this->l('Method for spinning the image'),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'speed',
|
||||
'label' => $this->l('Speed'),
|
||||
// 'lang' => 'true',
|
||||
'default' => '50',
|
||||
'desc' => $this->l('Mouse drag distance in pixels to next image (1 - 100). Ex 50'),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'mousewheel_step',
|
||||
'label' => $this->l('Mousewheel Step'),
|
||||
// 'lang' => 'true',
|
||||
'default' => '1',
|
||||
'desc' => $this->l('Number of image to spin on mousewheel'),
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Smoothing'),
|
||||
'name' => 'smoothing',
|
||||
'is_bool' => true,
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => 1,
|
||||
'desc' => $this->l('Smoothly stop the image spinning'),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Initialization'),
|
||||
'name' => 'initialize_on',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'hover', 'name' => $this->l('hover')),
|
||||
array('id' => 'click', 'name' => $this->l('click')),
|
||||
array('id' => 'load', 'name' => $this->l('load')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => 'load',
|
||||
'desc' => $this->l('Start automatic spin on page load, click or hover'),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Autospin duration'),
|
||||
'name' => 'autospin',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'once', 'name' => $this->l('Once')),
|
||||
array('id' => 'twice', 'name' => $this->l('Twice')),
|
||||
array('id' => 'infinite', 'name' => $this->l('Infinite')),
|
||||
array('id' => 'off', 'name' => $this->l('Off')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
// 'desc' => $this->l('Method for spinning the image'),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Autospin start'),
|
||||
'name' => 'autospin_start',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'load', 'name' => $this->l('load')),
|
||||
array('id' => 'hover', 'name' => $this->l('hover')),
|
||||
array('id' => 'click', 'name' => $this->l('click')),
|
||||
array('id' => 'load,hover', 'name' => $this->l('load,hover')),
|
||||
array('id' => 'load,click', 'name' => $this->l('load,click')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'desc' => $this->l('Start automatic spin on page load, click or hover'),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Autospin stops'),
|
||||
'name' => 'autospin_stop',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'hover', 'name' => $this->l('hover')),
|
||||
array('id' => 'click', 'name' => $this->l('click')),
|
||||
array('id' => 'never', 'name' => $this->l('never')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'desc' => $this->l('Start automatic spin on page load, click or hover'),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'autospin_speed',
|
||||
'label' => $this->l('Autospin Time'),
|
||||
// 'lang' => 'true',
|
||||
'default' => '2000',
|
||||
'desc' => $this->l('Value is milisecond. Ex 2000 (2s)'),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Autospin direction'),
|
||||
'name' => 'autospin_direction',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'clockwise', 'name' => $this->l('Clockwise')),
|
||||
array('id' => 'anticlockwise', 'name' => $this->l('Anticlockwise')),
|
||||
array('id' => 'alternate-clockwise', 'name' => $this->l('Alternate Clockwise')),
|
||||
array('id' => 'alternate-anticlockwise', 'name' => $this->l('Alternate Anticlockwise')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'desc' => $this->l('Method for spinning the image'),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'start_column',
|
||||
'label' => $this->l('Start Column'),
|
||||
'default' => '1',
|
||||
'desc' => $this->l('Column from which to start spin. auto means to start from the middle'),
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Loop Column'),
|
||||
'name' => 'loop_column',
|
||||
'is_bool' => true,
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => 1,
|
||||
'desc' => $this->l('Continue spin after the last image on X-axis'),
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Reverse rotation on X-axis'),
|
||||
'name' => 'reverse_column',
|
||||
'is_bool' => true,
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => 0,
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'message',
|
||||
'label' => $this->l('Message under image'),
|
||||
'default' => 'Drag image to spin',
|
||||
'lang' => true,
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Show hint message'),
|
||||
'name' => 'hint',
|
||||
'is_bool' => true,
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => 1,
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'message_desktop_hint',
|
||||
'label' => $this->l('Message Desktop Hint'),
|
||||
'default' => 'Drag to spin',
|
||||
'lang' => true,
|
||||
'desc' => $this->l('Text of the hint on Desktop'),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'message_mobile_hint',
|
||||
'label' => $this->l('Message Mobile Hint'),
|
||||
'default' => 'Swipe to spin',
|
||||
'lang' => true,
|
||||
'desc' => $this->l('Text of the hint on iOS/Android devices'),
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'total_slider',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Image Url (not image base 64 code)'),
|
||||
'type' => 'image_url_360',
|
||||
'name' => 'image_url_360',
|
||||
'lang' => false,
|
||||
'class' => 'image_url_360',
|
||||
'show_image' => false,
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Image'),
|
||||
'type' => 'selectImg',
|
||||
'href' => $href,
|
||||
'name' => 'image_360',
|
||||
'lang' => false,
|
||||
'class' => 'item-add-slide ignore-lang',
|
||||
'form_group_class' => 'apfullslider-row select-img',
|
||||
'show_image' => false,
|
||||
)
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function endRenderForm()
|
||||
{
|
||||
$this->helper->module = new $this->module_name();
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget can override this method and add more config at here
|
||||
*/
|
||||
public function addConfigList($values)
|
||||
{
|
||||
// Get value with keys special
|
||||
$config_val = array();
|
||||
$total = isset($values['total_slider']) ? $values['total_slider'] : '';
|
||||
|
||||
$arr = explode('|', $total);
|
||||
$inputs = array('image360');
|
||||
// $languages = Language::getLanguages(false);
|
||||
foreach ($arr as $i) {
|
||||
foreach ($inputs as $config) {
|
||||
$config_val[$config][$i] = str_replace($this->str_search, $this->str_relace_html_admin, Tools::getValue($config.'_'.$i, ''));
|
||||
}
|
||||
}
|
||||
|
||||
Context::getContext()->smarty->assign(array(
|
||||
'arr' => $arr,
|
||||
'config_val' => $config_val,
|
||||
'image_folder' => apPageHelper::getImgThemeUrl(),
|
||||
));
|
||||
$list_slider = Context::getContext()->smarty->fetch(apPageHelper::getShortcodeTemplatePath('ApImage360.tpl'));
|
||||
$input = array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => $list_slider
|
||||
);
|
||||
$this->config_list[] = $input;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
|
||||
if (!Configuration::get('APPAGEBUILDER_LOAD_IMAGE360')) {
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Please enable Magic360 library in Appagebuilder Configuration.';
|
||||
return $assign;
|
||||
}
|
||||
|
||||
$total_slider = isset($assign['formAtts']['total_slider']) ? $assign['formAtts']['total_slider'] : '';
|
||||
$list = explode('|', $total_slider);
|
||||
|
||||
|
||||
$image_list = array();
|
||||
$image_path = apPageHelper::getImgThemeUrl();
|
||||
|
||||
foreach ($list as $item) {
|
||||
if (isset($assign['formAtts']['image360_'.$item])) {
|
||||
$image_list[] = $assign['formAtts']['image360_'.$item];
|
||||
}
|
||||
}
|
||||
|
||||
$assign['formAtts']['image_path'] = $image_path;
|
||||
$assign['formAtts']['columns'] = count($list);
|
||||
$assign['formAtts']['row'] = 1;
|
||||
$assign['formAtts']['image_list'] = $image_list;
|
||||
|
||||
// IMAGE DEFAULT
|
||||
$min_key = min(array_keys($image_list));
|
||||
$assign['formAtts']['image_default'] = $image_list[$min_key];
|
||||
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
233
modules/appagebuilder/classes/shortcodes/ApImageGallery.php
Normal file
233
modules/appagebuilder/classes/shortcodes/ApImageGallery.php
Normal file
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApImageGallery extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApImageGallery';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Image Gallery'),
|
||||
'position' => 7,
|
||||
'desc' => $this->l('Create Images Mini Gallery From A Folder'),
|
||||
'icon_class' => 'icon-th',
|
||||
'tag' => 'content');
|
||||
}
|
||||
|
||||
private function addCustomJS()
|
||||
{
|
||||
return Context::getContext()->smarty->fetch(apPageHelper::getShortcodeTemplatePath($this->name.'.tpl'));
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$path_info = 'Example: themes/'.apPageHelper::getThemeName().'/assets/img/modules/appagebuilder/images/yourFolderImage';
|
||||
$path = 'themes/'.apPageHelper::getThemeName().'/assets/img/modules/appagebuilder/images/';
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'path',
|
||||
'label' => $this->l('Path'),
|
||||
'desc' => $this->trans($path_info),
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => $path,
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<input class="btn btn-primary btn-create-folder" type="button" value="'.$this->l('AJAX Create Folder').'" name="create_folder">' . $this->addCustomJS(),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Limit'),
|
||||
'name' => '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')),
|
||||
array('id' => '6', 'name' => $this->l('6 Columns')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'),
|
||||
'default' => '4',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Load more'),
|
||||
'name' => 'load_more',
|
||||
'options' => array('query' => array(
|
||||
array('id' => '0', 'name' => $this->l('No')),
|
||||
array('id' => '1', 'name' => $this->l('Yes')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'),
|
||||
'default' => '0',
|
||||
'desc' => $this->l('Show button load more image. Auto hide the button if all images is showed'),
|
||||
)
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
$form_atts = $assign['formAtts'];
|
||||
$form_atts['path'] = ltrim($form_atts['path'], '/');
|
||||
$form_atts['path'] = rtrim($form_atts['path'], '/');
|
||||
|
||||
$limit = (int)$form_atts['limit'];
|
||||
$images = array();
|
||||
$link = new Link();
|
||||
$current_link = $link->getPageLink('', null, Context::getContext()->language->id);
|
||||
$path = _PS_ROOT_DIR_.'/'.str_replace($current_link, '', isset($form_atts['path']) ? $form_atts['path'] : '');
|
||||
$arr_exten = array('jpg', 'jpge', 'gif', 'png');
|
||||
|
||||
$count = 0;
|
||||
if ($path && is_dir($path)) {
|
||||
if ($handle = scandir($path)) {
|
||||
if (($key = array_search('.', $handle)) !== false) {
|
||||
unset($handle[$key]);
|
||||
}
|
||||
if (($key = array_search('..', $handle)) !== false) {
|
||||
unset($handle[$key]);
|
||||
}
|
||||
foreach ($handle as $entry) {
|
||||
if ($entry != '.' && $entry != '..' && is_file($path.'/'.$entry)) {
|
||||
$ext = Tools::strtolower(pathinfo($path.'/'.$entry, PATHINFO_EXTENSION));
|
||||
if (in_array($ext, $arr_exten)) {
|
||||
# FIX 1.7
|
||||
$images[] = __PS_BASE_URI__.str_replace($current_link, '', $form_atts['path']).'/'.$entry;
|
||||
$count++;
|
||||
if ($count == $limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$total = count($handle);
|
||||
$total_nerver_show = (int)( $total - $count );
|
||||
|
||||
if (isset($form_atts['load_more']) && (int) $form_atts['load_more'] == 1 && $total_nerver_show) {
|
||||
# SHOW BUTTON SHOW_MORE
|
||||
$assign['show_number'] = $count;
|
||||
$assign['show_more_btn'] = 1;
|
||||
}
|
||||
|
||||
|
||||
$c = (int)$form_atts['columns'];
|
||||
$assign['columns'] = $c > 0 ? $c : 4;
|
||||
$assign['images'] = $images;
|
||||
if (isset($assign['tpl_dir'])) {
|
||||
unset($assign['tpl_dir']);
|
||||
}
|
||||
$assign['assign'] = Tools::jsonEncode($assign);
|
||||
|
||||
return $assign;
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX : create folder image follow user type url
|
||||
*/
|
||||
public function ajaxCallBackCreateDir()
|
||||
{
|
||||
$path = Tools::getValue('path');
|
||||
|
||||
// $domain = strpos($url, _PS_BASE_URL_.__PS_BASE_URI__ );
|
||||
// if ($domain === false)
|
||||
// {
|
||||
// # CHECK NOT SAME DOMAIN
|
||||
// # http://localhost/prestashop/ps_1700_RC03_local != http://prestashop/ps_1700_RC03_local
|
||||
// die(Tools::jsonEncode(array(
|
||||
// 'hasError' => true,
|
||||
// 'error' => $this->l('Domain is incorrect. Please type this at first: '),
|
||||
// 'img_dir' => _PS_BASE_URL_.__PS_BASE_URI__,
|
||||
// )));
|
||||
// }
|
||||
|
||||
$img_dir = str_replace(_PS_BASE_URL_.__PS_BASE_URI__, '', $path);
|
||||
$img_dir = _PS_ROOT_DIR_.'/'.$img_dir;
|
||||
$img_dir = str_replace('\\', '/', $img_dir);
|
||||
$img_dir = str_replace('//', '/', $img_dir);
|
||||
|
||||
if (file_exists($img_dir)) {
|
||||
# CHECK FOLDER EXIST
|
||||
die(Tools::jsonEncode(array(
|
||||
'hasError' => true,
|
||||
'error' => $this->l('Folder is exist'),
|
||||
'img_dir' => $img_dir,
|
||||
)));
|
||||
}
|
||||
|
||||
try {
|
||||
$result = mkdir($img_dir, 0755, true);
|
||||
if ($result) {
|
||||
die(Tools::jsonEncode(array(
|
||||
'success' => true,
|
||||
'information' => $this->l('Create folder successful'),
|
||||
'img_dir' => $img_dir,
|
||||
)));
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
die(Tools::jsonEncode(array(
|
||||
'hasError' => true,
|
||||
'error' => $this->l('Can NOT create folder'),
|
||||
'img_dir' => $img_dir,
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApImageGalleryProduct extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApImageGalleryProduct';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Image Gallery Product'),
|
||||
'position' => 7,
|
||||
'desc' => $this->l('Create Images Mini Gallery From Product'),
|
||||
'icon_class' => 'icon-th',
|
||||
'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$source = array(
|
||||
array(
|
||||
'value' => 'ip_pcategories',
|
||||
'name' => $this->l('Category')
|
||||
),
|
||||
array(
|
||||
'value' => 'ip_pproductids',
|
||||
'name' => $this->l('Product Ids')
|
||||
)
|
||||
);
|
||||
$pimagetypes = $this->getImageTypes();
|
||||
$selected_categories = array();
|
||||
if (Tools::getIsset('categorybox')) {
|
||||
$category_box = Tools::getValue('categorybox');
|
||||
$category_box = explode(',', $category_box);
|
||||
$selected_categories = $category_box;
|
||||
}
|
||||
$id_root_category = Context::getContext()->shop->getCategory();
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Source'),
|
||||
'name' => 'ip_source',
|
||||
'class' => 'group form-action',
|
||||
'default' => '',
|
||||
'options' => array(
|
||||
'query' => $source,
|
||||
'id' => 'value',
|
||||
'name' => 'name'
|
||||
),
|
||||
'desc' => 'Select source type'
|
||||
),
|
||||
array(
|
||||
'type' => 'categories',
|
||||
'label' => $this->l('Select Category'),
|
||||
'name' => 'categorybox',
|
||||
'tree' => array(
|
||||
'root_category' => $id_root_category,
|
||||
'use_search' => false,
|
||||
'id' => 'categorybox',
|
||||
'use_checkbox' => true,
|
||||
'selected_categories' => $selected_categories,
|
||||
),
|
||||
'form_group_class' => 'ip_source_sub ip_source-ip_pcategories'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Product Ids'),
|
||||
'form_group_class' => 'ip_source_sub ip_source-ip_pproductids',
|
||||
'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' => ApPageSetting::getDefaultNameImage('thickbox'),
|
||||
'options' => array(
|
||||
'query' => $pimagetypes,
|
||||
'id' => 'name',
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Limit'),
|
||||
'name' => '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')),
|
||||
array('id' => '6', 'name' => $this->l('6 Columns')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'),
|
||||
'default' => '4',
|
||||
)
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
$form_atts = $assign['formAtts'];
|
||||
$limit = (int)$form_atts['limit'];
|
||||
$images = array();
|
||||
$smallimage = ($form_atts['smallimage']) ? ($form_atts['smallimage']) : ApPageSetting::getDefaultNameImage('small');
|
||||
$thickimage = ($form_atts['thickimage']) ? ($form_atts['thickimage']) : ApPageSetting::getDefaultNameImage('thickbox');
|
||||
switch ($form_atts['ip_source']) {
|
||||
case 'ip_pproductids':
|
||||
if (empty($form_atts['ip_pproductids'])) {
|
||||
return false;
|
||||
}
|
||||
$pproductids = $form_atts['ip_pproductids'];
|
||||
if ($pproductids) {
|
||||
$images = $this->getImagesByProductId($pproductids, 0, $limit, (int)Context::getContext()->language->id);
|
||||
}
|
||||
break;
|
||||
case 'ip_pcategories':
|
||||
$catids = (isset($form_atts['categorybox']) && $form_atts['categorybox']) ? ($form_atts['categorybox']) : array();
|
||||
if ($catids) {
|
||||
$images = $this->getImagesByCategory($catids, 0, $limit, (int)Context::getContext()->language->id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
$c = (int)$form_atts['columns'];
|
||||
$assign['columns'] = $c > 0 ? $c : 4;
|
||||
$assign['thickimage'] = $thickimage;
|
||||
$assign['smallimage'] = $smallimage;
|
||||
$assign['images'] = $images;
|
||||
return $assign;
|
||||
}
|
||||
|
||||
public function getImagesByProductId($productids, $start, $limit, $id_lang)
|
||||
{
|
||||
$sql = 'SELECT DISTINCT(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 ('.$productids.')
|
||||
AND il.`id_lang` ='.(int)$id_lang.
|
||||
' AND pl.`id_lang` ='.(int)$id_lang.
|
||||
' 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(',', $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` ='.$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'.((int)$limit > 0 ? ' LIMIT '.(int)$start.','.(int)$limit : '');
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
537
modules/appagebuilder/classes/shortcodes/ApImageHotspot.php
Normal file
537
modules/appagebuilder/classes/shortcodes/ApImageHotspot.php
Normal file
@@ -0,0 +1,537 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApImageHotspot extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApImageHotspot';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public $inputs_lang = array('temp_title', 'temp_image_link' , 'temp_image', 'temp_description');
|
||||
public $inputs = array('temp_top', 'temp_left', 'temp_hpcolor', 'temp_location', 'temp_textalign', 'temp_trigger', 'temp_opacity', 'temp_width', 'temp_margin', 'temp_padding', 'temp_textcolor', 'temp_backcolor', 'temp_class', 'temp_imagealign');
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Image Hotspot'),
|
||||
'position' => 5,
|
||||
'desc' => $this->l('Display tooltip in your image when user hover over points'),
|
||||
'icon_class' => 'icon-image',
|
||||
'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
Context::getContext()->smarty->assign('path_image', apPageHelper::getImgThemeUrl());
|
||||
$href = Context::getContext()->link->getAdminLink('AdminApPageBuilderImages').'&ajax=1&action=manageimage&imgDir=images';
|
||||
$ad = __PS_BASE_URI__.basename(_PS_ADMIN_DIR_);
|
||||
$iso_tiny_mce = Context::getContext()->language->iso_code;
|
||||
$iso_tiny_mce = (file_exists(_PS_JS_DIR_.'tiny_mce/langs/'.$iso_tiny_mce.'.js') ? $iso_tiny_mce : 'en');
|
||||
$list_slider = '<button type="button" id="btn-add-hotpot" class="btn btn-default btn-add-level2">
|
||||
<i class="icon-plus-sign-alt"></i> '.$this->l('Add Hotspot').'</button><hr/>';
|
||||
$list_slider_button = '<div id="frm-level2" class="row-level2 frm-level2">
|
||||
<div class="form-group">
|
||||
<div class="col-lg-12 ">
|
||||
<button type="button" class="btn btn-primary btn-save-level2"
|
||||
data-error="'.$this->l('Please enter the title').'">'.$this->l('Save').'</button>
|
||||
<button type="button" class="btn btn-default btn-reset-level2">'.$this->l('Reset').'</button>
|
||||
<button type="button" class="btn btn-default btn-cancel-level2">'.$this->l('Cancel').'</button>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var ad = "'.$ad.'";
|
||||
var iso = "'.$iso_tiny_mce.'";
|
||||
</script>
|
||||
<hr/>
|
||||
</div>';
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Put image link (https)'),
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'name' => 'image_link',
|
||||
'lang' => true,
|
||||
'desc' => 'If you select image bellow, This field will auto overrired'
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Image'),
|
||||
'type' => 'selectImg',
|
||||
'href' => $href,
|
||||
'name' => 'image',
|
||||
'lang' => true,
|
||||
'show_image' => true,
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'alt',
|
||||
'label' => $this->l('Alt'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'url',
|
||||
'label' => $this->l('Link to'),
|
||||
'lang' => true,
|
||||
'desc' => 'Example: http://prestashop.com',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Open new tab'),
|
||||
'name' => 'is_open',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'width',
|
||||
'label' => $this->l('Image size width'),
|
||||
'desc' => $this->l('Example: auto, 100%, 100px'),
|
||||
'default' => '100%'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'height',
|
||||
'label' => $this->l('Image size height'),
|
||||
'desc' => $this->l('Example: auto, 100%, 100px'),
|
||||
'default' => 'auto'
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => $list_slider
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'temp_title',
|
||||
'label' => $this->l('Title'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
'class' => 'input-level2 temp_title js-multilang',
|
||||
'form_group_class' => 'row-level2 row2-title',
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Put image link (https)'),
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'name' => 'temp_image_link',
|
||||
'lang' => true,
|
||||
'desc' => 'If you select image bellow, This field will auto overrired',
|
||||
'form_group_class' => 'row-level2 image_link-slide'
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Image'),
|
||||
'type' => 'selectImg',
|
||||
'href' => $href,
|
||||
'name' => 'temp_image',
|
||||
'lang' => true,
|
||||
'class' => 'input-level2 temp_image js-multilang',
|
||||
'form_group_class' => 'row-level2 row2-image',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Image Align'),
|
||||
'name' => 'temp_imagealign',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'left',
|
||||
'name' => $this->l('Left'),
|
||||
),
|
||||
array(
|
||||
'id' => 'right',
|
||||
'name' => $this->l('Right'),
|
||||
),
|
||||
array(
|
||||
'id' => 'normal',
|
||||
'name' => $this->l('Normal'),
|
||||
),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => 'left',
|
||||
'class' => 'input-level2 temp_imagealign',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Description'),
|
||||
'name' => 'temp_description',
|
||||
'cols' => 40,
|
||||
'rows' => 10,
|
||||
'value' => true,
|
||||
'lang' => true,
|
||||
'default' => '',
|
||||
'class' => 'input-level2 temp_description js-multilang',
|
||||
'form_group_class' => 'row-level2 row2-description',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'temp_top',
|
||||
'label' => $this->l('Hotpot Top'),
|
||||
'lang' => false,
|
||||
'default' => '10',
|
||||
'class' => 'input-level2 temp_top',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'temp_left',
|
||||
'label' => $this->l('Hotpot Left'),
|
||||
'lang' => false,
|
||||
'default' => '10',
|
||||
'class' => 'input-level2 temp_left',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'color',
|
||||
'name' => 'temp_hpcolor',
|
||||
'label' => $this->l('Hotpot Color'),
|
||||
'lang' => false,
|
||||
'default' => '#000',
|
||||
'class' => 'input-level2 temp_hpcolor',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Location'),
|
||||
'name' => 'temp_location',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'top',
|
||||
'name' => $this->l('top'),
|
||||
),
|
||||
array(
|
||||
'id' => 'right',
|
||||
'name' => $this->l('right'),
|
||||
),
|
||||
array(
|
||||
'id' => 'bottom',
|
||||
'name' => $this->l('bottom'),
|
||||
),
|
||||
array(
|
||||
'id' => 'left',
|
||||
'name' => $this->l('left'),
|
||||
),
|
||||
array(
|
||||
'id' => 'top-left',
|
||||
'name' => $this->l('top-left'),
|
||||
),
|
||||
array(
|
||||
'id' => 'top-right',
|
||||
'name' => $this->l('top-right'),
|
||||
),
|
||||
array(
|
||||
'id' => 'right-top',
|
||||
'name' => $this->l('right-top'),
|
||||
),
|
||||
array(
|
||||
'id' => 'right-bottom',
|
||||
'name' => $this->l('right-bottom'),
|
||||
),
|
||||
array(
|
||||
'id' => 'bottom-left',
|
||||
'name' => $this->l('bottom-left'),
|
||||
),
|
||||
array(
|
||||
'id' => 'bottom-right',
|
||||
'name' => $this->l('bottom-right'),
|
||||
),
|
||||
array(
|
||||
'id' => 'left-top',
|
||||
'name' => $this->l('left-top'),
|
||||
),
|
||||
array(
|
||||
'id' => 'left-bottom',
|
||||
'name' => $this->l('left-bottom'),
|
||||
),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => 'none',
|
||||
'class' => 'input-level2 temp_location',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Text Align'),
|
||||
'name' => 'temp_textalign',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'left',
|
||||
'name' => $this->l('Left'),
|
||||
),
|
||||
array(
|
||||
'id' => 'top',
|
||||
'name' => $this->l('Top'),
|
||||
),
|
||||
array(
|
||||
'id' => 'right',
|
||||
'name' => $this->l('Right'),
|
||||
),
|
||||
array(
|
||||
'id' => 'center',
|
||||
'name' => $this->l('Center'),
|
||||
),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => 'left',
|
||||
'class' => 'input-level2 temp_textalign',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Mouse event'),
|
||||
'name' => 'temp_trigger',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'hover',
|
||||
'name' => $this->l('hover'),
|
||||
),
|
||||
array(
|
||||
'id' => 'hoverable',
|
||||
'name' => $this->l('hoverable'),
|
||||
),
|
||||
array(
|
||||
'id' => 'click',
|
||||
'name' => $this->l('click'),
|
||||
),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => 'hover',
|
||||
'class' => 'input-level2 temp_trigger',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'temp_opacity',
|
||||
'label' => $this->l('Opacity'),
|
||||
'lang' => false,
|
||||
'default' => '0.6',
|
||||
'class' => 'input-level2 temp_opacity',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'temp_class',
|
||||
'label' => $this->l('Class'),
|
||||
'lang' => false,
|
||||
'default' => '',
|
||||
'class' => 'input-level2 temp_class',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'temp_width',
|
||||
'label' => $this->l('Width'),
|
||||
'lang' => false,
|
||||
'default' => '200px',
|
||||
'class' => 'input-level2 temp_width',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'temp_margin',
|
||||
'label' => $this->l('Margin *'),
|
||||
'lang' => false,
|
||||
'default' => '0px',
|
||||
'class' => 'input-level2 temp_margin',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'temp_padding',
|
||||
'label' => $this->l('Padding'),
|
||||
'lang' => false,
|
||||
'default' => '',
|
||||
'class' => 'input-level2 temp_padding',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'color',
|
||||
'name' => 'temp_textcolor',
|
||||
'label' => $this->l('Text Color'),
|
||||
'lang' => false,
|
||||
'default' => '',
|
||||
'class' => 'input-level2 temp_textcolor',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'color',
|
||||
'name' => 'temp_backcolor',
|
||||
'label' => $this->l('Backgroud Color'),
|
||||
'lang' => false,
|
||||
'default' => '',
|
||||
'class' => 'input-level2 temp_backcolor',
|
||||
'form_group_class' => 'row-level2',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<script type="text/javascript" src="'.__PS_BASE_URI__.apPageHelper::getJsDir().'colorpicker/js/leo.jquery.colorpicker.js"></script>',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => $list_slider_button
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'total_slider',
|
||||
'default' => ''
|
||||
),
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function addConfigList($values)
|
||||
{
|
||||
// Get value with keys special
|
||||
$config_val = array();
|
||||
$total = isset($values['total_slider']) ? $values['total_slider'] : '';
|
||||
$arr = explode('|', $total);
|
||||
|
||||
$inputs_lang = $this->inputs_lang;
|
||||
$inputs = $this->inputs;
|
||||
|
||||
|
||||
$languages = Language::getLanguages(false);
|
||||
foreach ($arr as $i) {
|
||||
foreach ($inputs_lang as $config) {
|
||||
foreach ($languages as $lang) {
|
||||
$config_val[$config][$i][$lang['id_lang']] = str_replace($this->str_search, $this->str_relace_html_admin, Tools::getValue($config.'_'.$i.'_'.$lang['id_lang'], ''));
|
||||
}
|
||||
}
|
||||
foreach ($inputs as $config) {
|
||||
$config_val[$config][$i] = str_replace($this->str_search, $this->str_relace_html_admin, Tools::getValue($config.'_'.$i, ''));
|
||||
}
|
||||
}
|
||||
|
||||
Context::getContext()->smarty->assign(array(
|
||||
'lang' => $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')),
|
||||
'default_lang' => $lang->id,
|
||||
'arr' => $arr,
|
||||
'languages' => $languages,
|
||||
'config_val' => $config_val,
|
||||
'path' => apPageHelper::getImgThemeUrl(),
|
||||
'inputs_lang' => $this->inputs_lang,
|
||||
'inputs' => $this->inputs,
|
||||
));
|
||||
$list_slider = Context::getContext()->smarty->fetch(apPageHelper::getShortcodeTemplatePath('ApImageHotspot.tpl'));
|
||||
|
||||
$input = array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => $list_slider,
|
||||
);
|
||||
// Append new input type html
|
||||
$this->config_list[] = $input;
|
||||
}
|
||||
|
||||
public function endRenderForm()
|
||||
{
|
||||
$this->helper->module = new $this->module_name();
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
if (!Configuration::get('APPAGEBUILDER_LOAD_IMAGEHOTPOT')) {
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Please enable Image Hotpot library in Appagebuilder Configuration.';
|
||||
return $assign;
|
||||
}
|
||||
$assign['path'] = apPageHelper::getImgThemeUrl();
|
||||
$total_slider = isset($assign['formAtts']['total_slider']) ? $assign['formAtts']['total_slider'] : '';
|
||||
$list = explode('|', $total_slider);
|
||||
$list_items = array();
|
||||
$lang = Language::getLanguage(Context::getContext()->language->id);
|
||||
$id_lang = $lang['id_lang'];
|
||||
|
||||
$inputs_lang = $this->inputs_lang;
|
||||
$inputs = $this->inputs;
|
||||
|
||||
foreach ($list as $number) {
|
||||
if ($number) {
|
||||
$item = array();
|
||||
$item['id'] = $number;
|
||||
|
||||
foreach ($inputs_lang as $key) {
|
||||
# MULTI-LANG
|
||||
$name = $key.'_'.$number.'_'.$id_lang;
|
||||
$item[$key] = isset($assign['formAtts'][$name]) ? $assign['formAtts'][$name] : '';
|
||||
|
||||
// Description
|
||||
if ($key == 'temp_description' && isset($assign['formAtts'][$name]) && $assign['formAtts'][$name]) {
|
||||
$item[$key] = str_replace($this->str_search, $this->str_relace_html, $assign['formAtts'][$name]);
|
||||
}
|
||||
|
||||
// Image
|
||||
if ($key == 'temp_image' && isset($assign['formAtts'][$name]) && $assign['formAtts'][$name]) {
|
||||
$item[$key] = apPageHelper::getImgThemeUrl() . $assign['formAtts'][$name];
|
||||
} else if ($key == 'temp_image') {
|
||||
$item[$key] = '';
|
||||
}
|
||||
}
|
||||
foreach ($inputs as $key) {
|
||||
# SINGLE-LANG
|
||||
$name = $key.'_'.$number;
|
||||
$item[$key] = isset($assign['formAtts'][$name]) ? $assign['formAtts'][$name] : '';
|
||||
}
|
||||
|
||||
$list_items[] = $item;
|
||||
}
|
||||
}
|
||||
$assign['formAtts']['items'] = $list_items;
|
||||
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
576
modules/appagebuilder/classes/shortcodes/ApInstagram.php
Normal file
576
modules/appagebuilder/classes/shortcodes/ApInstagram.php
Normal file
@@ -0,0 +1,576 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApInstagram extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApInstagram';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Instagram'),
|
||||
'position' => 6,
|
||||
'desc' => $this->l('You can config Instagram box'),
|
||||
'icon_class' => 'icon-instagram',
|
||||
'tag' => 'social');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$accordion_type = array(
|
||||
array(
|
||||
'value' => 'full',
|
||||
'text' => $this->l('Always Full')
|
||||
),
|
||||
array(
|
||||
'value' => 'accordion',
|
||||
'text' => $this->l('Always Accordion')
|
||||
),
|
||||
array(
|
||||
'value' => 'accordion_small_screen',
|
||||
'text' => $this->l('Accordion at small screen')
|
||||
),
|
||||
);
|
||||
// $soption = ApPageSetting::returnYesNo();
|
||||
// $get = array(
|
||||
// array(
|
||||
// 'id' => 'popular',
|
||||
// 'label' => $this->l('Popular')
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'tagged',
|
||||
// 'label' => $this->l('Tagged'),
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'location',
|
||||
// 'label' => $this->l('Location')
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'user',
|
||||
// 'label' => $this->l('User')
|
||||
// ),
|
||||
// );
|
||||
// $sort = array(
|
||||
// array(
|
||||
// 'id' => 'none',
|
||||
// 'label' => $this->l('None')
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'most-recent',
|
||||
// 'label' => $this->l('Newest to oldest.'),
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'least-recent',
|
||||
// 'label' => $this->l('Oldest to newest.')
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'most-liked',
|
||||
// 'label' => $this->l('Highest # of likes to lowest.')
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'least-liked',
|
||||
// 'label' => $this->l('Lowest # likes to highest.')
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'most-commented',
|
||||
// 'label' => $this->l('Highest # of comments to lowest.')
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'least-commented',
|
||||
// 'label' => $this->l('Lowest # of comments to highest.')
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'random',
|
||||
// 'label' => $this->l('Random order.')
|
||||
// ),
|
||||
// );
|
||||
// $resolution = array(
|
||||
// array(
|
||||
// 'id' => '150',
|
||||
// 'label' => $this->l('150x150')
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => '200',
|
||||
// 'label' => $this->l('200x200')
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => '306',
|
||||
// 'label' => $this->l('306x306'),
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => '612',
|
||||
// 'label' => $this->l('612x612')
|
||||
// )
|
||||
// );
|
||||
// $display_type = array(
|
||||
// array(
|
||||
// 'id' => 'list',
|
||||
// 'label' => $this->l('Display as List')
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'carousel',
|
||||
// 'label' => $this->l('Display as Boostrap Carousel'),
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'owl-carousel',
|
||||
// 'label' => $this->l('Display as Owl Carousel')
|
||||
// )
|
||||
// );
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'desc' => $this->l('The script was get from http://instafeedjs.com/'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Accordion Type'),
|
||||
'name' => 'accordion_type',
|
||||
'options' => array(
|
||||
'query' => $accordion_type,
|
||||
'id' => 'value',
|
||||
'name' => 'text' ),
|
||||
'default' => 'full',
|
||||
'hint' => $this->l('Select a Accordion Type'),
|
||||
),
|
||||
// array(
|
||||
// 'type' => 'text',
|
||||
// 'label' => $this->l('Client ID'),
|
||||
// 'name' => 'client_id',
|
||||
// 'class' => 'ap_instagram',
|
||||
// 'desc' => $this->l('Your API client id from Instagram. Required.'),
|
||||
// 'default' => '3e4a239f6a704208ba131d140a751098',
|
||||
// ),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Access Token'),
|
||||
'name' => 'access_token',
|
||||
'class' => 'ap_instagram',
|
||||
'desc' => $this->l(''),
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '
|
||||
<a href="javascript:void(0);" id="leotheme_token_demo">Token Leotheme Demo</a>
|
||||
-
|
||||
<a target="_blank" href="https://demo1.leotheme.com/instagram.php?get_token=1&html=1" >Link</a>
|
||||
<br /><a target="_blank" href="https://www.youtube.com/watch?v=rWUcb8jXgVA">Youtube - How to get access token</a>
|
||||
<br /><a target="_blank" href="https://www.instagram.com/developer/">Instagram Developer</a>
|
||||
<br /><a target="_blank" href="https://developers.facebook.com/apps/">Facebook Developer</a>
|
||||
|
||||
',
|
||||
),
|
||||
// array(
|
||||
// 'type' => 'text',
|
||||
// 'label' => $this->l('Target'),
|
||||
// 'name' => 'target',
|
||||
// 'class' => 'ap_instagram',
|
||||
// 'desc' => $this->l('The ID of a DOM element you want to add the images to.'),
|
||||
// 'default' => '',
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'textarea',
|
||||
// 'label' => $this->l('Template'),
|
||||
// 'name' => 'template',
|
||||
// 'class' => 'ap_instagram',
|
||||
// 'desc' => $this->l('(Developer Only) Custom HTML template to use for images.'),
|
||||
// 'default' => '',
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'select',
|
||||
// 'label' => $this->l('Get'),
|
||||
// 'name' => 'get',
|
||||
// 'class' => 'ap_instagram',
|
||||
// 'options' => array(
|
||||
// 'query' => $get,
|
||||
// 'id' => 'id',
|
||||
// 'name' => 'label'
|
||||
// ),
|
||||
// 'desc' => $this->l('Customize what Instafeed fetches'),
|
||||
// 'default' => 'user',
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'text',
|
||||
// 'label' => $this->l('Tag Name'),
|
||||
// 'name' => 'tag_name',
|
||||
// 'desc' => $this->l('Name of the tag to get. Use with get: "tagged".'),
|
||||
// 'default' => '',
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'text',
|
||||
// 'label' => $this->l('Location ID'),
|
||||
// 'name' => 'location_id',
|
||||
// 'desc' => $this->l('(number) Unique id of a location to get. Use with get: "location".'),
|
||||
// 'default' => '',
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'text',
|
||||
// 'label' => $this->l('User ID'),
|
||||
// 'name' => 'user_id',
|
||||
// 'desc' => $this->l('User ID of Instagram Account. Type Number'),
|
||||
// 'default' => '3953969014',
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'select',
|
||||
// 'label' => $this->l('Sort By'),
|
||||
// 'name' => 'sort_by',
|
||||
// 'class' => 'ap_instagram',
|
||||
// 'options' => array(
|
||||
// 'query' => $sort,
|
||||
// 'id' => 'id',
|
||||
// 'name' => 'label'
|
||||
// ),
|
||||
// 'desc' => $this->l('Sort the images in a set order. Available options are'),
|
||||
// 'default' => 'none',
|
||||
// ),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Links'),
|
||||
'desc' => $this->l('Wrap the images with a link to the photo on Instagram. Set empty to use link of Instagram Image'),
|
||||
'name' => 'links',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Limit'),
|
||||
'desc' => $this->l('Number of Images want to get. Max is 20 images, this is rule of Instagram.'),
|
||||
'name' => 'limit',
|
||||
'default' => '20',
|
||||
),
|
||||
// array(
|
||||
// 'type' => 'select',
|
||||
// 'label' => $this->l('Resolution'),
|
||||
// 'name' => 'resolution',
|
||||
// 'class' => 'ap_instagram',
|
||||
// 'options' => array(
|
||||
// 'query' => $resolution,
|
||||
// 'id' => 'id',
|
||||
// 'name' => 'label'
|
||||
// ),
|
||||
// 'desc' => $this->l('Size of the images to show.'),
|
||||
// 'default' => '150',
|
||||
// ),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Profile Link'),
|
||||
'desc' => $this->l('Create link in footer link to profile'),
|
||||
'name' => 'profile_link',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="space" style="color:red">'.$this->l('Template Type').'</div>',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Carousel Type'),
|
||||
'class' => 'form-action',
|
||||
'name' => 'carousel_type',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'list', 'name' => $this->l('Normal List')),
|
||||
array('id' => 'owlcarousel', 'name' => $this->l('Owl Carousel')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => 'list'
|
||||
),
|
||||
//Owl Carousel begin
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="space" style="font-size:13px">'.$this->l('Items per Row').'</div>',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'items',
|
||||
'label' => $this->l('Items'),
|
||||
'desc' => $this->l('Typing number of items. Default'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
'default' => '5',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'itemsdesktop',
|
||||
'label' => $this->l('Items_Desktop'),
|
||||
'desc' => $this->l('Typing number of items ( with Screen < 1200 )'),
|
||||
'default' => '4',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'itemsdesktopsmall',
|
||||
'label' => $this->l('Items_Desktop_Small'),
|
||||
'desc' => $this->l('Typing number of items ( with Screen < 992 )'),
|
||||
'default' => '3',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'itemstablet',
|
||||
'label' => $this->l('Items_Tablet'),
|
||||
'desc' => $this->l('Typing number of items ( with Screen < 768 )'),
|
||||
'default' => '2',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'itemsmobile',
|
||||
'label' => $this->l('Items_Mobile'),
|
||||
'desc' => $this->l('Typing number of items ( with Screen < 576 )'),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'itemscustom',
|
||||
'label' => $this->l('Items_Custom'),
|
||||
'desc' => $this->l('(Advance User) Example: [[0, 2], [576, 3], [768, 4], [992, 5], [1200, 6]]. The format is [x,y] whereby x=browser width and y=number of slides displayed'),
|
||||
'default' => '',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'itempercolumn',
|
||||
'label' => $this->l('Items per Column'),
|
||||
'desc' => $this->l('Number of item per one column. Same with number of line for one page'),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="space" style="font-size:13px">'.$this->l('Effect').'</div>',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Autoplay'),
|
||||
'name' => 'autoplay',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('Yes - scroll per page. No - scroll per item. This affect next/prev buttons and mouse/touch dragging.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Stop on Hover'),
|
||||
'name' => 'stoponhover',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('Stop autoplay on mouse hover'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Responsive'),
|
||||
'name' => 'responsive',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('You can use Owl Carousel on desktop-only websites too! Just change that to "false" to disable resposive capabilities'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Navigation'),
|
||||
'name' => 'navigation',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('Display "next" and "prev" buttons.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Auto Height'),
|
||||
'name' => 'autoHeight',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('Add height to owl-wrapper-outer so you can use diffrent heights on slides. Use it only for one item per page setting.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Mouse Drag'),
|
||||
'name' => 'mouseDrag',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('On DeskTop - Turn off/on mouse events.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Touch Drag'),
|
||||
'name' => 'touchdrag',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('On Mobile - Turn off/on touch events.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="space" style="font-size:13px">'.$this->l('Lazy Load: This function is only work when have one item per column').'</div>',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Lazy Load'),
|
||||
'name' => 'lazyload',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'desc' => $this->l('Delays loading of images. Images outside of viewport will not be loaded before user scrolls to them. Great for mobile devices to speed up page loadings'),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Lazy Follow'),
|
||||
'name' => 'lazyfollow',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('When pagination used, it skips loading the images from pages that got skipped. It only loads the images that get displayed in viewport. If set to false, all images get loaded when pagination used. It is a sub setting of the lazy load function.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Lazy Effect'),
|
||||
'name' => 'lazyeffect',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'fade', 'name' => $this->l('fade')),
|
||||
array('id' => 'false', 'name' => $this->l('No')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'desc' => $this->l('Default is fadeIn on 400ms speed. Use false to remove that effect.'),
|
||||
'default' => 'fade',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Pagination Enable'),
|
||||
'name' => 'pagination',
|
||||
'is_bool' => true,
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'desc' => $this->l('Show Pagination below owl-carousel.'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Pagination Numbers'),
|
||||
'name' => 'paginationnumbers',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('Show numbers inside Pagination'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="space" style="font-size:13px">'.$this->l('NEXT PAGE').'</div>',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Scroll per Page'),
|
||||
'name' => 'scrollPerPage',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('Yes - scroll per Page. No - scroll per Item. This affect next/prev buttons and mouse/touch dragging.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Scroll Page Speed'),
|
||||
'name' => 'paginationspeed',
|
||||
'desc' => $this->l('Time to next page. Ex 800 ( Milliseconds )'),
|
||||
'default' => '800',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Scroll Item Speed'),
|
||||
'name' => 'slidespeed',
|
||||
'desc' => $this->l('Time to next item. Ex 200 (Milliseconds)'),
|
||||
'default' => '200',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
//Owl Carousel end
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
|
||||
if (!Configuration::get('APPAGEBUILDER_LOAD_INSTAFEED')) {
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Can not show Instagram. Please enable Instafeed library in Appagebuilder Configuration.';
|
||||
return $assign;
|
||||
} elseif (isset($assign['formAtts']['carousel_type']) && $assign['formAtts']['carousel_type'] == 'owlcarousel') {
|
||||
if (!Configuration::get('APPAGEBUILDER_LOAD_OWL')) {
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Can not show Instagram. Please enable Owl Carousel library in Appagebuilder Configuration.';
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
|
||||
$assign['formAtts']['get'] = 'user';
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,950 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApManuFacturersCarousel extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApManuFacturersCarousel';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Manufacturers carousel'), 'position' => 6,
|
||||
'desc' => $this->l('Show manufacturers in Carousel'), 'icon_class' => 'icon icon-chevron-right',
|
||||
'tag' => 'content slider');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
//get all manufacture
|
||||
$manufacturers = Manufacturer::getManufacturers(false, 0, true, false, false, false, true);
|
||||
// get image type
|
||||
$imagetype = ImageType::getImagesTypes('manufacturers');
|
||||
$iselect = Tools::getValue('value_by_manufacture');
|
||||
if ($iselect === '0') {
|
||||
$script_update_select = '<script>$("#value_by_manufacture").attr("checked", "checked");</script>';
|
||||
} else {
|
||||
$script_update_select = '<script>$("#value_by_manufacture").removeAttr("checked");</script>';
|
||||
}
|
||||
|
||||
$input = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-info">'.
|
||||
$this->l('Step 1: Use latest manufacturers or select Manufacturers').'</div>'.$script_update_select,
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'value_by',
|
||||
'label' => $this->l('Select manufacturers'),
|
||||
'class' => 'checkbox-group',
|
||||
'desc' => $this->l('Unchecked to show latest manufacturers'),
|
||||
'values' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'manufacture',
|
||||
'name' => $this->l('Select Manufacturers'),
|
||||
'val' => '0'
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Manufacture'),
|
||||
'name' => 'manuselect[]',
|
||||
'multiple' => true,
|
||||
'options' => array(
|
||||
'query' => $manufacturers,
|
||||
'id' => 'id_manufacturer',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => 'all',
|
||||
'form_group_class' => 'value_by_manufacture',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-info">'.$this->l('Step 2: Select image type').'</div>',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Image:'),
|
||||
'desc' => $this->l('Select image type for manufacture.'),
|
||||
'name' => 'imagetype',
|
||||
'default' => ApPageSetting::getDefaultNameImage('small'),
|
||||
'options' => array(
|
||||
'query' => $imagetype,
|
||||
'id' => 'name',
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-info">'.$this->l('Step 3: Product Order And Limit').'</div>',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Order Way'),
|
||||
'class' => 'form-action',
|
||||
'name' => 'order_way',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'asc', 'name' => $this->l('Asc')),
|
||||
array('id' => 'desc', 'name' => $this->l('Desc')),
|
||||
array('id' => 'random', 'name' => $this->l('Random'))),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => 'all',
|
||||
'form_group_class' => 'value_by_manufacture',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Order By'),
|
||||
'name' => 'order_by',
|
||||
'options' => array(
|
||||
'query' => ApPageSetting::getOrderByManu(),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'order_type_sub order_type-asc order_type-desc',
|
||||
'default' => 'all',
|
||||
'form_group_class' => 'value_by_manufacture',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'manu_limit',
|
||||
'label' => $this->l('Limit'),
|
||||
'default' => '10',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-info">'.$this->l('Step 3: Carousel Setting').'</div>',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Carousel Type'),
|
||||
'class' => 'form-action',
|
||||
'name' => 'carousel_type',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'boostrap', 'name' => $this->l('Bootstrap')),
|
||||
array('id' => 'owlcarousel', 'name' => $this->l('Owl Carousel')),
|
||||
array('id' => 'slickcarousel', 'name' => $this->l('Slick Carousel')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => 'boostrap'
|
||||
),
|
||||
//Owl Carousel begin
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="space" style="font-size:13px">'.$this->l('Items per Row').'</div>',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'items',
|
||||
'label' => $this->l('Items'),
|
||||
'desc' => $this->l('Typing number of items. Default'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
'default' => '5',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'itemsdesktop',
|
||||
'label' => $this->l('Items_Desktop'),
|
||||
'desc' => $this->l('Typing number of items ( with Screen < 1200 )'),
|
||||
'default' => '4',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'itemsdesktopsmall',
|
||||
'label' => $this->l('Items_Desktop_Small'),
|
||||
'desc' => $this->l('Typing number of items ( with Screen < 992 )'),
|
||||
'default' => '3',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'itemstablet',
|
||||
'label' => $this->l('Items_Tablet'),
|
||||
'desc' => $this->l('Typing number of items ( with Screen < 768 )'),
|
||||
'default' => '2',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'itemsmobile',
|
||||
'label' => $this->l('Items_Mobile'),
|
||||
'desc' => $this->l('Typing number of items ( with Screen < 576 )'),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'itemscustom',
|
||||
'label' => $this->l('Items_Custom'),
|
||||
'desc' => $this->l('(Advance User) Example: [[0, 2], [576, 3], [768, 4], [992, 5], [1200, 6]]. The format is [x,y] whereby x=browser width and y=number of slides displayed'),
|
||||
'default' => '',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'itempercolumn',
|
||||
'label' => $this->l('Items per Column'),
|
||||
'desc' => $this->l('Number of item per one column. Same with number of line for one page'),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="space" style="font-size:13px">'.$this->l('Effect').'</div>',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Autoplay'),
|
||||
'name' => 'autoplay',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('Yes - scroll per page. No - scroll per item. This affect next/prev buttons and mouse/touch dragging.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Stop on Hover'),
|
||||
'name' => 'stoponhover',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('Stop autoplay on mouse hover'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Responsive'),
|
||||
'name' => 'responsive',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('You can use Owl Carousel on desktop-only websites too! Just change that to "false" to disable resposive capabilities'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Navigation'),
|
||||
'name' => 'navigation',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('Display "next" and "prev" buttons.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Auto Height'),
|
||||
'name' => 'autoHeight',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('Add height to owl-wrapper-outer so you can use diffrent heights on slides. Use it only for one item per page setting.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Mouse Drag'),
|
||||
'name' => 'mouseDrag',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('On DeskTop - Turn off/on mouse events.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Touch Drag'),
|
||||
'name' => 'touchdrag',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('On Mobile - Turn off/on touch events.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="space" style="font-size:13px">'.$this->l('Lazy Load: This function is only work when have one item per column').'</div>',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Lazy Load'),
|
||||
'name' => 'lazyload',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'desc' => $this->l('Delays loading of images. Images outside of viewport will not be loaded before user scrolls to them. Great for mobile devices to speed up page loadings'),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Lazy Follow'),
|
||||
'name' => 'lazyfollow',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('When pagination used, it skips loading the images from pages that got skipped. It only loads the images that get displayed in viewport. If set to false, all images get loaded when pagination used. It is a sub setting of the lazy load function.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Lazy Effect'),
|
||||
'name' => 'lazyeffect',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'fade', 'name' => $this->l('fade')),
|
||||
array('id' => 'false', 'name' => $this->l('No')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'desc' => $this->l('Default is fadeIn on 400ms speed. Use false to remove that effect.'),
|
||||
'default' => 'fade',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Pagination Enable'),
|
||||
'name' => 'pagination',
|
||||
'is_bool' => true,
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'desc' => $this->l('Show Pagination below owl-carousel.'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Pagination Numbers'),
|
||||
'name' => 'paginationnumbers',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('Show numbers inside Pagination'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="space" style="font-size:13px">'.$this->l('NEXT PAGE').'</div>',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Scroll per Page'),
|
||||
'name' => 'scrollPerPage',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('Yes - scroll per Page. No - scroll per Item. This affect next/prev buttons and mouse/touch dragging.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '0',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Scroll Page Speed'),
|
||||
'name' => 'paginationspeed',
|
||||
'desc' => $this->l('Time to next page. Ex 800 ( Milliseconds )'),
|
||||
'default' => '800',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Scroll Item Speed'),
|
||||
'name' => 'slidespeed',
|
||||
'desc' => $this->l('Time to next item. Ex 200 (Milliseconds)'),
|
||||
'default' => '200',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-owlcarousel',
|
||||
),
|
||||
//Owl Carousel end
|
||||
//boostrap carousel begin
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'nbitemsperpage',
|
||||
'label' => $this->l('Number of Item per Page'),
|
||||
'desc' => $this->l('How many product you want to display in a Page. divisible by Item per Line (Desktop, Table, mobile)(default:12)'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-boostrap carousel_type-desc',
|
||||
'default' => '12',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="space">'.$this->l('Items per Row').'</div>',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-boostrap',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Items_Desktop ( >= 1200 )'),
|
||||
'name' => 'nbitemsperline_desktop',
|
||||
'default' => '',
|
||||
'options' => array('query' => array(
|
||||
array('id' => '', 'name' => $this->l('Default')),
|
||||
array('id' => '1', 'name' => $this->l('1 item')),
|
||||
array('id' => '2', 'name' => $this->l('2 items')),
|
||||
array('id' => '3', 'name' => $this->l('3 items')),
|
||||
array('id' => '4', 'name' => $this->l('4 items')),
|
||||
array('id' => '5', 'name' => $this->l('5 items')),
|
||||
array('id' => '6', 'name' => $this->l('6 items')),
|
||||
array('id' => '12', 'name' => $this->l('12 items')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'),
|
||||
'desc' => $this->l('How many product you want to display in a row of page. Default 4'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-boostrap carousel_type-desc',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Items_SmallDesktop ( >= 992 )'),
|
||||
'name' => 'nbitemsperline_smalldesktop',
|
||||
'default' => '',
|
||||
'options' => array('query' => array(
|
||||
array('id' => '', 'name' => $this->l('Default')),
|
||||
array('id' => '1', 'name' => $this->l('1 item')),
|
||||
array('id' => '2', 'name' => $this->l('2 items')),
|
||||
array('id' => '3', 'name' => $this->l('3 items')),
|
||||
array('id' => '4', 'name' => $this->l('4 items')),
|
||||
array('id' => '5', 'name' => $this->l('5 items')),
|
||||
array('id' => '6', 'name' => $this->l('6 items')),
|
||||
array('id' => '12', 'name' => $this->l('12 items')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'),
|
||||
'desc' => $this->l('How many product you want to display in a row of page. Default 3'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-boostrap carousel_type-desc',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Items_Tablet ( >= 768 )'),
|
||||
'name' => 'nbitemsperline_tablet',
|
||||
'default' => '',
|
||||
'options' => array('query' => array(
|
||||
array('id' => '', 'name' => $this->l('Default')),
|
||||
array('id' => '1', 'name' => $this->l('1 item')),
|
||||
array('id' => '2', 'name' => $this->l('2 items')),
|
||||
array('id' => '3', 'name' => $this->l('3 items')),
|
||||
array('id' => '4', 'name' => $this->l('4 items')),
|
||||
array('id' => '5', 'name' => $this->l('5 items')),
|
||||
array('id' => '6', 'name' => $this->l('6 items')),
|
||||
array('id' => '12', 'name' => $this->l('12 items')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'),
|
||||
'desc' => $this->l('How many product you want to display in a row of page. Default 3'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-boostrap carousel_type-desc',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Items_SmallDevices ( >= 576 )'),
|
||||
'name' => 'nbitemsperline_smalldevices',
|
||||
'default' => '',
|
||||
'options' => array('query' => array(
|
||||
array('id' => '', 'name' => $this->l('Default')),
|
||||
array('id' => '1', 'name' => $this->l('1 item')),
|
||||
array('id' => '2', 'name' => $this->l('2 items')),
|
||||
array('id' => '3', 'name' => $this->l('3 items')),
|
||||
array('id' => '4', 'name' => $this->l('4 items')),
|
||||
array('id' => '5', 'name' => $this->l('5 items')),
|
||||
array('id' => '6', 'name' => $this->l('6 items')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'),
|
||||
'desc' => $this->l('How many product you want to display in a row of page. Default 2'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-boostrap carousel_type-desc',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Items_ExtraSmallDevices ( >= 480 )'),
|
||||
'name' => 'nbitemsperline_extrasmalldevices',
|
||||
'default' => '',
|
||||
'options' => array('query' => array(
|
||||
array('id' => '', 'name' => $this->l('Default')),
|
||||
array('id' => '1', 'name' => $this->l('1 item')),
|
||||
array('id' => '2', 'name' => $this->l('2 items')),
|
||||
array('id' => '3', 'name' => $this->l('3 items')),
|
||||
array('id' => '4', 'name' => $this->l('4 items')),
|
||||
array('id' => '5', 'name' => $this->l('5 items')),
|
||||
array('id' => '6', 'name' => $this->l('6 items')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'),
|
||||
'desc' => $this->l('How many product you want to display in a row of page. Default 1'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-boostrap carousel_type-desc',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Items_Smartphone ( < 480 )'),
|
||||
'name' => 'nbitemsperline_smartphone',
|
||||
'default' => '',
|
||||
'options' => array('query' => array(
|
||||
array('id' => '', 'name' => $this->l('Default')),
|
||||
array('id' => '1', 'name' => $this->l('1 item')),
|
||||
array('id' => '2', 'name' => $this->l('2 items')),
|
||||
array('id' => '3', 'name' => $this->l('3 items')),
|
||||
array('id' => '4', 'name' => $this->l('4 items')),
|
||||
array('id' => '5', 'name' => $this->l('5 items')),
|
||||
array('id' => '6', 'name' => $this->l('6 items')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'),
|
||||
'desc' => $this->l('How many product you want to display in a row of page. Default 1'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-boostrap carousel_type-desc',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'interval',
|
||||
'label' => $this->l('interval'),
|
||||
'desc' => $this->l('The amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle.'),
|
||||
'default' => '5000',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-boostrap carousel_type-desc',
|
||||
),
|
||||
|
||||
//Slick carousel start
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Vertical'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
'name' => 'slick_vertical',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => '0', 'name' => $this->l('No')),
|
||||
array('id' => '1', 'name' => $this->l('Yes')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => '0'
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'slick_autoplay',
|
||||
'label' => $this->l('Auto play'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
'desc' => $this->l(''),
|
||||
'options' => array('query' => array(
|
||||
array('id' => '1', 'name' => $this->l('Yes')),
|
||||
array('id' => '0', 'name' => $this->l('No')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name')
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'slick_pauseonhover',
|
||||
'label' => $this->l('Pause on Hover'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
'desc' => $this->l(''),
|
||||
'options' => array('query' => array(
|
||||
array('id' => '1', 'name' => $this->l('Yes')),
|
||||
array('id' => '0', 'name' => $this->l('No')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name')
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'slick_loopinfinite',
|
||||
'label' => $this->l('Loop Infinite'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
'desc' => $this->l(''),
|
||||
'default' => '0',
|
||||
'options' => array('query' => array(
|
||||
array('id' => '0', 'name' => $this->l('No')),
|
||||
array('id' => '1', 'name' => $this->l('Yes')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'slick_arrows',
|
||||
'label' => $this->l('Prev/Next Arrows'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
'desc' => $this->l(''),
|
||||
'options' => array('query' => array(
|
||||
array('id' => '1', 'name' => $this->l('Yes')),
|
||||
array('id' => '0', 'name' => $this->l('No')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name')
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'slick_dot',
|
||||
'label' => $this->l('Show dot indicators'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
'desc' => $this->l(''),
|
||||
'default' => '0',
|
||||
'options' => array('query' => array(
|
||||
array('id' => '0', 'name' => $this->l('No')),
|
||||
array('id' => '1', 'name' => $this->l('Yes')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name')
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'slick_centermode',
|
||||
// 'class' => 'form-action',
|
||||
'label' => $this->l('Center mode'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
'desc' => $this->l(''),
|
||||
'default' => '0',
|
||||
'options' => array('query' => array(
|
||||
array('id' => '0', 'name' => $this->l('No')),
|
||||
array('id' => '1', 'name' => $this->l('Yes')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'slick_centerpadding',
|
||||
'label' => $this->l('Center padding'),
|
||||
'desc' => $this->l('Only for center mode. Unit is px (pixel). Default: 60(px)'),
|
||||
'default' => '60',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'slick_row',
|
||||
'label' => $this->l('Num Row'),
|
||||
'desc' => $this->l('Show number row display. Ex 1 or 1,2,3,4 '),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'slick_slidestoshow',
|
||||
'label' => $this->l('Slides To Show'),
|
||||
'desc' => $this->l('Number of item per row of page. Ex 1 or 1,2,3,4 '),
|
||||
'default' => '5',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'slick_slidestoscroll',
|
||||
'label' => $this->l('Slides To Scroll'),
|
||||
'desc' => $this->l('Number of column when scroll in slide. Ex 1 or 1,2,3,4 '),
|
||||
'default' => '1',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'slick_items_custom',
|
||||
'label' => $this->l('Display for other screen'),
|
||||
'desc' => $this->l('(Advance User) Example: [[1200, 6],[992, 5],[768, 4], [576, 3],[480, 2]]. The format is [x,y] whereby x=browser width and y=number of slides displayed'),
|
||||
'default' => '[[1200, 6],[992, 5],[768, 4], [576, 3],[480, 2]]',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'select',
|
||||
'name' => 'slick_custom_status',
|
||||
// 'class' => 'form-action',
|
||||
'label' => $this->l('Enable custom js slick'),
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
'desc' => $this->l('Only for developers and advanced users. Goto http://kenwheeler.github.io/slick/ for option'),
|
||||
'options' => array('query' => array(
|
||||
array('id' => '0', 'name' => $this->l('No')),
|
||||
array('id' => '1', 'name' => $this->l('Yes')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'),
|
||||
'default' => '0'
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'slick_custom',
|
||||
'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
'label' => $this->l('Custom js Slick'),
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '{
|
||||
dots: true,
|
||||
infinite: false,
|
||||
speed: 300,
|
||||
slidesToShow: 4,
|
||||
slidesToScroll: 4,
|
||||
responsive: [
|
||||
{
|
||||
breakpoint: 1024,
|
||||
settings: {
|
||||
slidesToShow: 3,
|
||||
slidesToScroll: 3,
|
||||
infinite: true,
|
||||
dots: true
|
||||
}
|
||||
},
|
||||
{
|
||||
breakpoint: 600,
|
||||
settings: {
|
||||
slidesToShow: 2,
|
||||
slidesToScroll: 2
|
||||
}
|
||||
},
|
||||
{
|
||||
breakpoint: 480,
|
||||
settings: {
|
||||
slidesToShow: 1,
|
||||
slidesToScroll: 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}',
|
||||
// 'form_group_class' => 'carousel_type_sub carousel_type-slickcarousel',
|
||||
),
|
||||
|
||||
//Slick carousel end
|
||||
|
||||
|
||||
);
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function endRenderForm()
|
||||
{
|
||||
// KEEP OLD DATA
|
||||
if (Tools::getIsset('nbitemsperline') && Tools::getValue('nbitemsperline')) {
|
||||
$this->helper->tpl_vars['fields_value']['nbitemsperline_desktop'] = Tools::getValue('nbitemsperline');
|
||||
$this->helper->tpl_vars['fields_value']['nbitemsperline_smalldesktop'] = Tools::getValue('nbitemsperline');
|
||||
$this->helper->tpl_vars['fields_value']['nbitemsperline_tablet'] = Tools::getValue('nbitemsperline');
|
||||
}
|
||||
|
||||
if (Tools::getIsset('nbitemsperlinetablet') && Tools::getValue('nbitemsperlinetablet')) {
|
||||
$this->helper->tpl_vars['fields_value']['nbitemsperline_smalldevices'] = Tools::getValue('nbitemsperlinetablet');
|
||||
}
|
||||
|
||||
if (Tools::getIsset('nbitemsperlinemobile') && Tools::getValue('nbitemsperlinemobile')) {
|
||||
$this->helper->tpl_vars['fields_value']['nbitemsperline_extrasmalldevices'] = Tools::getValue('nbitemsperlinemobile');
|
||||
$this->helper->tpl_vars['fields_value']['nbitemsperline_smartphone'] = Tools::getValue('nbitemsperlinemobile');
|
||||
}
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
if (isset($assign['formAtts']['carousel_type']) && $assign['formAtts']['carousel_type'] == 'owlcarousel') {
|
||||
if (!Configuration::get('APPAGEBUILDER_LOAD_OWL')) {
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Can not show ManuFacturer Carousel. Please enable Owl Carousel library in Appagebuilder Configuration.';
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
if (isset($assign['formAtts']['value_by_manufacture']) && $assign['formAtts']['value_by_manufacture'] == '0') {
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/libs/LeoProcessData.php');
|
||||
$assign['manuselect'] = LeoProcessData::getManufacturersSelect($assign['formAtts']);
|
||||
} else {
|
||||
// validate module
|
||||
$assign['manuselect'] = Manufacturer::getManufacturers(false, 0, true, 1, (int)$assign['formAtts']['manu_limit'], false, true);
|
||||
}
|
||||
$assign['manufacturers'] = $assign['manuselect'];
|
||||
$assign['image_type'] = ($assign['formAtts']['imagetype']) ? ($assign['formAtts']['imagetype']) : ApPageSetting::getDefaultNameImage('small');
|
||||
$assign['carouselName'] = 'carousel-'.ApPageSetting::getRandomNumber();
|
||||
if ($assign['formAtts']['carousel_type'] == 'boostrap') {
|
||||
if (isset($assign['formAtts']['nbitemsperline']) && $assign['formAtts']['nbitemsperline']) {
|
||||
$assign['formAtts']['nbitemsperline_desktop'] = $assign['formAtts']['nbitemsperline'];
|
||||
$assign['formAtts']['nbitemsperline_smalldesktop'] = $assign['formAtts']['nbitemsperline'];
|
||||
$assign['formAtts']['nbitemsperline_tablet'] = $assign['formAtts']['nbitemsperline'];
|
||||
}
|
||||
if (isset($assign['formAtts']['nbitemsperlinetablet']) && $assign['formAtts']['nbitemsperlinetablet']) {
|
||||
$assign['formAtts']['nbitemsperline_smalldevices'] = $assign['formAtts']['nbitemsperlinetablet'];
|
||||
}
|
||||
if (isset($assign['formAtts']['nbitemsperlinemobile']) && $assign['formAtts']['nbitemsperlinemobile']) {
|
||||
$assign['formAtts']['nbitemsperline_extrasmalldevices'] = $assign['formAtts']['nbitemsperlinemobile'];
|
||||
$assign['formAtts']['nbitemsperline_smartphone'] = $assign['formAtts']['nbitemsperlinemobile'];
|
||||
}
|
||||
|
||||
$assign['formAtts']['nbitemsperline_desktop'] = isset($assign['formAtts']['nbitemsperline_desktop']) && $assign['formAtts']['nbitemsperline_desktop'] ? (int)$assign['formAtts']['nbitemsperline_desktop'] : 4;
|
||||
$assign['formAtts']['nbitemsperline_smalldesktop'] = isset($assign['formAtts']['nbitemsperline_smalldesktop']) && $assign['formAtts']['nbitemsperline_smalldesktop'] ? (int)$assign['formAtts']['nbitemsperline_smalldesktop'] : 4;
|
||||
$assign['formAtts']['nbitemsperline_tablet'] = isset($assign['formAtts']['nbitemsperline_tablet']) && $assign['formAtts']['nbitemsperline_tablet'] ? (int)$assign['formAtts']['nbitemsperline_tablet'] : 3;
|
||||
$assign['formAtts']['nbitemsperline_smalldevices'] = isset($assign['formAtts']['nbitemsperline_smalldevices']) && $assign['formAtts']['nbitemsperline_smalldevices'] ? (int)$assign['formAtts']['nbitemsperline_smalldevices'] : 2;
|
||||
$assign['formAtts']['nbitemsperline_extrasmalldevices'] = isset($assign['formAtts']['nbitemsperline_extrasmalldevices']) && $assign['formAtts']['nbitemsperline_extrasmalldevices'] ? (int)$assign['formAtts']['nbitemsperline_extrasmalldevices'] : 1;
|
||||
$assign['formAtts']['nbitemsperline_smartphone'] = isset($assign['formAtts']['nbitemsperline_smartphone']) && $assign['formAtts']['nbitemsperline_smartphone'] ? (int)$assign['formAtts']['nbitemsperline_smartphone'] : 1;
|
||||
|
||||
$assign['tabname'] = 'carousel-'.ApPageSetting::getRandomNumber();
|
||||
$assign['itemsperpage'] = (int)$assign['formAtts']['nbitemsperpage'];
|
||||
$assign['nbItemsPerLine'] = (int)$assign['formAtts']['nbitemsperline_desktop'];
|
||||
|
||||
$assign['scolumn'] = '';
|
||||
|
||||
if ($assign['formAtts']['nbitemsperline_desktop'] == '5') {
|
||||
$assign['scolumn'] .= ' col-xl-2-4';
|
||||
} else {
|
||||
$assign['scolumn'] .= ' col-xl-' .str_replace('.', '-', ''.(int)(12 / $assign['formAtts']['nbitemsperline_desktop']));
|
||||
}
|
||||
|
||||
if ($assign['formAtts']['nbitemsperline_smalldesktop'] == '5') {
|
||||
$assign['scolumn'] .= ' col-lg-2-4';
|
||||
} else {
|
||||
$assign['scolumn'] .= ' col-lg-' .str_replace('.', '-', ''.(int)(12 / $assign['formAtts']['nbitemsperline_smalldesktop']));
|
||||
}
|
||||
|
||||
if ($assign['formAtts']['nbitemsperline_tablet'] == '5') {
|
||||
$assign['scolumn'] .= ' col-md-2-4';
|
||||
} else {
|
||||
$assign['scolumn'] .= ' col-md-' .str_replace('.', '-', ''.(int)(12 / $assign['formAtts']['nbitemsperline_tablet']));
|
||||
}
|
||||
|
||||
if ($assign['formAtts']['nbitemsperline_smalldevices'] == '5') {
|
||||
$assign['scolumn'] .= ' col-sm-2-4';
|
||||
} else {
|
||||
$assign['scolumn'] .= ' col-sm-' .str_replace('.', '-', ''.(int)(12 / $assign['formAtts']['nbitemsperline_smalldevices']));
|
||||
}
|
||||
|
||||
if ($assign['formAtts']['nbitemsperline_extrasmalldevices'] == '5') {
|
||||
$assign['scolumn'] .= ' col-xs-2-4';
|
||||
} else {
|
||||
$assign['scolumn'] .= ' col-xs-' .str_replace('.', '-', ''.(int)(12 / $assign['formAtts']['nbitemsperline_extrasmalldevices']));
|
||||
}
|
||||
|
||||
if ($assign['formAtts']['nbitemsperline_smartphone'] == '5') {
|
||||
$assign['scolumn'] .= ' col-sp-2-4';
|
||||
} else {
|
||||
$assign['scolumn'] .= ' col-sp-' .str_replace('.', '-', ''.(int)(12 / $assign['formAtts']['nbitemsperline_smartphone']));
|
||||
}
|
||||
}
|
||||
//DONGND:: create data for owl carousel with item custom
|
||||
if ($assign['formAtts']['carousel_type'] == 'owlcarousel') {
|
||||
//DONGND:: build data for fake item loading
|
||||
$assign['formAtts']['number_fake_item'] = $assign['formAtts']['items'];
|
||||
$array_fake_item = array();
|
||||
$array_fake_item['m'] = $assign['formAtts']['itemsmobile'];
|
||||
$array_fake_item['sm'] = $assign['formAtts']['itemstablet'];
|
||||
$array_fake_item['md'] = $assign['formAtts']['itemsdesktopsmall'];
|
||||
$array_fake_item['lg'] = $assign['formAtts']['itemsdesktop'];
|
||||
$array_fake_item['xl'] = $assign['formAtts']['items'];
|
||||
$assign['formAtts']['array_fake_item'] = $array_fake_item;
|
||||
|
||||
if (isset($assign['formAtts']['itemscustom']) && $assign['formAtts']['itemscustom'] != '') {
|
||||
$array_item_custom = Tools::jsonDecode($assign['formAtts']['itemscustom']);
|
||||
$array_item_custom_tmp = array();
|
||||
$array_number_item = array();
|
||||
foreach ($array_item_custom as $array_item_custom_val) {
|
||||
$size_window = $array_item_custom_val[0];
|
||||
$number_item = $array_item_custom_val[1];
|
||||
if (0 <= $size_window && $size_window < 576) {
|
||||
$array_item_custom_tmp['m'] = $number_item;
|
||||
} else if (576 <= $size_window && $size_window < 768) {
|
||||
$array_item_custom_tmp['sm'] = $number_item;
|
||||
} else if (768 <= $size_window && $size_window < 992) {
|
||||
$array_item_custom_tmp['md'] = $number_item;
|
||||
} else if (992 <= $size_window && $size_window < 1200) {
|
||||
$array_item_custom_tmp['lg'] = $number_item;
|
||||
} else if ($size_window >= 1200) {
|
||||
$array_item_custom_tmp['xl'] = $number_item;
|
||||
}
|
||||
$array_item_custom_tmp[$size_window] = $number_item;
|
||||
$array_number_item[] = $number_item;
|
||||
};
|
||||
$assign['formAtts']['array_fake_item'] = array_merge($array_fake_item, $array_item_custom_tmp);
|
||||
|
||||
if (max($array_number_item) > $assign['formAtts']['items']) {
|
||||
$assign['formAtts']['number_fake_item'] = max($array_number_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($assign['formAtts']['carousel_type'] == 'slickcarousel') {
|
||||
if (isset($assign['formAtts']['slick_items_custom'])) {
|
||||
$assign['formAtts']['slick_items_custom'] = str_replace($this->str_search, $this->str_relace, $assign['formAtts']['slick_items_custom']);
|
||||
}
|
||||
if (isset($assign['formAtts']['slick_custom'])) {
|
||||
$str_relace = array('&', '\"', '\'', '', '', '', '[', ']', '+', '{', '}');
|
||||
$assign['formAtts']['slick_custom'] = str_replace($this->str_search, $str_relace, $assign['formAtts']['slick_custom']);
|
||||
}
|
||||
if (isset($assign['formAtts']['slick_items_custom'])) {
|
||||
$assign['formAtts']['slick_items_custom'] = Tools::jsonDecode($assign['formAtts']['slick_items_custom']);
|
||||
}
|
||||
|
||||
//DONGND:: build data for fake item loading
|
||||
$assign['formAtts']['number_fake_item'] = $assign['formAtts']['slick_slidestoshow']*$assign['formAtts']['slick_row'];
|
||||
|
||||
if (isset($assign['formAtts']['slick_items_custom']) && $assign['formAtts']['slick_items_custom'] != '') {
|
||||
$array_item_custom = $assign['formAtts']['slick_items_custom'];
|
||||
$array_item_custom_tmp = array();
|
||||
$array_number_item = array();
|
||||
foreach ($array_item_custom as $array_item_custom_val) {
|
||||
$size_window = $array_item_custom_val[0];
|
||||
$number_item = $array_item_custom_val[1];
|
||||
if (0 <= $size_window && $size_window < 576) {
|
||||
$array_item_custom_tmp['m'] = $number_item;
|
||||
} else if (576 <= $size_window && $size_window < 768) {
|
||||
$array_item_custom_tmp['sm'] = $number_item;
|
||||
} else if (768 <= $size_window && $size_window < 992) {
|
||||
$array_item_custom_tmp['md'] = $number_item;
|
||||
} else if (992 <= $size_window && $size_window < 1200) {
|
||||
$array_item_custom_tmp['lg'] = $number_item;
|
||||
} else if ($size_window >= 1200) {
|
||||
$array_item_custom_tmp['xl'] = $assign['formAtts']['slick_slidestoshow'];
|
||||
}
|
||||
$number_item = $number_item*$assign['formAtts']['slick_row'];
|
||||
$array_item_custom_tmp[$size_window] = $number_item;
|
||||
$array_number_item[] = $number_item;
|
||||
};
|
||||
$assign['formAtts']['array_fake_item'] = $array_item_custom_tmp;
|
||||
|
||||
if (max($array_number_item) > $assign['formAtts']['slick_slidestoshow']) {
|
||||
$assign['formAtts']['number_fake_item'] = max($array_number_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
177
modules/appagebuilder/classes/shortcodes/ApMegamenu.php
Normal file
177
modules/appagebuilder/classes/shortcodes/ApMegamenu.php
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApMegamenu extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApMegamenu';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Megamenu Module'), 'position' => 3, 'desc' => $this->l('You can get group from leobootstrapmenu module'),
|
||||
'icon_class' => 'icon icon-chevron-right', 'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
if (Module::isInstalled('leobootstrapmenu') && Module::isEnabled('leobootstrapmenu')) {
|
||||
include_once(_PS_MODULE_DIR_.'leobootstrapmenu/leobootstrapmenu.php');
|
||||
$module = new Leobootstrapmenu();
|
||||
$list = $module->getGroups();
|
||||
// $controller = 'AdminModules';
|
||||
// $id_lang = Context::getContext()->language->id;
|
||||
// $params = array('token' => Tools::getAdminTokenLite($controller),
|
||||
// 'configure' => 'Leobootstrapmenu',
|
||||
// 'tab_module' => 'front_office_features',
|
||||
// 'module_name' => 'Leobootstrapmenu');
|
||||
//$url = dirname($_SERVER['PHP_SELF']).'/'.Dispatcher::getInstance()->createUrl($controller, $id_lang, $params, false);
|
||||
$url = Context::getContext()->link->getAdminLink('AdminLeoBootstrapMenuModule');
|
||||
if ($list && count($list) > 0) {
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Select a group for megamenu'),
|
||||
'name' => 'megamenu_group',
|
||||
'options' => array(
|
||||
'query' => $this->getListGroup($list),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'value_by_categories',
|
||||
'default' => 'all'
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class=""><a class="" href="'.$url.'" target="_blank">'.
|
||||
$this->l('Go to page configuration megamenu').'</a></div>'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Go to page setting of the module LeoSlideShow
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-warning">'.
|
||||
$this->l('There is no group in Leobootstrapmenu Module.').
|
||||
'</div><br/><div><center><a class="btn btn-primary" href="'.$url.'" target="_blank">'.
|
||||
$this->l(' CREATE GROUP ').'</a></center></div>'
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-warning">'.
|
||||
$this->l('"Leobootstrapmenu" Module must be installed and enabled before using.').
|
||||
'</div><br/><h4><center>You can take this module at leo-theme or apollo-theme</center></h4>'
|
||||
)
|
||||
);
|
||||
}
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function getListGroup($list)
|
||||
{
|
||||
$result = array();
|
||||
foreach ($list as $item) {
|
||||
$status = ' (ID: '.$item['id_btmegamenu_group'].' - '.($item['active'] ? $this->l('Active') : $this->l('Deactive')).')';
|
||||
$result[] = array('id' => $item['randkey'], 'name' => $item['title'].$status);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
if (Module::isInstalled('leobootstrapmenu') && Module::isEnabled('leobootstrapmenu')) {
|
||||
include_once(_PS_MODULE_DIR_.'leobootstrapmenu/leobootstrapmenu.php');
|
||||
$module = new Leobootstrapmenu();
|
||||
$id_shop = (int)Context::getContext()->shop->id;
|
||||
$assign['formAtts']['isEnabled'] = true;
|
||||
|
||||
$link_array = explode(',', $assign['formAtts']['megamenu_group']);
|
||||
if ($link_array && !is_numeric($link_array['0'])) {
|
||||
if (method_exists("BtmegamenuGroup", "cacheGroupsByFields")) {
|
||||
$result = array();
|
||||
|
||||
foreach ($link_array as $val) {
|
||||
//my module call this function from menu and we import it
|
||||
$temp = BtmegamenuGroup::cacheGroupsByFields(array('randkey' => $val));
|
||||
|
||||
if ($temp) {
|
||||
$result[] = $temp;
|
||||
}
|
||||
}
|
||||
if (is_array($result) && empty($result)) {
|
||||
$assign['formAtts']['isEnabled'] = false;
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Can not show LeoBootstrapMenu via Appagebuilder. Please check that The Group of LeoBootstrapMenu is exist.';
|
||||
return $assign;
|
||||
}
|
||||
|
||||
$where = '';
|
||||
foreach ($result as $group) {
|
||||
// validate module
|
||||
$where .= ($where == '') ? $group['id_btmegamenu_group'] : ','.$group['id_btmegamenu_group'];
|
||||
$where .= ',0';
|
||||
}
|
||||
$assign['formAtts']['megamenu_group'] = $where;
|
||||
} else {
|
||||
//fix for old version of leo bootrap menu
|
||||
$randkey_group = '';
|
||||
foreach ($link_array as $val) {
|
||||
// validate module
|
||||
$randkey_group .= ($randkey_group == '') ? "'".pSQL($val)."'" : ",'".pSQL($val)."'";
|
||||
}
|
||||
|
||||
$where = ' WHERE randkey IN ('.$randkey_group.') AND id_shop = ' . (int)$id_shop;
|
||||
$sql = 'SELECT id_btmegamenu_group FROM `'._DB_PREFIX_.'btmegamenu_group` '.$where;
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
if (is_array($result) && empty($result)) {
|
||||
$assign['formAtts']['isEnabled'] = false;
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Can not show LeoBootstrapMenu via Appagebuilder. Please check that The Group of LeoBootstrapMenu is exist.';
|
||||
return $assign;
|
||||
}
|
||||
|
||||
$where = '';
|
||||
foreach ($result as $blog) {
|
||||
// validate module
|
||||
$where .= ($where == '') ? $blog['id_btmegamenu_group'] : ','.$blog['id_btmegamenu_group'];
|
||||
}
|
||||
$assign['formAtts']['megamenu_group'] = $where;
|
||||
}
|
||||
}
|
||||
|
||||
$form_id = explode("_", $assign['formAtts']['form_id']);
|
||||
$assign['content_megamenu'] = $module->processHookCallBack($assign['formAtts']['megamenu_group'], $form_id[1]);
|
||||
} else {
|
||||
// validate module
|
||||
$assign['formAtts']['isEnabled'] = false;
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Can not show LeoBootstrapMenu via Appagebuilder. Please enable LeoBootstrapMenu module.';
|
||||
}
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
241
modules/appagebuilder/classes/shortcodes/ApModule.php
Normal file
241
modules/appagebuilder/classes/shortcodes/ApModule.php
Normal file
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
use PrestaShop\PrestaShop\Core\Module\WidgetInterface;
|
||||
|
||||
class ApModule extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApModule';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Module'),
|
||||
'position' => 5,
|
||||
'desc' => $this->l('Custom moule'),
|
||||
'icon_class' => 'icon-copy',
|
||||
'tag' => 'module');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
if (Tools::getIsset('edit')) {
|
||||
$name_module = Tools::getValue('name_module');
|
||||
} else {
|
||||
$name_module = Tools::getValue('type_shortcode');
|
||||
}
|
||||
if (!$name_module) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$module_WidgetInterface = false;
|
||||
# GET HOOK
|
||||
if (($module_instance = Module::getInstanceByName($name_module))) {
|
||||
if ($module_instance instanceof WidgetInterface) {
|
||||
# module has method function renderWidget()
|
||||
$module_WidgetInterface = true;
|
||||
$hooks = ApPageSetting::getOverrideHook();
|
||||
$arr = array(
|
||||
array(
|
||||
'id' => '',
|
||||
'name' => $this->l('--------- Select a Hook ---------')
|
||||
)
|
||||
);
|
||||
foreach ($hooks as $hook) {
|
||||
$arr[] = array(
|
||||
'id' => $hook,
|
||||
'name' => $hook,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# GET HOOK
|
||||
if ($module_WidgetInterface == false) {
|
||||
// Get list hook by id (this source code was coped from AdminApPageBuilderShortcodesController)
|
||||
$hook_assign = array('rightcolumn', 'leftcolumn', 'home', 'top', 'footer');
|
||||
$module_instance = ModuleCore::getInstanceByName($name_module);
|
||||
$hooks = array();
|
||||
$result = array();
|
||||
foreach ($hook_assign as $hook) {
|
||||
$retro_hook_name = Hook::getRetroHookName($hook);
|
||||
if (is_callable(array($module_instance, 'hook'.$hook)) || is_callable(array($module_instance, 'hook'.$retro_hook_name))) {
|
||||
$hooks[] = $retro_hook_name;
|
||||
}
|
||||
}
|
||||
if ($hooks) {
|
||||
$randkey_hook = '';
|
||||
foreach ($hooks as $val) {
|
||||
// validate module
|
||||
$randkey_hook .= ($randkey_hook == '') ? "'".pSQL($val)."'" : ",'".pSQL($val)."'";
|
||||
}
|
||||
|
||||
$result = Db::getInstance()->ExecuteS('
|
||||
SELECT `id_hook`, `name` FROM `'._DB_PREFIX_.'hook`
|
||||
WHERE `name` IN ('.$randkey_hook.')');
|
||||
}
|
||||
$arr = array(array('id' => '', 'name' => $this->l('--------- Select a Hook ---------')));
|
||||
$len = count($result);
|
||||
if ($result && $len > 0) {
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$arr[] = array('id' => $result[$i]['name'], 'name' => $result[$i]['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-info">Module name: <b>"'.$name_module
|
||||
.'"</b><input type="hidden" id="select-hook-error" value="'.$this->l('Please select a hook').'"/>
|
||||
<input type="hidden" id="name-module" name="name_module" value="'.$name_module.'"/>
|
||||
</div>',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'id' => 'select-hook',
|
||||
'label' => $this->l('Select hook of module (*)'),
|
||||
'name' => 'hook',
|
||||
'options' => array('query' => $arr,
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Remove display'),
|
||||
'desc' => $this->l('This module will remove in this hook'),
|
||||
'name' => 'is_display',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '1',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-danger">'.$this->l('Please consider using this function.
|
||||
This function is only for advance user,
|
||||
It will load other module and display in column of Appagebuilder.
|
||||
With some module have ID in wrapper DIV, your site will have Javascript Conflicts.
|
||||
We will not support this error.').'</div>',
|
||||
)
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
$form_attr = $assign['formAtts'];
|
||||
$context = Context::getContext();
|
||||
if (isset($form_attr['hook']) && isset($form_attr['name_module']) && Module::isEnabled($form_attr['name_module'])) {
|
||||
$assign['apContent'] = $this->execModuleHook($form_attr['hook'], array(), $form_attr['name_module'], false, $context->shop->id);
|
||||
}
|
||||
return $assign;
|
||||
}
|
||||
|
||||
public static function execModuleHook($hook_name = null, $hook_args = array(), $module_name = null, $use_push = false, $id_shop = null)
|
||||
{
|
||||
static $disable_non_native_modules = null;
|
||||
if ($disable_non_native_modules === null) {
|
||||
$disable_non_native_modules = (bool)Configuration::get('PS_DISABLE_NON_NATIVE_MODULE');
|
||||
}
|
||||
// Check arguments validity
|
||||
if (!Validate::isModuleName($module_name) || !Validate::isHookName($hook_name)) {
|
||||
return '';
|
||||
}
|
||||
//throw new PrestaShopException('Invalid module name or hook name');
|
||||
// If no modules associated to hook_name or recompatible hook name, we stop the function
|
||||
if (!Hook::getHookModuleExecList($hook_name)) {
|
||||
return '';
|
||||
}
|
||||
// Check if hook exists
|
||||
if (!$id_hook = Hook::getIdByName($hook_name)) {
|
||||
return false;
|
||||
}
|
||||
// Store list of executed hooks on this page
|
||||
Hook::$executed_hooks[$id_hook] = $hook_name;
|
||||
$context = Context::getContext();
|
||||
if (!isset($hook_args['cookie']) || !$hook_args['cookie']) {
|
||||
$hook_args['cookie'] = $context->cookie;
|
||||
}
|
||||
if (!isset($hook_args['cart']) || !$hook_args['cart']) {
|
||||
$hook_args['cart'] = $context->cart;
|
||||
}
|
||||
$retro_hook_name = Hook::getRetroHookName($hook_name);
|
||||
// Look on modules list
|
||||
$altern = 0;
|
||||
$output = '';
|
||||
if ($disable_non_native_modules && !isset(Hook::$native_module)) {
|
||||
Hook::$native_module = Module::getNativeModuleList();
|
||||
}
|
||||
$different_shop = false;
|
||||
if ($id_shop !== null && Validate::isUnsignedId($id_shop) && $id_shop != $context->shop->getContextShopID()) {
|
||||
$old_context = $context->shop->getContext();
|
||||
$old_shop = clone $context->shop;
|
||||
$shop = new Shop((int)$id_shop);
|
||||
if (Validate::isLoadedObject($shop)) {
|
||||
$context->shop = $shop;
|
||||
$context->shop->setContext(Shop::CONTEXT_SHOP, $shop->id);
|
||||
$different_shop = true;
|
||||
}
|
||||
}
|
||||
// Check errors
|
||||
if ((bool)$disable_non_native_modules && Hook::$native_module && count(Hook::$native_module) && !in_array($module_name, self::$native_module)) {
|
||||
return;
|
||||
}
|
||||
if (!($module_instance = Module::getInstanceByName($module_name))) {
|
||||
return;
|
||||
}
|
||||
if ($use_push && !$module_instance->allow_push) {
|
||||
return;
|
||||
}
|
||||
// Check which / if method is callable
|
||||
$hook_callable = is_callable(array($module_instance, 'hook'.$hook_name));
|
||||
$hook_retro_callable = is_callable(array($module_instance, 'hook'.$retro_hook_name));
|
||||
if (($hook_callable || $hook_retro_callable)) {
|
||||
$hook_args['altern'] = ++$altern;
|
||||
if ($use_push && isset($module_instance->push_filename) && file_exists($module_instance->push_filename)) {
|
||||
Tools::waitUntilFileIsModified($module_instance->push_filename, $module_instance->push_time_limit);
|
||||
}
|
||||
if ($hook_callable) {
|
||||
// Call hook method
|
||||
$display = $module_instance->{'hook'.$hook_name}($hook_args);
|
||||
} elseif ($hook_retro_callable) {
|
||||
$display = $module_instance->{'hook'.$retro_hook_name}($hook_args);
|
||||
}
|
||||
$output .= $display;
|
||||
} elseif (Hook::isDisplayHookName($hook_name)) {
|
||||
if ($module_instance instanceof WidgetInterface) {
|
||||
$display = Hook::coreRenderWidget($module_instance, $hook_name, $hook_args);
|
||||
|
||||
$output .= $display;
|
||||
}
|
||||
}
|
||||
|
||||
if ($different_shop) {
|
||||
$context->shop = $old_shop;
|
||||
$context->shop->setContext($old_context, $shop->id);
|
||||
}
|
||||
return $output; // Return html string
|
||||
}
|
||||
}
|
||||
1183
modules/appagebuilder/classes/shortcodes/ApProductCarousel.php
Normal file
1183
modules/appagebuilder/classes/shortcodes/ApProductCarousel.php
Normal file
File diff suppressed because it is too large
Load Diff
536
modules/appagebuilder/classes/shortcodes/ApProductList.php
Normal file
536
modules/appagebuilder/classes/shortcodes/ApProductList.php
Normal file
@@ -0,0 +1,536 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever;
|
||||
use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter;
|
||||
use PrestaShop\PrestaShop\Core\Product\ProductListingPresenter;
|
||||
use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever;
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageBuilderProductsModel.php');
|
||||
|
||||
class ApProductList extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApProductList';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Product List'),
|
||||
'position' => 7,
|
||||
'desc' => $this->l('Create Product List'),
|
||||
'icon_class' => 'icon icon-th',
|
||||
'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getAdditionConfig()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'type' => '',
|
||||
'name' => 'value_by_categories',
|
||||
'default' => '0'
|
||||
),
|
||||
array(
|
||||
'type' => '',
|
||||
'name' => 'value_by_product_type',
|
||||
'default' => '0'
|
||||
),
|
||||
array(
|
||||
'type' => '',
|
||||
'name' => 'value_by_manufacture',
|
||||
'default' => '0'
|
||||
),
|
||||
array(
|
||||
'type' => '',
|
||||
'name' => 'value_by_supplier',
|
||||
'default' => '0'
|
||||
),
|
||||
array(
|
||||
'type' => '',
|
||||
'name' => 'value_by_product_id',
|
||||
'default' => '0'
|
||||
),
|
||||
array(
|
||||
'type' => '',
|
||||
'name' => 'value_by_tags',
|
||||
'default' => '0'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$selected_categories = array();
|
||||
if (Tools::getIsset('categorybox')) {
|
||||
$category_box = Tools::getValue('categorybox');
|
||||
$selected_categories = explode(',', $category_box);
|
||||
}
|
||||
//get all manufacture
|
||||
$manufacturers = Manufacturer::getManufacturers(false, 0, true, false, false, false, true);
|
||||
$suppliers = Supplier::getSuppliers();
|
||||
// $product_active = ApPageBuilderProductsModel::getActive();
|
||||
// $product_class = $product_active['class'];
|
||||
$profile = new ApPageBuilderProductsModel();
|
||||
$profile_list = $profile->getAllProductProfileByShop();
|
||||
array_unshift($profile_list, array('plist_key' => 'default', 'name' => $this->l('Use Default')));
|
||||
$id_root_category = Context::getContext()->shop->getCategory();
|
||||
$input = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'), 'lang' => 'true',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-info">'.$this->l('Step 1: Product Filter').'</div>',
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'value_by',
|
||||
'label' => $this->l('Select By'),
|
||||
'class' => 'checkbox-group',
|
||||
'desc' => $this->l('Select Product Condition'),
|
||||
'values' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'categories',
|
||||
'name' => $this->l('Categories'),
|
||||
'val' => '1'
|
||||
),
|
||||
array(
|
||||
'id' => 'product_type',
|
||||
'name' => $this->l('Product Type'),
|
||||
'val' => '1'
|
||||
),
|
||||
array(
|
||||
'id' => 'manufacture',
|
||||
'name' => $this->l('Manufacture'),
|
||||
'val' => '1'
|
||||
),
|
||||
array(
|
||||
'id' => 'supplier',
|
||||
'name' => $this->l('Supplier'),
|
||||
'val' => '1'
|
||||
),
|
||||
array(
|
||||
'id' => 'product_id',
|
||||
'name' => $this->l('Product Ids'),
|
||||
'val' => '1'
|
||||
),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'categories',
|
||||
'label' => $this->l('Select Category'),
|
||||
'name' => 'categorybox',
|
||||
'desc' => $this->l('You can select one or more, if not select we will not search by category'),
|
||||
'tree' => array(
|
||||
'root_category' => $id_root_category,
|
||||
'use_search' => false,
|
||||
'id' => 'categorybox',
|
||||
'use_checkbox' => true,
|
||||
'selected_categories' => $selected_categories,
|
||||
),
|
||||
'form_group_class' => 'value_by_categories',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Product of Category'),
|
||||
'name' => 'category_type',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'all', 'name' => $this->l('Get All Product of Category')),
|
||||
array('id' => 'default', 'name' => $this->l('Get Product if category is default category of product'))),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'value_by_categories',
|
||||
'default' => 'all'
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="sperator"></div>',
|
||||
'form_group_class' => 'value_by_categories',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Product Type'),
|
||||
'name' => 'product_type',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'all',
|
||||
'name' => $this->l('All Product'),
|
||||
),
|
||||
array(
|
||||
'id' => 'new_product',
|
||||
'name' => $this->l('New Product'),
|
||||
),
|
||||
array(
|
||||
'id' => 'best_sellers',
|
||||
'name' => $this->l('Best sellers'),
|
||||
),
|
||||
array(
|
||||
'id' => 'price_drop',
|
||||
'name' => $this->l('Special'),
|
||||
),
|
||||
array(
|
||||
'id' => 'home_featured',
|
||||
'name' => $this->l('Home Featured'),
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'value_by_product_type',
|
||||
'default' => 'all',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="sperator"></div>',
|
||||
'form_group_class' => 'value_by_product_type',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Manufacture'),
|
||||
'name' => 'manufacture[]',
|
||||
'multiple' => true,
|
||||
'options' => array(
|
||||
'query' => $manufacturers,
|
||||
'id' => 'id_manufacturer',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'aprow_exceptions',
|
||||
'default' => 'all',
|
||||
'form_group_class' => 'value_by_manufacture',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="sperator"></div>',
|
||||
'form_group_class' => 'value_by_manufacture',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Supplier'),
|
||||
'name' => 'supplier[]',
|
||||
'multiple' => true,
|
||||
'options' => array(
|
||||
'query' => $suppliers,
|
||||
'id' => 'id_supplier',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'value_by_supplier',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="sperator"></div>',
|
||||
'form_group_class' => 'value_by_supplier',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'product_id',
|
||||
'label' => $this->l('Product Ids'),
|
||||
'desc' => $this->l('Show product follow product id. Ex 1 or 1,2,3,4 '),
|
||||
'default' => '',
|
||||
'form_group_class' => 'value_by_product_id',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="sperator"></div>',
|
||||
'form_group_class' => 'value_by_product_id',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-info">'.$this->l('Step 2: Product Order And Limit').'</div>',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Order Way'),
|
||||
'class' => 'form-action',
|
||||
'name' => 'order_way',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('id' => 'asc', 'name' => $this->l('Asc')),
|
||||
array('id' => 'desc', 'name' => $this->l('Desc')),
|
||||
array('id' => 'random', 'name' => $this->l('Random'))), // remove to increase speed
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => 'all'
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Order By'),
|
||||
'name' => 'order_by',
|
||||
'options' => array(
|
||||
'query' => ApPageSetting::getOrderBy(),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'order_type_sub order_type-asc order_type-desc',
|
||||
'default' => 'all'
|
||||
),
|
||||
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')),
|
||||
array('id' => '6', 'name' => $this->l('6 Columns')),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => '4',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'nb_products',
|
||||
'label' => $this->l('Limit'),
|
||||
'default' => '10',
|
||||
),
|
||||
//boostrap carousel end
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-info">'.$this->l('Step 3: Product Template').'</div>',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Product Template'),
|
||||
'name' => 'profile',
|
||||
'options' => array(
|
||||
'query' => $profile_list,
|
||||
'id' => 'plist_key',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => 'all'
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Use Animation For Product Item'),
|
||||
'name' => 'use_animation',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '1'
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Use Show More button'),
|
||||
'name' => 'use_showmore',
|
||||
'desc' => $this->l('Show button to load more product or hidden this function'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => '1'
|
||||
),
|
||||
);
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
$form_atts = $assign['formAtts'];
|
||||
$n = (int)isset($form_atts['nb_products']) ? $form_atts['nb_products'] : '10';
|
||||
$p = (int)Tools::getIsset('p') ? Tools::getValue('p') : '1';
|
||||
$form_atts['page_number'] = $p;
|
||||
$form_atts['get_total'] = true;
|
||||
$module = APPageBuilder::getInstance();
|
||||
$total = $module->getProductsFont($form_atts);
|
||||
$total = (is_array($total) && count($total) > 0) ? count($total) : 0;
|
||||
$form_atts['total_page'] = $total_page = ceil(($total / $n));
|
||||
|
||||
$products = array();
|
||||
if ($p <= $total_page) {
|
||||
$form_atts['get_total'] = false;
|
||||
$products = $module->getProductsFont($form_atts);
|
||||
$products = $this->loadProductDetail($products, $module);
|
||||
}
|
||||
|
||||
if (isset($assign['formAtts']['use_showmore']) && $assign['formAtts']['use_showmore']) {
|
||||
if ($p < $total_page) {
|
||||
$assign['formAtts']['use_showmore'] = 1;
|
||||
} else {
|
||||
$assign['formAtts']['use_showmore'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$assign['scolumn'] = $form_atts['columns'];
|
||||
$assign['products'] = $products;
|
||||
$assign['p'] = $p + 1;
|
||||
|
||||
$assign['productClassWidget'] = $this->getProductClassByPListKey($assign['formAtts']['profile']);
|
||||
|
||||
if (isset($assign['formAtts']['profile']) && $assign['formAtts']['profile'] != 'default' && file_exists(apPageHelper::getConfigDir('theme_profiles').$assign['formAtts']['profile'] . '.tpl')) {
|
||||
$assign['product_item_path'] = apPageHelper::getConfigDir('theme_profiles') . $assign['formAtts']['profile'].'.tpl';
|
||||
} else {
|
||||
// Default load file in theme
|
||||
$assign['product_item_path'] = 'catalog/_partials/miniatures/product.tpl';
|
||||
}
|
||||
|
||||
# DATA FOR AJAX
|
||||
$apPConfig = $form_atts;
|
||||
// FIX : special charactor http://screencast.com/t/cEqFoIL5K
|
||||
unset($apPConfig['title']);
|
||||
$apPConfig['product_item_path'] = $assign['product_item_path'];
|
||||
|
||||
$assign['apPConfig'] = call_user_func('base64'.'_encode', Tools::jsonEncode($apPConfig));
|
||||
return $assign;
|
||||
}
|
||||
|
||||
public function ajaxProcessRender($module)
|
||||
{
|
||||
$assign = array();
|
||||
$params = array();
|
||||
$input = Tools::jsonDecode(call_user_func('base64'.'_decode', Tools::getValue('config')));
|
||||
$use_animation = Tools::getValue('use_animation');
|
||||
$n = (int)isset($input->nb_products) ? $input->nb_products : '10';
|
||||
$p = (int)Tools::getIsset('p') ? Tools::getValue('p') : '1';
|
||||
$params['value_by_categories'] = isset($input->value_by_categories) ? $input->value_by_categories : '0';
|
||||
$params['value_by_product_type'] = isset($input->value_by_product_type) ? $input->value_by_product_type : '0';
|
||||
$params['value_by_manufacture'] = isset($input->value_by_manufacture) ? $input->value_by_manufacture : '0';
|
||||
$params['value_by_supplier'] = isset($input->value_by_supplier) ? $input->value_by_supplier : '0';
|
||||
$params['categorybox'] = isset($input->categorybox) ? $input->categorybox : '';
|
||||
$params['category_type'] = isset($input->category_type) ? $input->category_type : '';
|
||||
$params['product_type'] = isset($input->product_type) ? $input->product_type : '';
|
||||
$params['manufacture'] = isset($input->manufacture) ? $input->manufacture : '';
|
||||
$params['supplier'] = isset($input->supplier) ? $input->supplier : '';
|
||||
$params['nb_products'] = $n;
|
||||
$params['page_number'] = $p;
|
||||
$params['order_by'] = isset($input->order_by) ? $input->order_by : '';
|
||||
$params['order_way'] = isset($input->order_way) ? $input->order_way : '';
|
||||
$params['get_total'] = true;
|
||||
$params['override_folder'] = isset($input->override_folder) ? $input->override_folder : '';
|
||||
$assign['product_item_path'] = $input->product_item_path;
|
||||
$total_page = $input->total_page;
|
||||
|
||||
// FIX AJAX SHOW_MORE NOT GET PRODUCT_ID
|
||||
$input2 = Tools::jsonDecode(call_user_func('base64'.'_decode', Tools::getValue('config')), true);
|
||||
if (is_array($input2) && $input2) {
|
||||
$params = array_merge($input2, $params);
|
||||
}
|
||||
|
||||
|
||||
$is_more = ($p < $total_page) ? 'more' : '';
|
||||
$products = array();
|
||||
if ($p <= $total_page) {
|
||||
$params['get_total'] = false;
|
||||
$products = $module->getProductsFont($params);
|
||||
$products = $this->loadProductDetail($products, $module);
|
||||
}
|
||||
$assign['profile'] = (isset($input->profile) && $input->profile != 'default') ? $input->profile : '';
|
||||
$assign['products'] = $products;
|
||||
$assign['apAjax'] = 1;
|
||||
$assign['scolumn'] = $input->columns;
|
||||
$assign['formAtts']['use_animation'] = $use_animation;
|
||||
|
||||
$theme_name = apPageHelper::getThemeName();
|
||||
$tpl_name = 'ApProductList.tpl';
|
||||
if (isset($params['override_folder']) && file_exists(_PS_ALL_THEMES_DIR_.$theme_name.'/modules/appagebuilder/views/templates/hook/'.$params['override_folder'].'/'.$tpl_name)) {
|
||||
// overide_folder
|
||||
$tpl_file = _PS_ALL_THEMES_DIR_.$theme_name.'/modules/appagebuilder/views/templates/hook/'.$params['override_folder'].'/'.$tpl_name;
|
||||
// } elseif (file_exists(_PS_ALL_THEMES_DIR_.$theme_name.'/modules/appagebuilder/views/templates/hook/'.$hook_name.'/'.$tpl_name) || file_exists(dirname(__FILE__).'/views/templates/hook/'.$hook_name.'/'.$tpl_name)) {
|
||||
// $tpl_file = 'views/templates/hook/'.$hook_name.'/'.$tpl_name;
|
||||
} elseif (file_exists(_PS_ALL_THEMES_DIR_.$theme_name.'/modules/appagebuilder/views/templates/hook/'.$tpl_name) || file_exists(dirname(__FILE__).'/views/templates/hook/'.$tpl_name)) {
|
||||
// theme folder
|
||||
$tpl_file = _PS_ALL_THEMES_DIR_.$theme_name.'/modules/appagebuilder/views/templates/hook/'.$tpl_name;
|
||||
} else {
|
||||
// module folder
|
||||
$tpl_file = _PS_MODULE_DIR_.'appagebuilder/views/templates/hook/'.$tpl_name;
|
||||
}
|
||||
|
||||
$imageRetriever = new ImageRetriever(Context::getContext()->link);
|
||||
$urls = array();
|
||||
$urls['no_picture_image'] = $imageRetriever->getNoPictureImage(Context::getContext()->language);
|
||||
Context::getContext()->smarty->assign('urls', $urls);
|
||||
|
||||
foreach ($assign as $key => $ass) {
|
||||
Context::getContext()->smarty->assign(array($key => $ass));
|
||||
}
|
||||
$html = Context::getContext()->smarty->fetch($tpl_file);
|
||||
|
||||
return array('html' => $html, 'is_more' => $is_more);
|
||||
}
|
||||
|
||||
public function loadProductDetail($products, $module)
|
||||
{
|
||||
# 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();
|
||||
foreach ($products as $rawProduct) {
|
||||
$product_temp = $presenter->present(
|
||||
$presentationSettings,
|
||||
$assembler->assembleProduct($rawProduct),
|
||||
Context::getContext()->language
|
||||
);
|
||||
# FIX 1.7.5.0
|
||||
if (version_compare(_PS_VERSION_, '1.7.7.0', '<') && is_object($product_temp) && method_exists($product_temp, 'jsonSerialize')) {
|
||||
$product_temp = $product_temp->jsonSerialize();
|
||||
}
|
||||
# ADD SHORTCODE TO PRODUCT DESCRIPTION AND PRODUCT SHORT DESCRIPTION
|
||||
$product_temp['description'] = $module->buildShortCode($product_temp['description']);
|
||||
$product_temp['description_short'] = $module->buildShortCode($product_temp['description_short']);
|
||||
$products_for_template[] = $product_temp;
|
||||
}
|
||||
return $products_for_template;
|
||||
}
|
||||
}
|
||||
170
modules/appagebuilder/classes/shortcodes/ApProductTag.php
Normal file
170
modules/appagebuilder/classes/shortcodes/ApProductTag.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApProductTag extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApProductTag';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array(
|
||||
'label' => $this->l('Product Tags'),
|
||||
'position' => 4,
|
||||
'desc' => $this->l('Show Product Tags at Frontend'),
|
||||
'icon_class' => 'icon icon-tags',
|
||||
'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$accordion_type = array(
|
||||
array(
|
||||
'value' => 'full',
|
||||
'text' => $this->l('Always Full')
|
||||
),
|
||||
array(
|
||||
'value' => 'accordion',
|
||||
'text' => $this->l('Always Accordion')
|
||||
),
|
||||
array(
|
||||
'value' => 'accordion_small_screen',
|
||||
'text' => $this->l('Accordion at small screen')
|
||||
),
|
||||
);
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'autoload_rte' => false,
|
||||
'values' => '',
|
||||
'class' => 'sub_title',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Accordion Type'),
|
||||
'name' => 'accordion_type',
|
||||
'options' => array(
|
||||
'query' => $accordion_type,
|
||||
'id' => 'value',
|
||||
'name' => 'text'
|
||||
),
|
||||
'default' => 'full',
|
||||
'hint' => $this->l('Select a Accordion Type'),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'displayed_tags',
|
||||
'label' => $this->l('Displayed tags'),
|
||||
'desc' => $this->l('Set the number of tags you would like to see displayed in this block. (default: 10)'),
|
||||
'lang' => 'false',
|
||||
'default' => '10'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'tag_levels',
|
||||
'label' => $this->l('Tag levels'),
|
||||
'desc' => $this->l('Set the number of different tag levels you would like to use. (default: 3) '),
|
||||
'lang' => 'false',
|
||||
'default' => '10'
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Random display'),
|
||||
'name' => 'random_display',
|
||||
'class' => 'fixed-width-xs',
|
||||
'desc' => $this->l('If enabled, displays tags randomly. By default, random display is disabled and the most used tags are displayed first.'),
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'active_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'active_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
|
||||
$id_lang = (int) Context::getContext()->language->id;
|
||||
$displayed_tags = isset($assign['formAtts']['displayed_tags']) ? (int)$assign['formAtts']['displayed_tags'] : 10;
|
||||
$tag_levels = isset($assign['formAtts']['tag_levels']) ? (int)$assign['formAtts']['tag_levels'] : 10;
|
||||
$random_display = isset($assign['formAtts']['random_display']) ? (int)$assign['formAtts']['random_display'] : 0;
|
||||
|
||||
$tags = Tag::getMainTags($id_lang, $displayed_tags);
|
||||
|
||||
$max = -1;
|
||||
$min = -1;
|
||||
foreach ($tags as $tag) {
|
||||
if ($tag['times'] > $max) {
|
||||
$max = $tag['times'];
|
||||
}
|
||||
if ($tag['times'] < $min || $min == -1) {
|
||||
$min = $tag['times'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($min == $max) {
|
||||
$coef = $max;
|
||||
} else {
|
||||
$coef = ($tag_levels - 1) / ($max - $min);
|
||||
}
|
||||
|
||||
if (!count($tags)) {
|
||||
return $assign;
|
||||
}
|
||||
if ($random_display) {
|
||||
shuffle($tags);
|
||||
}
|
||||
foreach ($tags as &$tag) {
|
||||
$tag['class'] = 'tag_level'.(int)(($tag['times'] - $min) * $coef + 1);
|
||||
}
|
||||
|
||||
$assign['formAtts']['tags'] = $tags;
|
||||
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
120
modules/appagebuilder/classes/shortcodes/ApQuicklogin.php
Normal file
120
modules/appagebuilder/classes/shortcodes/ApQuicklogin.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApQuicklogin extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApQuicklogin';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Quicklogin Module'), 'position' => 3, 'desc' => $this->l('You set quick login or social login form from leoquicklogin module'),
|
||||
'icon_class' => 'icon icon-chevron-right', 'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
if (Module::isInstalled('leoquicklogin') && Module::isEnabled('leoquicklogin')) {
|
||||
include_once(_PS_MODULE_DIR_.'leoquicklogin/leoquicklogin.php');
|
||||
$module = new Leoquicklogin();
|
||||
$select_list_type = array();
|
||||
|
||||
foreach ($module->list_type as $key => $value) {
|
||||
$select_list_type[] = array('id' => $key, 'name' => $value);
|
||||
}
|
||||
|
||||
$select_list_layout = array();
|
||||
|
||||
foreach ($module->list_layout as $key => $value) {
|
||||
$select_list_layout[] = array('id' => $key, 'name' => $value);
|
||||
}
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Select type'),
|
||||
'name' => 'quicklogin_type',
|
||||
'options' => array(
|
||||
'query' => $select_list_type,
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Select layout'),
|
||||
'name' => 'quicklogin_layout',
|
||||
'options' => array(
|
||||
'query' => $select_list_layout,
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Show Social Login'),
|
||||
'name' => 'quicklogin_sociallogin',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'enable',
|
||||
'name' => $this->l('Yes'),
|
||||
),
|
||||
array(
|
||||
'id' => 'disable',
|
||||
'name' => $this->l('No'),
|
||||
)),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-warning">'.
|
||||
$this->l('"Leoquicklogin module" Module must be installed and enabled before using.').
|
||||
'</div><br/><h4><center>You can take this module at leo-theme or apollo-theme</center></h4>'
|
||||
)
|
||||
);
|
||||
}
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
if (Module::isInstalled('leoquicklogin') && Module::isEnabled('leoquicklogin')) {
|
||||
$assign['formAtts']['isEnabled'] = true;
|
||||
include_once(_PS_MODULE_DIR_.'leoquicklogin/leoquicklogin.php');
|
||||
$module = new Leoquicklogin();
|
||||
|
||||
$assign['content_quicklogin'] = $module->processHookCallBack($assign['formAtts']['quicklogin_type'], $assign['formAtts']['quicklogin_layout'], $assign['formAtts']['quicklogin_sociallogin']);
|
||||
} else {
|
||||
// validate module
|
||||
$assign['formAtts']['isEnabled'] = false;
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Can not show Leoquicklogin via Appagebuilder. Please enable Leoquicklogin module.';
|
||||
}
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
70
modules/appagebuilder/classes/shortcodes/ApRawHtml.php
Normal file
70
modules/appagebuilder/classes/shortcodes/ApRawHtml.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApRawHtml extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApRawHtml';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Raw Html'), 'position' => 3, 'desc' => $this->l('You can put raw html'),
|
||||
'icon_class' => 'icon-html5', 'tag' => 'content structure');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'content_html',
|
||||
'class' => 'ap_html_raw raw-'.time(),
|
||||
'rows' => '50',
|
||||
'lang' => true,
|
||||
'label' => $this->l('Raw html'),
|
||||
'values' => '',
|
||||
'default' => "<div>\n</div>"
|
||||
),
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
}
|
||||
790
modules/appagebuilder/classes/shortcodes/ApRow.php
Normal file
790
modules/appagebuilder/classes/shortcodes/ApRow.php
Normal file
@@ -0,0 +1,790 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
//require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageBuilderHookModel.php');
|
||||
|
||||
class ApRow extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApRow';
|
||||
public $for_module = 'manage';
|
||||
public $show_upload = '1';
|
||||
public $atribute = array('el_class' => '');
|
||||
public $profile_param = array();
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Row'), 'position' => 1,
|
||||
'desc' => $this->l('Each row can have one or more Column'),
|
||||
'tag' => 'content structure');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$input = array(
|
||||
array(
|
||||
'type' => 'tabConfig',
|
||||
'name' => 'tabConfig',
|
||||
'values' => array(
|
||||
'aprow_general' => $this->l('General'),
|
||||
'aprow_style' => $this->l('Style'),
|
||||
'aprow_background' => $this->l('Background'),
|
||||
// 'aprow_animation' => $this->l('Animation'),
|
||||
'aprow_exceptions' => $this->l('Exceptions'))
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'id',
|
||||
'label' => $this->l('ID'),
|
||||
'form_group_class' => 'aprow_general',
|
||||
'desc' => $this->l('Use for css and javascript'),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'container',
|
||||
'label' => $this->l('Class container'),
|
||||
'form_group_class' => 'aprow_general',
|
||||
'desc' => $this->getDescriptionContainerInput(),
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'ApRowclass',
|
||||
'name' => 'class',
|
||||
'leolabel' => 'CSS Class',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => 'row'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'min_height',
|
||||
'label' => $this->l('Minimum height'),
|
||||
'desc' => $this->l('You can use pixels : 10px or percents : 10%.'),
|
||||
'default' => '',
|
||||
'form_group_class' => 'aprow_style',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Margin Top'),
|
||||
'name' => 'margin_top',
|
||||
'desc' => $this->l('You can use pixels :10px or percents : 10%.'),
|
||||
'default' => '',
|
||||
'form_group_class' => 'aprow_style',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Margin Bottom'),
|
||||
'name' => 'margin_bottom',
|
||||
'desc' => $this->l('You can use pixels :10px or percents : 10%.'),
|
||||
'default' => '',
|
||||
'form_group_class' => 'aprow_style',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Padding Top'),
|
||||
'name' => 'padding_top',
|
||||
'desc' => $this->l('You can use pixels :10px or percents : 10%.'),
|
||||
'default' => '',
|
||||
'form_group_class' => 'aprow_style',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Padding Bottom'),
|
||||
'name' => 'padding_bottom',
|
||||
'desc' => $this->l('You can use pixels : 10px or percents : 10%.'),
|
||||
'default' => '',
|
||||
'form_group_class' => 'aprow_style',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Background Config'),
|
||||
'name' => 'bg_config',
|
||||
'default' => 'boxed',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'fullwidth',
|
||||
'name' => $this->l('Full width'),
|
||||
),
|
||||
array(
|
||||
'id' => 'boxed',
|
||||
'name' => $this->l('Boxed'),
|
||||
),
|
||||
array(
|
||||
'id' => 'none',
|
||||
'name' => $this->l('None'),
|
||||
),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'aprow_background',
|
||||
'desc' => $this->l('If your layout is boxed select background is boxed to run parallax.'),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Background Type'),
|
||||
'name' => 'bg_type',
|
||||
'class' => 'form-action',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'normal',
|
||||
'name' => $this->l('Normal'),
|
||||
),
|
||||
array(
|
||||
'id' => 'fixed',
|
||||
'name' => $this->l('Fixed'),
|
||||
),
|
||||
array(
|
||||
'id' => 'parallax',
|
||||
'name' => $this->l('Parallax'),
|
||||
),
|
||||
array(
|
||||
'id' => 'mouseparallax',
|
||||
'name' => $this->l('Mouse Parallax'),
|
||||
),
|
||||
// array(
|
||||
// 'id' => 'video_youtube',
|
||||
// 'name' => $this->l('Video Youtube'),
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'video_vimeo',
|
||||
// 'name' => $this->l('Vimeo video'),
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'video_html5',
|
||||
// 'name' => $this->l('HTML5'),
|
||||
// )
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'aprow_background',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Background size'),
|
||||
'name' => 'bg_size',
|
||||
'desc' => $this->l('Set CSS value for the background size. (Ex: contain, cover, 50% 100%, 100px 200px,..)'),
|
||||
'form_group_class' => 'aprow_background bg_type_sub bg_type-normal bg_type-fixed bg_type-parallax',
|
||||
),
|
||||
array(
|
||||
'type' => 'color',
|
||||
'label' => $this->l('Background color'),
|
||||
'name' => 'bg_color',
|
||||
'default' => '',
|
||||
'form_group_class' => 'aprow_background bg_type_sub bg_type-normal bg_type-fixed bg_type-parallax bg_type-mouseparallax',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<script type="text/javascript" src="'.__PS_BASE_URI__.apPageHelper::getJsDir().'colorpicker/js/leo.jquery.colorpicker.js"></script>',
|
||||
),
|
||||
array(
|
||||
'type' => 'bg_img',
|
||||
'label' => $this->l('Background image'),
|
||||
'name' => 'bg_img',
|
||||
// 'img_link' => _THEME_IMG_DIR_.'modules/'.$this->module_name.'/images/',
|
||||
'img_link' => _THEMES_DIR_.apPageHelper::getThemeName().'/assets/img/modules/'.$this->module_name.'/images/',
|
||||
'default' => '',
|
||||
'form_group_class' => 'aprow_background bg_type_sub bg_type-normal bg_type-fixed bg_type-parallax bg_type-mouseparallax',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Background position'),
|
||||
'name' => 'bg_position',
|
||||
'desc' => $this->l('Set CSS value for the background image position. (Ex: center top, right bottom, 50% 50%, 100px 200px,..)'),
|
||||
'form_group_class' => 'aprow_background bg_type_sub bg_type-normal bg_type-fixed bg_type-parallax',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Background repeat'),
|
||||
'name' => 'bg_repeat',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'no-repeat',
|
||||
'name' => $this->l('No repeat'),
|
||||
),
|
||||
array(
|
||||
'id' => 'repeat',
|
||||
'name' => $this->l('Repeat All'),
|
||||
),
|
||||
array(
|
||||
'id' => 'repeat-x',
|
||||
'name' => $this->l('repeat horizontally only'),
|
||||
),
|
||||
array(
|
||||
'id' => 'repeat-y',
|
||||
'name' => $this->l('repeat vertically only'),
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'aprow_background bg_type_sub bg_type-normal bg_type-fixed bg_type-parallax bg_type-mouseparallax',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Parallax speed'),
|
||||
'name' => 'parallax_speed',
|
||||
'default' => '0.1',
|
||||
'desc' => $this->l('Set the background speed, this is relative to the natural scroll speed (Ex: 0, 0.5, 1, 2).'),
|
||||
'form_group_class' => 'aprow_background bg_type_sub bg_type-parallax',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Parallax axis'),
|
||||
'desc' => $this->l('Select axis effect for this background.'),
|
||||
'name' => 'parallax_axis',
|
||||
'desc' => $this->l('Select axis effect for this background.'),
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'both',
|
||||
'name' => $this->l('Both'),
|
||||
),
|
||||
array(
|
||||
'id' => 'axis-x',
|
||||
'name' => $this->l('Axis X (horizontally)'),
|
||||
),
|
||||
array(
|
||||
'id' => 'axis-y',
|
||||
'name' => $this->l('Axis Y (vertically)'),
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'aprow_background bg_type_sub bg_type-mouseparallax',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Parallax strength'),
|
||||
'name' => 'parallax_strength',
|
||||
'default' => '0.5',
|
||||
'desc' => $this->l('Set the background strength, this is relative to the natural mouse speed (Ex: 0, 0.5, 1, 2).'),
|
||||
'form_group_class' => 'aprow_background bg_type_sub bg_type-mouseparallax',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Parallax rid'),
|
||||
'name' => 'parallax_rid',
|
||||
'default' => '0.5',
|
||||
'form_group_class' => 'aprow_background bg_type_sub bg_type-mouseparallax',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Parallax horizontal offsets'),
|
||||
'name' => 'parallax_hoffsets',
|
||||
'default' => '0.1',
|
||||
'desc' => $this->l('Set the global alignment horizontal offset'),
|
||||
'form_group_class' => 'aprow_background bg_type_sub bg_type-parallax',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Parallax vertical speed'),
|
||||
'name' => 'parallax_voffsets',
|
||||
'default' => '0.1',
|
||||
'desc' => $this->l('Set the global alignment vertical offset'),
|
||||
'form_group_class' => 'aprow_background bg_type_sub bg_type-parallax',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Video background'),
|
||||
'name' => 'video_link',
|
||||
'default' => '',
|
||||
'desc' => $this->l('Put video youtube link or vimeo'),
|
||||
'form_group_class' => 'aprow_background bg_type_sub bg_type-video_html5',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Video ID'),
|
||||
'name' => 'video_id',
|
||||
'default' => '',
|
||||
'desc' => $this->l('Put video ID of youtube link or vimeo'),
|
||||
'form_group_class' => 'aprow_background bg_type_sub bg_type-video_youtube bg_type-video_vimeo',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Specific Controller'),
|
||||
'name' => 'specific_type',
|
||||
'class' => 'form-action',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'all',
|
||||
'name' => $this->l('Show on all Page Controller'),
|
||||
),
|
||||
array(
|
||||
'id' => 'index',
|
||||
'name' => $this->l('Show on only Index'),
|
||||
),
|
||||
array(
|
||||
'id' => 'nocategory',
|
||||
'name' => $this->l('Category: Not Display In Category list'),
|
||||
),
|
||||
array(
|
||||
'id' => 'nocategoryproduct',
|
||||
'name' => $this->l('Category: Not Display In Category list and product of it'),
|
||||
),
|
||||
array(
|
||||
'id' => 'category',
|
||||
'name' => $this->l('Category: Display only Category list'),
|
||||
),
|
||||
array(
|
||||
'id' => 'categoryproduct',
|
||||
'name' => $this->l('Category: Display only Category list and product of Category'),
|
||||
),
|
||||
array(
|
||||
'id' => 'categoryproductmain',
|
||||
'name' => $this->l('Category: Display only Category list and product of Main Category'),
|
||||
),
|
||||
array(
|
||||
'id' => 'product',
|
||||
'name' => $this->l('Show on only Product'),
|
||||
),
|
||||
array(
|
||||
'id' => 'cms',
|
||||
'name' => $this->l('Show on only CMS'),
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'aprow_exceptions',
|
||||
'default' => 'all'
|
||||
),
|
||||
array(
|
||||
'type' => 'reloadControler',
|
||||
'label' => $this->l('AJAX Reload Controller'),
|
||||
'name' => 'reloadControler',
|
||||
'default' => '',
|
||||
'form_group_class' => 'aprow_exceptions specific_type_sub specific_type-all',
|
||||
'hint' => 'If website have new a Controller, click to generate Controller again.',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Controller ID'),
|
||||
'name' => 'controller_id',
|
||||
'desc' => $this->l('Example: 1,2,3'),
|
||||
'default' => '',
|
||||
'form_group_class' => 'aprow_exceptions specific_type_sub specific_type-category specific_type-nocategory specific_type-nocategoryproduct specific_type-categoryproduct specific_type-categoryproductmain specific_type-product specific_type-cms',
|
||||
),
|
||||
array(
|
||||
'type' => 'apExceptions',
|
||||
'name' => 'controller_pages',
|
||||
'form_group_class' => 'aprow_exceptions specific_type_sub specific_type-all',
|
||||
),
|
||||
);
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function endRenderForm()
|
||||
{
|
||||
// $display_module_exception = '';
|
||||
//
|
||||
// if (Tools::getValue('reloadControllerException')) {
|
||||
// # ReLoad : write to config
|
||||
// $display_module_exception = $this->displayModuleExceptionList();
|
||||
//
|
||||
// $ap_cache_controller_exception = apPageHelper::correctEnCodeData($display_module_exception);
|
||||
// Configuration::updateValue('AP_CACHE_CONTROLLER_EXCEPTION', $ap_cache_controller_exception);
|
||||
// } else {
|
||||
//
|
||||
// $display_module_exception = Configuration::get('AP_CACHE_CONTROLLER_EXCEPTION');
|
||||
// if ($display_module_exception === false)
|
||||
// {
|
||||
// # First Time : write to config
|
||||
// $display_module_exception = $this->displayModuleExceptionList();
|
||||
//
|
||||
// $ap_cache_controller_exception = apPageHelper::correctEnCodeData($display_module_exception);
|
||||
// Configuration::updateValue('AP_CACHE_CONTROLLER_EXCEPTION', $ap_cache_controller_exception);
|
||||
// } else {
|
||||
// # Second Time : read from config
|
||||
// $display_module_exception = apPageHelper::correctDeCodeData($display_module_exception);
|
||||
// }
|
||||
// }
|
||||
// $this->helper->tpl_vars['exception_list'] = $display_module_exception;
|
||||
$this->helper->module = new $this->module_name();
|
||||
$this->helper->tpl_vars['link'] = Context::getContext()->link;
|
||||
$this->helper->tpl_vars['exception_list'] = $this->displayModuleExceptionList();
|
||||
}
|
||||
|
||||
public function displayModuleExceptionList()
|
||||
{
|
||||
$controllers = array();
|
||||
$controllers_modules = array();
|
||||
$controllers_modules['admin'] = array();
|
||||
$controllers_modules['front'] = array();
|
||||
|
||||
if (Tools::getValue('reloadControllerException')) {
|
||||
$controllers = Dispatcher::getControllers(_PS_FRONT_CONTROLLER_DIR_);
|
||||
$controllers_modules = array(
|
||||
'admin' => Dispatcher::getModuleControllers('admin'),
|
||||
'front' => Dispatcher::getModuleControllers('front'),
|
||||
);
|
||||
|
||||
Configuration::updateValue('AP_CACHE_FRONT_CONTROLLER_EXCEPTION', apPageHelper::correctEnCodeData(Tools::jsonEncode($controllers)));
|
||||
Configuration::updateValue('AP_CACHE_FRONT_MODULE_EXCEPTION', apPageHelper::correctEnCodeData(Tools::jsonEncode($controllers_modules['admin'])));
|
||||
Configuration::updateValue('AP_CACHE_ADMIN_MODULE_EXCEPTION', apPageHelper::correctEnCodeData(Tools::jsonEncode($controllers_modules['front'])));
|
||||
} else {
|
||||
if (Configuration::get('AP_CACHE_FRONT_CONTROLLER_EXCEPTION') === false) {
|
||||
# First Time : write to config
|
||||
$controllers = Dispatcher::getControllers(_PS_FRONT_CONTROLLER_DIR_);
|
||||
Configuration::updateValue('AP_CACHE_FRONT_CONTROLLER_EXCEPTION', apPageHelper::correctEnCodeData(Tools::jsonEncode($controllers)));
|
||||
} else {
|
||||
# Second Time : read from config
|
||||
$controllers = Tools::jsonDecode(apPageHelper::correctDeCodeData(Configuration::get('AP_CACHE_FRONT_CONTROLLER_EXCEPTION')), true);
|
||||
}
|
||||
|
||||
if (Configuration::get('AP_CACHE_FRONT_MODULE_EXCEPTION') === false) {
|
||||
# First Time : write to config
|
||||
$controllers_modules['admin'] = Dispatcher::getModuleControllers('admin');
|
||||
Configuration::updateValue('AP_CACHE_FRONT_MODULE_EXCEPTION', apPageHelper::correctEnCodeData(Tools::jsonEncode($controllers_modules['admin'])));
|
||||
} else {
|
||||
# Second Time : read from config
|
||||
$controllers_modules['admin'] = Tools::jsonDecode(apPageHelper::correctDeCodeData(Configuration::get('AP_CACHE_FRONT_MODULE_EXCEPTION')), true);
|
||||
}
|
||||
|
||||
if (Configuration::get('AP_CACHE_ADMIN_MODULE_EXCEPTION') === false) {
|
||||
# First Time : write to config
|
||||
$controllers_modules['front'] = Dispatcher::getModuleControllers('front');
|
||||
Configuration::updateValue('AP_CACHE_ADMIN_MODULE_EXCEPTION', apPageHelper::correctEnCodeData(Tools::jsonEncode($controllers_modules['front'])));
|
||||
} else {
|
||||
# Second Time : read from config
|
||||
$controllers_modules['front'] = Tools::jsonDecode(apPageHelper::correctDeCodeData(Configuration::get('AP_CACHE_ADMIN_MODULE_EXCEPTION')), true);
|
||||
}
|
||||
}
|
||||
|
||||
$controller = Tools::getValue('controller_pages');
|
||||
$arr_controllers = explode(',', $controller);
|
||||
$arr_controllers = array_map('trim', $arr_controllers);
|
||||
|
||||
$modules_controllers_type = array('front' => $this->l('Front modules controller'), 'admin' => $this->l('Admin modules controller'));
|
||||
Context::getContext()->smarty->assign(array(
|
||||
'_core_' => $this->l('________________________________________ CORE ________________________________________'),
|
||||
'controller' => $controller,
|
||||
'arr_controllers' => $arr_controllers,
|
||||
'controllers' => $controllers,
|
||||
'modules_controllers_type' => $modules_controllers_type,
|
||||
'controllers_modules' => $controllers_modules,
|
||||
));
|
||||
$content = Context::getContext()->smarty->fetch(apPageHelper::getShortcodeTemplatePath('ApRow.tpl'));
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
// validate module
|
||||
unset($module);
|
||||
$form_atts = $assign['formAtts'];
|
||||
|
||||
//process back-ground
|
||||
$form_atts['bg_class'] = '';
|
||||
$form_atts['bg_data'] = '';
|
||||
$form_atts['parallax'] = '';
|
||||
$form_atts['bg_video'] = '';
|
||||
|
||||
//1. set class
|
||||
if (isset($form_atts['bg_config']) && $form_atts['bg_config'] != 'none') {
|
||||
$form_atts['bg_class'] = 'has-bg';
|
||||
//video
|
||||
if (isset($form_atts['bg_type']) && ($form_atts['bg_type'] == 'video_youtube' || $form_atts['bg_type'] == 'video_youtube' || $form_atts['bg_type'] == 'video_youtube')) {
|
||||
// validate module
|
||||
$form_atts['bg_video'] = $this->getBgStyleVideo($form_atts);
|
||||
} else {
|
||||
if ($form_atts['bg_config'] == 'boxed') {
|
||||
// validate module
|
||||
$form_atts['bg_class'] .= ' bg-boxed';
|
||||
} else {
|
||||
if (isset($form_atts['container']) && $form_atts['container']) {
|
||||
// validate module
|
||||
$form_atts['bg_class'] .= ' bg-fullwidth-container';
|
||||
} else {
|
||||
$form_atts['id'] = (isset($form_atts['id']) && $form_atts['id'] != '') ? $form_atts['id'] : $form_atts['form_id'];
|
||||
$form_atts['bg_class'] .= ' bg-fullwidth';
|
||||
}
|
||||
}
|
||||
if (isset($form_atts['bg_color']) && $form_atts['bg_color']) {
|
||||
// validate module
|
||||
$form_atts['bg_data'] .= ' '.$form_atts['bg_color'];
|
||||
}
|
||||
if (isset($form_atts['bg_img']) && $form_atts['bg_img']) {
|
||||
if (strpos($form_atts['bg_img'], '/') == false) {
|
||||
// validate module
|
||||
$form_atts['bg_img'] = _THEMES_DIR_.apPageHelper::getThemeName().'/assets/img/modules/'.$this->module_name.'/images/'.$form_atts['bg_img'];
|
||||
} else {
|
||||
$form_atts['bg_img'] = str_replace(apPageHelper::getStrSearch(), apPageHelper::getStrReplace(), $form_atts['bg_img']);
|
||||
}
|
||||
$form_atts['bg_img'] = $form_atts['bg_img'];
|
||||
}
|
||||
if (isset($form_atts['bg_type']) && $form_atts['bg_type'] == 'fixed') {
|
||||
// validate module
|
||||
$form_atts['bg_data'] .= ' fixed';
|
||||
}
|
||||
if ($form_atts['bg_repeat']) {
|
||||
// validate module
|
||||
$form_atts['bg_data'] .= ' '.$form_atts['bg_repeat'];
|
||||
}
|
||||
if (isset($form_atts['bg_position']) && $form_atts['bg_position']) {
|
||||
// validate module
|
||||
$form_atts['bg_data'] .= ' '.$form_atts['bg_position'];
|
||||
}
|
||||
if (isset($form_atts['bg_size']) && $form_atts['bg_size']) {
|
||||
if (!empty($form_atts['bg_data'])) {
|
||||
$form_atts['bg_data'] .= '; ';
|
||||
}
|
||||
|
||||
$form_atts['bg_data'] .= 'background-size: '.$form_atts['bg_size'];
|
||||
}
|
||||
//config for background style - stela - stela
|
||||
if (isset($form_atts['bg_img']) && $form_atts['bg_img'] && isset($form_atts['bg_type']) && $form_atts['bg_type'] == 'parallax') {
|
||||
$form_atts['bg_class'] .= ' bg-parallax';
|
||||
$hoffset = (isset($form_atts['parallax_hoffsets']) && $form_atts['parallax_hoffsets']) ? $form_atts['parallax_hoffsets'] : '40';
|
||||
$voffset = (isset($form_atts['parallax_voffsets']) && $form_atts['parallax_voffsets']) ? $form_atts['parallax_voffsets'] : '150';
|
||||
$bratio = (isset($form_atts['parallax_speed']) && $form_atts['parallax_speed']) ? $form_atts['parallax_speed'] : '0.5';
|
||||
|
||||
$form_atts['id'] = (isset($form_atts['id']) && $form_atts['id'] != '') ? $form_atts['id'] : $form_atts['form_id'];
|
||||
|
||||
$form_atts['parallax'] = 'data-stellar-horizontal-offset="'
|
||||
.$hoffset.'" data-stellar-vertical-offset="'.$voffset.'" data-stellar-background-ratio="'.$bratio.'"';
|
||||
}
|
||||
|
||||
if (isset($form_atts['bg_img']) && $form_atts['bg_img'] && isset($form_atts['bg_type']) && $form_atts['bg_type'] == 'mouseparallax') {
|
||||
$strength = (isset($form_atts['parallax_strength']) && $form_atts['parallax_strength']) ? $form_atts['parallax_strength'] : '40';
|
||||
$axis = (isset($form_atts['parallax_axis']) && $form_atts['parallax_axis']) ? $form_atts['parallax_axis'] : 'both';
|
||||
$rid = (isset($form_atts['parallax_rid']) && $form_atts['parallax_rid']) ? $form_atts['parallax_rid'] : '0.5';
|
||||
|
||||
$form_atts['id'] = $form_atts['form_id'];
|
||||
|
||||
$form_atts['parallax'] = 'data-mouse-parallax-strength="'.$strength.'" data-mouse-parallax-axis="'.$axis.'" data-mouse-parallax-rid="'.$rid.'"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($form_atts['animation']) || $form_atts['animation'] == 'none') {
|
||||
$form_atts['animation'] = 'none';
|
||||
$form_atts['animation_delay'] = '';
|
||||
} elseif ($form_atts['animation'] != 'none') {
|
||||
// validate module
|
||||
//DONGND:: add more config for animation
|
||||
if ((int)$form_atts['animation_delay'] >= 0) {
|
||||
$form_atts['animation_delay'] .= 's';
|
||||
} else {
|
||||
$form_atts['animation_delay'] = '1s';
|
||||
}
|
||||
|
||||
if (isset($form_atts['animation_duration']) && (int)$form_atts['animation_duration'] >= 0) {
|
||||
$form_atts['animation_duration'] .= 's';
|
||||
} else {
|
||||
$form_atts['animation_duration'] = '1s';
|
||||
}
|
||||
|
||||
if (isset($form_atts['animation_iteration_count']) && (int)$form_atts['animation_iteration_count'] > 0) {
|
||||
$form_atts['animation_iteration_count'] = (int)$form_atts['animation_iteration_count'];
|
||||
} else {
|
||||
$form_atts['animation_iteration_count'] = 1;
|
||||
}
|
||||
};
|
||||
|
||||
# set style
|
||||
$assign['formAtts'] = $form_atts;
|
||||
$form_atts['css_style'] = $this->showCSSStyle($assign);
|
||||
$assign['formAtts']['css_style'] = $this->showCSSStyle($assign);
|
||||
//not call this function in shortcode
|
||||
if ($this->profile_param) {
|
||||
$this->checkFullwidth($assign);
|
||||
}
|
||||
|
||||
|
||||
return $assign;
|
||||
}
|
||||
|
||||
//delete model return already value
|
||||
public function checkFullwidth(&$assign)
|
||||
{
|
||||
$page_name = apPageHelper::getPageName();
|
||||
$hook_name = ApShortCodesBuilder::$hook_name;
|
||||
|
||||
if ($page_name == 'index') {
|
||||
$hooks = $this->profile_param['fullwidth_index_hook'];
|
||||
} else {
|
||||
$hooks = $this->profile_param['fullwidth_other_hook'];
|
||||
}
|
||||
|
||||
if (isset($hooks[$hook_name]) && $hooks[$hook_name] == ApPageSetting::HOOK_FULWIDTH_INDEXPAGE) {
|
||||
// validate module
|
||||
$assign['formAtts']['container_remove'] = '0';
|
||||
} else {
|
||||
# remove container class - BEGIN
|
||||
if (isset($assign['formAtts']['container'])) {
|
||||
$str_search = array('/\bcontainer\b/');
|
||||
$str_replace = array('');
|
||||
$str_subject = $assign['formAtts']['container'];
|
||||
|
||||
$assign['formAtts']['container'] = preg_replace($str_search, $str_replace, $str_subject);
|
||||
$assign['formAtts']['container_remove'] = '1';
|
||||
}
|
||||
# remove container class - END
|
||||
}
|
||||
}
|
||||
|
||||
public function getHookLayout()
|
||||
{
|
||||
$hook_name = Tools::getValue('hook_name');
|
||||
return isset($this->profile_param['fullwidth_index_hook'][$hook_name]) ? $this->profile_param['fullwidth_index_hook'][$hook_name] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Live
|
||||
* not follow in database
|
||||
*/
|
||||
public function getRowLayOut($hook_layout)
|
||||
{
|
||||
$row_layout = ApPageSetting::ROW_BOXED;
|
||||
if ($hook_layout == ApPageSetting::HOOK_FULWIDTH_INDEXPAGE) {
|
||||
$row_container = Tools::getValue('container');
|
||||
if (!preg_match('/\bcontainer\b/', $row_container)) {
|
||||
// validate module
|
||||
$row_layout = ApPageSetting::ROW_FULWIDTH_INDEXPAGE;
|
||||
}
|
||||
}
|
||||
|
||||
return $row_layout;
|
||||
}
|
||||
|
||||
public function getDescriptionContainerInput()
|
||||
{
|
||||
$hook_layout = $this->getHookLayout();
|
||||
$row_layout = $this->getRowLayOut($hook_layout);
|
||||
|
||||
$id_profile = Tools::getValue('id_appagebuilder_profiles');
|
||||
$url_profile_edit = Context::getContext()->link->getAdminLink('AdminApPageBuilderProfiles').
|
||||
'&id_appagebuilder_profiles='.$id_profile.'&updateappagebuilder_profiles';
|
||||
$link = '<a href="'.$url_profile_edit.'" target="blank">edit profile</a>';
|
||||
|
||||
$hook_name = Tools::getValue('hook_name');
|
||||
|
||||
$row_layout_text = 'Boxed';
|
||||
if ($row_layout) {
|
||||
// validate module
|
||||
$row_layout_text = 'Fullwidth';
|
||||
}
|
||||
|
||||
$row_contain_class = 0;
|
||||
$row_container = Tools::getValue('container');
|
||||
if (preg_match('/\bcontainer\b/', $row_container)) {
|
||||
// validate module
|
||||
$row_contain_class = 1;
|
||||
}
|
||||
if ($row_layout) {
|
||||
# fullwidth
|
||||
$desc = 'Now Layout of Row is <strong>'.$row_layout_text.'</strong>, to change to Boxed :';
|
||||
$desc .= '<br />';
|
||||
$desc .= '- Typing "container" to above textbox.';
|
||||
} else {
|
||||
# boxed
|
||||
$desc = 'Now Layout of Row is <strong>'.$row_layout_text.'</strong>, to change to Fullwidth :';
|
||||
if ($row_contain_class) {
|
||||
$desc .= '<br />';
|
||||
$desc .= '- Removing "container" above textbox.';
|
||||
}
|
||||
if ($hook_layout == ApPageSetting::HOOK_BOXED) {
|
||||
$desc .= '<br />';
|
||||
$desc .= '- Going to '.$link.' check option "'.$hook_name.'" hook of "Fullwidth Homepage"';
|
||||
}
|
||||
}
|
||||
return $desc;
|
||||
}
|
||||
|
||||
public function showCSSStyle($assign)
|
||||
{
|
||||
$form_atts = $assign['formAtts'];
|
||||
$style = 'style="';
|
||||
if (isset($form_atts['bg_config']) && $form_atts['bg_config'] == 'boxed') {
|
||||
if (isset($form_atts['bg_img']) && $form_atts['bg_img'] && !Configuration::get('APPAGEBUILDER_LOAD_LAZY')) {
|
||||
$style .= 'background:url('.$form_atts['bg_img'].')'.$form_atts['bg_data'].';';
|
||||
} else {
|
||||
$style .= 'background:'.$form_atts['bg_data'].';';
|
||||
}
|
||||
}
|
||||
if (isset($form_atts['min_height']) && $form_atts['min_height']) {
|
||||
$style .= 'min-height: '.$form_atts['min_height'].';';
|
||||
}
|
||||
if (isset($form_atts['margin_top']) && $form_atts['margin_top']) {
|
||||
$style .= 'margin-top: '.$form_atts['margin_top'].';';
|
||||
}
|
||||
if (isset($form_atts['margin_bottom']) && $form_atts['margin_bottom']) {
|
||||
$style .= 'margin-bottom: '.$form_atts['margin_bottom'].';';
|
||||
}
|
||||
if (isset($form_atts['padding_top']) && $form_atts['padding_top']) {
|
||||
$style .= 'padding-top: '.$form_atts['padding_top'].';';
|
||||
}
|
||||
if (isset($form_atts['padding_bottom']) && $form_atts['padding_bottom']) {
|
||||
$style .= 'padding-bottom: '.$form_atts['padding_bottom'].';';
|
||||
}
|
||||
$style .= '"';
|
||||
return $style;
|
||||
}
|
||||
|
||||
public function getPageName()
|
||||
{
|
||||
// Are we in a payment module
|
||||
$module_name = '';
|
||||
if (Validate::isModuleName(Tools::getValue('module'))) {
|
||||
$module_name = Tools::getValue('module');
|
||||
}
|
||||
|
||||
if (!empty($this->page_name)) {
|
||||
$page_name = $this->page_name;
|
||||
} elseif (!empty($this->php_self)) {
|
||||
$page_name = $this->php_self;
|
||||
} elseif (Tools::getValue('fc') == 'module' && $module_name != '' && (Module::getInstanceByName($module_name) instanceof PaymentModule)) {
|
||||
$page_name = 'module-payment-submit';
|
||||
} elseif (preg_match('#^'.preg_quote(Context::getContext()->shop->physical_uri, '#').'modules/([a-zA-Z0-9_-]+?)/(.*)$#', $_SERVER['REQUEST_URI'], $m)) {
|
||||
// @retrocompatibility Are we in a module ?
|
||||
$page_name = 'module-'.$m[1].'-'.str_replace(array('.php', '/'), array('', '-'), $m[2]);
|
||||
} else {
|
||||
$page_name = Dispatcher::getInstance()->getController();
|
||||
$page_name = (preg_match('/^[0-9]/', $page_name) ? 'page_'.$page_name : $page_name);
|
||||
}
|
||||
return $page_name;
|
||||
}
|
||||
}
|
||||
183
modules/appagebuilder/classes/shortcodes/ApSlideShow.php
Normal file
183
modules/appagebuilder/classes/shortcodes/ApSlideShow.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApSlideShow extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApSlideShow';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Slide show Module'), 'position' => 3, 'desc' => $this->l('You can get group from leoslideshow module'),
|
||||
'icon_class' => 'icon icon-chevron-right', 'tag' => 'content slider');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
if (Module::isInstalled('leoslideshow') && Module::isEnabled('leoslideshow')) {
|
||||
include_once(_PS_MODULE_DIR_.'leoslideshow/leoslideshow.php');
|
||||
$module = new LeoSlideshow();
|
||||
$list = $module->getAllSlides();
|
||||
$controller = 'AdminModules';
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
$params = array('token' => Tools::getAdminTokenLite($controller),
|
||||
'configure' => 'leoslideshow',
|
||||
'tab_module' => 'front_office_features',
|
||||
'module_name' => 'leoslideshow');
|
||||
$url = dirname($_SERVER['PHP_SELF']).'/'.Dispatcher::getInstance()->createUrl($controller, $id_lang, $params, false);
|
||||
if ($list && count($list) > 0) {
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Select a group for slideshow'),
|
||||
'name' => 'slideshow_group',
|
||||
'options' => array(
|
||||
'query' => $this->getListGroup($list),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'value_by_categories',
|
||||
'default' => 'all'
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Select a group for slideshow on tablet'),
|
||||
'name' => 'slideshow_group_tablet',
|
||||
'options' => array(
|
||||
'query' => $this->getListGroup($list),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'value_by_categories',
|
||||
'default' => 'all'
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Select a group for slideshow on mobile'),
|
||||
'name' => 'slideshow_group_mobile',
|
||||
'options' => array(
|
||||
'query' => $this->getListGroup($list),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'value_by_categories',
|
||||
'default' => 'all'
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class=""><a class="" href="'.$url.'" target="_blank">'.
|
||||
$this->l('Go to page configuration Slider').'</a></div>'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Go to page setting of the module LeoSlideShow
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-warning">'.
|
||||
$this->l('There is no group slide in LeoSlideshow Module.').
|
||||
'</div><br/><div><center><a class="btn btn-primary" href="'.$url.'" target="_blank">'.
|
||||
$this->l(' CREATE GROUP SLIDER').'</a></center></div>'
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-warning">'.
|
||||
$this->l('"LeoSlideshow" Module must be installed and enabled before using.').
|
||||
'</div><br/><h4><center>You can take this module at leo-theme or apollo-theme</center></h4>'
|
||||
)
|
||||
);
|
||||
}
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function getListGroup($list)
|
||||
{
|
||||
$result = array();
|
||||
foreach ($list as $item) {
|
||||
$status = ' ('.($item['active'] ? $this->l('Active') : $this->l('Deactive')).')';
|
||||
$result[] = array('id' => $item['randkey'], 'name' => $item['title'].$status);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
if (Module::isInstalled('leoslideshow') && Module::isEnabled('leoslideshow')) {
|
||||
$id_shop = (int)Context::getContext()->shop->id;
|
||||
$assign['formAtts']['isEnabled'] = true;
|
||||
include_once(_PS_MODULE_DIR_.'leoslideshow/leoslideshow.php');
|
||||
$module = new LeoSlideshow();
|
||||
|
||||
if (Context::getContext()->isTablet()) {
|
||||
$link_array = explode(',', $assign['formAtts']['slideshow_group_tablet']);
|
||||
} elseif (Context::getContext()->isMobile()) {
|
||||
$link_array = explode(',', $assign['formAtts']['slideshow_group_mobile']);
|
||||
} else {
|
||||
$link_array = explode(',', $assign['formAtts']['slideshow_group']);
|
||||
}
|
||||
if ($link_array[0] == '') {
|
||||
$link_array = explode(',', $assign['formAtts']['slideshow_group']);
|
||||
}
|
||||
if ($link_array && !is_numeric($link_array['0'])) {
|
||||
$randkey_group = '';
|
||||
foreach ($link_array as $val) {
|
||||
// validate module
|
||||
$randkey_group .= ($randkey_group == '') ? "'".pSQL($val)."'" : ",'".pSQL($val)."'";
|
||||
}
|
||||
$where = ' WHERE randkey IN ('.$randkey_group.') AND id_shop = ' . (int)$id_shop;
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT id_leoslideshow_groups FROM `'._DB_PREFIX_.'leoslideshow_groups` '.$where);
|
||||
$where = '';
|
||||
|
||||
if (is_array($result) && !empty($result)) {
|
||||
foreach ($result as $slide) {
|
||||
// validate module
|
||||
$where .= ($where == '') ? $slide['id_leoslideshow_groups'] : ','.$slide['id_leoslideshow_groups'];
|
||||
}
|
||||
if (Context::getContext()->isTablet()) {
|
||||
$assign['formAtts']['slideshow_group_tablet'] = $where;
|
||||
$assign['content_slider'] = $module->processHookCallBack($assign['formAtts']['slideshow_group_tablet']);
|
||||
} elseif (Context::getContext()->isMobile()) {
|
||||
$assign['formAtts']['slideshow_group_mobile'] = $where;
|
||||
$assign['content_slider'] = $module->processHookCallBack($assign['formAtts']['slideshow_group_mobile']);
|
||||
} else {
|
||||
$assign['formAtts']['slideshow_group'] = $where;
|
||||
$assign['content_slider'] = $module->processHookCallBack($assign['formAtts']['slideshow_group']);
|
||||
}
|
||||
} else {
|
||||
$assign['formAtts']['isEnabled'] = false;
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Can not show LeoSlideShow via Appagebuilder. Please check that The Group of LeoSlideShow is exist.';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$assign['formAtts']['isEnabled'] = false;
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Can not show LeoSlideShow via Appagebuilder. Please enable LeoSlideShow module.';
|
||||
}
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
138
modules/appagebuilder/classes/shortcodes/ApSliderLayer.php
Normal file
138
modules/appagebuilder/classes/shortcodes/ApSliderLayer.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApSliderLayer extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApSliderLayer';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Slider Layer Module'), 'position' => 3, 'desc' => $this->l('You can group from leosliderlayer module to display'),
|
||||
'icon_class' => 'icon icon-chevron-right', 'tag' => 'content slider');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
if (Module::isInstalled('leosliderlayer') && Module::isEnabled('leosliderlayer')) {
|
||||
include_once(_PS_MODULE_DIR_.'leosliderlayer/leosliderlayer.php');
|
||||
$module = new LeoSliderLayer();
|
||||
$list = $module->getAllSlides();
|
||||
$controller = 'AdminModules';
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
$params = array('token' => Tools::getAdminTokenLite($controller),
|
||||
'configure' => 'leosliderlayer',
|
||||
'tab_module' => 'front_office_features',
|
||||
'module_name' => 'leosliderlayer');
|
||||
$url = dirname($_SERVER['PHP_SELF']).'/'.Dispatcher::getInstance()->createUrl($controller, $id_lang, $params, false);
|
||||
if ($list && count($list) > 0) {
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Select a group for slider layer'),
|
||||
'name' => 'slideshow_group',
|
||||
'options' => array(
|
||||
'query' => $this->getListGroup($list),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'form_group_class' => 'value_by_categories',
|
||||
'default' => 'all'
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class=""><a class="" href="'.$url.'" target="_blank">'.
|
||||
$this->l('Go to page configuration Slider').'</a></div>'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Go to page setting of the module LeoSlideShow
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-warning">'.
|
||||
$this->l('There is no group slide in Leosliderlayer Module.').
|
||||
'</div><br/><div><center><a class="btn btn-primary" href="'.$url.'" target="_blank">'.
|
||||
$this->l(' CREATE GROUP SLIDER').'</a></center></div>'
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<div class="alert alert-warning">'.
|
||||
$this->l('"Leosliderlayer" Module must be installed and enabled before using.').
|
||||
'</div><br/><h4><center>You can take this module at leo-theme or apollo-theme</center></h4>'
|
||||
)
|
||||
);
|
||||
}
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
public function getListGroup($list)
|
||||
{
|
||||
$result = array();
|
||||
foreach ($list as $item) {
|
||||
$status = ' ('.($item['active'] ? $this->l('Active') : $this->l('Deactive')).')';
|
||||
$result[] = array('id' => $item['id_leosliderlayer_groups'], 'name' => $item['title'].$status);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function prepareFontContent($assign, $module = null)
|
||||
{
|
||||
if (Module::isInstalled('leosliderlayer') && Module::isEnabled('leosliderlayer')) {
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
$assign['formAtts']['isEnabled'] = true;
|
||||
include_once(_PS_MODULE_DIR_.'leosliderlayer/leosliderlayer.php');
|
||||
$module = new LeoSliderLayer();
|
||||
//print_r($assign['slideshow_group']['slideshow_group']);
|
||||
$link_array = explode(',', $assign['formAtts']['slideshow_group']);
|
||||
if ($link_array && !is_numeric($link_array['0'])) {
|
||||
$randkey_title = '';
|
||||
foreach ($link_array as $val) {
|
||||
// validate module
|
||||
$randkey_title .= ($randkey_title == '') ? "'".pSQL($val)."'" : ",'".pSQL($val)."'";
|
||||
}
|
||||
|
||||
$where = ' WHERE title IN ('.$randkey_title.') AND id_shop = ' . (int)$id_shop;
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT id_leoslideshow_groups FROM `'._DB_PREFIX_.'leoslideshow_groups` '.pSQL($where));
|
||||
$where = '';
|
||||
foreach ($result as $blog) {
|
||||
// validate module
|
||||
$where .= ($where == '') ? $blog['id_leoslideshow_groups'] : ','.$blog['id_leoslideshow_groups'];
|
||||
}
|
||||
$assign['formAtts']['slideshow_group'] = $where;
|
||||
}
|
||||
$assign['content_slider'] = $module->processHookCallBack($assign['formAtts']['slideshow_group']);
|
||||
//$module->processHookCallBack();
|
||||
} else {
|
||||
// validate module
|
||||
$assign['formAtts']['isEnabled'] = false;
|
||||
$assign['formAtts']['lib_has_error'] = true;
|
||||
$assign['formAtts']['lib_error'] = 'Can not show LeoSliderLayer via Appagebuilder. Please enable LeoSliderLayer module.';
|
||||
}
|
||||
return $assign;
|
||||
}
|
||||
}
|
||||
419
modules/appagebuilder/classes/shortcodes/ApTabs.php
Normal file
419
modules/appagebuilder/classes/shortcodes/ApTabs.php
Normal file
@@ -0,0 +1,419 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApTabs extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApTabs';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Tabs'), 'position' => 4,
|
||||
'desc' => $this->l('You can put widget in tab'),
|
||||
'icon_class' => 'icon-html5', 'tag' => 'content');
|
||||
}
|
||||
|
||||
public function getConfigList($sub_tab = 0)
|
||||
{
|
||||
Context::getContext()->smarty->assign('path_image', apPageHelper::getImgThemeUrl());
|
||||
$href = Context::getContext()->link->getAdminLink('AdminApPageBuilderImages').'&ajax=1&action=manageimage&imgDir=images';
|
||||
if (Tools::getIsset('subTab') || $sub_tab) {
|
||||
$input = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'lang' => 'true',
|
||||
'values' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'id',
|
||||
'label' => $this->l('ID Tab'),
|
||||
'values' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'css_class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'values' => '',
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Image'),
|
||||
'type' => 'selectImg',
|
||||
'href' => $href,
|
||||
'name' => 'image',
|
||||
'lang' => false,
|
||||
'show_image' => true,
|
||||
),
|
||||
);
|
||||
$this->name = 'ap_sub_tabs';
|
||||
} else {
|
||||
$input = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'lang' => 'true',
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'label' => $this->l('CSS Class'),
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Select Type'),
|
||||
'name' => 'tab_type',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'tabs-top',
|
||||
'name' => $this->l('Tabs Top'),
|
||||
),
|
||||
array(
|
||||
'id' => 'tabs-below',
|
||||
'name' => $this->l('Tabs below'),
|
||||
),
|
||||
array(
|
||||
'id' => 'tabs-left',
|
||||
'name' => $this->l('Tabs Left'),
|
||||
),
|
||||
array(
|
||||
'id' => 'tabs-right',
|
||||
'name' => $this->l('Tabs Right'),
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Display Tab Title In Mobile'),
|
||||
'name' => 'tab_mobile_type',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'default',
|
||||
'name' => $this->l('Default Like Desktop'),
|
||||
),
|
||||
array(
|
||||
'id' => 'tabs-dropdown',
|
||||
'name' => $this->l('Dropdown'),
|
||||
),
|
||||
array(
|
||||
'id' => 'tabs-accordion',
|
||||
'name' => $this->l('Accordion'),
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'active_tab',
|
||||
'label' => $this->l('Active Tab'),
|
||||
'default' => '1',
|
||||
'desc' => $this->l('Input position(number) to show tab. If Blank, all tab default is inactive.'),
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Use Fade effect'),
|
||||
'name' => 'fade_effect',
|
||||
'is_bool' => true,
|
||||
'desc' => $this->l('To make tabs fade in.'),
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
)
|
||||
);
|
||||
}
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function endRenderForm()
|
||||
{
|
||||
$this->helper->module = new $this->module_name();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overide in tabs module
|
||||
* @param type $atts
|
||||
* @param type $content
|
||||
* @param type $tag_name
|
||||
* @param type $is_gen_html
|
||||
* @return type
|
||||
*/
|
||||
public function adminContent($atts, $content = null, $tag_name = null, $is_gen_html = null)
|
||||
{
|
||||
$this->preparaAdminContent($atts, $tag_name);
|
||||
if ($is_gen_html) {
|
||||
$assign = array();
|
||||
$assign['formAtts'] = $atts;
|
||||
$w_info = $this->getInfo();
|
||||
$w_info['name'] = $this->name;
|
||||
$assign['apInfo'] = $w_info;
|
||||
if ($tag_name == 'ApTab') {
|
||||
$assign['tabID'] = $atts['id'];
|
||||
$assign['isSubTab'] = 1;
|
||||
$w_info['name'] = 'ApTab';
|
||||
} else {
|
||||
preg_match_all('/ApTab form_id="([^\"]+)" id\=\"([^\"]+)\" css_class\=\"([^\"]+){0,1}\" title\=\"([^\"]+)\"{0,1}/i', $content, $matches, PREG_OFFSET_CAPTURE);
|
||||
$sub_tab_content = array();
|
||||
$len = count($matches[0]);
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$title = $matches[4][$i][0];
|
||||
$title = str_replace($this->str_search, $this->str_relace_html, $title);
|
||||
$form_id = $matches[1][$i][0];
|
||||
$sub_tab_content[$form_id] = array(
|
||||
'form_id' => $form_id,
|
||||
'id' => $matches[2][$i][0],
|
||||
'css_class' => $matches[3][$i][0],
|
||||
'title' => $title,
|
||||
);
|
||||
}
|
||||
// validate module
|
||||
$pattern = '/ApTab form_id="([^\"]+)" id\=\"([^\"]+)\" css_class\=\"([^\"]+){0,1}\" ';
|
||||
$pattern .= 'override_folder\=\"([^\"]+){0,1}\" title\=\"([^\"]+)\"{0,1}/i';
|
||||
preg_match_all($pattern, $content, $matches2, PREG_OFFSET_CAPTURE);
|
||||
$sub_tab_content2 = array();
|
||||
$len2 = count($matches2[0]);
|
||||
for ($i = 0; $i < $len2; $i++) {
|
||||
$title2 = $matches2[5][$i][0];
|
||||
$title2 = str_replace($this->str_search, $this->str_relace_html, $title2);
|
||||
$form_id2 = $matches2[1][$i][0];
|
||||
$sub_tab_content2[$form_id2] = array(
|
||||
'form_id' => $form_id2,
|
||||
'id' => $matches2[2][$i][0],
|
||||
'css_class' => $matches2[3][$i][0],
|
||||
'title' => $title2,
|
||||
);
|
||||
}
|
||||
|
||||
$pattern = '/ApTab form_id="([^\"]+)" id\=\"([^\"]+)\" css_class\=\"([^\"]+){0,1}\" image\=\"([^\"]+){0,1}\" override_folder\=\"([^\"]+){0,1}\" title\=\"([^\"]+){0,1}\" sub_title\=\"([^\"]+){0,1}/i';
|
||||
preg_match_all($pattern, $content, $matches3, PREG_OFFSET_CAPTURE);
|
||||
$sub_tab_content3 = array();
|
||||
$len3 = count($matches3[0]);
|
||||
for ($i = 0; $i < $len3; $i++) {
|
||||
$title3 = isset($matches3[6][$i][0]) ? $matches3[6][$i][0] : '';
|
||||
$title3 = str_replace($this->str_search, $this->str_relace_html, $title3);
|
||||
$sub_title = isset($matches3[7][$i][0]) ? $matches3[7][$i][0] : '';
|
||||
$sub_title = str_replace($this->str_search, $this->str_relace_html, $sub_title);
|
||||
|
||||
$form_id3 = $matches3[1][$i][0];
|
||||
$sub_tab_content3[$form_id3] = array(
|
||||
'form_id' => $form_id3,
|
||||
'id' => $matches3[2][$i][0],
|
||||
'css_class' => $matches3[3][$i][0],
|
||||
'title' => $title3,
|
||||
'sub_title' => $sub_title,
|
||||
);
|
||||
}
|
||||
$assign['subTabContent'] = array_merge($sub_tab_content, $sub_tab_content2, $sub_tab_content3);
|
||||
}
|
||||
$assign['apContent'] = ApShortCodesBuilder::doShortcode($content);
|
||||
$controller = new AdminApPageBuilderShortcodesController();
|
||||
return $controller->adminContent($assign, $this->name.'.tpl');
|
||||
} else {
|
||||
ApShortCodesBuilder::doShortcode($content);
|
||||
}
|
||||
//preg_match_all( '/ap_tab id="([^\"]+)"(\id\=\"([^\"]+)\"){0,1}/i', $content, $matches, PREG_OFFSET_CAPTURE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Overide in tabs module
|
||||
* @param type $atts
|
||||
* @param type $content
|
||||
* @param type $tag_name
|
||||
* @param type $is_gen_html
|
||||
* @return type
|
||||
*/
|
||||
public function fontContent($atts, $content = null, $tag_name = null, $is_gen_html = null)
|
||||
{
|
||||
$is_active = $this->isWidgetActive(array('formAtts' => $atts));
|
||||
if (!$is_active) {
|
||||
return '';
|
||||
}
|
||||
if (isset($atts['tab_mobile_type']) && $atts['tab_mobile_type'] == 'tabs-accordion') {
|
||||
if (!Configuration::get('APPAGEBUILDER_LOAD_TABCOLLAPSE')) {
|
||||
$atts['lib_has_error'] = true;
|
||||
$atts['lib_error'] = 'You are using function convert Tab to Accordion in Mobile. Please enable to load this Library';
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($atts as $key => $val) {
|
||||
if (strpos($key, 'content') !== false || strpos($key, 'link') !== false || strpos($key, 'url') !== false || strpos($key, 'alt') !== false || strpos($key, 'tit') !== false || strpos($key, 'name') !== false || strpos($key, 'desc') !== false || strpos($key, 'itemscustom') !== false) {
|
||||
$atts[$key] = str_replace($this->str_search, $this->str_relace_html, $val);
|
||||
if (strpos($atts[$key], '_AP_IMG_DIR') !== false) {
|
||||
// validate module
|
||||
$atts[$key] = str_replace('_AP_IMG_DIR/', $this->theme_img_module, $atts[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// validate module
|
||||
unset($is_gen_html);
|
||||
$assign = array();
|
||||
|
||||
if ($tag_name == 'ApTabs') {
|
||||
// ApTabs
|
||||
$assign['tab_name'] = 'ApTabs';
|
||||
preg_match_all('/ApTab form_id="([^\"]+)" id\=\"([^\"]+)\" css_class\=\"([^\"]+){0,1}\" image\=\"([^\"]+)\" title\=\"([^\"]+)\"{0,1}/i', $content, $matches, PREG_OFFSET_CAPTURE);
|
||||
$sub_tab_content = array();
|
||||
$len = count($matches[0]);
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$title = $matches[4][$i][0];
|
||||
$title = str_replace($this->str_search, $this->str_relace_html, $title);
|
||||
$sub_tab_content[] = array(
|
||||
'form_id' => $matches[1][$i][0],
|
||||
'id' => $matches[2][$i][0],
|
||||
'css_class' => $matches[3][$i][0],
|
||||
'title' => $title,
|
||||
);
|
||||
}
|
||||
$pattern = '/ApTab form_id="([^\"]+)" id\=\"([^\"]+)\" css_class\=\"([^\"]+){0,1}\" override_folder\=\"([^\"]+){0,1}\" title\=\"([^\"]+)\"{0,1}/i';
|
||||
preg_match_all($pattern, $content, $matches2, PREG_OFFSET_CAPTURE);
|
||||
$sub_tab_content2 = array();
|
||||
$len2 = count($matches2[0]);
|
||||
for ($i = 0; $i < $len2; $i++) {
|
||||
$title2 = $matches2[5][$i][0];
|
||||
$title2 = str_replace($this->str_search, $this->str_relace_html, $title2);
|
||||
$form_id2 = $matches2[1][$i][0];
|
||||
$sub_tab_content2[$form_id2] = array(
|
||||
'form_id' => $form_id2,
|
||||
'id' => $matches2[2][$i][0],
|
||||
'css_class' => $matches2[3][$i][0],
|
||||
'title' => $title2,
|
||||
);
|
||||
}
|
||||
|
||||
$pattern = '/ApTab form_id="([^\"]+)" id\=\"([^\"]+)\" css_class\=\"([^\"]+){0,1}\" image\=\"([^\"]+){0,1}\" override_folder\=\"([^\"]+){0,1}\" title\=\"([^\"]+){0,1}\" sub_title\=\"([^\"]+){0,1}/i';
|
||||
preg_match_all($pattern, $content, $matches3, PREG_OFFSET_CAPTURE);
|
||||
$sub_tab_content3 = array();
|
||||
$len3 = count($matches3[0]);
|
||||
for ($i = 0; $i < $len3; $i++) {
|
||||
$title3 = isset($matches3[6][$i][0]) ? $matches3[6][$i][0] : '';
|
||||
$title3 = str_replace($this->str_search, $this->str_relace_html, $title3);
|
||||
$sub_title = isset($matches3[7][$i][0]) ? $matches3[7][$i][0] : '';
|
||||
$sub_title = str_replace($this->str_search, $this->str_relace_html, $sub_title);
|
||||
|
||||
$form_id3 = $matches3[1][$i][0];
|
||||
$sub_tab_content3[$form_id3] = array(
|
||||
'form_id' => $form_id3,
|
||||
'id' => $matches3[2][$i][0],
|
||||
'css_class' => $matches3[3][$i][0],
|
||||
'title' => $title3,
|
||||
'image' => $matches3[4][$i][0],
|
||||
'sub_title' => $sub_title,
|
||||
'count' => $i,
|
||||
);
|
||||
}
|
||||
if (isset($atts['active_tab']) && $atts['active_tab'] != '') {
|
||||
$tab_count = substr_count($content, '[ApTab');
|
||||
$tab_active = (int)$atts['active_tab'];
|
||||
|
||||
if (($tab_active <= $tab_count) && ($tab_active >= 1)) {
|
||||
# ACTIVE TAB
|
||||
$atts['active_tab'] = $tab_active - 1;
|
||||
} elseif ($tab_active > $tab_count) {
|
||||
# ACTIVE LAST TAB
|
||||
$atts['active_tab'] = $tab_count - 1;
|
||||
} else {
|
||||
# ACTIVE FIRST TAB
|
||||
$atts['active_tab'] = 0;
|
||||
}
|
||||
} else {
|
||||
# BLANK
|
||||
$atts['active_tab'] = -1;
|
||||
}
|
||||
$assign['subTabContent'] = array_merge($sub_tab_content, $sub_tab_content2, $sub_tab_content3);
|
||||
$atts['id'] = 'tab_'.ApPageSetting::getRandomNumber();
|
||||
$atts['class'] = ((isset($atts['class']) && $atts['class']) ? $atts['class'].' ' : '').(isset($atts['tab_type']) ? $atts['tab_type'] : '');
|
||||
|
||||
$assign['formAtts'] = $atts;
|
||||
$module = APPageBuilder::getInstance();
|
||||
$assign['path'] = apPageHelper::getImgThemeUrl();
|
||||
$assign['apContent'] = ApShortCodesBuilder::doShortcode($content);
|
||||
return $module->fontContent($assign, $this->name.'.tpl');
|
||||
} else {
|
||||
// ApTab
|
||||
$assign['tabID'] = $atts['id'];
|
||||
$assign['tab_name'] = 'ApTab';
|
||||
$assign['isSubTab'] = 1;
|
||||
|
||||
$assign['formAtts'] = $atts;
|
||||
$module = APPageBuilder::getInstance();
|
||||
$assign['path'] = apPageHelper::getImgThemeUrl();
|
||||
$assign['apContent'] = ApShortCodesBuilder::doShortcode($content);
|
||||
return $module->fontContent($assign, $this->name.'.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Override
|
||||
* Fixed css_class is empty -> cant set to $apHomeBuilder.process (json) in javascript
|
||||
*/
|
||||
public function preparaAdminContent($atts, $tag_name = null)
|
||||
{
|
||||
if ($tag_name == null) {
|
||||
$tag_name = $this->name;
|
||||
}
|
||||
if (is_array($atts)) {
|
||||
if (!isset(ApShortCodesBuilder::$shortcode_lang[$tag_name])) {
|
||||
$inputs = $this->getConfigList();
|
||||
$lang_field = array();
|
||||
foreach ($inputs as $input) {
|
||||
if (isset($input['lang']) && $input['lang']) {
|
||||
$lang_field[] = $input['name'];
|
||||
}
|
||||
}
|
||||
ApShortCodesBuilder::$shortcode_lang[$tag_name] = $lang_field;
|
||||
} else {
|
||||
$lang_field = ApShortCodesBuilder::$shortcode_lang[$tag_name];
|
||||
}
|
||||
foreach ($atts as $key => $val) {
|
||||
if ($lang_field && in_array($key, $lang_field)) {
|
||||
$key .= '_'.ApShortCodesBuilder::$lang_id;
|
||||
}
|
||||
if (!isset(ApShortCodesBuilder::$data_form[$atts['form_id']][$key])) {
|
||||
ApShortCodesBuilder::$data_form[$atts['form_id']][$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
194
modules/appagebuilder/classes/shortcodes/ApTwitter.php
Normal file
194
modules/appagebuilder/classes/shortcodes/ApTwitter.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApTwitter extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApTwitter';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Twitter'),
|
||||
'position' => 6,
|
||||
'desc' => $this->l('You can config for display Twitter box'),
|
||||
'icon_class' => 'icon-twitter-sign',
|
||||
'tag' => 'social');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$accordion_type = array(
|
||||
array(
|
||||
'value' => 'full',
|
||||
'text' => $this->l('Always Full')
|
||||
),
|
||||
array(
|
||||
'value' => 'accordion',
|
||||
'text' => $this->l('Always Accordion')
|
||||
),
|
||||
array(
|
||||
'value' => 'accordion_small_screen',
|
||||
'text' => $this->l('Accordion at small screen')
|
||||
),
|
||||
);
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Accordion Type'),
|
||||
'name' => 'accordion_type',
|
||||
'options' => array(
|
||||
'query' => $accordion_type,
|
||||
'id' => 'value',
|
||||
'name' => 'text' ),
|
||||
'default' => 'full',
|
||||
'hint' => $this->l('Select a Accordion Type'),
|
||||
),
|
||||
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' => 'html',
|
||||
'name' => 'default_html',
|
||||
'html_content' => '<script type="text/javascript" src="'.__PS_BASE_URI__.apPageHelper::getJsDir().'colorpicker/js/leo.jquery.colorpicker.js"></script>',
|
||||
),
|
||||
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' => ApPageSetting::returnYesNo(),
|
||||
'default' => 0,
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Show Replies'),
|
||||
'name' => 'show_replies',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => 0,
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Show Header'),
|
||||
'name' => 'show_header',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => 0,
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Show Footer'),
|
||||
'name' => 'show_footer',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => 0,
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Show Border'),
|
||||
'name' => 'show_border',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'default' => 0,
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Show Scrollbar'),
|
||||
'name' => 'show_scrollbar',
|
||||
'values' => ApPageSetting::returnYesNo(),
|
||||
'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.'),
|
||||
'hint' => $this->l('Twitter not Show Scrollbar if you set a number of Tweets is specified. Please not set value for input Count.'),
|
||||
)
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
}
|
||||
84
modules/appagebuilder/classes/shortcodes/ApVideo.php
Normal file
84
modules/appagebuilder/classes/shortcodes/ApVideo.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ApVideo extends ApShortCodeBase
|
||||
{
|
||||
public $name = 'ApVideo';
|
||||
public $for_module = 'manage';
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return array('label' => $this->l('Video'),
|
||||
'position' => 5,
|
||||
'desc' => $this->l('Embed video box'),
|
||||
'icon_class' => 'icon-facetime-video',
|
||||
'tag' => 'social');
|
||||
}
|
||||
|
||||
public function getConfigList()
|
||||
{
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'title',
|
||||
'label' => $this->l('Title'),
|
||||
'desc' => $this->l('Auto hide if leave it blank'),
|
||||
'lang' => 'true',
|
||||
'form_group_class' => 'aprow_general',
|
||||
'default' => ''
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'sub_title',
|
||||
'label' => $this->l('Sub Title'),
|
||||
'lang' => true,
|
||||
'values' => '',
|
||||
'autoload_rte' => false,
|
||||
'default' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Code'),
|
||||
'name' => 'content_html',
|
||||
'cols' => 40,
|
||||
'rows' => 10,
|
||||
'value' => true,
|
||||
'default' => '',
|
||||
'desc' => $this->l('Example embed video: "<div class="embed-responsive"><iframe src="https://www.youtube.com/embed/iZoR21juRzs" frameborder="0" allowfullscreen></iframe></div>"'),
|
||||
'autoload_rte' => false,
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Align'),
|
||||
'name' => 'align',
|
||||
'options' => array('query' => array(
|
||||
array('id' => 'left', 'name' => $this->l('Left')),
|
||||
array('id' => 'center', 'name' => $this->l('Center')),
|
||||
array('id' => 'right', 'name' => $this->l('Right'))
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'default' => 'center',
|
||||
)
|
||||
);
|
||||
return $inputs;
|
||||
}
|
||||
}
|
||||
36
modules/appagebuilder/classes/shortcodes/index.php
Normal file
36
modules/appagebuilder/classes/shortcodes/index.php
Normal 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;
|
||||
12
modules/appagebuilder/config.xml
Normal file
12
modules/appagebuilder/config.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>appagebuilder</name>
|
||||
<displayName><![CDATA[Apollo Page Builder]]></displayName>
|
||||
<version><![CDATA[2.4.1]]></version>
|
||||
<description><![CDATA[Apollo Page Builder build content for your site.]]></description>
|
||||
<author><![CDATA[ApolloTheme]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class AdminApPageBuilderController extends ModuleAdminControllerCore
|
||||
{
|
||||
public static $shortcode_lang;
|
||||
public static $lang_id;
|
||||
public static $language;
|
||||
public $error_text = '';
|
||||
public $theme_name;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$url = 'index.php?controller=adminmodules&configure=appagebuilder&token='.Tools::getAdminTokenLite('AdminModules')
|
||||
.'&tab_module=Home&module_name=appagebuilder';
|
||||
Tools::redirectAdmin($url);
|
||||
$this->bootstrap = true;
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
$this->theme_name = apPageHelper::getThemeName();
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,815 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageBuilderDetailsModel.php');
|
||||
|
||||
class AdminApPageBuilderDetailsController extends ModuleAdminControllerCore
|
||||
{
|
||||
private $theme_name = '';
|
||||
public $module_name = 'appagebuilder';
|
||||
public $tpl_save = '';
|
||||
public $file_content = array();
|
||||
public $explicit_select;
|
||||
public $order_by;
|
||||
public $order_way;
|
||||
public $profile_css_folder;
|
||||
public $module_path;
|
||||
// public $module_path_resource;
|
||||
public $str_search = array();
|
||||
public $str_relace = array();
|
||||
public $theme_dir;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
$this->table = 'appagebuilder_details';
|
||||
$this->className = 'ApPageBuilderDetailsModel';
|
||||
$this->lang = false;
|
||||
$this->explicit_select = true;
|
||||
$this->allow_export = true;
|
||||
$this->can_import = true;
|
||||
$this->context = Context::getContext();
|
||||
$this->_join = '
|
||||
INNER JOIN `'._DB_PREFIX_.'appagebuilder_details_shop` ps ON (ps.`id_appagebuilder_details` = a.`id_appagebuilder_details`)';
|
||||
$this->_select .= ' ps.active as active, ps.active_mobile as active_mobile, ps.active_tablet as active_tablet';
|
||||
|
||||
$this->order_by = 'id_appagebuilder_details';
|
||||
$this->order_way = 'DESC';
|
||||
parent::__construct();
|
||||
$this->fields_list = array(
|
||||
'id_appagebuilder_details' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 50,
|
||||
'class' => 'fixed-width-xs'
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
'width' => 140,
|
||||
'type' => 'text',
|
||||
'filter_key' => 'a!name'
|
||||
),
|
||||
'plist_key' => array(
|
||||
'title' => $this->l('Product List Key'),
|
||||
'filter_key' => 'a!plist_key',
|
||||
'type' => 'text',
|
||||
'width' => 140,
|
||||
),
|
||||
'class_detail' => array(
|
||||
'title' => $this->l('Class'),
|
||||
'width' => 140,
|
||||
'type' => 'text',
|
||||
'filter_key' => 'a!class_detail',
|
||||
'orderby' => false
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->l('Is Default'),
|
||||
'active' => 'status',
|
||||
'filter_key' => 'ps!active',
|
||||
'align' => 'text-center',
|
||||
'type' => 'bool',
|
||||
'class' => 'fixed-width-sm',
|
||||
'orderby' => false
|
||||
),
|
||||
'active_mobile' => array(
|
||||
'title' => $this->l('Is Mobile'),
|
||||
'active' => 'active_mobile',
|
||||
'filter_key' => 'ps!active_mobile',
|
||||
'align' => 'text-center',
|
||||
'type' => 'bool',
|
||||
'class' => 'fixed-width-sm',
|
||||
'orderby' => false
|
||||
),
|
||||
'active_tablet' => array(
|
||||
'title' => $this->l('Is Tablet'),
|
||||
'active' => 'active_table',
|
||||
'filter_key' => 'ps!active_tablet',
|
||||
'align' => 'text-center',
|
||||
'type' => 'bool',
|
||||
'class' => 'fixed-width-sm',
|
||||
'orderby' => false
|
||||
)
|
||||
);
|
||||
$this->bulk_actions = array(
|
||||
'delete' => array(
|
||||
'text' => $this->l('Delete selected'),
|
||||
'confirm' => $this->l('Delete selected items?'),
|
||||
'icon' => 'icon-trash'
|
||||
)
|
||||
);
|
||||
$this->theme_dir = apPageHelper::getConfigDir('_PS_THEME_DIR_');
|
||||
|
||||
//nghiatd - add theme mobile and table
|
||||
$correct_mobile = Db::getInstance()->executeS('SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = "'._DB_NAME_.'" AND TABLE_NAME="'._DB_PREFIX_.'appagebuilder_details" AND column_name="active_mobile"');
|
||||
if (count($correct_mobile) < 1) {
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'appagebuilder_details_shop` ADD `active_mobile` int(11) NOT NULL');
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'appagebuilder_details_shop` ADD `active_tablet` int(11) NOT NULL');
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'appagebuilder_details` ADD `active_mobile` int(11) NOT NULL');
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'appagebuilder_details` ADD `active_tablet` int(11) NOT NULL');
|
||||
}
|
||||
|
||||
$this->_where = ' AND ps.id_shop='.(int)$this->context->shop->id;
|
||||
$this->theme_name = apPageHelper::getThemeName();
|
||||
$this->profile_css_folder = $this->theme_dir.'modules/'.$this->module_name.'/';
|
||||
$this->module_path = __PS_BASE_URI__.'modules/'.$this->module_name.'/';
|
||||
// $this->module_path_resource = $this->module_path.'views/';
|
||||
$this->str_search = array('_APAMP_', '_APQUOT_', '_APAPOST_', '_APTAB_', '_APNEWLINE_', '_APENTER_', '_APOBRACKET_', '_APCBRACKET_', '_APOCBRACKET_', '_APCCBRACKET_',);
|
||||
$this->str_relace = array('&', '\"', '\'', '\t', '\r', '\n', '[', ']', '{', '}');
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
parent::initToolbar();
|
||||
|
||||
# SAVE AND STAY
|
||||
if ($this->display == 'add' || $this->display == 'edit') {
|
||||
$this->context->controller->addJs(apPageHelper::getJsAdminDir().'admin/function.js');
|
||||
|
||||
$this->page_header_toolbar_btn['SaveAndStay'] = array(
|
||||
'href' => 'javascript:void(0);',
|
||||
'desc' => $this->l('Save and stay'),
|
||||
'js' => 'TopSaveAndStay()',
|
||||
'icon' => 'process-icon-save',
|
||||
);
|
||||
Media::addJsDef(array('TopSaveAndStay_Name' => 'submitAdd'.$this->table.'AndStay'));
|
||||
|
||||
$this->page_header_toolbar_btn['Save'] = array(
|
||||
'href' => 'javascript:void(0);',
|
||||
'desc' => $this->l('Save'),
|
||||
'js' => 'TopSave()',
|
||||
'icon' => 'process-icon-save',
|
||||
);
|
||||
Media::addJsDef(array('TopSave_Name' => 'submitAdd'.$this->table));
|
||||
}
|
||||
|
||||
# SHOW LINK EXPORT ALL FOR TOOLBAR
|
||||
switch ($this->display) {
|
||||
default:
|
||||
$this->toolbar_btn['new'] = array(
|
||||
'href' => self::$currentIndex . '&add' . $this->table . '&token=' . $this->token,
|
||||
'desc' => $this->l('Add new'),
|
||||
'class' => 'btn_add_new',
|
||||
);
|
||||
if (!$this->display && $this->can_import) {
|
||||
$this->toolbar_btn['import'] = array(
|
||||
'href' => self::$currentIndex . '&import' . $this->table . '&token=' . $this->token,
|
||||
'desc' => $this->trans('Import', array(), 'Admin.Actions'),
|
||||
'class' => 'btn_xml_import',
|
||||
);
|
||||
}
|
||||
if ($this->allow_export) {
|
||||
$this->toolbar_btn['export'] = array(
|
||||
'href' => self::$currentIndex . '&export' . $this->table . '&token=' . $this->token,
|
||||
'desc' => $this->l('Export'),
|
||||
'class' => 'btn_xml_export',
|
||||
);
|
||||
Media::addJsDef(array('record_id' => 'appagebuilder_detailsBox[]'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* OVERRIDE CORE
|
||||
*/
|
||||
public function processExport($text_delimiter = '"')
|
||||
{
|
||||
$record_id = Tools::getValue('record_id');
|
||||
$file_name = 'ap_product_detail_all.xml';
|
||||
# VALIDATE MODULE
|
||||
unset($text_delimiter);
|
||||
|
||||
if ($record_id) {
|
||||
$record_id_str = implode(", ", $record_id);
|
||||
$this->_where = ' AND a.id_appagebuilder_details IN ( '.pSQL($record_id_str).' )';
|
||||
$file_name = 'ap_product_detail.xml';
|
||||
}
|
||||
|
||||
$this->getList($this->context->language->id, null, null, 0, false);
|
||||
if (!count($this->_list)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = $this->_list;
|
||||
$this->file_content = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||
$this->file_content .= '<data>' . "\n";
|
||||
$this->file_content .= '<product_details>' . "\n";
|
||||
if ($data) {
|
||||
foreach ($data as $product_detail) {
|
||||
$this->file_content .= '<record>' . "\n";
|
||||
foreach ($product_detail as $key => $value) {
|
||||
$this->file_content .= ' <'.$key.'>';
|
||||
$this->file_content .= '<![CDATA['.$value.']]>';
|
||||
$this->file_content .= '</'.$key.'>' . "\n";
|
||||
}
|
||||
$this->file_content .= '</record>' . "\n";
|
||||
}
|
||||
}
|
||||
$this->file_content .= '</product_details>' . "\n";
|
||||
$this->file_content .= '</data>' . "\n";
|
||||
header('Content-type: text/xml');
|
||||
header('Content-Disposition: attachment; filename="'.$file_name.'"');
|
||||
echo $this->file_content;
|
||||
die();
|
||||
}
|
||||
|
||||
public function processImport()
|
||||
{
|
||||
$upload_file = new Uploader('importFile');
|
||||
$upload_file->setAcceptTypes(array('xml'));
|
||||
$file = $upload_file->process();
|
||||
$file = $file[0];
|
||||
if (!isset($file['save_path'])) {
|
||||
$this->errors[] = $this->trans('Failed to import.', array(), 'Admin.Notifications.Error');
|
||||
return;
|
||||
}
|
||||
$files_content = simplexml_load_file($file['save_path']);
|
||||
$override = Tools::getValue('override');
|
||||
|
||||
if (isset($files_content->product_details) && $files_content->product_details) {
|
||||
foreach ($files_content->product_details->children() as $product_details) {
|
||||
if (!$override) {
|
||||
$num = ApPageSetting::getRandomNumber();
|
||||
$obj_model = new ApPageBuilderDetailsModel();
|
||||
$obj_model->plist_key = 'detail'.$num;
|
||||
$obj_model->name = $product_details->name->__toString();
|
||||
$obj_model->class_detail = $product_details->class_detail->__toString();
|
||||
$obj_model->params = $product_details->params->__toString();
|
||||
$obj_model->type = $product_details->type->__toString();
|
||||
$obj_model->active = 0;
|
||||
$obj_model->url_img_preview = $product_details->url_img_preview->__toString();
|
||||
if ($obj_model->save()) {
|
||||
$this->saveTplFile($obj_model->plist_key, $obj_model->params);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->confirmations[] = $this->trans('Successful importing.', array(), 'Admin.Notifications.Success');
|
||||
} else {
|
||||
$this->errors[] = $this->trans('Failed to import.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
}
|
||||
|
||||
public function renderView()
|
||||
{
|
||||
$object = $this->loadObject();
|
||||
if ($object->page == 'product_detail') {
|
||||
$this->redirect_after = Context::getContext()->link->getAdminLink('AdminApPageBuilderProductDetail');
|
||||
} else {
|
||||
$this->redirect_after = Context::getContext()->link->getAdminLink('AdminApPageBuilderHome');
|
||||
}
|
||||
$this->redirect_after .= '&id_appagebuilder_details='.$object->id;
|
||||
$this->redirect();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
parent::postProcess();
|
||||
|
||||
if (Tools::getIsset('active_mobileappagebuilder_details') || Tools::getIsset('active_tableappagebuilder_details')) {
|
||||
if (Validate::isLoadedObject($object = $this->loadObject())) {
|
||||
$result = Tools::getIsset('active_mobileappagebuilder_details')?$object->toggleStatusMT('active_mobile'):$object->toggleStatusMT('active_tablet');
|
||||
if ($result) {
|
||||
// $this->mesage[] = Tools::displayError('You should enebale mobile theme in theme config');
|
||||
|
||||
$matches = array();
|
||||
if (preg_match('/[\?|&]controller=([^&]*)/', (string)$_SERVER['HTTP_REFERER'], $matches) !== false && Tools::strtolower($matches[1]) != Tools::strtolower(preg_replace('/controller/i', '', get_class($this)))) {
|
||||
$this->redirect_after = preg_replace('/[\?|&]conf=([^&]*)/i', '', (string)$_SERVER['HTTP_REFERER']);
|
||||
} else {
|
||||
$this->redirect_after = self::$currentIndex.'&token='.$this->token.'&mobiletheme';
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You can not disable default profile, Please select other profile as default');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating the status for an object.')
|
||||
.'<b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
}
|
||||
|
||||
if (count($this->errors) > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Tools::getIsset('duplicateappagebuilder_details')) {
|
||||
$id = Tools::getValue('id_appagebuilder_details');
|
||||
$model = new ApPageBuilderDetailsModel($id);
|
||||
$duplicate_object = $model->duplicateObject();
|
||||
$duplicate_object->name = $this->l('Duplicate of').' '.$duplicate_object->name;
|
||||
$old_key = $duplicate_object->plist_key;
|
||||
$duplicate_object->plist_key = 'detail'.ApPageSetting::getRandomNumber();
|
||||
# FIX 1751 : empty
|
||||
$duplicate_object->params = $model->params;
|
||||
if ($duplicate_object->add()) {
|
||||
//duplicate shortCode
|
||||
$filecontent = Tools::file_get_contents(apPageHelper::getConfigDir('theme_details').$old_key.'.tpl');
|
||||
ApPageSetting::writeFile(apPageHelper::getConfigDir('theme_details'), $duplicate_object->plist_key.'.tpl', $filecontent);
|
||||
$this->redirect_after = self::$currentIndex.'&token='.$this->token;
|
||||
$this->redirect();
|
||||
} else {
|
||||
Tools::displayError('Can not duplicate Profiles');
|
||||
}
|
||||
}
|
||||
if (Tools::isSubmit('saveELement')) {
|
||||
$filecontent = Tools::getValue('filecontent');
|
||||
$fileName = Tools::getValue('fileName');
|
||||
apPageHelper::createDir(apPageHelper::getConfigDir('theme_details'));
|
||||
ApPageSetting::writeFile(apPageHelper::getConfigDir('theme_details'), $fileName.'.tpl', $filecontent);
|
||||
}
|
||||
}
|
||||
|
||||
public function convertObjectToTpl($object_form)
|
||||
{
|
||||
$tpl = '';
|
||||
|
||||
foreach ($object_form as $object) {
|
||||
if ($object['name'] == 'functional_buttons') {
|
||||
//DONGND:: fix can save group column when change class
|
||||
if (isset($object['form']['class']) && $object['form']['class'] != '') {
|
||||
$tpl .= '<div class="'.$object['form']['class'].'">';
|
||||
} else {
|
||||
$tpl .= '<div class="row">';
|
||||
}
|
||||
foreach ($object['columns'] as $objectC) {
|
||||
$tpl .= '<div class="'.$this->convertToColumnClass($objectC['form']).'">';
|
||||
$tpl .= $this->convertObjectToTpl($objectC['sub']);
|
||||
$tpl .= '
|
||||
</div>';
|
||||
}
|
||||
|
||||
$tpl .= '</div>';
|
||||
} else if ($object['name'] == 'code') {
|
||||
$tpl .= $object['code'];
|
||||
} else {
|
||||
if (!isset($this->file_content[$object['name']])) {
|
||||
$this->returnFileContent($object['name']);
|
||||
//DONGND:: add config to type gallery
|
||||
if ($object['name'] == "product_image_with_thumb" || $object['name'] == "product_image_show_all") {
|
||||
$strdata = '';
|
||||
foreach ($object['form'] as $key => $value) {
|
||||
$strdata .= ' data-'.$key.'="'.$value.'"';
|
||||
}
|
||||
$this->file_content[$object['name']] = str_replace('id="content">', 'id="content"'.$strdata.'>', $this->file_content[$object['name']]);
|
||||
}
|
||||
}
|
||||
//add class
|
||||
$tpl .= $this->file_content[$object['name']];
|
||||
}
|
||||
}
|
||||
return $tpl;
|
||||
}
|
||||
|
||||
public function convertToColumnClass($form)
|
||||
{
|
||||
$class = '';
|
||||
foreach ($form as $key => $val) {
|
||||
//DONGND:: check class name of column
|
||||
if ($key == 'class') {
|
||||
if ($val != '') {
|
||||
$class .= ($class=='')?$val:' '.$val;
|
||||
}
|
||||
} else {
|
||||
$class .= ($class=='')?'col-'.$key.'-'.$val:' col-'.$key.'-'.$val;
|
||||
}
|
||||
}
|
||||
return $class;
|
||||
}
|
||||
|
||||
public function returnFileContent($pelement)
|
||||
{
|
||||
$tpl_dir = apPageHelper::getConfigDir('theme_details').$pelement.'.tpl';
|
||||
if (!file_exists($tpl_dir)) {
|
||||
$tpl_dir = apPageHelper::getConfigDir('module_details').$pelement.'.tpl';
|
||||
}
|
||||
$this->file_content[$pelement] = Tools::file_get_contents($tpl_dir);
|
||||
return $this->file_content[$pelement];
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
if (Tools::getIsset('pelement')) {
|
||||
$helper = new HelperForm();
|
||||
$helper->submit_action = 'saveELement';
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'filecontent',
|
||||
'label' => $this->l('File Content'),
|
||||
'desc' => $this->l('Please carefully when edit tpl file'),
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'fileName',
|
||||
)
|
||||
);
|
||||
$fields_form = array(
|
||||
'form' => array(
|
||||
'legend' => array(
|
||||
'title' => sprintf($this->l('You are Editing file: %s'), Tools::getValue('pelement').'.tpl'),
|
||||
'icon' => 'icon-cogs'
|
||||
),
|
||||
'action' => Context::getContext()->link->getAdminLink('AdminApPageBuilderShortcodes'),
|
||||
'input' => $inputs,
|
||||
'name' => 'importData',
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
'class' => 'button btn btn-default pull-right'
|
||||
),
|
||||
'tinymce' => false,
|
||||
),
|
||||
);
|
||||
$helper->tpl_vars = array(
|
||||
'fields_value' => $this->getFileContent()
|
||||
);
|
||||
return $helper->generateForm(array($fields_form));
|
||||
}
|
||||
$this->initToolbar();
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('duplicate');
|
||||
$this->addRowAction('delete');
|
||||
return $this->importForm() . parent::renderList();
|
||||
}
|
||||
|
||||
public function getFileContent()
|
||||
{
|
||||
$pelement = Tools::getValue('pelement');
|
||||
$tpl_dir = apPageHelper::getConfigDir('theme_details').$pelement.'.tpl';
|
||||
if (!file_exists($tpl_dir)) {
|
||||
$tpl_dir = apPageHelper::getConfigDir('module_details').$pelement.'.tpl';
|
||||
}
|
||||
return array('fileName' => $pelement, 'filecontent' => Tools::file_get_contents($tpl_dir));
|
||||
}
|
||||
|
||||
public function setHelperDisplay(Helper $helper)
|
||||
{
|
||||
parent::setHelperDisplay($helper);
|
||||
$this->helper->module = APPageBuilder::getInstance();
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
$this->initToolbar();
|
||||
$this->context->controller->addJqueryUI('ui.sortable');
|
||||
$this->context->controller->addJqueryUI('ui.draggable');
|
||||
//$this->context->controller->addJs(apPageHelper::getJsAdminDir().'admin/form.js');
|
||||
$this->context->controller->addJs(apPageHelper::getJsAdminDir().'admin/detail.js');
|
||||
$this->context->controller->addCss(apPageHelper::getCssAdminDir().'admin/form.css');
|
||||
|
||||
if (is_dir(apPageHelper::getConfigDir('theme_details'))) {
|
||||
$source_file = Tools::scandir(apPageHelper::getConfigDir('theme_details'), 'tpl');
|
||||
$source_template_file = Tools::scandir(apPageHelper::getConfigDir('theme_details'), 'tpl');
|
||||
$source_file = array_merge($source_file, $source_template_file);
|
||||
}
|
||||
|
||||
$params = array('gridLeft' => array(), 'gridRight' => array());
|
||||
|
||||
$this->object->params = str_replace($this->str_search, $this->str_relace, $this->object->params);
|
||||
|
||||
$config_dir = apPageHelper::getConfigDir('theme_details') . 'config.json';
|
||||
if (!file_exists($config_dir)) {
|
||||
$config_dir = apPageHelper::getConfigDir('module_details') . 'config.json';
|
||||
}
|
||||
|
||||
$config_file = Tools::jsonDecode(Tools::file_get_contents($config_dir), true);
|
||||
$element_by_name = array();
|
||||
foreach ($config_file as $k1 => $groups) {
|
||||
foreach ($groups['group'] as $k2 => $group) {
|
||||
$config_file[$k1]['group'][$k2]['dataForm'] = (!isset($group['data-form']))?'':Tools::jsonEncode($group['data-form']);
|
||||
if (isset($group['file'])) {
|
||||
$element_by_name[$group['file']] = $group;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->object->params)) {
|
||||
//add sample data
|
||||
if (Tools::getIsset('sampledetail')) {
|
||||
switch (Tools::getValue('sampledetail')) {
|
||||
case 'product_image_thumbs_bottom':
|
||||
$this->object->url_img_preview = 'https://i.pinimg.com/originals/8c/16/f9/8c16f9f024af16977adc1f618872eb8b.jpg';
|
||||
$this->object->params = '{"gridLeft":{"0":{"name":"functional_buttons","form":"","columns":{"0":{"form":{"form_id":"form_9367402777406408","md":6,"lg":6,"xl":6,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_image_with_thumb","form":{"templateview":"bottom","numberimage":"5","numberimage1200":"5","numberimage992":"4","numberimage768":"3","numberimage576":"3","numberimage480":"2","numberimage360":"2","templatemodal":"1","templatethumb":"1","templatezoomtype":"out","zoomposition":"right","zoomwindowwidth":"400","zoomwindowheight":"400"}}}},"1":{"form":{"form_id":"form_15874367062488778","md":6,"lg":6,"xl":6,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_detail_name","form":""},"1":{"name":"hook_display_product_additional_info","form":""},"2":{"name":"hook_display_leo_product_review_extra","form":""},"3":{"name":"product_price","form":""},"4":{"name":"product_description_short","form":""},"5":{"name":"product_customization","form":""},"6":{"name":"product_actions_form","form":""},"7":{"name":"hook_display_reassurance","form":""}}},"2":{"form":{"form_id":"form_4666379129988496","md":12,"lg":12,"xl":12,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_more_info_tab","form":""},"1":{"name":"product_accessories","form":""},"2":{"name":"hook_display_footer_product","form":""}}}}}},"class":"product-image-thumbs product-thumbs-bottom"}';
|
||||
break;
|
||||
case 'product_image_thumbs_left':
|
||||
$this->object->url_img_preview = 'https://i.pinimg.com/originals/98/b4/b0/98b4b05fef8913b2a37cbb592b921e7b.jpg';
|
||||
$this->object->params = '{"gridLeft":{"0":{"name":"functional_buttons","form":"","columns":{"0":{"form":{"md":6,"lg":6,"xl":6,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_image_with_thumb","form":{"templateview":"left","numberimage":"5","numberimage1200":"4","numberimage992":"4","numberimage768":"3","numberimage576":"3","numberimage480":"2","numberimage360":"2","templatemodal":"1","templatethumb":"1","templatezoomtype":"in","zoomposition":"right","zoomwindowwidth":"400","zoomwindowheight":"400"}}}},"1":{"form":{"md":6,"lg":6,"xl":6,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_detail_name","form":""},"1":{"name":"hook_display_product_additional_info","form":""},"2":{"name":"hook_display_leo_product_review_extra","form":""},"3":{"name":"product_price","form":""},"4":{"name":"product_description_short","form":""},"5":{"name":"product_customization","form":""},"6":{"name":"product_actions_form","form":""},"7":{"name":"hook_display_reassurance","form":""}}},"2":{"form":{"md":12,"lg":12,"xl":12,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_more_info_accordions","form":""},"1":{"name":"product_accessories","form":""},"2":{"name":"hook_display_footer_product","form":""}}}}}},"class":"product-image-thumbs product-thumbs-left"}';
|
||||
break;
|
||||
case 'product_image_thumbs_right':
|
||||
$this->object->url_img_preview = 'https://i.pinimg.com/originals/81/c4/41/81c441c1b2f6c3e56b3da56b65324423.jpg';
|
||||
$this->object->params = '{"gridLeft":{"0":{"name":"functional_buttons","form":"","columns":{"0":{"form":{"md":6,"lg":6,"xl":6,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_image_with_thumb","form":{"templateview":"right","numberimage":"5","numberimage1200":"4","numberimage992":"4","numberimage768":"3","numberimage576":"3","numberimage480":"2","numberimage360":"2","templatemodal":"1","templatethumb":"1","templatezoomtype":"in","zoomposition":"right","zoomwindowwidth":"400","zoomwindowheight":"400"}}}},"1":{"form":{"md":6,"lg":6,"xl":6,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_detail_name","form":""},"1":{"name":"hook_display_product_additional_info","form":""},"2":{"name":"hook_display_leo_product_review_extra","form":""},"3":{"name":"product_price","form":""},"4":{"name":"product_description_short","form":""},"5":{"name":"product_customization","form":""},"6":{"name":"product_actions_form","form":""},"7":{"name":"hook_display_reassurance","form":""}}},"2":{"form":{"md":12,"lg":12,"xl":12,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_more_info_default","form":""},"1":{"name":"product_accessories","form":""},"2":{"name":"hook_display_footer_product","form":""}}}}}},"class":"product-image-thumbs product-thumbs-right"}';
|
||||
break;
|
||||
case 'product_image_no_thumbs':
|
||||
$this->object->url_img_preview = 'https://i.pinimg.com/originals/60/ca/57/60ca570f6a8254c3741d8c9db78eb3d5.jpg';
|
||||
$this->object->params = '{"gridLeft":{"0":{"name":"functional_buttons","form":"","columns":{"0":{"form":{"md":6,"lg":6,"xl":6,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_image_with_thumb","form":{"templateview":"none","numberimage":"5","numberimage1200":"5","numberimage992":"4","numberimage768":"3","numberimage576":"3","numberimage480":"2","numberimage360":"2","templatemodal":"1","templatethumb":"1","templatezoomtype":"in","zoomposition":"right","zoomwindowwidth":"400","zoomwindowheight":"400"}}}},"1":{"form":{"md":6,"lg":6,"xl":6,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_detail_name","form":""},"1":{"name":"hook_display_product_additional_info","form":""},"2":{"name":"hook_display_leo_product_review_extra","form":""},"3":{"name":"product_price","form":""},"4":{"name":"product_description_short","form":""},"5":{"name":"product_customization","form":""},"6":{"name":"product_actions_form","form":""},"7":{"name":"hook_display_reassurance","form":""}}},"2":{"form":{"md":12,"lg":12,"xl":12,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_more_info_tab","form":""},"1":{"name":"product_accessories","form":""},"2":{"name":"hook_display_footer_product","form":""}}}}}},"class":"product-image-thumbs no-thumbs"}';
|
||||
break;
|
||||
case 'product_image_no_thumbs_fullwidth':
|
||||
$this->object->url_img_preview = 'https://i.pinimg.com/originals/c5/d9/02/c5d9025b68250832a31eac3b6d344955.jpg';
|
||||
$this->object->params = '{"gridLeft":{"0":{"name":"functional_buttons","form":"","columns":{"0":{"form":{"class":"","xl":"12","lg":"12","md":"12","sm":"12","xs":"12","sp":"12"},"element":"column","sub":{"0":{"name":"product_image_with_thumb","form":{"templateview":"none","numberimage":"5","numberimage1200":"5","numberimage992":"4","numberimage768":"3","numberimage576":"3","numberimage480":"2","numberimage360":"2","templatemodal":"1","templatethumb":"1","templatezoomtype":"in","zoomposition":"right","zoomwindowwidth":"400","zoomwindowheight":"400"}}}},"1":{"form":{"class":"offset-lg-2 offset-xl-2","xl":"8","lg":"8","md":"12","sm":"12","xs":"12","sp":"12"},"element":"column","sub":{"0":{"name":"product_detail_name","form":""},"1":{"name":"hook_display_product_additional_info","form":""},"2":{"name":"hook_display_leo_product_review_extra","form":""},"3":{"name":"product_price","form":""},"4":{"name":"product_description_short","form":""},"5":{"name":"product_customization","form":""},"6":{"name":"product_actions_form","form":""},"7":{"name":"hook_display_reassurance","form":""},"8":{"name":"product_more_info_tab","form":""}}},"2":{"form":{"class":"","xl":"12","lg":"12","md":"12","sm":"12","xs":"12","sp":"12"},"element":"column","sub":{"0":{"name":"product_accessories","form":""},"1":{"name":"hook_display_footer_product","form":""}}}}}},"class":"product-image-thumbs no-thumbs"}';
|
||||
break;
|
||||
case 'product_image_gallery':
|
||||
$this->object->url_img_preview = 'https://i.pinimg.com/originals/b1/a8/b9/b1a8b9381d8d3e3c4d13dfe24231581f.jpg';
|
||||
$this->object->params = '{"gridLeft":{"0":{"name":"functional_buttons","form":"","columns":{"0":{"form":{"md":6,"lg":6,"xl":6,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_image_show_all","form":{"templatezoomtype":"in","zoomposition":"right","zoomwindowwidth":"400","zoomwindowheight":"400"}}}},"1":{"form":{"md":6,"lg":6,"xl":6,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_detail_name","form":""},"1":{"name":"hook_display_product_additional_info","form":""},"2":{"name":"hook_display_leo_product_review_extra","form":""},"3":{"name":"product_price","form":""},"4":{"name":"product_description_short","form":""},"5":{"name":"product_customization","form":""},"6":{"name":"product_actions_form","form":""},"7":{"name":"hook_display_reassurance","form":""}}},"2":{"form":{"md":12,"lg":12,"xl":12,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_more_info_tab","form":""},"1":{"name":"product_accessories","form":""},"2":{"name":"hook_display_footer_product","form":""}}}}}},"class":"product-image-gallery"}';
|
||||
break;
|
||||
case 'product_image_no_thumbs_center':
|
||||
$this->object->url_img_preview = 'https://i.pinimg.com/originals/38/99/1a/38991a8c1582669d29abe889bc0d5f52.jpg';
|
||||
$this->object->params = '{"gridLeft":{"0":{"name":"functional_buttons","form":"","columns":{"0":{"form":{"class":"","xl":"4","lg":"4","md":"12","sm":"12","xs":"12","sp":"12"},"element":"column","sub":{"0":{"name":"product_detail_name","form":""},"1":{"name":"hook_display_product_additional_info","form":""},"2":{"name":"hook_display_leo_product_review_extra","form":""},"3":{"name":"product_price","form":""},"4":{"name":"product_description_short","form":""},"5":{"name":"hook_display_reassurance","form":""}}},"1":{"form":{"class":"","xl":"5","lg":"5","md":"12","sm":"12","xs":"12","sp":"12"},"element":"column","sub":{"0":{"name":"product_image_with_thumb","form":{"templateview":"none","numberimage":"5","numberimage1200":"5","numberimage992":"4","numberimage768":"3","numberimage576":"3","numberimage480":"2","numberimage360":"2","templatemodal":"1","templatethumb":"1","templatezoomtype":"in","zoomposition":"right","zoomwindowwidth":"400","zoomwindowheight":"400"}}}},"2":{"form":{"class":"","xl":"3","lg":"3","md":"12","sm":"12","xs":"12","sp":"12"},"element":"column","sub":{"0":{"name":"product_customization","form":""},"1":{"name":"product_actions_form","form":""}}},"3":{"form":{"md":12,"lg":12,"xl":12,"sm":12,"xs":12,"sp":12},"element":"column","sub":{"0":{"name":"product_more_info_tab","form":""},"1":{"name":"product_accessories","form":""},"2":{"name":"hook_display_footer_product","form":""}}}}}},"class":"product-image-thumbs no-thumbs"}';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$params = Tools::jsonDecode($this->object->params, true);
|
||||
if ($params['gridLeft']) {
|
||||
foreach ($params['gridLeft'] as $key => $value) {
|
||||
$params['gridLeft'][$key]['dataForm'] = (!isset($value['form']))?'':Tools::jsonEncode($value['form']);
|
||||
|
||||
if (isset($element_by_name[$value['name']])) {
|
||||
$params['gridLeft'][$key]['config'] = $element_by_name[$value['name']];
|
||||
}
|
||||
if ($value['name'] == "functional_buttons") {
|
||||
foreach ($value['columns'] as $k => $v) {
|
||||
$params['gridLeft'][$key]['columns'][$k]['dataForm'] = (!isset($v['form']))?'':Tools::jsonEncode($v['form']);
|
||||
foreach ($v['sub'] as $ke => $ve) {
|
||||
$params['gridLeft'][$key]['columns'][$k]['sub'][$ke]['dataForm'] = (!isset($ve['form']))?'':Tools::jsonEncode($ve['form']);
|
||||
if (isset($element_by_name[$ve['name']])) {
|
||||
$params['gridLeft'][$key]['columns'][$k]['sub'][$ke]['config'] = $element_by_name[$ve['name']];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$block_list = array(
|
||||
'gridLeft' => array('title' => 'Product-Layout', 'class' => 'left-block'),
|
||||
);
|
||||
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Ap Profile Manage'),
|
||||
'icon' => 'icon-folder-close'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Name'),
|
||||
'name' => 'name',
|
||||
'required' => true,
|
||||
'hint' => $this->l('Invalid characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Product List Key'),
|
||||
'name' => 'plist_key',
|
||||
'readonly' => 'readonly',
|
||||
'desc' => $this->l('Tpl File name'),
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Class'),
|
||||
'type' => 'text',
|
||||
'name' => 'class_detail',
|
||||
'width' => 140
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Url Image Preview'),
|
||||
'type' => 'text',
|
||||
'name' => 'url_img_preview',
|
||||
'desc' => $this->l('Only for developers'),
|
||||
'width' => 140
|
||||
),
|
||||
array(
|
||||
'type' => 'ap_proGrid',
|
||||
'name' => 'ap_proGrid',
|
||||
'params' => $params,
|
||||
'blockList' => $block_list,
|
||||
'elements' => $config_file,
|
||||
'demodetaillink' => 'index.php?controller=AdminApPageBuilderDetails'.'&token='.Tools::getAdminTokenLite('AdminApPageBuilderDetails').'&addappagebuilder_details',
|
||||
'element_by_name' => $element_by_name,
|
||||
'widthList' => ApPageSetting::returnWidthList(),
|
||||
'columnGrids' => ApPageSetting::getColumnGrid(),
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'params'
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and Stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save')
|
||||
)
|
||||
);
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
public function importForm()
|
||||
{
|
||||
$helper = new HelperForm();
|
||||
$helper->submit_action = 'import' . $this->table;
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'file',
|
||||
'name' => 'importFile',
|
||||
'label' => $this->l('File'),
|
||||
'desc' => $this->l('Only accept xml file'),
|
||||
),
|
||||
);
|
||||
$fields_form = array(
|
||||
'form' => array(
|
||||
'action' => Context::getContext()->link->getAdminLink('AdminApPageBuilderDetailsController'),
|
||||
'input' => $inputs,
|
||||
'submit' => array('title' => $this->l('Import'), 'class' => 'button btn btn-success'),
|
||||
'tinymce' => false,
|
||||
),
|
||||
);
|
||||
$helper->fields_value = isset($this->fields_value) ? $this->fields_value : array();
|
||||
$helper->identifier = $this->identifier;
|
||||
$helper->currentIndex = self::$currentIndex;
|
||||
$helper->token = $this->token;
|
||||
$helper->table = 'xml_import';
|
||||
$html = $helper->generateForm(array($fields_form));
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function replaceSpecialStringToHtml($arr)
|
||||
{
|
||||
foreach ($arr as &$v) {
|
||||
if ($v['name'] == 'code') {
|
||||
// validate module
|
||||
$v['code'] = str_replace($this->str_search, $this->str_relace, $v['code']);
|
||||
} else {
|
||||
if ($v['name'] == 'functional_buttons') {
|
||||
foreach ($v as &$f) {
|
||||
if ($f['name'] == 'code') {
|
||||
// validate module
|
||||
$f['code'] = str_replace($this->str_search, $this->str_relace, $f['code']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function getFieldsValue($obj)
|
||||
{
|
||||
$file_value = parent::getFieldsValue($obj);
|
||||
if (!$obj->id) {
|
||||
$num = ApPageSetting::getRandomNumber();
|
||||
$file_value['plist_key'] = 'detail'.$num;
|
||||
$file_value['name'] = $file_value['plist_key'];
|
||||
$file_value['class_detail'] = 'detail-'.$num;
|
||||
}
|
||||
return $file_value;
|
||||
}
|
||||
|
||||
public function processAdd()
|
||||
{
|
||||
if ($obj = parent::processAdd()) {
|
||||
$this->saveTplFile($obj->plist_key, $obj->params);
|
||||
}
|
||||
}
|
||||
|
||||
public function processUpdate()
|
||||
{
|
||||
if ($obj = parent::processUpdate()) {
|
||||
$this->saveTplFile($obj->plist_key, $obj->params);
|
||||
}
|
||||
}
|
||||
|
||||
public function processDelete()
|
||||
{
|
||||
$object = $this->loadObject();
|
||||
Tools::deleteFile(apPageHelper::getConfigDir('theme_details').$object->plist_key.'.tpl');
|
||||
parent::processDelete();
|
||||
}
|
||||
|
||||
//save file
|
||||
public function saveTplFile($plist_key, $params = '')
|
||||
{
|
||||
$data_form = str_replace($this->str_search, $this->str_relace, $params);
|
||||
$data_form = Tools::jsonDecode($data_form, true);
|
||||
|
||||
$grid_left = $data_form['gridLeft'];
|
||||
$tpl_grid = $this->returnFileContent('header_product');
|
||||
$tpl_grid = str_replace('class="product-detail', 'class="product-detail '.Tools::getValue('class_detail', '').' '.Tools::getValue('main_class', ''), $tpl_grid);
|
||||
$tpl_grid .= $this->convertObjectToTpl($grid_left);
|
||||
$tpl_grid .= $this->returnFileContent('footer_product');
|
||||
|
||||
$tpl_grid = preg_replace('/\{\*[\s\S]*?\*\}/', '', $tpl_grid);
|
||||
|
||||
$folder = apPageHelper::getConfigDir('theme_details');
|
||||
if (!is_dir($folder)) {
|
||||
mkdir($folder, 0755, true);
|
||||
}
|
||||
$file = $plist_key.'.tpl';
|
||||
//$tpl_grid = preg_replace('/\{\*[\s\S]*?\*\}/', '', $tpl_grid);
|
||||
//$tpl_grid = str_replace(" mod='appagebuilder'", '', $tpl_grid);
|
||||
|
||||
ApPageSetting::writeFile($folder, $file, apPageHelper::getLicenceTPL().$tpl_grid);
|
||||
}
|
||||
|
||||
public function processStatus()
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject())) {
|
||||
if ($object->toggleStatus()) {
|
||||
$matches = array();
|
||||
if (preg_match('/[\?|&]controller=([^&]*)/', (string)$_SERVER['HTTP_REFERER'], $matches) !== false && Tools::strtolower($matches[1]) != Tools::strtolower(preg_replace('/controller/i', '', get_class($this)))) {
|
||||
$this->redirect_after = preg_replace('/[\?|&]conf=([^&]*)/i', '', (string)$_SERVER['HTTP_REFERER']);
|
||||
} else {
|
||||
$this->redirect_after = self::$currentIndex.'&token='.$this->token;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating the status for an object.')
|
||||
.'<b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* SHOW LINK DUPLICATE FOR EACH ROW
|
||||
*/
|
||||
public function displayDuplicateLink($token = null, $id = null, $name = null)
|
||||
{
|
||||
$controller = 'AdminApPageBuilderDetails';
|
||||
$token = Tools::getAdminTokenLite($controller);
|
||||
$html = '<a href="#" title="Duplicate" onclick="confirm_link(\'\', \'Duplicate Product Details ID '.$id.'. If you wish to proceed, click "Yes". If not, click "No".\', \'Yes\', \'No\', \'index.php?controller='.$controller.'&id_appagebuilder_details='.$id.'&duplicateappagebuilder_details&token='.$token.'\', \'#\')">
|
||||
<i class="icon-copy"></i> Duplicate
|
||||
</a>';
|
||||
|
||||
// validate module
|
||||
unset($name);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* PERMISSION ACCOUNT demo@demo.com
|
||||
* OVERRIDE CORE
|
||||
*/
|
||||
public function access($action, $disable = false)
|
||||
{
|
||||
if (Tools::getIsset('update'.$this->table) && Tools::getIsset($this->identifier)) {
|
||||
// Allow person see "EDIT" form
|
||||
$action = 'view';
|
||||
}
|
||||
return parent::access($action, $disable);
|
||||
}
|
||||
|
||||
/**
|
||||
* PERMISSION ACCOUNT demo@demo.com
|
||||
* OVERRIDE CORE
|
||||
*/
|
||||
public function initProcess()
|
||||
{
|
||||
parent::initProcess();
|
||||
# SET ACTION : IMPORT DATA
|
||||
if ($this->can_import && Tools::getIsset('import' . $this->table)) {
|
||||
if ($this->access('edit')) {
|
||||
$this->action = 'import';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($this->errors) <= 0) {
|
||||
if (Tools::isSubmit('duplicate'.$this->table)) {
|
||||
if ($this->id_object) {
|
||||
if (!$this->access('add')) {
|
||||
$this->errors[] = $this->trans('You do not have permission to duplicate this.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
}
|
||||
} elseif (Tools::getIsset('saveELement') && Tools::getValue('saveELement')) {
|
||||
if (!$this->access('edit')) {
|
||||
$this->errors[] = $this->trans('You do not have permission to edit this.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
} elseif ($this->can_import && Tools::getIsset('import' . $this->table)) {
|
||||
if (!$this->access('edit')) {
|
||||
$this->errors[] = $this->trans('You do not have permission to import data.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1235
modules/appagebuilder/controllers/admin/AdminApPageBuilderHome.php
Normal file
1235
modules/appagebuilder/controllers/admin/AdminApPageBuilderHome.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,413 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/libs/Helper.php');
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class AdminApPageBuilderHookController extends ModuleAdminControllerCore
|
||||
{
|
||||
/**
|
||||
* @var Boolean $display_key
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
public $display_key = 0;
|
||||
/**
|
||||
* @var Array $hookspos
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
public $hookspos = array();
|
||||
/**
|
||||
* @var Array $ownPositions
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
// public $ownPositions = array();
|
||||
/**
|
||||
* @var String $theme_name
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
public $theme_name;
|
||||
/**
|
||||
* @var String $theme_name
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
public $themeKey;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
$this->table = 'leohook';
|
||||
$this->className = 'AdminApPageBuilderHook';
|
||||
$this->lang = true;
|
||||
$this->context = Context::getContext();
|
||||
parent::__construct();
|
||||
$this->display_key = (int)Tools::getValue('show_modules');
|
||||
|
||||
// $this->ownPositions = array(
|
||||
// 'displayHeaderRight',
|
||||
// 'displaySlideshow',
|
||||
// 'topNavigation',
|
||||
// 'displayPromoteTop',
|
||||
// 'displayBottom',
|
||||
// 'displayMassBottom'
|
||||
// );
|
||||
$this->hookspos = ApPageSetting::getHook();
|
||||
$this->theme_name = apPageHelper::getThemeName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build List linked Icons Toolbar
|
||||
*/
|
||||
public function initPageHeaderToolbar()
|
||||
{
|
||||
if (empty($this->display)) {
|
||||
$this->page_header_toolbar_btn['save'] = array(
|
||||
'href' => 'index.php?tab=AdminApPageBuilderHook&token='.Tools::getAdminTokenLite('AdminApPageBuilderHook').'&action=savepos',
|
||||
'id' => 'savepos',
|
||||
'desc' => $this->l('Save Positions')
|
||||
);
|
||||
}
|
||||
parent::initPageHeaderToolbar();
|
||||
}
|
||||
|
||||
/**
|
||||
* get live Edit URL
|
||||
*/
|
||||
public function getLiveEditUrl($live_edit_params)
|
||||
{
|
||||
$url = $this->context->shop->getBaseURL().Dispatcher::getInstance()->createUrl('index', (int)$this->context->language->id, $live_edit_params);
|
||||
if (Configuration::get('PS_REWRITING_SETTINGS')) {
|
||||
$url = str_replace('index.php', '', $url);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* add toolbar icons
|
||||
*/
|
||||
public function initToolbar()
|
||||
{
|
||||
$this->context->smarty->assign('toolbar_scroll', 1);
|
||||
$this->context->smarty->assign('show_toolbar', 1);
|
||||
$this->context->smarty->assign('toolbar_btn', $this->toolbar_btn);
|
||||
$this->context->smarty->assign('title', $this->toolbar_title);
|
||||
}
|
||||
|
||||
/**
|
||||
* render list of modules following positions in the layout editor.
|
||||
*/
|
||||
public function renderList()
|
||||
{
|
||||
$filePath = _PS_ALL_THEMES_DIR_.$this->theme_name.'';
|
||||
$showed = true;
|
||||
$xml = simplexml_load_file($filePath.'/config.xml');
|
||||
|
||||
if (isset($xml->theme_key)) {
|
||||
$this->themeKey = trim((string)$xml->theme_key);
|
||||
}
|
||||
$this->themeKey = '1111';
|
||||
if ($this->themeKey) {
|
||||
$this->initToolbarTitle();
|
||||
$this->initToolbar();
|
||||
$hookspos = $this->hookspos;
|
||||
|
||||
foreach ($hookspos as $hook) {
|
||||
if (Hook::getIdByName($hook)) {
|
||||
// validate module
|
||||
} else {
|
||||
$new_hook = new Hook();
|
||||
$new_hook->name = pSQL($hook);
|
||||
$new_hook->title = pSQL($hook);
|
||||
$new_hook->add();
|
||||
// $id_hook = $new_hook->id;
|
||||
}
|
||||
}
|
||||
|
||||
// $sql = 'UPDATE `'._DB_PREFIX_.'hook` SET position=1, live_edit=1
|
||||
// WHERE name in ("'.implode('","', $hookspos).'") ';
|
||||
// Db::getInstance(_PS_USE_SQL_SLAVE_)->execute($sql);
|
||||
|
||||
$modules = Module::getModulesInstalled(0);
|
||||
$assoc_modules_id = array();
|
||||
|
||||
$assoc_modules_id = $module_instances = array();
|
||||
foreach ($modules as $module) {
|
||||
if ($tmp_instance = Module::getInstanceById((int)$module['id_module'])) {
|
||||
// We want to be able to sort modules by display name
|
||||
$module_instances[$tmp_instance->displayName] = $tmp_instance;
|
||||
// But we also want to associate hooks to modules using the modules IDs
|
||||
$assoc_modules_id[(int)$module['id_module']] = $tmp_instance->displayName;
|
||||
}
|
||||
}
|
||||
$hooks = Hook::getHooks(!(int)Tools::getValue('hook_position'));
|
||||
|
||||
$hookModules = array();
|
||||
|
||||
$hookedModules = array();
|
||||
foreach ($hooks as $key => $hook) {
|
||||
// validate module
|
||||
unset($key);
|
||||
|
||||
$k = $hook['name'];
|
||||
$k = (Tools::strtolower(Tools::substr($k, 0, 1)).Tools::substr($k, 1));
|
||||
if (in_array($k, $hookspos)) {
|
||||
// Get all modules for this hook or only the filtered module
|
||||
$hookModules[$k]['modules'] = Hook::getModulesFromHook($hook['id_hook'], $this->display_key);
|
||||
$hookModules[$k]['module_count'] = count($hookModules[$k]['modules']);
|
||||
|
||||
if (is_array($hookModules[$k]['modules']) && !empty($hookModules[$k]['modules'])) {
|
||||
foreach ($hookModules[$k]['modules'] as $module_key => $module) {
|
||||
if (isset($assoc_modules_id[$module['id_module']])) {
|
||||
$hookedModules[] = $module['id_module'];
|
||||
$hookModules[$k]['modules'][$module_key]['instance'] = $module_instances[$assoc_modules_id[$module['id_module']]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$instances = array();
|
||||
foreach ($modules as $module) {
|
||||
if ($tmp_instance = Module::getInstanceById($module['id_module'])) {
|
||||
foreach ($hookspos as $hk) {
|
||||
$retro_hook_name = Hook::getRetroHookName($hk);
|
||||
$hook_callable = is_callable(array($tmp_instance, 'hook'.$hk));
|
||||
$hook_retro_callable = is_callable(array($tmp_instance, 'hook'.$retro_hook_name));
|
||||
if ($hook_retro_callable || $hook_callable) {
|
||||
$instances[$tmp_instance->displayName] = $tmp_instance;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ksort($instances);
|
||||
|
||||
$tpl = $this->createTemplate('panel.tpl');
|
||||
|
||||
// $this->context->controller->addJqueryUI('ui.sortable');
|
||||
// $this->context->controller->addJqueryUI('ui.draggable');
|
||||
$this->context->controller->addCss(apPageHelper::getCssAdminDir().'admin/style_hook_cpanel.css');
|
||||
$this->context->controller->addJs(apPageHelper::getJsAdminDir().'/jquery-ui-1.10.3.custom.min.js', 'all');
|
||||
$tpl->assign(array(
|
||||
'showed' => $showed,
|
||||
'toolbar' => $this->context->smarty->fetch('toolbar.tpl'),
|
||||
'modules' => $instances,
|
||||
'hookspos' => $hookspos,
|
||||
'URI' => __PS_BASE_URI__.'modules/',
|
||||
'hookModules' => $hookModules,
|
||||
'noModuleConfig' => $this->l('No Configuration For This Module'),
|
||||
'currentURL' => 'index.php?tab=AdminApPageBuilderHook&token='.Tools::getAdminTokenLite('AdminApPageBuilderHook').'',
|
||||
// 'moduleEditURL' => 'index.php?tab=AdminApPageBuilderHook&token='.Tools::getAdminTokenLite('AdminApPageBuilderHook').'',
|
||||
'moduleEditURL' => 'index.php?controller=adminmodules&token='.Tools::getAdminTokenLite('AdminModules').'&tab_module=Home',
|
||||
));
|
||||
|
||||
return $tpl->fetch();
|
||||
} else {
|
||||
$tpl = $this->createTemplate('error.tpl');
|
||||
$tpl->assign(array(
|
||||
'showed' => false,
|
||||
'themeURL' => 'index.php?controller=AdminThemes&token='.Tools::getAdminTokenLite('AdminThemes')
|
||||
));
|
||||
return $tpl->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process posting data
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if (count($this->errors) > 0) {
|
||||
if ($this->ajax) {
|
||||
$array = array('hasError' => true, 'errors' => $this->errors[0]);
|
||||
die(Tools::jsonEncode($array));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (Tools::getValue('action') && Tools::getValue('action') == 'modulehook') {
|
||||
// AJAX EDIT HOOK - READ
|
||||
$id = (int)Tools::getValue('id');
|
||||
|
||||
$tmp_instance = Module::getInstanceById($id);
|
||||
$hooks = array();
|
||||
|
||||
foreach ($this->hookspos as $hk) {
|
||||
$retro_hook_name = Hook::getRetroHookName($hk);
|
||||
$hook_callable = is_callable(array($tmp_instance, 'hook'.$hk));
|
||||
$hook_retro_callable = is_callable(array($tmp_instance, 'hook'.$retro_hook_name));
|
||||
|
||||
if ($hook_retro_callable || $hook_callable) {
|
||||
$hooks[] = $hk;
|
||||
}
|
||||
}
|
||||
$hooks = implode('|', $hooks);
|
||||
$sql = 'SELECT * FROM `'._DB_PREFIX_.'leohook` WHERE id_module='.(int)$id.' AND theme="'.pSQL($this->theme_name).'" AND id_shop='.(int)($this->context->shop->id);
|
||||
|
||||
if ($row = Db::getInstance()->getRow($sql)) {
|
||||
die('{"hasError" : false, "hook" : "'.$row['name_hook'].'","hooks":"'.$hooks.'"}');
|
||||
} else {
|
||||
die('{"hasError" : true, "errors" : "Can not update module position","hooks":"'.$hooks.'"}');
|
||||
}
|
||||
}
|
||||
if (Tools::getValue('action') && Tools::getValue('action') == 'overridehook') {
|
||||
// AJAX EDIT HOOK - SAVE
|
||||
$id_module = (int)Tools::getValue('hdidmodule');
|
||||
$name_hook = Tools::getValue('name_hook');
|
||||
if (is_numeric($name_hook)) {
|
||||
$sql = 'DELETE FROM`'._DB_PREFIX_.'leohook` WHERE id_module='.(int)$id_module.' AND theme="'.pSQL($this->theme_name).'" AND id_shop='.(int)($this->context->shop->id);
|
||||
|
||||
Db::getInstance(_PS_USE_SQL_SLAVE_)->execute($sql);
|
||||
die('{"hasError" : false, "errors" : "done!delete module position"}');
|
||||
} elseif ($name_hook) {
|
||||
$desHook = Tools::getValue('deshook');
|
||||
$desHookId = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT id_hook FROM `'._DB_PREFIX_."hook` WHERE name='".pSQL($desHook)."'");
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'leohook` WHERE id_hook= '.(int)$desHookId.' AND id_module='.(int)$id_module.' AND theme="'.pSQL($this->theme_name).'" AND id_shop='.(int)($this->context->shop->id);
|
||||
|
||||
if ($row = Db::getInstance()->getRow($sql)) {
|
||||
$sql = ' UPDATE `'._DB_PREFIX_.'leohook` SET `id_hook`='.(int)$desHookId.', name_hook="'.pSQL($name_hook).'"
|
||||
WHERE id_module='.(int)$id_module.' AND theme="'.pSQL($this->theme_name).'" AND id_shop='.(int)($this->context->shop->id);
|
||||
Db::getInstance(_PS_USE_SQL_SLAVE_)->execute($sql);
|
||||
} else {
|
||||
$sql = ' INSERT INTO `'._DB_PREFIX_.'leohook` (id_hook, id_module, id_shop, theme, name_hook)
|
||||
VALUES('.(int)$desHookId.','.(int)$id_module.','.(int)($this->context->shop->id).',"'.pSQL($this->theme_name).'","'.pSQL($name_hook).'")';
|
||||
Db::getInstance(_PS_USE_SQL_SLAVE_)->execute($sql);
|
||||
}
|
||||
die('{"hasError" : false, "errors" : "done!update module position"}');
|
||||
}
|
||||
die('{"hasError" : true, "errors" : "Can not update module position"}');
|
||||
}
|
||||
if (Tools::getValue('action') && Tools::getValue('action') == 'savepos') {
|
||||
// SUBMIT - SAVE HOOK
|
||||
$positions = Tools::getValue('position');
|
||||
$way = (int)(Tools::getValue('way'));
|
||||
$unhook = Tools::getValue('unhook');
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
|
||||
if (is_array($unhook)) {
|
||||
foreach ($unhook as $id_module => $str_hookId) {
|
||||
$hookIds = explode(',', $str_hookId);
|
||||
foreach ($hookIds as $hookId) {
|
||||
$module = Module::getInstanceById($id_module);
|
||||
if (Validate::isLoadedObject($module)) {
|
||||
!$module->unregisterHook((int)$hookId, array($id_shop));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($positions) && !empty($positions)) {
|
||||
foreach ($positions as $pos) {
|
||||
$tmp = explode('|', $pos);
|
||||
if (count($tmp) == 2 && $tmp[0] && $tmp[1]) {
|
||||
$position = $tmp[0];
|
||||
$hookId = Hook::getIdByName($position);
|
||||
$oldhooks = explode(',', Tools::getValue($position));
|
||||
|
||||
$ids = explode(',', $tmp[1]);
|
||||
if ($hookId && count($oldhooks)) {
|
||||
foreach ($ids as $index => $id_module) {
|
||||
$module = Module::getInstanceById($id_module);
|
||||
|
||||
if (Validate::isLoadedObject($module) && isset($oldhooks[$index]) && is_numeric($oldhooks[$index]) && $oldhooks[$index] != $hookId) {
|
||||
// MOVE MODULE TO OTHER HOOK
|
||||
$sql = 'UPDATE `'._DB_PREFIX_.'hook_module` SET id_hook='.(int)$hookId.'
|
||||
WHERE id_module='.(int)$id_module.' AND id_hook='.(int)$oldhooks[$index].' AND id_shop='.(int)($id_shop);
|
||||
try {
|
||||
// FIX: Drag a module to one hook in 2 times. Save 500 error
|
||||
Db::getInstance(_PS_USE_SQL_SLAVE_)->execute($sql);
|
||||
} catch (Exception $ex) {
|
||||
}
|
||||
} elseif (Validate::isLoadedObject($module) && (!isset($oldhooks[$index]) || !(int)$oldhooks[$index])) {
|
||||
$this->registerHook($id_module, $hookId, array($id_shop));
|
||||
//echo 'new:'.$id_module;
|
||||
}
|
||||
$module->updatePosition($hookId, $way, $index + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
die('{"hasError" : false, "errors" : "update module position"}');
|
||||
}
|
||||
}
|
||||
|
||||
public function registerHook($id_module, $id_hook, $shop_list = null)
|
||||
{
|
||||
// If shop lists is null, we fill it with all shops
|
||||
if (is_null($shop_list)) {
|
||||
$shop_list = Shop::getShops(true, null, true);
|
||||
}
|
||||
|
||||
$return = true;
|
||||
foreach ($shop_list as $shop_id) {
|
||||
// Check if already register
|
||||
$sql = 'SELECT hm.`id_module`
|
||||
FROM `'._DB_PREFIX_.'hook_module` hm, `'._DB_PREFIX_.'hook` h
|
||||
WHERE hm.`id_module` = '.(int)($id_module).' AND h.`id_hook` = '.(int)$id_hook.'
|
||||
AND h.`id_hook` = hm.`id_hook` AND `id_shop` = '.(int)$shop_id;
|
||||
|
||||
|
||||
if (Db::getInstance()->getRow($sql)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get module position in hook
|
||||
$sql = 'SELECT MAX(`position`) AS position
|
||||
FROM `'._DB_PREFIX_.'hook_module`
|
||||
WHERE `id_hook` = '.(int)$id_hook.' AND `id_shop` = '.(int)$shop_id;
|
||||
if (!$position = Db::getInstance()->getValue($sql)) {
|
||||
$position = 0;
|
||||
}
|
||||
|
||||
// Register module in hook
|
||||
$return &= Db::getInstance()->insert('hook_module', array(
|
||||
'id_module' => (int)$id_module,
|
||||
'id_hook' => (int)$id_hook,
|
||||
'id_shop' => (int)$shop_id,
|
||||
'position' => (int)($position + 1),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PERMISSION ACCOUNT demo@demo.com
|
||||
* OVERRIDE CORE
|
||||
*/
|
||||
public function initProcess()
|
||||
{
|
||||
parent::initProcess();
|
||||
|
||||
if (count($this->errors) <= 0) {
|
||||
if (Tools::getIsset('updateleohook') && Tools::getValue('updateleohook')) {
|
||||
if (!$this->access('edit')) {
|
||||
$this->errors[] = $this->trans('You do not have permission to edit this.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_ . 'appagebuilder/classes/ApPageSetting.php');
|
||||
|
||||
class AdminApPageBuilderImagesController extends ModuleAdminController
|
||||
{
|
||||
protected $max_image_size = null;
|
||||
public $theme_name;
|
||||
public $module_name = 'appagebuilder';
|
||||
public $img_path;
|
||||
public $folder_name;
|
||||
public $module_path;
|
||||
public $tpl_path;
|
||||
public $theme_dir;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->theme_dir = apPageHelper::getConfigDir('_PS_THEME_DIR_');
|
||||
$this->folder_name = Tools::getIsset('imgDir') ? Tools::getValue('imgDir') : 'images';
|
||||
$this->bootstrap = true;
|
||||
$this->max_image_size = (int) Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE');
|
||||
$this->theme_name = apPageHelper::getThemeName();
|
||||
$this->img_path = apPageHelper::getImgThemeDir($this->folder_name);
|
||||
$this->img_url = apPageHelper::getImgThemeUrl($this->folder_name);
|
||||
$this->className = 'ApPageBuilderImages';
|
||||
$this->context = Context::getContext();
|
||||
$this->module_path = __PS_BASE_URI__ . 'modules/' . $this->module_name . '/';
|
||||
$this->tpl_path = _PS_ROOT_DIR_ . '/modules/' . $this->module_name . '/views/templates/admin';
|
||||
|
||||
# LIVE THEME EDITER
|
||||
$leo_controller = Tools::getValue('leo_controller');
|
||||
if ($leo_controller == 'live_theme_edit') {
|
||||
$this->context->controller->addCss(apPageHelper::getCssAdminDir() . 'admin/images.css', 'all');
|
||||
|
||||
$this->img_path = _PS_ALL_THEMES_DIR_ . apPageHelper::getThemeName() . '/assets/img/patterns/';
|
||||
$this->img_url = __PS_BASE_URI__ . 'themes/' . apPageHelper::getThemeName() . '/assets/img/patterns/';
|
||||
$this->context->controller->addCss(apPageHelper::getCssAdminDir() . 'admin/images.css', 'all');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action Live Theme Editor
|
||||
*/
|
||||
public function renderList()
|
||||
{
|
||||
$tpl = $this->createTemplate('imagemanager.tpl');
|
||||
$sort_by = Tools::getValue('sortBy');
|
||||
$images = $this->getImageList($sort_by);
|
||||
$image_uploader = new HelperImageUploader('file');
|
||||
$image_uploader->setSavePath($this->img_path);
|
||||
$image_uploader->setMultiple(true)->setUseAjax(true)->setUrl(Context::getContext()->link->getAdminLink('AdminApPageBuilderImages') . '&ajax=1&action=addimage&leo_controller=live_theme_edit'); // url upload image
|
||||
|
||||
$tpl->assign(array(
|
||||
'img_dir' => $this->folder_name,
|
||||
'countImages' => count($images),
|
||||
'images' => $images,
|
||||
'max_image_size' => $this->max_image_size / 1024 / 1024,
|
||||
'image_uploader' => $image_uploader->render(),
|
||||
'imgManUrl' => Context::getContext()->link->getAdminLink('AdminApPageBuilderImages'),
|
||||
'token' => $this->token,
|
||||
'url_param' => '&leo_controller=live_theme_edit'
|
||||
));
|
||||
return $tpl->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Action Live Theme Editor
|
||||
*/
|
||||
public function ajaxProcessReloadBackground()
|
||||
{
|
||||
$sort_by = Tools::getValue('sortBy');
|
||||
$tpl = $this->createTemplate('imagemanager.tpl');
|
||||
$images = $this->getImageList($sort_by);
|
||||
$tpl->assign(array(
|
||||
'images' => $images,
|
||||
'reloadBack' => 1
|
||||
));
|
||||
die(Tools::jsonEncode($tpl->fetch()));
|
||||
}
|
||||
|
||||
public function getImageList($sortBy)
|
||||
{
|
||||
$path = $this->img_path;
|
||||
# CACH 1 : lay cac file anh
|
||||
$images = glob($path . '{*.jpeg,*.JPEG,*.jpg,*.JPG,*.gif,*.GIF,*.png,*.PNG}', GLOB_BRACE);
|
||||
if ($images === null) {
|
||||
# CACH 2 : lay cac file anh
|
||||
$files = scandir($path);
|
||||
$files = array_diff($files, array(
|
||||
'..',
|
||||
'.'
|
||||
)); # insert code
|
||||
|
||||
$images = array();
|
||||
foreach ($files as $key => $image) {
|
||||
# validate module
|
||||
unset($key);
|
||||
$ext = Tools::substr($image, strrpos($image, '.') + 1);
|
||||
if (in_array($ext, array(
|
||||
'jpg',
|
||||
'jpeg',
|
||||
'png',
|
||||
'gif',
|
||||
'JPG',
|
||||
'JPEG',
|
||||
'PNG',
|
||||
'GIF'
|
||||
))) {
|
||||
$images[] = $image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($sortBy == 'name_desc') {
|
||||
rsort($images);
|
||||
}
|
||||
|
||||
if ($sortBy == 'date' || $sortBy == 'date_desc') {
|
||||
ksort($images);
|
||||
}
|
||||
if ($sortBy == 'date_desc') {
|
||||
rsort($images);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
foreach ($images as &$file) {
|
||||
$fileInfo = pathinfo($file);
|
||||
$result[] = array(
|
||||
'name' => $fileInfo['basename'],
|
||||
'link' => $this->img_url . $fileInfo['basename']
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function renderTemplate($tpl_name)
|
||||
{
|
||||
$path = '';
|
||||
if (file_exists($this->theme_dir . 'modules/' . $this->module->name . '/views/templates/admin/' . $tpl_name) && $this->viewAccess()) {
|
||||
$path = $this->theme_dir . 'modules/' . $this->module->name . '/views/templates/admin/' . $tpl_name;
|
||||
} elseif (file_exists($this->getTemplatePath() . $this->override_folder . $tpl_name) && $this->viewAccess()) {
|
||||
$path = $this->getTemplatePath() . $this->override_folder . $tpl_name;
|
||||
}
|
||||
$content = Context::getContext()->smarty->fetch($path);
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action Manage Image
|
||||
*/
|
||||
public function ajaxProcessManageImage()
|
||||
{
|
||||
$smarty = Context::getContext()->smarty;
|
||||
$sort_by = Tools::getValue('sortBy');
|
||||
$images = $this->getImageList($sort_by);
|
||||
$image_uploader = new HelperImageUploader('file');
|
||||
$image_uploader->setSavePath($this->img_path);
|
||||
$image_uploader->setTemplateDirectory($this->tpl_path . '/helpers/uploader');
|
||||
|
||||
$image_uploader->setTemplate('ajax.tpl');
|
||||
$image_uploader->setMultiple(true)->setUseAjax(true)->setUrl(Context::getContext()->link->getAdminLink('AdminApPageBuilderImages') . '&ajax=1&action=addimage&imgDir=' . $this->folder_name);
|
||||
$upload_html = $image_uploader->render();
|
||||
$smarty->assign(array(
|
||||
'img_dir' => $this->folder_name,
|
||||
'widget' => Tools::getValue('widget'),
|
||||
'countImages' => count($images),
|
||||
'images' => $images,
|
||||
'max_image_size' => $this->max_image_size / 1024 / 1024,
|
||||
'image_uploader' => $upload_html,
|
||||
'imgManUrl' => Context::getContext()->link->getAdminLink('AdminApPageBuilderImages'),
|
||||
'token' => $this->token,
|
||||
'link' => Context::getContext()->link
|
||||
));
|
||||
die($this->renderTemplate('imagemanager.tpl'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Action Add Image
|
||||
*/
|
||||
public function ajaxProcessAddImage()
|
||||
{
|
||||
if (isset($_FILES['file'])) {
|
||||
try {
|
||||
$image_uploader = new HelperUploader('file');
|
||||
|
||||
if (!file_exists($this->img_path)) {
|
||||
mkdir($this->img_path, 0755, true);
|
||||
}
|
||||
$image_uploader->setSavePath($this->img_path);
|
||||
$image_uploader->setAcceptTypes(array(
|
||||
'jpeg',
|
||||
'gif',
|
||||
'png',
|
||||
'jpg'
|
||||
))->setMaxSize($this->max_image_size);
|
||||
$total_errors = array();
|
||||
|
||||
$files = $image_uploader->process();
|
||||
foreach ($files as &$file) {
|
||||
$errors = array();
|
||||
// Evaluate the memory required to resize the image: ifit's too much, you can't resize it.
|
||||
if (!ImageManager::checkImageMemoryLimit($file['save_path'])) {
|
||||
$errors[] = Tools::displayError('Due to memory limit restrictions, this image cannot be loaded.
|
||||
Please increase your memory_limit value via your server\'s configuration settings.');
|
||||
}
|
||||
if (count($errors)) {
|
||||
$total_errors = array_merge($total_errors, $errors);
|
||||
}
|
||||
//unlink($file['save_path']);
|
||||
//Necesary to prevent hacking
|
||||
unset($file['save_path']);
|
||||
//Add image preview and delete url
|
||||
}
|
||||
if (count($total_errors)) {
|
||||
$this->context->controller->errors = array_merge($this->context->controller->errors, $total_errors);
|
||||
}
|
||||
$images = $this->getImageList('date');
|
||||
$tpl = $this->createTemplate('imagemanager.tpl');
|
||||
$tpl->assign(array(
|
||||
'images' => $images,
|
||||
'reloadSliderImage' => 1,
|
||||
'link' => Context::getContext()->link
|
||||
));
|
||||
|
||||
die(Tools::jsonEncode($tpl->fetch()));
|
||||
} catch (Exception $ex) {
|
||||
die("Error in ajaxProcessAddImage");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action Sort Image
|
||||
*/
|
||||
public function ajaxProcessReLoadSliderImage()
|
||||
{
|
||||
$tpl = $this->createTemplate('imagemanager.tpl');
|
||||
$sort_by = Tools::getValue('sortBy');
|
||||
$images = $this->getImageList($sort_by);
|
||||
$tpl->assign(array(
|
||||
'images' => $images,
|
||||
'reloadSliderImage' => 1,
|
||||
'link' => Context::getContext()->link
|
||||
));
|
||||
die(Tools::jsonEncode($tpl->fetch()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Action Delete Image
|
||||
*/
|
||||
public function ajaxProcessDeleteImage()
|
||||
{
|
||||
if (($img_name = Tools::getValue('imgName', false)) !== false) {
|
||||
$link = $this->img_path;
|
||||
$this->icon_path = $link = str_replace('modules/appagebuilder/images', 'modules/appagebuilder/icon', $link);
|
||||
|
||||
if (file_exists($link . $img_name)) {
|
||||
unlink($link . $img_name);
|
||||
$images = $this->getIconList('date');
|
||||
} else if (file_exists($this->img_path . $img_name)) {
|
||||
unlink($this->img_path . $img_name);
|
||||
$images = $this->getImageList('date');
|
||||
} else {
|
||||
throw new PrestaShopException('Do not find' . $link . $img_name);
|
||||
}
|
||||
|
||||
$tpl = $this->createTemplate('imagemanager.tpl');
|
||||
$tpl->assign(array(
|
||||
'images' => $images,
|
||||
'reloadSliderImage' => 1,
|
||||
'link' => Context::getContext()->link
|
||||
));
|
||||
|
||||
die(Tools::jsonEncode($tpl->fetch()));
|
||||
}
|
||||
}
|
||||
|
||||
public function getIconList($sortBy)
|
||||
{
|
||||
$path = $this->icon_path;
|
||||
$images = glob($path . '{*.jpeg,*.JPEG,*.jpg,*.JPG,*.gif,*.GIF,*.png,*.PNG}', GLOB_BRACE);
|
||||
|
||||
if ($images === null) {
|
||||
# CACH 2 : lay cac file anh
|
||||
$files = scandir($path);
|
||||
$files = array_diff($files, array(
|
||||
'..',
|
||||
'.'
|
||||
)); # insert code
|
||||
|
||||
$images = array();
|
||||
foreach ($files as $key => $image) {
|
||||
# validate module
|
||||
unset($key);
|
||||
$ext = Tools::substr($image, strrpos($image, '.') + 1);
|
||||
if (in_array($ext, array(
|
||||
'jpg',
|
||||
'jpeg',
|
||||
'png',
|
||||
'gif',
|
||||
'JPG',
|
||||
'JPEG',
|
||||
'PNG',
|
||||
'GIF'
|
||||
))) {
|
||||
$images[] = $image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($sortBy == 'name_desc') {
|
||||
rsort($images);
|
||||
}
|
||||
|
||||
if ($sortBy == 'date' || $sortBy == 'date_desc') {
|
||||
ksort($images);
|
||||
}
|
||||
if ($sortBy == 'date_desc') {
|
||||
rsort($images);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
|
||||
foreach ($images as &$file) {
|
||||
$fileInfo = pathinfo($file);
|
||||
$result[] = array(
|
||||
'name' => $fileInfo['basename'],
|
||||
'link' => str_replace(
|
||||
'modules/appagebuilder/images',
|
||||
'modules/appagebuilder/icon',
|
||||
$this->img_url
|
||||
) . $fileInfo['basename']
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function viewAccess($disable = true)
|
||||
{
|
||||
// return $this->access('view', $disable);
|
||||
unset($disable);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class AdminApPageBuilderModuleController extends ModuleAdminControllerCore
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$url = 'index.php?controller=AdminModules&configure=appagebuilder&token='.Tools::getAdminTokenLite('AdminModules');
|
||||
Tools::redirectAdmin($url);
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,508 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageBuilderPositionsModel.php');
|
||||
|
||||
class AdminApPageBuilderPositionsController extends ModuleAdminControllerCore
|
||||
{
|
||||
public $position_js_folder = '';
|
||||
public $position_css_folder = '';
|
||||
public $module_name = 'appagebuilder';
|
||||
public $explicit_select;
|
||||
public $order_by;
|
||||
public $order_way;
|
||||
public $theme_dir;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
$this->table = 'appagebuilder_positions';
|
||||
$this->className = 'ApPageBuilderPositionsModel';
|
||||
$this->lang = false;
|
||||
$this->explicit_select = true;
|
||||
$this->allow_export = true;
|
||||
$this->context = Context::getContext();
|
||||
$this->order_by = 'position';
|
||||
$this->order_way = 'DESC';
|
||||
$this->_join = '
|
||||
INNER JOIN `'._DB_PREFIX_.'appagebuilder_positions_shop` ps ON (ps.`id_appagebuilder_positions` = a.`id_appagebuilder_positions`)';
|
||||
parent::__construct();
|
||||
$this->fields_list = array(
|
||||
'id_appagebuilder_positions' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 50,
|
||||
'class' => 'fixed-width-xs'
|
||||
),
|
||||
'position' => array(
|
||||
'title' => $this->l('Position'),
|
||||
'width' => 140,
|
||||
'type' => 'text',
|
||||
'filter_key' => 'a!position',
|
||||
'remove_onclick' => true
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
'width' => 140,
|
||||
'type' => 'text',
|
||||
'filter_key' => 'a!name',
|
||||
'remove_onclick' => true
|
||||
),
|
||||
'position_key' => array(
|
||||
'title' => $this->l('Key'),
|
||||
'filter_key' => 'a!position_key',
|
||||
'type' => 'text',
|
||||
'width' => 140,
|
||||
'remove_onclick' => true
|
||||
)
|
||||
);
|
||||
$this->list_no_link = 'no';
|
||||
$this->bulk_actions = array(
|
||||
'delete' => array(
|
||||
'text' => $this->l('Delete selected'),
|
||||
'confirm' => $this->l('Delete selected items?'),
|
||||
'icon' => 'icon-trash'
|
||||
),
|
||||
'correctlink' => array(
|
||||
'text' => $this->l('Correct Image Link'),
|
||||
'confirm' => $this->l('Are you sure you want to change image url from old theme to new theme?'),
|
||||
'icon' => 'icon-edit'
|
||||
),
|
||||
'insertLang' => array(
|
||||
'text' => $this->l('Auto Input Data for New Lang'),
|
||||
'confirm' => $this->l('Auto insert data for new language?'),
|
||||
'icon' => 'icon-edit'
|
||||
)
|
||||
);
|
||||
$this->_where = ' AND ps.id_shop='.(int)$this->context->shop->id;
|
||||
|
||||
$this->theme_dir = apPageHelper::getConfigDir('_PS_THEME_DIR_');
|
||||
$this->position_css_folder = apPageHelper::getConfigDir('_PS_THEME_DIR_').apPageHelper::getCssDir().'positions/';
|
||||
$this->position_js_folder = apPageHelper::getConfigDir('_PS_THEME_DIR_').apPageHelper::getJsDir().'positions/';
|
||||
|
||||
if (!is_dir($this->position_css_folder)) {
|
||||
mkdir($this->position_css_folder, 0755, true);
|
||||
}
|
||||
if (!is_dir($this->position_js_folder)) {
|
||||
mkdir($this->position_js_folder, 0755, true);
|
||||
}
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
parent::initToolbar();
|
||||
|
||||
# SAVE AND STAY
|
||||
if ($this->display == 'add' || $this->display == 'edit') {
|
||||
$this->context->controller->addJs(apPageHelper::getJsAdminDir().'admin/function.js');
|
||||
|
||||
$this->page_header_toolbar_btn['SaveAndStay'] = array(
|
||||
'href' => 'javascript:void(0);',
|
||||
'desc' => $this->l('Save and stay'),
|
||||
'js' => 'TopSaveAndStay()',
|
||||
'icon' => 'process-icon-save',
|
||||
);
|
||||
Media::addJsDef(array('TopSaveAndStay_Name' => 'submitAdd'.$this->table.'AndStay'));
|
||||
|
||||
$this->page_header_toolbar_btn['Save'] = array(
|
||||
'href' => 'javascript:void(0);',
|
||||
'desc' => $this->l('Save'),
|
||||
'js' => 'TopSave()',
|
||||
'icon' => 'process-icon-save',
|
||||
);
|
||||
Media::addJsDef(array('TopSave_Name' => 'submitAdd'.$this->table));
|
||||
}
|
||||
|
||||
# Delete POSITIONS NOT USE
|
||||
switch ($this->display) {
|
||||
default:
|
||||
$this->toolbar_btn['new'] = array(
|
||||
'href' => self::$currentIndex . '&add' . $this->table . '&token=' . $this->token,
|
||||
'desc' => $this->l('Add new'),
|
||||
'class' => 'btn_add_new',
|
||||
);
|
||||
$this->toolbar_btn['eraser'] = array(
|
||||
'href' => self::$currentIndex.'&leo_delete_position=1&token='.$this->token,
|
||||
'desc' => $this->l('Delete position do not use (fix error when create profile)'),
|
||||
'imgclass' => 'eraser',
|
||||
'class' => 'leo_delete_position',
|
||||
);
|
||||
if ($this->allow_export) {
|
||||
unset($this->toolbar_btn['export']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function processDelete()
|
||||
{
|
||||
$object = $this->loadObject();
|
||||
// Check using other profile
|
||||
$result = ApPageBuilderPositionsModel::getProfileUsingPosition($object->id);
|
||||
if (!$result) {
|
||||
$object = parent::processDelete();
|
||||
if ($object->position_key) {
|
||||
Tools::deleteFile($this->position_css_folder.$object->position.$object->position_key.'.css');
|
||||
Tools::deleteFile($this->position_js_folder.$object->position.$object->position_key.'.js');
|
||||
}
|
||||
} else {
|
||||
$name_profile = '';
|
||||
$sep = '';
|
||||
foreach ($result as $item) {
|
||||
$name_profile .= $sep.$item['name'];
|
||||
$sep = ', ';
|
||||
}
|
||||
$this->errors[] = sprintf($this->l('Can not delete position "%s", it is being used by Profile : "%s"'), $object->name, $name_profile);
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function processBulkDelete()
|
||||
{
|
||||
// Remove resouce and update table profiles
|
||||
$arr = $this->boxes;
|
||||
if (!$arr) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($arr as $id) {
|
||||
$profiles = ApPageBuilderPositionsModel::getProfileUsingPosition($id);
|
||||
$object = new ApPageBuilderPositionsModel($id);
|
||||
if (!$profiles) {
|
||||
$object->delete();
|
||||
if ($object->position_key) {
|
||||
Tools::deleteFile($this->position_css_folder.$object->position.$object->position_key.'.css');
|
||||
Tools::deleteFile($this->position_js_folder.$object->position.$object->position_key.'.js');
|
||||
}
|
||||
} else {
|
||||
$name_profile = '';
|
||||
$sep = '';
|
||||
foreach ($profiles as $profile) {
|
||||
$name_profile .= $sep.$profile['name'];
|
||||
$sep = ', ';
|
||||
}
|
||||
$this->errors[] = sprintf($this->l('Can not delete position "%s", it is being used by Profile : "%s"'), $object->name, $name_profile);
|
||||
}
|
||||
}
|
||||
if (empty($this->errors)) {
|
||||
$this->confirmations[] = $this->_conf[1];
|
||||
}
|
||||
}
|
||||
|
||||
public function renderView()
|
||||
{
|
||||
$object = $this->loadObject();
|
||||
$this->redirect_after = Context::getContext()->link->getAdminLink('AdminApPageBuilderHome');
|
||||
$this->redirect_after .= '&id_appagebuilder_positions='.$object->id;
|
||||
$this->redirect();
|
||||
}
|
||||
|
||||
public function processStatus()
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject())) {
|
||||
if ($object->toggleStatus()) {
|
||||
$matches = array();
|
||||
if (preg_match('/[\?|&]controller=([^&]*)/', (string)$_SERVER['HTTP_REFERER'], $matches) !== false && Tools::strtolower($matches[1]) != Tools::strtolower(preg_replace('/controller/i', '', get_class($this)))) {
|
||||
$this->redirect_after = preg_replace('/[\?|&]conf=([^&]*)/i', '', (string)$_SERVER['HTTP_REFERER']);
|
||||
} else {
|
||||
$this->redirect_after = self::$currentIndex.'&token='.$this->token;
|
||||
}
|
||||
|
||||
$id_category = (($id_category = (int)Tools::getValue('id_category')) && Tools::getValue('id_product')) ? '&id_category='.$id_category : '';
|
||||
$this->redirect_after .= '&conf=5'.$id_category;
|
||||
} else {
|
||||
$this->errors[] = $this->l('You can not disable default profile, Please select other profile as default');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('An error occurred while updating the status for an object.').' <b>'.$this->table.'</b> '.$this->l('(cannot load object)');
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
parent::postProcess();
|
||||
if (count($this->errors) > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Tools::getIsset('duplicateappagebuilder_positions')) {
|
||||
$id = Tools::getValue('id_appagebuilder_positions');
|
||||
$this->duplicatePosition($id, '');
|
||||
}
|
||||
|
||||
# Delete POSITIONS NOT USE
|
||||
if (Tools::getValue('leo_delete_position') && Tools::getValue('leo_delete_position')) {
|
||||
apPageHelper::processDeleteOldPosition();
|
||||
$this->confirmations[] = 'POSITIONS NOT USE have been deleted successfully.';
|
||||
}
|
||||
}
|
||||
|
||||
public function duplicatePosition($id, $type = '', $name = '')
|
||||
{
|
||||
$id = (int)$id;
|
||||
$object = ApPageBuilderPositionsModel::getPositionById($id);
|
||||
if ($object) {
|
||||
$key = ApPageSetting::getRandomNumber();
|
||||
$old_key = $object['position_key'];
|
||||
$name = $name ? $name : $this->l('Duplicate ').$key;
|
||||
$data = array('name' => $name, 'position' => $object['position'], 'position_key' => 'duplicate_'.$key);
|
||||
$model = new ApPageBuilderPositionsModel();
|
||||
$duplicate_id = $model->addAuto($data);
|
||||
AdminApPageBuilderShortcodesController::duplcateDataPosition($id, $duplicate_id);
|
||||
if ($duplicate_id) {
|
||||
//duplicate shortCode
|
||||
ApPageSetting::writeFile($this->position_js_folder, $data['position'].$data['position_key'].'.js', Tools::file_get_contents($this->position_js_folder.$data['position'].$old_key.'.js'));
|
||||
ApPageSetting::writeFile($this->position_css_folder, $data['position'].$data['position_key'].'.css', Tools::file_get_contents($this->position_css_folder.$data['position'].$old_key.'.css'));
|
||||
if ($type != 'ajax') {
|
||||
$this->redirect_after = self::$currentIndex.'&token='.$this->token;
|
||||
$this->redirect();
|
||||
} else {
|
||||
return $duplicate_id;
|
||||
}
|
||||
} else {
|
||||
if ($type != 'ajax') {
|
||||
Tools::displayError('Can not duplicate Position');
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else if ($type != 'ajax') {
|
||||
Tools::displayError('Can not duplicate Position');
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$this->initToolbar();
|
||||
|
||||
$this->addRowAction('view');
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('duplicate');
|
||||
$this->addRowAction('delete');
|
||||
return parent::renderList();
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
$this->initToolbar();
|
||||
$this->context->controller->addJqueryUI('ui.sortable');
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Ap Position Manage'),
|
||||
'icon' => 'icon-folder-close'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Name'),
|
||||
'name' => 'name',
|
||||
'required' => true,
|
||||
'hint' => $this->l('Invalid characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Position Key'),
|
||||
'name' => 'position_key',
|
||||
'required' => true,
|
||||
'desc' => $this->l('Use it to save as file name of css and js of Position'),
|
||||
'hint' => $this->l('Invalid characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Type'),
|
||||
'name' => 'position',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'header',
|
||||
'name' => $this->l('Header'),
|
||||
),
|
||||
array(
|
||||
'id' => 'content',
|
||||
'name' => $this->l('Content'),
|
||||
),
|
||||
array(
|
||||
'id' => 'footer',
|
||||
'name' => $this->l('Footer'),
|
||||
),
|
||||
array(
|
||||
'id' => 'product',
|
||||
'name' => $this->l('Product'),
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Custom Css'),
|
||||
'name' => 'css',
|
||||
'desc' => sprintf($this->l('Please set write Permission for folder %s'), $this->position_css_folder),
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Custom Js'),
|
||||
'name' => 'js',
|
||||
'desc' => sprintf($this->l('Please set write Permission for folder %s'), $this->position_js_folder),
|
||||
)
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and Stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save'
|
||||
))
|
||||
);
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
public function getFieldsValue($obj)
|
||||
{
|
||||
$file_value = parent::getFieldsValue($obj);
|
||||
if ($obj->id && $obj->position_key) {
|
||||
$file_value['css'] = Tools::file_get_contents($this->position_css_folder.$obj->position.$obj->position_key.'.css');
|
||||
$file_value['js'] = Tools::file_get_contents($this->position_js_folder.$obj->position.$obj->position_key.'.js');
|
||||
} else {
|
||||
$file_value['position_key'] = 'position'.ApPageSetting::getRandomNumber();
|
||||
}
|
||||
return $file_value;
|
||||
}
|
||||
|
||||
public function processAdd()
|
||||
{
|
||||
if ($obj = parent::processAdd()) {
|
||||
$this->saveCustomJsAndCss($obj->position.$obj->position_key, '');
|
||||
}
|
||||
}
|
||||
|
||||
public function processUpdate()
|
||||
{
|
||||
// Check ifchange position => need delete current file css/js before update
|
||||
$old_object = parent::loadObject();
|
||||
if ($obj = parent::processUpdate()) {
|
||||
$this->saveCustomJsAndCss($obj->position.$obj->position_key, $old_object->position.$obj->position_key);
|
||||
}
|
||||
}
|
||||
|
||||
public function saveCustomJsAndCss($key, $old_key = '')
|
||||
{
|
||||
// Delete old file
|
||||
if ($old_key) {
|
||||
Tools::deleteFile($this->position_css_folder.$old_key.'.css');
|
||||
Tools::deleteFile($this->position_js_folder.$old_key.'.js');
|
||||
}
|
||||
//DONGND:: validate
|
||||
// if (!empty(Tools::getValue('js'))) {
|
||||
if (Tools::getValue('js') != '') {
|
||||
ApPageSetting::writeFile($this->position_js_folder, $key.'.js', Tools::getValue('js'));
|
||||
}
|
||||
//DONGND:: validate
|
||||
// if (!empty(Tools::getValue('css'))) {
|
||||
if (Tools::getValue('css') != '') {
|
||||
ApPageSetting::writeFile($this->position_css_folder, $key.'.css', Tools::getValue('css'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto create a position for page build profile editing/creating
|
||||
* @param type $obj
|
||||
*/
|
||||
public function autoCreatePosition($obj)
|
||||
{
|
||||
$model = new ApPageBuilderPositionsModel();
|
||||
$id = $model->addAuto($obj);
|
||||
if ($id) {
|
||||
$this->saveCustomJsAndCss($obj['position'].$obj['position_key'], '');
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
public function updateName($id, $name)
|
||||
{
|
||||
return ApPageBuilderPositionsModel::updateName($id, $name);
|
||||
}
|
||||
|
||||
public function setMedia($isNewTheme = false)
|
||||
{
|
||||
parent::setMedia($isNewTheme);
|
||||
Context::getContext()->controller->addJs(apPageHelper::getJsAdminDir().'admin/form_admin_positions.js');
|
||||
Media::addJsDefL('leo_confirm_text', $this->l('Are you sure you want to Delete do not use position. Please back-up all thing before?'));
|
||||
Media::addJsDefL('leo_form_submit', Context::getContext()->link->getAdminLink('AdminApPageBuilderPositions'));
|
||||
}
|
||||
|
||||
public function displayDuplicateLink($token = null, $id = null, $name = null)
|
||||
{
|
||||
$controller = 'AdminApPageBuilderPositions';
|
||||
$token = Tools::getAdminTokenLite($controller);
|
||||
$html = '<a href="#" title="Duplicate" onclick="confirm_link(\'\', \'Duplicate Position ID '.$id.'. If you wish to proceed, click "Yes". If not, click "No".\', \'Yes\', \'No\', \'index.php?controller='.$controller.'&id_appagebuilder_positions='.$id.'&duplicateappagebuilder_positions&token='.$token.'\', \'#\')">
|
||||
<i class="icon-copy"></i> Duplicate
|
||||
</a>';
|
||||
|
||||
// validate module
|
||||
unset($name);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* PERMISSION ACCOUNT demo@demo.com
|
||||
* OVERRIDE CORE
|
||||
*/
|
||||
public function access($action, $disable = false)
|
||||
{
|
||||
if (Tools::getIsset('update'.$this->table) && Tools::getIsset($this->identifier)) {
|
||||
// Allow person see "EDIT" form
|
||||
$action = 'view';
|
||||
}
|
||||
return parent::access($action, $disable);
|
||||
}
|
||||
|
||||
/**
|
||||
* PERMISSION ACCOUNT demo@demo.com
|
||||
* OVERRIDE CORE
|
||||
*/
|
||||
public function initProcess()
|
||||
{
|
||||
parent::initProcess();
|
||||
|
||||
if (count($this->errors) <= 0) {
|
||||
if (Tools::isSubmit('duplicate'.$this->table)) {
|
||||
if ($this->id_object) {
|
||||
if (!$this->access('add')) {
|
||||
$this->errors[] = $this->trans('You do not have permission to duplicate this.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
}
|
||||
} elseif (Tools::getIsset('leo_delete_position') && Tools::getValue('leo_delete_position')) {
|
||||
if (!$this->access('delete')) {
|
||||
$this->errors[] = $this->trans('You do not have permission to delelte this.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class AdminAdminApthemeConfigLiveController extends ModuleAdminControllerCore
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,732 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageBuilderProductsModel.php');
|
||||
|
||||
class AdminApPageBuilderProductsController extends ModuleAdminControllerCore
|
||||
{
|
||||
private $theme_name = '';
|
||||
public $module_name = 'appagebuilder';
|
||||
public $tpl_save = '';
|
||||
public $file_content = array();
|
||||
public $explicit_select;
|
||||
public $order_by;
|
||||
public $order_way;
|
||||
public $profile_css_folder;
|
||||
public $module_path;
|
||||
// public $module_path_resource;
|
||||
public $str_search = array();
|
||||
public $str_relace = array();
|
||||
public $theme_dir;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
$this->table = 'appagebuilder_products';
|
||||
$this->className = 'ApPageBuilderProductsModel';
|
||||
$this->lang = false;
|
||||
$this->explicit_select = true;
|
||||
$this->allow_export = true;
|
||||
$this->context = Context::getContext();
|
||||
$this->_join = '
|
||||
INNER JOIN `'._DB_PREFIX_.'appagebuilder_products_shop` ps ON (ps.`id_appagebuilder_products` = a.`id_appagebuilder_products`)';
|
||||
$this->_select .= ' ps.active as active, ps.active_mobile as active_mobile, ps.active_tablet as active_tablet';
|
||||
|
||||
$this->order_by = 'id_appagebuilder_products';
|
||||
$this->order_way = 'DESC';
|
||||
parent::__construct();
|
||||
$this->fields_list = array(
|
||||
'id_appagebuilder_products' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 50,
|
||||
'class' => 'fixed-width-xs'
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
'width' => 140,
|
||||
'type' => 'text',
|
||||
'filter_key' => 'a!name'
|
||||
),
|
||||
'plist_key' => array(
|
||||
'title' => $this->l('Product List Key'),
|
||||
'filter_key' => 'a!plist_key',
|
||||
'type' => 'text',
|
||||
'width' => 140,
|
||||
),
|
||||
'class' => array(
|
||||
'title' => $this->l('Class'),
|
||||
'width' => 140,
|
||||
'type' => 'text',
|
||||
'filter_key' => 'a!class',
|
||||
'orderby' => false
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->l('Is Default'),
|
||||
'active' => 'status',
|
||||
'filter_key' => 'ps!active',
|
||||
'align' => 'text-center',
|
||||
'type' => 'bool',
|
||||
'class' => 'fixed-width-sm',
|
||||
'orderby' => false
|
||||
),
|
||||
'active_mobile' => array(
|
||||
'title' => $this->l('Is Mobile'),
|
||||
'active' => 'active_mobile',
|
||||
'filter_key' => 'ps!active_mobile',
|
||||
'align' => 'text-center',
|
||||
'type' => 'bool',
|
||||
'class' => 'fixed-width-sm',
|
||||
'orderby' => false
|
||||
),
|
||||
'active_tablet' => array(
|
||||
'title' => $this->l('Is Tablet'),
|
||||
'active' => 'active_tablet',
|
||||
'filter_key' => 'ps!active_tablet',
|
||||
'align' => 'text-center',
|
||||
'type' => 'bool',
|
||||
'class' => 'fixed-width-sm',
|
||||
'orderby' => false
|
||||
)
|
||||
);
|
||||
$this->bulk_actions = array(
|
||||
'delete' => array(
|
||||
'text' => $this->l('Delete selected'),
|
||||
'confirm' => $this->l('Delete selected items?'),
|
||||
'icon' => 'icon-trash'
|
||||
)
|
||||
);
|
||||
|
||||
//nghiatd - add theme mobile and table
|
||||
$correct_mobile = Db::getInstance()->executeS('SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = "'._DB_NAME_.'" AND TABLE_NAME="'._DB_PREFIX_.'appagebuilder_products" AND column_name="active_mobile"');
|
||||
if (count($correct_mobile) < 1) {
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'appagebuilder_products_shop` ADD `active_mobile` int(11) NOT NULL');
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'appagebuilder_products_shop` ADD `active_tablet` int(11) NOT NULL');
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'appagebuilder_products` ADD `active_mobile` int(11) NOT NULL');
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'appagebuilder_products` ADD `active_tablet` int(11) NOT NULL');
|
||||
}
|
||||
|
||||
$this->theme_dir = apPageHelper::getConfigDir('_PS_THEME_DIR_');
|
||||
|
||||
$this->_where = ' AND ps.id_shop='.(int)$this->context->shop->id;
|
||||
$this->theme_name = apPageHelper::getThemeName();
|
||||
$this->profile_css_folder = $this->theme_dir.'modules/'.$this->module_name.'/';
|
||||
$this->module_path = __PS_BASE_URI__.'modules/'.$this->module_name.'/';
|
||||
// $this->module_path_resource = $this->module_path.'views/';
|
||||
$this->str_search = array('_APAMP_', '_APQUOT_', '_APAPOST_', '_APTAB_', '_APNEWLINE_', '_APENTER_', '_APOBRACKET_', '_APCBRACKET_', '_APOCBRACKET_', '_APCCBRACKET_');
|
||||
$this->str_relace = array('&', '\"', '\'', '\t', '\r', '\n', '[', ']', '{', '}');
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
parent::initToolbar();
|
||||
|
||||
# SAVE AND STAY
|
||||
if ($this->display == 'add' || $this->display == 'edit') {
|
||||
$this->context->controller->addJs(apPageHelper::getJsAdminDir().'admin/function.js');
|
||||
|
||||
$this->page_header_toolbar_btn['SaveAndStay'] = array(
|
||||
'href' => 'javascript:void(0);',
|
||||
'desc' => $this->l('Save and stay'),
|
||||
'js' => 'TopSaveAndStay()',
|
||||
'icon' => 'process-icon-save',
|
||||
);
|
||||
Media::addJsDef(array('TopSaveAndStay_Name' => 'submitAdd'.$this->table.'AndStay'));
|
||||
|
||||
$this->page_header_toolbar_btn['Save'] = array(
|
||||
'href' => 'javascript:void(0);',
|
||||
'desc' => $this->l('Save'),
|
||||
'js' => 'TopSave()',
|
||||
'icon' => 'process-icon-save',
|
||||
);
|
||||
Media::addJsDef(array('TopSave_Name' => 'submitAdd'.$this->table));
|
||||
}
|
||||
|
||||
# SHOW LINK EXPORT ALL FOR TOOLBAR
|
||||
switch ($this->display) {
|
||||
default:
|
||||
$this->toolbar_btn['new'] = array(
|
||||
'href' => self::$currentIndex . '&add' . $this->table . '&token=' . $this->token,
|
||||
'desc' => $this->l('Add new'),
|
||||
'class' => 'btn_add_new',
|
||||
);
|
||||
if (!$this->display && $this->can_import) {
|
||||
$this->toolbar_btn['import'] = array(
|
||||
'href' => self::$currentIndex . '&import' . $this->table . '&token=' . $this->token,
|
||||
'desc' => $this->trans('Import', array(), 'Admin.Actions'),
|
||||
'class' => 'btn_xml_import',
|
||||
);
|
||||
}
|
||||
if ($this->allow_export) {
|
||||
$this->toolbar_btn['export'] = array(
|
||||
'href' => self::$currentIndex . '&export' . $this->table . '&token=' . $this->token,
|
||||
'desc' => $this->l('Export'),
|
||||
'class' => 'btn_xml_export',
|
||||
);
|
||||
Media::addJsDef(array('record_id' => 'appagebuilder_productsBox[]'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* OVERRIDE CORE
|
||||
*/
|
||||
public function processExport($text_delimiter = '"')
|
||||
{
|
||||
// $multilang = false;
|
||||
if (isset($this->className) && $this->className) {
|
||||
$definition = ObjectModel::getDefinition($this->className);
|
||||
// $multilang = $definition['multilang'];
|
||||
}
|
||||
|
||||
$record_id = Tools::getValue('record_id');
|
||||
$file_name = 'ap_product_list_all.xml';
|
||||
// validate module
|
||||
unset($text_delimiter);
|
||||
|
||||
if ($record_id) {
|
||||
$record_id_str = implode(", ", $record_id);
|
||||
$this->_where = ' AND a.'.$this->identifier.' IN ( '.pSQL($record_id_str).' )';
|
||||
$file_name = 'ap_product_list.xml';
|
||||
}
|
||||
|
||||
$this->getList($this->context->language->id, null, null, 0, false);
|
||||
if (!count($this->_list)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = $this->_list;
|
||||
|
||||
$data_all = array();
|
||||
foreach (Language::getLanguages() as $key => $lang) {
|
||||
$this->getList($lang['id_lang'], null, null, 0, false);
|
||||
$data_all[$lang['iso_code']] = $this->_list;
|
||||
}
|
||||
|
||||
$this->file_content = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||
$this->file_content .= '<data>' . "\n";
|
||||
$this->file_content .= '<product_list>' . "\n";
|
||||
|
||||
if ($data) {
|
||||
foreach ($data as $product_detail) {
|
||||
$this->file_content .= '<record>' . "\n";
|
||||
foreach ($product_detail as $key => $value) {
|
||||
if (isset($definition['fields'][$key]['lang']) && $definition['fields'][$key]['lang']) {
|
||||
# MULTI LANG
|
||||
$this->file_content .= ' <'.$key.'>'. "\n";
|
||||
foreach (Language::getLanguages() as $key_lang => $lang) {
|
||||
// validate module
|
||||
unset($key_lang);
|
||||
$this->file_content .= ' <'.$lang['iso_code'].'>';
|
||||
$this->file_content .= '<![CDATA['.$value.']]>';
|
||||
$this->file_content .= '</'.$lang['iso_code'].'>' . "\n";
|
||||
}
|
||||
$this->file_content .= ' </'.$key.'>' . "\n";
|
||||
} else {
|
||||
# SINGLE LANG
|
||||
$this->file_content .= ' <'.$key.'>';
|
||||
$this->file_content .= '<![CDATA['.$value.']]>';
|
||||
$this->file_content .= '</'.$key.'>' . "\n";
|
||||
}
|
||||
}
|
||||
$this->file_content .= '</record>' . "\n";
|
||||
}
|
||||
}
|
||||
$this->file_content .= '</product_list>' . "\n";
|
||||
$this->file_content .= '</data>' . "\n";
|
||||
header('Content-type: text/xml');
|
||||
header('Content-Disposition: attachment; filename="'.$file_name.'"');
|
||||
echo $this->file_content;
|
||||
die();
|
||||
}
|
||||
|
||||
public function processImport()
|
||||
{
|
||||
$upload_file = new Uploader('importFile');
|
||||
$upload_file->setAcceptTypes(array('xml'));
|
||||
$file = $upload_file->process();
|
||||
$file = $file[0];
|
||||
if (!isset($file['save_path'])) {
|
||||
$this->errors[] = $this->trans('Failed to import.', array(), 'Admin.Notifications.Error');
|
||||
return;
|
||||
}
|
||||
$files_content = simplexml_load_file($file['save_path']);
|
||||
$override = Tools::getValue('override');
|
||||
|
||||
if (isset($files_content->product_list) && $files_content->product_list) {
|
||||
foreach ($files_content->product_list->children() as $product_details) {
|
||||
if (!$override) {
|
||||
$obj_model = new ApPageBuilderProductsModel();
|
||||
$obj_model->plist_key = 'plist'.ApPageSetting::getRandomNumber();
|
||||
$obj_model->name = $product_details->name->__toString();
|
||||
$obj_model->class = $product_details->class->__toString();
|
||||
$obj_model->params = $product_details->params->__toString();
|
||||
$obj_model->type = $product_details->type->__toString();
|
||||
$obj_model->active = 0;
|
||||
|
||||
if ($obj_model->save()) {
|
||||
$this->saveTplFile($obj_model->plist_key, $obj_model->params);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->confirmations[] = $this->trans('Successful importing.', array(), 'Admin.Notifications.Success');
|
||||
} else {
|
||||
$this->errors[] = $this->trans('Wrong file to import.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
}
|
||||
|
||||
public function renderView()
|
||||
{
|
||||
$object = $this->loadObject();
|
||||
if ($object->page == 'product_detail') {
|
||||
$this->redirect_after = Context::getContext()->link->getAdminLink('AdminApPageBuilderProductDetail');
|
||||
} else {
|
||||
$this->redirect_after = Context::getContext()->link->getAdminLink('AdminApPageBuilderHome');
|
||||
}
|
||||
$this->redirect_after .= '&id_appagebuilder_products='.$object->id;
|
||||
$this->redirect();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
parent::postProcess();
|
||||
|
||||
if (Tools::getIsset('active_mobileappagebuilder_products') || Tools::getIsset('active_tabletappagebuilder_products')) {
|
||||
if (Validate::isLoadedObject($object = $this->loadObject())) {
|
||||
$result = Tools::getIsset('active_mobileappagebuilder_products')?$object->toggleStatusMT('active_mobile'):$object->toggleStatusMT('active_tablet');
|
||||
if ($result) {
|
||||
// $this->mesage[] = Tools::displayError('You should enebale mobile theme in theme config');
|
||||
|
||||
$matches = array();
|
||||
if (preg_match('/[\?|&]controller=([^&]*)/', (string)$_SERVER['HTTP_REFERER'], $matches) !== false && Tools::strtolower($matches[1]) != Tools::strtolower(preg_replace('/controller/i', '', get_class($this)))) {
|
||||
$this->redirect_after = preg_replace('/[\?|&]conf=([^&]*)/i', '', (string)$_SERVER['HTTP_REFERER']);
|
||||
} else {
|
||||
$this->redirect_after = self::$currentIndex.'&token='.$this->token.'&mobiletheme';
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You can not disable default profile, Please select other profile as default');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating the status for an object.')
|
||||
.'<b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
}
|
||||
|
||||
if (count($this->errors) > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Tools::getIsset('duplicateappagebuilder_products')) {
|
||||
$id = Tools::getValue('id_appagebuilder_products');
|
||||
$model = new ApPageBuilderProductsModel($id);
|
||||
$duplicate_object = $model->duplicateObject();
|
||||
if (isset($model->params)) {
|
||||
# FIX : insert code can not duplicate
|
||||
$duplicate_object->params = $model->params;
|
||||
}
|
||||
$duplicate_object->name = $this->l('Duplicate of').' '.$duplicate_object->name;
|
||||
$old_key = $duplicate_object->plist_key;
|
||||
$duplicate_object->plist_key = 'plist'.ApPageSetting::getRandomNumber();
|
||||
if ($duplicate_object->add()) {
|
||||
//duplicate shortCode
|
||||
$filecontent = Tools::file_get_contents(apPageHelper::getConfigDir('theme_profiles').$old_key.'.tpl');
|
||||
ApPageSetting::writeFile(apPageHelper::getConfigDir('theme_profiles'), $duplicate_object->plist_key.'.tpl', $filecontent);
|
||||
$this->redirect_after = self::$currentIndex.'&token='.$this->token;
|
||||
$this->redirect();
|
||||
} else {
|
||||
Tools::displayError('Can not duplicate Profiles');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Tools::isSubmit('saveELement')) {
|
||||
$filecontent = Tools::getValue('filecontent');
|
||||
$fileName = Tools::getValue('fileName');
|
||||
if (!is_dir($this->theme_dir.'modules/appagebuilder/views/templates/front/products/')) {
|
||||
if (!is_dir($this->theme_dir.'modules/appagebuilder/views/templates/front/products/')) {
|
||||
mkdir($this->theme_dir.'modules/appagebuilder/views/templates/front/products/', 0755, true);
|
||||
}
|
||||
}
|
||||
ApPageSetting::writeFile($this->theme_dir.'modules/appagebuilder/views/templates/front/products/', $fileName.'.tpl', $filecontent);
|
||||
}
|
||||
}
|
||||
|
||||
public function convertObjectToTpl($object_form)
|
||||
{
|
||||
$tpl = '';
|
||||
foreach ($object_form as $object) {
|
||||
if ($object['name'] == 'functional_buttons') {
|
||||
$tpl .= ApPageSetting::getProductFunctionalButtons();
|
||||
$tpl .= $this->convertObjectToTpl($object['element']);
|
||||
$tpl .= '</div>';
|
||||
} else if ($object['name'] == 'code') {
|
||||
$tpl .= $object['code'];
|
||||
} else {
|
||||
if (!isset($this->file_content[$object['name']])) {
|
||||
$this->returnFileContent($object['name']);
|
||||
}
|
||||
$tpl .= $this->file_content[$object['name']];
|
||||
}
|
||||
}
|
||||
return $tpl;
|
||||
}
|
||||
|
||||
public function returnFileContent($pelement)
|
||||
{
|
||||
$tpl_dir = $this->theme_dir.'modules/appagebuilder/views/templates/front/products/'.$pelement.'.tpl';
|
||||
if (!file_exists($tpl_dir)) {
|
||||
$tpl_dir = _PS_MODULE_DIR_.'appagebuilder/views/templates/front/products/'.$pelement.'.tpl';
|
||||
}
|
||||
$this->file_content[$pelement] = Tools::file_get_contents($tpl_dir);
|
||||
return $this->file_content[$pelement];
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
if (Tools::getIsset('pelement')) {
|
||||
$helper = new HelperForm();
|
||||
$helper->submit_action = 'saveELement';
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'name' => 'filecontent',
|
||||
'label' => $this->l('File Content'),
|
||||
'desc' => $this->l('Please carefully when edit tpl file'),
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'fileName',
|
||||
)
|
||||
);
|
||||
$fields_form = array(
|
||||
'form' => array(
|
||||
'legend' => array(
|
||||
'title' => sprintf($this->l('You are Editing file: %s'), Tools::getValue('pelement').'.tpl'),
|
||||
'icon' => 'icon-cogs'
|
||||
),
|
||||
'action' => Context::getContext()->link->getAdminLink('AdminApPageBuilderShortcodes'),
|
||||
'input' => $inputs,
|
||||
'name' => 'importData',
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
'class' => 'button btn btn-default pull-right'
|
||||
),
|
||||
'tinymce' => false,
|
||||
),
|
||||
);
|
||||
$helper->tpl_vars = array(
|
||||
'fields_value' => $this->getFileContent()
|
||||
);
|
||||
return $helper->generateForm(array($fields_form));
|
||||
}
|
||||
$this->initToolbar();
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('duplicate');
|
||||
$this->addRowAction('delete');
|
||||
return $this->importForm() . parent::renderList();
|
||||
}
|
||||
|
||||
public function importForm()
|
||||
{
|
||||
$helper = new HelperForm();
|
||||
$helper->submit_action = 'import' . $this->table;
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'file',
|
||||
'name' => 'importFile',
|
||||
'label' => $this->l('File'),
|
||||
'desc' => $this->l('Only accept xml file'),
|
||||
),
|
||||
);
|
||||
$fields_form = array(
|
||||
'form' => array(
|
||||
'action' => Context::getContext()->link->getAdminLink('AdminApPageBuilderShortcodeController'),
|
||||
'input' => $inputs,
|
||||
'submit' => array('title' => $this->l('Import'), 'class' => 'button btn btn-success'),
|
||||
'tinymce' => false,
|
||||
),
|
||||
);
|
||||
$helper->fields_value = isset($this->fields_value) ? $this->fields_value : array();
|
||||
$helper->identifier = $this->identifier;
|
||||
$helper->currentIndex = self::$currentIndex;
|
||||
$helper->token = $this->token;
|
||||
$helper->table = 'xml_import';
|
||||
$html = $helper->generateForm(array($fields_form));
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function getFileContent()
|
||||
{
|
||||
$pelement = Tools::getValue('pelement');
|
||||
$tpl_dir = $this->theme_dir.'modules/appagebuilder/views/templates/front/products/'.$pelement.'.tpl';
|
||||
if (!file_exists($tpl_dir)) {
|
||||
$tpl_dir = _PS_MODULE_DIR_.'appagebuilder/views/templates/front/products/'.$pelement.'.tpl';
|
||||
}
|
||||
return array('fileName' => $pelement, 'filecontent' => Tools::file_get_contents($tpl_dir));
|
||||
}
|
||||
|
||||
public function setHelperDisplay(Helper $helper)
|
||||
{
|
||||
parent::setHelperDisplay($helper);
|
||||
$this->helper->module = APPageBuilder::getInstance();
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
$this->initToolbar();
|
||||
$this->context->controller->addJqueryUI('ui.sortable');
|
||||
$this->context->controller->addJqueryUI('ui.draggable');
|
||||
$this->context->controller->addJs(apPageHelper::getJsAdminDir().'admin/form.js');
|
||||
$this->context->controller->addJs(apPageHelper::getJsAdminDir().'admin/product-list.js');
|
||||
$this->context->controller->addCss(apPageHelper::getCssAdminDir().'admin/form.css');
|
||||
$source_file = Tools::scandir(_PS_MODULE_DIR_.'appagebuilder/views/templates/front/products/', 'tpl');
|
||||
if (is_dir($this->theme_dir.'modules/appagebuilder/views/templates/front/products/')) {
|
||||
$source_template_file = Tools::scandir($this->theme_dir.'modules/appagebuilder/views/templates/front/products/', 'tpl');
|
||||
$source_file = array_merge($source_file, $source_template_file);
|
||||
}
|
||||
$elements = array();
|
||||
$icon_list = ApPageSetting::getProductElementIcon();
|
||||
foreach ($source_file as $value) {
|
||||
$fileName = basename($value, '.tpl');
|
||||
if ($fileName == 'index') {
|
||||
continue;
|
||||
}
|
||||
$elements[$fileName] = array(
|
||||
'name' => str_replace('_', ' ', $fileName),
|
||||
'icon' => (isset($icon_list[$fileName]) ? $icon_list[$fileName] : 'icon-sun'));
|
||||
}
|
||||
$params = array('gridLeft' => array(), 'gridRight' => array());
|
||||
|
||||
$this->object->params = str_replace($this->str_search, $this->str_relace, $this->object->params);
|
||||
|
||||
if (isset($this->object->params)) {
|
||||
$params = Tools::jsonDecode($this->object->params, true);
|
||||
}
|
||||
|
||||
//$params['gridLeft'] = $this->replaceSpecialStringToHtml($params['gridLeft']);
|
||||
//$params['gridRight'] = $this->replaceSpecialStringToHtml($params['gridRight']);
|
||||
|
||||
$block_list = array(
|
||||
'gridLeft' => array('title' => 'Product-Image', 'class' => 'left-block'),
|
||||
'gridRight' => array('title' => 'Product-Meta', 'class' => 'right-block'),
|
||||
);
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Ap Profile Manage'),
|
||||
'icon' => 'icon-folder-close'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Name'),
|
||||
'name' => 'name',
|
||||
'required' => true,
|
||||
'hint' => $this->l('Invalid characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Product List Key'),
|
||||
'name' => 'plist_key',
|
||||
'readonly' => 'readonly',
|
||||
'desc' => $this->l('Tpl File name'),
|
||||
),
|
||||
array(
|
||||
'label' => $this->l('Class'),
|
||||
'type' => 'text',
|
||||
'name' => 'class',
|
||||
'width' => 140
|
||||
),
|
||||
array(
|
||||
'type' => 'ap_proGrid',
|
||||
'name' => 'ap_proGrid',
|
||||
'label' => $this->l('Layout'),
|
||||
'elements' => $elements,
|
||||
'params' => $params,
|
||||
'blockList' => $block_list
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'params'
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and Stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save')
|
||||
)
|
||||
);
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
public function replaceSpecialStringToHtml($arr)
|
||||
{
|
||||
foreach ($arr as &$v) {
|
||||
if ($v['name'] == 'code') {
|
||||
// validate module
|
||||
$v['code'] = str_replace($this->str_search, $this->str_relace, $v['code']);
|
||||
} else {
|
||||
if ($v['name'] == 'functional_buttons') {
|
||||
foreach ($v as &$f) {
|
||||
if ($f['name'] == 'code') {
|
||||
// validate module
|
||||
$f['code'] = str_replace($this->str_search, $this->str_relace, $f['code']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function getFieldsValue($obj)
|
||||
{
|
||||
$file_value = parent::getFieldsValue($obj);
|
||||
if (!$obj->id) {
|
||||
$num = ApPageSetting::getRandomNumber();
|
||||
$file_value['plist_key'] = 'plist'.$num;
|
||||
$file_value['name'] = $file_value['plist_key'];
|
||||
$file_value['class'] = 'product-list-'.$num;
|
||||
}
|
||||
return $file_value;
|
||||
}
|
||||
|
||||
public function processAdd()
|
||||
{
|
||||
if ($obj = parent::processAdd()) {
|
||||
$this->saveTplFile($obj->plist_key, $obj->params);
|
||||
}
|
||||
}
|
||||
|
||||
public function processUpdate()
|
||||
{
|
||||
if ($obj = parent::processUpdate()) {
|
||||
$this->saveTplFile($obj->plist_key, $obj->params);
|
||||
}
|
||||
}
|
||||
|
||||
public function processDelete()
|
||||
{
|
||||
$object = $this->loadObject();
|
||||
Tools::deleteFile(apPageHelper::getConfigDir('theme_profiles').$object->plist_key.'.tpl');
|
||||
parent::processDelete();
|
||||
}
|
||||
|
||||
public function saveTplFile($plist_key, $params = '')
|
||||
{
|
||||
$data_form = str_replace($this->str_search, $this->str_relace, $params);
|
||||
$data_form = Tools::jsonDecode($data_form, true);
|
||||
|
||||
$grid_left = $data_form['gridLeft'];
|
||||
$grid_right = $data_form['gridRight'];
|
||||
$tpl_grid = ApPageSetting::getProductContainer();
|
||||
$tpl_grid .= ApPageSetting::getProductLeftBlock().$this->convertObjectToTpl($grid_left)."</div>\n";
|
||||
$tpl_grid .= ApPageSetting::getProductRightBlock().$this->convertObjectToTpl($grid_right)."</div>\n";
|
||||
$tpl_grid .= ApPageSetting::getProductContainerEnd();
|
||||
$folder = apPageHelper::getConfigDir('theme_profiles');
|
||||
if (!is_dir($folder)) {
|
||||
mkdir($folder, 0755, true);
|
||||
}
|
||||
$file = $plist_key.'.tpl';
|
||||
$tpl_grid = preg_replace('/\{\*[\s\S]*?\*\}/', '', $tpl_grid);
|
||||
$tpl_grid = str_replace(" mod='appagebuilder'", '', $tpl_grid);
|
||||
ApPageSetting::writeFile($folder, $file, apPageHelper::getLicenceTPL().$tpl_grid);
|
||||
}
|
||||
|
||||
public function processStatus()
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject())) {
|
||||
if ($object->toggleStatus()) {
|
||||
$matches = array();
|
||||
if (preg_match('/[\?|&]controller=([^&]*)/', (string)$_SERVER['HTTP_REFERER'], $matches) !== false && Tools::strtolower($matches[1]) != Tools::strtolower(preg_replace('/controller/i', '', get_class($this)))) {
|
||||
$this->redirect_after = preg_replace('/[\?|&]conf=([^&]*)/i', '', (string)$_SERVER['HTTP_REFERER']);
|
||||
} else {
|
||||
$this->redirect_after = self::$currentIndex.'&token='.$this->token;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating the status for an object.')
|
||||
.'<b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function displayDuplicateLink($token = null, $id = null, $name = null)
|
||||
{
|
||||
$controller = 'AdminApPageBuilderProducts';
|
||||
$token = Tools::getAdminTokenLite($controller);
|
||||
$html = '<a href="#" title="Duplicate" onclick="confirm_link(\'\', \'Duplicate Product List ID '.$id.'. If you wish to proceed, click "Yes". If not, click "No".\', \'Yes\', \'No\', \'index.php?controller='.$controller.'&id_appagebuilder_products='.$id.'&duplicateappagebuilder_products&token='.$token.'\', \'#\')">
|
||||
<i class="icon-copy"></i> Duplicate
|
||||
</a>';
|
||||
|
||||
// validate module
|
||||
unset($name);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* PERMISSION ACCOUNT demo@demo.com
|
||||
* OVERRIDE CORE
|
||||
*/
|
||||
public function access($action, $disable = false)
|
||||
{
|
||||
if (Tools::getIsset('update'.$this->table) && Tools::getIsset($this->identifier)) {
|
||||
// Allow person see "EDIT" form
|
||||
$action = 'view';
|
||||
}
|
||||
return parent::access($action, $disable);
|
||||
}
|
||||
|
||||
/**
|
||||
* PERMISSION ACCOUNT demo@demo.com
|
||||
* OVERRIDE CORE
|
||||
*/
|
||||
public function initProcess()
|
||||
{
|
||||
parent::initProcess();
|
||||
# SET ACTION : IMPORT DATA
|
||||
if ($this->can_import && Tools::getIsset('import' . $this->table)) {
|
||||
if ($this->access('edit')) {
|
||||
$this->action = 'import';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($this->errors) <= 0) {
|
||||
if (Tools::isSubmit('duplicate'.$this->table)) {
|
||||
if ($this->id_object) {
|
||||
if (!$this->access('add')) {
|
||||
$this->errors[] = $this->trans('You do not have permission to duplicate this.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
}
|
||||
} elseif ($this->can_import && Tools::getIsset('import' . $this->table)) {
|
||||
if (!$this->access('edit')) {
|
||||
$this->errors[] = $this->trans('You do not have permission to import data.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,855 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageBuilderProfilesModel.php');
|
||||
|
||||
class AdminApPageBuilderProfilesController extends ModuleAdminControllerCore
|
||||
{
|
||||
private $theme_name = '';
|
||||
public $profile_js_folder = '';
|
||||
public $profile_css_folder = '';
|
||||
public $module_name = 'appagebuilder';
|
||||
public $explicit_select;
|
||||
public $order_by;
|
||||
public $order_way;
|
||||
public $theme_dir;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
$this->table = 'appagebuilder_profiles';
|
||||
$this->className = 'ApPageBuilderProfilesModel';
|
||||
$this->lang = false;
|
||||
$this->explicit_select = true;
|
||||
$this->allow_export = true;
|
||||
|
||||
parent::__construct();
|
||||
$this->theme_dir = apPageHelper::getConfigDir('_PS_THEME_DIR_');
|
||||
|
||||
$this->context = Context::getContext();
|
||||
|
||||
$this->order_by = 'page';
|
||||
$this->order_way = 'DESC';
|
||||
$alias = 'sa';
|
||||
|
||||
$id_shop = (int)$this->context->shop->id;
|
||||
$this->_join .= ' JOIN `'._DB_PREFIX_.'appagebuilder_profiles_shop`
|
||||
sa ON (a.`id_appagebuilder_profiles` = sa.`id_appagebuilder_profiles` AND sa.id_shop = '.$id_shop.')';
|
||||
$this->_select .= ' sa.active as active, sa.active_mobile as active_mobile, sa.active_tablet as active_tablet';
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_appagebuilder_profiles' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 50,
|
||||
'class' => 'fixed-width-xs'
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
'width' => 140,
|
||||
'type' => 'text',
|
||||
'filter_key' => 'a!name'
|
||||
),
|
||||
'profile_key' => array(
|
||||
'title' => $this->l('Key'),
|
||||
'filter_key' => 'a!profile_key',
|
||||
'type' => 'text',
|
||||
'width' => 140,
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->l('Is Default'),
|
||||
'active' => 'status',
|
||||
'filter_key' => $alias.'!active',
|
||||
'align' => 'text-center',
|
||||
'type' => 'bool',
|
||||
'class' => 'fixed-width-sm',
|
||||
'orderby' => false
|
||||
),
|
||||
'active_mobile' => array(
|
||||
'title' => $this->l('Is Mobile'),
|
||||
'active' => 'active_mobile',
|
||||
'filter_key' => $alias.'!active_mobile',
|
||||
'align' => 'text-center',
|
||||
'type' => 'bool',
|
||||
'class' => 'fixed-width-sm',
|
||||
'orderby' => false
|
||||
),
|
||||
'active_tablet' => array(
|
||||
'title' => $this->l('Is Tablet'),
|
||||
'active' => 'active_tablet',
|
||||
'filter_key' => $alias.'!active_tablet',
|
||||
'align' => 'text-center',
|
||||
'type' => 'bool',
|
||||
'class' => 'fixed-width-sm',
|
||||
'orderby' => false
|
||||
)
|
||||
);
|
||||
|
||||
$this->bulk_actions = array(
|
||||
'delete' => array(
|
||||
'text' => $this->l('Delete selected'),
|
||||
'confirm' => $this->l('Delete selected items?'),
|
||||
'icon' => 'icon-trash'
|
||||
),
|
||||
'insertLang' => array(
|
||||
'text' => $this->l('Auto Input Data for New Lang'),
|
||||
'confirm' => $this->l('Auto insert data for new language?'),
|
||||
'icon' => 'icon-edit'
|
||||
)
|
||||
);
|
||||
|
||||
//nghiatd - add theme mobile and table
|
||||
$correct_mobile = Db::getInstance()->executeS('SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = "'._DB_NAME_.'" AND TABLE_NAME="'._DB_PREFIX_.'appagebuilder_profiles_shop" AND column_name="active_mobile"');
|
||||
if (count($correct_mobile) < 1) {
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'appagebuilder_profiles_shop` ADD `active_mobile` int(11) NOT NULL');
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'appagebuilder_profiles_shop` ADD `active_tablet` int(11) NOT NULL');
|
||||
}
|
||||
|
||||
|
||||
$this->_where = ' AND sa.id_shop='.(int)$this->context->shop->id;
|
||||
$this->theme_name = apPageHelper::getThemeName();
|
||||
|
||||
$this->profile_css_folder = apPageHelper::getConfigDir('_PS_THEME_DIR_').apPageHelper::getCssDir().'profiles/';
|
||||
$this->profile_js_folder = apPageHelper::getConfigDir('_PS_THEME_DIR_').apPageHelper::getJsDir().'profiles/';
|
||||
|
||||
if (!is_dir($this->profile_css_folder)) {
|
||||
mkdir($this->profile_css_folder, 0755, true);
|
||||
}
|
||||
if (!is_dir($this->profile_js_folder)) {
|
||||
mkdir($this->profile_js_folder, 0755, true);
|
||||
}
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
parent::initToolbar();
|
||||
|
||||
# SAVE AND STAY
|
||||
if ($this->display == 'add' || $this->display == 'edit') {
|
||||
$this->context->controller->addJs(apPageHelper::getJsAdminDir().'admin/function.js');
|
||||
|
||||
$this->page_header_toolbar_btn['SaveAndStay'] = array(
|
||||
'href' => 'javascript:void(0);',
|
||||
'desc' => $this->l('Save and stay'),
|
||||
'js' => 'TopSaveAndStay()',
|
||||
'icon' => 'process-icon-save',
|
||||
);
|
||||
Media::addJsDef(array('TopSaveAndStay_Name' => 'submitAdd'.$this->table.'AndStay'));
|
||||
|
||||
$this->page_header_toolbar_btn['Save'] = array(
|
||||
'href' => 'javascript:void(0);',
|
||||
'desc' => $this->l('Save'),
|
||||
'js' => 'TopSave()',
|
||||
'icon' => 'process-icon-save',
|
||||
);
|
||||
Media::addJsDef(array('TopSave_Name' => 'submitAdd'.$this->table));
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia($isNewTheme = false)
|
||||
{
|
||||
parent::setMedia($isNewTheme);
|
||||
$this->addJqueryPlugin('tagify');
|
||||
}
|
||||
|
||||
public function processDelete()
|
||||
{
|
||||
$object = $this->loadObject();
|
||||
$object->loadDataShop();
|
||||
|
||||
if ($object && !$object->active) {
|
||||
$object = parent::processDelete();
|
||||
if ($object->profile_key) {
|
||||
Tools::deleteFile($this->profile_css_folder.$object->profile_key.'.css');
|
||||
Tools::deleteFile($this->profile_js_folder.$object->profile_key.'.js');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Can not delete Default Profile.');
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function processBulkDelete()
|
||||
{
|
||||
$arr = $this->boxes;
|
||||
if (!$arr) {
|
||||
return;
|
||||
}
|
||||
foreach ($arr as $id) {
|
||||
$object = new $this->className($id);
|
||||
$object->loadDataShop();
|
||||
if ($object && !$object->active) {
|
||||
$object->delete();
|
||||
if ($object->profile_key) {
|
||||
Tools::deleteFile($this->profile_css_folder.$object->profile_key.'.css');
|
||||
Tools::deleteFile($this->profile_js_folder.$object->profile_key.'.js');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Can not delete Default Profile.');
|
||||
}
|
||||
}
|
||||
if (empty($this->errors)) {
|
||||
$this->confirmations[] = $this->_conf[1];
|
||||
}
|
||||
}
|
||||
|
||||
public function renderView()
|
||||
{
|
||||
//echo 'here';die;
|
||||
$object = $this->loadObject();
|
||||
if ($object->page == 'product_detail') {
|
||||
$this->redirect_after = Context::getContext()->link->getAdminLink('AdminApPageBuilderProductDetail');
|
||||
} else {
|
||||
$this->redirect_after = Context::getContext()->link->getAdminLink('AdminApPageBuilderHome');
|
||||
}
|
||||
$this->redirect_after .= '&id_appagebuilder_profiles='.$object->id;
|
||||
$this->redirect();
|
||||
}
|
||||
|
||||
public function displayViewLink($token = null, $id = null, $name = null)
|
||||
{
|
||||
// validate module
|
||||
unset($name);
|
||||
$token = Context::getContext()->link->getAdminLink('AdminApPageBuilderHome');
|
||||
$href = $token . '&id_appagebuilder_profiles='.$id;
|
||||
$html = '<a href="'.$href.'" class="btn btn-default" title="View"><i class="icon-search-plus"></i> View</a>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function processBulkinsertLang()
|
||||
{
|
||||
// Remove resouce and update table profiles
|
||||
$arr = $this->boxes;
|
||||
if (!$arr) {
|
||||
// validate module
|
||||
$arr[] = Tools::getValue('id');
|
||||
}
|
||||
|
||||
if (!$arr) {
|
||||
return;
|
||||
}
|
||||
foreach ($arr as $item) {
|
||||
if ($item) {
|
||||
//has profile id
|
||||
$pfile = new ApPageBuilderProfilesModel($item);
|
||||
$id_positions = array($pfile->header, $pfile->content, $pfile->footer, $pfile->product);
|
||||
$list_position = $pfile->getPositionsForProfile($id_positions);
|
||||
$list_pos_id = array();
|
||||
foreach ($list_position as $v) {
|
||||
// validate module
|
||||
$list_pos_id[] = $v['id_appagebuilder_positions'];
|
||||
}
|
||||
$s_model = new ApPageBuilderModel();
|
||||
$list_short_c = $s_model->getAllItemsByPositionId($list_pos_id);
|
||||
$context = Context::getContext();
|
||||
$id_lang = (int)$context->language->id;
|
||||
foreach ($list_short_c as $shor_code) {
|
||||
$s_model = new ApPageBuilderModel($shor_code['id']);
|
||||
if ($s_model->params) {
|
||||
foreach ($s_model->params as $key => $value) {
|
||||
if ($key != $id_lang) {
|
||||
// validate module
|
||||
$s_model->params[$key] = $s_model->params[$id_lang];
|
||||
}
|
||||
// validate module
|
||||
unset($value);
|
||||
}
|
||||
}
|
||||
$s_model->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function processStatus()
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject())) {
|
||||
if ($object->toggleStatus()) {
|
||||
$matches = array();
|
||||
if (preg_match('/[\?|&]controller=([^&]*)/', (string)$_SERVER['HTTP_REFERER'], $matches) !== false && Tools::strtolower($matches[1]) != Tools::strtolower(preg_replace('/controller/i', '', get_class($this)))) {
|
||||
$this->redirect_after = preg_replace('/[\?|&]conf=([^&]*)/i', '', (string)$_SERVER['HTTP_REFERER']);
|
||||
} else {
|
||||
$this->redirect_after = self::$currentIndex.'&token='.$this->token;
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You can not disable default profile, Please select other profile as default');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating the status for an object.')
|
||||
.'<b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
parent::postProcess();
|
||||
if (count($this->errors) > 0) {
|
||||
return;
|
||||
}
|
||||
if (Tools::getIsset('active_mobileappagebuilder_profiles') || Tools::getIsset('active_tabletappagebuilder_profiles')) {
|
||||
if (Validate::isLoadedObject($object = $this->loadObject())) {
|
||||
$result = Tools::getIsset('active_mobileappagebuilder_profiles')?$object->toggleStatusMT('active_mobile'):$object->toggleStatusMT('active_tablet');
|
||||
if ($result) {
|
||||
// $this->mesage[] = Tools::displayError('You should enebale mobile theme in theme config');
|
||||
|
||||
$matches = array();
|
||||
if (preg_match('/[\?|&]controller=([^&]*)/', (string)$_SERVER['HTTP_REFERER'], $matches) !== false && Tools::strtolower($matches[1]) != Tools::strtolower(preg_replace('/controller/i', '', get_class($this)))) {
|
||||
$this->redirect_after = preg_replace('/[\?|&]conf=([^&]*)/i', '', (string)$_SERVER['HTTP_REFERER']);
|
||||
} else {
|
||||
$this->redirect_after = self::$currentIndex.'&token='.$this->token.'&mobiletheme';
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You can not disable default profile, Please select other profile as default');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating the status for an object.')
|
||||
.'<b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
}
|
||||
if (Tools::getIsset('duplicateappagebuilder_profiles')) {
|
||||
// $context = Context::getContext();
|
||||
// $id_shop = $context->shop->id;
|
||||
$id = Tools::getValue('id_appagebuilder_profiles');
|
||||
$model = new ApPageBuilderProfilesModel($id);
|
||||
|
||||
if ($model) {
|
||||
$old_key = $model->profile_key;
|
||||
$model->profile_key = $profile_key = 'profile'.ApPageSetting::getRandomNumber();
|
||||
$model->id = null;
|
||||
$model->name = $this->l('Duplicate of ') . $model->name;
|
||||
$model->active = '';
|
||||
$model->friendly_url = array();
|
||||
$duplicate_object = $model->save();
|
||||
|
||||
if ($duplicate_object) {
|
||||
//duplicate shortCode
|
||||
$id_new = $model->id;
|
||||
ApPageSetting::writeFile($this->profile_js_folder, $profile_key.'.js', Tools::file_get_contents($this->profile_js_folder.$old_key.'.js'));
|
||||
ApPageSetting::writeFile($this->profile_css_folder, $profile_key.'.css', Tools::file_get_contents($this->profile_css_folder.$old_key.'.css'));
|
||||
AdminApPageBuilderShortcodesController::duplicateData($id, $id_new);
|
||||
$this->redirect_after = self::$currentIndex.'&token='.$this->token;
|
||||
$this->redirect();
|
||||
} else {
|
||||
Tools::displayError('Can not create new profile');
|
||||
}
|
||||
} else {
|
||||
Tools::displayError('Profile is not exist to duplicate');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$this->initToolbar();
|
||||
$this->addRowAction('view');
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('duplicate');
|
||||
$this->addRowAction('delete');
|
||||
$this->context->controller->addCss(apPageHelper::getCssAdminDir().'admin/form.css');
|
||||
$tpl_name = 'list.tpl';
|
||||
$path = '';
|
||||
if (file_exists($this->theme_dir.'modules/'.$this->module->name.'/views/templates/admin/'.$tpl_name)) {
|
||||
$path = $this->theme_dir.'modules/'.$this->module->name.'/views/templates/admin/'.$tpl_name;
|
||||
} elseif (file_exists($this->getTemplatePath().$this->override_folder.$tpl_name)) {
|
||||
$path = $this->getTemplatePath().$this->override_folder.$tpl_name;
|
||||
}
|
||||
$model = new ApPageBuilderProfilesModel();
|
||||
$list_profiles = $model->getAllProfileByShop();
|
||||
// Build url for back from live edit page, it is stored in cookie and read in fontContent function below
|
||||
$controller = 'AdminApPageBuilderHome';
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
$url_edit_profile_token = Tools::getAdminTokenLite($controller);
|
||||
$params = array('token' => $url_edit_profile_token);
|
||||
$url_edit_profile = dirname($_SERVER['PHP_SELF']).'/'.Dispatcher::getInstance()->createUrl($controller, $id_lang, $params, false);
|
||||
$live_edit_params = array(
|
||||
'ap_live_edit' => true,
|
||||
'ad' => basename(_PS_ADMIN_DIR_),
|
||||
'liveToken' => Tools::getAdminTokenLite('AdminModulesPositions'),
|
||||
'id_employee' => (int)Context::getContext()->employee->id,
|
||||
'id_shop' => (int)Context::getContext()->shop->id
|
||||
);
|
||||
$url_live_edit = $this->getLiveEditUrl($live_edit_params);
|
||||
$lang = '';
|
||||
if (Configuration::get('PS_REWRITING_SETTINGS') && count(Language::getLanguages(true)) > 1) {
|
||||
$lang = Language::getIsoById($this->context->employee->id_lang).'/';
|
||||
}
|
||||
$url_preview = $this->context->shop->getBaseUrl().(Configuration::get('PS_REWRITING_SETTINGS') ? '' : 'index.php').$lang;
|
||||
$cookie = new Cookie('url_live_back');
|
||||
$cookie->setExpire(time() + 60 * 60);
|
||||
$cookie->variable_name = $url_edit_profile;
|
||||
$cookie->write();
|
||||
// Save token for check valid
|
||||
$cookie = new Cookie('ap_token'); //make your own cookie
|
||||
$cookie->setExpire(time() + 60 * 60);
|
||||
$cookie->variable_name = $live_edit_params['liveToken'];
|
||||
$cookie->write();
|
||||
|
||||
$profile_link = $this->context->link->getAdminLink('AdminApPageBuilderProfiles').'&addappagebuilder_profiles';
|
||||
$this->context->smarty->assign(array(
|
||||
'profile_link' => $profile_link,
|
||||
'url_preview' => $url_preview,
|
||||
'list_profile' => $list_profiles,
|
||||
'use_mobile_theme' => $this->module->getConfig('USE_MOBILE_THEME'),
|
||||
'url_live_edit' => $url_live_edit,
|
||||
'url_profile_detail' => $this->context->link->getAdminLink('AdminApPageBuilderProfiles'),
|
||||
'url_edit_profile_token' => $url_edit_profile_token,
|
||||
'url_edit_profile' => $url_edit_profile));
|
||||
$content = $this->context->smarty->fetch($path);
|
||||
$path_guide = $this->getTemplatePath().'guide.tpl';
|
||||
$guide_box = ApPageSetting::buildGuide($this->context, $path_guide, 0);
|
||||
return $guide_box.parent::renderList().$content;
|
||||
//return parent::renderList();
|
||||
}
|
||||
|
||||
public function getLiveEditUrl($live_edit_params)
|
||||
{
|
||||
$lang = '';
|
||||
$admin_dir = dirname($_SERVER['PHP_SELF']);
|
||||
$admin_dir = Tools::substr($admin_dir, strrpos($admin_dir, '/') + 1);
|
||||
$dir = str_replace($admin_dir, '', dirname($_SERVER['SCRIPT_NAME']));
|
||||
if (Configuration::get('PS_REWRITING_SETTINGS') && count(Language::getLanguages(true)) > 1) {
|
||||
$lang = Language::getIsoById(Context::getContext()->employee->id_lang).'/';
|
||||
}
|
||||
$url = Tools::getCurrentUrlProtocolPrefix().Tools::getHttpHost().$dir.$lang.
|
||||
Dispatcher::getInstance()->createUrl('index', (int)Context::getContext()->language->id, $live_edit_params);
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
$this->initToolbar();
|
||||
$this->context->controller->addJqueryUI('ui.sortable');
|
||||
$groups = Group::getGroups($this->default_form_language, true);
|
||||
// UNSET GROUP_BOX
|
||||
if ($this->object->id == '') {
|
||||
$model = new ApPageBuilderProfilesModel();
|
||||
$list_profiles = $model->getAllProfileByShop();
|
||||
foreach ($list_profiles as $profile) {
|
||||
$group_boxs = $profile['group_box'];
|
||||
$aray_group_box = explode(',', $group_boxs);
|
||||
foreach ($aray_group_box as $group_box) {
|
||||
if ($group_box!=1&&$group_box!=2&&$group_box!=3) {
|
||||
while ($group = current($groups)) {
|
||||
if ($group['id_group'] == $group_box) {
|
||||
unset($groups[key($groups)]);
|
||||
}
|
||||
next($groups);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Ap Profile Manage'),
|
||||
'icon' => 'icon-folder-close'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Name'),
|
||||
'name' => 'name',
|
||||
'required' => true,
|
||||
'hint' => $this->l('Invalid characters:'),' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Friendly URL'),
|
||||
'name' => 'friendly_url',
|
||||
'lang' => true,
|
||||
'hint' => $this->l('Invalid characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Meta title'),
|
||||
'name' => 'meta_title',
|
||||
'id' => 'name', // for copyMeta2friendlyURL compatibility
|
||||
'lang' => true,
|
||||
// 'required' => true,
|
||||
'class' => 'copyMeta2friendlyURL',
|
||||
'hint' => $this->l('Invalid characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Meta description'),
|
||||
'name' => 'meta_description',
|
||||
'lang' => true,
|
||||
'cols' => 40,
|
||||
'rows' => 10,
|
||||
'hint' => $this->l('Invalid characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'tags',
|
||||
'label' => $this->l('Meta keywords'),
|
||||
'name' => 'meta_keywords',
|
||||
'lang' => true,
|
||||
'hint' => array(
|
||||
$this->l('Invalid characters:').' <>;=#{}',
|
||||
$this->l('To add "tags" click in the field, write something, and then press "Enter."')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Profile Key'),
|
||||
'name' => 'profile_key',
|
||||
'readonly' => 'readonly',
|
||||
'desc' => $this->l('Use it to save as file name of css and js of profile'),
|
||||
'hint' => $this->l('Invalid characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'group',
|
||||
'label' => $this->l('Apply default profile for these groups'),
|
||||
'name' => 'groupBox',
|
||||
'values' => $groups,
|
||||
'col' => '6',
|
||||
'hint' => $this->l('Select the groups that you would like to apply this profile is default.')
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'dump_name',
|
||||
'html_content' => '<div class="alert alert-info">'.$this->l('Fullwidth Function: is only for develop')
|
||||
.'<br/>'.$this->l('To use this function, you have to download')
|
||||
.'<br/><a href="http://demothemes.info/prestashop/appagebuilder/header.tpl.zip" title="'.$this->l('Header file').'">'
|
||||
.'<b>header.tpl</b></a>'
|
||||
.'<br/><a href="http://demothemes.info/prestashop/appagebuilder/footer.tpl.zip" title="'.$this->l('Footer file').'">'
|
||||
.'<b>footer.tpl</b></a><br/>'
|
||||
.$this->l('file and compare or override in themes folder').'</div>'
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'fullwidth_index_hook',
|
||||
'label' => $this->l('Fullwidth Homepage'),
|
||||
'class' => 'checkbox-group',
|
||||
'desc' => $this->l('The setting full-width for above HOOKS, apply for Home page'),
|
||||
'values' => array(
|
||||
'query' => self::getCheckboxIndexHook(),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'fullwidth_other_hook',
|
||||
'label' => $this->l('Fullwidth other Pages'),
|
||||
'class' => 'checkbox-group',
|
||||
'desc' => $this->l('The setting full-width for above HOOKS, apply for all OTHER pages ( not Home page )'),
|
||||
'values' => array(
|
||||
'query' => self::getCheckboxOtherHook(),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'disable_cache_hook',
|
||||
'label' => $this->l('Disable cache Hooks'),
|
||||
'class' => 'checkbox-group',
|
||||
'desc' => $this->l('Some modules always update data, disable cache for those modules show correct info.'),
|
||||
'values' => array(
|
||||
'query' => self::getCheckboxCacheHook(),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
//'label' => $this->l('Profile For Page'),
|
||||
'name' => 'page',
|
||||
'class' => 'hide',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 'index',
|
||||
'name' => $this->l('Index'),
|
||||
),
|
||||
array(
|
||||
'id' => 'product_detail',
|
||||
'name' => $this->l('Product Detail'),
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
)
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and Stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save'
|
||||
)
|
||||
)
|
||||
);
|
||||
$is_edit = Tools::getValue('id_appagebuilder_profiles');
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Custom Css'),
|
||||
'name' => 'css',
|
||||
'desc' => sprintf($this->l('Please set write Permission for folder %s'), $this->profile_css_folder),
|
||||
);
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Custom Js'),
|
||||
'name' => 'js',
|
||||
'desc' => sprintf($this->l('Please set write Permission for folder %s'), $this->profile_js_folder),
|
||||
);
|
||||
// Display link view if it existed
|
||||
if ($is_edit) {
|
||||
$profile_link = $this->context->link->getAdminLink('AdminApPageBuilderHome').'&id_appagebuilder_profiles='.$is_edit;
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'html',
|
||||
'name' => 'default_html',
|
||||
'name' => 'dess',
|
||||
'html_content' => '<a class="btn btn-info" href="'.$profile_link.'">
|
||||
<i class="icon icon-table"></i> '.$this->l('View and edit use mode Layout design').' >></a>'
|
||||
);
|
||||
}
|
||||
|
||||
$default_index_hook = $this->getDefaultIndexHook();
|
||||
$default_other_hook = $this->getDefaultOtherHook();
|
||||
$default_disable_cache_hook = $this->getDefaultDisableCacheHook();
|
||||
foreach ($default_index_hook as $key => $value) {
|
||||
$this->fields_value['fullwidth_index_hook_'.$key] = $value;
|
||||
}
|
||||
foreach ($default_other_hook as $key => $value) {
|
||||
$this->fields_value['fullwidth_other_hook_'.$key] = $value;
|
||||
}
|
||||
foreach ($default_disable_cache_hook as $key => $value) {
|
||||
$this->fields_value['disable_cache_hook_'.$key] = $value;
|
||||
}
|
||||
foreach ($groups as $group) {
|
||||
$this->fields_value['groupBox_'.$group['id_group']] = Tools::getValue('groupBox_'.$group['id_group'], in_array($group['id_group'], explode(',', $this->object->group_box)));
|
||||
}
|
||||
|
||||
$path_guide = $this->getTemplatePath().'guide.tpl';
|
||||
$guide_box = ApPageSetting::buildGuide($this->context, $path_guide, 2);
|
||||
return $guide_box.parent::renderForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read file css + js to form when add/edit
|
||||
*/
|
||||
public function getFieldsValue($obj)
|
||||
{
|
||||
$file_value = parent::getFieldsValue($obj);
|
||||
if ($obj->id && $obj->profile_key) {
|
||||
$file_value['css'] = Tools::file_get_contents($this->profile_css_folder.$obj->profile_key.'.css');
|
||||
$file_value['js'] = Tools::file_get_contents($this->profile_js_folder.$obj->profile_key.'.js');
|
||||
} else {
|
||||
$file_value['profile_key'] = 'profile'.ApPageSetting::getRandomNumber();
|
||||
}
|
||||
return $file_value;
|
||||
}
|
||||
|
||||
public function processAdd()
|
||||
{
|
||||
parent::validateRules();
|
||||
if (count($this->errors)) {
|
||||
return false;
|
||||
}
|
||||
if ($this->object = parent::processAdd()) {
|
||||
$this->saveCustomJsAndCss($this->object->profile_key, '');
|
||||
}
|
||||
$this->processParams();
|
||||
if (!Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
$this->redirect_after = Context::getContext()->link->getAdminLink('AdminApPageBuilderHome');
|
||||
$this->redirect_after .= '&id_appagebuilder_profiles='.($this->object->id);
|
||||
$this->redirect();
|
||||
}
|
||||
}
|
||||
|
||||
public function processUpdate()
|
||||
{
|
||||
parent::validateRules();
|
||||
if (count($this->errors)) {
|
||||
return false;
|
||||
}
|
||||
if ($this->object = parent::processUpdate()) {
|
||||
$this->saveCustomJsAndCss($this->object->profile_key, $this->object->profile_key);
|
||||
}
|
||||
|
||||
$this->processParams();
|
||||
if (!Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
$this->redirect_after = Context::getContext()->link->getAdminLink('AdminApPageBuilderHome');
|
||||
$this->redirect_after .= '&id_appagebuilder_profiles='.($this->object->id);
|
||||
$this->redirect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fullwidth hook, save to params
|
||||
*/
|
||||
public function processParams()
|
||||
{
|
||||
$params = Tools::jsonDecode($this->object->params);
|
||||
if ($params === null) {
|
||||
$params = new stdClass();
|
||||
}
|
||||
|
||||
# get post index hook
|
||||
$index_hook = ApPageSetting::getIndexHook();
|
||||
$post_index_hooks = array();
|
||||
foreach ($index_hook as $key => $value) {
|
||||
// validate module
|
||||
$post_index_hooks[$value] = Tools::getValue('fullwidth_index_hook_'.$value) ?
|
||||
Tools::getValue('fullwidth_index_hook_'.$value) : ApPageSetting::HOOK_BOXED;
|
||||
// validate module
|
||||
unset($key);
|
||||
}
|
||||
$params->fullwidth_index_hook = $post_index_hooks;
|
||||
|
||||
# get post other hook
|
||||
$other_hook = ApPageSetting::getOtherHook();
|
||||
$post_other_hooks = array();
|
||||
foreach ($other_hook as $key => $value) {
|
||||
// validate module
|
||||
$post_other_hooks[$value] = Tools::getValue('fullwidth_other_hook_'.$value) ? Tools::getValue('fullwidth_other_hook_'.$value) : ApPageSetting::HOOK_BOXED;
|
||||
// validate module
|
||||
unset($key);
|
||||
}
|
||||
$params->fullwidth_other_hook = $post_other_hooks;
|
||||
|
||||
# get post disable hook
|
||||
$cache_hooks = ApPageSetting::getCacheHook();
|
||||
$post_disable_hooks = array();
|
||||
foreach ($cache_hooks as $key => $value) {
|
||||
// validate module
|
||||
$post_disable_hooks[$value] = Tools::getValue('disable_cache_hook_'.$value) ? Tools::getValue('disable_cache_hook_'.$value) : ApPageSetting::HOOK_BOXED;
|
||||
// validate module
|
||||
unset($key);
|
||||
}
|
||||
$params->disable_cache_hook = $post_disable_hooks;
|
||||
|
||||
|
||||
# Save to params
|
||||
$this->object->params = Tools::jsonEncode($params);
|
||||
|
||||
# Save group_box
|
||||
if (Tools::getValue('groupBox')) {
|
||||
$this->object->group_box = implode(',', Tools::getValue('groupBox'));
|
||||
} else {
|
||||
$this->object->group_box = '';
|
||||
}
|
||||
|
||||
$this->object->save();
|
||||
}
|
||||
|
||||
public function saveCustomJsAndCss($key, $old_key = '')
|
||||
{
|
||||
# DELETE OLD FILE
|
||||
if ($old_key) {
|
||||
Tools::deleteFile($this->profile_css_folder.$old_key.'.css');
|
||||
Tools::deleteFile($this->profile_js_folder.$old_key.'.js');
|
||||
}
|
||||
|
||||
if (Tools::getValue('js') != '') {
|
||||
ApPageSetting::writeFile($this->profile_js_folder, $key.'.js', Tools::getValue('js'));
|
||||
}
|
||||
|
||||
if (Tools::getValue('css') != '') {
|
||||
# FIX CUSTOMER CAN NOT TYPE "\"
|
||||
$temp = Tools::getAllValues();
|
||||
$css = $temp['css'];
|
||||
ApPageSetting::writeFile($this->profile_css_folder, $key.'.css', $css);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate form : create checkbox in admin form ( add/edit profile )
|
||||
*/
|
||||
public static function getCheckboxIndexHook()
|
||||
{
|
||||
$ids = ApPageSetting::getIndexHook();
|
||||
$names = ApPageSetting::getIndexHook();
|
||||
return apPageHelper::getArrayOptions($ids, $names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate form : create checkbox in admin form ( add/edit profile )
|
||||
*/
|
||||
public static function getCheckboxOtherHook()
|
||||
{
|
||||
$ids = ApPageSetting::getOtherHook();
|
||||
$names = ApPageSetting::getOtherHook();
|
||||
return apPageHelper::getArrayOptions($ids, $names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate form : create checkbox in admin form ( add/edit profile )
|
||||
*/
|
||||
public static function getCheckboxCacheHook()
|
||||
{
|
||||
$ids = ApPageSetting::getCacheHook();
|
||||
$names = ApPageSetting::getCacheHook();
|
||||
return apPageHelper::getArrayOptions($ids, $names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fullwidth hook from database or default
|
||||
*/
|
||||
public function getDefaultIndexHook()
|
||||
{
|
||||
$params = Tools::jsonDecode($this->object->params);
|
||||
return isset($params->fullwidth_index_hook) ? $params->fullwidth_index_hook : ApPageSetting::getIndexHook(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fullwidth hook from database or default
|
||||
*/
|
||||
public function getDefaultOtherHook()
|
||||
{
|
||||
$params = Tools::jsonDecode($this->object->params);
|
||||
return isset($params->fullwidth_other_hook) ? $params->fullwidth_other_hook : ApPageSetting::getOtherHook(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fullwidth hook from database or default
|
||||
*/
|
||||
public function getDefaultDisableCacheHook()
|
||||
{
|
||||
$params = Tools::jsonDecode($this->object->params);
|
||||
return isset($params->disable_cache_hook) ? $params->disable_cache_hook : ApPageSetting::getCacheHook(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* PERMISSION ACCOUNT demo@demo.com
|
||||
* OVERRIDE CORE
|
||||
*/
|
||||
public function initProcess()
|
||||
{
|
||||
parent::initProcess();
|
||||
|
||||
if (count($this->errors) <= 0) {
|
||||
if (Tools::isSubmit('duplicate'.$this->table)) {
|
||||
if ($this->id_object) {
|
||||
if (!$this->access('add')) {
|
||||
$this->errors[] = $this->trans('You do not have permission to duplicate this.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,840 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageBuilderShortcodeModel.php');
|
||||
|
||||
class AdminApPageBuilderShortcodeController extends ModuleAdminControllerCore
|
||||
{
|
||||
public $tpl_path;
|
||||
public $module_name;
|
||||
public static $shortcode_lang;
|
||||
public static $language;
|
||||
public $theme_dir;
|
||||
public static $lang_id;
|
||||
public $tpl_controller_path;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->bootstrap = true;
|
||||
$this->table = 'appagebuilder_shortcode';
|
||||
$this->identifier = 'id_appagebuilder_shortcode';
|
||||
$this->className = 'ApPageBuilderShortcodeModel';
|
||||
$this->allow_export = true;
|
||||
$this->can_import = true;
|
||||
$id_shop = apPageHelper::getIDShop();
|
||||
$this->_join = '
|
||||
INNER JOIN `'._DB_PREFIX_.'appagebuilder_shortcode_shop` ps ON (ps.`id_appagebuilder_shortcode` = a.`id_appagebuilder_shortcode` AND ps.`id_shop` = '.$id_shop.')';
|
||||
$this->_select .= ' ps.active as active, ';
|
||||
$this->lang = true;
|
||||
$this->shop = true;
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('duplicate');
|
||||
$this->addRowAction('delete');
|
||||
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
|
||||
$this->fields_list = array(
|
||||
'id_appagebuilder_shortcode' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'type' => 'text',
|
||||
'class' => 'fixed-width-sm'
|
||||
),
|
||||
'shortcode_name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
'type' => 'text',
|
||||
),
|
||||
'shortcode_key' => array(
|
||||
'title' => $this->l('Key'),
|
||||
'type' => 'text',
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->l('Status'),
|
||||
'active' => 'status',
|
||||
'type' => 'bool',
|
||||
'class' => 'fixed-width-sm'
|
||||
),
|
||||
);
|
||||
|
||||
$this->_defaultOrderBy = 'id_appagebuilder_shortcode';
|
||||
$this->module_name = 'appagebuilder';
|
||||
$this->tpl_path = _PS_ROOT_DIR_.'/modules/'.$this->module_name.'/views/templates/admin';
|
||||
self::$language = Language::getLanguages(false);
|
||||
$this->theme_dir = apPageHelper::getConfigDir('_PS_THEME_DIR_');
|
||||
$this->tpl_controller_path = _PS_ROOT_DIR_.'/modules/'.$this->module_name.'/views/templates/admin/ap_page_builder_shortcode/';
|
||||
apPageHelper::loadShortCode(apPageHelper::getConfigDir('_PS_THEME_DIR_'));
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
//DONGND:: get list shortcode to tiny mce
|
||||
if (Tools::getIsset('get_listshortcode')) {
|
||||
die($this->module->getListShortCodeForEditor());
|
||||
} else {
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
parent::initToolbar();
|
||||
|
||||
# SAVE AND STAY
|
||||
if ($this->display == 'add' || $this->display == 'edit') {
|
||||
$this->context->controller->addJs(apPageHelper::getJsAdminDir().'admin/function.js');
|
||||
|
||||
$this->page_header_toolbar_btn['SaveAndStay'] = array(
|
||||
'href' => 'javascript:void(0);',
|
||||
'desc' => $this->l('Save and stay'),
|
||||
'js' => 'TopSaveAndStay()',
|
||||
'icon' => 'process-icon-save',
|
||||
);
|
||||
Media::addJsDef(array('TopSaveAndStay_Name' => 'submitAdd'.$this->table.'AndStay'));
|
||||
|
||||
$this->page_header_toolbar_btn['Save'] = array(
|
||||
'href' => 'javascript:void(0);',
|
||||
'desc' => $this->l('Save'),
|
||||
'js' => 'TopSave()',
|
||||
'icon' => 'process-icon-save',
|
||||
);
|
||||
Media::addJsDef(array('TopSave_Name' => 'submitAdd'.$this->table));
|
||||
}
|
||||
|
||||
# SHOW LINK EXPORT ALL FOR TOOLBAR
|
||||
switch ($this->display) {
|
||||
default:
|
||||
$this->toolbar_btn['new'] = array(
|
||||
'href' => self::$currentIndex . '&add' . $this->table . '&token=' . $this->token,
|
||||
'desc' => $this->l('Add new'),
|
||||
'class' => 'btn_add_new',
|
||||
);
|
||||
if (!$this->display && $this->can_import) {
|
||||
$this->toolbar_btn['import'] = array(
|
||||
'href' => self::$currentIndex . '&import' . $this->table . '&token=' . $this->token,
|
||||
'desc' => $this->trans('Import', array(), 'Admin.Actions'),
|
||||
'class' => 'btn_xml_import',
|
||||
);
|
||||
}
|
||||
if ($this->allow_export) {
|
||||
$this->toolbar_btn['export'] = array(
|
||||
'href' => self::$currentIndex . '&export' . $this->table . '&token=' . $this->token,
|
||||
'desc' => $this->l('Export'),
|
||||
'class' => 'btn_xml_export',
|
||||
);
|
||||
Media::addJsDef(array('record_id' => 'appagebuilder_shortcodeBox[]'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* OVERRIDE CORE
|
||||
*/
|
||||
public function processExport($text_delimiter = '"')
|
||||
{
|
||||
// $multilang = false;
|
||||
if (isset($this->className) && $this->className) {
|
||||
$definition = ObjectModel::getDefinition($this->className);
|
||||
// $multilang = $definition['multilang'];
|
||||
}
|
||||
|
||||
$record_id = Tools::getValue('record_id');
|
||||
$file_name = 'ap_shortcode_all.xml';
|
||||
# VALIDATE MODULE
|
||||
unset($text_delimiter);
|
||||
|
||||
if ($record_id) {
|
||||
$record_id_str = implode(", ", $record_id);
|
||||
$this->_where = ' AND a.'.$this->identifier.' IN ( '.pSQL($record_id_str).' )';
|
||||
$file_name = 'ap_shortcode.xml';
|
||||
}
|
||||
|
||||
$this->getList($this->context->language->id, null, null, 0, false);
|
||||
if (!count($this->_list)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = $this->_list;
|
||||
|
||||
$data_all = array();
|
||||
$this->_join_ori = $this->_join;
|
||||
$this->_select .= ' apl.id_appagebuilder, apl.params,';
|
||||
foreach (Language::getLanguages() as $key => $lang) {
|
||||
$this->_join = $this->_join_ori. '
|
||||
LEFT JOIN `'._DB_PREFIX_.'appagebuilder` ap ON (ap.id_appagebuilder_shortcode = a.id_appagebuilder_shortcode)
|
||||
LEFT JOIN `'._DB_PREFIX_.'appagebuilder_lang` apl ON (ap.id_appagebuilder = apl.id_appagebuilder AND apl.id_lang = '.$lang['id_lang'].' )
|
||||
';
|
||||
$this->getList($lang['id_lang'], null, null, 0, false);
|
||||
$data_all[$lang['iso_code']] = $this->_list;
|
||||
}
|
||||
|
||||
$this->file_content = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||
$this->file_content .= '<data>' . "\n";
|
||||
$this->file_content .= '<shortcode>' . "\n";
|
||||
$definition['fields']['params'] = array('lang' => '1');
|
||||
if ($data) {
|
||||
foreach ($data as $key_data => $product_detail) {
|
||||
$this->file_content .= '<record>' . "\n";
|
||||
// add more field
|
||||
$product_detail['params'] = '';
|
||||
foreach ($product_detail as $key => $value) {
|
||||
if (isset($definition['fields'][$key]['lang']) && $definition['fields'][$key]['lang']) {
|
||||
# MULTI LANG
|
||||
$this->file_content .= ' <'.$key.'>'. "\n";
|
||||
foreach (Language::getLanguages() as $key_lang => $lang) {
|
||||
unset($key_lang);
|
||||
$this->file_content .= ' <'.$lang['iso_code'].'>';
|
||||
$this->file_content .= '<![CDATA['.$data_all[$lang['iso_code']][$key_data][$key].']]>';
|
||||
$this->file_content .= '</'.$lang['iso_code'].'>' . "\n";
|
||||
}
|
||||
$this->file_content .= ' </'.$key.'>' . "\n";
|
||||
} else {
|
||||
# SINGLE LANG
|
||||
$this->file_content .= ' <'.$key.'>';
|
||||
$this->file_content .= '<![CDATA['.$value.']]>';
|
||||
$this->file_content .= '</'.$key.'>' . "\n";
|
||||
}
|
||||
}
|
||||
$this->file_content .= '</record>' . "\n";
|
||||
}
|
||||
}
|
||||
$this->file_content .= '</shortcode>' . "\n";
|
||||
$this->file_content .= '</data>' . "\n";
|
||||
header('Content-type: text/xml');
|
||||
header('Content-Disposition: attachment; filename="'.$file_name.'"');
|
||||
echo $this->file_content;
|
||||
die();
|
||||
}
|
||||
|
||||
public function processImport()
|
||||
{
|
||||
$upload_file = new Uploader('importFile');
|
||||
$upload_file->setAcceptTypes(array('xml'));
|
||||
$file = $upload_file->process();
|
||||
$file = $file[0];
|
||||
if (!isset($file['save_path'])) {
|
||||
$this->errors[] = $this->trans('Failed to import.', array(), 'Admin.Notifications.Error');
|
||||
return;
|
||||
}
|
||||
$files_content = simplexml_load_file($file['save_path']);
|
||||
$override = Tools::getValue('override');
|
||||
|
||||
if (isset($files_content->shortcode) && $files_content->shortcode) {
|
||||
foreach ($files_content->shortcode->children() as $product_details) {
|
||||
if (!$override) {
|
||||
$obj_model = new ApPageBuilderShortcodeModel();
|
||||
$obj_model->shortcode_key = $product_details->shortcode_key->__toString();
|
||||
$obj_model->active = $product_details->active->__toString();
|
||||
$name = array();
|
||||
foreach (Language::getLanguages() as $key_lang => $lang) {
|
||||
unset($key_lang);
|
||||
$name[$lang['id_lang']] = $product_details->shortcode_name->{$lang['iso_code']}->__toString();
|
||||
}
|
||||
$obj_model->shortcode_name = $name;
|
||||
$obj_model->save();
|
||||
|
||||
|
||||
$ap_model = new ApPageBuilderModel();
|
||||
$ap_model->hook_name = 'apshortcode';
|
||||
$ap_model->id_appagebuilder_shortcode = $obj_model->id;
|
||||
foreach (Language::getLanguages() as $lang) {
|
||||
$ap_model->params[$lang['id_lang']] = $product_details->params->{$lang['iso_code']}->__toString();
|
||||
}
|
||||
$ap_model->save();
|
||||
}
|
||||
}
|
||||
$this->confirmations[] = $this->trans('Successful importing.', array(), 'Admin.Notifications.Success');
|
||||
} else {
|
||||
$this->errors[] = $this->trans('Wrong file to import.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
return $this->importForm() . parent::renderList();
|
||||
}
|
||||
|
||||
public function importForm()
|
||||
{
|
||||
$helper = new HelperForm();
|
||||
$helper->submit_action = 'import' . $this->table;
|
||||
$inputs = array(
|
||||
array(
|
||||
'type' => 'file',
|
||||
'name' => 'importFile',
|
||||
'label' => $this->l('File'),
|
||||
'desc' => $this->l('Only accept xml file'),
|
||||
),
|
||||
);
|
||||
$fields_form = array(
|
||||
'form' => array(
|
||||
'action' => Context::getContext()->link->getAdminLink('AdminApPageBuilderShortcodeController'),
|
||||
'input' => $inputs,
|
||||
'submit' => array('title' => $this->l('Import'), 'class' => 'button btn btn-success'),
|
||||
'tinymce' => false,
|
||||
),
|
||||
);
|
||||
$helper->fields_value = isset($this->fields_value) ? $this->fields_value : array();
|
||||
$helper->identifier = $this->identifier;
|
||||
$helper->currentIndex = self::$currentIndex;
|
||||
$helper->token = $this->token;
|
||||
$helper->table = 'xml_import';
|
||||
$html = $helper->generateForm(array($fields_form));
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
|
||||
$txt_legend = '';
|
||||
if (Validate::isLoadedObject($this->object)) {
|
||||
$this->display = 'edit';
|
||||
$txt_legend = $this->l('Edit Shortcode');
|
||||
} else {
|
||||
$this->display = 'add';
|
||||
$txt_legend = $this->l('Add New Shortcode');
|
||||
}
|
||||
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $txt_legend,
|
||||
'icon' => 'icon-cogs',
|
||||
),
|
||||
'input' => array(
|
||||
// array(
|
||||
// 'type' => 'hidden',
|
||||
// 'name' => 'id_appagebuilder_shortcode',
|
||||
// ),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'id_appagebuilder',
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'shortcode_content',
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'stay_page',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'lang' => true,
|
||||
'required' => true,
|
||||
'label' => $this->l('Shortcode Name'),
|
||||
'name' => 'shortcode_name',
|
||||
),
|
||||
array(
|
||||
'type' => 'textbutton',
|
||||
'label' => $this->l('Shortcode Key'),
|
||||
'name' => 'shortcode_key',
|
||||
'readonly' => 'readonly',
|
||||
'lang' => false,
|
||||
'button' => array(
|
||||
'label' => $this->l('Copy To Clipboard'),
|
||||
'class' => 'bt_copy_clipboard shortcode_key',
|
||||
'attributes' => array(
|
||||
// 'onclick' => 'alert(\'something done\');'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'is_bool' => true, //retro compat 1.5
|
||||
'label' => $this->l('Active'),
|
||||
'name' => 'active',
|
||||
'default_value' => 1,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'active_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled'),
|
||||
),
|
||||
array(
|
||||
'id' => 'active_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled'),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
'class' => 'shortcode_save_btn btn btn-default pull-right',
|
||||
),
|
||||
'buttons' => array(
|
||||
'save_and_stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'shortcode_save_stay_btn btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save-and-stay'
|
||||
)
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
if (Validate::isLoadedObject($this->object)) {
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'textbutton',
|
||||
'label' => $this->l('Embed Hook'),
|
||||
'name' => 'shortcode_embedded_hook',
|
||||
'readonly' => 'readonly',
|
||||
'desc' => $this->l('Insert embed hook in any tpl file'),
|
||||
'lang' => false,
|
||||
'button' => array(
|
||||
'label' => $this->l('Copy To Clipboard'),
|
||||
'class' => 'bt_copy_clipboard shortcode_embedded_hook',
|
||||
'attributes' => array(
|
||||
// 'onclick' => 'alert(\'something done\');'
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'textbutton',
|
||||
'label' => $this->l('Embed Code'),
|
||||
'name' => 'shortcode_embedded_code',
|
||||
'readonly' => 'readonly',
|
||||
'desc' => $this->l('Insert embed code in any content with editor'),
|
||||
'lang' => false,
|
||||
'button' => array(
|
||||
'label' => $this->l('Copy To Clipboard'),
|
||||
'class' => 'bt_copy_clipboard shortcode_embedded_code',
|
||||
'attributes' => array(
|
||||
// 'onclick' => 'alert(\'something done\');'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->context->controller->addJqueryUI('ui.sortable');
|
||||
$this->context->controller->addJqueryUI('ui.draggable');
|
||||
$this->context->controller->addCss(apPageHelper::getCssAdminDir().'admin/form.css');
|
||||
$this->context->controller->addCss(apPageHelper::getCssAdminDir().'animate.css');
|
||||
$this->context->controller->addJs(apPageHelper::getJsAdminDir().'admin/form.js');
|
||||
$this->context->controller->addJs(apPageHelper::getJsAdminDir().'admin/home.js?t=1');
|
||||
$this->context->controller->addJs(apPageHelper::getJsAdminDir().'admin/isotope.pkgd.min.js');
|
||||
$this->context->controller->addJS(_PS_JS_DIR_.'tiny_mce/tiny_mce.js');
|
||||
|
||||
$this->context->controller->addJs(apPageHelper::getJsAdminDir().'admin/jquery-validation-1.9.0/jquery.validate.js');
|
||||
$this->context->controller->addCss(apPageHelper::getJsAdminDir().'admin/jquery-validation-1.9.0/screen.css');
|
||||
|
||||
// $version = Configuration::get('PS_INSTALL_VERSION');
|
||||
// $tiny_path = ($version >= '1.6.0.13') ? 'admin/' : '';
|
||||
// $tiny_path .= 'tinymce.inc.js';
|
||||
|
||||
// Pham_Khanh_Dong fix loading TINY_MCE library for all Prestashop_Versions
|
||||
$tiny_path = 'tinymce.inc.js';
|
||||
if (version_compare(_PS_VERSION_, '1.6.0.13', '>')) {
|
||||
$tiny_path = 'admin/tinymce.inc.js';
|
||||
}
|
||||
|
||||
$this->context->controller->addJS(_PS_JS_DIR_.$tiny_path);
|
||||
$bo_theme = ((Validate::isLoadedObject($this->context->employee) && $this->context->employee->bo_theme) ? $this->context->employee->bo_theme : 'default');
|
||||
if (!file_exists(_PS_BO_ALL_THEMES_DIR_.$bo_theme.DIRECTORY_SEPARATOR.'template')) {
|
||||
$bo_theme = 'default';
|
||||
}
|
||||
$this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.fileupload.js');
|
||||
$this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.fileupload-process.js');
|
||||
$this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.fileupload-validate.js');
|
||||
$this->context->controller->addJs(_PS_JS_DIR_.'vendor/spin.js');
|
||||
$this->context->controller->addJs(_PS_JS_DIR_.'vendor/ladda.js');
|
||||
|
||||
//load javascript for menu tree
|
||||
$tree = new HelperTreeCategories('123', null);
|
||||
$tree->render();
|
||||
|
||||
// if (isset($result_profile) && $result_profile) {
|
||||
|
||||
$languages = array();
|
||||
foreach (Language::getLanguages(false) as $lang) {
|
||||
$languages[$lang['iso_code']] = $lang['id_lang'];
|
||||
}
|
||||
|
||||
// get shortcode information
|
||||
$shortcode_infos = ApShortCodeBase::getShortCodeInfos();
|
||||
//include all short code default
|
||||
$shortcodes = Tools::scandir($this->tpl_path.'/ap_page_builder_shortcodes', 'tpl');
|
||||
$shortcode_form = array();
|
||||
foreach ($shortcodes as $s_from) {
|
||||
if ($s_from == 'shortcodelist.tpl') {
|
||||
continue;
|
||||
}
|
||||
$shortcode_form[] = $this->tpl_path.'/ap_page_builder_shortcodes/'.$s_from;
|
||||
};
|
||||
$tpl = $this->createTemplate('home.tpl');
|
||||
|
||||
$model = new ApPageBuilderShortcodeModel();
|
||||
|
||||
$data_shortcode_content = array();
|
||||
$positions_dum = array();
|
||||
|
||||
$data_form = '{}';
|
||||
|
||||
$id_appagebuilder = ApPageBuilderModel::getIdByIdShortCode($this->object->id);
|
||||
|
||||
if ($id_appagebuilder) {
|
||||
$positions_dum = $model->getShortCodeContent($id_appagebuilder, null);
|
||||
$temp = $positions_dum['content'];
|
||||
|
||||
foreach ($temp as $key_hook => &$row) {
|
||||
if (!is_array($row)) {
|
||||
$row = array('hook_name' => $key_hook, 'content' => '');
|
||||
}
|
||||
if ($key_hook == 'displayLeftColumn' || $key_hook == 'displayRightColumn') {
|
||||
$row['class'] = 'col-md-3';
|
||||
} else {
|
||||
$row['class'] = 'col-md-12';
|
||||
}
|
||||
}
|
||||
$data_shortcode_content = $temp;
|
||||
$data = $model->getAllItems($id_appagebuilder, null, (int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
$data_form = Tools::jsonEncode($data['dataForm']);
|
||||
}
|
||||
|
||||
$tpl->assign(array(
|
||||
'data_shortcode_content' => $data_shortcode_content,
|
||||
// 'positions' => $positions,
|
||||
// 'listPositions' => $list_positions,
|
||||
// 'dataByHook' => $data_by_hook,
|
||||
// 'exportItems' => $export_items,
|
||||
// 'currentProfile' => $result_profile,
|
||||
// 'currentPosition' => $current_position,
|
||||
// 'profilesList' => $this->getAllProfiles($result_profile['id_appagebuilder_profiles']),
|
||||
'tplPath' => $this->tpl_path,
|
||||
'ajaxShortCodeUrl' => Context::getContext()->link->getAdminLink('AdminApPageBuilderShortcodes'),
|
||||
'ajaxHomeUrl' => Context::getContext()->link->getAdminLink('AdminApPageBuilderHome'),
|
||||
'shortcodeForm' => $shortcode_form,
|
||||
'moduleDir' => _MODULE_DIR_,
|
||||
'imgModuleLink' => apPageHelper::getImgThemeUrl(),
|
||||
'shortcodeInfos' => Tools::jsonEncode($shortcode_infos),
|
||||
'languages' => Tools::jsonEncode($languages),
|
||||
'dataForm' => $data_form,
|
||||
// 'errorText' => $this->error_text,
|
||||
'imgController' => Context::getContext()->link->getAdminLink('AdminApPageBuilderImages'),
|
||||
'widthList' => ApPageSetting::returnWidthList(),
|
||||
'lang_id' => (int)$this->context->language->id,
|
||||
// 'idProfile' => '',
|
||||
// 'checkSaveMultithreading' => $check_save_multithreading,
|
||||
// 'checkSaveSubmit' => $check_save_submit,
|
||||
// 'errorSubmit' => $errorSubmit
|
||||
'listAnimation' => ApPageSetting::getAnimationsColumnGroup(),
|
||||
));
|
||||
// return $guide_box.$tpl->fetch();
|
||||
// } else {
|
||||
// $this->errors[] = $this->l('Your Profile ID is not exist!');
|
||||
// }
|
||||
|
||||
return parent::renderForm().$tpl->fetch();
|
||||
}
|
||||
|
||||
public function getFieldsValue($obj)
|
||||
{
|
||||
$file_value = parent::getFieldsValue($obj);
|
||||
|
||||
if ($file_value['shortcode_key'] == '') {
|
||||
$file_value['shortcode_key'] = 'sc'.ApPageSetting::getRandomNumber();
|
||||
} else {
|
||||
$file_value['shortcode_embedded_hook'] = "{hook h='displayApSC' sc_key=".$file_value['shortcode_key']."}";
|
||||
$file_value['shortcode_embedded_code'] = "[ApSC sc_key=".$file_value['shortcode_key']."][/ApSC]";
|
||||
}
|
||||
|
||||
return $file_value;
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (count($this->errors) > 0) {
|
||||
return;
|
||||
}
|
||||
if (Tools::isSubmit('submitAddappagebuilder_shortcode')) {
|
||||
parent::validateRules();
|
||||
|
||||
if ((int) Tools::getValue('id_appagebuilder_shortcode')) {
|
||||
$mess_id = '4';
|
||||
} else {
|
||||
$mess_id = '3';
|
||||
}
|
||||
|
||||
$shortcode_obj = new ApPageBuilderShortcodeModel((int) Tools::getValue('id_appagebuilder_shortcode'));
|
||||
$shortcode_obj->shortcode_key = Tools::getValue('shortcode_key');
|
||||
$shortcode_obj->active = Tools::getValue('active');
|
||||
|
||||
//DONGND:: fields multi lang
|
||||
$languages = Language::getLanguages();
|
||||
$name = array();
|
||||
foreach ($languages as $key => $value) {
|
||||
$name[$value['id_lang']] = Tools::getValue('shortcode_name_'.$value['id_lang']);
|
||||
}
|
||||
$shortcode_obj->shortcode_name = $name;
|
||||
|
||||
$shortcode_obj->save();
|
||||
|
||||
$shortcode_content = Tools::jsonDecode(Tools::getValue('shortcode_content'), 1);
|
||||
|
||||
$id_appagebuilder = ApPageBuilderModel::getIdByIdShortCode($shortcode_obj->id);
|
||||
if ($id_appagebuilder) {
|
||||
$obj_model = new ApPageBuilderModel($id_appagebuilder);
|
||||
} else {
|
||||
$obj_model = new ApPageBuilderModel();
|
||||
}
|
||||
|
||||
$obj_model->hook_name = 'apshortcode';
|
||||
$obj_model->id_appagebuilder_shortcode = $shortcode_obj->id;
|
||||
|
||||
if (isset($shortcode_content['groups'])) {
|
||||
foreach (self::$language as $lang) {
|
||||
$params = '';
|
||||
if (self::$shortcode_lang) {
|
||||
foreach (self::$shortcode_lang as &$s_type) {
|
||||
foreach ($s_type as $key => $value) {
|
||||
$s_type[$key] = $key.'_'.$lang['id_lang'];
|
||||
// validate module
|
||||
unset($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
$obj_model->params[$lang['id_lang']] = '';
|
||||
ApShortCodesBuilder::$lang_id = $lang['id_lang'];
|
||||
foreach ($shortcode_content['groups'] as $groups) {
|
||||
$params = $this->getParamByHook($groups, $params, '');
|
||||
}
|
||||
$obj_model->params[$lang['id_lang']] = $params;
|
||||
}
|
||||
}
|
||||
|
||||
if ($obj_model->id) {
|
||||
$obj_model->save();
|
||||
} else {
|
||||
$obj_model->add();
|
||||
}
|
||||
|
||||
if ($shortcode_obj->save()) {
|
||||
$this->module->clearShortCodeCache($shortcode_obj->shortcode_key);
|
||||
|
||||
if (Tools::getValue('stay_page')) {
|
||||
# validate module
|
||||
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$shortcode_obj->id.'&conf='.$mess_id.'&update'.$this->table.'&token='.$this->token;
|
||||
} else {
|
||||
# validate module
|
||||
$this->redirect_after = self::$currentIndex.'&conf=4&token='.$this->token;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if (Tools::getIsset('duplicateappagebuilder_shortcode')) {
|
||||
//DONGND:: duplicate
|
||||
if (Tools::getIsset('id_appagebuilder_shortcode') && (int)Tools::getValue('id_appagebuilder_shortcode')) {
|
||||
if ($shortcode_obj = new ApPageBuilderShortcodeModel((int) Tools::getValue('id_appagebuilder_shortcode'))) {
|
||||
$duplicate_object = new ApPageBuilderShortcodeModel();
|
||||
$duplicate_object->active = $shortcode_obj->active;
|
||||
|
||||
$languages = Language::getLanguages();
|
||||
$name = array();
|
||||
foreach ($languages as $key => $value) {
|
||||
$name[$value['id_lang']] = $this->l('Duplicate of').' '.$shortcode_obj->shortcode_name[$value['id_lang']];
|
||||
}
|
||||
|
||||
$duplicate_object->shortcode_name = $name;
|
||||
$duplicate_object->shortcode_key = 'sc'.ApPageSetting::getRandomNumber();
|
||||
|
||||
if ($duplicate_object->add()) {
|
||||
//duplicate shortCode
|
||||
$id_appagebuilder = ApPageBuilderModel::getIdByIdShortCode($shortcode_obj->id);
|
||||
if ($id_appagebuilder) {
|
||||
$obj_model = new ApPageBuilderModel($id_appagebuilder);
|
||||
$duplicate_obj_object = new ApPageBuilderModel();
|
||||
$duplicate_obj_object->hook_name = 'apshortcode';
|
||||
$duplicate_obj_object->id_appagebuilder_shortcode = $duplicate_object->id;
|
||||
$duplicate_obj_object->params = $obj_model->params;
|
||||
$duplicate_obj_object->add();
|
||||
|
||||
$this->redirect_after = self::$currentIndex.'&conf=3&token='.$this->token;
|
||||
} else {
|
||||
$this->redirect_after = self::$currentIndex.'&conf=3&token='.$this->token;
|
||||
}
|
||||
} else {
|
||||
Tools::displayError('Can not duplicate shortcode');
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (Tools::getIsset('statusappagebuilder_shortcode') || Tools::getIsset('deleteappagebuilder_shortcode')) {
|
||||
$shortcode_obj = new ApPageBuilderShortcodeModel((int) Tools::getValue('id_appagebuilder_shortcode'));
|
||||
$this->module->clearShortCodeCache($shortcode_obj->shortcode_key);
|
||||
}
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
private function getParamByHook($groups, $params, $hook, $action = 'save')
|
||||
{
|
||||
$groups['params']['specific_type'] = (isset($groups['params']['specific_type']) && $groups['params']['specific_type']) ? $groups['params']['specific_type'] : '';
|
||||
$groups['params']['controller_pages'] = (isset($groups['params']['controller_pages']) && $groups['params']['controller_pages']) ? $groups['params']['controller_pages'] : '';
|
||||
$groups['params']['controller_id'] = (isset($groups['params']['controller_id']) && $groups['params']['controller_id']) ? $groups['params']['controller_id'] : '';
|
||||
$params .= '[ApRow'.ApShortCodesBuilder::converParamToAttr2($groups['params'], 'ApRow', $this->theme_dir).']';
|
||||
//check exception page
|
||||
$this->saveExceptionConfig($hook, $groups['params']['specific_type'], $groups['params']['controller_pages'], $groups['params']['controller_id']);
|
||||
foreach ($groups['columns'] as $columns) {
|
||||
$columns['params']['specific_type'] = (isset($columns['params']['specific_type']) && $columns['params']['specific_type']) ? $columns['params']['specific_type'] : '';
|
||||
$columns['params']['controller_pages'] = (isset($columns['params']['controller_pages']) && $columns['params']['controller_pages']) ? $columns['params']['controller_pages'] : '';
|
||||
$columns['params']['controller_id'] = (isset($columns['params']['controller_id']) && $columns['params']['controller_id']) ? $columns['params']['controller_id'] : '';
|
||||
$this->saveExceptionConfig($hook, $columns['params']['specific_type'], $columns['params']['controller_pages'], $columns['params']['controller_id']);
|
||||
$params .= '[ApColumn'.ApShortCodesBuilder::converParamToAttr2($columns['params'], 'ApColumn', $this->theme_dir).']';
|
||||
foreach ($columns['widgets'] as $widgets) {
|
||||
if ($widgets['type'] == 'ApTabs' || $widgets['type'] == 'ApAjaxTabs' || $widgets['type'] == 'ApAccordions') {
|
||||
$params .= '['.$widgets['type'].ApShortCodesBuilder::converParamToAttr2($widgets['params'], $widgets['type'], $this->theme_dir).']';
|
||||
foreach ($widgets['widgets'] as $sub_widgets) {
|
||||
$type_sub = Tools::substr($widgets['type'], 0, -1);
|
||||
$params .= '['.$type_sub.ApShortCodesBuilder::converParamToAttr2($sub_widgets['params'], str_replace('_', '_sub_', $widgets['type']), $this->theme_dir).']';
|
||||
foreach ($sub_widgets['widgets'] as $sub_widget) {
|
||||
$params .= '['.$sub_widget['type']
|
||||
.ApShortCodesBuilder::converParamToAttr2($sub_widget['params'], $sub_widget['type'], $this->theme_dir).'][/'
|
||||
.$sub_widget['type'].']';
|
||||
}
|
||||
$params .= '[/'.$type_sub.']';
|
||||
}
|
||||
$params .= '[/'.$widgets['type'].']';
|
||||
} else {
|
||||
$params .= '['.$widgets['type'].ApShortCodesBuilder::converParamToAttr2($widgets['params'], $widgets['type'], $this->theme_dir).'][/'.$widgets['type'].']';
|
||||
if ($widgets['type'] == 'ApModule' && $action == 'save') {
|
||||
$is_delete = (int)$widgets['params']['is_display'];
|
||||
if ($is_delete) {
|
||||
if (!isset($widgets['params']['hook'])) {
|
||||
// FIX : Module not choose hook -> error
|
||||
$widgets['params']['hook'] = '';
|
||||
}
|
||||
$this->deleteModuleFromHook($widgets['params']['hook'], $widgets['params']['name_module']);
|
||||
}
|
||||
} else if ($widgets['type'] == 'ApProductCarousel') {
|
||||
if ($widgets['params']['order_way'] == 'random') {
|
||||
$this->config_module[$hook]['productCarousel']['order_way'] = 'random';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$params .= '[/ApColumn]';
|
||||
}
|
||||
$params .= '[/ApRow]';
|
||||
return $params;
|
||||
}
|
||||
|
||||
private function saveExceptionConfig($hook, $type, $page, $ids)
|
||||
{
|
||||
if (!$type) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($type == 'all') {
|
||||
if ($type != '') {
|
||||
$list = explode(',', $page);
|
||||
foreach ($list as $val) {
|
||||
$val = trim($val);
|
||||
if ($val && (!is_array($this->config_module) || !isset($this->config_module[$hook]) || !isset($this->config_module[$hook]['exception']) || !isset($val, $this->config_module[$hook]['exception']))) {
|
||||
$this->config_module[$hook]['exception'][] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->config_module[$hook][$type] = array();
|
||||
if ($type != 'index') {
|
||||
$ids = explode(',', $ids);
|
||||
foreach ($ids as $val) {
|
||||
$val = trim($val);
|
||||
if (!in_array($val, $this->config_module[$hook][$type])) {
|
||||
$this->config_module[$hook][$type][] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function adminContent($assign, $tpl_name)
|
||||
{
|
||||
if (file_exists($this->tpl_controller_path.$tpl_name)) {
|
||||
$tpl = $this->createTemplate($tpl_name);
|
||||
} else {
|
||||
$tpl = $this->createTemplate('ApGeneral.tpl');
|
||||
}
|
||||
$assign['moduleDir'] = _MODULE_DIR_;
|
||||
foreach ($assign as $key => $ass) {
|
||||
$tpl->assign(array($key => $ass));
|
||||
}
|
||||
return $tpl->fetch();
|
||||
}
|
||||
|
||||
public function displayDuplicateLink($token = null, $id = null, $name = null)
|
||||
{
|
||||
$href = self::$currentIndex.'&'.$this->identifier.'='.$id.'&duplicate'.$this->table.'&token='.($token != null ? $token : $this->token);
|
||||
$html = '<a href="'.$href.'" title="Duplicate">
|
||||
<i class="icon-copy"></i> Duplicate
|
||||
</a>';
|
||||
|
||||
// validate module
|
||||
unset($name);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* PERMISSION ACCOUNT demo@demo.com
|
||||
* OVERRIDE CORE
|
||||
*/
|
||||
public function access($action, $disable = false)
|
||||
{
|
||||
if (Tools::getIsset('update'.$this->table) && Tools::getIsset($this->identifier)) {
|
||||
// Allow person see "EDIT" form
|
||||
$action = 'view';
|
||||
}
|
||||
return parent::access($action, $disable);
|
||||
}
|
||||
|
||||
/**
|
||||
* PERMISSION ACCOUNT demo@demo.com
|
||||
* OVERRIDE CORE
|
||||
*/
|
||||
public function initProcess()
|
||||
{
|
||||
parent::initProcess();
|
||||
# SET ACTION : IMPORT DATA
|
||||
if ($this->can_import && Tools::getIsset('import' . $this->table)) {
|
||||
if ($this->access('edit')) {
|
||||
$this->action = 'import';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($this->errors) <= 0) {
|
||||
if (Tools::isSubmit('duplicate'.$this->table)) {
|
||||
if ($this->id_object) {
|
||||
if (!$this->access('add')) {
|
||||
$this->errors[] = $this->trans('You do not have permission to duplicate this.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
}
|
||||
} elseif ($this->can_import && Tools::getIsset('import' . $this->table)) {
|
||||
if (!$this->access('edit')) {
|
||||
$this->errors[] = $this->trans('You do not have permission to import data.', array(), 'Admin.Notifications.Error');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/classes/ApPageSetting.php');
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/controllers/admin/AdminApPageBuilderPositions.php');
|
||||
|
||||
class AdminApPageBuilderShortcodesController extends ModuleAdminControllerCore
|
||||
{
|
||||
public static $shortcode_lang;
|
||||
public static $language;
|
||||
public static $lang_id;
|
||||
public $file_content = '';
|
||||
protected $max_image_size = null;
|
||||
public $theme_name;
|
||||
public $config_module;
|
||||
public $hook_assign;
|
||||
public $module_name;
|
||||
public $module_path;
|
||||
public $tpl_controller_path;
|
||||
public $tpl_front_path;
|
||||
public $shortcode_dir;
|
||||
public $shortcode_override_dir;
|
||||
public $theme_dir;
|
||||
public $theme_url;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
$this->show_toolbar = true;
|
||||
$this->table = 'appagebuilder';
|
||||
$this->className = 'ApPageBuilderShortCode';
|
||||
$this->context = Context::getContext();
|
||||
$this->module_name = 'appagebuilder';
|
||||
$this->module_path = __PS_BASE_URI__.'modules/'.$this->module_name.'/';
|
||||
$this->tpl_controller_path = _PS_ROOT_DIR_.'/modules/'.$this->module_name.'/views/templates/admin/ap_page_builder_shortcodes/';
|
||||
$this->tpl_front_path = _PS_ROOT_DIR_.'/modules/'.$this->module_name.'/views/templates/font/';
|
||||
$this->shortcode_dir = _PS_MODULE_DIR_.'appagebuilder/classes/shortcodes/';
|
||||
|
||||
self::$language = Language::getLanguages(false);
|
||||
parent::__construct();
|
||||
$this->theme_dir = apPageHelper::getConfigDir('_PS_THEME_DIR_');
|
||||
$this->theme_url = _THEMES_DIR_.apPageHelper::getThemeName().'/';
|
||||
$this->shortcode_override_dir = $this->theme_dir.'modules/appagebuilder/classes/shortcodes/';
|
||||
$this->max_image_size = (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE');
|
||||
$this->theme_name = apPageHelper::getThemeName();
|
||||
$this->hook_assign = array('rightcolumn', 'leftcolumn', 'home', 'top', 'footer');
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
if (Tools::getIsset('type_shortcode')) {
|
||||
# Run AJAX here for Hight Speed
|
||||
$this->ajaxLoadWidget();
|
||||
}
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate all data relate with profile
|
||||
* @param type int $old_id : current profile id is duplicating
|
||||
* @param type int $new_id : new profile id after duplicated
|
||||
*/
|
||||
public static function duplicateData($old_id, $new_id)
|
||||
{
|
||||
// $context = Context::getContext();
|
||||
$positions = array();
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'appagebuilder_profiles` p
|
||||
WHERE p.id_appagebuilder_profiles='.(int)$old_id;
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
if ($result) {
|
||||
$positions[] = $result['header'];
|
||||
$positions[] = $result['content'];
|
||||
$positions[] = $result['footer'];
|
||||
$positions[] = $result['product'];
|
||||
}
|
||||
$sql_update = 'UPDATE '._DB_PREFIX_.'appagebuilder_profiles ';
|
||||
$sep = ' SET ';
|
||||
$is_update = false;
|
||||
// Duplicate positions
|
||||
foreach ($positions as $item) {
|
||||
$id = (int)$item;
|
||||
$object = ApPageBuilderPositionsModel::getPositionById($id);
|
||||
if ($object) {
|
||||
$key = ApPageSetting::getRandomNumber();
|
||||
$old_key = $object['position_key'];
|
||||
$name = 'Duplicate '.$key;
|
||||
$data = array('name' => $name, 'position' => $object['position'], 'position_key' => 'duplicate_'.$key);
|
||||
$model = new ApPageBuilderPositionsModel();
|
||||
$duplicate_id = $model->addAuto($data);
|
||||
if ($duplicate_id) {
|
||||
$position_controller = new AdminApPageBuilderPositionsController();
|
||||
$sql_update .= $sep.$data['position'].'='.$duplicate_id;
|
||||
$sep = ', ';
|
||||
$is_update = true;
|
||||
self::duplcateDataPosition($id, $duplicate_id);
|
||||
ApPageSetting::writeFile($position_controller->position_js_folder, $data['position'].$data['position_key'].'.js', Tools::file_get_contents($position_controller->position_js_folder.$data['position'].$old_key.'.js'));
|
||||
ApPageSetting::writeFile($position_controller->position_css_folder, $data['position'].$data['position_key'].'.css', Tools::file_get_contents($position_controller->position_css_folder.$data['position'].$old_key.'.css'));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($is_update) {
|
||||
$sql_update .= ' WHERE id_appagebuilder_profiles='.(int)$new_id;
|
||||
Db::getInstance()->execute($sql_update);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate a position: dulicate data in table appagebuilder_lang; appagebuilder; appagebuilder_shop;
|
||||
* @param type int $old_id: position id for duplicate
|
||||
* @param type int $duplicate_id: new position id
|
||||
*/
|
||||
public static function duplcateDataPosition($old_id, $duplicate_id)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$id_shop = $context->shop->id;
|
||||
// Get list appagebuilder for copy
|
||||
$sql = 'SELECT * from '._DB_PREFIX_.'appagebuilder p WHERE p.id_appagebuilder_positions='.(int)$old_id;
|
||||
$result = Db::getInstance()->executeS($sql);
|
||||
foreach ($result as $item) {
|
||||
// Duplicate to tables appagebuilder
|
||||
$sql = 'INSERT INTO '._DB_PREFIX_.'appagebuilder (id_appagebuilder_positions, hook_name)
|
||||
VALUES("'.(int)$duplicate_id.'", "'.pSQL($item['hook_name']).'")';
|
||||
Db::getInstance()->execute($sql);
|
||||
// Duplicate to tables appagebuilder_shop
|
||||
$id_new = Db::getInstance()->Insert_ID();
|
||||
$sql = 'INSERT INTO '._DB_PREFIX_.'appagebuilder_shop (id_appagebuilder, id_shop)
|
||||
VALUES('.(int)$id_new.', '.(int)$id_shop.')';
|
||||
Db::getInstance()->execute($sql);
|
||||
// Copy data and languages
|
||||
$sql = 'SELECT * from '._DB_PREFIX_.'appagebuilder_lang p
|
||||
WHERE p.id_appagebuilder='.(int)$item['id_appagebuilder'];
|
||||
$old_data = Db::getInstance()->executeS($sql);
|
||||
foreach ($old_data as $temp) {
|
||||
// Not pSQL at here because duplicate profile is error
|
||||
$sql = 'INSERT INTO '._DB_PREFIX_."appagebuilder_lang (id_appagebuilder, id_lang, params)
|
||||
VALUES('".(int)$id_new."', '".(int)$temp['id_lang']."', '".apPageHelper::replaceFormId($temp['params'])."')";
|
||||
Db::getInstance()->execute($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function adminContent($assign, $tpl_name)
|
||||
{
|
||||
if (file_exists($this->tpl_controller_path.$tpl_name)) {
|
||||
$tpl = $this->createTemplate($tpl_name);
|
||||
} else {
|
||||
$tpl = $this->createTemplate('ApGeneral.tpl');
|
||||
}
|
||||
$assign['moduleDir'] = _MODULE_DIR_;
|
||||
foreach ($assign as $key => $ass) {
|
||||
$tpl->assign(array($key => $ass));
|
||||
}
|
||||
return $tpl->fetch();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX :
|
||||
* - load widget or module
|
||||
* - call method of widget
|
||||
*/
|
||||
private function ajaxLoadWidget()
|
||||
{
|
||||
$type_shortcode = Tools::ucfirst(Tools::getValue('type_shortcode'));
|
||||
$type = Tools::getValue('type');
|
||||
$shor_code_dir = '';
|
||||
// Add new widget from apollotheme
|
||||
if ($type === 'widget') {
|
||||
if (!$shor_code_dir = ApPageSetting::requireShortCode($type_shortcode.'.php', $this->theme_dir)) {
|
||||
die($this->l('This short code is not exist'));
|
||||
}
|
||||
if (class_exists($type_shortcode) != true) {
|
||||
// validate module
|
||||
require_once($shor_code_dir);
|
||||
}
|
||||
|
||||
$obj = new $type_shortcode;
|
||||
die($obj->renderForm());
|
||||
} elseif ($type === 'module') {
|
||||
// Custom a module
|
||||
$shor_code_dir = ApPageSetting::requireShortCode('ApModule.php', $this->theme_dir);
|
||||
if (class_exists('ApModule') != true) {
|
||||
// validate module
|
||||
require_once($shor_code_dir);
|
||||
}
|
||||
$obj = new ApModule();
|
||||
die($obj->renderForm());
|
||||
}
|
||||
|
||||
|
||||
|
||||
# RUN WIDGET METHOD - BEGIN
|
||||
$result = array(
|
||||
'hasError' => false,
|
||||
'error' => '',
|
||||
'success' => false,
|
||||
'information' => '',
|
||||
);
|
||||
$type_shortcode = Tools::ucfirst(Tools::getValue('type_shortcode'));
|
||||
if (Tools::getIsset('type_shortcode') && $type_shortcode) {
|
||||
if ($shor_code_dir = ApPageSetting::requireShortCode($type_shortcode.'.php', $this->theme_dir)) {
|
||||
if (class_exists($type_shortcode) != true) {
|
||||
require_once($shor_code_dir);
|
||||
}
|
||||
$obj = new $type_shortcode;
|
||||
$method_name = Tools::getValue('method_name', '');
|
||||
$method_name = 'ajaxCallBack'.Tools::toCamelCase($method_name, true);
|
||||
if (method_exists($obj, $method_name)) {
|
||||
# RUN WIDGET METHOD
|
||||
$obj->{$method_name}();
|
||||
$result['information'] = $method_name . $this->l(' is successful');
|
||||
} else {
|
||||
$result['error'] = sprintf($this->l('%s method is not exist'), $method_name);
|
||||
}
|
||||
} else {
|
||||
$result['error'] = sprintf($this->l('%s is not found'), $type_shortcode.'.php');
|
||||
}
|
||||
} else {
|
||||
$result['error'] = $this->l('type_shortcode param is empty');
|
||||
}
|
||||
|
||||
if (count($result['error'])) {
|
||||
$result['hasError'] = true;
|
||||
}
|
||||
|
||||
die(Tools::jsonEncode($result));
|
||||
# RUN WIDGET METHOD - END
|
||||
}
|
||||
|
||||
public function viewAccess($disable = true)
|
||||
{
|
||||
// return $this->access('view', $disable);
|
||||
unset($disable);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class AdminApPageBuilderThemeEditorController extends ModuleAdminControllerCore
|
||||
{
|
||||
public $themeName = '';
|
||||
public $css_patterns;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
$this->table = 'appagebuilder_themeeditor';
|
||||
$this->lang = false;
|
||||
$this->context = Context::getContext();
|
||||
parent::__construct();
|
||||
$this->themeName = apPageHelper::getThemeName();
|
||||
$this->js_patterns = apPageHelper::getConfigDir('_PS_THEME_DIR_').apPageHelper::getJsDir().'patterns/';
|
||||
$this->css_patterns = apPageHelper::getConfigDir('_PS_THEME_DIR_').apPageHelper::getCssDir().'patterns/';
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (count($this->errors) > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Tools::getValue('action') && Tools::getValue('action') == 'savedata' && Tools::getValue('customize')) {
|
||||
$data = LeoFrameworkHelper::getPost(array('action-mode', 'saved_file', 'newfile', 'customize', 'customize_match', 'active'), 0);
|
||||
|
||||
$selectors = $data['customize'];
|
||||
$matches = $data['customize_match'];
|
||||
|
||||
$output = '';
|
||||
|
||||
$cache = array();
|
||||
foreach ($selectors as $match => $customizes) {
|
||||
$output .= "\r\n/* customize for $match */ \r\n";
|
||||
foreach ($customizes as $key => $customize) {
|
||||
if (isset($matches[$match]) && isset($matches[$match][$key])) {
|
||||
$tmp = explode('|', $matches[$match][$key]);
|
||||
$attribute = Tools::strtolower(trim($tmp[1]));
|
||||
if (trim($customize)) {
|
||||
$output .= $tmp[0].' { ';
|
||||
if ($attribute == 'background-image') {
|
||||
$output .= $attribute.':url('.$customize.')';
|
||||
} elseif ($attribute == 'font-size') {
|
||||
$output .= $attribute.':'.$customize.'px';
|
||||
} else if (strpos($attribute, 'color') !== false) {
|
||||
$output .= $attribute.':#'.$customize;
|
||||
} else if ($attribute == 'background') {
|
||||
$output .= $attribute.':#'.$customize;
|
||||
} else {
|
||||
$output .= $attribute.':'.$customize;
|
||||
}
|
||||
$output .= "} \r\n";
|
||||
}
|
||||
$cache[$match][] = array('val' => $customize, 'selector' => $tmp[0], 'attr' => $tmp[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# RENAME
|
||||
if (!empty($data['saved_file']) && !empty($data['newfile'])) {
|
||||
# DELETE PATTERN
|
||||
if (isset($data['saved_file']) && $data['saved_file'] && file_exists($this->css_patterns.$data['saved_file'].'.css')) {
|
||||
unlink($this->css_patterns.$data['saved_file'].'.css');
|
||||
}
|
||||
if (isset($data['saved_file']) && $data['saved_file'] && file_exists($this->css_patterns.$data['saved_file'].'.json')) {
|
||||
unlink($this->css_patterns.$data['saved_file'].'.json');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (empty($data['newfile'])) {
|
||||
# EDIT PATTERN
|
||||
$nameFile = $data['saved_file'] ? $data['saved_file'] : 'profile-'.time();
|
||||
} else {
|
||||
# CREATE PATTERN
|
||||
$nameFile = preg_replace('#\s+#', '-', trim($data['newfile']));
|
||||
}
|
||||
|
||||
if ($data['action-mode'] != 'save-delete') {
|
||||
# CREATE + EDIT
|
||||
if (!is_dir($this->css_patterns)) {
|
||||
mkdir($this->css_patterns, 0755, true);
|
||||
}
|
||||
|
||||
if (!empty($output)) {
|
||||
LeoFrameworkHelper::writeToCache($this->css_patterns, $nameFile, $output);
|
||||
}
|
||||
if (!empty($cache)) {
|
||||
LeoFrameworkHelper::writeToCache($this->css_patterns, $nameFile, Tools::jsonEncode($cache), 'json');
|
||||
}
|
||||
|
||||
if (isset($data['active']) && $data['active']) {
|
||||
# SET ACTIVE - YES
|
||||
apPageHelper::setConfig('C_PROFILE', $nameFile);
|
||||
} elseif (isset($data['active']) && empty($data['active'])) {
|
||||
# SET ACTIVE - NO
|
||||
$pattern_active = apPageHelper::getConfig('C_PROFILE');
|
||||
if ($nameFile == $pattern_active) {
|
||||
apPageHelper::setConfig('C_PROFILE', '');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# SET ACTIVE - NO
|
||||
$pattern_active = apPageHelper::getConfig('C_PROFILE');
|
||||
if ($data['saved_file'] == $pattern_active) {
|
||||
apPageHelper::setConfig('C_PROFILE', '');
|
||||
}
|
||||
# DELETE PATTERN
|
||||
if (isset($data['saved_file']) && $data['saved_file'] && file_exists($this->css_patterns.$data['saved_file'].'.css')) {
|
||||
unlink($this->css_patterns.$data['saved_file'].'.css');
|
||||
}
|
||||
if (isset($data['saved_file']) && $data['saved_file'] && file_exists($this->css_patterns.$data['saved_file'].'.json')) {
|
||||
unlink($this->css_patterns.$data['saved_file'].'.json');
|
||||
}
|
||||
}
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get list of files inside folder path.
|
||||
*/
|
||||
private function getFileList($path, $e = null, $nameOnly = false)
|
||||
{
|
||||
$output = array();
|
||||
$directories = glob($path.'*'.$e);
|
||||
if ($directories) {
|
||||
foreach ($directories as $dir) {
|
||||
$dir = basename($dir);
|
||||
if ($nameOnly) {
|
||||
$dir = str_replace($e, '', $dir);
|
||||
}
|
||||
$output[$dir] = $dir;
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* render list of modules following positions in the layout editor.
|
||||
*/
|
||||
public function renderList()
|
||||
{
|
||||
$filePath = _PS_ALL_THEMES_DIR_.$this->themeName.'';
|
||||
|
||||
$xml = simplexml_load_file($filePath.'/config.xml');
|
||||
|
||||
if (!isset($xml->theme_key) || empty($xml->theme_key)) {
|
||||
return '<div class="panel"><div class="panel-content"><div class="alert alert-warning">'.'This function is only avariable using for Theme from <b><a href=http://www.leotheme.com/ target=_blank>leotheme.com</a></b> or using theme built-in <b>Leo Framework</b>'.'</div></div></div>';
|
||||
}
|
||||
|
||||
$tpl = $this->createTemplate('themeeditor.tpl');
|
||||
Context::getContext()->controller->addCss(apPageHelper::getCssAdminDir().'admin/themeeditor.css');
|
||||
Context::getContext()->controller->addCss(apPageHelper::getCssAdminDir().'colorpicker/css/colorpicker.css');
|
||||
Context::getContext()->controller->addCss(apPageHelper::getCssAdminDir().'paneltool.css');
|
||||
|
||||
Context::getContext()->controller->addJs(apPageHelper::getJsAdminDir().'colorpicker/js/colorpicker.js');
|
||||
Context::getContext()->controller->addJs(apPageHelper::getJsAdminDir().'admin/themeeditor.js');
|
||||
|
||||
|
||||
|
||||
$output = LeoFrameworkHelper::renderEdtiorThemeForm($this->themeName);
|
||||
|
||||
$profiles = $this->getFileList($this->css_patterns, '.css', true);
|
||||
$patterns = $this->getFileList(_PS_ALL_THEMES_DIR_.$this->themeName.'/assets/img/patterns/', '.png');
|
||||
$patternsjpg = $this->getFileList(_PS_ALL_THEMES_DIR_.$this->themeName.'/assets/img/patterns/', '.jpg');
|
||||
|
||||
$patterns = array_merge($patterns, $patternsjpg);
|
||||
$backGroundValue = array(
|
||||
'attachment' => array('scroll', 'fixed', 'local', 'initial', 'inherit'),
|
||||
'repeat' => array('repeat', 'repeat-x', 'repeat-y', 'no-repeat', 'initial', 'inherit'),
|
||||
'position' => array('left top', 'left center', 'left bottom', 'right top', 'right center', 'right bottom', 'center top', 'center center', 'center bottom')
|
||||
);
|
||||
$siteURL = _PS_BASE_URL_.__PS_BASE_URI__;
|
||||
// URL LOAD IMAGE BUTTON
|
||||
$imgLink = Context::getContext()->link->getAdminLink('AdminApPageBuilderImages').'&leo_controller=live_theme_edit';
|
||||
$backgroundImageURL = _PS_BASE_URL_._THEME_DIR_.'assets/img/patterns/';
|
||||
|
||||
$ssl_enable = Configuration::get('PS_SSL_ENABLED');
|
||||
if ($ssl_enable) {
|
||||
$siteURL = str_replace('http:', 'https:', $siteURL);
|
||||
$imgLink = str_replace('http:', 'https:', $imgLink);
|
||||
$backgroundImageURL = str_replace('http:', 'https:', $backgroundImageURL);
|
||||
}
|
||||
|
||||
$tpl->assign(array(
|
||||
'actionURL' => 'index.php?tab=AdminApPageBuilderThemeEditor&token='.Tools::getAdminTokenLite('AdminApPageBuilderThemeEditor').'&action=savedata',
|
||||
'text_layout' => $this->l('Layout'),
|
||||
'text_elements' => $this->l('Elements'),
|
||||
'profiles' => $profiles,
|
||||
'profiles_active' => apPageHelper::getConfig('c_profile'),
|
||||
'xmlselectors' => $output,
|
||||
'apPageHelper' => apPageHelper::getInstance(),
|
||||
'themeName' => $this->themeName,
|
||||
'patterns' => $patterns,
|
||||
'backgroundImageURL' => $backgroundImageURL,
|
||||
'siteURL' => $siteURL,
|
||||
'customizeFolderURL' => _PS_THEME_URI_.apPageHelper::getCssDir().'patterns/',
|
||||
'backLink' => 'index.php?controller=AdminModules&configure=appagebuilder&token='.Tools::getAdminTokenLite('AdminModules'),
|
||||
'imgLink' => $imgLink,
|
||||
'backGroundValue' => $backGroundValue
|
||||
));
|
||||
|
||||
return $tpl->fetch();
|
||||
}
|
||||
}
|
||||
36
modules/appagebuilder/controllers/admin/index.php
Normal file
36
modules/appagebuilder/controllers/admin/index.php
Normal 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;
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Leo Theme for Prestashop 1.6.x
|
||||
*
|
||||
* @author http://www.leotheme.com
|
||||
* @copyright Copyright (C) October 2013 LeoThemes.com <@emai:leotheme@gmail.com>
|
||||
* <info@leotheme.com>.All rights reserved.
|
||||
* @license GNU General Public License version 2
|
||||
*/
|
||||
|
||||
class ApPageBuilderApPagebuilderHomeModuleFrontController extends FrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->display_column_left = false;
|
||||
$this->display_column_right = false;
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
$this->addJS(_THEME_JS_DIR_.'index.js');
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'HOOK_HOME' => Hook::exec('displayHome'),
|
||||
'HOOK_HOME_TAB' => Hook::exec('displayHomeTab'),
|
||||
'HOOK_HOME_TAB_CONTENT' => Hook::exec('displayHomeTabContent')
|
||||
));
|
||||
$this->display_column_left = false;
|
||||
$this->display_column_right = false;
|
||||
$this->context->smarty->assign(array(
|
||||
'page_name' => 'index',
|
||||
));
|
||||
$this->setTemplate('index.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* set html <body id="index"
|
||||
*/
|
||||
public function getPageName()
|
||||
{
|
||||
$page_name = 'index';
|
||||
return $page_name;
|
||||
}
|
||||
|
||||
public function getTemplateVarPage()
|
||||
{
|
||||
$page = parent::getTemplateVarPage();
|
||||
unset($page['body_classes']['page-']);
|
||||
$page['body_classes']['page-index'] = true;
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
36
modules/appagebuilder/controllers/front/index.php
Normal file
36
modules/appagebuilder/controllers/front/index.php
Normal 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;
|
||||
36
modules/appagebuilder/controllers/index.php
Normal file
36
modules/appagebuilder/controllers/index.php
Normal 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;
|
||||
35
modules/appagebuilder/index.php
Normal file
35
modules/appagebuilder/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2019 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;
|
||||
1423
modules/appagebuilder/libs/Helper.php
Normal file
1423
modules/appagebuilder/libs/Helper.php
Normal file
File diff suppressed because it is too large
Load Diff
2127
modules/appagebuilder/libs/LeoDataSample.php
Normal file
2127
modules/appagebuilder/libs/LeoDataSample.php
Normal file
File diff suppressed because it is too large
Load Diff
838
modules/appagebuilder/libs/LeoFrameworkHelper.php
Normal file
838
modules/appagebuilder/libs/LeoFrameworkHelper.php
Normal file
@@ -0,0 +1,838 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
if (!class_exists("LeoFrameworkHelper")) {
|
||||
|
||||
/**
|
||||
* LeoFrameworkHelper Class
|
||||
*/
|
||||
class LeoFrameworkHelper
|
||||
{
|
||||
/**
|
||||
* @var Array $overrideHooks;
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected $overrideHooks = array();
|
||||
/**
|
||||
* @var String $activedTheme
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected $activedTheme = '';
|
||||
/**
|
||||
* @var boolean $isLangRTL
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected $isLangRTL = false;
|
||||
protected $cparams = array();
|
||||
protected $fonts = array();
|
||||
|
||||
/**
|
||||
* get instance of current object
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
static $_instance;
|
||||
if (!$_instance) {
|
||||
$_instance = new LeoFrameworkHelper();
|
||||
}
|
||||
return $_instance;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// public static function getHookPositions()
|
||||
// {
|
||||
//
|
||||
// $hookspos = array(
|
||||
// 'displayNav',
|
||||
// 'displayTop',
|
||||
// 'displayHeaderRight',
|
||||
// 'displaySlideshow',
|
||||
// 'topNavigation',
|
||||
// 'displayTopColumn',
|
||||
// 'displayRightColumn',
|
||||
// 'displayLeftColumn',
|
||||
// 'displayHome',
|
||||
// 'displayFooter',
|
||||
// 'displayBottom',
|
||||
// 'displayContentBottom',
|
||||
// 'displayFootNav',
|
||||
// 'displayFooterTop',
|
||||
// 'displayFooterBottom'
|
||||
// );
|
||||
// return $hookspos;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Set actived theme and language direction
|
||||
*/
|
||||
public function setActivedTheme($theme, $isRTL = false)
|
||||
{
|
||||
$this->activedTheme = $theme;
|
||||
$this->isLangRTL = $isRTL;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function developmentMode($dDevMode, $skin)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$cssFiles = array();
|
||||
$theme = $this->activedTheme;
|
||||
/* export direct to stylesheet folder of the theme */
|
||||
|
||||
$themeDir = _PS_ALL_THEMES_DIR_.$theme;
|
||||
$cssFolder = _PS_ALL_THEMES_DIR_.$theme.'/css/';
|
||||
$lessDevURL = __PS_BASE_URI__.'cache/'.$theme.'/';
|
||||
$themeURL = '';
|
||||
require_once(_PS_MODULE_DIR_.'leotempcp/libs/lessparser.php');
|
||||
$lessparser = new LeoLessParser($themeDir.'/development/', $themeDir, $lessDevURL, $themeURL, $cssFolder);
|
||||
|
||||
if ($dDevMode == 'compile-export') {
|
||||
if (Tools::isSubmit('exportless')) {
|
||||
$lessparser->setLastTimeChanged(time())->compileLess();
|
||||
} else {
|
||||
$lessparser->compileLess();
|
||||
}
|
||||
} else {
|
||||
/* export direct to stylesheet to cache folder */
|
||||
$lessDevDir = _PS_CACHE_DIR_.$theme.'/';
|
||||
if (!is_dir($lessDevDir)) {
|
||||
mkdir($lessDevDir, 0755, true);
|
||||
}
|
||||
$cssFiles = $lessparser->setDevelopmentMode($lessDevDir)->compileLessDevelopment($skin, $this->isLangRTL);
|
||||
}
|
||||
return $cssFiles;
|
||||
}
|
||||
|
||||
public static function getIntelnalModule($theme)
|
||||
{
|
||||
$xml = _PS_ALL_THEMES_DIR_.$theme.'/development/customize/module.xml';
|
||||
$output = array();
|
||||
|
||||
|
||||
if (file_exists($xml)) {
|
||||
libxml_use_internal_errors(true);
|
||||
$xml = simplexml_load_file($xml, null, LIBXML_NOCDATA);
|
||||
|
||||
if (isset($xml->module)) {
|
||||
$xml = get_object_vars($xml);
|
||||
|
||||
|
||||
if (is_array($xml['module'])) {
|
||||
foreach ($xml['module'] as $module) {
|
||||
$tmp = get_object_vars($module);
|
||||
$output[$tmp['key']] = $tmp;
|
||||
}
|
||||
} else {
|
||||
$module = get_object_vars($xml['module']);
|
||||
$output[trim($module['key'])] = $module;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* save data into framework
|
||||
*/
|
||||
public static function writeToCache($folder, $file, $value, $e = 'css')
|
||||
{
|
||||
$file = $folder.preg_replace('/[^A-Z0-9\._-]/i', '', $file).'.'.$e;
|
||||
$handle = fopen($file, 'w+');
|
||||
fwrite($handle, ($value));
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* auto load all css file local folder
|
||||
*/
|
||||
public function loadLocalCss()
|
||||
{
|
||||
return $this->getFileList(_PS_ALL_THEMES_DIR_.$this->activedTheme.'/css/local/', '.css');
|
||||
}
|
||||
|
||||
/**
|
||||
* auto load all js file local folder
|
||||
*/
|
||||
public function loadLocalJs()
|
||||
{
|
||||
return $this->getFileList(_PS_ALL_THEMES_DIR_.$this->activedTheme.'/js/local/', '.js');
|
||||
}
|
||||
|
||||
public static function getThemeInfo($theme)
|
||||
{
|
||||
$xml = _PS_ALL_THEMES_DIR_.$theme.'/config.xml';
|
||||
|
||||
$output = array();
|
||||
|
||||
if (file_exists($xml)) {
|
||||
$output = simplexml_load_file($xml);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function getLayoutSettingByTheme($theme)
|
||||
{
|
||||
$xml = _PS_ALL_THEMES_DIR_.$theme.'/development/customize/layout.xml';
|
||||
|
||||
$output = array();
|
||||
|
||||
if (file_exists($xml)) {
|
||||
$info = simplexml_load_file($xml);
|
||||
|
||||
|
||||
if (isset($info->layout)) {
|
||||
foreach ($info->layout as $layouts) {
|
||||
$vars = get_object_vars($layouts);
|
||||
|
||||
if (is_object($vars['item'])) {
|
||||
|
||||
$tmp = get_object_vars($vars['item']);
|
||||
$block = $tmp['block'];
|
||||
if (is_object($tmp['option'])) {
|
||||
$options = $tmp['option'];
|
||||
$tmp['option'] = array();
|
||||
$tmp['option'][] = get_object_vars($options);
|
||||
} else {
|
||||
foreach ($tmp['option'] as $key => $o) {
|
||||
$tmp['option'][$key] = get_object_vars($o);
|
||||
}
|
||||
}
|
||||
unset($tmp['block']);
|
||||
$vars['layout'][$block] = $tmp;
|
||||
} else {
|
||||
foreach ($vars['item'] as $selector) {
|
||||
$tmp = get_object_vars($selector);
|
||||
|
||||
|
||||
if (is_array($tmp) && !empty($tmp)) {
|
||||
$block = $tmp['block'];
|
||||
unset($tmp['block']);
|
||||
if (is_object($tmp['option'])) {
|
||||
$options = $tmp['option'];
|
||||
$tmp['option'] = array();
|
||||
$tmp['option'][] = get_object_vars($options);
|
||||
} else {
|
||||
foreach ($tmp['option'] as $key => $o) {
|
||||
$tmp['option'][$key] = get_object_vars($o);
|
||||
}
|
||||
}
|
||||
|
||||
$vars['layout'][$block] = $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($vars['item']);
|
||||
$output = $vars;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function getPanelConfigByTheme($fileName, $theme)
|
||||
{
|
||||
$xml = _PS_ALL_THEMES_DIR_.$theme.'/development/customize/'.$fileName.'.xml';
|
||||
$output = array();
|
||||
if (file_exists($xml)) {
|
||||
$info = simplexml_load_file($xml);
|
||||
if (isset($info->configs)) {
|
||||
foreach ($info->configs as $header) {
|
||||
$vars = get_object_vars($header);
|
||||
if (is_object($vars['item'])) {
|
||||
$tmp = get_object_vars($vars['item']);
|
||||
$block = $tmp['block'];
|
||||
if (is_object($tmp['option'])) {
|
||||
$options = $tmp['option'];
|
||||
$tmp['option'] = array();
|
||||
$tmp['option'][] = get_object_vars($options);
|
||||
} else {
|
||||
foreach ($tmp['option'] as $key => $o) {
|
||||
$tmp['option'][$key] = get_object_vars($o);
|
||||
}
|
||||
}
|
||||
unset($tmp['block']);
|
||||
$vars['configs'][$block] = $tmp;
|
||||
} else {
|
||||
foreach ($vars['item'] as $selector) {
|
||||
$tmp = get_object_vars($selector);
|
||||
if (is_array($tmp) && !empty($tmp)) {
|
||||
$block = $tmp['block'];
|
||||
unset($tmp['block']);
|
||||
if (is_object($tmp['option'])) {
|
||||
$options = $tmp['option'];
|
||||
$tmp['option'] = array();
|
||||
$tmp['option'][] = get_object_vars($options);
|
||||
} else {
|
||||
foreach ($tmp['option'] as $key => $o) {
|
||||
$tmp['option'][$key] = get_object_vars($o);
|
||||
}
|
||||
}
|
||||
$vars['configs'][$block] = $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($vars['item']);
|
||||
$output = $vars;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function getParam($key, $value = "")
|
||||
{
|
||||
return $this->cparams[$this->activedTheme."_".$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* trigger to process user paramters using for demostration
|
||||
*/
|
||||
public function triggerUserParams($params)
|
||||
{
|
||||
if (Tools::getIsset('btn-leo-reset')) {
|
||||
foreach ($params as $param) {
|
||||
$kc = $this->activedTheme."_".$param;
|
||||
$this->cparams[$kc] = null;
|
||||
setcookie($kc, null, 0, '/');
|
||||
if (isset($_COOKIE[$kc])) {
|
||||
$this->cparams[$kc] = null;
|
||||
$_COOKIE[$kc] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = Tools::getValue('userparams');
|
||||
|
||||
$exp = time() + 60 * 60 * 24 * 355;
|
||||
foreach ($params as $param) {
|
||||
$kc = $this->activedTheme."_".$param;
|
||||
$this->cparams[$kc] = '';
|
||||
if ($data) {
|
||||
if (isset($data[$param])) {
|
||||
setcookie($kc, $data[$param], $exp, '/');
|
||||
$this->cparams[$kc] = $data[$param];
|
||||
}
|
||||
}
|
||||
if (isset($_COOKIE[$kc])) {
|
||||
$this->cparams[$kc] = $_COOKIE[$kc];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['user_setting']) && $data['user_setting'] == 1) {
|
||||
Tools::redirect($this->getURI());
|
||||
}
|
||||
}
|
||||
|
||||
public function loadLocalFont()
|
||||
{
|
||||
$this->fonts = array(
|
||||
'Verdana' => 'Verdana, Geneva, sans-serif',
|
||||
'Georgia' => 'Georgia, "Times New Roman", Times, serif',
|
||||
'Arial' => 'Arial, Helvetica, sans-serif',
|
||||
'Impact' => 'Impact, Arial, Helvetica, sans-serif',
|
||||
'Tahoma' => 'Tahoma, Geneva, sans-serif',
|
||||
'Trebuchet' => '"Trebuchet MS", Arial, Helvetica, sans-serif',
|
||||
'Arial' => '"Arial Black", Gadget, sans-serif',
|
||||
'Times' => 'Times, "Times New Roman", serif',
|
||||
'Palatino' => '"Palatino Linotype", "Book Antiqua", Palatino, serif',
|
||||
'Lucida' => '"Lucida Sans Unicode", "Lucida Grande", sans-serif',
|
||||
'MS' => '"MS Serif", "New York", serif',
|
||||
'Comic' => '"Comic Sans MS", cursive',
|
||||
'Courier' => '"Courier New", Courier, monospace',
|
||||
'Lucida' => '"Lucida Console", Monaco, monospace'
|
||||
);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function renderFontTagHeader($engine, $lfont, $glink, $gfont, $selector)
|
||||
{
|
||||
$output = '';
|
||||
if ($engine == 'google') {
|
||||
if (!empty($glink) && !empty($gfont)) {
|
||||
$output = '<link rel="stylesheet" type="text/css" href="'.trim($glink).'" media="screen" />';
|
||||
$output .= '<style type="text/css">'.trim($selector)." { font-family:".trim($gfont)." } </style> ";
|
||||
}
|
||||
} else {
|
||||
$fontfamily = isset($this->fonts[trim($lfont)]) ? $this->fonts[trim($lfont)] : $lfont;
|
||||
$output .= '<style type="text/css">'.trim($selector)." { font-family:".$fontfamily." } </style> ";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate into file css
|
||||
*/
|
||||
public function renderFontTagHeaderCSS($engine, $lfont, $glink, $gfont, $selector)
|
||||
{
|
||||
$output = '';
|
||||
|
||||
if ($engine == 'google') {
|
||||
if (!empty($glink) && !empty($gfont)) {
|
||||
$output = '@import url("'.trim($glink).'");' ."\n";
|
||||
$output .= trim($selector)." { font-family:".trim($gfont)." }\n\n";
|
||||
}
|
||||
} else {
|
||||
$fontfamily = isset($this->fonts[trim($lfont)]) ? $this->fonts[trim($lfont)] : $lfont;
|
||||
$output .= trim($selector)." { font-family:".$fontfamily." }\n\n";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* get URI with http or https
|
||||
*/
|
||||
public function getURI()
|
||||
{
|
||||
|
||||
$useSSL = ((isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED')) || Tools::usingSecureMode()) ? true : false;
|
||||
$protocol_content = ($useSSL) ? 'https://' : 'http://';
|
||||
|
||||
return $protocol_content.Tools::getHttpHost().__PS_BASE_URI__;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* load override Hooks following actived theme
|
||||
*/
|
||||
public function loadOverridedHooks($shopId)
|
||||
{
|
||||
|
||||
$overrideHooks = array();
|
||||
|
||||
$sql = 'SELECT * FROM `'._DB_PREFIX_.'leohook` WHERE theme="'.pSQL($this->activedTheme).'" AND id_shop='.(int)$shopId;
|
||||
$result = Db::getInstance()->executeS($sql);
|
||||
if ($result)
|
||||
foreach ($result as $row) {
|
||||
$overrideHooks[$row['id_module']] = $row['name_hook'];
|
||||
}
|
||||
$this->overrideHooks = $overrideHooks;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get list of filename inside folder
|
||||
*/
|
||||
public static function getFileList($path, $e = null, $nameOnly = false)
|
||||
{
|
||||
$output = array();
|
||||
$directories = glob($path.'*'.$e);
|
||||
if ($directories)
|
||||
foreach ($directories as $dir) {
|
||||
$dir = basename($dir);
|
||||
if ($nameOnly) {
|
||||
$dir = str_replace($e, '', $dir);
|
||||
}
|
||||
|
||||
$output[$dir] = $dir;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function getUserProfiles($theme)
|
||||
{
|
||||
|
||||
$folder = _PS_ALL_THEMES_DIR_.$theme.'/css/customize/*.css';
|
||||
$dirs = glob($folder);
|
||||
$output = array();
|
||||
if ($dirs)
|
||||
foreach ($dirs as $dir) {
|
||||
$file = str_replace(".css", "", basename($dir));
|
||||
$output[] = array("skin" => $file, "name" => (Tools::ucfirst($file)));
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function getLayoutDirections($theme)
|
||||
{
|
||||
$folder = _PS_ALL_THEMES_DIR_.$theme.'/layout/*';
|
||||
$dirs = glob($folder, GLOB_ONLYDIR);
|
||||
$output = array();
|
||||
foreach ($dirs as $dir) {
|
||||
$file = str_replace(".scss", "", basename($dir));
|
||||
$output[] = array("id" => $file, "name" => (Tools::ucfirst($file)));
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function getSkins()
|
||||
{
|
||||
$folders = array();
|
||||
if (!apPageHelper::isRelease()) {
|
||||
$folders[] = apPageHelper::getConfigDir('_PS_THEME_DIR_').'assets/css/'.apPageHelper::getCssDir().'skins/*';
|
||||
}
|
||||
$folders[] = apPageHelper::getConfigDir('_PS_THEME_DIR_').apPageHelper::getCssDir().'skins/*';
|
||||
$output = array();
|
||||
foreach ($folders as $folder) {
|
||||
$dirs = glob($folder, GLOB_ONLYDIR);
|
||||
$output = array();
|
||||
if ($dirs) {
|
||||
$i = 0;
|
||||
foreach ($dirs as $dir) {
|
||||
$output[$i]['id'] = basename($dir);
|
||||
$output[$i]['name'] = Tools::ucfirst(basename($dir));
|
||||
$skinFileUrl = apPageHelper::getUriFromPath($dir).'/';
|
||||
|
||||
if (file_exists($dir.'/icon.png')) {
|
||||
$output[$i]['icon'] = $skinFileUrl.'icon.png';
|
||||
}
|
||||
$output[$i]['css'] = $skinFileUrl;
|
||||
|
||||
$isRTL = Context::getContext()->language->is_rtl;
|
||||
if ($isRTL && file_exists($dir.'/custom-rtl.css')) {
|
||||
$output[$i]['rtl'] = 1;
|
||||
} else {
|
||||
$output[$i]['rtl'] = 0;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if (!empty($output)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function renderEdtiorThemeForm($theme)
|
||||
{
|
||||
$customizeXML = _PS_ALL_THEMES_DIR_.$theme.'/development/customize/themeeditor.xml';
|
||||
|
||||
$output = array('selectors' => array(), 'elements' => array());
|
||||
if (file_exists($customizeXML)) {
|
||||
$info = simplexml_load_file($customizeXML);
|
||||
if (isset($info->selectors->items)) {
|
||||
foreach ($info->selectors->items as $item) {
|
||||
$vars = get_object_vars($item);
|
||||
if (is_object($vars['item'])) {
|
||||
$tmp = get_object_vars($vars['item']);
|
||||
$vars['selector'][] = $tmp;
|
||||
} else {
|
||||
foreach ($vars['item'] as $selector) {
|
||||
$tmp = get_object_vars($selector);
|
||||
if (is_array($tmp) && !empty($tmp)) {
|
||||
$vars['selector'][] = $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($vars['item']);
|
||||
$output['selectors'][$vars['match']] = $vars;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($info->elements->items)) {
|
||||
foreach ($info->elements->items as $item) {
|
||||
$vars = get_object_vars($item);
|
||||
if (is_object($vars['item'])) {
|
||||
$tmp = get_object_vars($vars['item']);
|
||||
$vars['selector'][] = $tmp;
|
||||
} else {
|
||||
foreach ($vars['item'] as $selector) {
|
||||
$tmp = get_object_vars($selector);
|
||||
if (is_array($tmp) && !empty($tmp)) {
|
||||
$vars['selector'][] = $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($vars['item']);
|
||||
$output['elements'][$vars['match']] = $vars;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute modules for specified hook
|
||||
*
|
||||
* @param string $hook_name Hook Name
|
||||
* @param array $hook_args Parameters for the functions
|
||||
* @param int $id_module Execute hook for this module only
|
||||
* @return string modules output
|
||||
*/
|
||||
public function exec($hook_name, $hook_args = array(), $id_module = null)
|
||||
{
|
||||
|
||||
// Check arguments validity
|
||||
if (($id_module && !is_numeric($id_module)) || !Validate::isHookName($hook_name)) {
|
||||
throw new PrestaShopException('Invalid id_module or hook_name');
|
||||
}
|
||||
|
||||
// If no modules associated to hook_name or recompatible hook name, we stop the function
|
||||
|
||||
if (!$module_list = Hook::getHookModuleExecList($hook_name)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Check if hook exists
|
||||
if (!$id_hook = Hook::getIdByName($hook_name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store list of executed hooks on this page
|
||||
Hook::$executed_hooks[$id_hook] = $hook_name;
|
||||
|
||||
$live_edit = false;
|
||||
$context = Context::getContext();
|
||||
if (!isset($hook_args['cookie']) || !$hook_args['cookie']) {
|
||||
$hook_args['cookie'] = $context->cookie;
|
||||
}
|
||||
if (!isset($hook_args['cart']) || !$hook_args['cart']) {
|
||||
$hook_args['cart'] = $context->cart;
|
||||
}
|
||||
|
||||
$retro_hook_name = Hook::getRetroHookName($hook_name);
|
||||
|
||||
// Look on modules list
|
||||
$altern = 0;
|
||||
$output = '';
|
||||
foreach ($module_list as $array) {
|
||||
|
||||
// Check errors
|
||||
if ($id_module && $id_module != $array['id_module'])
|
||||
continue;
|
||||
if (!($moduleInstance = Module::getInstanceByName($array['module'])))
|
||||
continue;
|
||||
|
||||
|
||||
// Check permissions
|
||||
$exceptions = $moduleInstance->getExceptions($array['id_hook']);
|
||||
if (in_array(Dispatcher::getInstance()->getController(), $exceptions)) {
|
||||
continue;
|
||||
}
|
||||
if (Validate::isLoadedObject($context->employee) && !$moduleInstance->getPermission('view', $context->employee)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check which / if method is callable
|
||||
|
||||
$hook_callable = is_callable(array($moduleInstance, 'hook'.$hook_name));
|
||||
$ohook = $orhook = "";
|
||||
$hook_retro_callable = is_callable(array($moduleInstance, 'hook'.$retro_hook_name));
|
||||
if (array_key_exists($moduleInstance->id, $this->overrideHooks)) {
|
||||
$ohook = Hook::getRetroHookName($this->overrideHooks[$moduleInstance->id]);
|
||||
$orhook = ($this->overrideHooks[$moduleInstance->id]);
|
||||
$hook_callable = is_callable(array($moduleInstance, 'hook'.$orhook));
|
||||
$hook_retro_callable = is_callable(array($moduleInstance, 'hook'.$ohook));
|
||||
}
|
||||
|
||||
if (($hook_callable || $hook_retro_callable)) {
|
||||
$hook_args['altern'] = ++$altern;
|
||||
if (array_key_exists($moduleInstance->id, $this->overrideHooks)) {
|
||||
if ($hook_callable) {
|
||||
$display = $moduleInstance->{'hook'.$orhook}($hook_args);
|
||||
} else if ($hook_retro_callable) {
|
||||
$display = $moduleInstance->{'hook'.$ohook}($hook_args);
|
||||
}
|
||||
} else {
|
||||
// Call hook method
|
||||
if ($hook_callable) {
|
||||
$display = $moduleInstance->{'hook'.$hook_name}($hook_args);
|
||||
} else if ($hook_retro_callable) {
|
||||
$display = $moduleInstance->{'hook'.$retro_hook_name}($hook_args);
|
||||
}
|
||||
}
|
||||
// Live edit
|
||||
if (isset($array['live_edit']) && $array['live_edit'] && Tools::isSubmit('live_edit') && Tools::getValue('ad') && Tools::getValue('liveToken') == Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee'))) {
|
||||
$live_edit = true;
|
||||
$output .= self::wrapLiveEdit($display, $moduleInstance, $array['id_hook']);
|
||||
} else {
|
||||
$output .= $display;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return html string
|
||||
return ($live_edit ? '<script type="text/javascript">hooks_list.push(\''.$hook_name.'\'); </script>
|
||||
<div id="'.$hook_name.'" class="dndHook" style="min-height:50px">' : '').$output.($live_edit ? '</div>' : '');
|
||||
}
|
||||
|
||||
public static function getPattern($theme)
|
||||
{
|
||||
$output = array();
|
||||
|
||||
$path = apPageHelper::getConfigDir('_PS_THEME_DIR_').'assets/img/patterns/';
|
||||
if ($theme && is_dir($path)) {
|
||||
$files = glob($path.'*');
|
||||
$i = 0;
|
||||
foreach ($files as $dir) {
|
||||
if (preg_match("#.png|.jpg|.gif#", $dir)) {
|
||||
$output[$i]['img_name'] = basename($dir);
|
||||
$output[$i]['img_url'] = _THEMES_DIR_.apPageHelper::getThemeName().'/assets/img/patterns/'.basename($dir);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* wrap html Live Edit
|
||||
*/
|
||||
public static function wrapLiveEdit($display, $moduleInstance, $id_hook)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* get array languages
|
||||
* @param : id_lang, name, active, iso_code, language_code, date_format_lite, date_format_full, is_rtl, id_shop, shops (array)
|
||||
* return array (
|
||||
* 1 => en,
|
||||
* 2 => vn,
|
||||
* )
|
||||
*/
|
||||
public static function getLangAtt($attribute = 'iso_code')
|
||||
{
|
||||
$languages = array();
|
||||
foreach (Language::getLanguages(false, false, false) as $lang) {
|
||||
$languages[] = $lang[$attribute];
|
||||
}
|
||||
return $languages;
|
||||
}
|
||||
|
||||
public static function getCookie()
|
||||
{
|
||||
$data = $_COOKIE;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param
|
||||
* 0 no multi_lang
|
||||
* 1 multi_lang follow id_lang
|
||||
* 2 multi_lnag follow code_lang
|
||||
* @return array
|
||||
*/
|
||||
public static function getPost($keys = array(), $multi_lang = 0)
|
||||
{
|
||||
$post = array();
|
||||
if ($multi_lang == 0) {
|
||||
foreach ($keys as $key) {
|
||||
// get value from $_POST
|
||||
$post[$key] = Tools::getValue($key);
|
||||
}
|
||||
} elseif ($multi_lang == 1) {
|
||||
|
||||
foreach ($keys as $key) {
|
||||
// get value multi language from $_POST
|
||||
if (method_exists('Language', 'getIDs')) {
|
||||
foreach (Language::getIDs(false) as $id_lang)
|
||||
$post[$key.'_'.(int)$id_lang] = Tools::getValue($key.'_'.(int)$id_lang);
|
||||
}
|
||||
}
|
||||
} elseif ($multi_lang == 2) {
|
||||
$languages = self::getLangAtt();
|
||||
foreach ($keys as $key) {
|
||||
// get value multi language from $_POST
|
||||
foreach ($languages as $id_code)
|
||||
$post[$key.'_'.$id_code] = Tools::getValue($key.'_'.$id_code);
|
||||
}
|
||||
}
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of special char
|
||||
* http://www.computerhope.com/keys.htm
|
||||
*/
|
||||
public static function ConvertSpecialChar($str = '')
|
||||
{
|
||||
$result = '';
|
||||
|
||||
if (is_string($str)) {
|
||||
$result = str_replace('LEO_BACKSLASH', '\\', $str);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function leoExitsDb($type='', $table_name='', $col_name='')
|
||||
{
|
||||
if ($type == 'table') {
|
||||
# EXITS TABLE
|
||||
$sql = 'SELECT COUNT(*) FROM information_schema.tables
|
||||
WHERE table_schema = "'._DB_NAME_.'"
|
||||
AND table_name = "'._DB_PREFIX_.pSQL($table_name).'"';
|
||||
$table = Db::getInstance()->getValue($sql);
|
||||
if (empty($table)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
} else if ($type == 'column') {
|
||||
# EXITS COLUMN
|
||||
$sql = 'SHOW FIELDS FROM `'._DB_PREFIX_.pSQL($table_name) .'` LIKE "'.pSQL($col_name).'"';
|
||||
$column = Db::getInstance()->executeS($sql);
|
||||
if (empty($column)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function leoCreateColumn($table_name, $col_name, $data_type)
|
||||
{
|
||||
$sql = 'SHOW FIELDS FROM `'._DB_PREFIX_.pSQL($table_name) .'` LIKE "'.pSQL($col_name).'"';
|
||||
$column = Db::getInstance()->executeS($sql);
|
||||
|
||||
if (empty($column)) {
|
||||
$sql = 'ALTER TABLE `'._DB_PREFIX_.pSQL($table_name).'` ADD COLUMN `'.pSQL($col_name).'` '.pSQL($data_type);
|
||||
$res = Db::getInstance()->execute($sql);
|
||||
}
|
||||
}
|
||||
|
||||
public static function leoEditColumn($table_name, $col_name, $data_type)
|
||||
{
|
||||
$sql = 'SHOW FIELDS FROM `'._DB_PREFIX_.pSQL($table_name) .'` LIKE "'.pSQL($col_name).'"';
|
||||
$column = Db::getInstance()->executeS($sql);
|
||||
|
||||
if (!empty($column)) {
|
||||
$sql = 'ALTER TABLE `'._DB_PREFIX_.pSQL($table_name).'` MODIFY `'.pSQL($col_name).'` '.pSQL($data_type);
|
||||
$res = Db::getInstance()->execute($sql);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy from leotemcp module
|
||||
* Do not write more in this class, please write to 'class apPageHelper' in helper.php file
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
132
modules/appagebuilder/libs/LeoFriendlyUrl.php
Normal file
132
modules/appagebuilder/libs/LeoFriendlyUrl.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
if (!class_exists("LeoFriendlyUrl")) {
|
||||
|
||||
class LeoFriendlyUrl {
|
||||
|
||||
/** @var string[] Adds excluded $_GET keys for redirection */
|
||||
public $redirectionExtraExcludedKeys = array();
|
||||
|
||||
public static function getInstance() {
|
||||
static $_instance;
|
||||
if (!$_instance) {
|
||||
$_instance = new LeoFriendlyUrl();
|
||||
}
|
||||
return $_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* REFERRENCE ROOT\classes\Link.php
|
||||
* function getProductLink()
|
||||
*/
|
||||
// public function getApPagebuilderLink() {
|
||||
//
|
||||
// $link = Context::getContext()->link;
|
||||
// $idLang = Context::getContext()->language->id;
|
||||
// $idShop = null;
|
||||
// $relativeProtocol = false;
|
||||
//
|
||||
// $url = $link->getBaseLink($idShop, null, $relativeProtocol).$this->getLangLink($idLang, null, $idShop).$profile_data['friendly_url'];
|
||||
//
|
||||
// return $url;
|
||||
// }
|
||||
|
||||
/**
|
||||
* REFERRENCE ROOT\classes\Link.php
|
||||
* CORE function not PUBLIC
|
||||
*/
|
||||
public function getLangLink($idLang = null, Context $context = null, $idShop = null)
|
||||
{
|
||||
$this->allow = (int) Configuration::get('PS_REWRITING_SETTINGS');
|
||||
|
||||
static $psRewritingSettings = null;
|
||||
if ($psRewritingSettings === null) {
|
||||
$psRewritingSettings = (int) Configuration::get('PS_REWRITING_SETTINGS', null, null, $idShop);
|
||||
}
|
||||
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
}
|
||||
|
||||
if ((!$this->allow && in_array($idShop, array($context->shop->id, null))) || !Language::isMultiLanguageActivated($idShop) || !$psRewritingSettings) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!$idLang) {
|
||||
$idLang = $context->language->id;
|
||||
}
|
||||
|
||||
return Language::getIsoById($idLang).'/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirects to canonical URL.
|
||||
* REFERRENCE ROOT\classes\controller\FrontController.php
|
||||
* @param string $canonical_url
|
||||
*/
|
||||
public function canonicalRedirection($canonical_url = '') {
|
||||
if (!$canonical_url || !Configuration::get('PS_CANONICAL_REDIRECT') || strtoupper($_SERVER['REQUEST_METHOD']) != 'GET') {
|
||||
return;
|
||||
}
|
||||
|
||||
$canonical_url = preg_replace('/#.*$/', '', $canonical_url);
|
||||
|
||||
$match_url = rawurldecode(Tools::getCurrentUrlProtocolPrefix() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
||||
if (!preg_match('/^' . Tools::pRegexp(rawurldecode($canonical_url), '/') . '([&?].*)?$/', $match_url)) {
|
||||
$params = array();
|
||||
$url_details = parse_url($canonical_url);
|
||||
|
||||
if (!empty($url_details['query'])) {
|
||||
parse_str($url_details['query'], $query);
|
||||
foreach ($query as $key => $value) {
|
||||
$params[Tools::safeOutput($key)] = Tools::safeOutput($value);
|
||||
}
|
||||
}
|
||||
$excluded_key = array('isolang', 'id_lang', 'controller', 'fc', 'id_product', 'id_category', 'id_manufacturer', 'id_supplier', 'id_cms', 'id_appagebuilder_profiles');
|
||||
$excluded_key = array_merge($excluded_key, $this->redirectionExtraExcludedKeys);
|
||||
foreach ($_GET as $key => $value) {
|
||||
if (!in_array($key, $excluded_key) && Validate::isUrl($key) && Validate::isUrl($value)) {
|
||||
$params[Tools::safeOutput($key)] = Tools::safeOutput($value);
|
||||
}
|
||||
}
|
||||
|
||||
$str_params = http_build_query($params, '', '&');
|
||||
if (!empty($str_params)) {
|
||||
$final_url = preg_replace('/^([^?]*)?.*$/', '$1', $canonical_url) . '?' . $str_params;
|
||||
} else {
|
||||
$final_url = preg_replace('/^([^?]*)?.*$/', '$1', $canonical_url);
|
||||
}
|
||||
|
||||
// Don't send any cookie
|
||||
Context::getContext()->cookie->disallowWriting();
|
||||
if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_ && $_SERVER['REQUEST_URI'] != __PS_BASE_URI__) {
|
||||
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $final_url . '">' . $final_url . '</a>');
|
||||
}
|
||||
|
||||
$redirect_type = Configuration::get('PS_CANONICAL_REDIRECT') == 2 ? '301' : '302';
|
||||
header('HTTP/1.0 ' . $redirect_type . ' Moved');
|
||||
header('Cache-Control: no-cache');
|
||||
Tools::redirectLink($final_url);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
59
modules/appagebuilder/libs/LeoOptimization.php
Normal file
59
modules/appagebuilder/libs/LeoOptimization.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class LeoOptimization {
|
||||
|
||||
public static function getInstance() {
|
||||
static $_instance;
|
||||
if (!$_instance) {
|
||||
$_instance = new LeoOptimization();
|
||||
}
|
||||
return $_instance;
|
||||
}
|
||||
|
||||
public function isEnable()
|
||||
{
|
||||
return false; # turn off optimization
|
||||
}
|
||||
|
||||
public function processOptimization(&$params)
|
||||
{
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function gtmetrix($html='')
|
||||
{
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace link from DOMAIN to CDN
|
||||
*/
|
||||
public function setCDN($html='')
|
||||
{
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function checkGoogle($html='')
|
||||
{
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
50
modules/appagebuilder/libs/LeoProcessData.php
Normal file
50
modules/appagebuilder/libs/LeoProcessData.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class LeoProcessData
|
||||
{
|
||||
public static function getManufacturersSelect($params)
|
||||
{
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
//fix for previos version
|
||||
if ($params['order_by'] == 'position') {
|
||||
$params['order_by'] = 'id_manufacturer';
|
||||
}
|
||||
if (isset($params['order_way']) && $params['order_way'] == 'random') {
|
||||
$order = ' RAND()';
|
||||
} else {
|
||||
$order = (isset($params['order_by']) ? ' '.pSQL($params['order_by']) : '').(isset($params['order_way']) ? ' '.pSQL($params['order_way']) : '');
|
||||
}
|
||||
$sql = 'SELECT m.*, ml.`description`, ml.`short_description`
|
||||
FROM `'._DB_PREFIX_.'manufacturer` m
|
||||
'.Shop::addSqlAssociation('manufacturer', 'm').'
|
||||
INNER JOIN `'._DB_PREFIX_.'manufacturer_lang` ml ON (m.`id_manufacturer` = ml.`id_manufacturer` AND ml.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE m.`active` = 1 '.(isset($params['manuselect']) ? 'AND m.`id_manufacturer` IN ('.pSQL($params['manuselect']).')' : '').'
|
||||
ORDER BY '.$order;
|
||||
$manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
if ($manufacturers === false) {
|
||||
return false;
|
||||
}
|
||||
$total_manufacturers = count($manufacturers);
|
||||
$rewrite_settings = (int)Configuration::get('PS_REWRITING_SETTINGS');
|
||||
for ($i = 0; $i < $total_manufacturers; $i++)
|
||||
$manufacturers[$i]['link_rewrite'] = ($rewrite_settings ? Tools::link_rewrite($manufacturers[$i]['name']) : 0);
|
||||
return $manufacturers;
|
||||
}
|
||||
}
|
||||
88
modules/appagebuilder/libs/apValidate.php
Normal file
88
modules/appagebuilder/libs/apValidate.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
class Leoblog
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class LeoSliderLayer
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class LeoSlideShow
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class LeoLessParser
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class Leobootstrapmenu
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class ProductListingPresenter
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class ImageRetriever
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class PriceFormatter
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class ProductColorsRetriever
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class LeoBlogHelper
|
||||
{
|
||||
public static function getInstance()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class LeoBlogConfig
|
||||
{
|
||||
public static function getInstance()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class BtmegamenuGroup
|
||||
{
|
||||
public static function cacheGroupsByFields($params = array(), $one = false)
|
||||
{
|
||||
$result = array();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
10138
modules/appagebuilder/libs/google_fonts.php
Normal file
10138
modules/appagebuilder/libs/google_fonts.php
Normal file
File diff suppressed because it is too large
Load Diff
35
modules/appagebuilder/libs/index.php
Normal file
35
modules/appagebuilder/libs/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2019 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;
|
||||
780
modules/appagebuilder/libs/setup.php
Normal file
780
modules/appagebuilder/libs/setup.php
Normal file
@@ -0,0 +1,780 @@
|
||||
<?php
|
||||
/*
|
||||
* @Website: apollotheme.com - prestashop template provider
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2016 Apollotheme
|
||||
* @description: ApPageBuilder is module help you can build content for your shop
|
||||
*/
|
||||
if (!class_exists("ApPageSetup")) {
|
||||
|
||||
class ApPageSetup
|
||||
{
|
||||
|
||||
public static function getTabs()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'class_name' => 'AdminApPageBuilderProfiles',
|
||||
'name' => 'Ap Profiles Manage',
|
||||
),
|
||||
array(
|
||||
'class_name' => 'AdminApPageBuilderPositions',
|
||||
'name' => 'Ap Positions Manage',
|
||||
),
|
||||
array(
|
||||
'class_name' => 'AdminApPageBuilderShortcode',
|
||||
'name' => 'Ap ShortCode Manage',
|
||||
),
|
||||
array(
|
||||
'class_name' => 'AdminApPageBuilderHome',
|
||||
'name' => 'Ap Hook Builder',
|
||||
'id_parent' => -1,
|
||||
),
|
||||
array(
|
||||
'class_name' => 'AdminApPageBuilderProducts',
|
||||
'name' => 'Ap Products List Builder',
|
||||
),
|
||||
array(
|
||||
'class_name' => 'AdminApPageBuilderDetails',
|
||||
'name' => 'Ap Products Details Builder',
|
||||
),
|
||||
array(
|
||||
'class_name' => 'AdminApPageBuilderHook',
|
||||
'name' => 'Ap Hook Control Panel',
|
||||
),
|
||||
array(
|
||||
'class_name' => 'AdminApPageBuilderThemeEditor',
|
||||
'name' => 'Ap Live Theme Editor',
|
||||
),
|
||||
array(
|
||||
'class_name' => 'AdminApPageBuilderModule',
|
||||
'name' => 'Ap Module Configuration',
|
||||
),
|
||||
array(
|
||||
'class_name' => 'AdminApPageBuilderThemeConfiguration',
|
||||
'name' => 'Ap Theme Configuration',
|
||||
),
|
||||
array(
|
||||
'class_name' => 'AdminApPageBuilderImages',
|
||||
'name' => 'Ap Image Manage',
|
||||
'id_parent' => -1,
|
||||
),
|
||||
array(
|
||||
'class_name' => 'AdminApPageBuilderShortcodes',
|
||||
'name' => 'Ap Shortcodes Builder',
|
||||
'id_parent' => -1,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public static function createTables($reset = 0)
|
||||
{
|
||||
if ($reset == 0 && file_exists(_PS_MODULE_DIR_.'appagebuilder')) {
|
||||
require_once(_PS_MODULE_DIR_.'appagebuilder/libs/LeoDataSample.php');
|
||||
|
||||
$sample = new Datasample();
|
||||
if ($sample->processImport('appagebuilder')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$drop = '';
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_profiles`;';
|
||||
}
|
||||
//each shop will have one or more profile
|
||||
$res = (bool)Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_profiles` (
|
||||
`id_appagebuilder_profiles` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255),
|
||||
`group_box` varchar(255),
|
||||
`profile_key` varchar(255),
|
||||
`page` varchar(255),
|
||||
`params` text,
|
||||
`header` int(11) unsigned NOT NULL,
|
||||
`content` int(11) unsigned NOT NULL,
|
||||
`footer` int(11) unsigned NOT NULL,
|
||||
`product` int(11) unsigned NOT NULL,
|
||||
`active` TINYINT(1),
|
||||
`active_mobile` TINYINT(1),
|
||||
`active_tablet` TINYINT(1),
|
||||
PRIMARY KEY (`id_appagebuilder_profiles`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_profiles_lang`;';
|
||||
}
|
||||
$res &= Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_profiles_lang` (
|
||||
`id_appagebuilder_profiles` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_lang` int(10) unsigned NOT NULL,
|
||||
`friendly_url` varchar(255),
|
||||
`meta_title` varchar(255),
|
||||
`meta_description` varchar(255),
|
||||
`meta_keywords` varchar(255),
|
||||
PRIMARY KEY (`id_appagebuilder_profiles`, `id_lang`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_profiles_shop`;';
|
||||
}
|
||||
$res &= Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_profiles_shop` (
|
||||
`id_appagebuilder_profiles` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_shop` int(10) unsigned NOT NULL,
|
||||
`active` TINYINT(1),
|
||||
`active_mobile` TINYINT(1),
|
||||
`active_tablet` TINYINT(1),
|
||||
PRIMARY KEY (`id_appagebuilder_profiles`, `id_shop`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_products`;';
|
||||
}
|
||||
//we can create product item for each shop
|
||||
$res &= (bool)Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_products` (
|
||||
`id_appagebuilder_products` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`plist_key` varchar(255),
|
||||
`name` varchar(255),
|
||||
`class` varchar(255),
|
||||
`params` text,
|
||||
`type` TINYINT(1),
|
||||
`active` TINYINT(1),
|
||||
`active_mobile` TINYINT(1),
|
||||
`active_tablet` TINYINT(1),
|
||||
PRIMARY KEY (`id_appagebuilder_products`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_products_shop`;';
|
||||
}
|
||||
$res &= Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_products_shop` (
|
||||
`id_appagebuilder_products` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_shop` int(10) unsigned NOT NULL,
|
||||
`active` TINYINT(1),
|
||||
`active_mobile` TINYINT(1),
|
||||
`active_tablet` TINYINT(1),
|
||||
PRIMARY KEY (`id_appagebuilder_products`, `id_shop`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
$res &= (bool)Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_details` (
|
||||
`id_appagebuilder_details` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`plist_key` varchar(255),
|
||||
`name` varchar(255),
|
||||
`class_detail` varchar(255),
|
||||
`url_img_preview` varchar(255),
|
||||
`params` text,
|
||||
`type` TINYINT(1),
|
||||
`active` TINYINT(1),
|
||||
`active_mobile` TINYINT(1),
|
||||
`active_tablet` TINYINT(1),
|
||||
PRIMARY KEY (`id_appagebuilder_details`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_details_shop`;';
|
||||
}
|
||||
$res &= Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_details_shop` (
|
||||
`id_appagebuilder_details` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_shop` int(10) unsigned NOT NULL,
|
||||
`active` TINYINT(1),
|
||||
`active_mobile` TINYINT(1),
|
||||
`active_tablet` TINYINT(1),
|
||||
PRIMARY KEY (`id_appagebuilder_details`, `id_shop`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder`;';
|
||||
}
|
||||
$res &= (bool)Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder` (
|
||||
`id_appagebuilder` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_appagebuilder_positions` int(11) NOT NULL,
|
||||
`hook_name` varchar(255),
|
||||
`id_appagebuilder_shortcode` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id_appagebuilder`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_shop`;';
|
||||
}
|
||||
$res &= Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_shop` (
|
||||
`id_appagebuilder` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_shop` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_appagebuilder`, `id_shop`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_lang`;';
|
||||
}
|
||||
$res &= Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_lang` (
|
||||
`id_appagebuilder` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_lang` int(10) unsigned NOT NULL,
|
||||
`params` MEDIUMTEXT,
|
||||
PRIMARY KEY (`id_appagebuilder`, `id_lang`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
|
||||
');
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_positions`;';
|
||||
}
|
||||
$res &= Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_positions` (
|
||||
`id_appagebuilder_positions` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`position` varchar(255) NOT NULL,
|
||||
`position_key` varchar(255) NOT NULL,
|
||||
`params` text,
|
||||
PRIMARY KEY (`id_appagebuilder_positions`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_positions_shop`;';
|
||||
}
|
||||
$res &= Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_positions_shop` (
|
||||
`id_appagebuilder_positions` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`id_shop` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_appagebuilder_positions`, `id_shop`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_page_shop`;';
|
||||
}
|
||||
$res &= Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_page` (
|
||||
`id_product` int(11) unsigned NOT NULL,
|
||||
`id_category` int(11) unsigned NOT NULL,
|
||||
`page` varchar(255) NOT NULL,
|
||||
`id_shop` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_product`, `id_category`, `id_shop`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
//DONGND:: create table for ap shortcode
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_shortcode`;';
|
||||
}
|
||||
$res &= Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_shortcode` (
|
||||
`id_appagebuilder_shortcode` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`shortcode_key` varchar(255) NOT NULL,
|
||||
`active` TINYINT(1),
|
||||
PRIMARY KEY (`id_appagebuilder_shortcode`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
//DONGND:: create table for ap shortcode (lang)
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_shortcode_lang`;';
|
||||
}
|
||||
$res &= Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_shortcode_lang` (
|
||||
`id_appagebuilder_shortcode` int(11) unsigned NOT NULL,
|
||||
`id_lang` int(10) unsigned NOT NULL,
|
||||
`shortcode_name` text NOT NULL,
|
||||
PRIMARY KEY (`id_appagebuilder_shortcode`, `id_lang`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
//DONGND:: create table for ap shortcode (shop)
|
||||
if ($reset == 1) {
|
||||
$drop = 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'appagebuilder_shortcode_shop`;';
|
||||
}
|
||||
$res &= Db::getInstance()->execute($drop.'
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'appagebuilder_shortcode_shop` (
|
||||
`id_appagebuilder_shortcode` int(11) unsigned NOT NULL,
|
||||
`id_shop` int(10) unsigned NOT NULL,
|
||||
`active` TINYINT(1),
|
||||
PRIMARY KEY (`id_appagebuilder_shortcode`, `id_shop`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;
|
||||
');
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function installSample()
|
||||
{
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
|
||||
//table appagebuilder_profiles
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'appagebuilder_profiles`');
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'appagebuilder_profiles` (`id_appagebuilder_profiles`, `name`, `profile_key`, `page`, `params`, `header`, `content`, `footer`, `product`, `active`) VALUES
|
||||
(1, \'Home page\', \'profile1426561433\', \'index\', \'{"displayTopColumn":{"exception":[""]},"displayHome":{"exception":[""]},"fullwidth_index_hook":{"displayBanner":0,"displayNav":0,"displayTop":"1","displayTopColumn":"1","displayHome":0,"displayFooter":0},"fullwidth_other_hook":{"displayBanner":0,"displayNav":0,"displayTop":0,"displayTopColumn":0,"displayFooter":0}}\', 1, 2, 27, 4, NULL),
|
||||
(2, \'Detail demo\', \'profile1426579529\', \'index\', \'{"displayTopColumn":{"exception":[""]},"displayHome":{"exception":[""]},"fullwidth_index_hook":{"displayBanner":0,"displayNav":0,"displayTop":"1","displayTopColumn":"1","displayHome":0,"displayFooter":0},"fullwidth_other_hook":{"displayBanner":0,"displayNav":0,"displayTop":0,"displayTopColumn":0,"displayFooter":0}}\', 5, 6, 28, 8, NULL),
|
||||
(3, \'Home page 1\', \'profile1427119013\', \'index\', \'{"displayHome":{"exception":[""]}}\', 9, 10, 25, 12, NULL),
|
||||
(4, \'Home page 2\', \'profile1427116699\', \'index\', \'{"displayTopColumn":{"exception":[""]},"displayHome":{"exception":[""]}}\', 13, 14, 26, 16, NULL),
|
||||
(5, \'Home page 3\', \'profile1427805353\', \'index\', \'{"displayTopColumn":{"exception":[""]},"displayHome":{"exception":[""]},"fullwidth_index_hook":{"displayBanner":0,"displayNav":0,"displayTop":"1","displayTopColumn":"1","displayHome":0,"displayFooter":0},"fullwidth_other_hook":{"displayBanner":0,"displayNav":0,"displayTop":0,"displayTopColumn":0,"displayHome":0,"displayFooter":0}}\', 21, 22, 29, 24, NULL);';
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
//table appagebuilder_profiles_shop
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'appagebuilder_profiles_shop`');
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'appagebuilder_profiles_shop` (`id_appagebuilder_profiles`, `id_shop`, `active`) VALUES
|
||||
(1, ID_SHOP, 0),
|
||||
(2, ID_SHOP, 0),
|
||||
(3, ID_SHOP, 1),
|
||||
(4, ID_SHOP, 0),
|
||||
(5, ID_SHOP, 0);';
|
||||
$sql = str_replace('ID_SHOP', (int)$id_shop, $sql);
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
//table appagebuilder_positions
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'appagebuilder_positions`');
|
||||
$sql = "INSERT INTO `"._DB_PREFIX_."appagebuilder_positions` (`id_appagebuilder_positions`, `name`, `position`, `position_key`, `params`) VALUES
|
||||
(1, 'header1426579629', 'header', 'position1426579629', NULL),
|
||||
(2, 'content1426564879', 'content', 'position1426564879', NULL),
|
||||
(3, 'footer1426566238', 'footer', 'position1426566238', NULL),
|
||||
(4, 'product1426580519', 'product', 'position1426580519', NULL),
|
||||
(5, 'header1426564187', 'header', 'position1426564187', NULL),
|
||||
(6, 'content1426564490', 'content', 'position1426564490', NULL),
|
||||
(7, 'footer1426578355', 'footer', 'position1426578355', NULL),
|
||||
(8, 'product1426581801', 'product', 'position1426581801', NULL),
|
||||
(9, 'header1427111294', 'header', 'position1427111294', NULL),
|
||||
(10, 'content1427129695', 'content', 'position1427129695', NULL),
|
||||
(11, 'footer1427107373', 'footer', 'position1427107373', NULL),
|
||||
(12, 'product1427129206', 'product', 'position1427129206', NULL),
|
||||
(13, 'header1427138535', 'header', 'position1427138535', NULL),
|
||||
(14, 'content1427116604', 'content', 'position1427116604', NULL),
|
||||
(15, 'footer1427111534', 'footer', 'position1427111534', NULL),
|
||||
(16, 'product1427111243', 'product', 'position1427111243', NULL),
|
||||
(17, 'header1427806687', 'header', 'position1427806687', NULL),
|
||||
(18, 'content1427819338', 'content', 'position1427819338', NULL),
|
||||
(19, 'footer1427821311', 'footer', 'position1427821311', NULL),
|
||||
(20, 'product1427816721', 'product', 'position1427816721', NULL),
|
||||
(21, 'header1434016210', 'header', 'position1434016210', NULL),
|
||||
(22, 'content1434021220', 'content', 'position1434021220', NULL),
|
||||
(23, 'footer1434021922', 'footer', 'position1434021922', NULL),
|
||||
(24, 'product1434038427', 'product', 'position1434038427', NULL),
|
||||
(25, 'footer1435143282', 'footer', 'position1435143282', NULL),
|
||||
(26, 'footer1435158937', 'footer', 'position1435158937', NULL),
|
||||
(27, 'footer1435144169', 'footer', 'position1435144169', NULL),
|
||||
(28, 'footer1435153254', 'footer', 'position1435153254', NULL),
|
||||
(29, 'footer1435237119', 'footer', 'position1435237119', NULL);";
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
//table appagebuilder_positions_shop
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'appagebuilder_positions_shop`');
|
||||
$sql = "INSERT INTO `"._DB_PREFIX_."appagebuilder_positions_shop` (`id_appagebuilder_positions`, `id_shop`) VALUES
|
||||
(1, ID_SHOP),
|
||||
(2, ID_SHOP),
|
||||
(4, ID_SHOP),
|
||||
(5, ID_SHOP),
|
||||
(6, ID_SHOP),
|
||||
(8, ID_SHOP),
|
||||
(9, ID_SHOP),
|
||||
(10, ID_SHOP),
|
||||
(12, ID_SHOP),
|
||||
(13, ID_SHOP),
|
||||
(14, ID_SHOP),
|
||||
(16, ID_SHOP),
|
||||
(21, ID_SHOP),
|
||||
(22, ID_SHOP),
|
||||
(24, ID_SHOP),
|
||||
(25, ID_SHOP),
|
||||
(26, ID_SHOP),
|
||||
(27, ID_SHOP),
|
||||
(28, ID_SHOP),
|
||||
(29, ID_SHOP),
|
||||
(30, ID_SHOP);";
|
||||
$sql = str_replace('ID_SHOP', (int)$id_shop, $sql);
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
//table appagebuilder
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'appagebuilder`');
|
||||
$sql = "INSERT INTO `"._DB_PREFIX_."appagebuilder` (`id_appagebuilder`, `id_appagebuilder_positions`, `hook_name`) VALUES
|
||||
(1, 1, 'displayBanner'),
|
||||
(2, 1, 'displayNav'),
|
||||
(3, 1, 'displayTop'),
|
||||
(4, 2, 'displayTopColumn'),
|
||||
(5, 2, 'displayLeftColumn'),
|
||||
(6, 2, 'displayHome'),
|
||||
(7, 2, 'displayRightColumn'),
|
||||
(8, 3, 'displayFooter'),
|
||||
(9, 4, 'displayFooterProduct'),
|
||||
(10, 4, 'displayRightColumnProduct'),
|
||||
(11, 5, 'displayBanner'),
|
||||
(12, 5, 'displayNav'),
|
||||
(13, 5, 'displayTop'),
|
||||
(14, 6, 'displayTopColumn'),
|
||||
(15, 6, 'displayLeftColumn'),
|
||||
(16, 6, 'displayHome'),
|
||||
(17, 6, 'displayRightColumn'),
|
||||
(18, 7, 'displayFooter'),
|
||||
(19, 8, 'displayFooterProduct'),
|
||||
(20, 8, 'displayRightColumnProduct'),
|
||||
(21, 9, 'displayBanner'),
|
||||
(22, 9, 'displayNav'),
|
||||
(23, 9, 'displayTop'),
|
||||
(24, 10, 'displayTopColumn'),
|
||||
(25, 10, 'displayLeftColumn'),
|
||||
(26, 10, 'displayHome'),
|
||||
(27, 10, 'displayRightColumn'),
|
||||
(28, 11, 'displayFooter'),
|
||||
(29, 12, 'displayFooterProduct'),
|
||||
(30, 12, 'displayRightColumnProduct'),
|
||||
(31, 13, 'displayBanner'),
|
||||
(32, 13, 'displayNav'),
|
||||
(33, 13, 'displayTop'),
|
||||
(34, 14, 'displayTopColumn'),
|
||||
(35, 14, 'displayLeftColumn'),
|
||||
(36, 14, 'displayHome'),
|
||||
(37, 14, 'displayRightColumn'),
|
||||
(38, 15, 'displayFooter'),
|
||||
(39, 16, 'displayFooterProduct'),
|
||||
(40, 16, 'displayRightColumnProduct'),
|
||||
(41, 17, 'displayBanner'),
|
||||
(42, 17, 'displayNav'),
|
||||
(43, 17, 'displayTop'),
|
||||
(44, 18, 'displayTopColumn'),
|
||||
(45, 18, 'displayLeftColumn'),
|
||||
(46, 18, 'displayHome'),
|
||||
(47, 18, 'displayRightColumn'),
|
||||
(48, 19, 'displayFooter'),
|
||||
(49, 20, 'displayFooterProduct'),
|
||||
(50, 20, 'displayRightColumnProduct'),
|
||||
(51, 21, 'displayBanner'),
|
||||
(52, 21, 'displayNav'),
|
||||
(53, 21, 'displayTop'),
|
||||
(54, 22, 'displayTopColumn'),
|
||||
(55, 22, 'displayLeftColumn'),
|
||||
(56, 22, 'displayHome'),
|
||||
(57, 22, 'displayRightColumn'),
|
||||
(58, 23, 'displayFooter'),
|
||||
(59, 24, 'displayFooterProduct'),
|
||||
(60, 24, 'displayRightColumnProduct'),
|
||||
(61, 25, 'displayFooter'),
|
||||
(62, 26, 'displayFooter'),
|
||||
(63, 27, 'displayFooter'),
|
||||
(64, 28, 'displayFooter'),
|
||||
(65, 29, 'displayFooter');";
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
|
||||
//table appagebuilder_lang
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'appagebuilder_lang`');
|
||||
|
||||
$sqlArray[] = Tools::file_get_contents( apPageHelper::getShortcodeTemplatePath('setup.txt'));
|
||||
$languages = Language::getLanguages(false);
|
||||
foreach ($sqlArray as $sql) {
|
||||
foreach ($languages as $lang) {
|
||||
$sqlRun = str_replace('ID_LANG', (int)$lang["id_lang"], $sql);
|
||||
$sqlRun = str_replace('_DB_PREFIX_', _DB_PREFIX_, $sqlRun);
|
||||
Db::getInstance()->execute($sqlRun);
|
||||
}
|
||||
}
|
||||
|
||||
//table appagebuilder_shop
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'appagebuilder_shop`');
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'appagebuilder_shop` (`id_appagebuilder`, `id_shop`) VALUES
|
||||
(1, ID_SHOP),
|
||||
(2, ID_SHOP),
|
||||
(3, ID_SHOP),
|
||||
(4, ID_SHOP),
|
||||
(5, ID_SHOP),
|
||||
(6, ID_SHOP),
|
||||
(7, ID_SHOP),
|
||||
(8, ID_SHOP),
|
||||
(9, ID_SHOP),
|
||||
(10, ID_SHOP),
|
||||
(11, ID_SHOP),
|
||||
(12, ID_SHOP),
|
||||
(13, ID_SHOP),
|
||||
(14, ID_SHOP),
|
||||
(15, ID_SHOP),
|
||||
(16, ID_SHOP),
|
||||
(17, ID_SHOP),
|
||||
(18, ID_SHOP),
|
||||
(19, ID_SHOP),
|
||||
(20, ID_SHOP),
|
||||
(21, ID_SHOP),
|
||||
(22, ID_SHOP),
|
||||
(23, ID_SHOP),
|
||||
(24, ID_SHOP),
|
||||
(25, ID_SHOP),
|
||||
(26, ID_SHOP),
|
||||
(27, ID_SHOP),
|
||||
(28, ID_SHOP),
|
||||
(29, ID_SHOP),
|
||||
(30, ID_SHOP),
|
||||
(31, ID_SHOP),
|
||||
(32, ID_SHOP),
|
||||
(33, ID_SHOP),
|
||||
(34, ID_SHOP),
|
||||
(35, ID_SHOP),
|
||||
(36, ID_SHOP),
|
||||
(37, ID_SHOP),
|
||||
(38, ID_SHOP),
|
||||
(39, ID_SHOP),
|
||||
(40, ID_SHOP),
|
||||
(41, ID_SHOP),
|
||||
(42, ID_SHOP),
|
||||
(43, ID_SHOP),
|
||||
(44, ID_SHOP),
|
||||
(45, ID_SHOP),
|
||||
(46, ID_SHOP),
|
||||
(47, ID_SHOP),
|
||||
(48, ID_SHOP),
|
||||
(49, ID_SHOP),
|
||||
(50, ID_SHOP),
|
||||
(51, ID_SHOP),
|
||||
(52, ID_SHOP),
|
||||
(53, ID_SHOP),
|
||||
(54, ID_SHOP),
|
||||
(55, ID_SHOP),
|
||||
(56, ID_SHOP),
|
||||
(57, ID_SHOP),
|
||||
(58, ID_SHOP),
|
||||
(59, ID_SHOP),
|
||||
(60, ID_SHOP),
|
||||
(61, ID_SHOP),
|
||||
(62, ID_SHOP),
|
||||
(63, ID_SHOP),
|
||||
(64, ID_SHOP),
|
||||
(65, ID_SHOP);';
|
||||
$sql = str_replace('ID_SHOP', (int)$id_shop, $sql);
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
//table appagebuilder_products
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'appagebuilder_products`');
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'appagebuilder_products` (`id_appagebuilder_products`, `plist_key`, `name`, `params`, `type`, `class`, `active`) VALUES
|
||||
(1, \'plist1427203522\', \'plist1427203522\', \'{"gridLeft":{"0":{"name":"image_container"},"1":{"name":"quick_view"}},"gridRight":{"0":{"name":"price"},"1":{"name":"reviews"},"2":{"name":"name"},"3":{"name":"functional_buttons","element":{"0":{"name":"wishlist"},"1":{"name":"add_to_cart"},"2":{"name":"compare"}}}}}\', 0, \'\', NULL);';
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
//table appagebuilder_products_shop
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'appagebuilder_products_shop`');
|
||||
$sql = 'INSERT INTO `'._DB_PREFIX_.'appagebuilder_products_shop` (`id_appagebuilder_products`, `id_shop`, `active`) VALUES
|
||||
(1, ID_SHOP, 1)';
|
||||
$sql = str_replace('ID_SHOP', (int)$id_shop, $sql);
|
||||
Db::getInstance()->execute($sql);
|
||||
|
||||
//copy product profile
|
||||
$folder = apPageHelper::getConfigDir('theme_profiles');
|
||||
if (!is_dir($folder)) {
|
||||
mkdir($folder, 0755, true);
|
||||
}
|
||||
$tpl_grid = Tools::file_get_contents(_PS_MODULE_DIR_.'appagebuilder/views/templates/front/product-item/plist1427203522.tpl');
|
||||
ApPageSetting::writeFile($folder, 'plist1427203522.tpl', $tpl_grid);
|
||||
}
|
||||
|
||||
public static function installModuleTab()
|
||||
{
|
||||
$id_parent = Tab::getIdFromClassName('IMPROVE');
|
||||
|
||||
//create parent tab
|
||||
$newtab = new Tab();
|
||||
$newtab->class_name = 'AdminApPageBuilder';
|
||||
$newtab->id_parent = $id_parent;
|
||||
$newtab->module = 'appagebuilder';
|
||||
foreach (Language::getLanguages(false) as $l) {
|
||||
$newtab->name[$l['id_lang']] = Context::getContext()->getTranslator()->trans('Ap PageBuilder', array(), 'Modules.Appagebuilder.Admin');
|
||||
}
|
||||
|
||||
if ($newtab->save()) {
|
||||
|
||||
$id_parent = $newtab->id;
|
||||
# insert icon for tab
|
||||
Db::getInstance()->execute(' UPDATE `'._DB_PREFIX_.'tab` SET `icon` = "tab" WHERE `id_tab` = "'.(int)$newtab->id.'"');
|
||||
|
||||
foreach (self::getTabs() as $tab) {
|
||||
$newtab = new Tab();
|
||||
$newtab->class_name = $tab['class_name'];
|
||||
$newtab->id_parent = isset($tab['id_parent']) ? $tab['id_parent'] : $id_parent;
|
||||
$newtab->module = 'appagebuilder';
|
||||
foreach (Language::getLanguages(false) as $l) {
|
||||
$newtab->name[$l['id_lang']] = Context::getContext()->getTranslator()->trans($tab['name'], array(), 'Modules.Appagebuilder.Admin');
|
||||
}
|
||||
$newtab->save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function installConfiguration()
|
||||
{
|
||||
$res = true;
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_PRODUCT_MAX_RANDOM', 2);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_GUIDE', 1);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_OWL', 1);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_STELLAR', 1);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_WAYPOINTS', 1);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_INSTAFEED', 0);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_HTML5VIDEO', 0);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_SAVE_MULTITHREARING', 1);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_FULLPAGEJS', 0);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_IMAGE360', 0);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_IMAGEHOTPOT', 0);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_SAVE_SUBMIT', 1);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_PRODUCTZOOM', 1);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_TABCOLLAPSE', 0);
|
||||
// $res &= Configuration::updateValue('APPAGEBUILDER_LOAD_AJAX', 1);
|
||||
// $res &= Configuration::updateValue('APPAGEBUILDER_LOAD_PN', 1);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_TRAN', 1);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_IMG', 0);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_COUNT', 1);
|
||||
// $res &= Configuration::updateValue('APPAGEBUILDER_LOAD_COLOR', 1);
|
||||
// $res &= Configuration::updateValue('APPAGEBUILDER_LOAD_ACOLOR', 1);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_COLOR', '');
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_COOKIE_PROFILE', 0);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_SLIDE_IMAGE', 1);
|
||||
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_HEADER_HOOK', implode(',', ApPageSetting::getHook('header')));
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_CONTENT_HOOK', implode(',', ApPageSetting::getHook('content')));
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_FOOTER_HOOK', implode(',', ApPageSetting::getHook('footer')));
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_PRODUCT_HOOK', implode(',', ApPageSetting::getHook('product')));
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_GLOBAL_HEADER_ID', 0);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_GLOBAL_CONTENT_ID', 0);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_GLOBAL_FOOTER_ID', 0);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_GLOBAL_PRODUCT_ID', 0);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_GLOBAL_PROFILE_PARAM', '');
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_LOAD_COOKIE', 0);
|
||||
$res &= Configuration::updateValue('APPAGEBUILDER_REGISTER', 0);
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function deleteTables()
|
||||
{
|
||||
return Db::getInstance()->execute('DROP TABLE IF EXISTS `'.
|
||||
_DB_PREFIX_.'appagebuilder_profiles`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_profiles_lang`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_profiles_shop`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_products`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_products_shop` , `'.
|
||||
_DB_PREFIX_.'appagebuilder`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_shop`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_lang`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_extracat`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_extrapro`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_page`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_details`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_details_shop`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_positions`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_shortcode`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_shortcode_lang`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_shortcode_shop`, `'.
|
||||
_DB_PREFIX_.'appagebuilder_positions_shop`;
|
||||
');
|
||||
}
|
||||
|
||||
public static function uninstallModuleTab()
|
||||
{
|
||||
$id = Tab::getIdFromClassName('AdminApPageBuilder');
|
||||
if ($id) {
|
||||
$tab = new Tab($id);
|
||||
$tab->delete();
|
||||
}
|
||||
|
||||
foreach (self::getTabs() as $tab) {
|
||||
$id = Tab::getIdFromClassName($tab['class_name']);
|
||||
if ($id) {
|
||||
$tab = new Tab($id);
|
||||
$tab->delete();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function uninstallConfiguration()
|
||||
{
|
||||
$res = true;
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_PRODUCT_MAX_RANDOM');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_GUIDE');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_OWL');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_STELLAR');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_WAYPOINTS');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_INSTAFEED');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_HTML5VIDEO');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_SAVE_MULTITHREARING');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_FULLPAGEJS');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_IMAGE360');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_IMAGEHOTPOT');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_SAVE_SUBMIT');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_PRODUCTZOOM');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_TABCOLLAPSE');
|
||||
// $res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_AJAX');
|
||||
// $res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_PN');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_TRAN');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_IMG');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_COUNT');
|
||||
// $res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_COLOR');
|
||||
// $res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_ACOLOR');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_COLOR');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_COOKIE_PROFILE');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_SLIDE_IMAGE');
|
||||
|
||||
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_HEADER_HOOK');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_CONTENT_HOOK');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_FOOTER_HOOK');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_PRODUCT_HOOK');
|
||||
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_GLOBAL_HEADER_ID');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_GLOBAL_CONTENT_ID');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_GLOBAL_FOOTER_ID');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_GLOBAL_PRODUCT_ID');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_GLOBAL_PROFILE_PARAM');
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_LOAD_COOKIE');
|
||||
|
||||
//DONGND:: remove config check override for shortcode
|
||||
$res &= Configuration::deleteByName('APPAGEBUILDER_OVERRIDED');
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove file index.php in sub folder theme/translations folder when install theme
|
||||
*/
|
||||
public static function processTranslateTheme()
|
||||
{
|
||||
$theme_name = apPageHelper::getInstallationThemeName();
|
||||
if (file_exists(_PS_ALL_THEMES_DIR_.$theme_name.'/config.xml')) {
|
||||
$directories = glob(_PS_ALL_THEMES_DIR_.$theme_name.'/translations/*', GLOB_ONLYDIR);
|
||||
if (count($directories) > 0) {
|
||||
foreach ($directories as $directories_val) {
|
||||
if (file_exists($directories_val.'/index.php')) {
|
||||
unlink($directories_val.'/index.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove file index.php for translate in Quickstart version
|
||||
*/
|
||||
public static function processTranslateQSTheme()
|
||||
{
|
||||
# GET ARRAY THEME_NAME
|
||||
$arr_theme_name = array();
|
||||
$themes = glob(_PS_ROOT_DIR_.'/themes/*/config/theme.yml');
|
||||
if (count($themes) > 1) {
|
||||
foreach ($themes as $key => $value) {
|
||||
$temp_name = basename(Tools::substr($value, 0, -strlen('/config/theme.yml')));
|
||||
if ($temp_name == 'classic') {
|
||||
continue;
|
||||
} else {
|
||||
$arr_theme_name[] = $temp_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($arr_theme_name as $key => $theme_name) {
|
||||
//DONGND:: remove index.php in sub folder theme/translations folder when install theme
|
||||
|
||||
if (file_exists(_PS_ALL_THEMES_DIR_.$theme_name.'/config.xml')) {
|
||||
$directories = glob(_PS_ALL_THEMES_DIR_.$theme_name.'/translations/*', GLOB_ONLYDIR);
|
||||
if (count($directories) > 0) {
|
||||
foreach ($directories as $directories_val) {
|
||||
if (file_exists($directories_val.'/index.php')) {
|
||||
unlink($directories_val.'/index.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
BIN
modules/appagebuilder/logo.gif
Normal file
BIN
modules/appagebuilder/logo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
modules/appagebuilder/logo.png
Normal file
BIN
modules/appagebuilder/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
abstract class ProductListingFrontController extends ProductListingFrontControllerCore
|
||||
{
|
||||
// /**
|
||||
// * Override
|
||||
// * Category page show shortcode at product list
|
||||
// */
|
||||
// protected function prepareMultipleProductsForTemplate(array $products)
|
||||
// {
|
||||
// if ((bool)Module::isEnabled('appagebuilder')) {
|
||||
// foreach ($products as &$product) {
|
||||
// $appagebuilder = Module::getInstanceByName('appagebuilder');
|
||||
// $product['description'] = $appagebuilder->buildShortCode($product['description']);
|
||||
// $product['description_short'] = $appagebuilder->buildShortCode($product['description_short']);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return parent::prepareMultipleProductsForTemplate($products);
|
||||
// }
|
||||
}
|
||||
35
modules/appagebuilder/override/classes/controller/index.php
Normal file
35
modules/appagebuilder/override/classes/controller/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* 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-2018 PrestaShop SA
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 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;
|
||||
35
modules/appagebuilder/override/classes/index.php
Normal file
35
modules/appagebuilder/override/classes/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* 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-2018 PrestaShop SA
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 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;
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
class CmsController extends CmsControllerCore
|
||||
{
|
||||
public function initContent()
|
||||
{
|
||||
if ($this->assignCase == 1) {
|
||||
$cmsVar = $this->objectPresenter->present($this->cms);
|
||||
|
||||
$filteredCmsContent = Hook::exec(
|
||||
'filterCmsContent',
|
||||
array('object' => $cmsVar),
|
||||
$id_module = null,
|
||||
$array_return = false,
|
||||
$check_exceptions = true,
|
||||
$use_push = false,
|
||||
$id_shop = null,
|
||||
$chain = true
|
||||
);
|
||||
if (!empty($filteredCmsContent['object'])) {
|
||||
$cmsVar = $filteredCmsContent['object'];
|
||||
}
|
||||
//DONGND:: print shortcode
|
||||
if ((bool)Module::isEnabled('appagebuilder')) {
|
||||
$appagebuilder = Module::getInstanceByName('appagebuilder');
|
||||
$cmsVar['content'] = $appagebuilder->buildShortCode($cmsVar['content']);
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'cms' => $cmsVar,
|
||||
));
|
||||
|
||||
if ($this->cms->indexation == 0) {
|
||||
$this->context->smarty->assign('nobots', true);
|
||||
}
|
||||
|
||||
$this->setTemplate(
|
||||
'cms/page',
|
||||
array('entity' => 'cms', 'id' => $this->cms->id)
|
||||
);
|
||||
} elseif ($this->assignCase == 2) {
|
||||
$cmsCategoryVar = $this->getTemplateVarCategoryCms();
|
||||
|
||||
$filteredCmsCategoryContent = Hook::exec(
|
||||
'filterCmsCategoryContent',
|
||||
array('object' => $cmsCategoryVar),
|
||||
$id_module = null,
|
||||
$array_return = false,
|
||||
$check_exceptions = true,
|
||||
$use_push = false,
|
||||
$id_shop = null,
|
||||
$chain = true
|
||||
);
|
||||
if (!empty($filteredCmsCategoryContent['object'])) {
|
||||
$cmsCategoryVar = $filteredCmsCategoryContent['object'];
|
||||
}
|
||||
|
||||
$this->context->smarty->assign($cmsCategoryVar);
|
||||
$this->setTemplate('cms/category');
|
||||
}
|
||||
FrontController::initContent();
|
||||
|
||||
// validate module
|
||||
unset($id_module);
|
||||
unset($array_return);
|
||||
unset($check_exceptions);
|
||||
unset($use_push);
|
||||
unset($id_shop);
|
||||
unset($chain);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Apollotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* ApPageBuilder is module help you can build content for your shop
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2019 Apollotheme
|
||||
* @license http://apollotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
class ProductController extends ProductControllerCore
|
||||
{
|
||||
public function getTemplateVarProduct()
|
||||
{
|
||||
$product = parent::getTemplateVarProduct();
|
||||
|
||||
if ((bool)Module::isEnabled('appagebuilder')) {
|
||||
$appagebuilder = Module::getInstanceByName('appagebuilder');
|
||||
$product['description'] = $appagebuilder->buildShortCode($product['description']);
|
||||
$product['description_short'] = $appagebuilder->buildShortCode($product['description_short']);
|
||||
}
|
||||
|
||||
return $product;
|
||||
}
|
||||
}
|
||||
35
modules/appagebuilder/override/controllers/front/index.php
Normal file
35
modules/appagebuilder/override/controllers/front/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2017 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* 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-2017 PrestaShop SA
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 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;
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2017 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* 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-2017 PrestaShop SA
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class CategoryController extends CategoryControllerCore
|
||||
{
|
||||
protected function getTemplateVarCategory()
|
||||
{
|
||||
$category = parent::getTemplateVarCategory();
|
||||
|
||||
if ((bool)Module::isEnabled('appagebuilder')) {
|
||||
$appagebuilder = Module::getInstanceByName('appagebuilder');
|
||||
$category['description'] = $appagebuilder->buildShortCode($category['description']);
|
||||
}
|
||||
|
||||
return $category;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2017 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* 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-2017 PrestaShop SA
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 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;
|
||||
35
modules/appagebuilder/override/controllers/index.php
Normal file
35
modules/appagebuilder/override/controllers/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2017 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* 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-2017 PrestaShop SA
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 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;
|
||||
36
modules/appagebuilder/override/index.php
Normal file
36
modules/appagebuilder/override/index.php
Normal 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;
|
||||
1597
modules/appagebuilder/translations/ar.php
Normal file
1597
modules/appagebuilder/translations/ar.php
Normal file
File diff suppressed because it is too large
Load Diff
1606
modules/appagebuilder/translations/de.php
Normal file
1606
modules/appagebuilder/translations/de.php
Normal file
File diff suppressed because it is too large
Load Diff
1606
modules/appagebuilder/translations/es.php
Normal file
1606
modules/appagebuilder/translations/es.php
Normal file
File diff suppressed because it is too large
Load Diff
1606
modules/appagebuilder/translations/fr.php
Normal file
1606
modules/appagebuilder/translations/fr.php
Normal file
File diff suppressed because it is too large
Load Diff
35
modules/appagebuilder/translations/index.php
Normal file
35
modules/appagebuilder/translations/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2019 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;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user