first commit
This commit is contained in:
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user