PATH:
home
/
letacommog
/
letaweb
/
protected
/
extensions
/
yiibooster
/
widgets
<?php /** *## TbBaseMenu class file. * * @author Christoffer Niska <ChristofferNiska@gmail.com> * @copyright Copyright © Christoffer Niska 2012- * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php) */ Yii::import('zii.widgets.CMenu'); /** *## Base class for menu in Booster * * @package booster.widgets.navigation */ abstract class TbBaseMenu extends CMenu { /** *### .getDividerCssClass() * * Returns the divider css class. * @return string the class name */ abstract public function getDividerCssClass(); /** *### .getDropdownCssClass() * * Returns the dropdown css class. * @return string the class name */ abstract public function getDropdownCssClass(); /** *### .isVertical() * * Returns whether this is a vertical menu. * @return boolean the result */ abstract public function isVertical(); /** *### .renderMenu() * * Renders the menu items. * * @param array $items menu items. Each menu item will be an array with at least two elements: 'label' and 'active'. * It may have three other optional elements: 'items', 'linkOptions' and 'itemOptions'. */ protected function renderMenu($items) { $n = count($items); if ($n > 0) { echo CHtml::openTag('ul', $this->htmlOptions) . "\n"; $count = 0; foreach ($items as $item) { $count++; if (isset($item['divider'])) { echo "<li class=\"{$this->getDividerCssClass()}\"></li>\n"; } else { $options = isset($item['itemOptions']) ? $item['itemOptions'] : array(); $classes = array(); if ($item['active'] && $this->activeCssClass != '') { $classes[] = $this->activeCssClass; } if ($count === 1 && $this->firstItemCssClass !== null) { $classes[] = $this->firstItemCssClass; } if ($count === $n && $this->lastItemCssClass !== null) { $classes[] = $this->lastItemCssClass; } if ($this->itemCssClass !== null) { $classes[] = $this->itemCssClass; } if (isset($item['items'])) { $classes[] = $this->getDropdownCssClass(); } if (isset($item['disabled'])) { $classes[] = 'disabled'; } if (!empty($classes)) { $classes = implode(' ', $classes); if (!empty($options['class'])) { $options['class'] .= ' ' . $classes; } else { $options['class'] = $classes; } } echo CHtml::openTag('li', $options) . "\n"; $menu = $this->renderMenuItem($item); if (isset($this->itemTemplate) || isset($item['template'])) { $template = isset($item['template']) ? $item['template'] : $this->itemTemplate; echo strtr($template, array('{menu}' => $menu)); } else { echo $menu; } if (isset($item['items']) && !empty($item['items'])) { $dropdownOptions = array( 'encodeLabel' => $this->encodeLabel, 'htmlOptions' => isset($item['submenuOptions']) ? $item['submenuOptions'] : $this->submenuHtmlOptions, 'items' => $item['items'], ); $dropdownOptions['id'] = isset($dropdownOptions['htmlOptions']['id']) ? $dropdownOptions['htmlOptions']['id'] : null; $this->controller->widget('booster.widgets.TbDropdown', $dropdownOptions); } echo "</li>\n"; } } echo "</ul>\n"; } } /** *### .renderMenuItem() * * Renders the content of a menu item. * Note that the container and the sub-menus are not rendered here. * * @param array $item the menu item to be rendered. Please see {@link items} on what data might be in the item. * * @return string the rendered item */ protected function renderMenuItem($item) { if (isset($item['icon'])) { if (strpos($item['icon'], 'icon') === false && strpos($item['icon'], 'fa') === false) { $item['icon'] = 'glyphicon glyphicon-' . implode(' glyphicon-', explode(' ', $item['icon'])); $item['label'] = "<span class='" . $item['icon'] . "'></span>\r\n" . $item['label']; } else { $item['label'] = "<i class='" . $item['icon'] . "'></i>\r\n" . $item['label']; } } if (!isset($item['linkOptions'])) { $item['linkOptions'] = array(); } if (isset($item['items']) && !empty($item['items'])) { if (empty($item['url'])) { $item['url'] = '#'; } if (isset($item['linkOptions']['class'])) { $item['linkOptions']['class'] .= ' dropdown-toggle'; } else { $item['linkOptions']['class'] = 'dropdown-toggle'; } $item['linkOptions']['data-toggle'] = 'dropdown'; $item['label'] .= ' <span class="caret"></span>'; } if (isset($item['url'])) { return CHtml::link($item['label'], $item['url'], $item['linkOptions']); } else { return $item['label']; } } /** *### .normalizeItems() * * Normalizes the {@link items} property so that the 'active' state is properly identified for every menu item. * * @param array $items the items to be normalized. * @param string $route the route of the current request. * @param boolean $active whether there is an active child menu item. * * @return array the normalized menu items */ protected function normalizeItems($items, $route, &$active) { foreach ($items as $i => $item) { if (!is_array($item)) { $item = array('divider' => true); } else { if (!isset($item['itemOptions'])) { $item['itemOptions'] = array(); } $classes = array(); if (!isset($item['url']) && !isset($item['items']) && $this->isVertical()) { $item['header'] = true; $classes[] = 'nav-header'; } if (!empty($classes)) { $classes = implode($classes, ' '); if (isset($item['itemOptions']['class'])) { $item['itemOptions']['class'] .= ' ' . $classes; } else { $item['itemOptions']['class'] = $classes; } } } $items[$i] = $item; } return parent::normalizeItems($items, $route, $active); } }
[+]
..
[-] TbTabView.php
[edit]
[-] TbNavbar.php
[edit]
[-] TbHighCharts.php
[edit]
[-] TbPager.php
[edit]
[-] TbLabel.php
[edit]
[-] TbActiveForm.php
[edit]
[-] TbPanel.php
[edit]
[-] TbJsonButtonColumn.php
[edit]
[-] TbModalManager.php
[edit]
[-] TbToggleColumn.php
[edit]
[-] TbUiLayout.php
[edit]
[-] TbBaseMenu.php
[edit]
[-] widgets.md
[edit]
[-] TbEditableDetailView.php
[edit]
[-] TbButtonGroup.php
[edit]
[-] TbEditable.php
[edit]
[-] TbFileUpload.php
[edit]
[-] TbEditableField.php
[edit]
[-] TbTags.php
[edit]
[-] TbFormButtonElement.php
[edit]
[-] TbFormInputElement.php
[edit]
[-] TbJsonPager.php
[edit]
[-] TbCollapse.php
[edit]
[-] TbBulkActions.php
[edit]
[-] TbRelationalColumn.php
[edit]
[-] TbTabs.php
[edit]
[-] TbModal.php
[edit]
[-] TbExtendedGridView.php
[edit]
[-] TbJumbotron.php
[edit]
[-] TbImageGallery.php
[edit]
[-] TbWidget.php
[edit]
[-] TbMenu.php
[edit]
[-] TbProgress.php
[edit]
[-] TbButtonColumn.php
[edit]
[-] TbJsonToggleColumn.php
[edit]
[-] TbJsonPickerColumn.php
[edit]
[-] TbColorPicker.php
[edit]
[-] TbButtonGroupColumn.php
[edit]
[-] TbSwitch.php
[edit]
[-] TbHeroUnit.php
[edit]
[-] TbDatePicker.php
[edit]
[-] TbJsonCheckBoxColumn.php
[edit]
[-] TbButton.php
[edit]
[-] TbTypeahead.php
[edit]
[-] TbForm.php
[edit]
[-] TbPassfield.php
[edit]
[-] TbEditableColumn.php
[edit]
[-] TbMarkdownEditorJs.php
[edit]
[-] TbPopoverColumn.php
[edit]
[-] TbMarkdownEditor.php
[edit]
[-] TbAlert.php
[edit]
[-] TbGroupGridView.php
[edit]
[-] TbBaseInputWidget.php
[edit]
[-] TbWizard.php
[edit]
[-] TbGroupButtonColumn.php
[edit]
[-] TbExtendedFilter.php
[edit]
[-] TbGoogleVisualizationChart.php
[edit]
[-] TbHtml5Editor.php
[edit]
[-] TbGridView.php
[edit]
[-] TbListView.php
[edit]
[-] TbTimePicker.php
[edit]
[-] TbJsonGridView.php
[edit]
[-] TbCKEditor.php
[edit]
[-] TbTotalSumColumn.php
[edit]
[-] TbDateRangePicker.php
[edit]
[-] TbBadge.php
[edit]
[-] TbDropdown.php
[edit]
[-] TbBreadcrumbs.php
[edit]
[-] TbJsonGridColumn.php
[edit]
[-] TbDateTimePicker.php
[edit]
[-] TbDataColumn.php
[edit]
[-] TbCarousel.php
[edit]
[-] TbJsonDataColumn.php
[edit]
[-] TbRedactorJs.php
[edit]
[-] TbThumbnails.php
[edit]
[-] TbScrollSpy.php
[edit]
[-] TbDetailView.php
[edit]
[+]
input
[-] TbSelect2.php
[edit]
[-] TbImageColumn.php
[edit]