You are here

function nice_menus_block_view in Nice Menus 7.3

Same name and namespace in other branches
  1. 7.2 nice_menus.module \nice_menus_block_view()

Implements hook_block_view().

File

./nice_menus.module, line 232
Module to enable CSS dropdown and flyout menus.

Code

function nice_menus_block_view($delta = 1) {

  // Build the Nice menu for the block.
  $parts = explode(':', variable_get('nice_menus_menu_' . $delta, 'navigation:0'));
  if (!isset($parts[1])) {
    $parts[1] = '0';
  }
  list($menu_name, $mlid) = $parts;
  $direction = variable_get('nice_menus_type_' . $delta, 'right');
  $depth = variable_get('nice_menus_depth_' . $delta, '-1');
  $respect_expanded = variable_get('nice_menus_respect_expand_' . $delta, 0);
  if ($output = theme('nice_menus', array(
    'id' => $delta,
    'menu_name' => $menu_name,
    'mlid' => $mlid,
    'direction' => $direction,
    'depth' => $depth,
    'respect_expanded' => $respect_expanded,
  ))) {
    $block['content']['#markup'] = $output['content'];
    if (variable_get('nice_menus_type_' . $delta, 'right') == 'down') {
      $class = 'nice-menu-hide-title';
    }
    else {
      $class = 'nice-menu-show-title';
    }

    // If we're building the navigation block
    // use the same block title logic as menu module.
    global $user;
    if ($output['subject'] == t('navigation') && $user->uid) {
      $subject = $user->name;
    }
    else {
      $subject = $output['subject'];
    }
    $block['subject'] = '<span class="' . $class . '">' . check_plain($subject) . '</span>';
    $block['content']['#contextual_links']['simple_menus'] = array(
      'admin/structure/menu/manage',
      array(
        $menu_name,
      ),
    );
  }
  else {
    $block['content'] = FALSE;
  }
  return $block;
}