Fix admin menu/header license gating, AJAX save response handling, and dark theme compatibility

This commit is contained in:
nertyog 2026-10-20 04:51:39 +03:00
parent d62c0e6805
commit 754ecaa98d
4 changed files with 106 additions and 118 deletions

View File

@ -538,6 +538,7 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
// Blocks images // Blocks images
if (isset($slide['blocks']) && is_array($slide['blocks'])) { if (isset($slide['blocks']) && is_array($slide['blocks'])) {
foreach ($slide['blocks'] as $j => $block) { foreach ($slide['blocks'] as $j => $block) {
if (!is_array($block) || empty($block['type'])) continue;
if ($block['type'] === 'image') { if ($block['type'] === 'image') {
$slides[$i]['blocks'][$j]['thumb'] = []; $slides[$i]['blocks'][$j]['thumb'] = [];
foreach ($data['languages'] as $lang) { foreach ($data['languages'] as $lang) {
@ -585,6 +586,8 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
$this->load->language('extension/promo_top_bar_nat/module/promo_top_bar_nat'); $this->load->language('extension/promo_top_bar_nat/module/promo_top_bar_nat');
$json = []; $json = [];
try {
if (!$this->user->hasPermission('modify', 'extension/promo_top_bar_nat/module/promo_top_bar_nat')) { if (!$this->user->hasPermission('modify', 'extension/promo_top_bar_nat/module/promo_top_bar_nat')) {
$json['error'] = $this->language->get('error_permission'); $json['error'] = $this->language->get('error_permission');
} }
@ -610,6 +613,8 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
$existing_settings = $this->model_setting_setting->getSetting('module_promo_top_bar_nat'); $existing_settings = $this->model_setting_setting->getSetting('module_promo_top_bar_nat');
unset($this->request->post['module_promo_top_bar_nat_slides_json']); unset($this->request->post['module_promo_top_bar_nat_slides_json']);
unset($this->request->post['module_promo_top_bar_nat_slides']); unset($this->request->post['module_promo_top_bar_nat_slides']);
if (!is_array($existing_settings)) { $existing_settings = []; }
if (!is_array($this->request->post)) { $this->request->post = []; }
$this->request->post = array_merge($existing_settings, $this->request->post); $this->request->post = array_merge($existing_settings, $this->request->post);
} }
@ -627,6 +632,14 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
$json['success'] = $this->language->get('text_success'); $json['success'] = $this->language->get('text_success');
} }
} catch (\Throwable $e) {
$json['error'] = $e->getMessage();
}
if (ob_get_length()) {
ob_clean();
}
$this->response->addHeader('Content-Type: application/json'); $this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json)); $this->response->setOutput(json_encode($json));
} }
@ -683,93 +696,94 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
foreach ($slides as $i => $slide) { foreach ($slides as $i => $slide) {
if (isset($slide['blocks']) && is_array($slide['blocks'])) { if (isset($slide['blocks']) && is_array($slide['blocks'])) {
foreach ($slide['blocks'] as $j => $block) { foreach ($slide['blocks'] as $j => $block) {
if (!is_array($block) || empty($block['type'])) continue;
if ($block['type'] === 'text') { if ($block['type'] === 'text') {
if (isset($block['text']) && is_array($block['text'])) { if (isset($block['text']) && is_array($block['text'])) {
foreach ($block['text'] as $lang_id => $val) { foreach ($block['text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['text'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['text'][$lang_id] = base64_encode((string)$val);
} }
} }
if (isset($block['mobile_text']) && is_array($block['mobile_text'])) { if (isset($block['mobile_text']) && is_array($block['mobile_text'])) {
foreach ($block['mobile_text'] as $lang_id => $val) { foreach ($block['mobile_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['mobile_text'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['mobile_text'][$lang_id] = base64_encode((string)$val);
} }
} }
} elseif ($block['type'] === 'image') { } elseif ($block['type'] === 'image') {
if (isset($block['alt']) && is_array($block['alt'])) { if (isset($block['alt']) && is_array($block['alt'])) {
foreach ($block['alt'] as $lang_id => $val) { foreach ($block['alt'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['alt'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['alt'][$lang_id] = base64_encode((string)$val);
} }
} }
} elseif ($block['type'] === 'button') { } elseif ($block['type'] === 'button') {
if (isset($block['text']) && is_array($block['text'])) { if (isset($block['text']) && is_array($block['text'])) {
foreach ($block['text'] as $lang_id => $val) { foreach ($block['text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['text'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['text'][$lang_id] = base64_encode((string)$val);
} }
} }
if (isset($block['badge_text']) && is_array($block['badge_text'])) { if (isset($block['badge_text']) && is_array($block['badge_text'])) {
foreach ($block['badge_text'] as $lang_id => $val) { foreach ($block['badge_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['badge_text'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['badge_text'][$lang_id] = base64_encode((string)$val);
} }
} }
} elseif ($block['type'] === 'timer') { } elseif ($block['type'] === 'timer') {
if (isset($block['timer_fallback_text']) && is_array($block['timer_fallback_text'])) { if (isset($block['timer_fallback_text']) && is_array($block['timer_fallback_text'])) {
foreach ($block['timer_fallback_text'] as $lang_id => $val) { foreach ($block['timer_fallback_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['timer_fallback_text'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['timer_fallback_text'][$lang_id] = base64_encode((string)$val);
} }
} }
} elseif ($block['type'] === 'shipping') { } elseif ($block['type'] === 'shipping') {
if (isset($block['shipping_text_before']) && is_array($block['shipping_text_before'])) { if (isset($block['shipping_text_before']) && is_array($block['shipping_text_before'])) {
foreach ($block['shipping_text_before'] as $lang_id => $val) { foreach ($block['shipping_text_before'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['shipping_text_before'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['shipping_text_before'][$lang_id] = base64_encode((string)$val);
} }
} }
if (isset($block['shipping_text_after']) && is_array($block['shipping_text_after'])) { if (isset($block['shipping_text_after']) && is_array($block['shipping_text_after'])) {
foreach ($block['shipping_text_after'] as $lang_id => $val) { foreach ($block['shipping_text_after'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['shipping_text_after'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['shipping_text_after'][$lang_id] = base64_encode((string)$val);
} }
} }
} elseif ($block['type'] === 'subscribe') { } elseif ($block['type'] === 'subscribe') {
if (isset($block['subscribe_placeholder']) && is_array($block['subscribe_placeholder'])) { if (isset($block['subscribe_placeholder']) && is_array($block['subscribe_placeholder'])) {
foreach ($block['subscribe_placeholder'] as $lang_id => $val) { foreach ($block['subscribe_placeholder'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['subscribe_placeholder'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['subscribe_placeholder'][$lang_id] = base64_encode((string)$val);
} }
} }
if (isset($block['subscribe_button_text']) && is_array($block['subscribe_button_text'])) { if (isset($block['subscribe_button_text']) && is_array($block['subscribe_button_text'])) {
foreach ($block['subscribe_button_text'] as $lang_id => $val) { foreach ($block['subscribe_button_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['subscribe_button_text'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['subscribe_button_text'][$lang_id] = base64_encode((string)$val);
} }
} }
if (isset($block['subscribe_success_msg']) && is_array($block['subscribe_success_msg'])) { if (isset($block['subscribe_success_msg']) && is_array($block['subscribe_success_msg'])) {
foreach ($block['subscribe_success_msg'] as $lang_id => $val) { foreach ($block['subscribe_success_msg'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['subscribe_success_msg'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['subscribe_success_msg'][$lang_id] = base64_encode((string)$val);
} }
} }
} elseif ($block['type'] === 'coupon') { } elseif ($block['type'] === 'coupon') {
if (isset($block['coupon_text']) && is_array($block['coupon_text'])) { if (isset($block['coupon_text']) && is_array($block['coupon_text'])) {
foreach ($block['coupon_text'] as $lang_id => $val) { foreach ($block['coupon_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['coupon_text'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['coupon_text'][$lang_id] = base64_encode((string)$val);
} }
} }
if (isset($block['coupon_code']) && is_array($block['coupon_code'])) { if (isset($block['coupon_code']) && is_array($block['coupon_code'])) {
foreach ($block['coupon_code'] as $lang_id => $val) { foreach ($block['coupon_code'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['coupon_code'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['coupon_code'][$lang_id] = base64_encode((string)$val);
} }
} }
if (isset($block['coupon_tooltip']) && is_array($block['coupon_tooltip'])) { if (isset($block['coupon_tooltip']) && is_array($block['coupon_tooltip'])) {
foreach ($block['coupon_tooltip'] as $lang_id => $val) { foreach ($block['coupon_tooltip'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['coupon_tooltip'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['coupon_tooltip'][$lang_id] = base64_encode((string)$val);
} }
} }
} elseif ($block['type'] === 'activity') { } elseif ($block['type'] === 'activity') {
if (isset($block['activity_text']) && is_array($block['activity_text'])) { if (isset($block['activity_text']) && is_array($block['activity_text'])) {
foreach ($block['activity_text'] as $lang_id => $val) { foreach ($block['activity_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['activity_text'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['activity_text'][$lang_id] = base64_encode((string)$val);
} }
} }
} elseif ($block['type'] === 'product') { } elseif ($block['type'] === 'product') {
if (isset($block['product_button_text']) && is_array($block['product_button_text'])) { if (isset($block['product_button_text']) && is_array($block['product_button_text'])) {
foreach ($block['product_button_text'] as $lang_id => $val) { foreach ($block['product_button_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['product_button_text'][$lang_id] = base64_encode($val); $slides[$i]['blocks'][$j]['product_button_text'][$lang_id] = base64_encode((string)$val);
} }
} }
} }
@ -789,93 +803,94 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
foreach ($slides as $i => $slide) { foreach ($slides as $i => $slide) {
if (isset($slide['blocks']) && is_array($slide['blocks'])) { if (isset($slide['blocks']) && is_array($slide['blocks'])) {
foreach ($slide['blocks'] as $j => $block) { foreach ($slide['blocks'] as $j => $block) {
if (!is_array($block) || empty($block['type'])) continue;
if ($block['type'] === 'text') { if ($block['type'] === 'text') {
if (isset($block['text']) && is_array($block['text'])) { if (isset($block['text']) && is_array($block['text'])) {
foreach ($block['text'] as $lang_id => $val) { foreach ($block['text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['text'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['text'][$lang_id] = base64_decode((string)$val);
} }
} }
if (isset($block['mobile_text']) && is_array($block['mobile_text'])) { if (isset($block['mobile_text']) && is_array($block['mobile_text'])) {
foreach ($block['mobile_text'] as $lang_id => $val) { foreach ($block['mobile_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['mobile_text'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['mobile_text'][$lang_id] = base64_decode((string)$val);
} }
} }
} elseif ($block['type'] === 'image') { } elseif ($block['type'] === 'image') {
if (isset($block['alt']) && is_array($block['alt'])) { if (isset($block['alt']) && is_array($block['alt'])) {
foreach ($block['alt'] as $lang_id => $val) { foreach ($block['alt'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['alt'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['alt'][$lang_id] = base64_decode((string)$val);
} }
} }
} elseif ($block['type'] === 'button') { } elseif ($block['type'] === 'button') {
if (isset($block['text']) && is_array($block['text'])) { if (isset($block['text']) && is_array($block['text'])) {
foreach ($block['text'] as $lang_id => $val) { foreach ($block['text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['text'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['text'][$lang_id] = base64_decode((string)$val);
} }
} }
if (isset($block['badge_text']) && is_array($block['badge_text'])) { if (isset($block['badge_text']) && is_array($block['badge_text'])) {
foreach ($block['badge_text'] as $lang_id => $val) { foreach ($block['badge_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['badge_text'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['badge_text'][$lang_id] = base64_decode((string)$val);
} }
} }
} elseif ($block['type'] === 'timer') { } elseif ($block['type'] === 'timer') {
if (isset($block['timer_fallback_text']) && is_array($block['timer_fallback_text'])) { if (isset($block['timer_fallback_text']) && is_array($block['timer_fallback_text'])) {
foreach ($block['timer_fallback_text'] as $lang_id => $val) { foreach ($block['timer_fallback_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['timer_fallback_text'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['timer_fallback_text'][$lang_id] = base64_decode((string)$val);
} }
} }
} elseif ($block['type'] === 'shipping') { } elseif ($block['type'] === 'shipping') {
if (isset($block['shipping_text_before']) && is_array($block['shipping_text_before'])) { if (isset($block['shipping_text_before']) && is_array($block['shipping_text_before'])) {
foreach ($block['shipping_text_before'] as $lang_id => $val) { foreach ($block['shipping_text_before'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['shipping_text_before'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['shipping_text_before'][$lang_id] = base64_decode((string)$val);
} }
} }
if (isset($block['shipping_text_after']) && is_array($block['shipping_text_after'])) { if (isset($block['shipping_text_after']) && is_array($block['shipping_text_after'])) {
foreach ($block['shipping_text_after'] as $lang_id => $val) { foreach ($block['shipping_text_after'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['shipping_text_after'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['shipping_text_after'][$lang_id] = base64_decode((string)$val);
} }
} }
} elseif ($block['type'] === 'subscribe') { } elseif ($block['type'] === 'subscribe') {
if (isset($block['subscribe_placeholder']) && is_array($block['subscribe_placeholder'])) { if (isset($block['subscribe_placeholder']) && is_array($block['subscribe_placeholder'])) {
foreach ($block['subscribe_placeholder'] as $lang_id => $val) { foreach ($block['subscribe_placeholder'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['subscribe_placeholder'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['subscribe_placeholder'][$lang_id] = base64_decode((string)$val);
} }
} }
if (isset($block['subscribe_button_text']) && is_array($block['subscribe_button_text'])) { if (isset($block['subscribe_button_text']) && is_array($block['subscribe_button_text'])) {
foreach ($block['subscribe_button_text'] as $lang_id => $val) { foreach ($block['subscribe_button_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['subscribe_button_text'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['subscribe_button_text'][$lang_id] = base64_decode((string)$val);
} }
} }
if (isset($block['subscribe_success_msg']) && is_array($block['subscribe_success_msg'])) { if (isset($block['subscribe_success_msg']) && is_array($block['subscribe_success_msg'])) {
foreach ($block['subscribe_success_msg'] as $lang_id => $val) { foreach ($block['subscribe_success_msg'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['subscribe_success_msg'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['subscribe_success_msg'][$lang_id] = base64_decode((string)$val);
} }
} }
} elseif ($block['type'] === 'coupon') { } elseif ($block['type'] === 'coupon') {
if (isset($block['coupon_text']) && is_array($block['coupon_text'])) { if (isset($block['coupon_text']) && is_array($block['coupon_text'])) {
foreach ($block['coupon_text'] as $lang_id => $val) { foreach ($block['coupon_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['coupon_text'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['coupon_text'][$lang_id] = base64_decode((string)$val);
} }
} }
if (isset($block['coupon_code']) && is_array($block['coupon_code'])) { if (isset($block['coupon_code']) && is_array($block['coupon_code'])) {
foreach ($block['coupon_code'] as $lang_id => $val) { foreach ($block['coupon_code'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['coupon_code'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['coupon_code'][$lang_id] = base64_decode((string)$val);
} }
} }
if (isset($block['coupon_tooltip']) && is_array($block['coupon_tooltip'])) { if (isset($block['coupon_tooltip']) && is_array($block['coupon_tooltip'])) {
foreach ($block['coupon_tooltip'] as $lang_id => $val) { foreach ($block['coupon_tooltip'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['coupon_tooltip'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['coupon_tooltip'][$lang_id] = base64_decode((string)$val);
} }
} }
} elseif ($block['type'] === 'activity') { } elseif ($block['type'] === 'activity') {
if (isset($block['activity_text']) && is_array($block['activity_text'])) { if (isset($block['activity_text']) && is_array($block['activity_text'])) {
foreach ($block['activity_text'] as $lang_id => $val) { foreach ($block['activity_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['activity_text'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['activity_text'][$lang_id] = base64_decode((string)$val);
} }
} }
} elseif ($block['type'] === 'product') { } elseif ($block['type'] === 'product') {
if (isset($block['product_button_text']) && is_array($block['product_button_text'])) { if (isset($block['product_button_text']) && is_array($block['product_button_text'])) {
foreach ($block['product_button_text'] as $lang_id => $val) { foreach ($block['product_button_text'] as $lang_id => $val) {
$slides[$i]['blocks'][$j]['product_button_text'][$lang_id] = base64_decode($val); $slides[$i]['blocks'][$j]['product_button_text'][$lang_id] = base64_decode((string)$val);
} }
} }
} }
@ -1106,8 +1121,8 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
try { try {
$is_installed = is_file(DIR_EXTENSION . 'promo_top_bar_nat/admin/controller/module/promo_top_bar_nat.php') || is_file(DIR_APPLICATION . 'controller/extension/module/promo_top_bar_nat.php'); $is_installed = is_file(DIR_EXTENSION . 'promo_top_bar_nat/admin/controller/module/promo_top_bar_nat.php') || is_file(DIR_APPLICATION . 'controller/extension/module/promo_top_bar_nat.php');
if ($is_installed) { if ($is_installed) {
$nat_status = $this->config->get('module_promo_top_bar_nat_status'); $1$nat_license = (string)$this->config->get('module_promo_top_bar_nat_license');
if ($nat_status === null || $nat_status) { if (!empty($nat_status) && $this->checkLicense($nat_license)) {
$nat_pos = $this->config->get('module_promo_top_bar_nat_menu_position'); $nat_pos = $this->config->get('module_promo_top_bar_nat_menu_position');
if (empty($nat_pos)) { $nat_pos = 'both'; } if (empty($nat_pos)) { $nat_pos = 'both'; }
if ($nat_pos == 'sidebar' || $nat_pos == 'both') { if ($nat_pos == 'sidebar' || $nat_pos == 'both') {
@ -1164,8 +1179,8 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
$output = $style . $output; $output = $style . $output;
} }
$nat_status = $this->config->get('module_promo_top_bar_nat_status'); $1$nat_license = (string)$this->config->get('module_promo_top_bar_nat_license');
if ($nat_status === null || $nat_status) { if (!empty($nat_status) && $this->checkLicense($nat_license)) {
$nat_pos = $this->config->get('module_promo_top_bar_nat_menu_position'); $nat_pos = $this->config->get('module_promo_top_bar_nat_menu_position');
if (empty($nat_pos)) { $nat_pos = 'both'; } if (empty($nat_pos)) { $nat_pos = 'both'; }
if ($nat_pos == 'header' || $nat_pos == 'both') { if ($nat_pos == 'header' || $nat_pos == 'both') {

View File

@ -1,4 +1,9 @@
<script> <script>
$.ajaxPrefilter(function(options) {
if (options && options.url) {
options.url = options.url.replace(/&amp;/g, '&');
}
});
(function() { (function() {
window.NAT_OC4_SEP = '{{ oc4_sep|default(".") }}'; window.NAT_OC4_SEP = '{{ oc4_sep|default(".") }}';
function natInitOc4Sep() { function natInitOc4Sep() {
@ -393,67 +398,25 @@ body.nat-dark-mode .nat-contact-btn:hover {
color: #ffffff !important; color: #ffffff !important;
} }
html.nat-dark-mode .nat-license-status-badge, html.nat-dark-mode .nat-license-status-badge,
body.nat-dark-mode body.nat-dark-mode .nat-license-status-badge,
.nat-license-input-group { html[data-bs-theme="dark"] .nat-license-status-badge,
display: flex !important; body[data-bs-theme="dark"] .nat-license-status-badge,
align-items: stretch !important; html[data-theme="dark"] .nat-license-status-badge,
} body[data-theme="dark"] .nat-license-status-badge,
.nat-license-input-group .form-control { html.dark .nat-license-status-badge,
height: 36px !important; body.dark .nat-license-status-badge {
line-height: 20px !important; background: rgba(5, 150, 105, 0.15) !important;
padding: 7px 12px !important; border-color: #059669 !important;
border-radius: 4px 0 0 4px !important; color: #34d399 !important;
box-sizing: border-box !important;
flex: 1 1 auto !important;
width: 1% !important;
min-width: 0 !important;
margin: 0 !important;
float: none !important;
position: relative !important;
z-index: 1 !important;
}
.nat-license-input-group .input-group-btn {
display: flex !important;
align-items: stretch !important;
width: auto !important;
flex: 0 0 auto !important;
margin: 0 0 0 -1px !important;
padding: 0 !important;
z-index: 2 !important;
vertical-align: top !important;
}
.nat-license-input-group .input-group-btn > .btn {
height: 36px !important;
max-height: 36px !important;
min-height: 36px !important;
line-height: 20px !important;
padding: 7px 14px !important;
border-radius: 0 4px 4px 0 !important;
box-sizing: border-box !important;
margin: 0 !important;
display: inline-flex !important;
align-items: center !important;
justify-content: center !important;
}
.nat-license-status-badge {
display: inline-flex !important;
align-items: center !important;
gap: 6px !important;
height: 36px !important;
line-height: 34px !important;
padding: 0 14px !important;
border-radius: 4px !important;
font-weight: 700 !important;
font-size: 12px !important;
background: #ecfdf5 !important;
border: 1px solid #a7f3d0 !important;
color: #059669 !important;
white-space: nowrap !important;
box-sizing: border-box !important;
} }
html.nat-dark-mode .nat-settings-license-row, html.nat-dark-mode .nat-settings-license-row,
body.nat-dark-mode .nat-settings-license-row { body.nat-dark-mode .nat-settings-license-row,
html[data-bs-theme="dark"] .nat-settings-license-row,
body[data-bs-theme="dark"] .nat-settings-license-row,
html[data-theme="dark"] .nat-settings-license-row,
body[data-theme="dark"] .nat-settings-license-row,
html.dark .nat-settings-license-row,
body.dark .nat-settings-license-row {
background: rgba(255, 255, 255, 0.03) !important; background: rgba(255, 255, 255, 0.03) !important;
border-color: #334155 !important; border-color: #334155 !important;
} }
@ -4909,7 +4872,7 @@ $(document).ready(function() {
$('#button-save').on('click', function() { $('#button-save').on('click', function() {
updateHiddenInputs(); updateHiddenInputs();
$.ajax({ $.ajax({
url: '{{ save }}', url: ('{{ save }}').replace(/&amp;/g, '&'),
type: 'post', type: 'post',
data: $('#form-promo-top-bar').serialize(), data: $('#form-promo-top-bar').serialize(),
dataType: 'json', dataType: 'json',
@ -4932,7 +4895,17 @@ $(document).ready(function() {
} }
}, },
error: function(xhr, ajaxOptions, thrownError) { error: function(xhr, ajaxOptions, thrownError) {
showToast(thrownError, 'error'); var errorMsg = thrownError;
if (xhr.status === 403) {
errorMsg = 'Access Denied / Доступ заборонено (403)';
} else if (xhr.status === 404) {
errorMsg = 'Route not found / Маршрут не знайдено (404)';
} else if (xhr.status >= 500) {
errorMsg = 'Server Error / Помилка сервера (' + xhr.status + ')';
} else if (xhr.responseText && xhr.responseText.indexOf('<') !== -1) {
errorMsg = 'Помилка сервера (отримано HTML замість JSON)';
}
showToast(errorMsg, 'error');
} }
}); });
}); });
@ -4948,7 +4921,7 @@ $(document).ready(function() {
if (window.natIsPurging) return; if (window.natIsPurging) return;
updateHiddenInputs(); updateHiddenInputs();
$.ajax({ $.ajax({
url: '{{ save }}', url: ('{{ save }}').replace(/&amp;/g, '&'),
type: 'post', type: 'post',
data: $('#form-promo-top-bar').serialize(), data: $('#form-promo-top-bar').serialize(),
dataType: 'json', dataType: 'json',

View File

@ -398,8 +398,8 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
if (isset($slide['blocks']) && is_array($slide['blocks'])) { if (isset($slide['blocks']) && is_array($slide['blocks'])) {
foreach ($slide['blocks'] as $blockIdx => $block) { foreach ($slide['blocks'] as $blockIdx => $block) {
if ($block['type'] === 'text') { if ($block['type'] === 'text') {
$text = isset($block['text'][$lang_id]) ? trim(base64_decode($block['text'][$lang_id])) : ''; $text = isset($block['text'][$lang_id]) ? trim(base64_decode((string)$block['text'][$lang_id])) : '';
$mobile_text = isset($block['mobile_text'][$lang_id]) ? trim(base64_decode($block['mobile_text'][$lang_id])) : ''; $mobile_text = isset($block['mobile_text'][$lang_id]) ? trim(base64_decode((string)$block['mobile_text'][$lang_id])) : '';
$blocks[] = [ $blocks[] = [
'type' => 'text', 'type' => 'text',
'text' => html_entity_decode($text, ENT_QUOTES, 'UTF-8'), 'text' => html_entity_decode($text, ENT_QUOTES, 'UTF-8'),
@ -423,7 +423,7 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
} else { } else {
$img_src = $this->model_tool_image->resize($img_path, $width, $height); $img_src = $this->model_tool_image->resize($img_path, $width, $height);
} }
$alt_text = isset($block['alt'][$lang_id]) ? trim(base64_decode($block['alt'][$lang_id])) : ''; $alt_text = isset($block['alt'][$lang_id]) ? trim(base64_decode((string)$block['alt'][$lang_id])) : '';
$img_link = isset($block['link']) ? trim($block['link']) : ''; $img_link = isset($block['link']) ? trim($block['link']) : '';
if (strpos($img_link, 'route:') === 0) { if (strpos($img_link, 'route:') === 0) {
$img_link = $this->parseSystemRoute($img_link); $img_link = $this->parseSystemRoute($img_link);
@ -441,7 +441,7 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
]; ];
} }
} elseif ($block['type'] === 'button') { } elseif ($block['type'] === 'button') {
$btn_text = isset($block['text'][$lang_id]) ? trim(base64_decode($block['text'][$lang_id])) : ''; $btn_text = isset($block['text'][$lang_id]) ? trim(base64_decode((string)$block['text'][$lang_id])) : '';
$btn_link = isset($block['link']) ? trim($block['link']) : ''; $btn_link = isset($block['link']) ? trim($block['link']) : '';
if (strpos($btn_link, 'route:') === 0) { if (strpos($btn_link, 'route:') === 0) {
$btn_link = $this->parseSystemRoute($btn_link); $btn_link = $this->parseSystemRoute($btn_link);
@ -458,7 +458,7 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
'color_hover' => $block['color_hover'] ?? '#ffffff', 'color_hover' => $block['color_hover'] ?? '#ffffff',
'button_icon' => $block['button_icon'] ?? '', 'button_icon' => $block['button_icon'] ?? '',
'badge_status' => isset($block['badge_status']) && $block['badge_status'] == '1', 'badge_status' => isset($block['badge_status']) && $block['badge_status'] == '1',
'badge_text' => isset($block['badge_text'][$lang_id]) ? html_entity_decode(trim(base64_decode($block['badge_text'][$lang_id])), ENT_QUOTES, 'UTF-8') : '', 'badge_text' => isset($block['badge_text'][$lang_id]) ? html_entity_decode(trim(base64_decode((string)$block['badge_text'][$lang_id])), ENT_QUOTES, 'UTF-8') : '',
'badge_bg' => $block['badge_bg'] ?? '#e74c3c', 'badge_bg' => $block['badge_bg'] ?? '#e74c3c',
'badge_color' => $block['badge_color'] ?? '#ffffff', 'badge_color' => $block['badge_color'] ?? '#ffffff',
'animation' => $block['animation'] ?? '', 'animation' => $block['animation'] ?? '',
@ -469,7 +469,7 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
'custom_css' => $block['custom_css'] ?? '' 'custom_css' => $block['custom_css'] ?? ''
]; ];
} elseif ($block['type'] === 'timer') { } elseif ($block['type'] === 'timer') {
$fallback_text = isset($block['timer_fallback_text'][$lang_id]) ? trim(base64_decode($block['timer_fallback_text'][$lang_id])) : ''; $fallback_text = isset($block['timer_fallback_text'][$lang_id]) ? trim(base64_decode((string)$block['timer_fallback_text'][$lang_id])) : '';
$blocks[] = [ $blocks[] = [
'type' => 'timer', 'type' => 'timer',
'timer_mode' => $block['timer_mode'] ?? 'fixed', 'timer_mode' => $block['timer_mode'] ?? 'fixed',
@ -487,8 +487,8 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
$shipping_total = (float)($block['shipping_total'] ?? 2000); $shipping_total = (float)($block['shipping_total'] ?? 2000);
$percent = $shipping_total > 0 ? min(100, max(0, ($cart_total / $shipping_total) * 100)) : 100; $percent = $shipping_total > 0 ? min(100, max(0, ($cart_total / $shipping_total) * 100)) : 100;
$before = isset($block['shipping_text_before'][$lang_id]) ? trim(base64_decode($block['shipping_text_before'][$lang_id])) : ''; $before = isset($block['shipping_text_before'][$lang_id]) ? trim(base64_decode((string)$block['shipping_text_before'][$lang_id])) : '';
$after = isset($block['shipping_text_after'][$lang_id]) ? trim(base64_decode($block['shipping_text_after'][$lang_id])) : ''; $after = isset($block['shipping_text_after'][$lang_id]) ? trim(base64_decode((string)$block['shipping_text_after'][$lang_id])) : '';
if ($cart_total >= $shipping_total) { if ($cart_total >= $shipping_total) {
$text = $after ?: $this->language->get('text_free_shipping_active'); $text = $after ?: $this->language->get('text_free_shipping_active');
@ -510,9 +510,9 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
'custom_css' => $block['custom_css'] ?? '' 'custom_css' => $block['custom_css'] ?? ''
]; ];
} elseif ($block['type'] === 'subscribe') { } elseif ($block['type'] === 'subscribe') {
$placeholder = isset($block['subscribe_placeholder'][$lang_id]) ? trim(base64_decode($block['subscribe_placeholder'][$lang_id])) : ''; $placeholder = isset($block['subscribe_placeholder'][$lang_id]) ? trim(base64_decode((string)$block['subscribe_placeholder'][$lang_id])) : '';
$btn_text = isset($block['subscribe_button_text'][$lang_id]) ? trim(base64_decode($block['subscribe_button_text'][$lang_id])) : ''; $btn_text = isset($block['subscribe_button_text'][$lang_id]) ? trim(base64_decode((string)$block['subscribe_button_text'][$lang_id])) : '';
$success_msg = isset($block['subscribe_success_msg'][$lang_id]) ? trim(base64_decode($block['subscribe_success_msg'][$lang_id])) : ''; $success_msg = isset($block['subscribe_success_msg'][$lang_id]) ? trim(base64_decode((string)$block['subscribe_success_msg'][$lang_id])) : '';
$blocks[] = [ $blocks[] = [
'type' => 'subscribe', 'type' => 'subscribe',
@ -528,9 +528,9 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
'custom_css' => $block['custom_css'] ?? '' 'custom_css' => $block['custom_css'] ?? ''
]; ];
} elseif ($block['type'] === 'coupon') { } elseif ($block['type'] === 'coupon') {
$coupon_text = isset($block['coupon_text'][$lang_id]) ? trim(base64_decode($block['coupon_text'][$lang_id])) : ''; $coupon_text = isset($block['coupon_text'][$lang_id]) ? trim(base64_decode((string)$block['coupon_text'][$lang_id])) : '';
$coupon_code = isset($block['coupon_code'][$lang_id]) ? trim(base64_decode($block['coupon_code'][$lang_id])) : ''; $coupon_code = isset($block['coupon_code'][$lang_id]) ? trim(base64_decode((string)$block['coupon_code'][$lang_id])) : '';
$coupon_tooltip = isset($block['coupon_tooltip'][$lang_id]) ? trim(base64_decode($block['coupon_tooltip'][$lang_id])) : ''; $coupon_tooltip = isset($block['coupon_tooltip'][$lang_id]) ? trim(base64_decode((string)$block['coupon_tooltip'][$lang_id])) : '';
$blocks[] = [ $blocks[] = [
'type' => 'coupon', 'type' => 'coupon',
@ -557,7 +557,7 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
$count = rand($min, $max); $count = rand($min, $max);
srand(); srand();
$template_text = isset($block['activity_text'][$lang_id]) ? trim(base64_decode($block['activity_text'][$lang_id])) : ''; $template_text = isset($block['activity_text'][$lang_id]) ? trim(base64_decode((string)$block['activity_text'][$lang_id])) : '';
if (empty($template_text)) { if (empty($template_text)) {
$template_text = sprintf($this->language->get('text_activity_views'), '{count}'); $template_text = sprintf($this->language->get('text_activity_views'), '{count}');
} }
@ -594,7 +594,7 @@ class PromoTopBarNat extends \Opencart\System\Engine\Controller {
} }
} }
$btn_text = isset($block['product_button_text'][$lang_id]) ? trim(base64_decode($block['product_button_text'][$lang_id])) : ''; $btn_text = isset($block['product_button_text'][$lang_id]) ? trim(base64_decode((string)$block['product_button_text'][$lang_id])) : '';
$blocks[] = [ $blocks[] = [
'type' => 'product', 'type' => 'product',

Binary file not shown.