first commit

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

View File

@@ -0,0 +1,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;
}
}
}
}
}