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

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
+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);