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 ControllerBlogArticle extends \Divine\Engine\Core\Controller |
||||||
0 ignored issues
–
show
|
|||||||
24 | { |
||||||
25 | private $error = array(); |
||||||
26 | |||||||
27 | public function index() |
||||||
0 ignored issues
–
show
|
|||||||
28 | { |
||||||
29 | $this->load->language('blog/article'); |
||||||
30 | |||||||
31 | $this->document->setTitle($this->language->get('heading_title')); |
||||||
32 | |||||||
33 | $this->load->model('blog/article'); |
||||||
34 | |||||||
35 | $this->getList(); |
||||||
0 ignored issues
–
show
The method
getList() does not exist on ControllerBlogArticle .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
36 | } |
||||||
37 | |||||||
38 | public function add() |
||||||
39 | { |
||||||
40 | $this->load->language('blog/article'); |
||||||
41 | |||||||
42 | $this->document->setTitle($this->language->get('heading_title')); |
||||||
43 | |||||||
44 | $this->load->model('blog/article'); |
||||||
45 | |||||||
46 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { |
||||||
0 ignored issues
–
show
The method
validateForm() does not exist on ControllerBlogArticle .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
47 | $this->model_blog_article->addArticle($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_name'])) { |
||||||
54 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||||||
55 | } |
||||||
56 | |||||||
57 | if (isset($this->request->get['filter_status'])) { |
||||||
58 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||||||
59 | } |
||||||
60 | |||||||
61 | if (isset($this->request->get['filter_noindex'])) { |
||||||
62 | $url .= '&filter_noindex=' . $this->request->get['filter_noindex']; |
||||||
63 | } |
||||||
64 | |||||||
65 | if (isset($this->request->get['sort'])) { |
||||||
66 | $url .= '&sort=' . $this->request->get['sort']; |
||||||
67 | } |
||||||
68 | |||||||
69 | if (isset($this->request->get['order'])) { |
||||||
70 | $url .= '&order=' . $this->request->get['order']; |
||||||
71 | } |
||||||
72 | |||||||
73 | if (isset($this->request->get['page'])) { |
||||||
74 | $url .= '&page=' . $this->request->get['page']; |
||||||
75 | } |
||||||
76 | |||||||
77 | $this->response->redirect($this->url->link('blog/article', 'token=' . $this->session->data['token'] . $url, true)); |
||||||
78 | } |
||||||
79 | |||||||
80 | $this->getForm(); |
||||||
0 ignored issues
–
show
The method
getForm() does not exist on ControllerBlogArticle .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
81 | } |
||||||
82 | |||||||
83 | public function edit() |
||||||
84 | { |
||||||
85 | $this->load->language('blog/article'); |
||||||
86 | |||||||
87 | $this->document->setTitle($this->language->get('heading_title')); |
||||||
88 | |||||||
89 | $this->load->model('blog/article'); |
||||||
90 | |||||||
91 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { |
||||||
92 | $this->model_blog_article->editArticle($this->request->get['article_id'], $this->request->post); |
||||||
93 | |||||||
94 | $this->session->data['success'] = $this->language->get('text_success'); |
||||||
95 | |||||||
96 | $url = ''; |
||||||
97 | |||||||
98 | if (isset($this->request->get['filter_name'])) { |
||||||
99 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||||||
100 | } |
||||||
101 | |||||||
102 | if (isset($this->request->get['filter_status'])) { |
||||||
103 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||||||
104 | } |
||||||
105 | |||||||
106 | if (isset($this->request->get['filter_noindex'])) { |
||||||
107 | $url .= '&filter_noindex=' . $this->request->get['filter_noindex']; |
||||||
108 | } |
||||||
109 | |||||||
110 | if (isset($this->request->get['sort'])) { |
||||||
111 | $url .= '&sort=' . $this->request->get['sort']; |
||||||
112 | } |
||||||
113 | |||||||
114 | if (isset($this->request->get['order'])) { |
||||||
115 | $url .= '&order=' . $this->request->get['order']; |
||||||
116 | } |
||||||
117 | |||||||
118 | if (isset($this->request->get['page'])) { |
||||||
119 | $url .= '&page=' . $this->request->get['page']; |
||||||
120 | } |
||||||
121 | |||||||
122 | $this->response->redirect($this->url->link('blog/article', 'token=' . $this->session->data['token'] . $url, true)); |
||||||
123 | } |
||||||
124 | |||||||
125 | $this->getForm(); |
||||||
126 | } |
||||||
127 | |||||||
128 | public function delete() |
||||||
129 | { |
||||||
130 | $this->load->language('blog/article'); |
||||||
131 | |||||||
132 | $this->document->setTitle($this->language->get('heading_title')); |
||||||
133 | |||||||
134 | $this->load->model('blog/article'); |
||||||
135 | |||||||
136 | if (isset($this->request->post['selected']) && $this->validateDelete()) { |
||||||
0 ignored issues
–
show
The method
validateDelete() does not exist on ControllerBlogArticle .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
137 | foreach ($this->request->post['selected'] as $article_id) { |
||||||
138 | $this->model_blog_article->deleteArticle($article_id); |
||||||
139 | } |
||||||
140 | |||||||
141 | $this->session->data['success'] = $this->language->get('text_success'); |
||||||
142 | |||||||
143 | $url = ''; |
||||||
144 | |||||||
145 | if (isset($this->request->get['filter_name'])) { |
||||||
146 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||||||
147 | } |
||||||
148 | |||||||
149 | if (isset($this->request->get['filter_status'])) { |
||||||
150 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||||||
151 | } |
||||||
152 | |||||||
153 | if (isset($this->request->get['filter_noindex'])) { |
||||||
154 | $url .= '&filter_noindex=' . $this->request->get['filter_noindex']; |
||||||
155 | } |
||||||
156 | |||||||
157 | if (isset($this->request->get['sort'])) { |
||||||
158 | $url .= '&sort=' . $this->request->get['sort']; |
||||||
159 | } |
||||||
160 | |||||||
161 | if (isset($this->request->get['order'])) { |
||||||
162 | $url .= '&order=' . $this->request->get['order']; |
||||||
163 | } |
||||||
164 | |||||||
165 | if (isset($this->request->get['page'])) { |
||||||
166 | $url .= '&page=' . $this->request->get['page']; |
||||||
167 | } |
||||||
168 | |||||||
169 | $this->response->redirect($this->url->link('blog/article', 'token=' . $this->session->data['token'] . $url, true)); |
||||||
170 | } |
||||||
171 | |||||||
172 | $this->getList(); |
||||||
173 | } |
||||||
174 | |||||||
175 | public function copy() |
||||||
176 | { |
||||||
177 | $this->load->language('blog/article'); |
||||||
178 | |||||||
179 | $this->document->setTitle($this->language->get('heading_title')); |
||||||
180 | |||||||
181 | $this->load->model('blog/article'); |
||||||
182 | |||||||
183 | if (isset($this->request->post['selected']) && $this->validateCopy()) { |
||||||
0 ignored issues
–
show
The method
validateCopy() does not exist on ControllerBlogArticle .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
184 | foreach ($this->request->post['selected'] as $article_id) { |
||||||
185 | $this->model_blog_article->copyArticle($article_id); |
||||||
186 | } |
||||||
187 | |||||||
188 | $this->session->data['success'] = $this->language->get('text_success'); |
||||||
189 | |||||||
190 | $url = ''; |
||||||
191 | |||||||
192 | if (isset($this->request->get['filter_name'])) { |
||||||
193 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||||||
194 | } |
||||||
195 | |||||||
196 | if (isset($this->request->get['filter_status'])) { |
||||||
197 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||||||
198 | } |
||||||
199 | |||||||
200 | if (isset($this->request->get['filter_noindex'])) { |
||||||
201 | $url .= '&filter_noindex=' . $this->request->get['filter_noindex']; |
||||||
202 | } |
||||||
203 | |||||||
204 | if (isset($this->request->get['sort'])) { |
||||||
205 | $url .= '&sort=' . $this->request->get['sort']; |
||||||
206 | } |
||||||
207 | |||||||
208 | if (isset($this->request->get['order'])) { |
||||||
209 | $url .= '&order=' . $this->request->get['order']; |
||||||
210 | } |
||||||
211 | |||||||
212 | if (isset($this->request->get['page'])) { |
||||||
213 | $url .= '&page=' . $this->request->get['page']; |
||||||
214 | } |
||||||
215 | |||||||
216 | $this->response->redirect($this->url->link('blog/article', 'token=' . $this->session->data['token'] . $url, true)); |
||||||
217 | } |
||||||
218 | |||||||
219 | $this->getList(); |
||||||
220 | } |
||||||
221 | |||||||
222 | protected function getList() |
||||||
223 | { |
||||||
224 | if (isset($this->request->get['filter_name'])) { |
||||||
225 | $filter_name = $this->request->get['filter_name']; |
||||||
226 | } else { |
||||||
227 | $filter_name = null; |
||||||
228 | } |
||||||
229 | |||||||
230 | if (isset($this->request->get['filter_status'])) { |
||||||
231 | $filter_status = $this->request->get['filter_status']; |
||||||
232 | } else { |
||||||
233 | $filter_status = null; |
||||||
234 | } |
||||||
235 | |||||||
236 | if (isset($this->request->get['filter_noindex'])) { |
||||||
237 | $filter_noindex = $this->request->get['filter_noindex']; |
||||||
238 | } else { |
||||||
239 | $filter_noindex = null; |
||||||
240 | } |
||||||
241 | |||||||
242 | if (isset($this->request->get['sort'])) { |
||||||
243 | $sort = $this->request->get['sort']; |
||||||
244 | } else { |
||||||
245 | $sort = 'pd.name'; |
||||||
246 | } |
||||||
247 | |||||||
248 | if (isset($this->request->get['order'])) { |
||||||
249 | $order = $this->request->get['order']; |
||||||
250 | } else { |
||||||
251 | $order = 'ASC'; |
||||||
252 | } |
||||||
253 | |||||||
254 | if (isset($this->request->get['page'])) { |
||||||
255 | $page = $this->request->get['page']; |
||||||
256 | } else { |
||||||
257 | $page = 1; |
||||||
258 | } |
||||||
259 | |||||||
260 | $url = ''; |
||||||
261 | |||||||
262 | if (isset($this->request->get['filter_name'])) { |
||||||
263 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||||||
264 | } |
||||||
265 | |||||||
266 | if (isset($this->request->get['filter_status'])) { |
||||||
267 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||||||
268 | } |
||||||
269 | |||||||
270 | if (isset($this->request->get['filter_noindex'])) { |
||||||
271 | $url .= '&filter_noindex=' . $this->request->get['filter_noindex']; |
||||||
272 | } |
||||||
273 | |||||||
274 | if (isset($this->request->get['sort'])) { |
||||||
275 | $url .= '&sort=' . $this->request->get['sort']; |
||||||
276 | } |
||||||
277 | |||||||
278 | if (isset($this->request->get['order'])) { |
||||||
279 | $url .= '&order=' . $this->request->get['order']; |
||||||
280 | } |
||||||
281 | |||||||
282 | if (isset($this->request->get['page'])) { |
||||||
283 | $url .= '&page=' . $this->request->get['page']; |
||||||
284 | } |
||||||
285 | |||||||
286 | $data['breadcrumbs'] = array(); |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
287 | |||||||
288 | $data['breadcrumbs'][] = array( |
||||||
289 | 'text' => $this->language->get('text_home'), |
||||||
290 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||||||
291 | ); |
||||||
292 | |||||||
293 | $data['breadcrumbs'][] = array( |
||||||
294 | 'text' => $this->language->get('heading_title'), |
||||||
295 | 'href' => $this->url->link('blog/article', 'token=' . $this->session->data['token'] . $url, true) |
||||||
296 | ); |
||||||
297 | |||||||
298 | $data['add'] = $this->url->link('blog/article/add', 'token=' . $this->session->data['token'] . $url, true); |
||||||
299 | $data['copy'] = $this->url->link('blog/article/copy', 'token=' . $this->session->data['token'] . $url, true); |
||||||
300 | $data['delete'] = $this->url->link('blog/article/delete', 'token=' . $this->session->data['token'] . $url, true); |
||||||
301 | |||||||
302 | $data['enabled'] = $this->url->link('blog/article/enable', 'token=' . $this->session->data['token'] . $url, true); |
||||||
303 | $data['disabled'] = $this->url->link('blog/article/disable', 'token=' . $this->session->data['token'] . $url, true); |
||||||
304 | |||||||
305 | $data['articles'] = array(); |
||||||
306 | |||||||
307 | $filter_data = array( |
||||||
308 | 'filter_name' => $filter_name, |
||||||
309 | 'filter_status' => $filter_status, |
||||||
310 | 'filter_noindex' => $filter_noindex, |
||||||
311 | 'sort' => $sort, |
||||||
312 | 'order' => $order, |
||||||
313 | 'start' => ($page - 1) * $this->config->get('config_limit_admin'), |
||||||
314 | 'limit' => $this->config->get('config_limit_admin') |
||||||
315 | ); |
||||||
316 | |||||||
317 | |||||||
318 | |||||||
319 | $article_total = $this->model_blog_article->getTotalArticles($filter_data); |
||||||
320 | |||||||
321 | $results = $this->model_blog_article->getArticles($filter_data); |
||||||
322 | |||||||
323 | foreach ($results as $result) { |
||||||
324 | if (is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $result['image'])) { |
||||||
325 | $image = '/public_html/assets/images/' . $result['image']; |
||||||
326 | } else { |
||||||
327 | $image = '/public_html/assets/images/no_image.png'; |
||||||
328 | } |
||||||
329 | |||||||
330 | $data['articles'][] = array( |
||||||
331 | 'article_id' => $result['article_id'], |
||||||
332 | 'image' => $image, |
||||||
333 | 'name' => $result['name'], |
||||||
334 | 'status' => ($result['status']) ? $this->language->get('text_enabled') : $this->language->get('text_disabled'), |
||||||
335 | 'noindex' => ($result['noindex']) ? $this->language->get('text_enabled') : $this->language->get('text_disabled'), |
||||||
336 | 'href_shop' => '/index.php?route=blog/article&article_id=' . ($result['article_id']), |
||||||
337 | 'edit' => $this->url->link('blog/article/edit', 'token=' . $this->session->data['token'] . '&article_id=' . $result['article_id'] . $url, true) |
||||||
338 | ); |
||||||
339 | } |
||||||
340 | |||||||
341 | $data['heading_title'] = $this->language->get('heading_title'); |
||||||
342 | |||||||
343 | $data['text_list'] = $this->language->get('text_list'); |
||||||
344 | $data['text_enabled'] = $this->language->get('text_enabled'); |
||||||
345 | $data['text_disabled'] = $this->language->get('text_disabled'); |
||||||
346 | $data['text_no_results'] = $this->language->get('text_no_results'); |
||||||
347 | $data['text_confirm'] = $this->language->get('text_confirm'); |
||||||
348 | |||||||
349 | $data['column_image'] = $this->language->get('column_image'); |
||||||
350 | $data['column_name'] = $this->language->get('column_name'); |
||||||
351 | $data['column_status'] = $this->language->get('column_status'); |
||||||
352 | $data['column_noindex'] = $this->language->get('column_noindex'); |
||||||
353 | $data['column_action'] = $this->language->get('column_action'); |
||||||
354 | |||||||
355 | $data['entry_name'] = $this->language->get('entry_name'); |
||||||
356 | $data['entry_status'] = $this->language->get('entry_status'); |
||||||
357 | $data['entry_noindex'] = $this->language->get('entry_noindex'); |
||||||
358 | |||||||
359 | $data['button_copy'] = $this->language->get('button_copy'); |
||||||
360 | $data['button_add'] = $this->language->get('button_add'); |
||||||
361 | $data['button_edit'] = $this->language->get('button_edit'); |
||||||
362 | $data['button_shop'] = $this->language->get('button_shop'); |
||||||
363 | $data['button_delete'] = $this->language->get('button_delete'); |
||||||
364 | $data['button_filter'] = $this->language->get('button_filter'); |
||||||
365 | |||||||
366 | $data['button_enable'] = $this->language->get('button_enable'); |
||||||
367 | $data['button_disable'] = $this->language->get('button_disable'); |
||||||
368 | |||||||
369 | $data['token'] = $this->session->data['token']; |
||||||
370 | |||||||
371 | if (isset($this->error['warning'])) { |
||||||
372 | $data['error_warning'] = $this->error['warning']; |
||||||
373 | } else { |
||||||
374 | $data['error_warning'] = ''; |
||||||
375 | } |
||||||
376 | |||||||
377 | if (isset($this->session->data['success'])) { |
||||||
378 | $data['success'] = $this->session->data['success']; |
||||||
379 | |||||||
380 | unset($this->session->data['success']); |
||||||
381 | } else { |
||||||
382 | $data['success'] = ''; |
||||||
383 | } |
||||||
384 | |||||||
385 | if (isset($this->request->post['selected'])) { |
||||||
386 | $data['selected'] = (array)$this->request->post['selected']; |
||||||
387 | } else { |
||||||
388 | $data['selected'] = array(); |
||||||
389 | } |
||||||
390 | |||||||
391 | $url = ''; |
||||||
392 | |||||||
393 | if (isset($this->request->get['filter_name'])) { |
||||||
394 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||||||
395 | } |
||||||
396 | |||||||
397 | if (isset($this->request->get['filter_status'])) { |
||||||
398 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||||||
399 | } |
||||||
400 | |||||||
401 | if (isset($this->request->get['filter_noindex'])) { |
||||||
402 | $url .= '&filter_noindex=' . $this->request->get['filter_noindex']; |
||||||
403 | } |
||||||
404 | |||||||
405 | if ($order == 'ASC') { |
||||||
406 | $url .= '&order=DESC'; |
||||||
407 | } else { |
||||||
408 | $url .= '&order=ASC'; |
||||||
409 | } |
||||||
410 | |||||||
411 | if (isset($this->request->get['page'])) { |
||||||
412 | $url .= '&page=' . $this->request->get['page']; |
||||||
413 | } |
||||||
414 | |||||||
415 | $data['sort_name'] = $this->url->link('blog/article', 'token=' . $this->session->data['token'] . '&sort=pd.name' . $url, true); |
||||||
416 | $data['sort_status'] = $this->url->link('blog/article', 'token=' . $this->session->data['token'] . '&sort=p.status' . $url, true); |
||||||
417 | $data['sort_noindex'] = $this->url->link('blog/article', 'token=' . $this->session->data['token'] . '&sort=p.noindex' . $url, true); |
||||||
418 | $data['sort_order'] = $this->url->link('blog/article', 'token=' . $this->session->data['token'] . '&sort=p.sort_order' . $url, true); |
||||||
419 | |||||||
420 | $url = ''; |
||||||
421 | |||||||
422 | if (isset($this->request->get['filter_name'])) { |
||||||
423 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||||||
424 | } |
||||||
425 | |||||||
426 | if (isset($this->request->get['filter_status'])) { |
||||||
427 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||||||
428 | } |
||||||
429 | |||||||
430 | if (isset($this->request->get['filter_noindex'])) { |
||||||
431 | $url .= '&filter_noindex=' . $this->request->get['filter_noindex']; |
||||||
432 | } |
||||||
433 | |||||||
434 | if (isset($this->request->get['sort'])) { |
||||||
435 | $url .= '&sort=' . $this->request->get['sort']; |
||||||
436 | } |
||||||
437 | |||||||
438 | if (isset($this->request->get['order'])) { |
||||||
439 | $url .= '&order=' . $this->request->get['order']; |
||||||
440 | } |
||||||
441 | |||||||
442 | $pagination = new \Divine\Engine\Library\Pagination(); |
||||||
443 | $pagination->total = $article_total; |
||||||
444 | $pagination->page = $page; |
||||||
445 | $pagination->limit = $this->config->get('config_limit_admin'); |
||||||
446 | $pagination->url = $this->url->link('blog/article', 'token=' . $this->session->data['token'] . $url . '&page={page}', true); |
||||||
447 | |||||||
448 | $data['pagination'] = $pagination->render(); |
||||||
449 | |||||||
450 | $data['results'] = sprintf($this->language->get('text_pagination'), ($article_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($article_total - $this->config->get('config_limit_admin'))) ? $article_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $article_total, ceil($article_total / $this->config->get('config_limit_admin'))); |
||||||
451 | |||||||
452 | $data['filter_name'] = $filter_name; |
||||||
453 | $data['filter_status'] = $filter_status; |
||||||
454 | $data['filter_noindex'] = $filter_noindex; |
||||||
455 | |||||||
456 | $data['sort'] = $sort; |
||||||
457 | $data['order'] = $order; |
||||||
458 | |||||||
459 | $data['header'] = $this->load->controller('common/header'); |
||||||
460 | $data['column'] = $this->load->controller('common/column_left'); |
||||||
461 | $data['footer'] = $this->load->controller('common/footer'); |
||||||
462 | |||||||
463 | $this->response->setOutput($this->load->view('blog/article_list', $data)); |
||||||
464 | } |
||||||
465 | |||||||
466 | protected function getForm() |
||||||
467 | { |
||||||
468 | $data['heading_title'] = $this->language->get('heading_title'); |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
469 | |||||||
470 | $data['text_form'] = !isset($this->request->get['article_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); |
||||||
471 | $data['text_enabled'] = $this->language->get('text_enabled'); |
||||||
472 | $data['text_disabled'] = $this->language->get('text_disabled'); |
||||||
473 | $data['text_none'] = $this->language->get('text_none'); |
||||||
474 | $data['text_yes'] = $this->language->get('text_yes'); |
||||||
475 | $data['text_no'] = $this->language->get('text_no'); |
||||||
476 | $data['text_default'] = $this->language->get('text_default'); |
||||||
477 | $data['text_select'] = $this->language->get('text_select'); |
||||||
478 | $data['entry_name'] = $this->language->get('entry_name'); |
||||||
479 | $data['entry_description'] = $this->language->get('entry_description'); |
||||||
480 | $data['entry_meta_title'] = $this->language->get('entry_meta_title'); |
||||||
481 | $data['entry_meta_h1'] = $this->language->get('entry_meta_h1'); |
||||||
482 | $data['entry_meta_description'] = $this->language->get('entry_meta_description'); |
||||||
483 | $data['entry_keyword'] = $this->language->get('entry_keyword'); |
||||||
484 | $data['entry_image'] = $this->language->get('entry_image'); |
||||||
485 | $data['entry_download'] = $this->language->get('entry_download'); |
||||||
486 | $data['entry_category'] = $this->language->get('entry_category'); |
||||||
487 | $data['entry_main_category'] = $this->language->get('entry_main_category'); |
||||||
488 | $data['entry_related'] = $this->language->get('entry_related'); |
||||||
489 | $data['entry_related_product'] = $this->language->get('entry_related_product'); |
||||||
490 | $data['entry_sort_order'] = $this->language->get('entry_sort_order'); |
||||||
491 | $data['entry_status'] = $this->language->get('entry_status'); |
||||||
492 | $data['entry_noindex'] = $this->language->get('entry_noindex'); |
||||||
493 | $data['entry_tag'] = $this->language->get('entry_tag'); |
||||||
494 | $data['entry_layout'] = $this->language->get('entry_layout'); |
||||||
495 | |||||||
496 | $data['help_keyword'] = $this->language->get('help_keyword'); |
||||||
497 | $data['help_category'] = $this->language->get('help_category'); |
||||||
498 | $data['help_download'] = $this->language->get('help_download'); |
||||||
499 | $data['help_related'] = $this->language->get('help_related'); |
||||||
500 | $data['help_related_product'] = $this->language->get('help_related_product'); |
||||||
501 | $data['help_tag'] = $this->language->get('help_tag'); |
||||||
502 | $data['help_noindex'] = $this->language->get('help_noindex'); |
||||||
503 | |||||||
504 | $data['button_save'] = $this->language->get('button_save'); |
||||||
505 | $data['button_cancel'] = $this->language->get('button_cancel'); |
||||||
506 | $data['button_image_add'] = $this->language->get('button_image_add'); |
||||||
507 | $data['button_remove'] = $this->language->get('button_remove'); |
||||||
508 | |||||||
509 | $data['tab_general'] = $this->language->get('tab_general'); |
||||||
510 | $data['tab_data'] = $this->language->get('tab_data'); |
||||||
511 | $data['tab_links'] = $this->language->get('tab_links'); |
||||||
512 | $data['tab_design'] = $this->language->get('tab_design'); |
||||||
513 | |||||||
514 | if (isset($this->error['warning'])) { |
||||||
515 | $data['error_warning'] = $this->error['warning']; |
||||||
516 | } else { |
||||||
517 | $data['error_warning'] = ''; |
||||||
518 | } |
||||||
519 | |||||||
520 | if (isset($this->error['name'])) { |
||||||
521 | $data['error_name'] = $this->error['name']; |
||||||
522 | } else { |
||||||
523 | $data['error_name'] = array(); |
||||||
524 | } |
||||||
525 | |||||||
526 | if (isset($this->error['meta_title'])) { |
||||||
527 | $data['error_meta_title'] = $this->error['meta_title']; |
||||||
528 | } else { |
||||||
529 | $data['error_meta_title'] = array(); |
||||||
530 | } |
||||||
531 | |||||||
532 | if (isset($this->error['meta_h1'])) { |
||||||
533 | $data['error_meta_h1'] = $this->error['meta_h1']; |
||||||
534 | } else { |
||||||
535 | $data['error_meta_h1'] = array(); |
||||||
536 | } |
||||||
537 | |||||||
538 | if (isset($this->error['keyword'])) { |
||||||
539 | $data['error_keyword'] = $this->error['keyword']; |
||||||
540 | } else { |
||||||
541 | $data['error_keyword'] = ''; |
||||||
542 | } |
||||||
543 | |||||||
544 | $url = ''; |
||||||
545 | |||||||
546 | if (isset($this->request->get['filter_name'])) { |
||||||
547 | $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8')); |
||||||
548 | } |
||||||
549 | |||||||
550 | if (isset($this->request->get['filter_status'])) { |
||||||
551 | $url .= '&filter_status=' . $this->request->get['filter_status']; |
||||||
552 | } |
||||||
553 | |||||||
554 | if (isset($this->request->get['filter_noindex'])) { |
||||||
555 | $url .= '&filter_noindex=' . $this->request->get['filter_noindex']; |
||||||
556 | } |
||||||
557 | |||||||
558 | if (isset($this->request->get['sort'])) { |
||||||
559 | $url .= '&sort=' . $this->request->get['sort']; |
||||||
560 | } |
||||||
561 | |||||||
562 | if (isset($this->request->get['order'])) { |
||||||
563 | $url .= '&order=' . $this->request->get['order']; |
||||||
564 | } |
||||||
565 | |||||||
566 | if (isset($this->request->get['page'])) { |
||||||
567 | $url .= '&page=' . $this->request->get['page']; |
||||||
568 | } |
||||||
569 | |||||||
570 | $data['breadcrumbs'] = array(); |
||||||
571 | |||||||
572 | $data['breadcrumbs'][] = array( |
||||||
573 | 'text' => $this->language->get('text_home'), |
||||||
574 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||||||
575 | ); |
||||||
576 | |||||||
577 | $data['breadcrumbs'][] = array( |
||||||
578 | 'text' => $this->language->get('heading_title'), |
||||||
579 | 'href' => $this->url->link('blog/article', 'token=' . $this->session->data['token'] . $url, true) |
||||||
580 | ); |
||||||
581 | |||||||
582 | if (!isset($this->request->get['article_id'])) { |
||||||
583 | $data['action'] = $this->url->link('blog/article/add', 'token=' . $this->session->data['token'] . $url, true); |
||||||
584 | } else { |
||||||
585 | $data['action'] = $this->url->link('blog/article/edit', 'token=' . $this->session->data['token'] . '&article_id=' . $this->request->get['article_id'] . $url, true); |
||||||
586 | } |
||||||
587 | |||||||
588 | $data['cancel'] = $this->url->link('blog/article', 'token=' . $this->session->data['token'] . $url, true); |
||||||
589 | |||||||
590 | if (isset($this->request->get['article_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) { |
||||||
591 | $article_info = $this->model_blog_article->getArticle($this->request->get['article_id']); |
||||||
592 | } |
||||||
593 | |||||||
594 | $data['token'] = $this->session->data['token']; |
||||||
595 | |||||||
596 | $this->load->model('localisation/language'); |
||||||
597 | |||||||
598 | $data['languages'] = $this->model_localisation_language->getLanguages(); |
||||||
599 | |||||||
600 | if (isset($this->request->post['article_description'])) { |
||||||
601 | $data['article_description'] = $this->request->post['article_description']; |
||||||
602 | } elseif (isset($this->request->get['article_id'])) { |
||||||
603 | $data['article_description'] = $this->model_blog_article->getArticleDescriptions($this->request->get['article_id']); |
||||||
604 | } else { |
||||||
605 | $data['article_description'] = array(); |
||||||
606 | } |
||||||
607 | |||||||
608 | $language_id = $this->config->get('config_language_id'); |
||||||
609 | if (isset($data['article_description'][$language_id]['name'])) { |
||||||
610 | $data['heading_title'] = $data['article_description'][$language_id]['name']; |
||||||
611 | } |
||||||
612 | |||||||
613 | if (isset($this->request->post['image'])) { |
||||||
614 | $data['image'] = $this->request->post['image']; |
||||||
615 | } elseif (!empty($article_info)) { |
||||||
616 | $data['image'] = $article_info['image']; |
||||||
617 | } else { |
||||||
618 | $data['image'] = ''; |
||||||
619 | } |
||||||
620 | |||||||
621 | |||||||
622 | |||||||
623 | if (isset($this->request->post['image']) && is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $this->request->post['image'])) { |
||||||
624 | $data['thumb'] = '/public_html/assets/images/' . $this->request->post['image']; |
||||||
625 | } elseif (!empty($article_info) && is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $article_info['image'])) { |
||||||
626 | $data['thumb'] = '/public_html/assets/images/' . $article_info['image']; |
||||||
627 | } else { |
||||||
628 | $data['thumb'] = '/public_html/assets/images/no_image.png'; |
||||||
629 | } |
||||||
630 | |||||||
631 | $data['placeholder'] = '/public_html/assets/images/no_image.png'; |
||||||
632 | |||||||
633 | if (isset($this->request->post['keyword'])) { |
||||||
634 | $data['keyword'] = $this->request->post['keyword']; |
||||||
635 | } elseif (!empty($article_info)) { |
||||||
636 | $data['keyword'] = $article_info['keyword']; |
||||||
637 | } else { |
||||||
638 | $data['keyword'] = ''; |
||||||
639 | } |
||||||
640 | |||||||
641 | if (isset($this->request->post['sort_order'])) { |
||||||
642 | $data['sort_order'] = $this->request->post['sort_order']; |
||||||
643 | } elseif (!empty($article_info)) { |
||||||
644 | $data['sort_order'] = $article_info['sort_order']; |
||||||
645 | } else { |
||||||
646 | $data['sort_order'] = 1; |
||||||
647 | } |
||||||
648 | |||||||
649 | if (isset($this->request->post['status'])) { |
||||||
650 | $data['status'] = $this->request->post['status']; |
||||||
651 | } elseif (!empty($article_info)) { |
||||||
652 | $data['status'] = $article_info['status']; |
||||||
653 | } else { |
||||||
654 | $data['status'] = true; |
||||||
655 | } |
||||||
656 | |||||||
657 | if (isset($this->request->post['noindex'])) { |
||||||
658 | $data['noindex'] = $this->request->post['noindex']; |
||||||
659 | } elseif (!empty($article_info)) { |
||||||
660 | $data['noindex'] = $article_info['noindex']; |
||||||
661 | } else { |
||||||
662 | $data['noindex'] = 1; |
||||||
663 | } |
||||||
664 | |||||||
665 | // Categories |
||||||
666 | $this->load->model('blog/category'); |
||||||
667 | |||||||
668 | $categories = $this->model_blog_category->getAllCategories(); |
||||||
669 | |||||||
670 | $data['categories'] = $this->model_blog_category->getCategories($categories); |
||||||
671 | |||||||
672 | if (isset($this->request->post['main_blog_category_id'])) { |
||||||
673 | $data['main_blog_category_id'] = $this->request->post['main_blog_category_id']; |
||||||
674 | } elseif (isset($article_info)) { |
||||||
675 | $data['main_blog_category_id'] = $this->model_blog_article->getArticleMainCategoryId($this->request->get['article_id']); |
||||||
676 | } else { |
||||||
677 | $data['main_blog_category_id'] = 0; |
||||||
678 | } |
||||||
679 | |||||||
680 | if (isset($this->request->post['article_blog_category'])) { |
||||||
681 | $categories = $this->request->post['article_blog_category']; |
||||||
682 | } elseif (isset($this->request->get['article_id'])) { |
||||||
683 | $categories = $this->model_blog_article->getArticleCategories($this->request->get['article_id']); |
||||||
684 | } else { |
||||||
685 | $categories = array(); |
||||||
686 | } |
||||||
687 | |||||||
688 | $data['article_categories'] = array(); |
||||||
689 | |||||||
690 | foreach ($categories as $blog_category_id) { |
||||||
691 | $category_info = $this->model_blog_category->getCategory($blog_category_id); |
||||||
692 | |||||||
693 | if ($category_info) { |
||||||
694 | $data['article_categories'][] = array( |
||||||
695 | 'blog_category_id' => $category_info['blog_category_id'], |
||||||
696 | 'name' => ($category_info['path']) ? $category_info['path'] . ' > ' . $category_info['name'] : $category_info['name'] |
||||||
697 | ); |
||||||
698 | } |
||||||
699 | } |
||||||
700 | |||||||
701 | // Images |
||||||
702 | if (isset($this->request->post['article_image'])) { |
||||||
703 | $article_images = $this->request->post['article_image']; |
||||||
704 | } elseif (isset($this->request->get['article_id'])) { |
||||||
705 | $article_images = $this->model_blog_article->getArticleImages($this->request->get['article_id']); |
||||||
706 | } else { |
||||||
707 | $article_images = array(); |
||||||
708 | } |
||||||
709 | |||||||
710 | $data['article_images'] = array(); |
||||||
711 | |||||||
712 | foreach ($article_images as $article_image) { |
||||||
713 | if (is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $article_image['image'])) { |
||||||
714 | $image = $article_image['image']; |
||||||
715 | $thumb = $article_image['image']; |
||||||
716 | } else { |
||||||
717 | $image = ''; |
||||||
718 | $thumb = 'no_image.png'; |
||||||
719 | } |
||||||
720 | |||||||
721 | $data['article_images'][] = array( |
||||||
722 | 'image' => $image, |
||||||
723 | 'thumb' => '/public_html/assets/images/' . $thumb, |
||||||
724 | 'sort_order' => $article_image['sort_order'] |
||||||
725 | ); |
||||||
726 | } |
||||||
727 | |||||||
728 | // Downloads |
||||||
729 | $this->load->model('catalog/download'); |
||||||
730 | |||||||
731 | if (isset($this->request->post['article_download'])) { |
||||||
732 | $article_downloads = $this->request->post['article_download']; |
||||||
733 | } elseif (isset($this->request->get['article_id'])) { |
||||||
734 | $article_downloads = $this->model_blog_article->getArticleDownloads($this->request->get['article_id']); |
||||||
735 | } else { |
||||||
736 | $article_downloads = array(); |
||||||
737 | } |
||||||
738 | |||||||
739 | $data['article_downloads'] = array(); |
||||||
740 | |||||||
741 | foreach ($article_downloads as $download_id) { |
||||||
742 | $download_info = $this->model_catalog_download->getDownload($download_id); |
||||||
743 | |||||||
744 | if ($download_info) { |
||||||
745 | $data['article_downloads'][] = array( |
||||||
746 | 'download_id' => $download_info['download_id'], |
||||||
747 | 'name' => $download_info['name'] |
||||||
748 | ); |
||||||
749 | } |
||||||
750 | } |
||||||
751 | |||||||
752 | if (isset($this->request->post['article_related'])) { |
||||||
753 | $articles = $this->request->post['article_related']; |
||||||
754 | } elseif (isset($this->request->get['article_id'])) { |
||||||
755 | $articles = $this->model_blog_article->getArticleRelated($this->request->get['article_id']); |
||||||
756 | } else { |
||||||
757 | $articles = array(); |
||||||
758 | } |
||||||
759 | |||||||
760 | $data['article_relateds'] = array(); |
||||||
761 | |||||||
762 | foreach ($articles as $article_id) { |
||||||
763 | $related_info = $this->model_blog_article->getArticle($article_id); |
||||||
764 | |||||||
765 | if ($related_info) { |
||||||
766 | $data['article_relateds'][] = array( |
||||||
767 | 'article_id' => $related_info['article_id'], |
||||||
768 | 'name' => $related_info['name'] |
||||||
769 | ); |
||||||
770 | } |
||||||
771 | } |
||||||
772 | |||||||
773 | if (isset($this->request->post['product_related'])) { |
||||||
774 | $products = $this->request->post['product_related']; |
||||||
775 | } elseif (isset($article_info)) { |
||||||
776 | $products = $this->model_blog_article->getProductRelated($this->request->get['article_id']); |
||||||
777 | } else { |
||||||
778 | $products = array(); |
||||||
779 | } |
||||||
780 | |||||||
781 | $data['product_relateds'] = array(); |
||||||
782 | $this->load->model('catalog/product'); |
||||||
783 | |||||||
784 | foreach ($products as $product_id) { |
||||||
785 | $product_info = $this->model_catalog_product->getProduct($product_id); |
||||||
786 | |||||||
787 | if ($product_info) { |
||||||
788 | $data['product_relateds'][] = array( |
||||||
789 | 'product_id' => $product_info['product_id'], |
||||||
790 | 'name' => $product_info['name'] |
||||||
791 | ); |
||||||
792 | } |
||||||
793 | } |
||||||
794 | |||||||
795 | if (isset($this->request->post['article_layout'])) { |
||||||
796 | $data['article_layout'] = $this->request->post['article_layout']; |
||||||
797 | } elseif (isset($this->request->get['article_id'])) { |
||||||
798 | $data['article_layout'] = $this->model_blog_article->getArticleLayouts($this->request->get['article_id']); |
||||||
799 | } else { |
||||||
800 | $data['article_layout'] = array(); |
||||||
801 | } |
||||||
802 | |||||||
803 | $this->load->model('design/layout'); |
||||||
804 | |||||||
805 | $data['layouts'] = $this->model_design_layout->getLayouts(); |
||||||
806 | |||||||
807 | $data['header'] = $this->load->controller('common/header'); |
||||||
808 | $data['column'] = $this->load->controller('common/column_left'); |
||||||
809 | $data['footer'] = $this->load->controller('common/footer'); |
||||||
810 | |||||||
811 | $this->response->setOutput($this->load->view('blog/article_form', $data)); |
||||||
812 | } |
||||||
813 | |||||||
814 | protected function validateForm() |
||||||
815 | { |
||||||
816 | if (!$this->user->hasPermission('modify', 'blog/article')) { |
||||||
817 | $this->error['warning'] = $this->language->get('error_permission'); |
||||||
818 | } |
||||||
819 | |||||||
820 | foreach ($this->request->post['article_description'] as $language_id => $value) { |
||||||
821 | if ((\voku\helper\UTF8::strlen($value['name']) < 3) || (\voku\helper\UTF8::strlen($value['name']) > 255)) { |
||||||
822 | $this->error['name'][$language_id] = $this->language->get('error_name'); |
||||||
823 | } |
||||||
824 | |||||||
825 | if ((\voku\helper\UTF8::strlen($value['meta_title']) < 0) || (\voku\helper\UTF8::strlen($value['meta_title']) > 255)) { |
||||||
826 | $this->error['meta_title'][$language_id] = $this->language->get('error_meta_title'); |
||||||
827 | } |
||||||
828 | |||||||
829 | if ((\voku\helper\UTF8::strlen($value['meta_h1']) < 0) || (\voku\helper\UTF8::strlen($value['meta_h1']) > 255)) { |
||||||
830 | $this->error['meta_h1'][$language_id] = $this->language->get('error_meta_h1'); |
||||||
831 | } |
||||||
832 | } |
||||||
833 | |||||||
834 | if (\voku\helper\UTF8::strlen($this->request->post['keyword']) > 0) { |
||||||
835 | $this->load->model('catalog/url_alias'); |
||||||
836 | |||||||
837 | $url_alias_info = $this->model_catalog_url_alias->getUrlAlias($this->request->post['keyword']); |
||||||
838 | |||||||
839 | if ($url_alias_info && isset($this->request->get['article_id']) && $url_alias_info['query'] != 'article_id=' . $this->request->get['article_id']) { |
||||||
840 | $this->error['keyword'] = sprintf($this->language->get('error_keyword')); |
||||||
841 | } |
||||||
842 | |||||||
843 | if ($url_alias_info && !isset($this->request->get['article_id'])) { |
||||||
844 | $this->error['keyword'] = sprintf($this->language->get('error_keyword')); |
||||||
845 | } |
||||||
846 | } |
||||||
847 | |||||||
848 | if ($this->error && !isset($this->error['warning'])) { |
||||||
0 ignored issues
–
show
The expression
$this->error of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||||||
849 | $this->error['warning'] = $this->language->get('error_warning'); |
||||||
850 | } |
||||||
851 | |||||||
852 | return !$this->error; |
||||||
853 | } |
||||||
854 | |||||||
855 | public function enable() |
||||||
856 | { |
||||||
857 | $this->load->language('blog/article'); |
||||||
858 | |||||||
859 | $this->document->setTitle($this->language->get('heading_title')); |
||||||
860 | |||||||
861 | $this->load->model('blog/article'); |
||||||
862 | |||||||
863 | if (isset($this->request->post['selected'])) { |
||||||
864 | foreach ($this->request->post['selected'] as $article_id) { |
||||||
865 | $this->model_blog_article->editArticleStatus($article_id, 1); |
||||||
866 | } |
||||||
867 | |||||||
868 | $this->session->data['success'] = $this->language->get('text_success'); |
||||||
869 | |||||||
870 | $url = ''; |
||||||
871 | |||||||
872 | if (isset($this->request->get['page'])) { |
||||||
873 | $url .= '&page=' . $this->request->get['page']; |
||||||
874 | } |
||||||
875 | |||||||
876 | if (isset($this->request->get['sort'])) { |
||||||
877 | $url .= '&sort=' . $this->request->get['sort']; |
||||||
878 | } |
||||||
879 | |||||||
880 | if (isset($this->request->get['order'])) { |
||||||
881 | $url .= '&order=' . $this->request->get['order']; |
||||||
882 | } |
||||||
883 | |||||||
884 | $this->response->redirect($this->url->link('blog/article', 'token=' . $this->session->data['token'] . $url, true)); |
||||||
885 | } |
||||||
886 | |||||||
887 | $this->getList(); |
||||||
888 | } |
||||||
889 | |||||||
890 | public function disable() |
||||||
891 | { |
||||||
892 | $this->load->language('blog/article'); |
||||||
893 | |||||||
894 | $this->document->setTitle($this->language->get('heading_title')); |
||||||
895 | |||||||
896 | $this->load->model('blog/article'); |
||||||
897 | |||||||
898 | if (isset($this->request->post['selected'])) { |
||||||
899 | foreach ($this->request->post['selected'] as $article_id) { |
||||||
900 | $this->model_blog_article->editArticleStatus($article_id, 0); |
||||||
901 | } |
||||||
902 | |||||||
903 | $this->session->data['success'] = $this->language->get('text_success'); |
||||||
904 | |||||||
905 | $url = ''; |
||||||
906 | |||||||
907 | if (isset($this->request->get['page'])) { |
||||||
908 | $url .= '&page=' . $this->request->get['page']; |
||||||
909 | } |
||||||
910 | |||||||
911 | if (isset($this->request->get['sort'])) { |
||||||
912 | $url .= '&sort=' . $this->request->get['sort']; |
||||||
913 | } |
||||||
914 | |||||||
915 | if (isset($this->request->get['order'])) { |
||||||
916 | $url .= '&order=' . $this->request->get['order']; |
||||||
917 | } |
||||||
918 | |||||||
919 | $this->response->redirect($this->url->link('blog/article', 'token=' . $this->session->data['token'] . $url, true)); |
||||||
920 | } |
||||||
921 | |||||||
922 | $this->getList(); |
||||||
923 | } |
||||||
924 | |||||||
925 | protected function validateDelete() |
||||||
926 | { |
||||||
927 | if (!$this->user->hasPermission('modify', 'blog/article')) { |
||||||
928 | $this->error['warning'] = $this->language->get('error_permission'); |
||||||
929 | } |
||||||
930 | |||||||
931 | return !$this->error; |
||||||
932 | } |
||||||
933 | |||||||
934 | protected function validateCopy() |
||||||
935 | { |
||||||
936 | if (!$this->user->hasPermission('modify', 'blog/article')) { |
||||||
937 | $this->error['warning'] = $this->language->get('error_permission'); |
||||||
938 | } |
||||||
939 | |||||||
940 | return !$this->error; |
||||||
941 | } |
||||||
942 | |||||||
943 | public function autocomplete() |
||||||
944 | { |
||||||
945 | $json = array(); |
||||||
946 | |||||||
947 | if (isset($this->request->get['filter_name'])) { |
||||||
948 | $this->load->model('blog/article'); |
||||||
949 | |||||||
950 | if (isset($this->request->get['filter_name'])) { |
||||||
951 | $filter_name = $this->request->get['filter_name']; |
||||||
952 | } else { |
||||||
953 | $filter_name = ''; |
||||||
954 | } |
||||||
955 | |||||||
956 | if (isset($this->request->get['limit'])) { |
||||||
957 | $limit = $this->request->get['limit']; |
||||||
958 | } else { |
||||||
959 | $limit = 5; |
||||||
960 | } |
||||||
961 | |||||||
962 | $filter_data = array( |
||||||
963 | 'filter_name' => $filter_name, |
||||||
964 | 'start' => 0, |
||||||
965 | 'limit' => $limit |
||||||
966 | ); |
||||||
967 | |||||||
968 | $results = $this->model_blog_article->getArticles($filter_data); |
||||||
969 | |||||||
970 | foreach ($results as $result) { |
||||||
971 | $json[] = array( |
||||||
972 | 'article_id' => $result['article_id'], |
||||||
973 | 'name' => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')) |
||||||
974 | ); |
||||||
975 | } |
||||||
976 | } |
||||||
977 | |||||||
978 | $this->response->addHeader('Content-Type: application/json'); |
||||||
979 | $this->response->setOutput(json_encode($json)); |
||||||
980 | } |
||||||
981 | } |
||||||
982 |
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.