Автозамены регионов

This commit is contained in:
Konstantin
2026-05-30 17:43:37 +03:00
parent df8cf22112
commit 6c8a012702
16 changed files with 317 additions and 18 deletions
+8 -1
View File
@@ -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');
@@ -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) {
@@ -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();
@@ -0,0 +1,8 @@
<?php
class ControllerStartupRegionReplacement extends Controller {
public function index() {
$this->load->model('localisation/zone');
$this->response->setReplacements($this->model_localisation_zone->getReplacements());
}
}
@@ -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'] = 'Работает на <a target="_blank" href="https://ocstore.com/?utm_source=ocstore3_install">ocStore</a><br /> %s &copy; %s';
$_['text_powered'] = 'Работает на <a target="_blank" href="https://ocstore.com/?utm_source=ocstore3_install">ocStore</a><br /> %s &copy; %s';
+61
View File
@@ -26,6 +26,67 @@ class ModelLocalisationZone extends Model {
return $query->row;
}
public function getContacts($zone_id = 0) {
if (!$zone_id) {
$zone_id = isset($this->session->data['city_id']) ? (int)$this->session->data['city_id'] : (int)$this->config->get('config_zone_id');
}
$zone = $this->getZone($zone_id);
$contacts = array();
foreach (array('telephone', 'email', 'address', 'geocode', 'fax', 'open', 'comment') as $field) {
$key = 'contact_' . $field;
if (isset($zone[$key]) && trim((string)$zone[$key]) !== '') {
$contacts[$field] = $zone[$key];
} else {
$contacts[$field] = $this->config->get('config_' . $field);
}
}
return $contacts;
}
public function getReplacements($zone_id = 0) {
if (!$zone_id) {
$zone_id = isset($this->session->data['city_id']) ? (int)$this->session->data['city_id'] : (int)$this->config->get('config_zone_id');
}
$zone = $this->getZone($zone_id);
if (!$zone) {
$zone = $this->getZone((int)$this->config->get('config_zone_id'));
}
if (!$zone) {
return array();
}
$country_query = $this->db->query("SELECT name FROM " . DB_PREFIX . "country WHERE country_id = '" . (int)$zone['country_id'] . "' LIMIT 1");
$country = $country_query->num_rows ? $country_query->row['name'] : '';
$replacements = array(
'{_REGION_}' => $zone['name'],
'{_GOROD_}' => $zone['name'],
'{_GORODU_}' => $zone['name'],
'{_GORODOM_}' => $zone['name'],
'{_STRANA_}' => $country,
'{_STRANU_}' => $country,
'{_STRANOI_}' => $country,
'{_STRANE_}' => $country,
'{_STRANY_}' => $country
);
foreach (array('gorod', 'gorodu', 'gorodom', 'strana', 'stranu', 'stranoi', 'strane', 'strany') as $field) {
$key = 'replacement_' . $field;
if (isset($zone[$key]) && trim((string)$zone[$key]) !== '') {
$replacements['{_' . strtoupper($field) . '_}'] = $zone[$key];
}
}
return $replacements;
}
public function getZoneUrl($zone_id, $url) {
$zone = $this->getZone($zone_id);
@@ -11,16 +11,14 @@
<div><a href="mailto:{{ config_email }}">{{ config_email }}</a></div>
<div>{{ config_address }}</div>
</div>
{% if informations %}
<div class="col-12">
<div class="row g-3 justify-content-center">
<div class="col-auto"><a href="{{ contact }}">{{ text_contacts }}</a></div>
{% for information in informations %}
<div class="col-auto"><a href="{{ information.href }}">{{ information.title }}</a></div>
{% endfor %}
</div>
</div>
{% endif %}
</div>
</div>
</footer>
@@ -33,4 +31,4 @@
<script src="{{ script }}" type="text/javascript"></script>
{% endfor %}
<script src="store/view/theme/dominik/assets/js/script.js"></script>
</body></html>
</body></html>