Completed
Push — develop ( 18ce4b...3c36de )
by Daniel
11:04
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 0
CRAP Score 2

Importance

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