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