GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

TbDropdown::init()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 9.4285
cc 2
eloc 6
nc 2
nop 0
crap 6
1
<?php
2
/**
3
 *## TbDropdown class file.
4
 *
5
 *
6
 * @author Christoffer Niska <[email protected]>
7
 * @copyright Copyright &copy; Christoffer Niska 2012-
8
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
9
 */
10
11
Yii::import('booster.widgets.TbBaseMenu');
12
13
/**
14
 *## Bootstrap dropdown menu.
15
 *
16
 * @see http://twitter.github.com/bootstrap/javascript.html#dropdowns
17
 *
18
 * @package booster.widgets.navigation
19
 */
20
class TbDropdown extends TbBaseMenu {
21
	/**
22
	 *### .init()
23
	 *
24
	 * Initializes the widget.
25
	 */
26
	public function init() {
27
		
28
		parent::init();
29
30
		if (isset($this->htmlOptions['class'])) {
31
			$this->htmlOptions['class'] .= ' dropdown-menu';
32
		} else {
33
			$this->htmlOptions['class'] = 'dropdown-menu';
34
		}
35
	}
36
37
	/**
38
	 *### .renderMenuItem()
39
	 *
40
	 * Renders the content of a menu item.
41
	 * Note that the container and the sub-menus are not rendered here.
42
	 *
43
	 * @param array $item the menu item to be rendered. Please see {@link items} on what data might be in the item.
44
	 *
45
	 * @return string the rendered item
46
	 */
47
	protected function renderMenuItem($item) {
48
		
49
		if (isset($item['icon'])) {
50
			if (strpos($item['icon'], 'icon') === false && strpos($item['icon'], 'fa') === false) {
51
				$item['icon'] = 'icon-' . implode(' icon-', explode(' ', $item['icon']));
52
			}
53
54
			$item['label'] = '<i class="' . $item['icon'] . '"></i> ' . $item['label'];
55
		}
56
57
		if (!isset($item['linkOptions'])) {
58
			$item['linkOptions'] = array();
59
		}
60
61
		// TODO: Bootstrap 3 does not support submenu 
62
		// http://stackoverflow.com/questions/18023493/bootstrap-3-dropdown-sub-menu-missing
63
		// we may use this to support it 
64
		/* if (isset($item['items']) && !empty($item['items']) && empty($item['url'])) {
65
			$item['url'] = '#';
66
		} */
67
68
		$item['linkOptions']['tabindex'] = -1;
69
70
		if (isset($item['url'])) {
71
			return CHtml::link($item['label'], $item['url'], $item['linkOptions']);
72
		} else {
73
			return CHtml::link($item['label'], '#', array());
74
		}
75
	}
76
77
	/**
78
	 *### .getDividerCssClass()
79
	 *
80
	 * Returns the divider CSS class.
81
	 * @return string the class name
82
	 */
83
	public function getDividerCssClass()
84
	{
85
		return 'divider';
86
	}
87
88
	/**
89
	 *### .getDropdownCssClass()
90
	 *
91
	 * Returns the dropdown css class.
92
	 * @return string the class name
93
	 */
94
	public function getDropdownCssClass()
95
	{
96
		return 'dropdown-submenu';
97
	}
98
99
	/**
100
	 *### .isVertical()
101
	 *
102
	 * Returns whether this is a vertical menu.
103
	 * @return boolean the result
104
	 */
105
	public function isVertical()
106
	{
107
		return true;
108
	}
109
}
110