diff --git a/database/migrations/20260530_add_region_replacement_tags.sql b/database/migrations/20260530_add_region_replacement_tags.sql new file mode 100644 index 0000000..95ed022 --- /dev/null +++ b/database/migrations/20260530_add_region_replacement_tags.sql @@ -0,0 +1,36 @@ +UPDATE `oc_banner_image` +SET `description` = REPLACE(REPLACE(`description`, 'из Беларуси', 'из {_STRANY_}'), 'в Беларуси', 'в {_STRANE_}') +WHERE `description` LIKE '%из Беларуси%' OR `description` LIKE '%в Беларуси%'; + +UPDATE `oc_banner_image` +SET `title` = REPLACE(`title`, '{_REGIONE_}', '{_GOROD_}') +WHERE `title` LIKE '%{_REGIONE_}%'; + +UPDATE `oc_category_description` +SET `description_bottom` = REPLACE(`description_bottom`, 'в Москве', 'в {_GOROD_}') +WHERE `description_bottom` LIKE '%в Москве%'; + +UPDATE `oc_category_description` +SET `meta_title` = REPLACE(`meta_title`, 'в Москве и Московской области', 'в {_GOROD_}'), + `meta_description` = REPLACE(`meta_description`, 'в Москве и Московской области', 'в {_GOROD_}') +WHERE `meta_title` LIKE '%в Москве и Московской области%' + OR `meta_description` LIKE '%в Москве и Московской области%'; + +UPDATE `oc_product_description` +SET `meta_title` = REPLACE(`meta_title`, 'в Москве', 'в {_GOROD_}'), + `meta_description` = REPLACE(`meta_description`, 'в Москве и МО', 'в {_GOROD_}') +WHERE `meta_title` LIKE '%в Москве%' + OR `meta_description` LIKE '%в Москве и МО%'; + +UPDATE `oc_service_category_description` +SET `meta_keyword` = REPLACE(`meta_keyword`, 'минск', '{_REGION_}') +WHERE `meta_keyword` LIKE '%минск%'; + +UPDATE `oc_service_description` +SET `meta_title` = REPLACE(`meta_title`, 'в Минске', 'в {_GOROD_}') +WHERE `meta_title` LIKE '%в Минске%'; + +UPDATE `oc_setting` +SET `value` = REPLACE(REPLACE(REPLACE(`value`, 'в Москве и области', 'в {_GOROD_}'), 'в Москве', 'в {_GOROD_}'), 'в Минске', 'в {_GOROD_}') +WHERE `code` = 'config' + AND `key` IN ('config_meta_title', 'config_meta_description'); diff --git a/database/migrations/20260530_add_zone_contacts.sql b/database/migrations/20260530_add_zone_contacts.sql new file mode 100644 index 0000000..16d2f56 --- /dev/null +++ b/database/migrations/20260530_add_zone_contacts.sql @@ -0,0 +1,8 @@ +ALTER TABLE `oc_zone` + ADD `contact_telephone` TEXT NOT NULL AFTER `slug`, + ADD `contact_email` TEXT NOT NULL AFTER `contact_telephone`, + ADD `contact_address` TEXT NOT NULL AFTER `contact_email`, + ADD `contact_geocode` TEXT NOT NULL AFTER `contact_address`, + ADD `contact_fax` TEXT NOT NULL AFTER `contact_geocode`, + ADD `contact_open` TEXT NOT NULL AFTER `contact_fax`, + ADD `contact_comment` TEXT NOT NULL AFTER `contact_open`; diff --git a/database/migrations/20260530_add_zone_replacements.sql b/database/migrations/20260530_add_zone_replacements.sql new file mode 100644 index 0000000..37dc8f8 --- /dev/null +++ b/database/migrations/20260530_add_zone_replacements.sql @@ -0,0 +1,17 @@ +ALTER TABLE `oc_zone` + ADD `replacement_gorod` VARCHAR(128) NOT NULL DEFAULT '' AFTER `contact_comment`, + ADD `replacement_gorodu` VARCHAR(128) NOT NULL DEFAULT '' AFTER `replacement_gorod`, + ADD `replacement_gorodom` VARCHAR(128) NOT NULL DEFAULT '' AFTER `replacement_gorodu`, + ADD `replacement_strana` VARCHAR(128) NOT NULL DEFAULT '' AFTER `replacement_gorodom`, + ADD `replacement_stranu` VARCHAR(128) NOT NULL DEFAULT '' AFTER `replacement_strana`, + ADD `replacement_stranoi` VARCHAR(128) NOT NULL DEFAULT '' AFTER `replacement_stranu`, + ADD `replacement_strane` VARCHAR(128) NOT NULL DEFAULT '' AFTER `replacement_stranoi`, + ADD `replacement_strany` VARCHAR(128) NOT NULL DEFAULT '' AFTER `replacement_strane`; + +UPDATE `oc_zone` SET `replacement_gorod` = 'Бресте', `replacement_gorodu` = 'Бресту', `replacement_gorodom` = 'Брестом', `replacement_strana` = 'Беларусь', `replacement_stranu` = 'Беларусь', `replacement_stranoi` = 'Беларусью', `replacement_strane` = 'Беларуси', `replacement_strany` = 'Беларуси' WHERE `zone_id` = 337; +UPDATE `oc_zone` SET `replacement_gorod` = 'Гомеле', `replacement_gorodu` = 'Гомелю', `replacement_gorodom` = 'Гомелем', `replacement_strana` = 'Беларусь', `replacement_stranu` = 'Беларусь', `replacement_stranoi` = 'Беларусью', `replacement_strane` = 'Беларуси', `replacement_strany` = 'Беларуси' WHERE `zone_id` = 338; +UPDATE `oc_zone` SET `replacement_gorod` = 'Минске', `replacement_gorodu` = 'Минску', `replacement_gorodom` = 'Минском', `replacement_strana` = 'Беларусь', `replacement_stranu` = 'Беларусь', `replacement_stranoi` = 'Беларусью', `replacement_strane` = 'Беларуси', `replacement_strany` = 'Беларуси' WHERE `zone_id` = 339; +UPDATE `oc_zone` SET `replacement_gorod` = 'Гродно', `replacement_gorodu` = 'Гродно', `replacement_gorodom` = 'Гродно', `replacement_strana` = 'Беларусь', `replacement_stranu` = 'Беларусь', `replacement_stranoi` = 'Беларусью', `replacement_strane` = 'Беларуси', `replacement_strany` = 'Беларуси' WHERE `zone_id` = 340; +UPDATE `oc_zone` SET `replacement_gorod` = 'Москве', `replacement_gorodu` = 'Москве', `replacement_gorodom` = 'Москвой', `replacement_strana` = 'Россия', `replacement_stranu` = 'Россию', `replacement_stranoi` = 'Россией', `replacement_strane` = 'России', `replacement_strany` = 'России' WHERE `zone_id` = 2761; +UPDATE `oc_zone` SET `replacement_gorod` = 'Санкт-Петербурге', `replacement_gorodu` = 'Санкт-Петербургу', `replacement_gorodom` = 'Санкт-Петербургом', `replacement_strana` = 'Россия', `replacement_stranu` = 'Россию', `replacement_stranoi` = 'Россией', `replacement_strane` = 'России', `replacement_strany` = 'России' WHERE `zone_id` = 4239; +UPDATE `oc_zone` SET `replacement_gorod` = 'Брянске', `replacement_gorodu` = 'Брянску', `replacement_gorodom` = 'Брянском', `replacement_strana` = 'Россия', `replacement_stranu` = 'Россию', `replacement_stranoi` = 'Россией', `replacement_strane` = 'России', `replacement_strany` = 'России' WHERE `zone_id` = 4240; diff --git a/public/admin/controller/localisation/zone.php b/public/admin/controller/localisation/zone.php index a48a73a..a718df8 100644 --- a/public/admin/controller/localisation/zone.php +++ b/public/admin/controller/localisation/zone.php @@ -270,6 +270,17 @@ class ControllerLocalisationZone extends Controller { $data['error_slug'] = ''; } + if (isset($this->error['contact_email'])) { + $data['error_contact_email'] = $this->error['contact_email']; + } else { + $data['error_contact_email'] = ''; + } + + foreach (array('gorod', 'gorodu', 'gorodom', 'strana', 'stranu', 'stranoi', 'strane', 'strany') as $replacement_field) { + $key = 'replacement_' . $replacement_field; + $data['error_' . $key] = isset($this->error[$key]) ? $this->error[$key] : ''; + } + $url = ''; if (isset($this->request->get['sort'])) { @@ -340,6 +351,42 @@ class ControllerLocalisationZone extends Controller { $data['slug'] = ''; } + foreach (array('telephone', 'email', 'address', 'geocode', 'fax', 'open', 'comment') as $contact_field) { + $key = 'contact_' . $contact_field; + + if (isset($this->request->post[$key])) { + $data[$key] = $this->request->post[$key]; + } elseif (!empty($zone_info)) { + $data[$key] = $zone_info[$key]; + } else { + $data[$key] = ''; + } + } + + foreach (array('gorod', 'gorodu', 'gorodom', 'strana', 'stranu', 'stranoi', 'strane', 'strany') as $replacement_field) { + $key = 'replacement_' . $replacement_field; + + if (isset($this->request->post[$key])) { + $data[$key] = $this->request->post[$key]; + } elseif (!empty($zone_info)) { + $data[$key] = $zone_info[$key]; + } else { + $data[$key] = ''; + } + } + + $data['replacement_fields'] = array(); + + foreach (array('gorod', 'gorodu', 'gorodom', 'strana', 'stranu', 'stranoi', 'strane', 'strany') as $replacement_field) { + $key = 'replacement_' . $replacement_field; + $data['replacement_fields'][] = array( + 'name' => $key, + 'label' => $this->language->get('entry_' . $key), + 'value' => $data[$key], + 'error' => $data['error_' . $key] + ); + } + if (isset($this->request->post['country_id'])) { $data['country_id'] = $this->request->post['country_id']; } elseif (!empty($zone_info)) { @@ -378,6 +425,18 @@ class ControllerLocalisationZone extends Controller { $this->error['slug'] = $this->language->get('error_slug_exists'); } + if ($this->request->post['contact_email'] !== '' && !filter_var($this->request->post['contact_email'], FILTER_VALIDATE_EMAIL)) { + $this->error['contact_email'] = $this->language->get('error_contact_email'); + } + + foreach (array('gorod', 'gorodu', 'gorodom', 'strana', 'stranu', 'stranoi', 'strane', 'strany') as $replacement_field) { + $key = 'replacement_' . $replacement_field; + + if ((utf8_strlen(trim($this->request->post[$key])) < 1) || (utf8_strlen($this->request->post[$key]) > 128)) { + $this->error[$key] = $this->language->get('error_replacement'); + } + } + return !$this->error; } diff --git a/public/admin/language/ru-ru/localisation/zone.php b/public/admin/language/ru-ru/localisation/zone.php index 4367e19..24f5615 100644 --- a/public/admin/language/ru-ru/localisation/zone.php +++ b/public/admin/language/ru-ru/localisation/zone.php @@ -10,6 +10,8 @@ $_['text_success'] = 'Настройки успешно изменен $_['text_list'] = 'Список регионов'; $_['text_add'] = 'Добавить'; $_['text_edit'] = 'Редактирование'; +$_['text_contacts'] = 'Контакты региона'; +$_['text_replacements'] = 'Автозамены'; // Column $_['column_name'] = 'Название региона'; @@ -24,12 +26,33 @@ $_['entry_code'] = 'Код региона'; $_['entry_slug'] = 'Slug для URL'; $_['entry_country'] = 'Страна'; $_['entry_status'] = 'Статус'; +$_['entry_contact_telephone'] = 'Телефон'; +$_['entry_contact_email'] = 'Email'; +$_['entry_contact_address'] = 'Адрес'; +$_['entry_contact_geocode'] = 'Геокод'; +$_['entry_contact_fax'] = 'Факс'; +$_['entry_contact_open'] = 'Режим работы'; +$_['entry_contact_comment'] = 'Комментарий'; +$_['entry_replacement_gorod'] = '{_GOROD_}: в городе'; +$_['entry_replacement_gorodu'] = '{_GORODU_}: к городу'; +$_['entry_replacement_gorodom'] = '{_GORODOM_}: городом'; +$_['entry_replacement_strana'] = '{_STRANA_}: страна'; +$_['entry_replacement_stranu'] = '{_STRANU_}: в страну'; +$_['entry_replacement_stranoi'] = '{_STRANOI_}: страной'; +$_['entry_replacement_strane'] = '{_STRANE_}: в стране'; +$_['entry_replacement_strany'] = '{_STRANY_}: из страны'; + +// Help +$_['help_contacts'] = 'Заполните только отличающиеся контакты. Для пустых полей будут использоваться общие настройки магазина.'; +$_['help_replacements'] = 'Название региона используется для тега {_REGION_}. Остальные словоформы обязательны и подставляются в текст витрины автоматически.'; // Error $_['error_permission'] = 'У вас недостаточно прав для внесения изменений!'; $_['error_name'] = 'Название должно содержать от 3 до 128 символов!'; $_['error_slug'] = 'Slug обязателен для всех регионов, кроме региона по умолчанию, и может содержать только строчные латинские буквы, цифры и дефисы!'; $_['error_slug_exists'] = 'Такой slug уже используется другим регионом!'; +$_['error_contact_email'] = 'Введите корректный email или оставьте поле пустым!'; +$_['error_replacement'] = 'Словоформа обязательна и не должна быть длиннее 128 символов!'; $_['error_default'] = 'Этот Регион нельзя удалить, поскольку он используется по умолчанию!'; $_['error_store'] = 'Этот Регион нельзя удалить, поскольку он используется в %s магазинах!'; $_['error_address'] = 'Этот Регион нельзя удалить, поскольку он используется в %s адресах!'; diff --git a/public/admin/model/localisation/zone.php b/public/admin/model/localisation/zone.php index 9c1df32..b5f0894 100644 --- a/public/admin/model/localisation/zone.php +++ b/public/admin/model/localisation/zone.php @@ -1,7 +1,7 @@ db->query("INSERT INTO " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', slug = '" . $this->db->escape($data['slug']) . "', country_id = '" . (int)$data['country_id'] . "'"); + $this->db->query("INSERT INTO " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', slug = '" . $this->db->escape($data['slug']) . "', contact_telephone = '" . $this->db->escape($data['contact_telephone']) . "', contact_email = '" . $this->db->escape($data['contact_email']) . "', contact_address = '" . $this->db->escape($data['contact_address']) . "', contact_geocode = '" . $this->db->escape($data['contact_geocode']) . "', contact_fax = '" . $this->db->escape($data['contact_fax']) . "', contact_open = '" . $this->db->escape($data['contact_open']) . "', contact_comment = '" . $this->db->escape($data['contact_comment']) . "', replacement_gorod = '" . $this->db->escape($data['replacement_gorod']) . "', replacement_gorodu = '" . $this->db->escape($data['replacement_gorodu']) . "', replacement_gorodom = '" . $this->db->escape($data['replacement_gorodom']) . "', replacement_strana = '" . $this->db->escape($data['replacement_strana']) . "', replacement_stranu = '" . $this->db->escape($data['replacement_stranu']) . "', replacement_stranoi = '" . $this->db->escape($data['replacement_stranoi']) . "', replacement_strane = '" . $this->db->escape($data['replacement_strane']) . "', replacement_strany = '" . $this->db->escape($data['replacement_strany']) . "', country_id = '" . (int)$data['country_id'] . "'"); $this->cache->delete('zone'); @@ -9,7 +9,7 @@ class ModelLocalisationZone extends Model { } public function editZone($zone_id, $data) { - $this->db->query("UPDATE " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', slug = '" . $this->db->escape($data['slug']) . "', country_id = '" . (int)$data['country_id'] . "' WHERE zone_id = '" . (int)$zone_id . "'"); + $this->db->query("UPDATE " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', slug = '" . $this->db->escape($data['slug']) . "', contact_telephone = '" . $this->db->escape($data['contact_telephone']) . "', contact_email = '" . $this->db->escape($data['contact_email']) . "', contact_address = '" . $this->db->escape($data['contact_address']) . "', contact_geocode = '" . $this->db->escape($data['contact_geocode']) . "', contact_fax = '" . $this->db->escape($data['contact_fax']) . "', contact_open = '" . $this->db->escape($data['contact_open']) . "', contact_comment = '" . $this->db->escape($data['contact_comment']) . "', replacement_gorod = '" . $this->db->escape($data['replacement_gorod']) . "', replacement_gorodu = '" . $this->db->escape($data['replacement_gorodu']) . "', replacement_gorodom = '" . $this->db->escape($data['replacement_gorodom']) . "', replacement_strana = '" . $this->db->escape($data['replacement_strana']) . "', replacement_stranu = '" . $this->db->escape($data['replacement_stranu']) . "', replacement_stranoi = '" . $this->db->escape($data['replacement_stranoi']) . "', replacement_strane = '" . $this->db->escape($data['replacement_strane']) . "', replacement_strany = '" . $this->db->escape($data['replacement_strany']) . "', country_id = '" . (int)$data['country_id'] . "' WHERE zone_id = '" . (int)$zone_id . "'"); $this->cache->delete('zone'); } diff --git a/public/admin/view/template/localisation/zone_form.twig b/public/admin/view/template/localisation/zone_form.twig index 222be74..c9fe6e5 100644 --- a/public/admin/view/template/localisation/zone_form.twig +++ b/public/admin/view/template/localisation/zone_form.twig @@ -77,6 +77,70 @@ +
+ diff --git a/public/store/controller/common/footer.php b/public/store/controller/common/footer.php index 8361a09..bca65a4 100644 --- a/public/store/controller/common/footer.php +++ b/public/store/controller/common/footer.php @@ -16,7 +16,7 @@ class ControllerCommonFooter extends Controller { } } - $data['contact'] = $this->url->link('information/contact'); + $data['contact'] = $this->url->link('information/contact', '', true); $data['return'] = $this->url->link('account/return/add', '', true); $data['sitemap'] = $this->url->link('information/sitemap'); $data['tracking'] = $this->url->link('information/tracking'); @@ -28,6 +28,7 @@ class ControllerCommonFooter extends Controller { $data['order'] = $this->url->link('account/order', '', true); $data['wishlist'] = $this->url->link('account/wishlist', '', true); $data['newsletter'] = $this->url->link('account/newsletter', '', true); + $data['text_contacts'] = $this->language->get('text_contacts'); $data['powered'] = sprintf($this->language->get('text_powered'), $this->config->get('config_name'), date('Y', time())); @@ -60,6 +61,12 @@ foreach(['name','email','telephone','address','open', 'comment'] as $item){ $data['config_' . $item] = $this->config->get('config_' . $item); } + $this->load->model('localisation/zone'); + + foreach ($this->model_localisation_zone->getContacts() as $field => $value) { + $data['config_' . $field] = $value; + } + $data['scripts'] = $this->document->getScripts('footer'); $data['styles'] = $this->document->getStyles('footer'); diff --git a/public/store/controller/common/header.php b/public/store/controller/common/header.php index f4de203..fff97bd 100644 --- a/public/store/controller/common/header.php +++ b/public/store/controller/common/header.php @@ -109,6 +109,13 @@ foreach(['name','email','telephone','address','open', 'comment'] as $item){ $zones = $this->model_localisation_zone->getZonesByCountryId($country_id); $current_zone_id = isset($this->session->data['city_id']) ? (int)$this->session->data['city_id'] : (int)$this->config->get('config_zone_id'); + $contacts = $this->model_localisation_zone->getContacts($current_zone_id); + + foreach ($contacts as $field => $value) { + $data['config_' . $field] = $value; + } + + $data['telephone'] = $contacts['telephone']; $data['current_city_name'] = ''; foreach ($zones as $zone) { diff --git a/public/store/controller/information/contact.php b/public/store/controller/information/contact.php index 3d7ab21..526f447 100644 --- a/public/store/controller/information/contact.php +++ b/public/store/controller/information/contact.php @@ -4,6 +4,9 @@ class ControllerInformationContact extends Controller { public function index() { $this->load->language('information/contact'); + $this->load->model('localisation/zone'); + + $contacts = $this->model_localisation_zone->getContacts(); $this->document->setTitle($this->language->get('heading_title')); @@ -18,7 +21,7 @@ class ControllerInformationContact extends Controller { $mail->smtp_port = $this->config->get('config_mail_smtp_port'); $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); - $mail->setTo($this->config->get('config_email')); + $mail->setTo($contacts['email']); $mail->setFrom($this->request->post['email']); $mail->setReplyTo($this->request->post['email']); $mail->setSender(html_entity_decode($this->request->post['name'], ENT_QUOTES, 'UTF-8')); @@ -89,13 +92,13 @@ class ControllerInformationContact extends Controller { } $data['store'] = $this->config->get('config_name'); - $data['address'] = nl2br($this->config->get('config_address')); - $data['geocode'] = $this->config->get('config_geocode'); + $data['address'] = nl2br($contacts['address']); + $data['geocode'] = $contacts['geocode']; $data['geocode_hl'] = $this->config->get('config_language'); - $data['telephone'] = $this->config->get('config_telephone'); - $data['fax'] = $this->config->get('config_fax'); - $data['open'] = nl2br($this->config->get('config_open')); - $data['comment'] = $this->config->get('config_comment'); + $data['telephone'] = $contacts['telephone']; + $data['fax'] = $contacts['fax']; + $data['open'] = nl2br($contacts['open']); + $data['comment'] = $contacts['comment']; $data['locations'] = array(); diff --git a/public/store/controller/startup/region_replacement.php b/public/store/controller/startup/region_replacement.php new file mode 100644 index 0000000..34fdad9 --- /dev/null +++ b/public/store/controller/startup/region_replacement.php @@ -0,0 +1,8 @@ +load->model('localisation/zone'); + + $this->response->setReplacements($this->model_localisation_zone->getReplacements()); + } +} diff --git a/public/store/language/ru-ru/common/footer.php b/public/store/language/ru-ru/common/footer.php index 8fb35af..4d6b551 100644 --- a/public/store/language/ru-ru/common/footer.php +++ b/public/store/language/ru-ru/common/footer.php @@ -7,6 +7,7 @@ $_['text_information'] = 'Информация'; $_['text_service'] = 'Служба поддержки'; $_['text_extra'] = 'Дополнительно'; $_['text_contact'] = 'Связаться с нами'; +$_['text_contacts'] = 'Контакты'; $_['text_return'] = 'Возврат товара'; $_['text_sitemap'] = 'Карта сайта'; $_['text_manufacturer'] = 'Производители'; @@ -20,4 +21,4 @@ $_['text_account'] = 'Личный кабинет'; $_['text_order'] = 'История заказов'; $_['text_wishlist'] = 'Закладки'; $_['text_newsletter'] = 'Рассылка'; -$_['text_powered'] = 'Работает на ocStore