helpers/TbHtml.php
public static function menu(array $items, $htmlOptions = array(), $depth = 0)
    {
        // todo: consider making this method protected.
        if (!empty($items)) {
            $htmlOptions['role'] = 'menu';
            $output = self::openTag('ul', $htmlOptions);
            foreach ($items as $itemOptions) {
                if (is_string($itemOptions)) {
                    if ($itemOptions == '---') {
                        $output .= self::menuDivider();
                    } else {
                        $output .= $itemOptions;
                    }
                } else {
                    if (TbArray::popValue('visible', $itemOptions, true)  === false) {
                        continue;
                    }
                    // todo: consider removing the support for htmlOptions.
                    $options = TbArray::popValue('htmlOptions', $itemOptions, array());
                    if (!empty($options)) {
                        $itemOptions = TbArray::merge($options, $itemOptions);
                    }
                    $label = TbArray::popValue('label', $itemOptions, '');
                    if (TbArray::popValue('active', $itemOptions, false)) {
                        self::addCssClass('active', $itemOptions);
                    }
                    if (TbArray::popValue('disabled', $itemOptions, false)) {
                        self::addCssClass('disabled', $itemOptions);
                    }
                    if (!isset($itemOptions['linkOptions'])) {
                        $itemOptions['linkOptions'] = array();
                    }
                    $icon = TbArray::popValue('icon', $itemOptions);
                    if (!empty($icon)) {
                        $label = self::icon($icon) . ' ' . $label;
                    }
                    $items = TbArray::popValue('items', $itemOptions, array());
                    $url = TbArray::popValue('url', $itemOptions, false);
                    if (empty($items)) {
                        if (!$url) {
                            $output .= self::menuHeader($label);
                        } else {
                            $itemOptions['linkOptions']['tabindex'] = -1;
                            $output .= self::menuLink($label, $url, $itemOptions);
                        }
                    } else {
                        $output .= self::menuDropdown($label, $url, $items, $itemOptions, $depth);
                    }
                }
            }
            $output .= '</ul>';
            return $output;
        } else {
            return '';
        }
    }
public static function menu(array $items, $htmlOptions = array(), $depth = 0)
    {
        // todo: consider making this method protected.
        if (!empty($items)) {
            $htmlOptions['role'] = 'menu';
            $output = self::openTag('ul', $htmlOptions);
            foreach ($items as $itemOptions) {
                if (is_string($itemOptions)) {
                    if ($itemOptions == '---') {
                        $output .= self::menuDivider();
                    } else {
                        $output .= $itemOptions;
                    }
                } else {
                    if (TbArray::popValue('visible', $itemOptions, true)  === false) {
                        continue;
                    }
                    // todo: consider removing the support for htmlOptions.
                    $options = TbArray::popValue('htmlOptions', $itemOptions, array());
                    if (!empty($options)) {
                        $itemOptions = TbArray::merge($options, $itemOptions);
                    }
                    $label = TbArray::popValue('label', $itemOptions, '');
                    if (TbArray::popValue('active', $itemOptions, false)) {
                        self::addCssClass('active', $itemOptions);
                    }
                    if (TbArray::popValue('disabled', $itemOptions, false)) {
                        self::addCssClass('disabled', $itemOptions);
                    }
                    if (!isset($itemOptions['linkOptions'])) {
                        $itemOptions['linkOptions'] = array();
                    }
                    $icon = TbArray::popValue('icon', $itemOptions);
                    if (!empty($icon)) {
                        $label = self::icon($icon) . ' ' . $label;
                    }
                    $items = TbArray::popValue('items', $itemOptions, array());
                    $url = TbArray::popValue('url', $itemOptions, false);
                    if (empty($items)) {
                        if (!$url) {
                            $output .= self::menuHeader($label);
                        } else {
                            $itemOptions['linkOptions']['tabindex'] = -1;
                            $output .= self::menuLink($label, $url, $itemOptions);
                        }
                    } else {
                        $output .= self::menuDropdown($label, $url, $items, $itemOptions, $depth);
                    }
                }
            }
            $output .= '</ul>';
            return $output;
        } else {
            return '';
        }
    }
public static function menu ( array $ items , $ htmlOptions = array ( ) , $ depth = 0 ) { // todo: consider making this method protected.
 if ( ! empty ( $ items ) ) { $ htmlOptions [ 'role' ] = 'menu' ; $ output = self :: openTag ( 'ul' , $ htmlOptions ) ; foreach ( $ items as $ itemOptions ) { if ( is_string ( $ itemOptions ) ) { if ( $ itemOptions == '---' ) { $ output .= self :: menuDivider ( ) ; } else { $ output .= $ itemOptions ; } } else { if ( TbArray :: popValue ( 'visible' , $ itemOptions , true ) === false ) { continue ; } // todo: consider removing the support for htmlOptions.
 $ options = TbArray :: popValue ( 'htmlOptions' , $ itemOptions , array ( ) ) ; if ( ! empty ( $ options ) ) { $ itemOptions = TbArray :: merge ( $ options , $ itemOptions ) ; } $ label = TbArray :: popValue ( 'label' , $ itemOptions , '' ) ; if ( TbArray :: popValue ( 'active' , $ itemOptions , false ) ) { self :: addCssClass ( 'active' , $ itemOptions ) ; } if ( TbArray :: popValue ( 'disabled' , $ itemOptions , false ) ) { self :: addCssClass ( 'disabled' , $ itemOptions ) ; } if ( ! isset ( $ itemOptions [ 'linkOptions' ] ) ) { $ itemOptions [ 'linkOptions' ] = array ( ) ; } $ icon = TbArray :: popValue ( 'icon' , $ itemOptions ) ; if ( ! empty ( $ icon ) ) { $ label = self :: icon ( $ icon ) . ' ' . $ label ; } $ items = TbArray :: popValue ( 'items' , $ itemOptions , array ( ) ) ; $ url = TbArray :: popValue ( 'url' , $ itemOptions , false ) ; if ( empty ( $ items ) ) { if ( ! $ url ) { $ output .= self :: menuHeader ( $ label ) ; } else { $ itemOptions [ 'linkOptions' ] [ 'tabindex' ] = - 1 ; $ output .= self :: menuLink ( $ label , $ url , $ itemOptions ) ; } } else { $ output .= self :: menuDropdown ( $ label , $ url , $ items , $ itemOptions , $ depth ) ; } } } $ output .= '</ul>' ; return $ output ; } else { return '' ; } }
Generates a menu.
@param array $items the menu items.
@param array $htmlOptions additional HTML attributes.
@param integer $depth the current depth.
@return string the generated menu.
Generates a menu .