1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* Divine CMS - Open source CMS for widespread use. |
4
|
|
|
Copyright (c) 2019 Mykola Burakov ([email protected]) |
5
|
|
|
|
6
|
|
|
See SOURCE.txt for other and additional information. |
7
|
|
|
|
8
|
|
|
This file is part of Divine CMS. |
9
|
|
|
|
10
|
|
|
This program is free software: you can redistribute it and/or modify |
11
|
|
|
it under the terms of the GNU General Public License as published by |
12
|
|
|
the Free Software Foundation, either version 3 of the License, or |
13
|
|
|
(at your option) any later version. |
14
|
|
|
|
15
|
|
|
This program is distributed in the hope that it will be useful, |
16
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
|
|
|
GNU General Public License for more details. |
19
|
|
|
|
20
|
|
|
You should have received a copy of the GNU General Public License |
21
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
22
|
|
|
|
23
|
|
|
class ModelLocalisationLanguage extends \Divine\Engine\Core\Model |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
public function addLanguage($data) |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
$this->db->query(" |
28
|
|
|
INSERT INTO language |
29
|
|
|
SET name = '" . $this->db->escape($data['name']) . "', |
30
|
|
|
code = '" . $this->db->escape($data['code']) . "', |
31
|
|
|
locale = '" . $this->db->escape($data['locale']) . "', |
32
|
|
|
sort_order = '" . $this->db->escape($data['sort_order']) . "', |
33
|
|
|
status = '" . (int)$data['status'] . "' |
34
|
|
|
"); |
35
|
|
|
|
36
|
|
|
$this->cache->delete('language'); |
37
|
|
|
|
38
|
|
|
$language_id = $this->db->getLastId(); |
39
|
|
|
|
40
|
|
|
// Blog Article |
41
|
|
|
$query = $this->db->query(" |
42
|
|
|
SELECT * |
43
|
|
|
FROM article_description |
44
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
45
|
|
|
"); |
46
|
|
|
|
47
|
|
|
foreach ($query->rows as $article) { |
48
|
|
|
$this->db->query(" |
49
|
|
|
INSERT INTO article_description |
50
|
|
|
SET article_id = '" . (int)$article['article_id'] . "', |
51
|
|
|
language_id = '" . (int)$language_id . "', |
52
|
|
|
name = '" . $this->db->escape($article['name']) . "', |
53
|
|
|
description = '" . $this->db->escape($article['description']) . "', |
54
|
|
|
meta_description = '" . $this->db->escape($article['meta_description']) . "', |
55
|
|
|
meta_title = '" . $this->db->escape($article['meta_title']) . "', |
56
|
|
|
meta_h1 = '" . $this->db->escape($article['meta_h1']) . "', |
57
|
|
|
tag = '" . $this->db->escape($article['tag']) . "' |
58
|
|
|
"); |
59
|
|
|
} |
60
|
|
|
$this->cache->delete('article'); |
61
|
|
|
|
62
|
|
|
// Blog Category |
63
|
|
|
$query = $this->db->query(" |
64
|
|
|
SELECT * |
65
|
|
|
FROM blog_category_description |
66
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
67
|
|
|
"); |
68
|
|
|
|
69
|
|
|
foreach ($query->rows as $blog_category) { |
70
|
|
|
$this->db->query(" |
71
|
|
|
INSERT INTO blog_category_description |
72
|
|
|
SET blog_category_id = '" . (int)$blog_category['blog_category_id'] . "', |
73
|
|
|
language_id = '" . (int)$language_id . "', |
74
|
|
|
name = '" . $this->db->escape($blog_category['name']) . "', |
75
|
|
|
description = '" . $this->db->escape($blog_category['description']) . "', |
76
|
|
|
meta_description = '" . $this->db->escape($blog_category['meta_description']) . "', |
77
|
|
|
meta_title = '" . $this->db->escape($blog_category['meta_title']) . "', |
78
|
|
|
meta_h1 = '" . $this->db->escape($blog_category['meta_h1']) . "' |
79
|
|
|
"); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
// Menu |
83
|
|
|
$query = $this->db->query(" |
84
|
|
|
SELECT * |
85
|
|
|
FROM custommenu_description |
86
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
87
|
|
|
"); |
88
|
|
|
|
89
|
|
|
foreach ($query->rows as $custommenu) { |
90
|
|
|
$this->db->query(" |
91
|
|
|
INSERT INTO custommenu_description |
92
|
|
|
SET custommenu_id = '" . (int)$custommenu['custommenu_id'] . "', |
93
|
|
|
language_id = '" . (int)$language_id . "', |
94
|
|
|
name = '" . $this->db->escape($custommenu['name']) . "', |
95
|
|
|
link = '" . $this->db->escape($custommenu['link']) . "' |
96
|
|
|
"); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
// Menu Child |
100
|
|
|
$query = $this->db->query(" |
101
|
|
|
SELECT * |
102
|
|
|
FROM custommenu_child_description |
103
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
104
|
|
|
"); |
105
|
|
|
|
106
|
|
|
foreach ($query->rows as $custommenu_child) { |
107
|
|
|
$this->db->query(" |
108
|
|
|
INSERT INTO custommenu_child_description |
109
|
|
|
SET custommenu_child_id = '" . (int)$custommenu_child['custommenu_child_id'] . "', |
110
|
|
|
custommenu_id = '" . (int)$custommenu_child['custommenu_id'] . "', |
111
|
|
|
language_id = '" . (int)$language_id . "', |
112
|
|
|
name = '" . $this->db->escape($custommenu_child['name']) . "', |
113
|
|
|
link = '" . $this->db->escape($custommenu_child['link']) . "' |
114
|
|
|
"); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
// Attribute |
118
|
|
|
$query = $this->db->query(" |
119
|
|
|
SELECT * |
120
|
|
|
FROM attribute_description |
121
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
122
|
|
|
"); |
123
|
|
|
|
124
|
|
|
foreach ($query->rows as $attribute) { |
125
|
|
|
$this->db->query(" |
126
|
|
|
INSERT INTO attribute_description |
127
|
|
|
SET attribute_id = '" . (int)$attribute['attribute_id'] . "', |
128
|
|
|
language_id = '" . (int)$language_id . "', |
129
|
|
|
name = '" . $this->db->escape($attribute['name']) . "' |
130
|
|
|
"); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
// Attribute Group |
134
|
|
|
$query = $this->db->query(" |
135
|
|
|
SELECT * |
136
|
|
|
FROM attribute_group_description |
137
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
138
|
|
|
"); |
139
|
|
|
|
140
|
|
|
foreach ($query->rows as $attribute_group) { |
141
|
|
|
$this->db->query(" |
142
|
|
|
INSERT INTO attribute_group_description |
143
|
|
|
SET attribute_group_id = '" . (int)$attribute_group['attribute_group_id'] . "', |
144
|
|
|
language_id = '" . (int)$language_id . "', |
145
|
|
|
name = '" . $this->db->escape($attribute_group['name']) . "' |
146
|
|
|
"); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
$this->cache->delete('attribute'); |
150
|
|
|
|
151
|
|
|
// Banner |
152
|
|
|
$query = $this->db->query(" |
153
|
|
|
SELECT * |
154
|
|
|
FROM banner_image |
155
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
156
|
|
|
"); |
157
|
|
|
|
158
|
|
|
foreach ($query->rows as $banner_image) { |
159
|
|
|
$this->db->query(" |
160
|
|
|
INSERT INTO banner_image |
161
|
|
|
SET banner_id = '" . (int)$banner_image['banner_id'] . "', |
162
|
|
|
language_id = '" . (int)$language_id . "', |
163
|
|
|
title = '" . $this->db->escape($banner_image['title']) . "', |
164
|
|
|
link = '" . $this->db->escape($banner_image['link']) . "', |
165
|
|
|
image = '" . $this->db->escape($banner_image['image']) . "', |
166
|
|
|
sort_order = '" . (int)$banner_image['sort_order'] . "' |
167
|
|
|
"); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
$this->cache->delete('banner'); |
171
|
|
|
|
172
|
|
|
// Category |
173
|
|
|
$query = $this->db->query(" |
174
|
|
|
SELECT * |
175
|
|
|
FROM category_description |
176
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
177
|
|
|
"); |
178
|
|
|
|
179
|
|
|
foreach ($query->rows as $category) { |
180
|
|
|
$this->db->query(" |
181
|
|
|
INSERT INTO category_description |
182
|
|
|
SET category_id = '" . (int)$category['category_id'] . "', |
183
|
|
|
language_id = '" . (int)$language_id . "', |
184
|
|
|
name = '" . $this->db->escape($category['name']) . "', |
185
|
|
|
description = '" . $this->db->escape($category['description']) . "', |
186
|
|
|
meta_title = '" . $this->db->escape($category['meta_title']) . "', |
187
|
|
|
meta_description = '" . $this->db->escape($category['meta_description']) . "' |
188
|
|
|
"); |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
$this->cache->delete('category'); |
192
|
|
|
|
193
|
|
|
// Customer Group |
194
|
|
|
$query = $this->db->query(" |
195
|
|
|
SELECT * |
196
|
|
|
FROM customer_group_description |
197
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
198
|
|
|
"); |
199
|
|
|
|
200
|
|
|
foreach ($query->rows as $customer_group) { |
201
|
|
|
$this->db->query(" |
202
|
|
|
INSERT INTO customer_group_description |
203
|
|
|
SET customer_group_id = '" . (int)$customer_group['customer_group_id'] . "', |
204
|
|
|
language_id = '" . (int)$language_id . "', |
205
|
|
|
name = '" . $this->db->escape($customer_group['name']) . "', |
206
|
|
|
description = '" . $this->db->escape($customer_group['description']) . "' |
207
|
|
|
"); |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
// Custom Field |
211
|
|
|
$query = $this->db->query(" |
212
|
|
|
SELECT * |
213
|
|
|
FROM custom_field_description |
214
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
215
|
|
|
"); |
216
|
|
|
|
217
|
|
|
foreach ($query->rows as $custom_field) { |
218
|
|
|
$this->db->query(" |
219
|
|
|
INSERT INTO custom_field_description |
220
|
|
|
SET custom_field_id = '" . (int)$custom_field['custom_field_id'] . "', |
221
|
|
|
language_id = '" . (int)$language_id . "', |
222
|
|
|
name = '" . $this->db->escape($custom_field['name']) . "' |
223
|
|
|
"); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
// Custom Field Value |
227
|
|
|
$query = $this->db->query(" |
228
|
|
|
SELECT * |
229
|
|
|
FROM custom_field_value_description |
230
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
231
|
|
|
"); |
232
|
|
|
|
233
|
|
|
foreach ($query->rows as $custom_field_value) { |
234
|
|
|
$this->db->query(" |
235
|
|
|
INSERT INTO custom_field_value_description |
236
|
|
|
SET custom_field_value_id = '" . (int)$custom_field_value['custom_field_value_id'] . "', |
237
|
|
|
language_id = '" . (int)$language_id . "', |
238
|
|
|
custom_field_id = '" . (int)$custom_field_value['custom_field_id'] . "', |
239
|
|
|
name = '" . $this->db->escape($custom_field_value['name']) . "' |
240
|
|
|
"); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
// Download |
244
|
|
|
$query = $this->db->query(" |
245
|
|
|
SELECT * |
246
|
|
|
FROM download_description |
247
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
248
|
|
|
"); |
249
|
|
|
|
250
|
|
|
foreach ($query->rows as $download) { |
251
|
|
|
$this->db->query(" |
252
|
|
|
INSERT INTO download_description |
253
|
|
|
SET download_id = '" . (int)$download['download_id'] . "', |
254
|
|
|
language_id = '" . (int)$language_id . "', |
255
|
|
|
name = '" . $this->db->escape($download['name']) . "' |
256
|
|
|
"); |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
// Filter |
260
|
|
|
$query = $this->db->query(" |
261
|
|
|
SELECT * |
262
|
|
|
FROM filter_description |
263
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
264
|
|
|
"); |
265
|
|
|
|
266
|
|
|
foreach ($query->rows as $filter) { |
267
|
|
|
$this->db->query(" |
268
|
|
|
INSERT INTO filter_description |
269
|
|
|
SET filter_id = '" . (int)$filter['filter_id'] . "', |
270
|
|
|
language_id = '" . (int)$language_id . "', |
271
|
|
|
filter_group_id = '" . (int)$filter['filter_group_id'] . "', |
272
|
|
|
name = '" . $this->db->escape($filter['name']) . "' |
273
|
|
|
"); |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
// Filter Group |
277
|
|
|
$query = $this->db->query(" |
278
|
|
|
SELECT * |
279
|
|
|
FROM filter_group_description |
280
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
281
|
|
|
"); |
282
|
|
|
|
283
|
|
|
foreach ($query->rows as $filter_group) { |
284
|
|
|
$this->db->query(" |
285
|
|
|
INSERT INTO filter_group_description |
286
|
|
|
SET filter_group_id = '" . (int)$filter_group['filter_group_id'] . "', |
287
|
|
|
language_id = '" . (int)$language_id . "', |
288
|
|
|
name = '" . $this->db->escape($filter_group['name']) . "' |
289
|
|
|
"); |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
// Information |
293
|
|
|
$query = $this->db->query(" |
294
|
|
|
SELECT * |
295
|
|
|
FROM information_description |
296
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
297
|
|
|
"); |
298
|
|
|
|
299
|
|
|
foreach ($query->rows as $information) { |
300
|
|
|
$this->db->query(" |
301
|
|
|
INSERT INTO information_description |
302
|
|
|
SET information_id = '" . (int)$information['information_id'] . "', |
303
|
|
|
language_id = '" . (int)$language_id . "', |
304
|
|
|
title = '" . $this->db->escape($information['title']) . "', |
305
|
|
|
description = '" . $this->db->escape($information['description']) . "', |
306
|
|
|
meta_title = '" . $this->db->escape($information['meta_title']) . "', |
307
|
|
|
meta_description = '" . $this->db->escape($information['meta_description']) . "' |
308
|
|
|
"); |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
$this->cache->delete('information'); |
312
|
|
|
|
313
|
|
|
// Option |
314
|
|
|
$query = $this->db->query(" |
315
|
|
|
SELECT * |
316
|
|
|
FROM option_description |
317
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
318
|
|
|
"); |
319
|
|
|
|
320
|
|
|
foreach ($query->rows as $option) { |
321
|
|
|
$this->db->query(" |
322
|
|
|
INSERT INTO option_description |
323
|
|
|
SET option_id = '" . (int)$option['option_id'] . "', |
324
|
|
|
language_id = '" . (int)$language_id . "', |
325
|
|
|
name = '" . $this->db->escape($option['name']) . "' |
326
|
|
|
"); |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
// Option Value |
330
|
|
|
$query = $this->db->query(" |
331
|
|
|
SELECT * |
332
|
|
|
FROM option_value_description |
333
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
334
|
|
|
"); |
335
|
|
|
|
336
|
|
|
foreach ($query->rows as $option_value) { |
337
|
|
|
$this->db->query(" |
338
|
|
|
INSERT INTO option_value_description |
339
|
|
|
SET option_value_id = '" . (int)$option_value['option_value_id'] . "', |
340
|
|
|
language_id = '" . (int)$language_id . "', |
341
|
|
|
option_id = '" . (int)$option_value['option_id'] . "', |
342
|
|
|
name = '" . $this->db->escape($option_value['name']) . "' |
343
|
|
|
"); |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
// Order Status |
347
|
|
|
$query = $this->db->query(" |
348
|
|
|
SELECT * |
349
|
|
|
FROM order_status |
350
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
351
|
|
|
"); |
352
|
|
|
|
353
|
|
|
foreach ($query->rows as $order_status) { |
354
|
|
|
$this->db->query(" |
355
|
|
|
INSERT INTO order_status |
356
|
|
|
SET order_status_id = '" . (int)$order_status['order_status_id'] . "', |
357
|
|
|
language_id = '" . (int)$language_id . "', |
358
|
|
|
name = '" . $this->db->escape($order_status['name']) . "' |
359
|
|
|
"); |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
$this->cache->delete('order_status'); |
363
|
|
|
|
364
|
|
|
// Product |
365
|
|
|
$query = $this->db->query(" |
366
|
|
|
SELECT * |
367
|
|
|
FROM product_description |
368
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
369
|
|
|
"); |
370
|
|
|
|
371
|
|
|
foreach ($query->rows as $product) { |
372
|
|
|
$this->db->query(" |
373
|
|
|
INSERT INTO product_description |
374
|
|
|
SET product_id = '" . (int)$product['product_id'] . "', |
375
|
|
|
language_id = '" . (int)$language_id . "', |
376
|
|
|
name = '" . $this->db->escape($product['name']) . "', |
377
|
|
|
description = '" . $this->db->escape($product['description']) . "', |
378
|
|
|
tag = '" . $this->db->escape($product['tag']) . "', |
379
|
|
|
meta_title = '" . $this->db->escape($product['meta_title']) . "', |
380
|
|
|
meta_description = '" . $this->db->escape($product['meta_description']) . "' |
381
|
|
|
"); |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
$this->cache->delete('product'); |
385
|
|
|
|
386
|
|
|
// Product Attribute |
387
|
|
|
$query = $this->db->query(" |
388
|
|
|
SELECT * |
389
|
|
|
FROM product_attribute |
390
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
391
|
|
|
"); |
392
|
|
|
|
393
|
|
|
foreach ($query->rows as $product_attribute) { |
394
|
|
|
$this->db->query(" |
395
|
|
|
INSERT INTO product_attribute |
396
|
|
|
SET product_id = '" . (int)$product_attribute['product_id'] . "', |
397
|
|
|
attribute_id = '" . (int)$product_attribute['attribute_id'] . "', |
398
|
|
|
language_id = '" . (int)$language_id . "', |
399
|
|
|
text = '" . $this->db->escape($product_attribute['text']) . "' |
400
|
|
|
"); |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
// Stock Status |
404
|
|
|
$query = $this->db->query(" |
405
|
|
|
SELECT * |
406
|
|
|
FROM stock_status |
407
|
|
|
WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
408
|
|
|
"); |
409
|
|
|
|
410
|
|
|
foreach ($query->rows as $stock_status) { |
411
|
|
|
$this->db->query(" |
412
|
|
|
INSERT INTO stock_status |
413
|
|
|
SET stock_status_id = '" . (int)$stock_status['stock_status_id'] . "', |
414
|
|
|
language_id = '" . (int)$language_id . "', |
415
|
|
|
name = '" . $this->db->escape($stock_status['name']) . "' |
416
|
|
|
"); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
$this->cache->delete('stock_status'); |
420
|
|
|
|
421
|
|
|
return $language_id; |
422
|
|
|
} |
423
|
|
|
|
424
|
|
|
public function editLanguage($language_id, $data) |
425
|
|
|
{ |
426
|
|
|
$language_query = $this->db->query(" |
427
|
|
|
SELECT `code` |
428
|
|
|
FROM language |
429
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
430
|
|
|
"); |
431
|
|
|
|
432
|
|
|
$this->db->query(" |
433
|
|
|
UPDATE language |
434
|
|
|
SET name = '" . $this->db->escape($data['name']) . "', |
435
|
|
|
code = '" . $this->db->escape($data['code']) . "', |
436
|
|
|
locale = '" . $this->db->escape($data['locale']) . "', |
437
|
|
|
sort_order = '" . $this->db->escape($data['sort_order']) . "', |
438
|
|
|
status = '" . (int)$data['status'] . "' |
439
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
440
|
|
|
"); |
441
|
|
|
|
442
|
|
|
if ($language_query->row['code'] != $data['code']) { |
443
|
|
|
$this->db->query(" |
444
|
|
|
UPDATE setting |
445
|
|
|
SET value = '" . $this->db->escape($data['code']) . "' |
446
|
|
|
WHERE `key` = 'config_language' |
447
|
|
|
AND value = '" . $this->db->escape($language_query->row['code']) . "' |
448
|
|
|
"); |
449
|
|
|
$this->db->query(" |
450
|
|
|
UPDATE setting |
451
|
|
|
SET value = '" . $this->db->escape($data['code']) . "' |
452
|
|
|
WHERE `key` = 'config_admin_language' |
453
|
|
|
AND value = '" . $this->db->escape($language_query->row['code']) . "' |
454
|
|
|
"); |
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
$this->cache->delete('language'); |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
public function deleteLanguage($language_id) |
461
|
|
|
{ |
462
|
|
|
$this->db->query(" |
463
|
|
|
DELETE |
464
|
|
|
FROM language |
465
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
466
|
|
|
"); |
467
|
|
|
|
468
|
|
|
$this->cache->delete('language'); |
469
|
|
|
|
470
|
|
|
$this->db->query(" |
471
|
|
|
DELETE |
472
|
|
|
FROM article_description |
473
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
474
|
|
|
"); |
475
|
|
|
$this->cache->delete('article'); |
476
|
|
|
$this->db->query(" |
477
|
|
|
DELETE |
478
|
|
|
FROM blog_category_description |
479
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
480
|
|
|
"); |
481
|
|
|
$this->db->query(" |
482
|
|
|
DELETE |
483
|
|
|
FROM custommenu_description |
484
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
485
|
|
|
"); |
486
|
|
|
$this->db->query(" |
487
|
|
|
DELETE |
488
|
|
|
FROM custommenu_child_description |
489
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
490
|
|
|
"); |
491
|
|
|
|
492
|
|
|
$this->db->query(" |
493
|
|
|
DELETE |
494
|
|
|
FROM attribute_description |
495
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
496
|
|
|
"); |
497
|
|
|
$this->db->query(" |
498
|
|
|
DELETE |
499
|
|
|
FROM attribute_group_description |
500
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
501
|
|
|
"); |
502
|
|
|
$this->db->query(" |
503
|
|
|
DELETE |
504
|
|
|
FROM category_description |
505
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
506
|
|
|
"); |
507
|
|
|
|
508
|
|
|
$this->cache->delete('category'); |
509
|
|
|
|
510
|
|
|
$this->db->query(" |
511
|
|
|
DELETE |
512
|
|
|
FROM customer_group_description |
513
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
514
|
|
|
"); |
515
|
|
|
$this->db->query(" |
516
|
|
|
DELETE |
517
|
|
|
FROM download_description |
518
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
519
|
|
|
"); |
520
|
|
|
$this->db->query(" |
521
|
|
|
DELETE |
522
|
|
|
FROM filter_description |
523
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
524
|
|
|
"); |
525
|
|
|
$this->db->query(" |
526
|
|
|
DELETE |
527
|
|
|
FROM filter_group_description |
528
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
529
|
|
|
"); |
530
|
|
|
$this->db->query(" |
531
|
|
|
DELETE |
532
|
|
|
FROM information_description |
533
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
534
|
|
|
"); |
535
|
|
|
|
536
|
|
|
$this->cache->delete('information'); |
537
|
|
|
|
538
|
|
|
$this->db->query(" |
539
|
|
|
DELETE |
540
|
|
|
FROM option_description |
541
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
542
|
|
|
"); |
543
|
|
|
$this->db->query(" |
544
|
|
|
DELETE |
545
|
|
|
FROM option_value_description |
546
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
547
|
|
|
"); |
548
|
|
|
$this->db->query(" |
549
|
|
|
DELETE |
550
|
|
|
FROM order_status |
551
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
552
|
|
|
"); |
553
|
|
|
|
554
|
|
|
$this->cache->delete('order_status'); |
555
|
|
|
|
556
|
|
|
$this->db->query(" |
557
|
|
|
DELETE |
558
|
|
|
FROM product_attribute |
559
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
560
|
|
|
"); |
561
|
|
|
$this->db->query(" |
562
|
|
|
DELETE |
563
|
|
|
FROM product_description |
564
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
565
|
|
|
"); |
566
|
|
|
|
567
|
|
|
$this->cache->delete('product'); |
568
|
|
|
|
569
|
|
|
$this->db->query(" |
570
|
|
|
DELETE |
571
|
|
|
FROM stock_status |
572
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
573
|
|
|
"); |
574
|
|
|
|
575
|
|
|
$this->cache->delete('stock_status'); |
576
|
|
|
} |
577
|
|
|
|
578
|
|
|
public function getLanguage($language_id) |
579
|
|
|
{ |
580
|
|
|
$query = $this->db->query(" |
581
|
|
|
SELECT DISTINCT * |
582
|
|
|
FROM language |
583
|
|
|
WHERE language_id = '" . (int)$language_id . "' |
584
|
|
|
"); |
585
|
|
|
|
586
|
|
|
return $query->row; |
587
|
|
|
} |
588
|
|
|
|
589
|
|
|
public function getLanguages($data = array()) |
590
|
|
|
{ |
591
|
|
|
if ($data) { |
592
|
|
|
$sql = " |
|
|
|
|
593
|
|
|
SELECT * |
594
|
|
|
FROM language |
595
|
|
|
"; |
596
|
|
|
|
597
|
|
|
$sort_data = array( |
598
|
|
|
'name', |
599
|
|
|
'code', |
600
|
|
|
'sort_order' |
601
|
|
|
); |
602
|
|
|
|
603
|
|
|
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { |
604
|
|
|
$sql .= " ORDER BY " . $data['sort']; |
|
|
|
|
605
|
|
|
} else { |
606
|
|
|
$sql .= " ORDER BY sort_order, name"; |
|
|
|
|
607
|
|
|
} |
608
|
|
|
|
609
|
|
|
if (isset($data['order']) && ($data['order'] == 'DESC')) { |
610
|
|
|
$sql .= " DESC"; |
|
|
|
|
611
|
|
|
} else { |
612
|
|
|
$sql .= " ASC"; |
|
|
|
|
613
|
|
|
} |
614
|
|
|
|
615
|
|
|
if (isset($data['start']) || isset($data['limit'])) { |
616
|
|
|
if ($data['start'] < 0) { |
617
|
|
|
$data['start'] = 0; |
618
|
|
|
} |
619
|
|
|
|
620
|
|
|
if ($data['limit'] < 1) { |
621
|
|
|
$data['limit'] = 20; |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; |
|
|
|
|
625
|
|
|
} |
626
|
|
|
|
627
|
|
|
$query = $this->db->query($sql); |
628
|
|
|
|
629
|
|
|
return $query->rows; |
630
|
|
|
} else { |
631
|
|
|
$language_data = $this->cache->get('language'); |
632
|
|
|
|
633
|
|
|
if (!$language_data) { |
634
|
|
|
$language_data = array(); |
635
|
|
|
|
636
|
|
|
$query = $this->db->query(" |
|
|
|
|
637
|
|
|
SELECT * |
638
|
|
|
FROM language |
639
|
|
|
ORDER BY sort_order, name |
640
|
|
|
"); |
641
|
|
|
|
642
|
|
|
foreach ($query->rows as $result) { |
643
|
|
|
$language_data[$result['code']] = array( |
644
|
|
|
'language_id' => $result['language_id'], |
645
|
|
|
'name' => $result['name'], |
646
|
|
|
'code' => $result['code'], |
647
|
|
|
'locale' => $result['locale'], |
648
|
|
|
'image' => $result['image'], |
649
|
|
|
'directory' => $result['directory'], |
650
|
|
|
'sort_order' => $result['sort_order'], |
651
|
|
|
'status' => $result['status'] |
652
|
|
|
); |
653
|
|
|
} |
654
|
|
|
|
655
|
|
|
$this->cache->set( |
656
|
|
|
'language', |
657
|
|
|
$language_data |
658
|
|
|
); |
659
|
|
|
} |
660
|
|
|
|
661
|
|
|
return $language_data; |
662
|
|
|
} |
663
|
|
|
} |
664
|
|
|
|
665
|
|
|
public function getLanguageByCode($code) |
666
|
|
|
{ |
667
|
|
|
$query = $this->db->query(" |
668
|
|
|
SELECT * |
669
|
|
|
FROM `language` |
670
|
|
|
WHERE code = '" . $this->db->escape($code) . "' |
671
|
|
|
"); |
672
|
|
|
|
673
|
|
|
return $query->row; |
674
|
|
|
} |
675
|
|
|
|
676
|
|
|
public function getTotalLanguages() |
677
|
|
|
{ |
678
|
|
|
$query = $this->db->query(" |
|
|
|
|
679
|
|
|
SELECT COUNT(*) AS total |
680
|
|
|
FROM language |
681
|
|
|
"); |
682
|
|
|
|
683
|
|
|
return $query->row['total']; |
684
|
|
|
} |
685
|
|
|
} |
686
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.