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

menu   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 64
ccs 30
cts 30
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get_config() 0 12 1
B display() 0 25 2
A get_depth_options() 0 10 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
* Menu Block
16
* @package phpBB Sitemaker Main Menu
17
*/
18
class menu 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 1
		$depth_options = $this->get_depth_options();
30
31
		return array(
32 1
			'legend1'       => 'SETTINGS',
33 1
			'menu_id'		=> array('lang' => 'MENU', 'validate' => 'int', 'type' => 'select', 'options' => $menu_options, 'default' => 0, 'explain' => false),
34 1
			'expanded'		=> array('lang' => 'EXPANDED', 'validate' => 'bool', 'type' => 'checkbox', 'options' => array(1 => ''), 'default' => 0, 'explain' => false),
35 1
			'max_depth'		=> array('lang' => 'MAX_DEPTH', 'validate' => 'int', 'type' => 'select', 'options' => $depth_options, 'default' => 3, 'explain' => false),
36 1
		);
37
	}
38
39
	/**
40
	 * {@inheritdoc}
41
	 */
42 12
	public function display(array $db_data, $editing = false)
43
	{
44 12
		$title = 'MENU';
45 12
		$menu_id = $db_data['settings']['menu_id'];
46
47 12
		$data = $this->get_menu($menu_id);
48
49 12
		if (!sizeof($data))
50 12
		{
51
			return array(
52 4
				'title'		=> $title,
53 4
				'content'	=> $this->get_message($menu_id, $editing),
54 4
				'status'	=> (int) !$editing,
55 4
			);
56
		}
57
58 8
		$this->tree->set_params($db_data['settings']);
59 8
		$this->tree->display_navlist($data, $this->ptemplate, 'tree');
60 8
		$this->tree->generate_breadcrumb($data);
61
62
		return array(
63 8
			'title'     => $title,
64 8
			'content'   => $this->ptemplate->render_view('blitze/sitemaker', 'blocks/menu.html', 'menu_block'),
65 8
		);
66
	}
67
68
	/**
69
	 * @return array
70
	 */
71 1
	protected function get_depth_options()
72
	{
73 1
		$options = array();
74 1
		for ($i = 3; $i < 10; $i++)
75
		{
76 1
			$options[$i] = $i;
77 1
		}
78
79 1
		return $options;
80
	}
81
}
82