Code Duplication    Length = 51-51 lines in 2 locations

qte.php 2 locations

@@ 291-341 (lines=51) @@
288
	*
289
	* @return	null
290
	*/
291
	public function attr_sort($forum_id = 0, $attribute_id = 0)
292
	{
293
		$show_select = false;
294
295
		foreach ($this->_attr as $attr)
296
		{
297
			if (empty($attr['attr_auths']))
298
			{
299
				$attr_auths = array(array(
300
					'forums_ids'	=> array(),
301
					'groups_ids'	=> array(),
302
					'author'		=> false,
303
				));
304
			}
305
			else
306
			{
307
				$attr_auths = json_decode($attr['attr_auths'], true);
308
			}
309
310
			foreach ($attr_auths as $attr_auth)
311
			{
312
				$forum_ids = $attr_auth['forums_ids'];
313
314
				if (is_array($forum_ids) && in_array($forum_id, $forum_ids))
315
				{
316
					// show the selector !
317
					$show_select = true;
318
319
					// parse the attribute name
320
					$attribute_name = str_replace(array('%mod%', '%date%'), array($this->user->lang['QTE_KEY_USERNAME'], $this->user->lang['QTE_KEY_DATE']), $this->user->lang($attr['attr_name']));
321
322
					$this->template->assign_block_vars('attributes', array(
323
						'QTE_ID'		=> $attr['attr_id'],
324
						'QTE_TYPE'		=> $attr['attr_type'],
325
						'QTE_NAME'		=> $attribute_name,
326
						'QTE_DESC'		=> $this->user->lang($attr['attr_desc']),
327
						'QTE_COLOUR'	=> $this->attr_colour($attr['attr_name'], $attr['attr_colour']),
328
329
						'IS_SELECTED'	=> (!empty($attribute_id) && ($attr['attr_id'] == $attribute_id)) ? true : false,
330
331
						'S_QTE_DESC'	=> !empty($attr['attr_desc']) ? true : false,
332
					));
333
				}
334
			}
335
		}
336
337
		if ($show_select)
338
		{
339
			$this->template->assign_var('S_QTE_SELECT', true);
340
		}
341
	}
342
343
	/**
344
	* Generate a default attribute list for a forum
@@ 351-401 (lines=51) @@
348
	*
349
	* @return	null
350
	*/
351
	public function attr_default($forum_id = 0, $attribute_id = 0)
352
	{
353
		$show_select = false;
354
355
		foreach ($this->_attr as $attr)
356
		{
357
			if (empty($attr['attr_auths']))
358
			{
359
				$attr_auths = array(array(
360
					'forums_ids'	=> array(),
361
					'groups_ids'	=> array(),
362
					'author'		=> false,
363
				));
364
			}
365
			else
366
			{
367
				$attr_auths = json_decode($attr['attr_auths'], true);
368
			}
369
370
			foreach ($attr_auths as $attr_auth)
371
			{
372
				$forum_ids = $attr_auth['forums_ids'];
373
374
				if (is_array($forum_ids) && in_array($forum_id, $forum_ids))
375
				{
376
					// show the selector !
377
					$show_select = true;
378
379
					// parse the attribute name
380
					$attribute_name = str_replace(array('%mod%', '%date%'), array($this->user->lang['QTE_KEY_USERNAME'], $this->user->lang['QTE_KEY_DATE']), $this->user->lang($attr['attr_name']));
381
382
					$this->template->assign_block_vars('attributes', array(
383
						'QTE_ID'		=> $attr['attr_id'],
384
						'QTE_TYPE'		=> $attr['attr_type'],
385
						'QTE_NAME'		=> $attribute_name,
386
						'QTE_DESC'		=> $this->user->lang($attr['attr_desc']),
387
						'QTE_COLOUR'	=> $this->attr_colour($attr['attr_name'], $attr['attr_colour']),
388
389
						'IS_SELECTED'	=> (!empty($attribute_id) && ($attr['attr_id'] == $attribute_id)),
390
391
						'S_QTE_DESC'	=> !empty($attr['attr_desc']) ? true : false,
392
					));
393
				}
394
			}
395
		}
396
397
		if ($show_select)
398
		{
399
			$this->template->assign_var('S_QTE_SELECT', true);
400
		}
401
	}
402
403
	/**
404
	* Generate attribute for topic title