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 ControllerCatalogReview extends \Divine\Engine\Core\Controller |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
private $error = array(); |
26
|
|
|
|
27
|
|
|
public function index() |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
$this->load->language('catalog/review'); |
30
|
|
|
|
31
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
32
|
|
|
|
33
|
|
|
$this->load->model('catalog/review'); |
34
|
|
|
|
35
|
|
|
$this->getList(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function add() |
39
|
|
|
{ |
40
|
|
|
$this->load->language('catalog/review'); |
41
|
|
|
|
42
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
43
|
|
|
|
44
|
|
|
$this->load->model('catalog/review'); |
45
|
|
|
|
46
|
|
|
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { |
47
|
|
|
$this->model_catalog_review->addReview($this->request->post); |
48
|
|
|
|
49
|
|
|
$this->session->data['success'] = $this->language->get('text_success'); |
50
|
|
|
|
51
|
|
|
$url = ''; |
52
|
|
|
|
53
|
|
|
if (isset($this->request->get['filter_product'])) { |
54
|
|
|
$url .= '&filter_product=' . urlencode(html_entity_decode($this->request->get['filter_product'], ENT_QUOTES, 'UTF-8')); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
if (isset($this->request->get['filter_author'])) { |
58
|
|
|
$url .= '&filter_author=' . urlencode(html_entity_decode($this->request->get['filter_author'], ENT_QUOTES, 'UTF-8')); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
if (isset($this->request->get['filter_status'])) { |
62
|
|
|
$url .= '&filter_status=' . $this->request->get['filter_status']; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
66
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
if (isset($this->request->get['sort'])) { |
70
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
if (isset($this->request->get['order'])) { |
74
|
|
|
$url .= '&order=' . $this->request->get['order']; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
if (isset($this->request->get['page'])) { |
78
|
|
|
$url .= '&page=' . $this->request->get['page']; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
$this->response->redirect($this->url->link('catalog/review', 'token=' . $this->session->data['token'] . $url, true)); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
$this->getForm(); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function edit() |
88
|
|
|
{ |
89
|
|
|
$this->load->language('catalog/review'); |
90
|
|
|
|
91
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
92
|
|
|
|
93
|
|
|
$this->load->model('catalog/review'); |
94
|
|
|
|
95
|
|
|
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { |
96
|
|
|
$this->model_catalog_review->editReview($this->request->get['review_id'], $this->request->post); |
97
|
|
|
|
98
|
|
|
$this->session->data['success'] = $this->language->get('text_success'); |
99
|
|
|
|
100
|
|
|
$url = ''; |
101
|
|
|
|
102
|
|
|
if (isset($this->request->get['filter_product'])) { |
103
|
|
|
$url .= '&filter_product=' . urlencode(html_entity_decode($this->request->get['filter_product'], ENT_QUOTES, 'UTF-8')); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
if (isset($this->request->get['filter_author'])) { |
107
|
|
|
$url .= '&filter_author=' . urlencode(html_entity_decode($this->request->get['filter_author'], ENT_QUOTES, 'UTF-8')); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
if (isset($this->request->get['filter_status'])) { |
111
|
|
|
$url .= '&filter_status=' . $this->request->get['filter_status']; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
115
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
if (isset($this->request->get['sort'])) { |
119
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
if (isset($this->request->get['order'])) { |
123
|
|
|
$url .= '&order=' . $this->request->get['order']; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
if (isset($this->request->get['page'])) { |
127
|
|
|
$url .= '&page=' . $this->request->get['page']; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
$this->response->redirect($this->url->link('catalog/review', 'token=' . $this->session->data['token'] . $url, true)); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
$this->getForm(); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
public function delete() |
137
|
|
|
{ |
138
|
|
|
$this->load->language('catalog/review'); |
139
|
|
|
|
140
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
141
|
|
|
|
142
|
|
|
$this->load->model('catalog/review'); |
143
|
|
|
|
144
|
|
|
if (isset($this->request->post['selected']) && $this->validateDelete()) { |
145
|
|
|
foreach ($this->request->post['selected'] as $review_id) { |
146
|
|
|
$this->model_catalog_review->deleteReview($review_id); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
$this->session->data['success'] = $this->language->get('text_success'); |
150
|
|
|
|
151
|
|
|
$url = ''; |
152
|
|
|
|
153
|
|
|
if (isset($this->request->get['filter_product'])) { |
154
|
|
|
$url .= '&filter_product=' . urlencode(html_entity_decode($this->request->get['filter_product'], ENT_QUOTES, 'UTF-8')); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
if (isset($this->request->get['filter_author'])) { |
158
|
|
|
$url .= '&filter_author=' . urlencode(html_entity_decode($this->request->get['filter_author'], ENT_QUOTES, 'UTF-8')); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
if (isset($this->request->get['filter_status'])) { |
162
|
|
|
$url .= '&filter_status=' . $this->request->get['filter_status']; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
166
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
if (isset($this->request->get['sort'])) { |
170
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
if (isset($this->request->get['order'])) { |
174
|
|
|
$url .= '&order=' . $this->request->get['order']; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
if (isset($this->request->get['page'])) { |
178
|
|
|
$url .= '&page=' . $this->request->get['page']; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
$this->response->redirect($this->url->link('catalog/review', 'token=' . $this->session->data['token'] . $url, true)); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
$this->getList(); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
protected function getList() |
188
|
|
|
{ |
189
|
|
|
if (isset($this->request->get['filter_product'])) { |
190
|
|
|
$filter_product = $this->request->get['filter_product']; |
191
|
|
|
} else { |
192
|
|
|
$filter_product = null; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
if (isset($this->request->get['filter_author'])) { |
196
|
|
|
$filter_author = $this->request->get['filter_author']; |
197
|
|
|
} else { |
198
|
|
|
$filter_author = null; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
if (isset($this->request->get['filter_status'])) { |
202
|
|
|
$filter_status = $this->request->get['filter_status']; |
203
|
|
|
} else { |
204
|
|
|
$filter_status = null; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
208
|
|
|
$filter_date_added = $this->request->get['filter_date_added']; |
209
|
|
|
} else { |
210
|
|
|
$filter_date_added = null; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
if (isset($this->request->get['order'])) { |
214
|
|
|
$order = $this->request->get['order']; |
215
|
|
|
} else { |
216
|
|
|
$order = 'DESC'; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
if (isset($this->request->get['sort'])) { |
220
|
|
|
$sort = $this->request->get['sort']; |
221
|
|
|
} else { |
222
|
|
|
$sort = 'r.date_added'; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
if (isset($this->request->get['page'])) { |
226
|
|
|
$page = $this->request->get['page']; |
227
|
|
|
} else { |
228
|
|
|
$page = 1; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
$url = ''; |
232
|
|
|
|
233
|
|
|
if (isset($this->request->get['filter_product'])) { |
234
|
|
|
$url .= '&filter_product=' . urlencode(html_entity_decode($this->request->get['filter_product'], ENT_QUOTES, 'UTF-8')); |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
if (isset($this->request->get['filter_author'])) { |
238
|
|
|
$url .= '&filter_author=' . urlencode(html_entity_decode($this->request->get['filter_author'], ENT_QUOTES, 'UTF-8')); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
if (isset($this->request->get['filter_status'])) { |
242
|
|
|
$url .= '&filter_status=' . $this->request->get['filter_status']; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
246
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
if (isset($this->request->get['sort'])) { |
250
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
if (isset($this->request->get['order'])) { |
254
|
|
|
$url .= '&order=' . $this->request->get['order']; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
if (isset($this->request->get['page'])) { |
258
|
|
|
$url .= '&page=' . $this->request->get['page']; |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
$data['breadcrumbs'] = array(); |
|
|
|
|
262
|
|
|
|
263
|
|
|
$data['breadcrumbs'][] = array( |
264
|
|
|
'text' => $this->language->get('text_home'), |
265
|
|
|
'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
266
|
|
|
); |
267
|
|
|
|
268
|
|
|
$data['breadcrumbs'][] = array( |
269
|
|
|
'text' => $this->language->get('heading_title'), |
270
|
|
|
'href' => $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . $url, true) |
271
|
|
|
); |
272
|
|
|
|
273
|
|
|
$data['add'] = $this->url->link('catalog/review/add', 'token=' . $this->session->data['token'] . $url, true); |
274
|
|
|
$data['delete'] = $this->url->link('catalog/review/delete', 'token=' . $this->session->data['token'] . $url, true); |
275
|
|
|
$data['enabled'] = $this->url->link('catalog/review/enable', 'token=' . $this->session->data['token'] . $url, true); |
276
|
|
|
$data['disabled'] = $this->url->link('catalog/review/disable', 'token=' . $this->session->data['token'] . $url, true); |
277
|
|
|
|
278
|
|
|
|
279
|
|
|
$data['reviews'] = array(); |
280
|
|
|
|
281
|
|
|
$filter_data = array( |
282
|
|
|
'filter_product' => $filter_product, |
283
|
|
|
'filter_author' => $filter_author, |
284
|
|
|
'filter_status' => $filter_status, |
285
|
|
|
'filter_date_added' => $filter_date_added, |
286
|
|
|
'sort' => $sort, |
287
|
|
|
'order' => $order, |
288
|
|
|
'start' => ($page - 1) * $this->config->get('config_limit_admin'), |
289
|
|
|
'limit' => $this->config->get('config_limit_admin') |
290
|
|
|
); |
291
|
|
|
|
292
|
|
|
$review_total = $this->model_catalog_review->getTotalReviews($filter_data); |
293
|
|
|
|
294
|
|
|
$results = $this->model_catalog_review->getReviews($filter_data); |
295
|
|
|
|
296
|
|
|
foreach ($results as $result) { |
297
|
|
|
$data['reviews'][] = array( |
298
|
|
|
'review_id' => $result['review_id'], |
299
|
|
|
'name' => $result['name'], |
300
|
|
|
'author' => $result['author'], |
301
|
|
|
'rating' => $result['rating'], |
302
|
|
|
'status' => ($result['status']) ? $this->language->get('text_enabled') : $this->language->get('text_disabled'), |
303
|
|
|
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])), |
304
|
|
|
'edit' => $this->url->link('catalog/review/edit', 'token=' . $this->session->data['token'] . '&review_id=' . $result['review_id'] . $url, true) |
305
|
|
|
); |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
$data['heading_title'] = $this->language->get('heading_title'); |
309
|
|
|
|
310
|
|
|
$data['text_list'] = $this->language->get('text_list'); |
311
|
|
|
$data['text_no_results'] = $this->language->get('text_no_results'); |
312
|
|
|
$data['text_confirm'] = $this->language->get('text_confirm'); |
313
|
|
|
$data['text_enabled'] = $this->language->get('text_enabled'); |
314
|
|
|
$data['text_disabled'] = $this->language->get('text_disabled'); |
315
|
|
|
|
316
|
|
|
$data['column_product'] = $this->language->get('column_product'); |
317
|
|
|
$data['column_author'] = $this->language->get('column_author'); |
318
|
|
|
$data['column_rating'] = $this->language->get('column_rating'); |
319
|
|
|
$data['column_status'] = $this->language->get('column_status'); |
320
|
|
|
$data['column_date_added'] = $this->language->get('column_date_added'); |
321
|
|
|
$data['column_action'] = $this->language->get('column_action'); |
322
|
|
|
|
323
|
|
|
$data['entry_product'] = $this->language->get('entry_product'); |
324
|
|
|
$data['entry_author'] = $this->language->get('entry_author'); |
325
|
|
|
$data['entry_rating'] = $this->language->get('entry_rating'); |
326
|
|
|
$data['entry_status'] = $this->language->get('entry_status'); |
327
|
|
|
$data['entry_date_added'] = $this->language->get('entry_date_added'); |
328
|
|
|
|
329
|
|
|
$data['button_add'] = $this->language->get('button_add'); |
330
|
|
|
$data['button_edit'] = $this->language->get('button_edit'); |
331
|
|
|
$data['button_delete'] = $this->language->get('button_delete'); |
332
|
|
|
$data['button_filter'] = $this->language->get('button_filter'); |
333
|
|
|
$data['button_enable'] = $this->language->get('button_enable'); |
334
|
|
|
$data['button_disable'] = $this->language->get('button_disable'); |
335
|
|
|
|
336
|
|
|
$data['token'] = $this->session->data['token']; |
337
|
|
|
|
338
|
|
|
if (isset($this->error['warning'])) { |
339
|
|
|
$data['error_warning'] = $this->error['warning']; |
340
|
|
|
} else { |
341
|
|
|
$data['error_warning'] = ''; |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
if (isset($this->session->data['success'])) { |
345
|
|
|
$data['success'] = $this->session->data['success']; |
346
|
|
|
|
347
|
|
|
unset($this->session->data['success']); |
348
|
|
|
} else { |
349
|
|
|
$data['success'] = ''; |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
if (isset($this->request->post['selected'])) { |
353
|
|
|
$data['selected'] = (array)$this->request->post['selected']; |
354
|
|
|
} else { |
355
|
|
|
$data['selected'] = array(); |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
$url = ''; |
359
|
|
|
|
360
|
|
|
if (isset($this->request->get['filter_product'])) { |
361
|
|
|
$url .= '&filter_product=' . urlencode(html_entity_decode($this->request->get['filter_product'], ENT_QUOTES, 'UTF-8')); |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
if (isset($this->request->get['filter_author'])) { |
365
|
|
|
$url .= '&filter_author=' . urlencode(html_entity_decode($this->request->get['filter_author'], ENT_QUOTES, 'UTF-8')); |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
if (isset($this->request->get['filter_status'])) { |
369
|
|
|
$url .= '&filter_status=' . $this->request->get['filter_status']; |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
373
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
if ($order == 'ASC') { |
377
|
|
|
$url .= '&order=DESC'; |
378
|
|
|
} else { |
379
|
|
|
$url .= '&order=ASC'; |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
if (isset($this->request->get['page'])) { |
383
|
|
|
$url .= '&page=' . $this->request->get['page']; |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
$data['sort_product'] = $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . '&sort=pd.name' . $url, true); |
387
|
|
|
$data['sort_author'] = $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . '&sort=r.author' . $url, true); |
388
|
|
|
$data['sort_rating'] = $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . '&sort=r.rating' . $url, true); |
389
|
|
|
$data['sort_status'] = $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . '&sort=r.status' . $url, true); |
390
|
|
|
$data['sort_date_added'] = $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . '&sort=r.date_added' . $url, true); |
391
|
|
|
|
392
|
|
|
$url = ''; |
393
|
|
|
|
394
|
|
|
if (isset($this->request->get['filter_product'])) { |
395
|
|
|
$url .= '&filter_product=' . urlencode(html_entity_decode($this->request->get['filter_product'], ENT_QUOTES, 'UTF-8')); |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
if (isset($this->request->get['filter_author'])) { |
399
|
|
|
$url .= '&filter_author=' . urlencode(html_entity_decode($this->request->get['filter_author'], ENT_QUOTES, 'UTF-8')); |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
if (isset($this->request->get['filter_status'])) { |
403
|
|
|
$url .= '&filter_status=' . $this->request->get['filter_status']; |
404
|
|
|
} |
405
|
|
|
|
406
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
407
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
if (isset($this->request->get['sort'])) { |
411
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
if (isset($this->request->get['order'])) { |
415
|
|
|
$url .= '&order=' . $this->request->get['order']; |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
$pagination = new \Divine\Engine\Library\Pagination(); |
419
|
|
|
$pagination->total = $review_total; |
420
|
|
|
$pagination->page = $page; |
421
|
|
|
$pagination->limit = $this->config->get('config_limit_admin'); |
422
|
|
|
$pagination->url = $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . $url . '&page={page}', true); |
423
|
|
|
|
424
|
|
|
$data['pagination'] = $pagination->render(); |
425
|
|
|
|
426
|
|
|
$data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($review_total - $this->config->get('config_limit_admin'))) ? $review_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $review_total, ceil($review_total / $this->config->get('config_limit_admin'))); |
427
|
|
|
|
428
|
|
|
$data['filter_product'] = $filter_product; |
429
|
|
|
$data['filter_author'] = $filter_author; |
430
|
|
|
$data['filter_status'] = $filter_status; |
431
|
|
|
$data['filter_date_added'] = $filter_date_added; |
432
|
|
|
|
433
|
|
|
$data['sort'] = $sort; |
434
|
|
|
$data['order'] = $order; |
435
|
|
|
|
436
|
|
|
$data['header'] = $this->load->controller('common/header'); |
437
|
|
|
$data['column'] = $this->load->controller('common/column_left'); |
438
|
|
|
$data['footer'] = $this->load->controller('common/footer'); |
439
|
|
|
|
440
|
|
|
$this->response->setOutput($this->load->view('catalog/review_list', $data)); |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
protected function getForm() |
444
|
|
|
{ |
445
|
|
|
$data['heading_title'] = $this->language->get('heading_title'); |
|
|
|
|
446
|
|
|
|
447
|
|
|
$data['text_form'] = !isset($this->request->get['review_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); |
448
|
|
|
$data['text_enabled'] = $this->language->get('text_enabled'); |
449
|
|
|
$data['text_disabled'] = $this->language->get('text_disabled'); |
450
|
|
|
|
451
|
|
|
$data['entry_product'] = $this->language->get('entry_product'); |
452
|
|
|
$data['entry_author'] = $this->language->get('entry_author'); |
453
|
|
|
$data['entry_rating'] = $this->language->get('entry_rating'); |
454
|
|
|
$data['entry_date_added'] = $this->language->get('entry_date_added'); |
455
|
|
|
$data['entry_status'] = $this->language->get('entry_status'); |
456
|
|
|
$data['entry_text'] = $this->language->get('entry_text'); |
457
|
|
|
|
458
|
|
|
$data['help_product'] = $this->language->get('help_product'); |
459
|
|
|
|
460
|
|
|
$data['button_save'] = $this->language->get('button_save'); |
461
|
|
|
$data['button_cancel'] = $this->language->get('button_cancel'); |
462
|
|
|
|
463
|
|
|
if (isset($this->error['warning'])) { |
464
|
|
|
$data['error_warning'] = $this->error['warning']; |
465
|
|
|
} else { |
466
|
|
|
$data['error_warning'] = ''; |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
if (isset($this->error['product'])) { |
470
|
|
|
$data['error_product'] = $this->error['product']; |
471
|
|
|
} else { |
472
|
|
|
$data['error_product'] = ''; |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
if (isset($this->error['author'])) { |
476
|
|
|
$data['error_author'] = $this->error['author']; |
477
|
|
|
} else { |
478
|
|
|
$data['error_author'] = ''; |
479
|
|
|
} |
480
|
|
|
|
481
|
|
|
if (isset($this->error['text'])) { |
482
|
|
|
$data['error_text'] = $this->error['text']; |
483
|
|
|
} else { |
484
|
|
|
$data['error_text'] = ''; |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
if (isset($this->error['rating'])) { |
488
|
|
|
$data['error_rating'] = $this->error['rating']; |
489
|
|
|
} else { |
490
|
|
|
$data['error_rating'] = ''; |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
$url = ''; |
494
|
|
|
|
495
|
|
|
if (isset($this->request->get['filter_product'])) { |
496
|
|
|
$url .= '&filter_product=' . urlencode(html_entity_decode($this->request->get['filter_product'], ENT_QUOTES, 'UTF-8')); |
497
|
|
|
} |
498
|
|
|
|
499
|
|
|
if (isset($this->request->get['filter_author'])) { |
500
|
|
|
$url .= '&filter_author=' . urlencode(html_entity_decode($this->request->get['filter_author'], ENT_QUOTES, 'UTF-8')); |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
if (isset($this->request->get['filter_status'])) { |
504
|
|
|
$url .= '&filter_status=' . $this->request->get['filter_status']; |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
if (isset($this->request->get['filter_date_added'])) { |
508
|
|
|
$url .= '&filter_date_added=' . $this->request->get['filter_date_added']; |
509
|
|
|
} |
510
|
|
|
|
511
|
|
|
if (isset($this->request->get['sort'])) { |
512
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
if (isset($this->request->get['order'])) { |
516
|
|
|
$url .= '&order=' . $this->request->get['order']; |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
if (isset($this->request->get['page'])) { |
520
|
|
|
$url .= '&page=' . $this->request->get['page']; |
521
|
|
|
} |
522
|
|
|
|
523
|
|
|
$data['breadcrumbs'] = array(); |
524
|
|
|
|
525
|
|
|
$data['breadcrumbs'][] = array( |
526
|
|
|
'text' => $this->language->get('text_home'), |
527
|
|
|
'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
528
|
|
|
); |
529
|
|
|
|
530
|
|
|
$data['breadcrumbs'][] = array( |
531
|
|
|
'text' => $this->language->get('heading_title'), |
532
|
|
|
'href' => $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . $url, true) |
533
|
|
|
); |
534
|
|
|
|
535
|
|
|
if (!isset($this->request->get['review_id'])) { |
536
|
|
|
$data['action'] = $this->url->link('catalog/review/add', 'token=' . $this->session->data['token'] . $url, true); |
537
|
|
|
} else { |
538
|
|
|
$data['action'] = $this->url->link('catalog/review/edit', 'token=' . $this->session->data['token'] . '&review_id=' . $this->request->get['review_id'] . $url, true); |
539
|
|
|
} |
540
|
|
|
|
541
|
|
|
$data['cancel'] = $this->url->link('catalog/review', 'token=' . $this->session->data['token'] . $url, true); |
542
|
|
|
|
543
|
|
|
if (isset($this->request->get['review_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) { |
544
|
|
|
$review_info = $this->model_catalog_review->getReview($this->request->get['review_id']); |
545
|
|
|
} |
546
|
|
|
|
547
|
|
|
$data['token'] = $this->session->data['token']; |
548
|
|
|
|
549
|
|
|
$this->load->model('catalog/product'); |
550
|
|
|
|
551
|
|
|
if (isset($this->request->post['product_id'])) { |
552
|
|
|
$data['product_id'] = $this->request->post['product_id']; |
553
|
|
|
} elseif (!empty($review_info)) { |
554
|
|
|
$data['product_id'] = $review_info['product_id']; |
555
|
|
|
} else { |
556
|
|
|
$data['product_id'] = ''; |
557
|
|
|
} |
558
|
|
|
|
559
|
|
|
if (isset($this->request->post['product'])) { |
560
|
|
|
$data['product'] = $this->request->post['product']; |
561
|
|
|
} elseif (!empty($review_info)) { |
562
|
|
|
$data['product'] = $review_info['product']; |
563
|
|
|
} else { |
564
|
|
|
$data['product'] = ''; |
565
|
|
|
} |
566
|
|
|
|
567
|
|
|
if (isset($this->request->post['author'])) { |
568
|
|
|
$data['author'] = $this->request->post['author']; |
569
|
|
|
} elseif (!empty($review_info)) { |
570
|
|
|
$data['author'] = $review_info['author']; |
571
|
|
|
} else { |
572
|
|
|
$data['author'] = ''; |
573
|
|
|
} |
574
|
|
|
|
575
|
|
|
if (isset($this->request->post['text'])) { |
576
|
|
|
$data['text'] = $this->request->post['text']; |
577
|
|
|
} elseif (!empty($review_info)) { |
578
|
|
|
$data['text'] = $review_info['text']; |
579
|
|
|
} else { |
580
|
|
|
$data['text'] = ''; |
581
|
|
|
} |
582
|
|
|
|
583
|
|
|
if (isset($this->request->post['rating'])) { |
584
|
|
|
$data['rating'] = $this->request->post['rating']; |
585
|
|
|
} elseif (!empty($review_info)) { |
586
|
|
|
$data['rating'] = $review_info['rating']; |
587
|
|
|
} else { |
588
|
|
|
$data['rating'] = ''; |
589
|
|
|
} |
590
|
|
|
|
591
|
|
|
if (isset($this->request->post['date_added'])) { |
592
|
|
|
$data['date_added'] = $this->request->post['date_added']; |
593
|
|
|
} elseif (!empty($review_info)) { |
594
|
|
|
$data['date_added'] = ($review_info['date_added'] != '2000-01-01 01:01' ? $review_info['date_added'] : ''); |
595
|
|
|
} else { |
596
|
|
|
$data['date_added'] = ''; |
597
|
|
|
} |
598
|
|
|
|
599
|
|
|
if (isset($this->request->post['status'])) { |
600
|
|
|
$data['status'] = $this->request->post['status']; |
601
|
|
|
} elseif (!empty($review_info)) { |
602
|
|
|
$data['status'] = $review_info['status']; |
603
|
|
|
} else { |
604
|
|
|
$data['status'] = ''; |
605
|
|
|
} |
606
|
|
|
|
607
|
|
|
$data['header'] = $this->load->controller('common/header'); |
608
|
|
|
$data['column'] = $this->load->controller('common/column_left'); |
609
|
|
|
$data['footer'] = $this->load->controller('common/footer'); |
610
|
|
|
|
611
|
|
|
$this->response->setOutput($this->load->view('catalog/review_form', $data)); |
612
|
|
|
} |
613
|
|
|
|
614
|
|
|
protected function validateForm() |
615
|
|
|
{ |
616
|
|
|
if (!$this->user->hasPermission('modify', 'catalog/review')) { |
617
|
|
|
$this->error['warning'] = $this->language->get('error_permission'); |
618
|
|
|
} |
619
|
|
|
|
620
|
|
|
if (!$this->request->post['product_id']) { |
621
|
|
|
$this->error['product'] = $this->language->get('error_product'); |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
if ((\voku\helper\UTF8::strlen($this->request->post['author']) < 3) || (\voku\helper\UTF8::strlen($this->request->post['author']) > 64)) { |
625
|
|
|
$this->error['author'] = $this->language->get('error_author'); |
626
|
|
|
} |
627
|
|
|
|
628
|
|
|
if (\voku\helper\UTF8::strlen($this->request->post['text']) < 1) { |
629
|
|
|
$this->error['text'] = $this->language->get('error_text'); |
630
|
|
|
} |
631
|
|
|
|
632
|
|
|
if (!isset($this->request->post['rating']) || $this->request->post['rating'] < 0 || $this->request->post['rating'] > 5) { |
633
|
|
|
$this->error['rating'] = $this->language->get('error_rating'); |
634
|
|
|
} |
635
|
|
|
|
636
|
|
|
return !$this->error; |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
public function enable() |
640
|
|
|
{ |
641
|
|
|
$this->load->language('catalog/review'); |
642
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
643
|
|
|
$this->load->model('catalog/review'); |
644
|
|
|
if (isset($this->request->post['selected'])) { |
645
|
|
|
foreach ($this->request->post['selected'] as $review_id) { |
646
|
|
|
$data = array(); |
647
|
|
|
$result = $this->model_catalog_review->getReview($review_id); |
648
|
|
|
foreach ($result as $key => $value) { |
649
|
|
|
$data[$key] = $value; |
650
|
|
|
} |
651
|
|
|
$data['status'] = 1; |
652
|
|
|
$this->model_catalog_review->editReview($review_id, $data); |
653
|
|
|
} |
654
|
|
|
$this->session->data['success'] = $this->language->get('text_success'); |
655
|
|
|
$url = ''; |
656
|
|
|
if (isset($this->request->get['page'])) { |
657
|
|
|
$url .= '&page=' . $this->request->get['page']; |
658
|
|
|
} |
659
|
|
|
if (isset($this->request->get['sort'])) { |
660
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
661
|
|
|
} |
662
|
|
|
if (isset($this->request->get['order'])) { |
663
|
|
|
$url .= '&order=' . $this->request->get['order']; |
664
|
|
|
} |
665
|
|
|
$this->response->redirect($this->url->link('catalog/review', 'token=' . $this->session->data['token'] . $url, true)); |
666
|
|
|
} |
667
|
|
|
$this->getList(); |
668
|
|
|
} |
669
|
|
|
public function disable() |
670
|
|
|
{ |
671
|
|
|
$this->load->language('catalog/review'); |
672
|
|
|
$this->document->setTitle($this->language->get('heading_title')); |
673
|
|
|
$this->load->model('catalog/review'); |
674
|
|
|
if (isset($this->request->post['selected'])) { |
675
|
|
|
foreach ($this->request->post['selected'] as $review_id) { |
676
|
|
|
$data = array(); |
677
|
|
|
$result = $this->model_catalog_review->getReview($review_id); |
678
|
|
|
foreach ($result as $key => $value) { |
679
|
|
|
$data[$key] = $value; |
680
|
|
|
} |
681
|
|
|
$data['status'] = 0; |
682
|
|
|
$this->model_catalog_review->editReview($review_id, $data); |
683
|
|
|
} |
684
|
|
|
$this->session->data['success'] = $this->language->get('text_success'); |
685
|
|
|
$url = ''; |
686
|
|
|
if (isset($this->request->get['page'])) { |
687
|
|
|
$url .= '&page=' . $this->request->get['page']; |
688
|
|
|
} |
689
|
|
|
if (isset($this->request->get['sort'])) { |
690
|
|
|
$url .= '&sort=' . $this->request->get['sort']; |
691
|
|
|
} |
692
|
|
|
if (isset($this->request->get['order'])) { |
693
|
|
|
$url .= '&order=' . $this->request->get['order']; |
694
|
|
|
} |
695
|
|
|
$this->response->redirect($this->url->link('catalog/review', 'token=' . $this->session->data['token'] . $url, true)); |
696
|
|
|
} |
697
|
|
|
$this->getList(); |
698
|
|
|
} |
699
|
|
|
|
700
|
|
|
protected function validateDelete() |
701
|
|
|
{ |
702
|
|
|
if (!$this->user->hasPermission('modify', 'catalog/review')) { |
703
|
|
|
$this->error['warning'] = $this->language->get('error_permission'); |
704
|
|
|
} |
705
|
|
|
|
706
|
|
|
return !$this->error; |
707
|
|
|
} |
708
|
|
|
} |
709
|
|
|
|
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.