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

links::display()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 22
ccs 13
cts 13
cp 1
rs 9.2
cc 2
eloc 12
nc 2
nop 2
crap 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