Passed
Push — renovate/configure ( 97377d...3d37a9 )
by
unknown
26:52
created

picker::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 5
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 *
5
 * @package sitemaker
6
 * @copyright (c) 2013 Daniel A. (blitze)
7
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
8
 *
9
 */
10
11
namespace blitze\sitemaker\services\icons;
12
13
/**
14
 * Sitemaker icons
15
 */
16
class picker
17
{
18
	/** @var \phpbb\config\config */
19
	protected $config;
20
21
	/** @var \phpbb\language\language */
22
	protected $translator;
23
24
	/** @var \blitze\sitemaker\services\util */
25
	protected $util;
26
27
	/** @var \blitze\sitemaker\services\template */
28
	protected $ptemplate;
29
30
	/** @var string */
31
	protected $categories_file;
32
33
	/**
34
	 * Constructor
35
	 *
36
	 * @param \phpbb\config\config					$config					Config object
37
	 * @param \phpbb\language\language     			$translator     		Language object
38
	 * @param \blitze\sitemaker\services\util		$util					Sitemaker utility object
39
	 * @param \blitze\sitemaker\services\template	$ptemplate				Sitemaker Template object
40
	 * @param string								$categories_file		Categories file (json)
41
	 */
42
	public function __construct(\phpbb\config\config $config, \phpbb\language\language $translator, \blitze\sitemaker\services\util $util, \blitze\sitemaker\services\template $ptemplate, $categories_file)
43
	{
44
		$this->config          = $config;
45
		$this->translator      = $translator;
46
		$this->util            = $util;
47
		$this->ptemplate       = $ptemplate;
48
		$this->categories_file = $categories_file;
49
	}
50
51
	/**
52
	 * Load icon picker
53
	 */
54
	public function picker()
55
	{
56
		global $phpbb_root_path;
57
		$this->translator->add_lang('icons', 'blitze/sitemaker');
58
		$this->ptemplate->set_style(array('ext/blitze/sitemaker/styles', 'styles'));
59
60
		$this->util->add_assets(array(
61
			'css'	=> array_filter(array(
62
				defined('IN_ADMIN') ? $this->util->get_web_path() . 'assets/css/font-awesome.min.css' : '',
63
			))
64
		));
65
66
		$categories = '';
67
		$icons_tpl = 'fontawesome4';
68
69
		if (phpbb_version_compare($this->config['version'], '3.3.1', '>='))
70
		{
71
			$icons_tpl = 'fontawesome5';
72
			$categories = json_decode(file_get_contents($this->categories_file), true);
73
		}
74
75
		$this->ptemplate->assign_vars(array(
76
			'icons_tpl'		=> $icons_tpl,
77
			'categories'	=> $categories,
78
		));
79
80
		$this->ptemplate->set_filenames(array(
81
			'icons'	=> 'icons/picker.html'
82
		));
83
84
		return $this->ptemplate->assign_display('icons');
85
	}
86
}
87