Completed
Push — 1.1.0 ( 20d850...72422e )
by Sylver
02:50
created

category   F

Complexity

Total Complexity 64

Size/Duplication

Total Lines 558
Duplicated Lines 0 %

Importance

Changes 14
Bugs 0 Features 0
Metric Value
eloc 352
c 14
b 0
f 0
dl 0
loc 558
rs 3.28
wmc 64

16 Methods

Rating   Name   Duplication   Size   Complexity  
A shoutbox_smilies() 0 39 3
A select_categories() 0 26 6
B shoutbox_smilies_popup() 0 55 5
A get_max_id() 0 10 1
A capitalize() 0 3 1
B extract_categories() 0 41 10
A get_version() 0 16 2
A smilies_count() 0 13 2
A __construct() 0 13 1
C extract_list_smilies() 0 77 17
A adm_edit_smiley() 0 30 2
B adm_list_cat() 0 47 6
A get_first_order() 0 12 1
A adm_add_cat() 0 19 2
A get_max_order() 0 10 1
A adm_edit_cat() 0 69 4

How to fix   Complexity   

Complex Class

Complex classes like category often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use category, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
*
4
* @package		Breizh Smilies Categories Extension
5
* @copyright	(c) 2020 Sylver35  https://breizhcode.com
6
* @license		http://opensource.org/licenses/gpl-license.php GNU Public License
7
*
8
*/
9
10
namespace sylver35\smiliescat\core;
11
12
use phpbb\cache\driver\driver_interface as cache;
13
use phpbb\db\driver\driver_interface as db;
14
use phpbb\config\config;
15
use phpbb\user;
16
use phpbb\language\language;
17
use phpbb\template\template;
18
use phpbb\request\request;
19
use phpbb\pagination;
20
use phpbb\extension\manager;
21
22
class category
23
{
24
	/** @var \phpbb\cache\driver\driver_interface */
25
	protected $cache;
26
27
	/** @var \phpbb\db\driver\driver_interface */
28
	protected $db;
29
30
	/** @var \phpbb\config\config */
31
	protected $config;
32
33
	/** @var \phpbb\user */
34
	protected $user;
35
36
	/** @var \phpbb\language\language */
37
	protected $language;
38
39
	/** @var \phpbb\template\template */
40
	protected $template;
41
42
	/** @var \phpbb\request\request */
43
	protected $request;
44
45
	/** @var \phpbb\pagination */
46
	protected $pagination;
47
48
	/** @var \phpbb\extension\manager "Extension Manager" */
49
	protected $ext_manager;
50
51
	/**
52
	 * The database tables
53
	 *
54
	 * @var string */
55
	protected $smilies_category_table;
56
57
	/** @var string phpBB root path */
58
	protected $root_path;
59
60
	/**
61
	 * Constructor
62
	 */
63
	public function __construct(cache $cache, db $db, config $config, user $user, language $language, template $template, request $request, pagination $pagination, manager $ext_manager, $smilies_category_table, $root_path)
64
	{
65
		$this->cache = $cache;
66
		$this->db = $db;
67
		$this->config = $config;
68
		$this->user = $user;
69
		$this->language = $language;
70
		$this->template = $template;
71
		$this->request = $request;
72
		$this->pagination = $pagination;
73
		$this->ext_manager = $ext_manager;
74
		$this->smilies_category_table = $smilies_category_table;
75
		$this->root_path = $root_path;
76
	}
77
78
	public function get_version()
79
	{
80
		if (($data = $this->cache->get('_smiliescat_version')) === false)
81
		{
82
			$md_manager = $this->ext_manager->create_extension_metadata_manager('sylver35/smiliescat');
83
			$meta = $md_manager->get_metadata();
84
85
			$data = array(
86
				'version'	=> $meta['version'],
87
				'homepage'	=> $meta['homepage'],
88
			);
89
			// cache for 7 days
90
			$this->cache->put('_smiliescat_version', $data, 604800);
91
		}
92
93
		return $data;
94
	}
95
96
	public function smilies_count($cat)
97
	{
98
		$sql_where = ($cat == -1) ? "code <> ''" : "category = $cat";
99
		$sql = $this->db->sql_build_query('SELECT', array(
100
			'SELECT'	=> 'COUNT(DISTINCT smiley_url) AS smilies_count',
101
			'FROM'		=> array(SMILIES_TABLE => ''),
102
			'WHERE'		=> $sql_where,
103
		));
104
		$result = $this->db->sql_query($sql);
105
		$smilies_count = (int) $this->db->sql_fetchfield('smilies_count');
106
		$this->db->sql_freeresult($result);
107
108
		return $smilies_count;
109
	}
110
111
	public function select_categories($cat, $modify = false)
112
	{
113
		$lang = $this->user->lang_name;
114
		$select = '<option>' . $this->language->lang('SC_CATEGORY_SELECT') . '</option>';
115
		if (!$modify)
116
		{
117
			$sel = ($cat == -1) ? ' selected="selected"' : '';
118
			$select .= '<option value="-1"' . $sel . '>' . $this->language->lang('SC_CATEGORY_ANY') . '</option>';
119
		}
120
121
		$sql = 'SELECT *
122
			FROM ' . $this->smilies_category_table . "
123
				WHERE cat_lang = '$lang'
124
				ORDER BY cat_order ASC";
125
		$result = $this->db->sql_query($sql);
126
		while ($row = $this->db->sql_fetchrow($result))
127
		{
128
			$selected = ($cat == $row['cat_id']) ? ' selected="selected"' : '';
129
			$select .= '<option title="' . $row['cat_name'] . '" value="' . $row['cat_id'] . '"' . $selected . '> ' . $row['cat_name'] . '</option>';
130
		}
131
		$this->db->sql_freeresult($result);
132
133
		$selected_defaut = ($cat == 0) ? ' selected="selected"' : '';
134
		$select .= '<option title="' . $this->language->lang('SC_CATEGORY_DEFAUT') . '" value="0"' . $selected_defaut . '> ' . $this->language->lang('SC_CATEGORY_DEFAUT') . '</option>';
135
136
		return $select;
137
	}
138
139
	public function capitalize($var)
140
	{
141
		return $this->db->sql_escape(ucfirst(strtolower(trim($var))));
142
	}
143
144
	public function get_max_order()
145
	{
146
		// Get max order id...
147
		$sql = 'SELECT MAX(cat_order) AS maxi
148
			FROM ' . $this->smilies_category_table;
149
		$result = $this->db->sql_query($sql);
150
		$max = (int) $this->db->sql_fetchfield('maxi', $result);
151
		$this->db->sql_freeresult($result);
152
153
		return $max;
154
	}
155
156
	public function get_max_id()
157
	{
158
		// Get max id...
159
		$sql = 'SELECT MAX(cat_id) AS id_max
160
			FROM ' . $this->smilies_category_table;
161
		$result = $this->db->sql_query($sql);
162
		$id_max = (int) $this->db->sql_fetchfield('id_max', $result);
163
		$this->db->sql_freeresult($result);
164
165
		return $id_max;
166
	}
167
168
	public function get_first_order()
169
	{
170
		// Get first order id...
171
		$sql = 'SELECT cat_order, cat_id
172
			FROM ' . $this->smilies_category_table . '
173
			ORDER BY cat_order ASC';
174
		$result = $this->db->sql_query_limit($sql, 1);
175
		$row = $this->db->sql_fetchrow($result);
176
		$mini = $row['cat_id'];
177
		$this->db->sql_freeresult($result);
178
179
		return $mini;
180
	}
181
182
	public function shoutbox_smilies($event)
183
	{
184
		$i = $cat_order = $cat_id = 0;
185
		$list_cat = [];
186
		$lang = $this->user->lang_name;
187
188
		$sql = $this->db->sql_build_query('SELECT', array(
189
			'SELECT'	=> '*',
190
			'FROM'		=> array($this->smilies_category_table => ''),
191
			'WHERE'		=> "cat_lang = '$lang'",
192
			'ORDER_BY'	=> 'cat_order ASC',
193
		));
194
		$result = $this->db->sql_query($sql, 3600);
195
		while ($row = $this->db->sql_fetchrow($result))
196
		{
197
			$list_cat[$i] = array(
198
				'cat_id'		=> $row['cat_id'],
199
				'cat_order'		=> $row['cat_order'],
200
				'cat_name'		=> $row['cat_name'],
201
				'cat_nb'		=> $row['cat_nb'],
202
			);
203
			$i++;
204
			$cat_order = $row['cat_order'];
205
		}
206
		$this->db->sql_freeresult($result);
207
208
		if ($i > 0)
209
		{
210
			// Add the Unclassified category
211
			$list_cat[$i] = array(
212
				'cat_id'		=> $cat_id,
213
				'cat_order'		=> $cat_order + 1,
214
				'cat_name'		=> $this->language->lang('SC_CATEGORY_DEFAUT'),
215
				'cat_nb'		=> $this->smilies_count($cat_id),
216
			);
217
218
			$event['content'] = array_merge($event['content'], array(
219
				'title_cat'		=> $this->language->lang('ACP_SC_SMILIES'),
220
				'categories'	=> $list_cat,
221
			));
222
		}
223
	}
224
225
	public function shoutbox_smilies_popup($event)
226
	{
227
		$cat = $event['cat'];
228
		if ($cat > -1)
229
		{
230
			$i = 0;
231
			$smilies = array();
232
			$lang = $this->user->lang_name;
233
234
			if ($cat > 0)
235
			{
236
				$sql = 'SELECT cat_name
237
					FROM ' . $this->smilies_category_table . "
238
						WHERE cat_lang = '$lang'
239
						AND cat_id = $cat";
240
				$result = $this->db->sql_query_limit($sql, 1);
241
				$row = $this->db->sql_fetchrow($result);
242
				$cat_name = $row['cat_name'];
243
				$this->db->sql_freeresult($result);
244
			}
245
			else
246
			{
247
				$cat_name = $this->language->lang('SC_CATEGORY_DEFAUT');
248
			}
249
250
			$sql = $this->db->sql_build_query('SELECT', array(
251
				'SELECT'	=> 'smiley_url, MIN(smiley_id) AS smiley_id, MIN(code) AS code, MIN(smiley_order) AS min_smiley_order, MIN(smiley_width) AS smiley_width, MIN(smiley_height) AS smiley_height, MIN(emotion) AS emotion, MIN(display_on_shout) AS display_on_shout',
252
				'FROM'		=> array(SMILIES_TABLE => ''),
253
				'WHERE'		=> "category = $cat",
254
				'GROUP_BY'	=> 'smiley_url',
255
				'ORDER_BY'	=> 'min_smiley_order ASC',
256
			));
257
			$result = $this->db->sql_query($sql);
258
			while ($row = $this->db->sql_fetchrow($result))
259
			{
260
				$smilies[$i] = array(
261
					'nb'		=> $i,
262
					'code'		=> $row['code'],
263
					'emotion'	=> $row['emotion'],
264
					'width'		=> $row['smiley_width'],
265
					'height'	=> $row['smiley_height'],
266
					'image'		=> $row['smiley_url'],
267
				);
268
				$i++;
269
			}
270
271
			$empty_row = ($i == 0) ? $this->language->lang('SC_SMILIES_EMPTY_CATEGORY') : false;
272
273
			$event['content'] = array_merge($event['content'], array(
274
				'in_cat'		=> true,
275
				'cat'			=> $cat,
276
				'total'			=> $i,
277
				'smilies'		=> $smilies,
278
				'emptyRow'		=> $empty_row,
279
				'title'			=> $this->language->lang('SC_CATEGORY_IN', $cat_name),
280
			));
281
		}
282
	}
283
284
	public function adm_add_cat()
285
	{
286
		$max = $this->get_max_order();
287
		$sql = 'SELECT lang_local_name, lang_iso
288
			FROM ' . LANG_TABLE . "
289
				ORDER BY lang_id ASC";
290
		$result = $this->db->sql_query($sql);
291
		while ($row = $this->db->sql_fetchrow($result))
292
		{
293
			$this->template->assign_block_vars('categories', array(
294
				'CAT_LANG'		=> $row['lang_local_name'],
295
				'CAT_ISO'		=> $row['lang_iso'],
296
				'CAT_ORDER'		=> $max + 1,
297
			));
298
		}
299
		$this->db->sql_freeresult($result);
300
301
		$this->template->assign_vars(array(
302
			'CAT_ORDER'		=> $max + 1,
303
		));
304
	}
305
	
306
	public function adm_edit_cat($id)
307
	{
308
		// Get total lang id...
309
		$sql = 'SELECT COUNT(lang_id) as total
310
			FROM ' . LANG_TABLE;
311
		$result = $this->db->sql_query($sql);
312
		$total = (int) $this->db->sql_fetchfield('total', $result);
313
		$this->db->sql_freeresult($result);
314
315
		$title = '';
316
		$i = $cat_order = $cat_id = 0;
317
		$list_id = [];
318
		$sql = $this->db->sql_build_query('SELECT', array(
319
			'SELECT'	=> 'l.*, c.*',
320
			'FROM'		=> array(LANG_TABLE => 'l'),
321
			'LEFT_JOIN'	=> array(
322
				array(
323
					'FROM'	=> array($this->smilies_category_table => 'c'),
324
					'ON'	=> 'c.cat_lang = l.lang_iso',
325
				),
326
			),
327
			'WHERE'		=> "cat_id = $id",
328
			'ORDER_BY'	=> 'lang_id ASC',
329
		));
330
		$result = $this->db->sql_query($sql);
331
		while ($row = $this->db->sql_fetchrow($result))
332
		{
333
			$this->template->assign_block_vars('category_lang', array(
334
				'CAT_LANG'			=> $row['lang_local_name'],
335
				'CAT_ISO'			=> $row['lang_iso'],
336
				'CAT_ORDER'			=> $row['cat_order'],
337
				'CAT_ID'			=> $row['cat_id'],
338
				'CAT_TRADUCT'		=> $row['cat_name'],
339
				'CAT_SORT'			=> 'edit',
340
			));
341
			$i++;
342
			$list_id[$i] = $row['lang_id'];
343
			$cat_id = $row['cat_id'];
344
			$cat_order = $row['cat_order'];
345
			$title = $row['cat_title'];
346
		}
347
		$this->db->sql_freeresult($result);
348
349
		// Add rows for empty langs in this category
350
		if ($i !== $total)
351
		{
352
			$sql = $this->db->sql_build_query('SELECT', array(
353
				'SELECT'	=> '*',
354
				'FROM'		=> array(LANG_TABLE => 'l'),
355
				'WHERE'		=> $this->db->sql_in_set('lang_id', $list_id, true, true),
356
			));
357
			$result = $this->db->sql_query($sql);
358
			while ($row = $this->db->sql_fetchrow($result))
359
			{
360
				$this->template->assign_block_vars('category_lang', array(
361
					'CAT_LANG'			=> $row['lang_local_name'],
362
					'CAT_ISO'			=> $row['lang_iso'],
363
					'CAT_ORDER'			=> $cat_order,
364
					'CAT_ID'			=> $cat_id,
365
					'CAT_TRADUCT'		=> '',
366
					'CAT_SORT'			=> 'create',
367
				));
368
			}
369
			$this->db->sql_freeresult($result);
370
		}
371
372
		$this->template->assign_vars(array(
373
			'CAT_ORDER'		=> $cat_order,
374
			'CAT_TITLE'		=> $title,
375
		));
376
	}
377
378
	public function adm_list_cat($u_action)
379
	{
380
		$i = 1;
381
		$cat = 0;
382
		$empty_row = false;
383
		$max = $this->get_max_order();
384
		$sql = $this->db->sql_build_query('SELECT', array(
385
			'SELECT'	=> 'l.lang_iso, l.lang_local_name, c.*',
386
			'FROM'		=> array(LANG_TABLE => 'l'),
387
			'LEFT_JOIN'	=> array(
388
				array(
389
					'FROM'	=> array($this->smilies_category_table => 'c'),
390
					'ON'	=> 'c.cat_lang = l.lang_iso',
391
				),
392
			),
393
			'ORDER_BY'	=> 'cat_order ASC, c.cat_lang_id ASC',
394
		));
395
		$result = $this->db->sql_query($sql);
396
		if ($row = $this->db->sql_fetchrow($result))
397
		{
398
			do
399
			{
400
				$this->template->assign_block_vars('categories', array(
401
					'CAT_NR'			=> $i,
402
					'CAT_LANG'			=> $row['lang_local_name'],
403
					'CAT_ISO'			=> $row['lang_iso'],
404
					'CAT_ID'			=> $row['cat_id'],
405
					'CAT_ORDER'			=> $row['cat_order'],
406
					'CAT_TRADUCT'		=> $row['cat_name'],
407
					'CAT_NB'			=> $row['cat_nb'],
408
					'ROW'				=> ($cat !== $row['cat_id']) ? true : false,
409
					'ROW_MAX'			=> ($row['cat_order'] == $max) ? true : false,
410
					'SPACER_CAT'		=> $this->language->lang('SC_CATEGORY_IN', $row['cat_title']),
411
					'U_EDIT'			=> $u_action . '&amp;action=edit&amp;id=' . $row['cat_id'],
412
					'U_DELETE'			=> $u_action . '&amp;action=delete&amp;id=' . $row['cat_id'],
413
					'U_MOVE_UP'			=> $u_action . '&amp;action=move_up&amp;id=' . $row['cat_id'] . '&amp;hash=' . generate_link_hash('acp-main_module'),
414
					'U_MOVE_DOWN'		=> $u_action . '&amp;action=move_down&amp;id=' . $row['cat_id'] . '&amp;hash=' . generate_link_hash('acp-main_module'),
415
				));
416
				$i++;
417
				$cat = $row['cat_id'];
418
				$empty_row = (!$cat) ? true : false;
419
			} while ($row = $this->db->sql_fetchrow($result));
420
		}
421
		$this->db->sql_freeresult($result);
422
423
		$this->template->assign_vars(array(
424
			'EMPTY_ROW'		=> $empty_row,
425
		));
426
	}
427
	
428
	public function extract_categories($cat)
429
	{
430
		$title = '';
431
		$cat_order = $i = 0;
432
		$sql = $this->db->sql_build_query('SELECT', array(
433
			'SELECT'	=> '*',
434
			'FROM'		=> array($this->smilies_category_table => ''),
435
			'WHERE'		=> "cat_lang = '$this->user->lang_name'",
436
			'ORDER_BY'	=> 'cat_order ASC',
437
		));
438
		$result = $this->db->sql_query($sql);
439
		while ($row = $this->db->sql_fetchrow($result))
440
		{
441
			$active = ($row['cat_id'] == $cat) ? true : false;
442
			$this->template->assign_block_vars('categories', array(
443
				'CLASS'			=> ($active) ? 'cat-active' : 'cat-inactive',
444
				'SEPARATE'		=> ($i > 0) ? ' - ' : '',
445
				'CAT_ID'		=> $row['cat_id'],
446
				'CAT_ORDER'		=> $row['cat_order'],
447
				'CAT_NAME'		=> $row['cat_name'],
448
				'CAT_NB'		=> $row['cat_nb'],
449
			));
450
			$i++;
451
			$title = ($active) ? $row['cat_name'] : $title;
452
			$cat_order = $row['cat_order'];
453
		}
454
		$this->db->sql_freeresult($result);
455
456
		// Add the Unclassified category
457
		$unclassified = $this->language->lang('SC_CATEGORY_DEFAUT');
458
		$un_active = ($cat == 0) ? true : false;
459
		$this->template->assign_block_vars('categories', array(
460
			'CLASS'			=> ($un_active) ? 'cat-active' : 'cat-inactive',
461
			'SEPARATE'		=> ($i > 0) ? ' - ' : '',
462
			'CAT_ID'		=> 0,
463
			'CAT_ORDER'		=> $cat_order + 1,
464
			'CAT_NAME'		=> $unclassified,
465
			'CAT_NB'		=> $this->smilies_count(0),
466
		));
467
468
		return ($un_active) ? $unclassified : $title;
469
	}
470
471
	public function adm_edit_smiley($id, $u_action, $start)
472
	{
473
		$lang = $this->user->lang_name;
474
		$sql = $this->db->sql_build_query('SELECT', array(
475
			'SELECT'	=> 's.*, c.*',
476
			'FROM'		=> array(SMILIES_TABLE => 's'),
477
			'LEFT_JOIN'	=> array(
478
				array(
479
					'FROM'	=> array($this->smilies_category_table => 'c'),
480
					'ON'	=> "c.cat_id = s.category AND c.cat_lang = '$lang'",
481
				),
482
			),
483
			'WHERE'	=> "smiley_id = $id",
484
		));
485
		$result = $this->db->sql_query($sql);
486
		$row = $this->db->sql_fetchrow($result);
487
488
		$this->template->assign_vars(array(
489
			'WIDTH'				=> $row['smiley_width'],
490
			'HEIGHT'			=> $row['smiley_height'],
491
			'CODE'				=> $row['code'],
492
			'EMOTION'			=> $row['emotion'],
493
			'CATEGORY'			=> $row['cat_name'],
494
			'EX_CAT'			=> ($row['cat_id']) ? $row['cat_id'] : 0,
495
			'SELECT_CATEGORY'	=> $this->select_categories($row['cat_id'], true),
496
			'IMG_SRC'			=> $this->root_path . $this->config['smilies_path'] . '/' . $row['smiley_url'],
497
			'U_MODIFY'			=> $u_action . '&amp;action=modify&amp;id=' . $row['smiley_id'] . '&amp;start=' . $start,
498
			'U_BACK'			=> $u_action,
499
		));
500
		$this->db->sql_freeresult($result);
501
	}
502
503
	public function extract_list_smilies($select, $start, $u_action)
504
	{
505
		$cat = $i = 0;
506
		$smiley_url = '';
507
		$spacer_cat = false;
508
		$lang = $this->user->lang_name;
509
		$smilies_count = $this->smilies_count($select);
510
		$cat_title = $this->language->lang('SC_CATEGORY_DEFAUT');
511
		$where = ($select !== -1) ? "cat_id = $select" : 'smiley_id > 0';
512
513
		if ($select !== 0)
514
		{
515
			$sql = $this->db->sql_build_query('SELECT', array(
516
				'SELECT'	=> 's.*, c.*',
517
				'FROM'		=> array(SMILIES_TABLE => 's'),
518
				'LEFT_JOIN'	=> array(
519
					array(
520
						'FROM'	=> array($this->smilies_category_table => 'c'),
521
						'ON'	=> "cat_id = category AND cat_lang = '$lang'",
522
					),
523
				),
524
				'WHERE'		=> "$where AND code <> ''",
525
				'ORDER_BY'	=> 'cat_order ASC, smiley_order ASC',
526
			));
527
		}
528
		else
529
		{
530
			$sql = $this->db->sql_build_query('SELECT', array(
531
				'SELECT'	=> '*',
532
				'FROM'		=> array(SMILIES_TABLE => ''),
533
				'WHERE'		=> "category = 0",
534
				'ORDER_BY'	=> 'smiley_order ASC',
535
			));
536
		}
537
		$result = $this->db->sql_query_limit($sql, (int) $this->config['smilies_per_page_cat'], $start);
538
		while ($row = $this->db->sql_fetchrow($result))
539
		{
540
			if ($smiley_url === $row['smiley_url'])
541
			{
542
				continue;
543
			}
544
			$title = ($row['category'] == 0) ? $this->language->lang('SC_SMILIES_NO_CATEGORY') : $this->language->lang('SC_CATEGORY_IN', $row['cat_name']);
545
			$this->template->assign_block_vars('items', array(
546
				'S_SPACER_CAT'	=> (!$spacer_cat && ($cat !== $row['category'])) ? true : false,
547
				'SPACER_CAT'	=> $title,
548
				'IMG_SRC'		=> $this->root_path . $this->config['smilies_path'] . '/' . $row['smiley_url'],
549
				'WIDTH'			=> $row['smiley_width'],
550
				'HEIGHT'		=> $row['smiley_height'],
551
				'CODE'			=> $row['code'],
552
				'EMOTION'		=> $row['emotion'],
553
				'CATEGORY'		=> (isset($row['cat_name'])) ? $row['cat_name'] : '',
554
				'U_EDIT'		=> $u_action . '&amp;action=edit&amp;id=' . $row['smiley_id'] . '&amp;start=' . $start,
555
			));
556
			$i++;
557
			$smiley_url = $row['smiley_url'];
558
			$cat = $row['category'];
559
			$cat_title = ($select > 0) ? $row['cat_name'] : $cat_title;
560
			if (!$spacer_cat && ($cat !== $row['category']))
561
			{
562
				$spacer_cat = true;
563
			}
564
		}
565
		$this->db->sql_freeresult($result);
566
		$empty_row = ($i == 0) ? true : false;
567
568
		$this->template->assign_vars(array(
569
			'NB_SMILIES'		=> $smilies_count,
570
			'EMPTY_ROW'			=> $empty_row,
571
			'LIST_CATEGORY'		=> $this->select_categories($select),
572
			'S_SPACER_ANY'		=> ($cat === 0) ? true : false,
573
			'S_CAT_SELECT'		=> ($select) ? true : false,
574
			'CAT_SELECT_TITLE'	=> ($select) ? $this->language->lang('SC_CATEGORY_IN', $cat_title) : '',
575
			'U_BACK'			=> ($select) ? $u_action : false,
576
			'U_SELECT_CAT'		=> $u_action . '&amp;select=' . $select,
577
		));
578
579
		$this->pagination->generate_template_pagination($u_action . '&amp;select=' . $select, 'pagination', 'start', $smilies_count, (int) $this->config['smilies_per_page_cat'], $start);
580
	}
581
}
582