forked from pavlickm/seopro
-
Notifications
You must be signed in to change notification settings - Fork 28
/
install.ocstore2102.ocmod.xml
132 lines (126 loc) · 6.25 KB
/
install.ocstore2102.ocmod.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?xml version="1.0" encoding="utf-8"?>
<modification>
<code>seopro-20150125</code>
<name>SeoPro for ocStore v2.x</name>
<version>1.0.2016-12-13</version>
<author>OpencartJazz.com</author>
<link>http://www.opencartjazz.com/opencart-module/seo/ocj-seopro-oc2</link>
<file path="catalog/controller/common/header.php">
<operation>
<search trim="true" index="0"><![CDATA[$data['name'] = $this->config->get('config_name');]]></search>
<add position="after" trim="false" offset="0"><![CDATA[ $data['alter_lang'] = $this->getAlterLanguageLinks($this->document->getLinks());]]></add>
</operation>
<operation>
<search trim="true" index="0"><![CDATA[return $this->load->view('default/template/common/header.tpl', $data);]]></search>
<add position="after" trim="false" offset="2"><![CDATA[
protected function getAlterLanguageLinks($links) {
$result = array();
if ($this->config->get('config_seo_url')) {
foreach($links as $link) {
if($link['rel']=='canonical') {
$url=$link['href'];
$schema = parse_url($url,PHP_URL_SCHEME);
$server = strtolower($schema)=='https' ? HTTPS_SERVER : HTTP_SERVER;
$cur_lang = substr($url, strlen($server),2);
$query = substr($url, strlen($server)+2);
$this->load->model('localisation/language');
$languages = $this->model_localisation_language->getLanguages();
$active_langs = array();
foreach($languages as $lang) {
if($lang['status']) {
$active_langs[]=$lang['code'];
}
}
if(in_array($cur_lang, $active_langs)) {
foreach($active_langs as $lang) {
$result[$lang] = $server.$lang.($query ? $query : '');
}
}
}
}
}
return $result;
}]]></add>
</operation>
</file>
<file path="catalog/controller/common/home.php">
<operation>
<search trim="true" index="0"><![CDATA[$this->document->addLink(HTTP_SERVER, 'canonical');]]></search>
<add position="replace" trim="false" offset="0"><![CDATA[$this->document->addLink($this->url->link('common/home'), 'canonical');]]></add>
</operation>
</file>
<file path="catalog/controller/common/language.php">
<operation>
<search trim="true" index="0"><![CDATA[$data['redirect'] = $this->url->link('common/home');]]></search>
<add position="replace" trim="false" offset="0"><![CDATA[ $data['redirect_route'] = 'common/home';
$data['redirect_query'] = '';
$data['redirect_ssl'] = '';]]></add>
</operation>
<operation>
<search trim="true" index="0"><![CDATA[$data['redirect'] = $this->url->link($route, $url, $this->request->server['HTTPS']);]]></search>
<add position="replace" trim="false" offset="0"><![CDATA[ $data['redirect_route']=$route;
$data['redirect_query']=$url;
$data['redirect_ssl']=$this->request->server['HTTPS'];]]></add>
</operation>
<operation>
<search regex="true" limit="1" quote="true"><![CDATA[~ if (isset($this->request->post['redirect'])) {
$this->response->redirect($this->request->post['redirect']);~]]></search>
<add><![CDATA[ if (isset($this->request->post['redirect_route'])) {
$url = $this->url->link($this->request->post['redirect_route'],
isset($this->request->post['redirect_query']) ? html_entity_decode($this->request->post['redirect_query']) : '',
isset($this->request->post['redirect_ssl']) ? $this->request->post['redirect_ssl'] : '');
$this->response->redirect($url);]]></add>
</operation>
</file>
<file path="catalog/view/theme/default/template/common/header.tpl">
<operation>
<search trim="true" index="0"><![CDATA[<script src="catalog/view/javascript/jquery/jquery-2.1.1.min.js" type="text/javascript"></script>]]></search>
<add position="before" trim="false" offset="0"><![CDATA[<?php foreach ($alter_lang as $lang=>$href) { ?>
<link href="<?php echo $href; ?>" hreflang="<?php echo $lang; ?>" rel="alternate" />
<?php } ?>]]></add>
</operation>
</file>
<file path="catalog/view/theme/default/template/common/language.tpl">
<operation>
<search trim="true" index="0"><![CDATA[<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />]]></search>
<add position="replace" trim="false" offset="0"><![CDATA[ <input type="hidden" name="redirect_route" value="<?php echo $redirect_route; ?>" />
<input type="hidden" name="redirect_query" value="<?php echo isset($redirect_query) ? $redirect_query : ''; ?>" />
<input type="hidden" name="redirect_ssl" value="<?php echo isset($redirect_ssl) ? $redirect_ssl : ''; ?>" />]]></add>
</operation>
</file>
<file path="catalog/controller/common/home.php">
<operation>
<search regex="true" limit="1" quote="true"><![CDATA[~if (isset($this->request->get['route'])) {
$this->document->addLink($this->url->link('common/home'), 'canonical');
}~]]></search>
<add><![CDATA[$this->document->addLink($this->getCanonical(), 'canonical');]]></add>
</operation>
<operation>
<search trim="true" index="0"><![CDATA[$this->response->setOutput($this->load->view('default/template/common/home.tpl', $data));]]></search>
<add position="after" trim="false" offset="2"><![CDATA[
protected function getCanonical() {
$url = HTTP_SERVER;
if( $this->config->get('config_seo_url')
&& $this->config->get('config_seo_url_type') == 'seo_pro') {
$url = $this->url->link('common/home');
$query = $this->db->query("SELECT value FROM " . DB_PREFIX . "setting WHERE store_id = '" . (int)$this->config->get('config_store_id') . "' AND `key` ='config_language'");
$code = $this->session->data['language'];
// Do not show language code for home when default language is always shown
if( !$this->config->get('ocjazz_seopro_hide_default')
&& $code == $query->row['value'])
{
$component = parse_url($url);
if ($component['scheme'] == 'https') {
$domain = $this->config->get('config_ssl');
} else {
$domain = $this->config->get('config_url');
}
$url = preg_replace('~('.$domain.')('.$code.'/)(.+)~i', '$1$3',$url);
}
}
return $url;
}
]]></add>
</operation>
</file>
</modification>