feat(oc20-22): Language::all fix, serialize compatibility, menu.php/menu.tpl support, Gatekeeper V5 and Anti-Zombie backup

This commit is contained in:
nertyog 2026-10-12 04:48:58 +03:00
parent d6a56769a2
commit 44df0f8ac3
13 changed files with 1126 additions and 311 deletions

View File

@ -7,6 +7,45 @@
<author>NAT</author> <author>NAT</author>
<link>mailto:info@nat.od.ua</link> <link>mailto:info@nat.od.ua</link>
<file path="admin/controller/common/menu.php">
<operation error="skip">
<search><![CDATA[$data['text_dashboard'] = $this->language->get('text_dashboard');]]></search>
<add position="before"><![CDATA[
try {
if (is_file(DIR_APPLICATION . 'controller/module/poll_widget_nat.php')) {
$this->load->model('setting/setting');
$nat_status = $this->config->get('module_poll_widget_nat_status');
if ($nat_status === null || $nat_status) {
$nat_pos = $this->config->get('module_poll_widget_nat_menu_position');
if (empty($nat_pos)) { $nat_pos = 'both'; }
if ($nat_pos == 'sidebar' || $nat_pos == 'both') {
if ($this->user->hasPermission('access', 'module/poll_widget_nat')) {
$data['poll_widget_nat_href'] = $this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], 'SSL');
}
}
}
}
} catch (\Throwable $e) {
}
]]></add>
</operation>
</file>
<file path="admin/view/template/common/menu.tpl">
<operation error="skip">
<search><![CDATA[<li id="catalog">]]></search>
<add position="before"><![CDATA[
<?php if (!empty($poll_widget_nat_href)) { ?>
<li id="menu-nat"><a class="parent"><i class="fa fa-space-shuttle fa-rotate-270 fw" style="color: #ec741c;"></i> <span>[NAT] Modules</span></a>
<ul>
<li><a href="<?php echo $poll_widget_nat_href; ?>"><i class="fa fa-angle-right"></i> Poll Widget</a></li>
</ul>
</li>
<?php } ?>
]]></add>
</operation>
</file>
<file path="admin/controller/common/column_left.php"> <file path="admin/controller/common/column_left.php">
<operation error="skip"> <operation error="skip">
<search><![CDATA[if ($this->user->hasPermission('access', 'catalog/product')) {]]></search> <search><![CDATA[if ($this->user->hasPermission('access', 'catalog/product')) {]]></search>
@ -41,7 +80,7 @@
} else { } else {
$data['menus'][] = array( $data['menus'][] = array(
'id' => 'menu-nat', 'id' => 'menu-nat',
'icon' => 'fa-rocket fw', 'icon' => 'fa-space-shuttle fa-rotate-270 fw',
'name' => '[NAT] Modules', 'name' => '[NAT] Modules',
'href' => '', 'href' => '',
'children' => array($nat_item) 'children' => array($nat_item)
@ -75,7 +114,7 @@
if ($this->user->hasPermission('access', 'module/poll_widget_nat')) { if ($this->user->hasPermission('access', 'module/poll_widget_nat')) {
$data['nat_menus'][] = array( $data['nat_menus'][] = array(
'name' => 'Poll Widget', 'name' => 'Poll Widget',
'href' => $this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true) 'href' => $this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], 'SSL')
); );
} }
} }
@ -88,13 +127,30 @@
</file> </file>
<file path="admin/view/template/common/header.tpl"> <file path="admin/view/template/common/header.tpl">
<operation error="skip">
<search><![CDATA[</head>]]></search>
<add position="before"><![CDATA[
<style type="text/css">
#nat-ecosystem-menu .fa-space-shuttle,
#collapse-nat .fa-space-shuttle,
.fa-space-shuttle.fa-rotate-270 {
color: #ec741c !important;
}
#nat-ecosystem-menu a:hover .fa-space-shuttle {
color: #ff8c3b !important;
}
#nat-ecosystem-menu .fa-rocket { color: #ec741c !important; }
#nat-ecosystem-menu .fa-rocket:before { content: "\f197" !important; display: inline-block; transform: rotate(270deg); }
</style>
]]></add>
</operation>
<operation error="skip"> <operation error="skip">
<search><![CDATA[<li><a href="<?php echo $logout; ?>"]]></search> <search><![CDATA[<li><a href="<?php echo $logout; ?>"]]></search>
<add position="before"><![CDATA[ <add position="before"><![CDATA[
<?php if (isset($nat_menus) && $nat_menus && empty($nat_menu_rendered)) { ?> <?php if (isset($nat_menus) && $nat_menus && empty($nat_menu_rendered)) { ?>
<?php $nat_menu_rendered = true; ?> <?php $nat_menu_rendered = true; ?>
<li class="dropdown" id="nat-ecosystem-menu"> <li class="dropdown" id="nat-ecosystem-menu">
<a class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-rocket fa-lg" style="color:#e74c3c;"></i> <span class="hidden-xs hidden-sm hidden-md">[NAT]</span> <span class="caret"></span></a> <a class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-space-shuttle fa-rotate-270" style="color: #ec741c;"></i> <span class="hidden-xs hidden-sm hidden-md">[NAT]</span> <span class="caret"></span></a>
<ul class="dropdown-menu dropdown-menu-right" id="nat-ecosystem-list"> <ul class="dropdown-menu dropdown-menu-right" id="nat-ecosystem-list">
<li class="dropdown-header">Ecosystem [NAT]</li> <li class="dropdown-header">Ecosystem [NAT]</li>
<?php foreach ($nat_menus as $n_menu) { ?> <?php foreach ($nat_menus as $n_menu) { ?>

View File

@ -39,8 +39,12 @@ class ControllerModulePollWidgetNat extends Controller {
$this->load->model('setting/setting'); $this->load->model('setting/setting');
$this->model_setting_setting->editSetting('module_poll_widget_nat', array( $this->model_setting_setting->editSetting('module_poll_widget_nat', array(
'module_poll_widget_nat_status' => 1, 'module_poll_widget_nat_status' => 1,
'poll_widget_nat_status' => 1,
'module_poll_widget_nat_menu_position' => 'both' 'module_poll_widget_nat_menu_position' => 'both'
)); ));
$this->model_setting_setting->editSetting('poll_widget_nat', array(
'poll_widget_nat_status' => 1
));
} }
public function uninstall() { public function uninstall() {
@ -51,7 +55,10 @@ class ControllerModulePollWidgetNat extends Controller {
private function checkLicense($key) { private function checkLicense($key) {
if (empty($key)) return false; if (empty($key)) return false;
$host = explode(':', str_replace(array('http://', 'https://', 'www.'), '', strtolower($this->request->server['HTTP_HOST'])))[0]; $_h = defined('HTTP_CATALOG') ? parse_url(HTTP_CATALOG, PHP_URL_HOST) : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
$_h = preg_replace('/:\d+$/', '', trim((string)$_h));
$_h = preg_replace('/^www\./i', '', $_h);
$host = strtolower($_h);
$parts = explode('.', $host); $parts = explode('.', $host);
$v_core = '_redis'; $v_core = '_redis';
$v_end = 'aet_'; $v_end = 'aet_';
@ -74,21 +81,72 @@ class ControllerModulePollWidgetNat extends Controller {
public function index() { public function index() {
$this->load->language('module/poll_widget_nat'); $this->load->language('module/poll_widget_nat');
$this->document->setTitle($this->language->get('heading_title_raw')); if ($this->language->get('heading_title_raw')) {
$this->load->model('module/poll_widget_nat'); $this->document->setTitle($this->language->get('heading_title_raw'));
} else {
$this->document->setTitle(strip_tags($this->language->get('heading_title')));
}
if (is_file(DIR_APPLICATION . 'model/module/poll_widget_nat.php')) {
$this->load->model('module/poll_widget_nat');
}
$this->load->model('setting/setting'); $this->load->model('setting/setting');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_setting_setting->editSetting('module_poll_widget_nat', $this->request->post); $settings = $this->model_setting_setting->getSetting('module_poll_widget_nat');
$data_post = array_merge($settings, $this->request->post);
$posted_lic = isset($this->request->post['module_poll_widget_nat_license']) ? trim((string)$this->request->post['module_poll_widget_nat_license']) : (isset($data_post['module_poll_widget_nat_license']) ? trim((string)$data_post['module_poll_widget_nat_license']) : '');
$data_post['module_poll_widget_nat_license'] = $posted_lic;
$data_post['poll_widget_nat_status'] = !empty($data_post['module_poll_widget_nat_status']) ? 1 : 0;
$this->model_setting_setting->editSetting('module_poll_widget_nat', $data_post);
$this->model_setting_setting->editSetting('poll_widget_nat', array(
'poll_widget_nat_status' => $data_post['poll_widget_nat_status']
));
if ($posted_lic === '') {
$this->model_setting_setting->deleteSetting('nat_poll_widget_backup');
} else {
$this->model_setting_setting->editSetting('nat_poll_widget_backup', $data_post);
}
$this->session->data['success'] = $this->language->get('text_success'); $this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true)); $this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true));
} }
$current_lic = (string)$this->config->get('module_poll_widget_nat_license');
$has_deliberate_setting = ($this->config->get('module_poll_widget_nat_license') !== null);
if (!$has_deliberate_setting && (empty($current_lic) || !$this->checkLicense($current_lic))) {
$restored = array();
$bk_set = $this->model_setting_setting->getSetting('nat_poll_widget_backup');
if (!empty($bk_set) && is_array($bk_set) && !empty($bk_set['module_poll_widget_nat_license'])) {
$restored = $bk_set;
}
if (!empty($restored) && !empty($restored['module_poll_widget_nat_license'])) {
$this->model_setting_setting->editSetting('module_poll_widget_nat', $restored);
$this->model_setting_setting->editSetting('poll_widget_nat', array(
'poll_widget_nat_status' => !empty($restored['module_poll_widget_nat_status']) ? 1 : 0
));
foreach ($restored as $rk => $rv) {
$this->config->set($rk, $rv);
}
}
}
$this->getList(); $this->getList();
} }
protected function getList() { protected function getList() {
$data = array_merge(array(), $this->language->all()); $data = array();
$langs = $this->load->language('module/poll_widget_nat');
if (is_array($langs)) {
foreach ($langs as $k => $v) {
$data[$k] = $v;
}
}
$data['heading_title_raw'] = $this->language->get('heading_title_raw') ? $this->language->get('heading_title_raw') : strip_tags($this->language->get('heading_title'));
$data['breadcrumbs'] = array(); $data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array( $data['breadcrumbs'][] = array(
@ -100,7 +158,7 @@ class ControllerModulePollWidgetNat extends Controller {
'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], true) 'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], true)
); );
$data['breadcrumbs'][] = array( $data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title_raw'), 'text' => strip_tags($this->language->get('heading_title_raw') ? $this->language->get('heading_title_raw') : $this->language->get('heading_title')),
'href' => $this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true) 'href' => $this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true)
); );
@ -134,19 +192,29 @@ class ControllerModulePollWidgetNat extends Controller {
$data['module_poll_widget_nat_menu_position'] = 'both'; $data['module_poll_widget_nat_menu_position'] = 'both';
} }
$data['is_licensed'] = $this->checkLicense($data['module_poll_widget_nat_license']); $data['token'] = $this->session->data['token'];
$_h = defined('HTTP_CATALOG') ? parse_url(HTTP_CATALOG, PHP_URL_HOST) : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
$_h = preg_replace('/:\d+$/', '', trim((string)$_h));
$_h = preg_replace('/^www\./i', '', $_h);
$data['nat_current_domain'] = strtolower($_h);
$data['is_licensed'] = $this->checkLicense((string)$this->config->get('module_poll_widget_nat_license'));
$data['polls'] = array(); $data['polls'] = array();
$results = $this->model_module_poll_widget_nat->getPolls(); try {
if (isset($this->model_module_poll_widget_nat)) {
$results = $this->model_module_poll_widget_nat->getPolls();
foreach ($results as $result) { foreach ($results as $result) {
$data['polls'][] = array( $data['polls'][] = array(
'poll_id' => (int)$result['poll_id'], 'poll_id' => (int)$result['poll_id'],
'question'=> (string)$result['question'], 'question'=> (string)$result['question'],
'status' => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')), 'status' => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')),
'edit' => $this->url->link('module/poll_widget_nat/edit', 'token=' . $this->session->data['token'] . '&poll_id=' . (int)$result['poll_id'], true), 'edit' => $this->url->link('module/poll_widget_nat/edit', 'token=' . $this->session->data['token'] . '&poll_id=' . (int)$result['poll_id'], true),
'delete' => $this->url->link('module/poll_widget_nat/delete', 'token=' . $this->session->data['token'] . '&poll_id=' . (int)$result['poll_id'], true) 'delete' => $this->url->link('module/poll_widget_nat/delete', 'token=' . $this->session->data['token'] . '&poll_id=' . (int)$result['poll_id'], true)
); );
}
}
} catch (\Throwable $e) {
} }
if (isset($this->session->data['success'])) { if (isset($this->session->data['success'])) {
@ -166,11 +234,8 @@ class ControllerModulePollWidgetNat extends Controller {
$data['column_left'] = $this->load->controller('common/column_left'); $data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer'); $data['footer'] = $this->load->controller('common/footer');
if (version_compare(VERSION, '2.2.0.0', '<')) { $view_path = (defined('VERSION') && version_compare(VERSION, '2.2.0.0', '<')) ? 'module/poll_widget_nat_list.tpl' : 'module/poll_widget_nat_list';
$this->response->setOutput($this->load->view('module/poll_widget_nat_list.tpl', $data)); $this->response->setOutput($this->load->view($view_path, $data));
} else {
$this->response->setOutput($this->load->view('module/poll_widget_nat_list', $data));
}
} }
public function add() { public function add() {
@ -178,13 +243,25 @@ class ControllerModulePollWidgetNat extends Controller {
if (!$this->checkLicense($this->config->get('module_poll_widget_nat_license'))) { if (!$this->checkLicense($this->config->get('module_poll_widget_nat_license'))) {
$this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true)); $this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true));
} }
$this->document->setTitle($this->language->get('heading_title_raw')); if ($this->language->get('heading_title_raw')) {
$this->load->model('module/poll_widget_nat'); $this->document->setTitle($this->language->get('heading_title_raw'));
} else {
$this->document->setTitle(strip_tags($this->language->get('heading_title')));
}
if (is_file(DIR_APPLICATION . 'model/module/poll_widget_nat.php')) {
$this->load->model('module/poll_widget_nat');
}
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { try {
$this->model_module_poll_widget_nat->addPoll($this->request->post); if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
$this->session->data['success'] = $this->language->get('text_success'); if (isset($this->model_module_poll_widget_nat)) {
$this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true)); $this->model_module_poll_widget_nat->addPoll($this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true));
}
}
} catch (\Throwable $e) {
$this->error['warning'] = $e->getMessage();
} }
$this->getForm(); $this->getForm();
@ -195,13 +272,25 @@ class ControllerModulePollWidgetNat extends Controller {
if (!$this->checkLicense($this->config->get('module_poll_widget_nat_license'))) { if (!$this->checkLicense($this->config->get('module_poll_widget_nat_license'))) {
$this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true)); $this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true));
} }
$this->document->setTitle($this->language->get('heading_title_raw')); if ($this->language->get('heading_title_raw')) {
$this->load->model('module/poll_widget_nat'); $this->document->setTitle($this->language->get('heading_title_raw'));
} else {
$this->document->setTitle(strip_tags($this->language->get('heading_title')));
}
if (is_file(DIR_APPLICATION . 'model/module/poll_widget_nat.php')) {
$this->load->model('module/poll_widget_nat');
}
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { try {
$this->model_module_poll_widget_nat->editPoll((int)$this->request->get['poll_id'], $this->request->post); if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
$this->session->data['success'] = $this->language->get('text_success'); if (isset($this->model_module_poll_widget_nat)) {
$this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true)); $this->model_module_poll_widget_nat->editPoll((int)$this->request->get['poll_id'], $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true));
}
}
} catch (\Throwable $e) {
$this->error['warning'] = $e->getMessage();
} }
$this->getForm(); $this->getForm();
@ -212,18 +301,40 @@ class ControllerModulePollWidgetNat extends Controller {
if (!$this->checkLicense($this->config->get('module_poll_widget_nat_license'))) { if (!$this->checkLicense($this->config->get('module_poll_widget_nat_license'))) {
$this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true)); $this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true));
} }
$this->load->model('module/poll_widget_nat'); if (is_file(DIR_APPLICATION . 'model/module/poll_widget_nat.php')) {
$this->load->model('module/poll_widget_nat');
}
if (isset($this->request->get['poll_id']) && $this->validate()) { try {
$this->model_module_poll_widget_nat->deletePoll((int)$this->request->get['poll_id']); if (isset($this->request->get['poll_id']) && $this->validate()) {
$this->session->data['success'] = $this->language->get('text_success'); if (isset($this->model_module_poll_widget_nat)) {
$this->model_module_poll_widget_nat->deletePoll((int)$this->request->get['poll_id']);
$this->session->data['success'] = $this->language->get('text_success');
}
}
} catch (\Throwable $e) {
$this->error['warning'] = $e->getMessage();
} }
$this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true)); $this->response->redirect($this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true));
} }
protected function getForm() { protected function getForm() {
$data = array_merge(array(), $this->language->all()); $data = array();
$langs = $this->load->language('module/poll_widget_nat');
if (is_array($langs)) {
foreach ($langs as $k => $v) {
$data[$k] = $v;
}
}
$data['heading_title_raw'] = $this->language->get('heading_title_raw') ? $this->language->get('heading_title_raw') : strip_tags($this->language->get('heading_title'));
$data['token'] = $this->session->data['token'];
$_h = defined('HTTP_CATALOG') ? parse_url(HTTP_CATALOG, PHP_URL_HOST) : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
$_h = preg_replace('/:\d+$/', '', trim((string)$_h));
$_h = preg_replace('/^www\./i', '', $_h);
$data['nat_current_domain'] = strtolower($_h);
$data['is_licensed'] = $this->checkLicense((string)$this->config->get('module_poll_widget_nat_license'));
if (isset($this->error['warning'])) { if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning']; $data['error_warning'] = $this->error['warning'];
@ -243,7 +354,11 @@ class ControllerModulePollWidgetNat extends Controller {
'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true)
); );
$data['breadcrumbs'][] = array( $data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title_raw'), 'text' => $this->language->get('text_extension'),
'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], true)
);
$data['breadcrumbs'][] = array(
'text' => strip_tags($this->language->get('heading_title_raw') ? $this->language->get('heading_title_raw') : $this->language->get('heading_title')),
'href' => $this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true) 'href' => $this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true)
); );
@ -258,13 +373,18 @@ class ControllerModulePollWidgetNat extends Controller {
$data['cancel'] = $this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true); $data['cancel'] = $this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true);
$poll_info = array(); $poll_info = array();
if ($poll_id && ($this->request->server['REQUEST_METHOD'] != 'POST')) { try {
$poll_info = $this->model_module_poll_widget_nat->getPoll($poll_id); if ($poll_id && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
if ($poll_info) { if (isset($this->model_module_poll_widget_nat)) {
$poll_info['config'] = json_decode($poll_info['config'], true); $poll_info = $this->model_module_poll_widget_nat->getPoll($poll_id);
$poll_info['colors'] = json_decode($poll_info['colors'], true); if ($poll_info) {
$poll_info['custom_stats'] = json_decode($poll_info['custom_stats'], true); $poll_info['config'] = json_decode($poll_info['config'], true);
$poll_info['colors'] = json_decode($poll_info['colors'], true);
$poll_info['custom_stats'] = json_decode($poll_info['custom_stats'], true);
}
}
} }
} catch (\Throwable $e) {
} }
$this->load->model('localisation/language'); $this->load->model('localisation/language');
@ -273,7 +393,11 @@ class ControllerModulePollWidgetNat extends Controller {
if (isset($this->request->post['poll_description'])) { if (isset($this->request->post['poll_description'])) {
$data['poll_description'] = $this->request->post['poll_description']; $data['poll_description'] = $this->request->post['poll_description'];
} elseif ($poll_id) { } elseif ($poll_id) {
$data['poll_description'] = $this->model_module_poll_widget_nat->getPollDescriptions($poll_id); try {
$data['poll_description'] = isset($this->model_module_poll_widget_nat) ? $this->model_module_poll_widget_nat->getPollDescriptions($poll_id) : array();
} catch (\Throwable $e) {
$data['poll_description'] = array();
}
} else { } else {
$data['poll_description'] = array(); $data['poll_description'] = array();
} }
@ -326,22 +450,27 @@ class ControllerModulePollWidgetNat extends Controller {
$data['total_votes_count'] = 0; $data['total_votes_count'] = 0;
if ($poll_id) { if ($poll_id) {
$data['voted_total'] = $this->model_module_poll_widget_nat->getVotesCountByIndex($poll_id); try {
$data['total_votes_count'] = $this->model_module_poll_widget_nat->getTotalVotes($poll_id); if (isset($this->model_module_poll_widget_nat)) {
$data['voted_total'] = $this->model_module_poll_widget_nat->getVotesCountByIndex($poll_id);
$data['total_votes_count'] = $this->model_module_poll_widget_nat->getTotalVotes($poll_id);
$results = $this->model_module_poll_widget_nat->getVotes($poll_id, ($page - 1) * $limit, $limit); $results = $this->model_module_poll_widget_nat->getVotes($poll_id, ($page - 1) * $limit, $limit);
foreach ($results as $result) { foreach ($results as $result) {
$user_info = $result['customer_id'] ? $result['firstname'] . ' ' . $result['lastname'] . ' (' . $result['email'] . ')' : $this->language->get('text_guest'); $user_info = $result['customer_id'] ? $result['firstname'] . ' ' . $result['lastname'] . ' (' . $result['email'] . ')' : $this->language->get('text_guest');
$answer_text = isset($answers_map[$result['answer_index']]) ? $answers_map[$result['answer_index']] : $this->language->get('text_answer_index') . ' ' . (int)$result['answer_index']; $answer_text = isset($answers_map[$result['answer_index']]) ? $answers_map[$result['answer_index']] : $this->language->get('text_answer_index') . ' ' . (int)$result['answer_index'];
$data['latest_votes'][] = array( $data['latest_votes'][] = array(
'answer' => $answer_text, 'answer' => $answer_text,
'user' => $user_info, 'user' => $user_info,
'ip' => $result['ip'], 'ip' => $result['ip'],
'page_url' => isset($result['page_url']) ? $result['page_url'] : '', 'page_url' => isset($result['page_url']) ? $result['page_url'] : '',
'date' => date('d.m.Y H:i', strtotime($result['date_added'])) 'date' => date('d.m.Y H:i', strtotime($result['date_added']))
); );
}
}
} catch (\Throwable $e) {
} }
} }
@ -357,11 +486,8 @@ class ControllerModulePollWidgetNat extends Controller {
$data['column_left'] = $this->load->controller('common/column_left'); $data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer'); $data['footer'] = $this->load->controller('common/footer');
if (version_compare(VERSION, '2.2.0.0', '<')) { $view_path = (defined('VERSION') && version_compare(VERSION, '2.2.0.0', '<')) ? 'module/poll_widget_nat_form.tpl' : 'module/poll_widget_nat_form';
$this->response->setOutput($this->load->view('module/poll_widget_nat_form.tpl', $data)); $this->response->setOutput($this->load->view($view_path, $data));
} else {
$this->response->setOutput($this->load->view('module/poll_widget_nat_form', $data));
}
} }
protected function validate() { protected function validate() {
@ -386,4 +512,22 @@ class ControllerModulePollWidgetNat extends Controller {
} }
return !$this->error; return !$this->error;
} }
public function purgeAllData() {
$json = array();
if (!$this->user->hasPermission('modify', 'module/poll_widget_nat')) {
$json['error'] = 'Permission denied';
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
return;
}
$this->load->model('setting/setting');
$this->model_setting_setting->deleteSetting('module_poll_widget_nat');
$this->model_setting_setting->deleteSetting('poll_widget_nat');
$this->model_setting_setting->deleteSetting('nat_poll_widget_backup');
$json['success'] = true;
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
} }

View File

@ -1,6 +1,15 @@
<?php <?php
$_['heading_title'] = '<b>Poll Widget [NAT]:</b> Polls and Voting'; $_['heading_title'] = '<b><i class="fa fa-space-shuttle fa-rotate-270" style="color: #ec741c; margin-right: 3px; vertical-align: -1px;"></i>Poll Widget [NAT]:</b> Polls and Voting';
$_['heading_title_raw'] = 'Poll Widget [NAT]: Polls and Voting'; $_['heading_title_raw'] = 'Poll Widget [NAT]';
$_['tab_nat_info'] = 'About Module';
$_['text_nat_author'] = 'Author / Developer:';
$_['text_nat_support'] = 'Technical Support:';
$_['text_nat_tg_channel'] = 'Support Telegram Bot:';
$_['text_nat_dev_profile'] = 'Forum Profile:';
$_['text_nat_site'] = 'Official Website:';
$_['text_nat_version_badge']= 'Official Version 3.0 ai';
$_['text_extension'] = 'Extensions'; $_['text_extension'] = 'Extensions';
$_['text_success'] = 'Module settings successfully updated!'; $_['text_success'] = 'Module settings successfully updated!';
$_['text_edit'] = 'Edit Poll'; $_['text_edit'] = 'Edit Poll';
@ -91,3 +100,19 @@ $_['text_poll_widget_desc'] = 'Create polls and voting widgets with a visual d
$_['text_current_module'] = 'Current module'; $_['text_current_module'] = 'Current module';
$_['text_info_title_promo_top_bar'] = 'Promo Top Bar [NAT]: Upper promotional info-banner, information bar above header, marquee and top-banner'; $_['text_info_title_promo_top_bar'] = 'Promo Top Bar [NAT]: Upper promotional info-banner, information bar above header, marquee and top-banner';
$_['text_info_desc_promo_top_bar'] = 'Create interactive promo bars and header slideshows with a block builder, countdown timers, subscription forms, and flexible targeting.'; $_['text_info_desc_promo_top_bar'] = 'Create interactive promo bars and header slideshows with a block builder, countdown timers, subscription forms, and flexible targeting.';
$_['nat_gk_title'] = 'Module Activation';
$_['text_nat_domain_label'] = 'Your domain:';
$_['text_nat_copy_domain'] = 'Copy';
$_['text_nat_enter_key'] = 'Enter license key:';
$_['button_nat_activate'] = 'Activate';
$_['text_nat_bot_btn'] = 'Get key via Telegram Bot';
$_['text_nat_rules_title'] = 'License Terms:';
$_['text_nat_rules_desc'] = '1 purchase = 1 domain. The key is bound to the main domain without www prefix.';
$_['text_nat_contacts_title'] = 'Get key and support:';
$_['placeholder_license'] = 'XXXX-XXXX-XXXX-XXXX';
$_['text_license_active'] = 'License Active';
$_['text_nat_support'] = 'Support:';
$_['entry_license'] = 'License Key:';
$_['text_nat_domain_copied'] = 'Copied!';
$_['button_instruction'] = 'Module Instructions';

