Completed
Push — develop ( 3c36de...4211b9 )
by Daniel
10:56
created

links::get_config()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
ccs 5
cts 5
cp 1
cc 1
eloc 5
nc 1
nop 1
crap 1
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 \blitze\sitemaker\services\menus\display */
21
	protected $tree;
22
23
	/**
24
	 * {@inheritdoc}
25
	 */
26 1
	public function get_config(array $settings)
27
	{
28 1
		$menu_options = $this->get_menu_options();
29
30
		return array(
31 1
			'legend1'       => 'SETTINGS',
32 1
			'menu_id'		=> array('lang' => 'MENU', 'validate' => 'int', 'type' => 'select', 'options' => $menu_options, 'default' => 0, 'explain' => false),
33 1
		);
34
	}
35
36
	/**
37
	 * {@inheritdoc}
38
	 */
39 5
	public function display(array $db_data, $editing = false)
40
	{
41 5
		$title = 'LINKS';
42 5
		$menu_id = $db_data['settings']['menu_id'];
43
44 5
		$data = $this->get_menu($menu_id);
45
46 5
		if (!sizeof($data))
47 5
		{
48
			return array(
49 4
				'title'		=> $title,
50 4
				'content'	=> $this->get_message($menu_id, $editing),
51 4
				'status'	=> (int) !$editing,
52 4
			);
53
		}
54
55 1
		$this->tree->display_list($data, $this->ptemplate, 'tree');
56
57
		return array(
58 1
			'title'     => $title,
59 1
			'content'   => $this->ptemplate->render_view('blitze/sitemaker', 'blocks/links.html', 'links_block'),
60 1
		);
61
	}
62
}
63