main_module::main()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 43
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 3
eloc 27
c 4
b 0
f 0
nc 3
nop 2
dl 0
loc 43
rs 9.488
1
<?php
2
/**
3
*
4
* @package		Breizh Smilies Categories Extension
5
* @copyright	(c) 2020-2024 Sylver35  https://breizhcode.com
6
* @license		https://opensource.org/licenses/gpl-license.php GNU Public License
7
*
8
*/
9
10
namespace sylver35\smiliescat\acp;
11
12
class main_module
13
{
14
	/** @var string */
15
	public $u_action;
16
17
	/** @var string */
18
	public $tpl_name;
19
20
	/** @var string */
21
	public $page_title;
22
23
	/** @var string */
24
	public $id;
25
26
	/**
27
	 * @param int		$id
28
	 * @param string	$mode
29
	 *
30
	 * @return void
31
	 * @access public
32
	 */
33
	public function main(/** @scrutinizer ignore-unused */$id, $mode)
34
	{
35
		global $phpbb_container;
36
37
		/** @type \phpbb\language\language $language Language object */
38
		$language = $phpbb_container->get('language');
39
		/** @type \phpbb\template\template $template Template object */
40
		$template = $phpbb_container->get('template');
41
		/** @type \sylver35\smiliescat\controller\admin_controller $admin_controller */
42
		$admin_controller = $phpbb_container->get('sylver35.smiliescat.admin.controller');
43
		/** @type \sylver35\smiliescat\core\category $category */
44
		$category = $phpbb_container->get('sylver35.smiliescat.category');
45
		/** @type \phpbb\request\request $request Request object */
46
		$request = $phpbb_container->get('request');
47
		// Make the $u_action url available in the admin controller
48
		$admin_controller->set_page_url($this->u_action);
49
		$action = (string) $request->variable('action', '');
50
		$on_id = (int) $request->variable('id', 0);
51
52
		$language->add_lang('smilies_category', 'sylver35/smiliescat');
53
		$this->tpl_name = 'category_' . strtolower($mode);
54
		$this->page_title = 'ACP_SC_' . strtoupper($mode);
55
		$meta = $category->get_version();
56
57
		switch ($mode)
58
		{
59
			case 'config':
60
				$admin_controller->acp_categories_config($on_id, $action, $mode);
61
			break;
62
63
			case 'smilies':
64
				$admin_controller->acp_smilies_category($on_id, $action);
65
			break;
66
67
			default:
68
				trigger_error('NO_MODE', E_USER_ERROR);
69
		}
70
71
		$template->assign_vars([
72
			'U_ACTION'			=> $this->u_action,
73
			'TITLE'				=> $language->lang($this->page_title),
74
			'TITLE_EXPLAIN'		=> $language->lang($this->page_title . '_EXPLAIN'),
75
			'CATEGORY_VERSION'	=> $language->lang('SC_VERSION_COPY', $meta['homepage'], $meta['version']),
76
		]);
77
	}
78
}
79