добавил обработку относительных ссылок баннеров с учётом выбранного региона.
This commit is contained in:
@@ -5,6 +5,7 @@ class ControllerExtensionModuleWDBanners extends Controller {
|
|||||||
|
|
||||||
$this->load->model('tool/image');
|
$this->load->model('tool/image');
|
||||||
$this->load->model('design/banner');
|
$this->load->model('design/banner');
|
||||||
|
$this->load->model('localisation/zone');
|
||||||
|
|
||||||
if (isset($setting['include'])) {
|
if (isset($setting['include'])) {
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ class ControllerExtensionModuleWDBanners extends Controller {
|
|||||||
'image_orig' => HTTPS_SERVER . 'image/' . $result['image'],
|
'image_orig' => HTTPS_SERVER . 'image/' . $result['image'],
|
||||||
'title' => html_entity_decode($result['title'], ENT_QUOTES, 'UTF-8'),
|
'title' => html_entity_decode($result['title'], ENT_QUOTES, 'UTF-8'),
|
||||||
'text' => html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'),
|
'text' => html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'),
|
||||||
'link' => $result['link'],
|
'link' => $this->getRegionLink($result['link']),
|
||||||
'button' => $result['button_text'],
|
'button' => $result['button_text'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -57,4 +58,33 @@ class ControllerExtensionModuleWDBanners extends Controller {
|
|||||||
|
|
||||||
return $this->load->view('extension/module/' . ((isset($setting['twig']) && $setting['twig'] != "") ? trim($setting['twig']) : "wd_banners"), $data);
|
return $this->load->view('extension/module/' . ((isset($setting['twig']) && $setting['twig'] != "") ? trim($setting['twig']) : "wd_banners"), $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getRegionLink($link) {
|
||||||
|
$link = trim((string)$link);
|
||||||
|
|
||||||
|
if ($link === '' || $link[0] === '#' || strpos($link, '//') === 0 || preg_match('#^[a-z][a-z0-9+.-]*:#i', $link)) {
|
||||||
|
return $link;
|
||||||
|
}
|
||||||
|
|
||||||
|
$zone_id = isset($this->session->data['city_id']) ? (int)$this->session->data['city_id'] : (int)$this->config->get('config_zone_id');
|
||||||
|
$store_url = $this->config->get('config_url');
|
||||||
|
$regional_link = $this->model_localisation_zone->getZoneUrl($zone_id, rtrim($store_url, '/') . '/' . ltrim($link, '/'));
|
||||||
|
$url_info = parse_url($regional_link);
|
||||||
|
|
||||||
|
if (!$url_info) {
|
||||||
|
return $link;
|
||||||
|
}
|
||||||
|
|
||||||
|
$link = isset($url_info['path']) ? $url_info['path'] : '/';
|
||||||
|
|
||||||
|
if (isset($url_info['query'])) {
|
||||||
|
$link .= '?' . $url_info['query'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($url_info['fragment'])) {
|
||||||
|
$link .= '#' . $url_info['fragment'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $link;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user