Created
August 23, 2024 05:54
-
-
Save PechenkiUA/9fe64bcf6fc91351d48fc89a410ea5fd to your computer and use it in GitHub Desktop.
Приховати російську мову та зробити переадресацію з усіх сторінок на укр
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<modification> | |
<name>01-Coder_redirect_disabled_lang</name> | |
<code>Coder_redirect_disabled_lang</code> | |
<version>0.1</version> | |
<author>Pechenki</author> | |
<link>coder.org.ua</link> | |
<file path="catalog/controller/common/language.php"> | |
<operation> | |
<search trim="true"><![CDATA[public function index() {]]></search> | |
<add position="before"><![CDATA[ | |
private function redirectToDefaultLanguage() { | |
$this->load->language('common/language'); | |
$data['action'] = $this->url->link('common/language/language', '', $this->request->server['HTTPS']); | |
$data['code'] = $this->session->data['language']; | |
$this->load->model('localisation/language'); | |
$data['languages'] = array(); | |
$results = $this->model_localisation_language->getLanguages(); | |
if (count($results) > 1 ) { | |
$old_language_id = $this->config->get('config_language_id'); | |
$old_language_ses = $this->session->data['language']; | |
$url_data = $this->request->get; | |
if (!isset($url_data['route'])) { | |
$route = 'common/home'; | |
} else { | |
$route = $url_data['route']; | |
} | |
unset($url_data['_route_']); | |
unset($url_data['route']); | |
$url = ''; | |
if ($url_data) { | |
$url = '&' . urldecode(http_build_query($url_data, '', '&')); | |
} else { | |
$url = ''; | |
} | |
} | |
if (!isset($this->request->get['route'])) { | |
$data['redirect'] = $this->url->link('common/home'); | |
} else { | |
$url_data = $this->request->get; | |
unset($url_data['_route_']); | |
$route = $url_data['route']; | |
unset($url_data['route']); | |
$url = ''; | |
if ($url_data) { | |
$url = '&' . urldecode(http_build_query($url_data, '', '&')); | |
} | |
$data['route'] = $route; | |
$data['url'] = $url; | |
$data['protocol'] = $this->request->server['HTTPS']; | |
} | |
/** | |
* тут потрібно зробити редарект на укр як поточна ру | |
*/ | |
$curLang = $this->config->get('config_language_id'); | |
if ($curLang == 3){ | |
$this->config->set('config_language_id', 2); | |
$this->session->data['language'] = 'uk-ua'; | |
$uk_rl = $this->url->link($data['route'], $data['url'], $data['protocol']); | |
$this->response->redirect($uk_rl,301); | |
} | |
} | |
]]></add> | |
</operation> | |
<operation> | |
<search trim="true"><![CDATA[public function index() {]]></search> | |
<add position="after"><![CDATA[ | |
$this->redirectToDefaultLanguage(); | |
]]></add> | |
</operation> | |
<operation> | |
<search trim="true"><![CDATA[if ($result['status']) {]]></search> | |
<add position="before"><![CDATA[ | |
if($result['language_id']==3){ continue;} | |
]]></add> | |
</operation> | |
</file> | |
<file path="admin/model/localisation/language.php"> | |
<operation> | |
<search trim="true"><![CDATA[$language_data[$result['code']] = array(]]></search> | |
<add position="before"><![CDATA[ | |
if($result['language_id']==3){ continue;} | |
]]></add> | |
</operation> | |
</file> | |
</modification> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment