HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
TbMenu.php
Go to the documentation of this file.
1 <?php
10 Yii::import('booster.widgets.TbBaseMenu');
11 
19 class TbMenu extends TbBaseMenu {
20 
21  // Menu types.
22  const TYPE_TABS = 'tabs';
23  const TYPE_PILLS = 'pills';
24  const TYPE_LIST = 'list';
25  const TYPE_NAVBAR = 'navbar';
26 
32  public $type;
33 
37  public $scrollspy;
38 
42  public $stacked = false;
43 
47  public $justified = false;
48 
49 
53  public $dropup = false;
54 
60  public function init() {
61 
62  parent::init();
63 
64  $classes = array('nav');
65 
66  $validTypes = array(self::TYPE_TABS, self::TYPE_PILLS, self::TYPE_LIST, self::TYPE_NAVBAR);
67 
68  if (isset($this->type) && in_array($this->type, $validTypes)) {
69  $classes[] = $this->type === self::TYPE_NAVBAR ? 'navbar-nav' : 'nav-' . $this->type;
70  }
71 
72  if ($this->stacked && $this->type !== self::TYPE_LIST) {
73  $classes[] = 'nav-stacked';
74  }
75 
76  if ($this->justified && $this->type !== self::TYPE_LIST) {
77  $classes[] = 'nav-justified';
78  }
79 
80  if ($this->dropup === true) {
81  $classes[] = 'dropup';
82  }
83 
84  if (isset($this->scrollspy)) {
85  $scrollspy = is_string($this->scrollspy) ? array('target' => $this->scrollspy) : $this->scrollspy;
86  $this->widget('booster.widgets.TbScrollSpy', $scrollspy);
87  }
88 
89  if (!empty($classes)) {
90  $classes = implode(' ', $classes);
91  if (isset($this->htmlOptions['class'])) {
92  $this->htmlOptions['class'] .= ' ' . $classes;
93  } else {
94  $this->htmlOptions['class'] = $classes;
95  }
96  }
97  }
98 
106  public function getDividerCssClass() {
107 
108  return (isset($this->type) && $this->type === self::TYPE_LIST) ? 'nav-divider' : 'divider-vertical';
109  }
110 
118  public function getDropdownCssClass() {
119 
120  return 'dropdown';
121  }
122 
130  public function isVertical() {
131 
132  return isset($this->type) && $this->type === self::TYPE_LIST;
133  }
134 }