View File

@ -1,6 +1,15 @@
<?php <?php
$_['heading_title'] = '<b>Poll Widget [NAT]:</b> Polls and Voting'; $_['heading_title'] = '<b><i class="fa fa-space-shuttle fa-rotate-270" style="color: #ec741c; margin-right: 3px; vertical-align: -1px;"></i>Poll Widget [NAT]:</b> Polls and Voting';
$_['heading_title_raw'] = 'Poll Widget [NAT]: Polls and Voting'; $_['heading_title_raw'] = 'Poll Widget [NAT]';
$_['tab_nat_info'] = 'About Module';
$_['text_nat_author'] = 'Author / Developer:';
$_['text_nat_support'] = 'Technical Support:';
$_['text_nat_tg_channel'] = 'Support Telegram Bot:';
$_['text_nat_dev_profile'] = 'Forum Profile:';
$_['text_nat_site'] = 'Official Website:';
$_['text_nat_version_badge']= 'Official Version 3.0 ai';
$_['text_extension'] = 'Extensions'; $_['text_extension'] = 'Extensions';
$_['text_success'] = 'Module settings successfully updated!'; $_['text_success'] = 'Module settings successfully updated!';
$_['text_edit'] = 'Edit Poll'; $_['text_edit'] = 'Edit Poll';
@ -91,3 +100,19 @@ $_['text_poll_widget_desc'] = 'Create polls and voting widgets with a visual d
$_['text_current_module'] = 'Current module'; $_['text_current_module'] = 'Current module';
$_['text_info_title_promo_top_bar'] = 'Promo Top Bar [NAT]: Upper promotional info-banner, information bar above header, marquee and top-banner'; $_['text_info_title_promo_top_bar'] = 'Promo Top Bar [NAT]: Upper promotional info-banner, information bar above header, marquee and top-banner';
$_['text_info_desc_promo_top_bar'] = 'Create interactive promo bars and header slideshows with a block builder, countdown timers, subscription forms, and flexible targeting.'; $_['text_info_desc_promo_top_bar'] = 'Create interactive promo bars and header slideshows with a block builder, countdown timers, subscription forms, and flexible targeting.';
$_['nat_gk_title'] = 'Module Activation';
$_['text_nat_domain_label'] = 'Your domain:';
$_['text_nat_copy_domain'] = 'Copy';
$_['text_nat_enter_key'] = 'Enter license key:';
$_['button_nat_activate'] = 'Activate';
$_['text_nat_bot_btn'] = 'Get key via Telegram Bot';
$_['text_nat_rules_title'] = 'License Terms:';
$_['text_nat_rules_desc'] = '1 purchase = 1 domain. The key is bound to the main domain without www prefix.';
$_['text_nat_contacts_title'] = 'Get key and support:';
$_['placeholder_license'] = 'XXXX-XXXX-XXXX-XXXX';
$_['text_license_active'] = 'License Active';
$_['text_nat_support'] = 'Support:';
$_['entry_license'] = 'License Key:';
$_['text_nat_domain_copied'] = 'Copied!';
$_['button_instruction'] = 'Module Instructions';

View File

@ -1,6 +1,16 @@
<?php <?php
$_['heading_title'] = '<b>Poll Widget [NAT]:</b> Опросы и голосования'; $_['heading_title'] = '<b><i class="fa fa-space-shuttle fa-rotate-270" style="color: #ec741c; margin-right: 3px; vertical-align: -1px;"></i>Poll Widget [NAT]:</b> Опросы и голосования';
$_['heading_title_raw'] = 'Poll Widget [NAT]: Опросы и голосования'; $_['heading_title_raw'] = 'Poll Widget [NAT]';
// Вкладка «О модуле»
$_['tab_nat_info'] = 'О модуле';
$_['text_nat_author'] = 'Автор / Разработчик:';
$_['text_nat_support'] = 'Техническая поддержка:';
$_['text_nat_tg_channel'] = 'Telegram-бот поддержки:';
$_['text_nat_dev_profile'] = 'Профиль на форуме:';
$_['text_nat_site'] = 'Официальный сайт:';
$_['text_nat_version_badge']= 'Официальная версия 3.0 ai';
$_['text_extension'] = 'Расширения'; $_['text_extension'] = 'Расширения';
$_['text_success'] = 'Настройки модуля успешно обновлены!'; $_['text_success'] = 'Настройки модуля успешно обновлены!';
$_['text_edit'] = 'Редактирование опроса'; $_['text_edit'] = 'Редактирование опроса';
@ -91,3 +101,19 @@ $_['text_poll_widget_desc'] = 'Создание опросов и виджет
$_['text_current_module'] = 'Текущий модуль'; $_['text_current_module'] = 'Текущий модуль';
$_['text_info_title_promo_top_bar'] = 'Promo Top Bar [NAT]: Верхний рекламный инфо-баннер, информационная полоса над шапкой, бегущая строка и топ-баннер'; $_['text_info_title_promo_top_bar'] = 'Promo Top Bar [NAT]: Верхний рекламный инфо-баннер, информационная полоса над шапкой, бегущая строка и топ-баннер';
$_['text_info_desc_promo_top_bar'] = 'Создание интерактивных промо-панелей и слайд-шоу в шапке сайта с конструктором блоков, таймерами, формой подписки и гибким таргетингом.'; $_['text_info_desc_promo_top_bar'] = 'Создание интерактивных промо-панелей и слайд-шоу в шапке сайта с конструктором блоков, таймерами, формой подписки и гибким таргетингом.';
$_['nat_gk_title'] = 'Активация модуля';
$_['text_nat_domain_label'] = 'Ваш домен:';
$_['text_nat_copy_domain'] = 'Копировать';
$_['text_nat_enter_key'] = 'Введите лицензионный ключ:';
$_['button_nat_activate'] = 'Активировать';
$_['text_nat_bot_btn'] = 'Получить ключ в Telegram-боте';
$_['text_nat_rules_title'] = 'Условия лицензии:';
$_['text_nat_rules_desc'] = '1 покупка = 1 домен. Ключ привязывается к основному домену без префикса www.';
$_['text_nat_contacts_title'] = 'Получение ключа и поддержка:';
$_['placeholder_license'] = 'XXXX-XXXX-XXXX-XXXX';
$_['text_license_active'] = 'Лицензия активна';
$_['text_nat_support'] = 'Поддержка:';
$_['entry_license'] = 'Лицензионный ключ:';
$_['text_nat_domain_copied'] = 'Скопировано!';
$_['button_instruction'] = 'Инструкция к модулю';

View File

@ -1,6 +1,16 @@
<?php <?php
$_['heading_title'] = '<b>Poll Widget [NAT]:</b> Опросы и голосования'; $_['heading_title'] = '<b><i class="fa fa-space-shuttle fa-rotate-270" style="color: #ec741c; margin-right: 3px; vertical-align: -1px;"></i>Poll Widget [NAT]:</b> Опросы и голосования';
$_['heading_title_raw'] = 'Poll Widget [NAT]: Опросы и голосования'; $_['heading_title_raw'] = 'Poll Widget [NAT]';
// Вкладка «О модуле»
$_['tab_nat_info'] = 'О модуле';
$_['text_nat_author'] = 'Автор / Разработчик:';
$_['text_nat_support'] = 'Техническая поддержка:';
$_['text_nat_tg_channel'] = 'Telegram-бот поддержки:';
$_['text_nat_dev_profile'] = 'Профиль на форуме:';
$_['text_nat_site'] = 'Официальный сайт:';
$_['text_nat_version_badge']= 'Официальная версия 3.0 ai';
$_['text_extension'] = 'Расширения'; $_['text_extension'] = 'Расширения';
$_['text_success'] = 'Настройки модуля успешно обновлены!'; $_['text_success'] = 'Настройки модуля успешно обновлены!';
$_['text_edit'] = 'Редактирование опроса'; $_['text_edit'] = 'Редактирование опроса';
@ -91,3 +101,19 @@ $_['text_poll_widget_desc'] = 'Создание опросов и виджет
$_['text_current_module'] = 'Текущий модуль'; $_['text_current_module'] = 'Текущий модуль';
$_['text_info_title_promo_top_bar'] = 'Promo Top Bar [NAT]: Верхний рекламный инфо-баннер, информационная полоса над шапкой, бегущая строка и топ-баннер'; $_['text_info_title_promo_top_bar'] = 'Promo Top Bar [NAT]: Верхний рекламный инфо-баннер, информационная полоса над шапкой, бегущая строка и топ-баннер';
$_['text_info_desc_promo_top_bar'] = 'Создание интерактивных промо-панелей и слайд-шоу в шапке сайта с конструктором блоков, таймерами, формой подписки и гибким таргетингом.'; $_['text_info_desc_promo_top_bar'] = 'Создание интерактивных промо-панелей и слайд-шоу в шапке сайта с конструктором блоков, таймерами, формой подписки и гибким таргетингом.';
$_['nat_gk_title'] = 'Активация модуля';
$_['text_nat_domain_label'] = 'Ваш домен:';
$_['text_nat_copy_domain'] = 'Копировать';
$_['text_nat_enter_key'] = 'Введите лицензионный ключ:';
$_['button_nat_activate'] = 'Активировать';
$_['text_nat_bot_btn'] = 'Получить ключ в Telegram-боте';
$_['text_nat_rules_title'] = 'Условия лицензии:';
$_['text_nat_rules_desc'] = '1 покупка = 1 домен. Ключ привязывается к основному домену без префикса www.';
$_['text_nat_contacts_title'] = 'Получение ключа и поддержка:';
$_['placeholder_license'] = 'XXXX-XXXX-XXXX-XXXX';
$_['text_license_active'] = 'Лицензия активна';
$_['text_nat_support'] = 'Поддержка:';
$_['entry_license'] = 'Лицензионный ключ:';
$_['text_nat_domain_copied'] = 'Скопировано!';
$_['button_instruction'] = 'Инструкция к модулю';

