Рамиз Мирзаев

Add seo package

This diff could not be displayed because it is too large.
...@@ -846,6 +846,10 @@ class ModelToolSeoPackage extends Model { ...@@ -846,6 +846,10 @@ class ModelToolSeoPackage extends Model {
846 $this->session->data['kwCountArray'][$seo_kw]++; 846 $this->session->data['kwCountArray'][$seo_kw]++;
847 } 847 }
848 848
849 + if ($number == '') {
850 + $number = (int)$number;
851 + }
852 +
849 $search_kw = $seo_kw .'-'. ++$number; 853 $search_kw = $seo_kw .'-'. ++$number;
850 } 854 }
851 /* 855 /*
......
1 <?php 1 <?php
2 -// * @source See SOURCE.txt for source and other copyright.
3 -// * @license GNU General Public License version 3; see LICENSE.txt
4 -
5 class ControllerStartupSeoUrl extends Controller { 2 class ControllerStartupSeoUrl extends Controller {
6 -
7 - //seopro start
8 - private $seo_pro;
9 - public function __construct($registry) {
10 - parent::__construct($registry);
11 - $this->seo_pro = new SeoPro($registry);
12 - }
13 - //seopro end
14 -
15 public function index() { 3 public function index() {
16 -
17 // Add rewrite to url class 4 // Add rewrite to url class
18 if ($this->config->get('config_seo_url')) { 5 if ($this->config->get('config_seo_url')) {
19 $this->url->addRewrite($this); 6 $this->url->addRewrite($this);
20 } 7 }
21 8
22 -
23 // Decode URL 9 // Decode URL
24 if (isset($this->request->get['_route_'])) { 10 if (isset($this->request->get['_route_'])) {
25 $parts = explode('/', $this->request->get['_route_']); 11 $parts = explode('/', $this->request->get['_route_']);
26 12
27 - //seopro prepare route
28 - if($this->config->get('config_seo_pro')){
29 - $parts = $this->seo_pro->prepareRoute($parts);
30 - }
31 - //seopro prepare route end
32 -
33 // remove any empty arrays from trailing 13 // remove any empty arrays from trailing
34 if (utf8_strlen(end($parts)) == 0) { 14 if (utf8_strlen(end($parts)) == 0) {
35 array_pop($parts); 15 array_pop($parts);
...@@ -65,9 +45,7 @@ class ControllerStartupSeoUrl extends Controller { ...@@ -65,9 +45,7 @@ class ControllerStartupSeoUrl extends Controller {
65 $this->request->get['route'] = $query->row['query']; 45 $this->request->get['route'] = $query->row['query'];
66 } 46 }
67 } else { 47 } else {
68 - if(!$this->config->get('config_seo_pro')){
69 $this->request->get['route'] = 'error/not_found'; 48 $this->request->get['route'] = 'error/not_found';
70 - }
71 49
72 break; 50 break;
73 } 51 }
...@@ -85,38 +63,17 @@ class ControllerStartupSeoUrl extends Controller { ...@@ -85,38 +63,17 @@ class ControllerStartupSeoUrl extends Controller {
85 } 63 }
86 } 64 }
87 } 65 }
88 -
89 - //seopro validate
90 - if($this->config->get('config_seo_pro')){
91 - $this->seo_pro->validate();
92 - }
93 - //seopro validate
94 -
95 } 66 }
96 67
97 public function rewrite($link) { 68 public function rewrite($link) {
98 $url_info = parse_url(str_replace('&amp;', '&', $link)); 69 $url_info = parse_url(str_replace('&amp;', '&', $link));
99 70
100 - if($this->config->get('config_seo_pro')){
101 - $url = null;
102 - } else {
103 $url = ''; 71 $url = '';
104 - }
105 72
106 $data = array(); 73 $data = array();
107 74
108 parse_str($url_info['query'], $data); 75 parse_str($url_info['query'], $data);
109 76
110 - //seo_pro baseRewrite
111 - if($this->config->get('config_seo_pro')){
112 - list($url, $data, $postfix) = $this->seo_pro->baseRewrite($data, (int)$this->config->get('config_language_id'));
113 - }
114 -
115 -
116 -
117 -
118 - //seo_pro baseRewrite
119 -
120 foreach ($data as $key => $value) { 77 foreach ($data as $key => $value) {
121 if (isset($data['route'])) { 78 if (isset($data['route'])) {
122 if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) { 79 if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {
...@@ -147,7 +104,7 @@ class ControllerStartupSeoUrl extends Controller { ...@@ -147,7 +104,7 @@ class ControllerStartupSeoUrl extends Controller {
147 } 104 }
148 } 105 }
149 106
150 - //seo_pro add blank url 107 + if ($url) {
151 unset($data['route']); 108 unset($data['route']);
152 109
153 $query = ''; 110 $query = '';
...@@ -162,21 +119,6 @@ class ControllerStartupSeoUrl extends Controller { ...@@ -162,21 +119,6 @@ class ControllerStartupSeoUrl extends Controller {
162 } 119 }
163 } 120 }
164 121
165 - if($this->config->get('config_seo_pro')) {
166 - $condition = ($url !== null);
167 - } else {
168 - $condition = $url;
169 - }
170 -
171 - if ($condition) {
172 - if($this->config->get('config_seo_pro')){
173 - if($this->config->get('config_page_postfix') && $postfix) {
174 - $url .= $this->config->get('config_page_postfix');
175 - } elseif($this->config->get('config_seopro_addslash') || !empty( $query)) {
176 - $url .= '/';
177 - }
178 - }
179 -
180 return $url_info['scheme'] . '://' . $url_info['host'] . (isset($url_info['port']) ? ':' . $url_info['port'] : '') . str_replace('/index.php', '', $url_info['path']) . $url . $query; 122 return $url_info['scheme'] . '://' . $url_info['host'] . (isset($url_info['port']) ? ':' . $url_info['port'] : '') . str_replace('/index.php', '', $url_info['path']) . $url . $query;
181 } else { 123 } else {
182 return $link; 124 return $link;
......
1 +<?php
2 +// * @source See SOURCE.txt for source and other copyright.
3 +// * @license GNU General Public License version 3; see LICENSE.txt
4 +
5 +class ControllerStartupSeoUrl extends Controller {
6 +
7 + //seopro start
8 + private $seo_pro;
9 + public function __construct($registry) {
10 + parent::__construct($registry);
11 + $this->seo_pro = new SeoPro($registry);
12 + }
13 + //seopro end
14 +
15 + public function index() {
16 +
17 + // Add rewrite to url class
18 + if ($this->config->get('config_seo_url')) {
19 + $this->url->addRewrite($this);
20 + }
21 +
22 +
23 + // Decode URL
24 + if (isset($this->request->get['_route_'])) {
25 + $parts = explode('/', $this->request->get['_route_']);
26 +
27 + //seopro prepare route
28 + if($this->config->get('config_seo_pro')){
29 + $parts = $this->seo_pro->prepareRoute($parts);
30 + }
31 + //seopro prepare route end
32 +
33 + // remove any empty arrays from trailing
34 + if (utf8_strlen(end($parts)) == 0) {
35 + array_pop($parts);
36 + }
37 +
38 + foreach ($parts as $part) {
39 + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE keyword = '" . $this->db->escape($part) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");
40 +
41 + if ($query->num_rows) {
42 + $url = explode('=', $query->row['query']);
43 +
44 + if ($url[0] == 'product_id') {
45 + $this->request->get['product_id'] = $url[1];
46 + }
47 +
48 + if ($url[0] == 'category_id') {
49 + if (!isset($this->request->get['path'])) {
50 + $this->request->get['path'] = $url[1];
51 + } else {
52 + $this->request->get['path'] .= '_' . $url[1];
53 + }
54 + }
55 +
56 + if ($url[0] == 'manufacturer_id') {
57 + $this->request->get['manufacturer_id'] = $url[1];
58 + }
59 +
60 + if ($url[0] == 'information_id') {
61 + $this->request->get['information_id'] = $url[1];
62 + }
63 +
64 + if ($query->row['query'] && $url[0] != 'information_id' && $url[0] != 'manufacturer_id' && $url[0] != 'category_id' && $url[0] != 'product_id') {
65 + $this->request->get['route'] = $query->row['query'];
66 + }
67 + } else {
68 + if(!$this->config->get('config_seo_pro')){
69 + $this->request->get['route'] = 'error/not_found';
70 + }
71 +
72 + break;
73 + }
74 + }
75 +
76 + if (!isset($this->request->get['route'])) {
77 + if (isset($this->request->get['product_id'])) {
78 + $this->request->get['route'] = 'product/product';
79 + } elseif (isset($this->request->get['path'])) {
80 + $this->request->get['route'] = 'product/category';
81 + } elseif (isset($this->request->get['manufacturer_id'])) {
82 + $this->request->get['route'] = 'product/manufacturer/info';
83 + } elseif (isset($this->request->get['information_id'])) {
84 + $this->request->get['route'] = 'information/information';
85 + }
86 + }
87 + }
88 +
89 + //seopro validate
90 + if($this->config->get('config_seo_pro')){
91 + $this->seo_pro->validate();
92 + }
93 + //seopro validate
94 +
95 + }
96 +
97 + public function rewrite($link) {
98 + $url_info = parse_url(str_replace('&amp;', '&', $link));
99 +
100 + if($this->config->get('config_seo_pro')){
101 + $url = null;
102 + } else {
103 + $url = '';
104 + }
105 +
106 + $data = array();
107 +
108 + parse_str($url_info['query'], $data);
109 +
110 + //seo_pro baseRewrite
111 + if($this->config->get('config_seo_pro')){
112 + list($url, $data, $postfix) = $this->seo_pro->baseRewrite($data, (int)$this->config->get('config_language_id'));
113 + }
114 +
115 +
116 +
117 +
118 + //seo_pro baseRewrite
119 +
120 + foreach ($data as $key => $value) {
121 + if (isset($data['route'])) {
122 + if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {
123 + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
124 +
125 + if ($query->num_rows && $query->row['keyword']) {
126 + $url .= '/' . $query->row['keyword'];
127 +
128 + unset($data[$key]);
129 + }
130 + } elseif ($key == 'path') {
131 + $categories = explode('_', $value);
132 +
133 + foreach ($categories as $category) {
134 + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = 'category_id=" . (int)$category . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
135 +
136 + if ($query->num_rows && $query->row['keyword']) {
137 + $url .= '/' . $query->row['keyword'];
138 + } else {
139 + $url = '';
140 +
141 + break;
142 + }
143 + }
144 +
145 + unset($data[$key]);
146 + }
147 + }
148 + }
149 +
150 + //seo_pro add blank url
151 + unset($data['route']);
152 +
153 + $query = '';
154 +
155 + if ($data) {
156 + foreach ($data as $key => $value) {
157 + $query .= '&' . rawurlencode((string)$key) . '=' . rawurlencode((is_array($value) ? http_build_query($value) : (string)$value));
158 + }
159 +
160 + if ($query) {
161 + $query = '?' . str_replace('&', '&amp;', trim($query, '&'));
162 + }
163 + }
164 +
165 + if($this->config->get('config_seo_pro')) {
166 + $condition = ($url !== null);
167 + } else {
168 + $condition = $url;
169 + }
170 +
171 + if ($condition) {
172 + if($this->config->get('config_seo_pro')){
173 + if($this->config->get('config_page_postfix') && $postfix) {
174 + $url .= $this->config->get('config_page_postfix');
175 + } elseif($this->config->get('config_seopro_addslash') || !empty( $query)) {
176 + $url .= '/';
177 + }
178 + }
179 +
180 + return $url_info['scheme'] . '://' . $url_info['host'] . (isset($url_info['port']) ? ':' . $url_info['port'] : '') . str_replace('/index.php', '', $url_info['path']) . $url . $query;
181 + } else {
182 + return $link;
183 + }
184 + }
185 +}