Code Duplication    Length = 54-54 lines in 2 locations

qte.php 2 locations

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