diff --git a/www/system-brs-core/app/index/inc/indexController.php b/www/system-brs-core/app/index/inc/indexController.php index b4a54dc..1251f9c 100644 --- a/www/system-brs-core/app/index/inc/indexController.php +++ b/www/system-brs-core/app/index/inc/indexController.php @@ -4,9 +4,11 @@ namespace BRSystems\Core\App\index\inc; use BRSystems\Core\Cms\cmsTextManager\inc\cmsTextManagerConst; use BRSystems\Core\Library\cCore\cCore; +use BRSystems\Core\Library\cApc\cApc; use BRSystems\Core\Library\cDefuseCrypto\cDefuseCrypto; use BRSystems\Core\Library\cJSON\cJSON; use BRSystems\Core\Library\cSession\cSession; +use BRSystems\Core\Library\cUrl\cUrl; use BRSystems\Core\Library\cValidator\cValidator; use BRSystems\Core\Library\cApc\cCacheHelper; use Exception; @@ -29,6 +31,7 @@ class indexController extends cCore const IMG_DEFAULT_BREADCRUMBS_BG = '/img/assets/other/breadcrumb-bgimg3.jpg'; const IMG_DEFAULT_COLLECTION_BANNER = '/img/assets/collection/collection-banner.jpg'; const IMG_DEFAULT_POPUP_BG = '/img/assets/newsletter/newsletter-popup.jpg'; + const IMG_DEFAULT_FOOTER_INSTAGRAM = '/img/assets/instagram/insta-1.jpg'; public function __construct($uriData, $dir, $name) { @@ -472,6 +475,52 @@ class indexController extends cCore return ($backgroundImg ?: self::IMG_DEFAULT_COLLECTION_BANNER); } + public static function getFooterInstagramSlides(int $langId): array + { + $cache = new cCacheHelper(new cApc()); + $cached = $cache->get(cmsTextManagerConst::APC_FOOTER_INSTAGRAM_KEY, $langId); + if ($cached !== false && is_array($cached)) { + return $cached; + } + + $slidesData = (new indexModule())->getArticleData(cmsTextManagerConst::FOOTER_INSTAGRAM, $langId, true); + $slides = []; + + if (!empty($slidesData) && is_array($slidesData)) { + foreach ($slidesData as $slideRow) { + if (!is_array($slideRow)) { + continue; + } + + $imgPath = self::IMG_DEFAULT_FOOTER_INSTAGRAM; + if (!empty($slideRow['i'])) { + $normalizedImg = self::normalizeImagePath($slideRow['i'], 'footer_instagram'); + if ($normalizedImg) { + $imgPath = $normalizedImg; + } + } + + $slides[] = [ + 'img' => $imgPath, + 'url' => self::normalizeSlideUrl($slideRow['l'] ?? ''), + 'title' => !empty($slideRow['t']) ? $slideRow['t'] : '', + ]; + } + } + + $cache->store(cmsTextManagerConst::APC_FOOTER_INSTAGRAM_KEY, $langId, $slides); + return $slides; + } + + private static function normalizeSlideUrl(?string $url): string + { + if (empty($url)) { + return '/'; + } + + return (new cUrl())->rmSlashesIndex($url); + } + public function getIndexAboutTextSectionsData(): array { $data = $this->module->getArticleData(cmsTextManagerConst::INDEX_PAGE_ABOUT_TEXT, $this->langId, true); @@ -811,12 +860,18 @@ class indexController extends cCore ]; } - public static function acceptCookiePolicy(): bool + public static function acceptCookiePolicy(bool $acceptAll = false): bool { if (!isset($_COOKIE['_cookie_policy_accepted'])) { /* expire in 1 month */ setSameSiteCookie('_cookie_policy_accepted', 1, 60 * 60 * 24 * 30); } + + $statistics = ($acceptAll ? 1 : (int)getP('statistics')); + $preferences = ($acceptAll ? 1 : (int)getP('preferences')); + setSameSiteCookie('_cookie_policy_statistics', $statistics, 60 * 60 * 24 * 30); + setSameSiteCookie('_cookie_policy_preferences', $preferences, 60 * 60 * 24 * 30); + return true; } diff --git a/www/system-brs-core/app/index/index.php b/www/system-brs-core/app/index/index.php index ec1f296..b7e8296 100644 --- a/www/system-brs-core/app/index/index.php +++ b/www/system-brs-core/app/index/index.php @@ -57,6 +57,9 @@ class index case 'accept-cookies': cJSON::sendOk($this->controller->acceptCookiePolicy()); break; + case 'accept-all-cookies': + cJSON::sendOk($this->controller->acceptCookiePolicy(true)); + break; default: $this->controller->runCookies(); break; diff --git a/www/system-brs-core/cms/cmsClassificators/cmsClassificators.php b/www/system-brs-core/cms/cmsClassificators/cmsClassificators.php index 96c15e3..2640cb6 100644 --- a/www/system-brs-core/cms/cmsClassificators/cmsClassificators.php +++ b/www/system-brs-core/cms/cmsClassificators/cmsClassificators.php @@ -73,6 +73,9 @@ class cmsClassificators cJSON::sendOk($this->controller->changeEnumFields(getP('baseField'), getP('fields'))); } break; + case 'generateInsertSql': + cJSON::sendOk($this->controller->generateInsertSql(getV('ids'), getP('filter'))); + break; default: $this->controller->run(); break; diff --git a/www/system-brs-core/cms/cmsClassificators/inc/cmsClassificatorsController.php b/www/system-brs-core/cms/cmsClassificators/inc/cmsClassificatorsController.php index 91b0b1a..1c25e86 100644 --- a/www/system-brs-core/cms/cmsClassificators/inc/cmsClassificatorsController.php +++ b/www/system-brs-core/cms/cmsClassificators/inc/cmsClassificatorsController.php @@ -296,6 +296,65 @@ class cmsClassificatorsController extends cCore } + public function generateInsertSql($ids, $filterJson = '') + { + if (!!$ids) { + $ids = json_decode($ids, true); + } + + $filter = []; + if ($filterJson) { + $filter = cJSON::decode($filterJson, true); + } + + $where = 'AND 1'; + $sort = "id DESC"; + $tFields = $this->getTableFields(); + if (count($filter)) { + $where = $this->module->db->genSearchFieldQuery($filter, $tFields); + } + + $vData = $this->module->getClassificatorDataForSqlExport($ids ?: [], $where, $sort); + if (!empty($vData) && is_array($vData)) { + $sSqlInsertClassificators = "INSERT INTO mod_classificators (id, cl_name, cl_data, cl_type, cl_order, cl_blocked, cl_shop_filter, cl_has_translations, cl_modified, cl_created) VALUES"; + $sSqlInsertTranslations = ""; + $sSqlPt1 = ""; + $classificatorIds = []; + + foreach ($vData as $v) { + $classificatorIds[$v['id']] = $v['id']; + $clName = $this->module->db->prepData($v['cl_name']); + $clData = $this->module->db->prepData($v['cl_data']); + $sSqlPt1 .= ",\n ({$v['id']}, '{$clName}', '{$clData}', {$v['cl_type']}, {$v['cl_order']}, '{$v['cl_blocked']}', '{$v['cl_shop_filter']}', '{$v['cl_has_translations']}', {$v['cl_modified']}, {$v['cl_created']})"; + } + + $sSqlInsertClassificators .= substr($sSqlPt1, 1) . ";"; + + $translations = $this->module->getClassificatorTranslationsForSqlExport(array_values($classificatorIds)); + if (!empty($translations)) { + $sSqlPt2 = ""; + $sSqlInsertTranslations = "INSERT INTO mod_classificators_translations (id, cl_id, cl_lang_id, cl_value, cl_data) VALUES"; + foreach ($translations as $translation) { + $clValue = $this->module->db->prepData($translation['cl_value']); + $clData = $this->module->db->prepData($translation['cl_data']); + $sSqlPt2 .= ",\n ({$translation['id']}, {$translation['cl_id']}, {$translation['cl_lang_id']}, '{$clValue}', '{$clData}')"; + } + $sSqlInsertTranslations .= substr($sSqlPt2, 1) . ";"; + } + + return array( + 'sql' => array( + 'sDeleteTranslations' => "DELETE FROM mod_classificators_translations WHERE cl_id IN (" . implode(", ", $classificatorIds) . ");", + 'sDeleteClassificators' => "DELETE FROM mod_classificators WHERE id IN (" . implode(", ", $classificatorIds) . ");", + 'sInsertClassificators' => $sSqlInsertClassificators, + 'sInsertTranslations' => $sSqlInsertTranslations, + ) + ); + } + + return false; + } + /** * Function to create table headers + search * @@ -403,6 +462,8 @@ class cmsClassificatorsController extends cCore return array( 'yes' => $this->gM('Yes'), 'no' => $this->gM('No'), + 'done' => $this->gM('Done!'), + 'sSqlExpTitle' => $this->gM('Sql Export for classificators'), 'delTitle' => $this->gM('Delete classificators?'), 'delMessage' => $this->gM('Selected classificators will be permanently deleted and cannot be recovered. Confirm delete?'), 'buttonYes' => $this->gM('Delete selected classificators'), @@ -429,6 +490,9 @@ class cmsClassificatorsController extends cCore 'lbl' => $this->gM("Add new"), 'icon' => 'nico-add' ), + 'igensql' => array( + 'lbl' => $this->gM("Gen. sql"), + ), 'istatus' => array( 'lbl' => $this->gM("Change item status"), ), diff --git a/www/system-brs-core/cms/cmsClassificators/inc/cmsClassificatorsModule.php b/www/system-brs-core/cms/cmsClassificators/inc/cmsClassificatorsModule.php index ed9c2b2..6d0eb59 100644 --- a/www/system-brs-core/cms/cmsClassificators/inc/cmsClassificatorsModule.php +++ b/www/system-brs-core/cms/cmsClassificators/inc/cmsClassificatorsModule.php @@ -130,6 +130,65 @@ class cmsClassificatorsModule } + public function getClassificatorDataForSqlExport($ids = [], $where = 'AND 1', $sort = 'id DESC') + { + $ids = $this->db->prepData($ids); + $idWhere = ''; + if (!empty($ids) && is_array($ids)) { + $idWhere = " AND mc.id IN (" . implode(',', $ids) . ")"; + } + + $sSql = " + SELECT + mc.id, + mc.cl_name, + mc.cl_data, + mc.cl_type, + mc.cl_order, + mc.cl_blocked, + mc.cl_shop_filter, + mc.cl_has_translations, + mc.cl_modified, + mc.cl_created + FROM + mod_classificators mc + WHERE + 1 {$where} + {$idWhere} + ORDER BY + {$sort} + "; + + $this->db->query($sSql); + return $this->db->getFieldBasedArrayFieldsAdv('id'); + } + + public function getClassificatorTranslationsForSqlExport($ids) + { + $ids = $this->db->prepData($ids); + if (empty($ids) || !is_array($ids)) { + return []; + } + + $sSql = " + SELECT + mct.id, + mct.cl_id, + mct.cl_lang_id, + mct.cl_value, + mct.cl_data + FROM + mod_classificators_translations mct + WHERE + mct.cl_id IN (" . implode(',', $ids) . ") + ORDER BY + mct.cl_id, mct.cl_lang_id, mct.id + "; + + $this->db->query($sSql); + return $this->db->getArray(); + } + /** * Function to get record translation data * diff --git a/www/system-brs-core/cms/cmsClassificators/js/cmsClassificators.js b/www/system-brs-core/cms/cmsClassificators/js/cmsClassificators.js index 77f3150..d46eb2b 100644 --- a/www/system-brs-core/cms/cmsClassificators/js/cmsClassificators.js +++ b/www/system-brs-core/cms/cmsClassificators/js/cmsClassificators.js @@ -7,7 +7,62 @@ var CmsClassificators = (function() { _this.oTable.loadTableData(); } CTable.prototype.tableObjectCallback = function(jqObj){ + jqObj.find("#igensql").click(function(){ + var oIds = [], + id = 0, + filter = {}; + jqObj.find("ul.dxr.single:not(.thead) li.first .chked").each(function(){ + id = $(this).closest("ul").attr("id"); + if(id) oIds.push(id); + }); + + jqObj.find(".thead .search :input").each(function(){ + var jqInput = $(this), + inputId = jqInput.attr("id"); + if(inputId && jqInput.val() !== ""){ + filter[inputId] = jqInput.val(); + } + }); + + var jqData = $("
"+ str +"
")); + } + }); + + jqData.find("> div").click(function(){ + var selection = window.getSelection(); + var txt = jqData.find("> div"); + var range = document.createRange(); + range.selectNodeContents(txt[0]); + selection.removeAllRanges(); + selection.addRange(range); + }); + } + }); + + if(!CBase.jsModule.oMyDialog) + CBase.jsModule.oMyDialog = new ConfirmDialog("sqlExport"); + + CBase.jsModule.oMyDialog.setCustomContentAndShow({ + closeBtn: true, + title : defaultVal(CBase.gM.sSqlExpTitle, "Sql Export for classificators"), + message : jqData, + buttons : { + 1 : { + lbl : defaultVal(CBase.gM.done, "Done!"), + id : "buttonYes", + click : function(){ + CBase.jsModule.oMyDialog.hide(); + } + } + } + }); + }); }; // Rewrite CBase form callback CBlank.prototype.viewCallback = function(jqObj){ diff --git a/www/system-brs-core/cms/cmsTextManager/inc/cmsTextManagerConst.php b/www/system-brs-core/cms/cmsTextManager/inc/cmsTextManagerConst.php index 045cb26..f1c1254 100644 --- a/www/system-brs-core/cms/cmsTextManager/inc/cmsTextManagerConst.php +++ b/www/system-brs-core/cms/cmsTextManager/inc/cmsTextManagerConst.php @@ -17,6 +17,7 @@ class cmsTextManagerConst const APC_CATEGORY_MENU_KEY = "APP_CATEGORY_MENU_"; const APC_HEADER_CATEGORY_MENU_KEY = "APP_HEADER_CATEGORY_MENU_"; const APC_SHOP_SIDE_BANNER_KEY = "APP_SHOP_SIDE_BANNER_"; + const APC_FOOTER_INSTAGRAM_KEY = 'FOOTER_INSTAGRAM'; const APC_INDEX_GLOBAL_KEY = 'INDEX_GLOBAL'; const APC_INDEX_COOKIES_KEY = 'INDEX_COOKIES'; const APC_INDEX_AGREE_TO_TERMS_KEY = 'INDEX_AGREE_TO_TERMS'; @@ -54,6 +55,7 @@ class cmsTextManagerConst const PAGE_TYPE_RETURN_POLICY = 1478; // Return Policy page const PAGE_TYPE_SHIPPING_POLICY = 1479; // Shipping Policy page const PAGE_TYPE_COPYRIGHT = 1480; // Copyright page + const FOOTER_INSTAGRAM = 1481; // Footer instagram slider // Text manager types for Products categories and sub-categories const BASE_SUB_CATEGORIES = 1443; // Base sub categories diff --git a/www/system-brs-core/cms/cmsTextManager/inc/cmsTextManagerController.php b/www/system-brs-core/cms/cmsTextManager/inc/cmsTextManagerController.php index daa9228..27a950a 100644 --- a/www/system-brs-core/cms/cmsTextManager/inc/cmsTextManagerController.php +++ b/www/system-brs-core/cms/cmsTextManager/inc/cmsTextManagerController.php @@ -38,6 +38,7 @@ class cmsTextManagerController extends cCore 'carousel' => '1920x950', 'shop_side_banner' => '360x420', 'collection_banner' => '1420x330', + 'footer_instagram' => '450x450', ], ], 'file' => [ @@ -962,6 +963,7 @@ class cmsTextManagerController extends cCore cmsTextManagerConst::GLOBAL_BREADCRUMBS => ['category_bg'], cmsTextManagerConst::SHOP_SIDE_BANNER => ['shop_side_banner'], cmsTextManagerConst::COLLECTION_BANNER => ['collection_banner'], + cmsTextManagerConst::FOOTER_INSTAGRAM => ['footer_instagram'], cmsTextManagerConst::INDEX_PAGE_TESTIMONIAL => ['service_card'], ]; @@ -1028,6 +1030,7 @@ class cmsTextManagerController extends cCore cmsTextManagerConst::POPUP_SUBSCRIBE_BG => $defaultImageOnly, cmsTextManagerConst::SHOP_SIDE_BANNER => [$image, $link], cmsTextManagerConst::COLLECTION_BANNER => $defaultImageOnly, + cmsTextManagerConst::FOOTER_INSTAGRAM => [$shortRecord, $image, $link], cmsTextManagerConst::PAGE_TYPE_ABOUT_US => $defaultTextWithFiles, cmsTextManagerConst::PAGE_TYPE_FAQ => $defaultTextWithFiles, cmsTextManagerConst::PAGE_TYPE_DISCLAIMER => $defaultTextWithFiles, @@ -1113,6 +1116,9 @@ class cmsTextManagerController extends cCore case cmsTextManagerConst::SHOP_SIDE_BANNER: $apcKey = cmsTextManagerConst::APC_SHOP_SIDE_BANNER_KEY; break; + case cmsTextManagerConst::FOOTER_INSTAGRAM: + $apcKey = cmsTextManagerConst::APC_FOOTER_INSTAGRAM_KEY; + break; case cmsTextManagerConst::COLLECTION_BANNER: $apcKey = cmsTextManagerConst::APC_COLLECTION_BANNER_KEY; break; diff --git a/www/system-brs-core/library/cCore/cCore.php b/www/system-brs-core/library/cCore/cCore.php index 3473f23..8b5be0e 100644 --- a/www/system-brs-core/library/cCore/cCore.php +++ b/www/system-brs-core/library/cCore/cCore.php @@ -189,8 +189,12 @@ class cCore /** Set global default settings across all pages */ $defaultLang = cmsTextManagerConst::DEFAULT_LANGUAGE; - $this->oView->BREADCRUMBS_BG_IMG = indexController::getBreadcrumbBackgroundImg($defaultLang); - $this->oView->SUBSCRIBE_BG_IMG = indexController::getPopupBackgroundImg($defaultLang); + $viewLangId = (!empty($this->langId) ? (int)$this->langId : $defaultLang); + + $this->oView->BREADCRUMBS_BG_IMG = indexController::getBreadcrumbBackgroundImg($viewLangId); + $this->oView->SUBSCRIBE_BG_IMG = indexController::getPopupBackgroundImg($viewLangId); + $this->oView->FOOTER_INSTAGRAM_SLIDES = indexController::getFooterInstagramSlides($viewLangId); + $this->oView->setAsJSON('subCfg', indexController::valCfgForSubscribe()); $this->oView->setAsJSON('subLink', $this->gL(742)); $this->oView->setAsJSON('profileLink', $this->gL(905)); diff --git a/www/system-brs-core/library/cView/tpl/helpers/pub/footer.twig b/www/system-brs-core/library/cView/tpl/helpers/pub/footer.twig index 7e06fbf..910d8f2 100644 --- a/www/system-brs-core/library/cView/tpl/helpers/pub/footer.twig +++ b/www/system-brs-core/library/cView/tpl/helpers/pub/footer.twig @@ -14,57 +14,51 @@ { 'title': 'Terms & condition', 'url': dt.gL(832) } ] %} -{% set instaSlides = [ - { 'img': '/img/assets/instagram/insta-1.jpg', 'url': dt.gL(525) }, - { 'img': '/img/assets/instagram/insta-2.jpg', 'url': dt.gL(525) }, - { 'img': '/img/assets/instagram/insta-3.jpg', 'url': dt.gL(525) }, - { 'img': '/img/assets/instagram/insta-4.jpg', 'url': dt.gL(525) }, - { 'img': '/img/assets/instagram/insta-5.jpg', 'url': dt.gL(525) }, - { 'img': '/img/assets/instagram/insta-6.jpg', 'url': dt.gL(525) }, - { 'img': '/img/assets/instagram/insta-7.jpg', 'url': dt.gL(525) } -] %} +{% set instaSlides = FOOTER_INSTAGRAM_SLIDES|default([]) %}