You are here

function ultimenu_regions in Ultimenu 7

The array of available Ultimenu regions based on enabled menu items.

Parameters

string $delta: The block delta which is the menu name.

Return value

array An array of regions definition dependent on available main-menu items.

See also

menu_navigation_links()

3 calls to ultimenu_regions()
ultimenu_admin_settings in includes/ultimenu.admin.inc
Menu callback for 'admin/structure/ultimenu'.
ultimenu_get_ultimenu_theme_info in includes/ultimenu.utilities.inc
Gets Ultimenu regions from the default theme .info.
ultimenu_regions_enabled in includes/ultimenu.utilities.inc
Returns the array of enabled Ultimenu regions based on enabled settings.
1 string reference to 'ultimenu_regions'
ultimenu_admin_settings_form_submit in includes/ultimenu.admin.inc
Submit handler for ultimenu_admin_settings().

File

includes/ultimenu.utilities.inc, line 106
Misc functions that hardly change.

Code

function ultimenu_regions($delta = NULL) {
  $regions =& drupal_static(__FUNCTION__);
  if (!isset($regions)) {
    $blocks = ultimenu_get_settings('blocks');
    $goodies = ultimenu_get_settings('goodies');
    $is_mlid = !empty($goodies['ultimenu-mlid']) ? TRUE : FALSE;
    $menu_blocks = is_array($blocks) ? array_filter($blocks) : array(
      $blocks,
    );
    $menus = array();
    if ($delta) {
      $menus[$delta] = menu_navigation_links($delta);
    }
    else {
      foreach ($menu_blocks as $menu_name => $title) {
        $menus[$menu_name] = menu_navigation_links($menu_name);
      }
    }

    // Allow alteration.
    drupal_alter('ultimenu_menus_info', $menus);
    $regions = array();
    foreach ($menus as $menu_key => $menu_items) {
      foreach ($menu_items as $item_key => $item) {
        $name_id = ultimenu_truncate_menu_property($menu_key);
        $name_id_nice = str_replace("_", " ", $name_id);
        $menu_title = check_plain($item['title']);
        if ($is_mlid) {
          $item_id = str_replace('menu-', '', $item_key);
        }
        else {
          $item_id = ultimenu_truncate_menu_property($menu_title, 28);
        }
        $regions["ultimenu_{$name_id}_{$item_id}"] = "Ultimenu:{$name_id_nice}: {$menu_title}";
        $regions = array_unique($regions);
      }
    }

    // Allow alteration.
    drupal_alter('ultimenu_regions_info', $regions);
  }
  return $regions;
}