Completed
Push — master ( edb932...4a8b55 )
by Daniel
08:30
created

links   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
c 1
b 1
f 0
lcom 1
cbo 2
dl 0
loc 47
ccs 18
cts 18
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get_config() 0 9 1
A display() 0 22 2
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2013 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\sitemaker\blocks;
11
12
use blitze\sitemaker\services\menus\menu_block;
13
14
/**
15
* Links Block
16
* @package phpBB Sitemaker
17
*/
18
class links extends menu_block
19
{
20
	/** @var \phpbb\user */
21
	protected $user;
22
23
	/** @var \blitze\sitemaker\services\menus\display */
24
	protected $tree;
25
26
	/**
27
	 * {@inheritdoc}
28
	 */
29 1
	public function get_config(array $settings)
30
	{
31 1
		$menu_options = $this->get_menu_options();
32
33
		return array(
34 1
			'legend1'       => $this->user->lang('SETTINGS'),
35 1
			'menu_id'		=> array('lang' => 'MENU', 'validate' => 'int', 'type' => 'select', 'options' => $menu_options, 'default' => 0, 'explain' => false),
36 1
		);
37
	}
38
39
	/**
40
	 * {@inheritdoc}
41
	 */
42 5
	public function display(array $db_data, $editing = false)
43
	{
44 5
		$title = $this->user->lang('LINKS');
45 5
		$menu_id = $db_data['settings']['menu_id'];
46
47 5
		$data = $this->_get_menu($menu_id);
48
49 5
		if (!sizeof($data))
50 5
		{
51
			return array(
52 4
				'title'		=> $title,
53 4
				'content'	=> $this->_get_message($menu_id, $editing),
54 4
			);
55
		}
56
57 1
		$this->tree->display_list($data, $this->ptemplate, 'tree');
58
59
		return array(
60 1
			'title'     => $title,
61 1
			'content'   => $this->ptemplate->render_view('blitze/sitemaker', 'blocks/links.html', 'links_block'),
62 1
		);
63
	}
64
}
65