From 443080608255a9ab9c3eb9182e5a2805a888cd69 Mon Sep 17 00:00:00 2001 From: Alexis Wilke Date: Sun, 16 May 2010 10:45:25 +0000 Subject: [PATCH] * Fixed the Inactive Parent anchor name so they all are unique. * Fixed the Devel menu name and identifier. * Added support for users to select multiple menus. --- simplemenu.admin.inc | 7 ++++--- simplemenu.install | 9 ++++++++ simplemenu.module | 33 ++++++++++++++++++++++++++++-- simplemenu_devel.module | 2 ++ simplemenu_inactive_parents.module | 4 +++- 5 files changed, 49 insertions(+), 6 deletions(-) diff --git a/simplemenu.admin.inc b/simplemenu.admin.inc index aaf09686..2b7be851 100644 --- a/simplemenu.admin.inc +++ b/simplemenu.admin.inc @@ -21,12 +21,13 @@ function simplemenu_admin_settings() { ); if (module_exists('menu')) { - $form['default_menu']['simplemenu_menu'] = array( + $form['default_menu']['simplemenu_menus'] = array( '#type' => 'select', + '#multiple' => TRUE, '#title' => t('Menu'), '#options' => menu_parent_options(menu_get_menus(), array('mlid' => 0)), // return complete tree - '#default_value' => variable_get('simplemenu_menu', 'navigation:0'), - '#description' => t('Select the menu to display.'), + '#default_value' => variable_get('simplemenu_menus', array('navigation:0')), + '#description' => t('Select the menu to display. Select multiple menus to show each one of them (use Ctrl or Shift to select multiple entries.) Please, avoid selecting a parent and a child from the same menu.'), ); } diff --git a/simplemenu.install b/simplemenu.install index cf2afcf6..fabbc263 100644 --- a/simplemenu.install +++ b/simplemenu.install @@ -41,4 +41,13 @@ function simplemenu_update_6003() { return array(); } +/** + * Implementation of hook_update_N(). + */ +function simplemenu_update_6004() { + // enable multiple menus selection + variable_set('simplemenu_menus', array(variable_get('simplemenu_menu', 'navigation:0'))); + return array(); +} + // vim: ts=2 sw=2 et syntax=php diff --git a/simplemenu.module b/simplemenu.module index f8fb2c5e..8d49d8a3 100644 --- a/simplemenu.module +++ b/simplemenu.module @@ -282,8 +282,37 @@ function simplemenu_get_menu() { // if a user turned off menu module but SimpleMenu was previously set // reset variable so a menu appears - $menu_name = module_exists('menu') ? variable_get('simplemenu_menu', 'navigation:0') : 'navigation:0'; - $tree = simplemenu_menu_tree($menu_name); + $all_menus = array('navigation:0'); + if (module_exists('menu')) { + $all_menus = variable_get('simplemenu_menus', $all_menus); + } + if (count($all_menus) > 1) { + // if menu is not enable then we cannot have a count other than 1 + $menu_titles = menu_get_menus(); + $tree = array(); + foreach ($all_menus as $full_name) { + list($menu_name, $mlid) = explode(':', $full_name); + $tree[] = array( + 'link' => array( + 'mlid' => $mlid, + 'menu_name' => $full_name, + 'hidden' => FALSE, + 'title' => $menu_titles[$menu_name], + 'href' => 'admin/settings/simplemenu', /// ??? -- we should not have a link here + 'in_active_trail' => FALSE, + 'has_children' => TRUE, + 'localized_options' => array( + 'attributes' => array('class' => 'simplemenu-top-level'), + ), + ), + 'below' => simplemenu_menu_tree($full_name), + ); + } + } + else { + reset($all_menus); + $tree = simplemenu_menu_tree(current($all_menus)); + } // allow other modules to modify the menu tree drupal_alter('simplemenu_tree', $tree); diff --git a/simplemenu_devel.module b/simplemenu_devel.module index 98fa8f2c..76e01b13 100644 --- a/simplemenu_devel.module +++ b/simplemenu_devel.module @@ -13,6 +13,8 @@ function simplemenu_devel_simplemenu_tree_alter(&$tree) { if (user_access('access devel information')) { $devel = array( 'link' => array( + 'mlid' => 0, + 'menu_name' => 'devel', 'hidden' => FALSE, 'title' => t('Devel module'), 'href' => 'admin/settings/devel', diff --git a/simplemenu_inactive_parents.module b/simplemenu_inactive_parents.module index 5620ce04..85cf8cd2 100644 --- a/simplemenu_inactive_parents.module +++ b/simplemenu_inactive_parents.module @@ -42,10 +42,12 @@ function simplemenu_theme_registry_alter(&$theme_registry) { */ function simplemenu_theme_menu_item_link($link) { global $theme; + static $cnt = 0; // this is a drop down? if (!empty($link['has_children']) && variable_get('simplemenu_running', FALSE)) { - return '' . $link['title'] . ''; + ++$cnt; + return '' . $link['title'] . ''; } // got a theme function?