View File

@ -1,6 +1,15 @@
<?php <?php
$_['heading_title'] = '<b>Poll Widget [NAT]:</b> Опитування та голосування'; $_['heading_title'] = '<b><i class="fa fa-space-shuttle fa-rotate-270" style="color: #ec741c; margin-right: 3px; vertical-align: -1px;"></i>Poll Widget [NAT]:</b> Опитування та голосування';
$_['heading_title_raw'] = 'Poll Widget [NAT]: Опитування та голосування'; $_['heading_title_raw'] = 'Poll Widget [NAT]';
$_['tab_nat_info'] = 'Про модуль';
$_['text_nat_author'] = 'Автор / Розробник:';
$_['text_nat_support'] = 'Технічна підтримка:';
$_['text_nat_tg_channel'] = 'Telegram-бот підтримки:';
$_['text_nat_dev_profile'] = 'Профіль на форумі:';
$_['text_nat_site'] = 'Офіційний сайт:';
$_['text_nat_version_badge']= 'Офіційна версія 3.0 ai';
$_['text_extension'] = 'Розширення'; $_['text_extension'] = 'Розширення';
$_['text_success'] = 'Налаштування модуля успішно оновлено!'; $_['text_success'] = 'Налаштування модуля успішно оновлено!';
$_['text_edit'] = 'Редагування опитування'; $_['text_edit'] = 'Редагування опитування';
@ -78,7 +87,7 @@ $_['error_form'] = 'Уважно перевірте форму на
$_['text_database_opt_title'] = 'Database Optimizer [NAT]'; $_['text_database_opt_title'] = 'Database Optimizer [NAT]';
$_['text_database_opt_desc'] = 'Інтелектуальне очищення сміття БД, керування системними логами та додавання критичних індексів для прискорення сайту.'; $_['text_database_opt_desc'] = 'Інтелектуальне очищення сміття БД, керування системними логами та додавання критичних індексів для прискорення сайту.';
$_['text_admin_tools_title'] = 'Admin Tools [NAT]'; $_['text_admin_tools_title'] = 'Admin Tools [NAT]';
$_['text_admin_tools_desc'] = 'Зручні інструменти адміністратора: вхід під клієнтом, кастомізація адмінки, керування правами та приховування непотрібних пунктів меню.'; $_['text_admin_tools_desc'] = 'Зручні інструменти адміністратора: вхід під клієнтом, кастомизация адмінки, керування правами та приховування непотрібних пунктів меню.';
$_['text_easy_import_title'] = 'Easy Import/Export [NAT]'; $_['text_easy_import_title'] = 'Easy Import/Export [NAT]';
$_['text_easy_import_desc'] = 'Швидкий імпорт/экспорт цін, залишків та товарів з XLS/XLSX/CSV/XML/JSON. Зіставлення полів, Cron та підтримка посилань.'; $_['text_easy_import_desc'] = 'Швидкий імпорт/экспорт цін, залишків та товарів з XLS/XLSX/CSV/XML/JSON. Зіставлення полів, Cron та підтримка посилань.';
$_['text_utm_tracker_title'] = 'Order UTM Tracker [NAT]'; $_['text_utm_tracker_title'] = 'Order UTM Tracker [NAT]';
@ -88,3 +97,19 @@ $_['text_poll_widget_desc'] = 'Створення опитувань та ві
$_['text_current_module'] = 'Поточний модуль'; $_['text_current_module'] = 'Поточний модуль';
$_['text_info_title_promo_top_bar'] = 'Promo Top Bar [NAT]: Верхній рекламний інфо-баннер, інформаційна смуга над шапкою, рухомий рядок та топ-баннер'; $_['text_info_title_promo_top_bar'] = 'Promo Top Bar [NAT]: Верхній рекламний інфо-баннер, інформаційна смуга над шапкою, рухомий рядок та топ-баннер';
$_['text_info_desc_promo_top_bar'] = 'Створення інтерактивних промо-панелей та слайд-шоу в шапці сайту з конструктором блоків, таймерами, формою підписки та гнучким націлюванням.'; $_['text_info_desc_promo_top_bar'] = 'Створення інтерактивних промо-панелей та слайд-шоу в шапці сайту з конструктором блоків, таймерами, формою підписки та гнучким націлюванням.';
$_['nat_gk_title'] = 'Активація модуля';
$_['text_nat_domain_label'] = 'Ваш домен:';
$_['text_nat_copy_domain'] = 'Копіювати';
$_['text_nat_enter_key'] = 'Введіть ліцензійний ключ:';
$_['button_nat_activate'] = 'Активувати';
$_['text_nat_bot_btn'] = 'Отримати ключ у Telegram-боті';
$_['text_nat_rules_title'] = 'Умови ліцензії:';
$_['text_nat_rules_desc'] = '1 покупка = 1 домен. Ключ прив\'язується до основного домену без префікса www.';
$_['text_nat_contacts_title'] = 'Отримання ключа та підтримка:';
$_['placeholder_license'] = 'XXXX-XXXX-XXXX-XXXX';
$_['text_license_active'] = 'Ліцензія активна';
$_['text_nat_support'] = 'Підтримка:';
$_['entry_license'] = 'Ліцензійний ключ:';
$_['text_nat_domain_copied'] = 'Скопійовано!';
$_['button_instruction'] = 'Інструкція до модуля';

View File

@ -1,6 +1,15 @@
<?php <?php
$_['heading_title'] = '<b>Poll Widget [NAT]:</b> Опитування та голосування'; $_['heading_title'] = '<b><i class="fa fa-space-shuttle fa-rotate-270" style="color: #ec741c; margin-right: 3px; vertical-align: -1px;"></i>Poll Widget [NAT]:</b> Опитування та голосування';
$_['heading_title_raw'] = 'Poll Widget [NAT]: Опитування та голосування'; $_['heading_title_raw'] = 'Poll Widget [NAT]';
$_['tab_nat_info'] = 'Про модуль';
$_['text_nat_author'] = 'Автор / Розробник:';
$_['text_nat_support'] = 'Технічна підтримка:';
$_['text_nat_tg_channel'] = 'Telegram-бот підтримки:';
$_['text_nat_dev_profile'] = 'Профіль на форумі:';
$_['text_nat_site'] = 'Офіційний сайт:';
$_['text_nat_version_badge']= 'Офіційна версія 3.0 ai';
$_['text_extension'] = 'Розширення'; $_['text_extension'] = 'Розширення';
$_['text_success'] = 'Налаштування модуля успішно оновлено!'; $_['text_success'] = 'Налаштування модуля успішно оновлено!';
$_['text_edit'] = 'Редагування опитування'; $_['text_edit'] = 'Редагування опитування';
@ -78,7 +87,7 @@ $_['error_form'] = 'Уважно перевірте форму на
$_['text_database_opt_title'] = 'Database Optimizer [NAT]'; $_['text_database_opt_title'] = 'Database Optimizer [NAT]';
$_['text_database_opt_desc'] = 'Інтелектуальне очищення сміття БД, керування системними логами та додавання критичних індексів для прискорення сайту.'; $_['text_database_opt_desc'] = 'Інтелектуальне очищення сміття БД, керування системними логами та додавання критичних індексів для прискорення сайту.';
$_['text_admin_tools_title'] = 'Admin Tools [NAT]'; $_['text_admin_tools_title'] = 'Admin Tools [NAT]';
$_['text_admin_tools_desc'] = 'Зручні інструменти адміністратора: вхід під клієнтом, кастомізація адмінки, керування правами та приховування непотрібних пунктів меню.'; $_['text_admin_tools_desc'] = 'Зручні інструменти адміністратора: вхід під клієнтом, кастомизация адмінки, керування правами та приховування непотрібних пунктів меню.';
$_['text_easy_import_title'] = 'Easy Import/Export [NAT]'; $_['text_easy_import_title'] = 'Easy Import/Export [NAT]';
$_['text_easy_import_desc'] = 'Швидкий імпорт/экспорт цін, залишків та товарів з XLS/XLSX/CSV/XML/JSON. Зіставлення полів, Cron та підтримка посилань.'; $_['text_easy_import_desc'] = 'Швидкий імпорт/экспорт цін, залишків та товарів з XLS/XLSX/CSV/XML/JSON. Зіставлення полів, Cron та підтримка посилань.';
$_['text_utm_tracker_title'] = 'Order UTM Tracker [NAT]'; $_['text_utm_tracker_title'] = 'Order UTM Tracker [NAT]';
@ -88,3 +97,19 @@ $_['text_poll_widget_desc'] = 'Створення опитувань та ві
$_['text_current_module'] = 'Поточний модуль'; $_['text_current_module'] = 'Поточний модуль';
$_['text_info_title_promo_top_bar'] = 'Promo Top Bar [NAT]: Верхній рекламний інфо-баннер, інформаційна смуга над шапкою, рухомий рядок та топ-баннер'; $_['text_info_title_promo_top_bar'] = 'Promo Top Bar [NAT]: Верхній рекламний інфо-баннер, інформаційна смуга над шапкою, рухомий рядок та топ-баннер';
$_['text_info_desc_promo_top_bar'] = 'Створення інтерактивних промо-панелей та слайд-шоу в шапці сайту з конструктором блоків, таймерами, формою підписки та гнучким націлюванням.'; $_['text_info_desc_promo_top_bar'] = 'Створення інтерактивних промо-панелей та слайд-шоу в шапці сайту з конструктором блоків, таймерами, формою підписки та гнучким націлюванням.';
$_['nat_gk_title'] = 'Активація модуля';
$_['text_nat_domain_label'] = 'Ваш домен:';
$_['text_nat_copy_domain'] = 'Копіювати';
$_['text_nat_enter_key'] = 'Введіть ліцензійний ключ:';
$_['button_nat_activate'] = 'Активувати';
$_['text_nat_bot_btn'] = 'Отримати ключ у Telegram-боті';
$_['text_nat_rules_title'] = 'Умови ліцензії:';
$_['text_nat_rules_desc'] = '1 покупка = 1 домен. Ключ прив\'язується до основного домену без префікса www.';
$_['text_nat_contacts_title'] = 'Отримання ключа та підтримка:';
$_['placeholder_license'] = 'XXXX-XXXX-XXXX-XXXX';
$_['text_license_active'] = 'Ліцензія активна';
$_['text_nat_support'] = 'Підтримка:';
$_['entry_license'] = 'Ліцензійний ключ:';
$_['text_nat_domain_copied'] = 'Скопійовано!';
$_['button_instruction'] = 'Інструкція до модуля';

View File

