links   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 84
ccs 26
cts 26
cp 1
rs 10
c 0
b 0
f 0
wmc 8

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A display() 0 16 2
A get_message() 0 9 3
A get_template() 0 3 1
A get_config() 0 8 1
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\blocks;
12
13
use blitze\sitemaker\services\blocks\driver\block;
14
15
/**
16
 * Links Block
17
 * @package phpBB Sitemaker
18
 */
19
class links extends block
20
{
21
	/** @var \phpbb\language\language */
22
	protected $language;
23
24
	/** @var \blitze\sitemaker\services\menus\navigation */
25
	protected $navigation;
26
27
	/** @var string */
28
	protected $title = 'LINKS';
29
30
	/** @var bool */
31
	protected $is_navigation = false;
32
33
	/**
34
	 * Constructor
35
	 *
36
	 * @param \phpbb\language\language						$language			Language object
37
	 * @param \blitze\sitemaker\services\menus\navigation	$navigation			sitemaker navigation object
38
	 */
39
	public function __construct(\phpbb\language\language $language, \blitze\sitemaker\services\menus\navigation $navigation)
40
	{
41 19
		$this->language = $language;
42
		$this->navigation = $navigation;
43 19
	}
44 19
45 19
	/**
46
	 * {@inheritdoc}
47
	 */
48
	public function get_config(array $settings)
49
	{
50 1
		$menu_options = $this->navigation->get_menu_options();
51
		$append = '<a href="' . $this->navigation->get_menus_admin_url() . '" target="_blank" title="' . $this->language->lang('MANAGE_MENUS') . '"><i class="fa fa-cog fa-lg fa-green"></i></a>';
52 1
53
		return array(
54
			'legend1'       => 'SETTINGS',
55 1
			'menu_id'		=> array('lang' => 'MENU', 'validate' => 'int', 'type' => 'select', 'options' => $menu_options, 'default' => 0, 'explain' => false, 'append' => $append),
56 1
		);
57 1
	}
58
59
	/**
60
	 * {@inheritdoc}
61
	 */
62
	public function display(array $db_data, $editing = false)
63 17
	{
64
		$menu_id = $db_data['settings']['menu_id'];
65 17
66
		if ($data = $this->navigation->build_menu($menu_id, $this->is_navigation, $db_data['settings']))
67 17
		{
68 17
			return array(
69
				'title'		=> $this->title,
70 8
				'data'		=> $data,
71 8
			);
72 8
		}
73 8
74
		return array(
75
			'title'     => $this->title,
76
			'status'	=> (int) !$editing,
77 9
			'content'   => $this->get_message($menu_id, $editing),
78 9
		);
79 10
	}
80
81
	/**
82
	 * @param int $menu_id
83
	 * @param bool $editing
84
	 * @return string
85
	 */
86
	protected function get_message($menu_id, $editing)
87 8
	{
88
		$msg_key = '';
89 8
		if ($editing)
90
		{
91 8
			$msg_key = ($menu_id) ? 'MENU_NO_ITEMS' : 'SELECT_MENU';
92 4
		}
93 4
94
		return $this->language->lang($msg_key);
95 8
	}
96
97
	/**
98
	 * {@inheritdoc}
99
	 */
100
	public function get_template()
101
	{
102
		return '@blitze_sitemaker/blocks/lists.html';
103
	}
104
}
105