Passed
Push — 1.4.0 ( 7b09fd...3b45e1 )
by Sylver
04:26
created

admin_controller::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 11
dl 0
loc 13
rs 9.9

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
/**
3
*
4
* @package		Breizh Smilies Categories Extension
5
* @copyright	(c) 2020-2023 Sylver35  https://breizhcode.com
6
* @license		http://opensource.org/licenses/gpl-license.php GNU Public License
7
*
8
*/
9
10
namespace sylver35\smiliescat\controller;
11
12
use sylver35\smiliescat\core\category;
13
use phpbb\config\config;
14
use phpbb\db\driver\driver_interface as db;
15
use phpbb\pagination;
16
use phpbb\request\request;
17
use phpbb\template\template;
18
use phpbb\user;
19
use phpbb\language\language;
20
use phpbb\log\log;
21
22
class admin_controller
23
{
24
	/* @var \sylver35\smiliescat\core\category */
25
	protected $category;
26
27
	/** @var \phpbb\config\config */
28
	protected $config;
29
30
	/** @var \phpbb\db\driver\driver_interface */
31
	protected $db;
32
33
	/** @var \phpbb\pagination */
34
	protected $pagination;
35
36
	/** @var \phpbb\request\request */
37
	protected $request;
38
39
	/** @var \phpbb\template\template */
40
	protected $template;
41
42
	/** @var \phpbb\user */
43
	protected $user;
44
45
	/** @var \phpbb\language\language */
46
	protected $language;
47
48
	/** @var \phpbb\log\log */
49
	protected $log;
50
51
	/** @var string phpBB root path */
52
	protected $root_path;
53
54
	/** @var string Custom form action */
55
	protected $u_action;
56
57
	/**
58
	 * The database tables
59
	 *
60
	 * @var string */
61
	protected $smilies_category_table;
62
63
	/**
64
	 * Constructor
65
	 */
66
	public function __construct(category $category, config $config, db $db, pagination $pagination, request $request, template $template, user $user, language $language, log $log, $root_path, $smilies_category_table)
67
	{
68
		$this->category = $category;
69
		$this->config = $config;
70
		$this->db = $db;
71
		$this->pagination = $pagination;
72
		$this->request = $request;
73
		$this->template = $template;
74
		$this->user = $user;
75
		$this->language = $language;
76
		$this->log = $log;
77
		$this->root_path = $root_path;
78
		$this->smilies_category_table = $smilies_category_table;
79
	}
80
81
	public function acp_smilies_category($id, $action)
82
	{
83
		$this->language->add_lang('acp/posting');
84
		$start = (int) $this->request->variable('start', 0);
85
		$select = (int) $this->request->variable('select', -1);
86
		$cat_id = (int) $this->request->variable('cat_id', 0);
87
		$ex_cat = (int) $this->request->variable('ex_cat', 0);
88
		$list = $this->request->variable('list', [0]);
89
		$form_key = 'sylver35/smiliescat';
90
		add_form_key($form_key);
91
92
		if ($action)
93
		{
94
			switch ($action)
95
			{
96
				case 'edit':
97
					$this->edit_smiley($id, $start);
98
				break;
99
100
				case 'edit_multi':
101
					$list = $this->request->variable('mark', [0]);
102
					$this->edit_multi_smiley($list, $start);
103
				break;
104
105
				case 'modify':
106
					if (!check_form_key($form_key))
107
					{
108
						trigger_error($this->language->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
109
					}
110
111
					$this->modify_smiley($id, $cat_id, $ex_cat);
112
					trigger_error($this->language->lang('SMILIES_EDITED', 1) . adm_back_link($this->u_action . '&amp;start=' . $start . '#acp_smilies_category'));
113
				break;
114
115
				case 'modify_list':
116
					foreach ($list as $smiley)
117
					{
118
						$this->modify_smiley($smiley, $cat_id);
119
					}
120
					trigger_error($this->language->lang('SMILIES_EDITED', count($list)) . adm_back_link($this->u_action . '&amp;start=' . $start . '#acp_smilies_category'));
121
				break;
122
			}
123
124
			$this->template->assign_var('IN_ACTION', true);
0 ignored issues
show
Bug introduced by
true of type true is incompatible with the type string expected by parameter $varval of phpbb\template\template::assign_var(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

124
			$this->template->assign_var('IN_ACTION', /** @scrutinizer ignore-type */ true);
Loading history...
125
		}
126
		else
127
		{
128
			$this->extract_list_smilies($select, $start);
129
130
			$this->template->assign_vars([
131
				'LIST_CATEGORY'		=> $this->category->select_categories($select, true, true),
132
				'U_SELECT_CAT'		=> $this->u_action . '&amp;select=' . $select,
133
				'U_BACK'			=> ($select) ? $this->u_action : '',
134
			]);
135
		}
136
137
		$this->template->assign_vars([
138
			'CATEGORIE_SMILIES'	=> true,
139
		]);
140
	}
141
142
	public function acp_categories_config($id, $action, $mode)
143
	{
144
		$this->language->add_lang('acp/language');
145
		$form_key = 'sylver35/smiliescat';
146
		add_form_key($form_key);
147
148
		if ($action)
149
		{
150
			if (in_array($action, ['config_cat', 'add_cat', 'edit_cat']) && !check_form_key($form_key))
151
			{
152
				trigger_error($this->language->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
153
			}
154
155
			switch ($action)
156
			{
157
				case 'config_cat':
158
					$this->config->set('smilies_per_page_cat', (int) $this->request->variable('smilies_per_page_cat', 15));
159
160
					$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_SC_CONFIG', time());
161
					trigger_error($this->language->lang('CONFIG_UPDATED') . adm_back_link($this->u_action));
162
				break;
163
164
				case 'add':
165
					$this->add_cat();
166
				break;
167
168
				case 'add_cat':
169
					$this->add_category();
170
				break;
171
172
				case 'edit':
173
					$this->edit_cat((int) $id);
174
				break;
175
176
				case 'edit_cat':
177
					$this->edit_category((int) $id);
178
				break;
179
180
				case 'delete':
181
					if (confirm_box(true))
182
					{
183
						$this->delete_cat((int) $id);
184
					}
185
					else
186
					{
187
						confirm_box(false, $this->language->lang('CONFIRM_OPERATION'), build_hidden_fields([
188
							'mode'		=> $mode,
189
							'id'		=> $id,
190
							'action'	=> $action,
191
						]));
192
					}
193
				break;
194
			}
195
196
			$this->template->assign_vars([
197
				'IN_ACTION'	=> true,
198
			]);
199
		}
200
		else
201
		{
202
			$this->category->adm_list_cat($this->u_action);
203
		}
204
205
		$this->template->assign_vars([
206
			'CATEGORIE_CONFIG'		=> true,
207
			'SMILIES_PER_PAGE_CAT'	=> $this->config['smilies_per_page_cat'],
208
			'U_ACTION_CONFIG'		=> $this->u_action . '&amp;action=config_cat',
209
			'U_ADD'					=> $this->u_action . '&amp;action=add',
210
		]);
211
	}
212
213
	private function modify_smiley($id, $cat_id, $ex_cat = -1)
214
	{
215
		if ($ex_cat == -1)
216
		{
217
			$sql = 'SELECT category
218
				FROM ' . SMILIES_TABLE . '
219
					WHERE smiley_id = ' . $id;
220
			$result = $this->db->sql_query($sql);
221
			$row = $this->db->sql_fetchrow($result);
222
			$this->db->sql_freeresult($result);
223
			$ex_cat = $row['category'];
224
		}
225
		
226
		$this->db->sql_query('UPDATE ' . SMILIES_TABLE . ' SET category = ' . $cat_id . ' WHERE smiley_id = ' . $id);
227
		$this->update_cat_smiley($cat_id, $ex_cat);
228
	}
229
230
	private function update_cat_smiley($cat_id, $ex_cat)
231
	{
232
		// Increment nb value if wanted
233
		if ($cat_id)
234
		{
235
			if ($this->category->get_first_order() === $cat_id)
236
			{
237
				if ($this->category->get_cat_nb($cat_id) === 0)
238
				{
239
					$this->config->set('smilies_category_nb', $cat_id);
240
				}
241
			}
242
			$this->db->sql_query('UPDATE ' . $this->smilies_category_table . ' SET cat_nb = cat_nb + 1 WHERE cat_id = ' . $cat_id);
243
		}
244
245
		// Decrement nb value if wanted
246
		if ($ex_cat)
247
		{
248
			$this->db->sql_query('UPDATE ' . $this->smilies_category_table . ' SET cat_nb = cat_nb - 1 WHERE cat_id = ' . $ex_cat);
249
		}
250
	}
251
252
	private function extract_list_smilies($select, $start)
253
	{
254
		$i = 0;
255
		$cat = -1;
256
		$lang = $this->user->lang_name;
257
		$smilies_count = (int) $this->category->smilies_count($select);
258
259
		if ($select === 0)
260
		{
261
			$sql = 'SELECT *
262
				FROM ' . SMILIES_TABLE . '
263
					WHERE category = 0
264
				ORDER BY smiley_order ASC';
265
		}
266
		else
267
		{
268
			$sql = $this->db->sql_build_query('SELECT', [
269
				'SELECT'	=> 's.*, c.*',
270
				'FROM'		=> [SMILIES_TABLE => 's'],
271
				'LEFT_JOIN'	=> [
272
					[
273
						'FROM'	=> [$this->smilies_category_table => 'c'],
274
						'ON'	=> "cat_id = category AND cat_lang = '$lang'",
275
					],
276
				],
277
				'WHERE'		=> ($select === -1) ? "code <> ''" : "cat_id = $select AND code <> ''",
278
				'ORDER_BY'	=> 'cat_order ASC, smiley_order ASC',
279
			]);
280
		}
281
		$result = $this->db->sql_query_limit($sql, (int) $this->config['smilies_per_page_cat'], $start);
282
		while ($row = $this->db->sql_fetchrow($result))
283
		{
284
			$row['cat_name'] = ($row['category']) ? $row['cat_name'] : $this->language->lang('SC_CATEGORY_DEFAUT');
285
			$this->template->assign_block_vars('items', [
286
				'SPACER_CAT'	=> ($cat !== (int) $row['category']) ? $this->language->lang('SC_CATEGORY_IN', $row['cat_name']) : '',
287
				'IMG_SRC'		=> $row['smiley_url'],
288
				'WIDTH'			=> $row['smiley_width'],
289
				'HEIGHT'		=> $row['smiley_height'],
290
				'ID'			=> $row['smiley_id'],
291
				'CODE'			=> $row['code'],
292
				'EMOTION'		=> $row['emotion'],
293
				'CATEGORY'		=> $row['cat_name'],
294
				'U_EDIT'		=> $this->u_action . '&amp;action=edit&amp;id=' . $row['smiley_id'] . '&amp;start=' . $start,
295
			]);
296
			$i++;
297
298
			// Keep this value in memory
299
			$cat = (int) $row['category'];
300
		}
301
		$this->db->sql_freeresult($result);
302
303
		$this->template->assign_vars([
304
			'NB_SMILIES'	=> $this->language->lang('SC_SMILIES', ($smilies_count > 1) ? 2 : 1, $smilies_count),
305
			'U_SMILIES'		=> $this->root_path . $this->config['smilies_path'] . '/',
306
			'U_MODIFY'		=> $this->u_action . '&amp;action=edit_multi&ampstart=' . $start,
307
		]);
308
309
		$this->pagination->generate_template_pagination($this->u_action . '&amp;select=' . $select, 'pagination', 'start', $smilies_count, (int) $this->config['smilies_per_page_cat'], $start);
310
	}
311
312
	private function delete_cat($id)
313
	{
314
		$sql = 'SELECT cat_title, cat_order
315
			FROM ' . $this->smilies_category_table . '
316
				WHERE cat_id = ' . $id;
317
		$result = $this->db->sql_query($sql);
318
		$row = $this->db->sql_fetchrow($result);
319
		$title = $row['cat_title'];
320
		$order = (int) $row['cat_order'];
321
		$this->db->sql_freeresult($result);
322
323
		$this->db->sql_query('DELETE FROM ' . $this->smilies_category_table . ' WHERE cat_id = ' . $id);
324
325
		// Decrement orders if needed
326
		$sql_decrement = 'SELECT cat_id, cat_order
327
			FROM ' . $this->smilies_category_table . '
328
				WHERE cat_order > ' . $order;
329
		$result = $this->db->sql_query($sql_decrement);
330
		while ($row = $this->db->sql_fetchrow($result))
331
		{
332
			$new_order = (int) $row['cat_order'] - 1;
333
			$this->db->sql_query('UPDATE ' . $this->smilies_category_table . ' SET cat_order = ' . $new_order . ' WHERE cat_id = ' . $row['cat_id'] . ' AND cat_order = ' . $row['cat_order']);
334
		}
335
		$this->db->sql_freeresult($result);
336
337
		// Reset appropriate smilies category id
338
		$this->db->sql_query('UPDATE ' . SMILIES_TABLE . ' SET category = 0 WHERE category = ' . $id);
339
340
		$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_SC_DELETE_CAT', time(), [$title]);
341
		trigger_error($this->language->lang('SC_DELETE_SUCCESS') . adm_back_link($this->u_action));
342
	}
343
344
	private function add_category()
345
	{
346
		$sql_ary = [];
347
		$title = (string) $this->request->variable('name_' . $this->user->lang_name, '', true);
348
		$cat_order = (int) $this->request->variable('order', 0);
349
		$cat_id = (int) $this->category->get_max_id() + 1;
350
351
		$sql = 'SELECT lang_id, lang_iso
352
			FROM ' . LANG_TABLE . "
353
				ORDER BY lang_id ASC";
354
		$result = $this->db->sql_query($sql);
355
		while ($row = $this->db->sql_fetchrow($result))
356
		{
357
			$iso = strtolower($row['lang_iso']);
358
			$lang = (string) $this->request->variable("lang_$iso", '', true);
359
			$name = (string) $this->request->variable("name_$iso", '', true);
360
			if ($name === '')
361
			{
362
				trigger_error($this->language->lang('SC_CATEGORY_ERROR') . adm_back_link($this->u_action . '&amp;action=add'), E_USER_WARNING);
363
			}
364
			else
365
			{
366
				$sql_ary[] = [
367
					'cat_id'		=> $cat_id,
368
					'cat_order'		=> $cat_order,
369
					'cat_lang'		=> $lang,
370
					'cat_name'		=> $this->category->capitalize($name),
371
					'cat_title'		=> $this->category->capitalize($title),
372
					'cat_nb'		=> 0,
373
				];
374
			}
375
		}
376
		$this->db->sql_freeresult($result);
377
378
		$this->db->sql_multi_insert($this->smilies_category_table, $sql_ary);
379
380
		if ($cat_order === 1)
381
		{
382
			$sql = 'SELECT cat_id, cat_nb
383
				FROM ' . $this->smilies_category_table . '
384
					WHERE cat_order = 1';
385
			$result = $this->db->sql_query_limit($sql, 1);
386
			$row = $this->db->sql_fetchrow($result);
387
			if ($row['cat_nb'] > 0)
388
			{
389
				$this->config->set('smilies_category_nb', $row['cat_id']);
390
			}
391
			$this->db->sql_freeresult($result);
392
		}
393
394
		$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_SC_ADD_CAT', time(), [$title]);
395
		trigger_error($this->language->lang('SC_CREATE_SUCCESS') . adm_back_link($this->u_action));
396
	}
397
398
	private function edit_category($id)
399
	{
400
		$sql_in = [];
401
		$title = $this->category->capitalize($this->request->variable('name_' . $this->user->lang_name, '', true));
402
		$order = (int) $this->request->variable('order', 0);
403
		$cat_nb = (int) $this->request->variable('cat_nb', 0);
404
405
		$sql = 'SELECT lang_id, lang_iso
406
			FROM ' . LANG_TABLE . "
407
				ORDER BY lang_id ASC";
408
		$result = $this->db->sql_query($sql);
409
		while ($row = $this->db->sql_fetchrow($result))
410
		{
411
			$iso = strtolower($row['lang_iso']);
412
			$lang = (string) $this->request->variable("lang_$iso", '', true);
413
			$sort = (string) $this->request->variable("sort_$iso", '');
414
			$name = $this->category->capitalize($this->request->variable("name_$iso", '', true));
415
416
			if ($name === '')
417
			{
418
				trigger_error($this->language->lang('SC_CATEGORY_ERROR') . adm_back_link($this->u_action . '&amp;action=edit&amp;id=' . $id), E_USER_WARNING);
419
			}
420
			else
421
			{
422
				if ($sort === 'edit')
423
				{
424
					$this->db->sql_query('UPDATE ' . $this->smilies_category_table . " SET cat_name = '" . $this->db->sql_escape($name) . "', cat_title = '" . $this->db->sql_escape($title) . "', cat_nb = $cat_nb WHERE cat_lang = '" . $this->db->sql_escape($lang) . "' AND cat_id = $id");
425
				}
426
				else if ($sort === 'create')
427
				{
428
					$sql_in[] = [
429
						'cat_id'		=> $id,
430
						'cat_order'		=> $order,
431
						'cat_lang'		=> $lang,
432
						'cat_name'		=> $name,
433
						'cat_title'		=> $title,
434
						'cat_nb'		=> $cat_nb,
435
					];
436
				}
437
			}
438
		}
439
		$this->db->sql_freeresult($result);
440
441
		$this->db->sql_multi_insert($this->smilies_category_table, $sql_in);
442
443
		$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_SC_EDIT_CAT', time(), [$title]);
444
		trigger_error($this->language->lang('SC_EDIT_SUCCESS') . adm_back_link($this->u_action));
445
	}
446
447
	private function add_cat()
448
	{
449
		$max = (int) $this->category->get_max_order() + 1;
450
		$sql = 'SELECT lang_local_name, lang_iso
451
			FROM ' . LANG_TABLE . '
452
				ORDER BY lang_id ASC';
453
		$result = $this->db->sql_query($sql);
454
		while ($row = $this->db->sql_fetchrow($result))
455
		{
456
			$this->template->assign_block_vars('categories', [
457
				'CAT_LANG'		=> $row['lang_local_name'],
458
				'CAT_ISO'		=> $row['lang_iso'],
459
				'CAT_ORDER'		=> $max,
460
			]);
461
		}
462
		$this->db->sql_freeresult($result);
463
464
		$this->template->assign_vars([
465
			'IN_CAT_ACTION'		=> true,
466
			'IN_ADD_ACTION'		=> true,
467
			'CAT_ORDER'			=> $max,
468
			'U_BACK'			=> $this->u_action,
469
			'U_ADD_CAT'			=> $this->u_action . '&amp;action=add_cat',
470
		]);
471
	}
472
473
	private function edit_cat($id)
474
	{
475
		// Get total lang id...
476
		$sql = 'SELECT COUNT(lang_id) as total
477
			FROM ' . LANG_TABLE;
478
		$result = $this->db->sql_query($sql);
479
		$total = (int) $this->db->sql_fetchfield('total');
480
		$this->db->sql_freeresult($result);
481
482
		$title = '';
483
		$list_id = [];
484
		$i = $cat_order = $cat_nb = 0;
485
		$sql = $this->db->sql_build_query('SELECT', [
486
			'SELECT'	=> 'l.*, c.*',
487
			'FROM'		=> [LANG_TABLE => 'l'],
488
			'LEFT_JOIN'	=> [
489
				[
490
					'FROM'	=> [$this->smilies_category_table => 'c'],
491
					'ON'	=> 'c.cat_lang = l.lang_iso',
492
				],
493
			],
494
			'WHERE'		=> 'cat_id = ' . $id,
495
			'ORDER_BY'	=> 'lang_id ASC',
496
		]);
497
		$result = $this->db->sql_query($sql);
498
		while ($row = $this->db->sql_fetchrow($result))
499
		{
500
			$this->template->assign_block_vars('category_lang', [
501
				'CAT_LANG'			=> $row['lang_local_name'],
502
				'CAT_ISO'			=> $row['lang_iso'],
503
				'CAT_ORDER'			=> $row['cat_order'],
504
				'CAT_ID'			=> $row['cat_id'],
505
				'CAT_TRANSLATE'		=> $row['cat_name'],
506
				'CAT_SORT'			=> 'edit',
507
			]);
508
			$i++;
509
			$list_id[$i] = $row['lang_id'];
510
			$cat_order = $row['cat_order'];
511
			$title = $row['cat_title'];
512
			$cat_nb = $row['cat_nb'];
513
		}
514
		$this->db->sql_freeresult($result);
515
516
		// Add rows for empty langs in this category
517
		if ($i !== $total)
518
		{
519
			$sql = $this->db->sql_build_query('SELECT', [
520
				'SELECT'	=> '*',
521
				'FROM'		=> [LANG_TABLE => 'l'],
522
				'WHERE'		=> $this->db->sql_in_set('lang_id', $list_id, true, true),
523
			]);
524
			$result = $this->db->sql_query($sql);
525
			while ($row = $this->db->sql_fetchrow($result))
526
			{
527
				$this->template->assign_block_vars('category_lang', [
528
					'CAT_LANG'			=> $row['lang_local_name'],
529
					'CAT_ISO'			=> $row['lang_iso'],
530
					'CAT_ORDER'			=> $cat_order,
531
					'CAT_ID'			=> $id,
532
					'CAT_TRANSLATE'		=> '',
533
					'CAT_SORT'			=> 'create',
534
				]);
535
			}
536
			$this->db->sql_freeresult($result);
537
		}
538
539
		$this->template->assign_vars([
540
			'IN_CAT_ACTION'	=> true,
541
			'CAT_ORDER'		=> $cat_order,
542
			'CAT_NB'		=> $cat_nb,
543
			'CAT_TITLE'		=> $title,
544
			'U_BACK'		=> $this->u_action,
545
			'U_EDIT_CAT'	=> $this->u_action . '&amp;action=edit_cat&amp;id=' . $id,
546
		]);
547
	}
548
549
	private function edit_smiley($id, $start)
550
	{
551
		$lang = $this->user->lang_name;
552
		$sql = $this->db->sql_build_query('SELECT', [
553
			'SELECT'	=> 's.*, c.*',
554
			'FROM'		=> [SMILIES_TABLE => 's'],
555
			'LEFT_JOIN'	=> [
556
				[
557
					'FROM'	=> [$this->smilies_category_table => 'c'],
558
					'ON'	=> "c.cat_id = s.category AND c.cat_lang = '$lang'",
559
				],
560
			],
561
			'WHERE'	=> 's.smiley_id = ' . (int) $id,
562
		]);
563
		$result = $this->db->sql_query($sql);
564
		$row = $this->db->sql_fetchrow($result);
565
566
		$this->template->assign_vars([
567
			'WIDTH'				=> $row['smiley_width'],
568
			'HEIGHT'			=> $row['smiley_height'],
569
			'CODE'				=> $row['code'],
570
			'EMOTION'			=> $row['emotion'],
571
			'CATEGORY'			=> $row['cat_name'],
572
			'EX_CAT'			=> $row['cat_id'],
573
			'SELECT_CATEGORY'	=> $this->category->select_categories($row['cat_id'], false, false),
574
			'IMG_SRC'			=> $this->root_path . $this->config['smilies_path'] . '/' . $row['smiley_url'],
575
			'U_MODIFY'			=> $this->u_action . '&amp;action=modify&amp;id=' . $row['smiley_id'] . '&amp;start=' . $start,
576
			'U_BACK'			=> $this->u_action,
577
			'S_IN_LIST'			=> false,
578
		]);
579
		$this->db->sql_freeresult($result);
580
	}
581
582
	private function edit_multi_smiley($list, $start)
583
	{
584
		$i = 0;
585
		$lang = $this->user->lang_name;
586
		$sql = $this->db->sql_build_query('SELECT', [
587
			'SELECT'	=> 's.*, c.*',
588
			'FROM'		=> [SMILIES_TABLE => 's'],
589
			'LEFT_JOIN'	=> [
590
				[
591
					'FROM'	=> [$this->smilies_category_table => 'c'],
592
					'ON'	=> "c.cat_id = s.category AND cat_lang = '$lang'",
593
				],
594
			],
595
			'WHERE'		=> $this->db->sql_in_set('smiley_id', $list),
596
			'ORDER_BY'	=> 'cat_order ASC, s.smiley_order ASC',
597
		]);
598
		$result = $this->db->sql_query($sql);
599
		while ($row = $this->db->sql_fetchrow($result))
600
		{
601
			$row['cat_name'] = ($row['category']) ? $row['cat_name'] : $this->language->lang('SC_CATEGORY_DEFAUT');
602
			$this->template->assign_block_vars('items', [
603
				'IMG_SRC'		=>  $this->root_path . $this->config['smilies_path'] . '/' . $row['smiley_url'],
604
				'WIDTH'			=> $row['smiley_width'],
605
				'HEIGHT'		=> $row['smiley_height'],
606
				'ID'			=> $row['smiley_id'],
607
				'CODE'			=> $row['code'],
608
				'EMOTION'		=> $row['emotion'],
609
				'CATEGORY'		=> $row['cat_name'],
610
			]);
611
			$i++;
612
		}
613
		$this->db->sql_freeresult($result);
614
615
		$this->template->assign_vars([
616
			'SELECT_CATEGORY'	=> $this->category->select_categories(-1),
617
			'U_MODIFY'			=> $this->u_action . '&amp;action=modify_list&amp;start=' . $start,
618
			'S_IN_LIST'			=> true,
619
		]);
620
	}
621
622
	/**
623
	 * Set page url
624
	 *
625
	 * @param string $u_action Custom form action
626
	 * @return null
627
	 * @access public
628
	 */
629
	public function set_page_url($u_action)
630
	{
631
		$this->u_action = $u_action;
632
	}
633
}
634