@ -2,6 +2,23 @@
if (!defined('VERSION')) exit; if (!defined('VERSION')) exit;
class ModelModulePollWidgetNat extends Model { class ModelModulePollWidgetNat extends Model {
private function encodeSetting($setting) {
if (defined('VERSION') && version_compare(VERSION, '2.1.0.0', '<')) {
return serialize($setting);
}
return json_encode($setting);
}
private function decodeSetting($raw) {
if (defined('VERSION') && version_compare(VERSION, '2.1.0.0', '<')) {
$data = @unserialize($raw);
if ($data !== false) {
return $data;
}
}
return json_decode($raw, true);
}
public function addPoll($data) { public function addPoll($data) {
$status = (int)$data['status']; $status = (int)$data['status'];
$config = $this->db->escape(json_encode($data['config'])); $config = $this->db->escape(json_encode($data['config']));
@ -31,7 +48,7 @@ class ModelModulePollWidgetNat extends Model {
'status' => $status 'status' => $status
); );
$this->db->query("INSERT INTO `" . DB_PREFIX . "module` SET `name` = '" . $this->db->escape($name) . "', `code` = 'poll_widget_nat', `setting` = '" . $this->db->escape(json_encode($setting)) . "'"); $this->db->query("INSERT INTO `" . DB_PREFIX . "module` SET `name` = '" . $this->db->escape($name) . "', `code` = 'poll_widget_nat', `setting` = '" . $this->db->escape($this->encodeSetting($setting)) . "'");
return $poll_id; return $poll_id;
} }
@ -70,16 +87,16 @@ class ModelModulePollWidgetNat extends Model {
$found = false; $found = false;
foreach ($module_query->rows as $row) { foreach ($module_query->rows as $row) {
$mod_setting = json_decode($row['setting'], true); $mod_setting = $this->decodeSetting($row['setting']);
if (isset($mod_setting['poll_id']) && (int)$mod_setting['poll_id'] === $poll_id) { if (isset($mod_setting['poll_id']) && (int)$mod_setting['poll_id'] === $poll_id) {
$this->db->query("UPDATE `" . DB_PREFIX . "module` SET `name` = '" . $this->db->escape($name) . "', `setting` = '" . $this->db->escape(json_encode($setting)) . "' WHERE module_id = '" . (int)$row['module_id'] . "'"); $this->db->query("UPDATE `" . DB_PREFIX . "module` SET `name` = '" . $this->db->escape($name) . "', `setting` = '" . $this->db->escape($this->encodeSetting($setting)) . "' WHERE module_id = '" . (int)$row['module_id'] . "'");
$found = true; $found = true;
break; break;
} }
} }
if (!$found) { if (!$found) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "module` SET `name` = '" . $this->db->escape($name) . "', `code` = 'poll_widget_nat', `setting` = '" . $this->db->escape(json_encode($setting)) . "'"); $this->db->query("INSERT INTO `" . DB_PREFIX . "module` SET `name` = '" . $this->db->escape($name) . "', `code` = 'poll_widget_nat', `setting` = '" . $this->db->escape($this->encodeSetting($setting)) . "'");
} }
} }
@ -91,7 +108,7 @@ class ModelModulePollWidgetNat extends Model {
$module_query = $this->db->query("SELECT module_id, setting FROM `" . DB_PREFIX . "module` WHERE `code` = 'poll_widget_nat'"); $module_query = $this->db->query("SELECT module_id, setting FROM `" . DB_PREFIX . "module` WHERE `code` = 'poll_widget_nat'");
foreach ($module_query->rows as $row) { foreach ($module_query->rows as $row) {
$mod_setting = json_decode($row['setting'], true); $mod_setting = $this->decodeSetting($row['setting']);
if (isset($mod_setting['poll_id']) && (int)$mod_setting['poll_id'] === $poll_id) { if (isset($mod_setting['poll_id']) && (int)$mod_setting['poll_id'] === $poll_id) {
$mod_id = (int)$row['module_id']; $mod_id = (int)$row['module_id'];
$this->db->query("DELETE FROM `" . DB_PREFIX . "module` WHERE module_id = '" . $mod_id . "'"); $this->db->query("DELETE FROM `" . DB_PREFIX . "module` WHERE module_id = '" . $mod_id . "'");
@ -108,6 +125,7 @@ class ModelModulePollWidgetNat extends Model {
public function getPollDescriptions($poll_id) { public function getPollDescriptions($poll_id) {
$poll_description_data = array(); $poll_description_data = array();
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "poll_widget_nat_description` WHERE poll_id = '" . (int)$poll_id . "'"); $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "poll_widget_nat_description` WHERE poll_id = '" . (int)$poll_id . "'");
foreach ($query->rows as $result) { foreach ($query->rows as $result) {
@ -121,28 +139,29 @@ class ModelModulePollWidgetNat extends Model {
return $poll_description_data; return $poll_description_data;
} }
public function getPolls() { public function getPolls($data = array()) {
$lang_id = (int)$this->config->get('config_language_id'); $sql = "SELECT p.poll_id, pd.question, p.status FROM `" . DB_PREFIX . "poll_widget_nat` p LEFT JOIN `" . DB_PREFIX . "poll_widget_nat_description` pd ON (p.poll_id = pd.poll_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY p.poll_id DESC";
$sql = "SELECT p.poll_id, pd.question, p.status FROM `" . DB_PREFIX . "poll_widget_nat` p LEFT JOIN `" . DB_PREFIX . "poll_widget_nat_description` pd ON (p.poll_id = pd.poll_id) WHERE pd.language_id = '" . $lang_id . "' ORDER BY p.date_added DESC";
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql); $query = $this->db->query($sql);
return $query->rows; return $query->rows;
} }
public function getVotes($poll_id, $start = 0, $limit = 10) { public function getTotalPolls() {
$poll_id = (int)$poll_id; $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "poll_widget_nat`");
$start = (int)$start; return (int)$query->row['total'];
$limit = (int)$limit;
if ($start < 0) {
$start = 0;
}
if ($limit < 1) {
$limit = 10;
}
$sql = "SELECT v.*, c.firstname, c.lastname, c.email FROM `" . DB_PREFIX . "poll_widget_nat_vote` v LEFT JOIN `" . DB_PREFIX . "customer` c ON (v.customer_id = c.customer_id) WHERE v.poll_id = '" . $poll_id . "' ORDER BY v.date_added DESC LIMIT " . $start . "," . $limit;
$query = $this->db->query($sql);
return $query->rows;
} }
public function getTotalVotes($poll_id) { public function getTotalVotes($poll_id) {
@ -150,14 +169,18 @@ class ModelModulePollWidgetNat extends Model {
return (int)$query->row['total']; return (int)$query->row['total'];
} }
public function getVotes($poll_id, $start = 0, $limit = 20) {
$sql = "SELECT v.*, c.firstname, c.lastname, c.email FROM `" . DB_PREFIX . "poll_widget_nat_vote` v LEFT JOIN `" . DB_PREFIX . "customer` c ON (v.customer_id = c.customer_id) WHERE v.poll_id = '" . (int)$poll_id . "' ORDER BY v.date_added DESC LIMIT " . (int)$start . "," . (int)$limit;
$query = $this->db->query($sql);
return $query->rows;
}
public function getVotesCountByIndex($poll_id) { public function getVotesCountByIndex($poll_id) {
$vote_data = array(); $counts = array();
$query = $this->db->query("SELECT answer_index, COUNT(*) AS total FROM `" . DB_PREFIX . "poll_widget_nat_vote` WHERE poll_id = '" . (int)$poll_id . "' GROUP BY answer_index"); $query = $this->db->query("SELECT answer_index, COUNT(*) as total FROM `" . DB_PREFIX . "poll_widget_nat_vote` WHERE poll_id = '" . (int)$poll_id . "' GROUP BY answer_index");
foreach ($query->rows as $row) {
foreach ($query->rows as $result) { $counts[(int)$row['answer_index']] = (int)$row['total'];
$vote_data[(int)$result['answer_index']] = (int)$result['total'];
} }
return $counts;
return $vote_data;
} }
} }

View File

@ -311,7 +311,7 @@
<div class="text-center" style="margin-top: 20px;"> <div class="text-center" style="margin-top: 20px;">
<a href="http://oc3-demo.nat.od.ua/instructions/poll_widget_nat_instruction.html" target="_blank" class="btn btn-success btn-lg" style="margin: 5px; background-color: #27ae60; border-color: #27ae60;"> <a href="http://oc3-demo.nat.od.ua/instructions/poll_widget_nat_instruction.html" target="_blank" class="btn btn-success btn-lg" style="margin: 5px; background-color: #27ae60; border-color: #27ae60;">
<i class="fa fa-book"></i> Инструкция к модулю <i class="fa fa-book"></i> <?php echo !empty($button_instruction) ? $button_instruction : 'Інструкція до модуля'; ?>
</a> </a>
<a href="https://www.opencart.com/index.php?route=marketplace/extension&amp;filter_member=nat.odua" target="_blank" class="btn btn-primary btn-lg" style="margin: 5px;"> <a href="https://www.opencart.com/index.php?route=marketplace/extension&amp;filter_member=nat.odua" target="_blank" class="btn btn-primary btn-lg" style="margin: 5px;">
<i class="fa fa-opencart"></i> OpenCart.com <i class="fa fa-opencart"></i> OpenCart.com

View File

@ -1,4 +1,361 @@
<?php echo $header; ?><?php echo $column_left; ?> <?php echo $header; ?><?php echo $column_left; ?>
<style>
/* ═══ NAT Gatekeeper Card (Экран блокировки) ═══ */
.nat-gatekeeper-card {
background: #ffffff;
border: 1px solid #e2e8f0;
border-top: 4px solid #ec741c;
border-radius: 10px;
box-shadow: 0 4px 25px rgba(0, 0, 0, 0.07);
padding: 30px;
}
.nat-gk-header {
text-align: center;
margin-bottom: 22px;
}
.nat-gk-badge {
font-size: 11px;
font-weight: 700;
color: #64748b;
letter-spacing: 0.8px;
margin-bottom: 6px;
}
.nat-gk-title {
margin: 0 0 10px 0;
font-weight: 800;
font-size: 22px;
color: #1e293b;
}
/* Строка домена */
.nat-gk-domain-box {
background: #f8fafc;
border: 1px dashed #cbd5e1;
border-radius: 6px;
padding: 10px 14px;
margin-bottom: 20px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
flex-wrap: wrap;
}
.nat-gk-domain-info {
display: flex;
align-items: center;
gap: 8px;
}
.nat-gk-domain-label {
font-size: 13px;
color: #475569;
}
.nat-gk-domain-val {
font-family: monospace;
font-size: 14px;
color: #0f172a;
}
.nat-btn-copy {
height: 34px !important;
line-height: 20px !important;
font-weight: 600;
border-radius: 5px !important;
padding: 6px 14px !important;
background: #ffffff !important;
border: 1px solid #cbd5e1 !important;
color: #334155 !important;
transition: all 0.2s !important;
}
.nat-btn-copy:hover {
background: #f1f5f9 !important;
border-color: #94a3b8 !important;
}
/* Поле ввода ключа с кнопкой в одной линии */
.nat-gk-input-group {
display: flex !important;
align-items: stretch !important;
width: 100% !important;
box-sizing: border-box !important;
}
.nat-gk-input-group .nat-gk-input {
flex: 1 1 auto !important;
width: 1% !important;
height: 44px !important;
border-radius: 6px 0 0 6px !important;
border: 2px solid #cbd5e1 !important;
border-right: none !important;
font-family: monospace;
font-size: 14px;
letter-spacing: 0.5px;
box-shadow: none !important;
padding: 8px 14px !important;
box-sizing: border-box !important;
}
.nat-gk-input-group .nat-gk-input:focus {
border-color: #ec741c !important;
outline: none !important;
}
.nat-gk-input-group .nat-btn-activate {
flex: 0 0 auto !important;
height: 44px !important;
line-height: 42px !important;
padding: 0 22px !important;
margin: 0 !important;
border-radius: 0 6px 6px 0 !important;
font-size: 14px !important;
font-weight: 700 !important;
letter-spacing: 0.3px !important;
background: #ec741c !important;
border: 2px solid #ec741c !important;
color: #ffffff !important;
box-shadow: none !important;
cursor: pointer !important;
display: inline-flex !important;
align-items: center !important;
justify-content: center !important;
gap: 6px !important;
box-sizing: border-box !important;
white-space: nowrap !important;
transition: background-color 0.2s, border-color 0.2s !important;
}
.nat-gk-input-group .nat-btn-activate:hover,
.nat-gk-input-group .nat-btn-activate:focus {
background: #d6630f !important;
border-color: #d6630f !important;
color: #ffffff !important;
}
/* Кнопка Телеграм бота */
.nat-btn-bot {
background: #0284c7 !important;
border: 1px solid #0284c7 !important;
color: #ffffff !important;
height: 44px !important;
line-height: 42px !important;
padding: 0 20px !important;
font-size: 14px !important;
font-weight: 700 !important;
border-radius: 6px !important;
box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25) !important;
transition: all 0.2s !important;
display: flex !important;
align-items: center !important;
justify-content: center !important;
gap: 8px !important;
text-decoration: none !important;
box-sizing: border-box !important;
}
.nat-btn-bot:hover {
background: #0369a1 !important;
border-color: #0369a1 !important;
color: #ffffff !important;
transform: translateY(-1px);
}
/* Блок правил */
.nat-gk-rules {
background: #fff7ed;
border-left: 3px solid #ec741c;
padding: 10px 14px;
border-radius: 0 6px 6px 0;
margin-bottom: 22px;
font-size: 12px;
color: #7c2d12;
line-height: 1.5;
}
.nat-gk-rules p {
margin: 0;
}
/* Сетка контактов (4 кнопки в ряд, 36px высота) */
.nat-gk-contacts-wrap {
border-top: 1px solid #e2e8f0;
padding-top: 16px;
}
.nat-gk-contacts-title {
display: block;
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.5px;
color: #64748b;
margin-bottom: 10px;
text-align: center;
}
.nat-gk-contacts-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 8px;
}
@media (max-width: 767px) {
.nat-gk-contacts-grid {
grid-template-columns: repeat(2, 1fr);
}
}
.nat-contact-btn {
height: 36px !important;
line-height: 34px !important;
padding: 0 10px !important;
font-size: 12px !important;
font-weight: 600 !important;
border-radius: 6px !important;
background: #ffffff !important;
border: 1px solid #cbd5e1 !important;
color: #334155 !important;
display: inline-flex !important;
align-items: center !important;
justify-content: center !important;
gap: 6px !important;
text-decoration: none !important;
box-sizing: border-box !important;
white-space: nowrap !important;
overflow: hidden !important;
text-overflow: ellipsis !important;
transition: all 0.2s !important;
}
.nat-contact-btn:hover {
background: #f8fafc !important;
border-color: #94a3b8 !important;
color: #0f172a !important;
}
/* Бейдж активной лицензии */
.nat-license-status-badge {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 5px 12px;
background: #ecfdf5;
color: #059669;
border: 1px solid #a7f3d0;
border-radius: 20px;
font-size: 12px;
font-weight: 700;
letter-spacing: 0.2px;
box-sizing: border-box;
}
/* Компактная плашка ввода ключа */
.nat-license-input-group {
display: inline-flex !important;
align-items: stretch !important;
vertical-align: middle !important;
box-sizing: border-box !important;
}
.nat-license-input-group .form-control {
border-radius: 4px 0 0 4px !important;
box-sizing: border-box !important;
}
.nat-license-input-group .input-group-btn {
width: auto !important;
display: inline-flex !important;
align-items: stretch !important;
}
.nat-license-input-group .input-group-btn > .btn {
height: 35px !important;
line-height: 1 !important;
padding: 0 16px !important;
margin: 0 !important;
display: inline-flex !important;
align-items: center !important;
justify-content: center !important;
box-sizing: border-box !important;
border-radius: 0 4px 4px 0 !important;
background: #ec741c !important;
border: 1px solid #ec741c !important;
color: #ffffff !important;
box-shadow: none !important;
outline: none !important;
vertical-align: top !important;
font-size: 14px !important;
transition: background-color 0.2s, border-color 0.2s !important;
}
.nat-license-input-group .input-group-btn > .btn:hover,
.nat-license-input-group .input-group-btn > .btn:focus {
background: #d6630f !important;
border-color: #d6630f !important;
color: #ffffff !important;
}
/* Dark mode */
html.nat-dark-mode .nat-gatekeeper-card,
body.nat-dark-mode .nat-gatekeeper-card {
background: #1e293b !important;
border-color: #334155 !important;
border-top-color: #ec741c !important;
box-shadow: 0 10px 35px rgba(0, 0, 0, 0.5) !important;
}
html.nat-dark-mode .nat-gk-badge,
body.nat-dark-mode .nat-gk-badge,
html.nat-dark-mode .nat-gk-domain-label,
body.nat-dark-mode .nat-gk-domain-label,
html.nat-dark-mode .nat-gk-contacts-title,
body.nat-dark-mode .nat-gk-contacts-title {
color: #94a3b8 !important;
}
html.nat-dark-mode .nat-gk-title,
body.nat-dark-mode .nat-gk-title {
color: #f1f5f9 !important;
}
html.nat-dark-mode .nat-gk-domain-box,
body.nat-dark-mode .nat-gk-domain-box {
background: #0f172a !important;
border-color: #334155 !important;
}
html.nat-dark-mode .nat-gk-domain-val,
body.nat-dark-mode .nat-gk-domain-val {
color: #38bdf8 !important;
}
html.nat-dark-mode .nat-btn-copy,
body.nat-dark-mode .nat-btn-copy {
background: #1e293b !important;
border-color: #475569 !important;
color: #f1f5f9 !important;
}
html.nat-dark-mode .nat-btn-copy:hover,
body.nat-dark-mode .nat-btn-copy:hover {
background: #334155 !important;
}
html.nat-dark-mode .nat-gk-input,
body.nat-dark-mode .nat-gk-input {
background: #0f172a !important;
border-color: #475569 !important;
color: #f8fafc !important;
}
html.nat-dark-mode .nat-btn-bot,
body.nat-dark-mode .nat-btn-bot {
background: #0284c7 !important;
border-color: #0284c7 !important;
color: #ffffff !important;
box-shadow: 0 4px 15px rgba(2, 132, 199, 0.45) !important;
}
html.nat-dark-mode .nat-gk-rules,
body.nat-dark-mode .nat-gk-rules {
background: rgba(236, 116, 28, 0.1) !important;
color: #cbd5e1 !important;
}
html.nat-dark-mode .nat-gk-contacts-wrap,
body.nat-dark-mode .nat-gk-contacts-wrap {
border-top-color: #334155 !important;
}
html.nat-dark-mode .nat-contact-btn,
body.nat-dark-mode .nat-contact-btn {
background: #0f172a !important;
border-color: #334155 !important;
color: #cbd5e1 !important;
}
html.nat-dark-mode .nat-contact-btn:hover,
body.nat-dark-mode .nat-contact-btn:hover {
background: #1e293b !important;
color: #ffffff !important;
}
html.nat-dark-mode .nat-license-status-badge,
body.nat-dark-mode .nat-license-status-badge {
background: rgba(16, 185, 129, 0.15) !important;
color: #34d399 !important;
border-color: rgba(16, 185, 129, 0.3) !important;
}
</style>
<div id="content"> <div id="content">
<div class="page-header"> <div class="page-header">
<div class="container-fluid"> <div class="container-fluid">
@ -11,7 +368,7 @@
<?php } ?> <?php } ?>
<a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a> <a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a>
</div> </div>
<h1><?php echo $heading_title_raw; ?></h1> <h1><?php echo $heading_title; ?></h1>
<ul class="breadcrumb"> <ul class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?> <?php foreach ($breadcrumbs as $breadcrumb) { ?>
<li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li> <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
@ -31,25 +388,114 @@
</div> </div>
<?php } ?> <?php } ?>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading" style="background: #2c3e50; color: white;"> <div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-list"></i> <?php echo $text_list; ?></h3> <h3 class="panel-title"><i class="fa fa-pencil"></i> <?php echo $is_licensed ? $text_list : $text_edit; ?></h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<?php if ($is_licensed) { ?> <?php if (!$is_licensed) { ?>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-module">
<div class="row" style="margin-top: 30px; margin-bottom: 50px;">
<div class="col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
<div class="nat-gatekeeper-card">
<div class="nat-gk-header">
<div class="nat-gk-badge">
<i class="fa fa-space-shuttle fa-rotate-270" style="color: #ec741c;"></i> [NAT] ECOSYSTEM MODULE
</div>
<h2 class="nat-gk-title"><i class="fa fa-key" style="color: #ec741c;"></i> <?php echo !empty($nat_gk_title) ? $nat_gk_title : 'Активація модуля'; ?></h2>
<span class="label" style="font-size: 11px; padding: 4px 10px; background: #ec741c; color: #fff;">ОЧІКУЄ АКТИВАЦІЇ</span>
</div>
<div class="nat-gk-domain-box">
<div class="nat-gk-domain-info">
<span class="nat-gk-domain-label"><?php echo !empty($text_nat_domain_label) ? $text_nat_domain_label : 'Ваш домен:'; ?></span>
<strong id="natCurrentDomain" class="nat-gk-domain-val"><?php echo $nat_current_domain; ?></strong>
</div>
<button type="button" class="btn btn-default btn-sm nat-btn-copy" id="natBtnCopyDomain" onclick="natCopyDomainToClipboard();">
<i class="fa fa-copy"></i> <span id="natBtnCopyDomainText"><?php echo !empty($text_nat_copy_domain) ? $text_nat_copy_domain : 'Копіювати'; ?></span>
</button>
</div>
<div class="form-group" style="margin-bottom: 16px;">
<label class="control-label" style="font-weight: 700; margin-bottom: 6px; display: block; color: inherit; font-size: 12.5px;"><?php echo !empty($text_nat_enter_key) ? $text_nat_enter_key : 'Введіть ліцензійний ключ:'; ?></label>
<div class="nat-gk-input-group">
<input type="text" name="module_poll_widget_nat_license" id="input-license" value="<?php echo $module_poll_widget_nat_license; ?>" class="form-control nat-gk-input" placeholder="XXXX-XXXX-XXXX-XXXX" autocomplete="off" />
<button type="submit" class="btn nat-btn-activate">
<i class="fa fa-key"></i> <?php echo !empty($button_nat_activate) ? $button_nat_activate : 'Активувати'; ?>
</button>
</div>
</div>
<div style="margin-bottom: 16px;">
<a href="https://t.me/natodua_hosting_bot?start=lic_<?php echo $nat_current_domain; ?>" target="_blank" rel="noopener noreferrer" class="btn nat-btn-bot btn-block">
<i class="fa fa-paper-plane"></i> <?php echo !empty($text_nat_bot_btn) ? $text_nat_bot_btn : 'Отримати ключ у Telegram-боті'; ?>
</a>
</div>
<div class="nat-gk-rules">
<p><strong><i class="fa fa-info-circle" style="color: #ec741c;"></i> <?php echo !empty($text_nat_rules_title) ? $text_nat_rules_title : 'Умови ліцензії:'; ?></strong> <?php echo !empty($text_nat_rules_desc) ? $text_nat_rules_desc : '1 покупка = 1 домен. Ключ прив\'язується до основного домену без префікса www.'; ?></p>
</div>
<div class="nat-gk-contacts-wrap">
<span class="nat-gk-contacts-title"><?php echo !empty($text_nat_contacts_title) ? $text_nat_contacts_title : 'Отримання ключа та підтримка:'; ?></span>
<div class="nat-gk-contacts-grid">
<a href="https://t.me/natodua_hosting_bot?start=lic_<?php echo $nat_current_domain; ?>" target="_blank" rel="noopener noreferrer" class="btn btn-default nat-contact-btn">
<i class="fa fa-paper-plane text-primary"></i> Telegram-бот
</a>
<a href="https://t.me/nat_support" target="_blank" rel="noopener noreferrer" class="btn btn-default nat-contact-btn">
<i class="fa fa-paper-plane text-info"></i> Підтримка
</a>
<a href="https://opencartforum.com/ru/files/developer/725443-nertyod/" target="_blank" rel="noopener noreferrer" class="btn btn-default nat-contact-btn">
<i class="fa fa-comments text-warning"></i> Профіль
</a>
<a href="mailto:info@nat.od.ua" class="btn btn-default nat-contact-btn">
<i class="fa fa-envelope text-danger"></i> info@nat.od.ua
</a>
</div>
</div>
</div>
</div>
</div>
</form>
<?php } else { ?>
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a href="#tab-general" data-toggle="tab"><?php echo $tab_polls; ?></a></li> <li class="active"><a href="#tab-general" data-toggle="tab"><?php echo $tab_polls; ?></a></li>
<li><a href="#tab-info" data-toggle="tab"><?php echo $tab_info; ?></a></li> <li><a href="#tab-info" data-toggle="tab"><i class="fa fa-info-circle"></i> <?php echo $tab_info; ?></a></li>
</ul> </ul>
<?php } ?>
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane active" id="tab-general"> <div class="tab-pane active" id="tab-general">
<?php if ($is_licensed) { ?> <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-module" class="form-horizontal">
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-module"> <div class="form-group nat-settings-license-row" style="background: rgba(0,0,0,0.02); padding: 12px 15px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.08); margin-bottom: 20px;">
<div class="row"> <label class="col-sm-3 control-label" style="padding-top: 8px;">
<div class="col-md-4"> <i class="fa fa-key" style="color: #ec741c; margin-right: 5px;"></i> <?php echo !empty($entry_license) ? $entry_license : 'Ліцензійний ключ:'; ?>
<div class="form-group" style="background: #f8f9fa; padding: 15px; border-radius: 4px; border: 1px solid #dee2e6;"> </label>
<div class="col-sm-9">
<div class="nat-license-row-controls" style="display: flex; align-items: center; gap: 10px; flex-wrap: wrap;">
<div class="input-group nat-license-input-group" style="max-width: 440px; width: 100%; flex: 1 1 300px;">
<input type="text" name="module_poll_widget_nat_license" value="<?php echo $module_poll_widget_nat_license; ?>" class="form-control" style="font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: 13px;" placeholder="<?php echo !empty($placeholder_license) ? $placeholder_license : 'XXXX-XXXX-XXXX-XXXX'; ?>" />
<span class="input-group-btn">
<button type="submit" class="btn btn-primary" style="background: #ec741c; border-color: #ec741c;" title="<?php echo !empty($button_save) ? $button_save : 'Зберегти / Оновити'; ?>">
<i class="fa fa-save"></i>
</button>
</span>
</div>
<span class="nat-license-status-badge">
<i class="fa fa-check-circle" style="font-size: 13px;"></i> <?php echo !empty($text_license_active) ? $text_license_active : 'Ліцензія активна'; ?>
</span>
</div>
<div class="help-block" style="margin-top: 6px; margin-bottom: 0; font-size: 12px; display: flex; justify-content: space-between; flex-wrap: wrap;">
<span>Домен: <b><?php echo $nat_current_domain; ?></b></span>
<span><?php echo !empty($text_nat_support) ? $text_nat_support : 'Підтримка:'; ?> <a href="https://t.me/natodua_hosting_bot?start=lic_<?php echo $nat_current_domain; ?>" target="_blank" rel="noopener noreferrer"><i class="fa fa-paper-plane text-primary"></i> Telegram-бот</a> | <a href="https://opencartforum.com/ru/files/developer/725443-nertyod/" target="_blank" rel="noopener noreferrer"><i class="fa fa-comments text-warning"></i> OpenCartForum</a> | <a href="mailto:info@nat.od.ua"><i class="fa fa-envelope text-danger"></i> info@nat.od.ua</a></span>
</div>
</div>
</div>
<div class="row" style="margin-left: 0; margin-right: 0;">
<div class="col-md-6" style="padding-left: 0; padding-right: 10px;">
<div class="form-group" style="background: #f8f9fa; padding: 15px; border-radius: 4px; border: 1px solid #dee2e6; margin-left: 0; margin-right: 0;">
<label><?php echo $entry_status; ?></label> <label><?php echo $entry_status; ?></label>
<div class="input-group"> <div class="input-group">
<select name="module_poll_widget_nat_status" class="form-control"> <select name="module_poll_widget_nat_status" class="form-control">
@ -62,8 +508,8 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-4"> <div class="col-md-6" style="padding-left: 10px; padding-right: 0;">
<div class="form-group" style="background: #f8f9fa; padding: 15px; border-radius: 4px; border: 1px solid #dee2e6;"> <div class="form-group" style="background: #f8f9fa; padding: 15px; border-radius: 4px; border: 1px solid #dee2e6; margin-left: 0; margin-right: 0;">
<label><?php echo $entry_menu_position; ?></label> <label><?php echo $entry_menu_position; ?></label>
<div class="input-group"> <div class="input-group">
<select name="module_poll_widget_nat_menu_position" class="form-control"> <select name="module_poll_widget_nat_menu_position" class="form-control">
@ -78,20 +524,6 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-4">
<div class="form-group" style="background: #f8f9fa; padding: 15px; border-radius: 4px; border: 1px solid #dee2e6;">
<label><?php echo $entry_license; ?></label>
<div class="input-group">
<input type="text" name="module_poll_widget_nat_license" value="<?php echo $module_poll_widget_nat_license; ?>" class="form-control" />
<span class="input-group-btn">
<button type="submit" class="btn btn-info"><i class="fa fa-refresh"></i></button>
</span>
<span class="input-group-addon">
<i class="fa fa-check text-success"></i>
</span>
</div>
</div>
</div>
</div> </div>
</form> </form>
@ -132,39 +564,8 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<?php } else { ?>
<div class="row">
<div class="col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
<div class="well text-center" style="background: #fff; border: 1px solid #ffbc34; padding: 25px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); margin-top: 20px;">
<h3 style="color: #d9534f; margin-top: 0; font-weight: bold;"><i class="fa fa-exclamation-triangle"></i> Требуется активация модуля</h3>
<p style="font-size: 14px; margin-bottom: 25px; color: #666;"><?php echo $text_license_warning; ?></p>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-module">
<div class="form-group" style="max-width: 400px; margin: 0 auto 20px;">
<label style="font-weight: bold; color: #333; margin-bottom: 8px;"><?php echo $entry_license; ?></label>
<div class="input-group">
<input type="text" name="module_poll_widget_nat_license" value="<?php echo $module_poll_widget_nat_license; ?>" class="form-control text-center" placeholder="Введите лицензионный ключ..." style="font-family: monospace; font-size: 16px; font-weight: bold; letter-spacing: 1px;" />
<span class="input-group-btn">
<button type="submit" class="btn btn-primary" style="font-weight: bold;"><i class="fa fa-key"></i> Активировать</button>
</span>
</div>
</div>
</form>
<div style="border-top: 1px solid #eee; padding-top: 20px; font-size: 13px; color: #666; text-align: left; max-width: 450px; margin: 0 auto;">
<strong style="color: #333;">Как получить лицензионный ключ:</strong>
<ul style="padding-left: 20px; margin-top: 8px; line-height: 1.6;">
<li>Напишите на почту <a href="mailto:info@nat.od.ua" style="font-weight: bold; color: #2980b9;">info@nat.od.ua</a> с указанием вашего домена и номера заказа.</li>
<li>Или свяжитесь с автором на форуме <a href="https://opencartforum.com/ru/files/developer/725443-nertyod/" target="_blank" style="font-weight: bold; color: #2980b9;">OpenCartForum (nertyod)</a>.</li>
</ul>
</div>
</div>
</div>
</div>
<?php } ?>
</div> </div>
<?php if ($is_licensed) { ?>
<div class="tab-pane" id="tab-info"> <div class="tab-pane" id="tab-info">
<div class="alert alert-info" style="font-size: 15px;"> <div class="alert alert-info" style="font-size: 15px;">
<i class="fa fa-info-circle"></i> <?php echo $text_footer_ecosystem; ?> <i class="fa fa-info-circle"></i> <?php echo $text_footer_ecosystem; ?>
@ -201,7 +602,7 @@
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<div class="well" style="min-height: 140px; background: #fff; border: 1px dashed #2980b9;"> <div class="well" style="min-height: 140px; background: #fff; border: 1px dashed #2980b9;">
<h4 style="margin-top:0; color: #2c3e50;"><b><i class="fa fa-question-circle text-primary"></i> <?php echo $text_poll_widget_title; ?></b> <span class="label label-success" style="font-size: 10px; vertical-align: middle;"><?php echo isset($text_current_module) ? $text_current_module : 'Текущий модуль'; ?></span></h4> <h4 style="margin-top:0; color: #2c3e50;"><b><i class="fa fa-question-circle text-primary"></i> <?php echo $text_poll_widget_title; ?></b> <span class="label label-success" style="font-size: 10px; vertical-align: middle;"><?php echo !empty($text_current_module) ? $text_current_module : 'Поточний модуль'; ?></span></h4>
<p style="font-size: 13px;"><?php echo $text_poll_widget_desc; ?></p> <p style="font-size: 13px;"><?php echo $text_poll_widget_desc; ?></p>
</div> </div>
</div> </div>
@ -243,7 +644,7 @@
<div class="text-center" style="margin-top: 20px;"> <div class="text-center" style="margin-top: 20px;">
<a href="http://oc3-demo.nat.od.ua/instructions/poll_widget_nat_instruction.html" target="_blank" class="btn btn-success btn-lg" style="margin: 5px; background-color: #27ae60; border-color: #27ae60;"> <a href="http://oc3-demo.nat.od.ua/instructions/poll_widget_nat_instruction.html" target="_blank" class="btn btn-success btn-lg" style="margin: 5px; background-color: #27ae60; border-color: #27ae60;">
<i class="fa fa-book"></i> Инструкция к модулю <i class="fa fa-book"></i> <?php echo !empty($button_instruction) ? $button_instruction : 'Інструкція до модуля'; ?>
</a> </a>
<a href="https://www.opencart.com/index.php?route=marketplace/extension&amp;filter_member=nat.odua" target="_blank" class="btn btn-primary btn-lg" style="margin: 5px;"> <a href="https://www.opencart.com/index.php?route=marketplace/extension&amp;filter_member=nat.odua" target="_blank" class="btn btn-primary btn-lg" style="margin: 5px;">
<i class="fa fa-opencart"></i> OpenCart.com <i class="fa fa-opencart"></i> OpenCart.com
@ -265,26 +666,43 @@
</div> </div>
</div> </div>
<?php if ($is_licensed) { ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { function natCopyDomainToClipboard() {
var tabStorageKey = 'nat_active_tab_poll_widget_nat_list'; var domainElem = document.getElementById('natCurrentDomain');
var $mainTabs = $('.panel-body > ul.nav-tabs'); if (!domainElem) return;
var domainText = domainElem.innerText || domainElem.textContent;
var textSpan = document.getElementById('natBtnCopyDomainText');
var origText = textSpan ? textSpan.innerText : 'Копіювати';
var savedTab = localStorage.getItem(tabStorageKey); function onSuccess() {
if (savedTab) { if (textSpan) {
var $target = $mainTabs.find('a[href="' + savedTab + '"]'); textSpan.innerText = '<?php echo !empty($text_nat_domain_copied) ? $text_nat_domain_copied : "Скопійовано!"; ?>';
if ($target.length) { setTimeout(function() { textSpan.innerText = origText; }, 2000);
$target.tab('show');
} }
} else {
$mainTabs.find('a[href="#tab-general"]').tab('show');
} }
$mainTabs.on('shown.bs.tab', 'a[data-toggle="tab"]', function(e) { if (navigator.clipboard && window.isSecureContext) {
localStorage.setItem(tabStorageKey, $(e.target).attr('href')); navigator.clipboard.writeText(domainText).then(onSuccess).catch(function() {
}); fallbackCopy(domainText);
}); });
} else {
fallbackCopy(domainText);
}
function fallbackCopy(text) {
var textArea = document.createElement("textarea");
textArea.value = text;
textArea.style.position = "fixed";
textArea.style.left = "-999999px";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
document.execCommand('copy');
onSuccess();
} catch (err) {}
document.body.removeChild(textArea);
}
}
</script> </script>
<?php } ?>
<?php echo $footer; ?> <?php echo $footer; ?>

View File

@ -4,7 +4,10 @@ if (!defined('VERSION')) exit;
class ControllerModulePollWidgetNat extends Controller { class ControllerModulePollWidgetNat extends Controller {
private function checkLicense($key) { private function checkLicense($key) {
if (empty($key)) return false; if (empty($key)) return false;
$host = explode(':', str_replace(array('http://', 'https://', 'www.'), '', strtolower($this->request->server['HTTP_HOST'])))[0]; $_h = defined('HTTP_SERVER') ? parse_url(HTTP_SERVER, PHP_URL_HOST) : (isset($this->request->server['HTTP_HOST']) ? $this->request->server['HTTP_HOST'] : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''));
$_h = preg_replace('/:\d+$/', '', trim((string)$_h));
$_h = preg_replace('/^www\./i', '', $_h);
$host = strtolower($_h);
$parts = explode('.', $host); $parts = explode('.', $host);
$v_core = '_redis'; $v_core = '_redis';
$v_end = 'aet_'; $v_end = 'aet_';
@ -33,82 +36,90 @@ class ControllerModulePollWidgetNat extends Controller {
return false; return false;
} }
$poll_id = (int)$setting['poll_id']; if (!is_file(DIR_APPLICATION . 'model/module/poll_widget_nat.php')) {
$this->load->model('module/poll_widget_nat');
$this->load->language('module/poll_widget_nat');
$poll_info = $this->model_module_poll_widget_nat->getPoll($poll_id);
if (!$poll_info) {
return false; return false;
} }
$description = $this->model_module_poll_widget_nat->getPollDescription($poll_id); try {
if (!$description) { $poll_id = (int)$setting['poll_id'];
return false;
}
$data['poll_id'] = (int)$poll_info['poll_id']; $this->load->model('module/poll_widget_nat');
$data['question'] = (string)$description['question']; $this->load->language('module/poll_widget_nat');
$data['colors'] = is_array($poll_info['colors']) ? $poll_info['colors'] : array();
$data['config'] = is_array($poll_info['config']) ? $poll_info['config'] : array();
$data['button_vote'] = $this->language->get('button_vote'); $poll_info = $this->model_module_poll_widget_nat->getPoll($poll_id);
$data['error_select'] = $this->language->get('error_select'); if (!$poll_info) {
return false;
$answers_raw = explode("\n", str_replace("\r", "", $description['answers']));
$data['answers'] = array();
if (!empty($answers_raw) && is_array($answers_raw)) {
foreach ($answers_raw as $index => $text) {
$text = trim((string)$text);
if ($text !== '') {
$data['answers'][] = array(
'index' => (int)$index,
'text' => $text
);
}
} }
}
$limit = isset($poll_info['config']['limit']) ? (int)$poll_info['config']['limit'] : 0; $description = $this->model_module_poll_widget_nat->getPollDescription($poll_id);
$data['voted'] = $this->model_module_poll_widget_nat->checkVoted($data['poll_id'], $limit); if (!$description) {
return false;
}
$data['show_total'] = false; $data['poll_id'] = (int)$poll_info['poll_id'];
$data['total_votes'] = 0; $data['question'] = (string)$description['question'];
$data['text_total_votes'] = $this->language->get('text_total_votes'); $data['colors'] = is_array($poll_info['colors']) ? $poll_info['colors'] : array();
$data['config'] = is_array($poll_info['config']) ? $poll_info['config'] : array();
if (isset($poll_info['config']['show_total']) && $poll_info['config']['show_total']) { $data['button_vote'] = $this->language->get('button_vote');
$access = isset($poll_info['config']['total_access']) ? (string)$poll_info['config']['total_access'] : 'all'; $data['error_select'] = $this->language->get('error_select');
if ($access === 'all' || ($access === 'registered' && $this->customer->isLogged())) { $answers_raw = explode("\n", str_replace("\r", "", $description['answers']));
$data['show_total'] = true; $data['answers'] = array();
$results_data = $this->getResultsData($poll_info, $data['answers']);
if (!empty($results_data) && is_array($results_data)) { if (!empty($answers_raw) && is_array($answers_raw)) {
foreach ($results_data as $res) { foreach ($answers_raw as $index => $text) {
$data['total_votes'] += (int)$res['count']; $text = trim((string)$text);
if ($text !== '') {
$data['answers'][] = array(
'index' => (int)$index,
'text' => $text
);
} }
} }
} }
}
if ($data['voted']) { $limit = isset($poll_info['config']['limit']) ? (int)$poll_info['config']['limit'] : 0;
$data['results'] = $this->getResultsData($poll_info, $data['answers']); $data['voted'] = $this->model_module_poll_widget_nat->checkVoted($data['poll_id'], $limit);
$data['thanks_text'] = (string)$description['thanks_text'];
} else {
$data['results'] = array();
$data['thanks_text'] = '';
}
if (version_compare(VERSION, '2.2.0.0', '<')) { $data['show_total'] = false;
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/poll_widget_nat.tpl')) { $data['total_votes'] = 0;
return $this->load->view($this->config->get('config_template') . '/template/module/poll_widget_nat.tpl', $data); $data['text_total_votes'] = $this->language->get('text_total_votes');
} else {
return $this->load->view('default/template/module/poll_widget_nat.tpl', $data); if (isset($poll_info['config']['show_total']) && $poll_info['config']['show_total']) {
$access = isset($poll_info['config']['total_access']) ? (string)$poll_info['config']['total_access'] : 'all';
if ($access === 'all' || ($access === 'registered' && $this->customer->isLogged())) {
$data['show_total'] = true;
$results_data = $this->getResultsData($poll_info, $data['answers']);
if (!empty($results_data) && is_array($results_data)) {
foreach ($results_data as $res) {
$data['total_votes'] += (int)$res['count'];
}
}
}
} }
} else {
return $this->load->view('module/poll_widget_nat', $data); if ($data['voted']) {
$data['results'] = $this->getResultsData($poll_info, $data['answers']);
$data['thanks_text'] = (string)$description['thanks_text'];
} else {
$data['results'] = array();
$data['thanks_text'] = '';
}
if (version_compare(VERSION, '2.2.0.0', '<')) {
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/poll_widget_nat.tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/module/poll_widget_nat.tpl', $data);
} else {
return $this->load->view('default/template/module/poll_widget_nat.tpl', $data);
}
} else {
return $this->load->view('module/poll_widget_nat', $data);
}
} catch (\Throwable $e) {
return false;
} }
} }
@ -121,69 +132,80 @@ class ControllerModulePollWidgetNat extends Controller {
return; return;
} }
$this->load->model('module/poll_widget_nat'); if (!is_file(DIR_APPLICATION . 'model/module/poll_widget_nat.php')) {
$this->load->language('module/poll_widget_nat'); $json['error'] = 'Module missing.';
if (!$this->checkLicense($this->config->get('module_poll_widget_nat_license'))) {
$this->response->addHeader('Content-Type: application/json'); $this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode(array('error' => 'License verification failed.'))); $this->response->setOutput(json_encode($json));
return; return;
} }
$poll_id = isset($this->request->post['poll_id']) ? (int)$this->request->post['poll_id'] : 0; try {
$answer_index = isset($this->request->post['answer_index']) ? (int)$this->request->post['answer_index'] : -1; $this->load->model('module/poll_widget_nat');
$this->load->language('module/poll_widget_nat');
$page_url = ''; if (!$this->checkLicense($this->config->get('module_poll_widget_nat_license'))) {
if (isset($this->request->post['page_url'])) { $this->response->addHeader('Content-Type: application/json');
$page_url = strip_tags(html_entity_decode((string)$this->request->post['page_url'], ENT_QUOTES, 'UTF-8')); $this->response->setOutput(json_encode(array('error' => 'License verification failed.')));
$page_url = mb_substr($page_url, 0, 500); return;
} }
$poll_info = $this->model_module_poll_widget_nat->getPoll($poll_id); $poll_id = isset($this->request->post['poll_id']) ? (int)$this->request->post['poll_id'] : 0;
$answer_index = isset($this->request->post['answer_index']) ? (int)$this->request->post['answer_index'] : -1;
if ($poll_info && $answer_index !== -1) { $page_url = '';
$limit = isset($poll_info['config']['limit']) ? (int)$poll_info['config']['limit'] : 0; if (isset($this->request->post['page_url'])) {
$voted = $this->model_module_poll_widget_nat->checkVoted($poll_id, $limit); $page_url = strip_tags(html_entity_decode((string)$this->request->post['page_url'], ENT_QUOTES, 'UTF-8'));
$page_url = mb_substr($page_url, 0, 500);
}
if (!$voted) { $poll_info = $this->model_module_poll_widget_nat->getPoll($poll_id);
$guest_allowed = !empty($poll_info['config']['guest']);
if (!$this->customer->isLogged() && !$guest_allowed) {
$json['error'] = $this->language->get('error_guest');
} else {
$this->model_module_poll_widget_nat->addVote($poll_id, $answer_index, $page_url);
$description = $this->model_module_poll_widget_nat->getPollDescription($poll_id); if ($poll_info && $answer_index !== -1) {
$answers_raw = explode("\n", str_replace("\r", "", $description['answers'])); $limit = isset($poll_info['config']['limit']) ? (int)$poll_info['config']['limit'] : 0;
$answers = array(); $voted = $this->model_module_poll_widget_nat->checkVoted($poll_id, $limit);
if (!empty($answers_raw) && is_array($answers_raw)) { if (!$voted) {
foreach ($answers_raw as $i => $t) { $guest_allowed = !empty($poll_info['config']['guest']);
$t = trim((string)$t); if (!$this->customer->isLogged() && !$guest_allowed) {
if ($t !== '') { $json['error'] = $this->language->get('error_guest');
$answers[] = array('index' => (int)$i, 'text' => $t); } else {
$this->model_module_poll_widget_nat->addVote($poll_id, $answer_index, $page_url);
$description = $this->model_module_poll_widget_nat->getPollDescription($poll_id);
$answers_raw = explode("\n", str_replace("\r", "", $description['answers']));
$answers = array();
if (!empty($answers_raw) && is_array($answers_raw)) {
foreach ($answers_raw as $i => $t) {
$t = trim((string)$t);
if ($t !== '') {
$answers[] = array('index' => (int)$i, 'text' => $t);
}
} }
} }
}
$json['success'] = true; $json['success'] = true;
$json['thanks_text'] = (string)$description['thanks_text']; $json['thanks_text'] = (string)$description['thanks_text'];
$json['results'] = $this->getResultsData($poll_info, $answers); $json['results'] = $this->getResultsData($poll_info, $answers);
$json['result_type'] = isset($poll_info['config']['result_type']) ? (string)$poll_info['config']['result_type'] : 'none'; $json['result_type'] = isset($poll_info['config']['result_type']) ? (string)$poll_info['config']['result_type'] : 'none';
$total_votes = 0; $total_votes = 0;
if (!empty($json['results']) && is_array($json['results'])) { if (!empty($json['results']) && is_array($json['results'])) {
foreach ($json['results'] as $res) { foreach ($json['results'] as $res) {
$total_votes += (int)$res['count']; $total_votes += (int)$res['count'];
}
} }
$json['total_votes'] = $total_votes;
$json['text_total_votes'] = $this->language->get('text_total_votes');
} }
$json['total_votes'] = $total_votes; } else {
$json['text_total_votes'] = $this->language->get('text_total_votes'); $json['error'] = $this->language->get('error_voted');
} }
} else { } else {
$json['error'] = $this->language->get('error_voted'); $json['error'] = $this->language->get('error_select');
} }
} else { } catch (\Throwable $e) {
$json['error'] = $this->language->get('error_select'); $json['error'] = $e->getMessage();
} }
$this->response->addHeader('Content-Type: application/json'); $this->response->addHeader('Content-Type: application/json');