? nice-menus-d7-2.patch
Index: nice_menus.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nice_menus/nice_menus.info,v
retrieving revision 1.6
diff -u -p -r1.6 nice_menus.info
--- nice_menus.info	14 Nov 2007 04:30:26 -0000	1.6
+++ nice_menus.info	29 Mar 2010 21:48:24 -0000
@@ -2,4 +2,7 @@
 name = Nice Menus
 description = CSS/jQuery drop-down, drop-right and drop-left menus to be placed in blocks
 dependencies[] = menu
-core = 6.x
+core = 7.x
+files[] = nice_menus.info
+files[] = nice_menus.install
+files[] = nice_menus.module
\ No newline at end of file
Index: nice_menus.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nice_menus/nice_menus.module,v
retrieving revision 1.62
diff -u -p -r1.62 nice_menus.module
--- nice_menus.module	6 May 2009 15:33:49 -0000	1.62
+++ nice_menus.module	29 Mar 2010 21:48:24 -0000
@@ -28,7 +28,7 @@ function nice_menus_help($path, $arg) {
 /**
  * Implementation of hook_form_alter().
  */
-function nice_menus_form_alter(&$form, $form_state, $form_id) {
+function nice_menus_form_alter(&$form, &$form_state, $form_id) {
   switch ($form_id) {
     case 'system_theme_settings':
 
@@ -135,23 +135,58 @@ function nice_menus_settings_validate($f
   }
 }
 
+
+
 /**
- * Implementation of hook_block().
+ * Implementation of hook_block_view().
  */
-function nice_menus_block($op = 'list', $delta = 0, $edit = array()) {
+
+function nice_menus_block_view($delta) {
   global $user;
+  // Build the Nice menu for the block.
+  list($menu_name, $mlid) = explode(':', variable_get('nice_menus_menu_'. $delta, 'navigation:0'));
+  $direction = variable_get('nice_menus_type_'. $delta, 'right');
+  $depth = variable_get('nice_menus_depth_'. $delta, '-1');
+  if ($output = theme('nice_menus', array('id' => $delta, 'menu_name' => $menu_name, 'mlid' => $mlid, 'direction' => $direction, 'depth' => $depth, 'menu' => NULL))) {
+    $block['content'] = $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.
+    if ($output['subject'] == t('Navigation') && $user->uid) {
+      $subject = $user->name;
+    }
+    else {
+      $subject = $output['subject'];
+    }
+    $block['subject'] = '<span class="'. $class .'">'. check_plain($subject) .'</span>';
+  }
+  else {
+    $block['content'] = FALSE;
+  }
+  return $block;
+}
+
+/**
+ *Implementation of hook_block_save().
+ */
+function nice_menus_block_save($delta, $edit) {
+      variable_set('nice_menus_name_'. $delta, $edit['nice_menus_name_'. $delta]);
+      variable_set('nice_menus_menu_'. $delta, $edit['nice_menus_menu_'. $delta]);
+      variable_set('nice_menus_depth_'. $delta, $edit['nice_menus_depth_'. $delta]);
+      variable_set('nice_menus_type_'. $delta, $edit['nice_menus_type_'. $delta]);
+}
+
 
-  switch ($op) {
-    case 'list':
-      for ($i = 1; $i <= variable_get('nice_menus_number', '2'); $i++) {
-        $blocks[$i]['info'] = variable_get('nice_menus_name_'. $i, 'Nice menu '. $i) .' (Nice menu)';
-        // We have too many things changing per user, per page to cache.
-        $blocks[$i]['cache'] = BLOCK_NO_CACHE;
-      }
-      return $blocks;
-    break;
 
-    case 'configure':
+/**
+ *Implementation of hook_block_configure().
+ */
+function nice_menus_block_configure($delta) {
       $form['nice_menus_name_'. $delta] = array(
         '#type' => 'textfield',
         '#title' => t('Menu Name'),
@@ -162,7 +197,8 @@ function nice_menus_block($op = 'list', 
         '#title' => t('Menu Parent'),
         '#description' => t('The menu parent from which to show a Nice menu.'),
         '#default_value' => variable_get('nice_menus_menu_'. $delta, 'navigation:0'),
-        '#options' => menu_parent_options(menu_get_menus(), 0),
+        //This has changed in d7  menu_parent_options is slightly different.
+        '#options' => menu_parent_options(menu_get_menus(), array('mlid' => 0)),
       );
       $form['nice_menus_depth_'. $delta] = array(
        '#type' => 'select',
@@ -179,46 +215,23 @@ function nice_menus_block($op = 'list', 
         '#options' => drupal_map_assoc(array('right', 'left', 'down')),
       );
       return $form;
-    break;
+}
 
-    case 'save':
-      variable_set('nice_menus_name_'. $delta, $edit['nice_menus_name_'. $delta]);
-      variable_set('nice_menus_menu_'. $delta, $edit['nice_menus_menu_'. $delta]);
-      variable_set('nice_menus_depth_'. $delta, $edit['nice_menus_depth_'. $delta]);
-      variable_set('nice_menus_type_'. $delta, $edit['nice_menus_type_'. $delta]);
-    break;
 
-    case 'view':
-      // Build the Nice menu for the block.
-      list($menu_name, $mlid) = explode(':', variable_get('nice_menus_menu_'. $delta, 'navigation:0'));
-      $direction = variable_get('nice_menus_type_'. $delta, 'right');
-      $depth = variable_get('nice_menus_depth_'. $delta, '-1');
-      if ($output = theme('nice_menus', $delta, $menu_name, $mlid, $direction, $depth)) {
-        $block['content'] = $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.
-        if ($output['subject'] == t('Navigation') && $user->uid) {
-          $subject = $user->name;
-        }
-        else {
-          $subject = $output['subject'];
-        }
-        $block['subject'] = '<span class="'. $class .'">'. check_plain($subject) .'</span>';
-      }
-      else {
-        $block['content'] = FALSE;
-      }
-      return $block;
-    break;
+
+/**
+ * Implementation of hook_block_info().
+ */
+function nice_menus_block_info() {
+  for ($i = 1; $i <= variable_get('nice_menus_number', '2'); $i++) {
+    $blocks[$i]['info'] = variable_get('nice_menus_name_'. $i, 'Nice menu '. $i) .' (Nice menu)';
+    // We have too many things changing per user, per page to cache.
+    $blocks[$i]['cache'] = DRUPAL_NO_CACHE;
   }
+  return $blocks;
 }
 
+
 /**
  * Implementation of hook_theme().
  */
@@ -331,16 +344,19 @@ function nice_menus_build_page_trail($pa
  * @return
  *   An HTML string of properly nested Nice menu lists.
  */
-function theme_nice_menus_tree($menu_name, $mlid = NULL, $depth = -1, $menu = NULL) {
+function theme_nice_menus_tree($variables) { 
+  $menu_name = $variables['menu_name'];
+  $mlid = $variables['mlid'];
+  $depth = $variables['depth'];
+  $menu = $variables['menu'];
+  
   // Load the full menu array.
   $menu = isset($menu) ? $menu : menu_tree_all_data($menu_name);
-
   if (isset($menu)) {
     $page_menu = menu_tree_page_data($menu_name);
     $trail = nice_menus_build_page_trail($page_menu);
     unset($page_menu);
   }
-
   // Allow i18n module to translate strings where available.
   if(module_exists('i18nmenu')) {
     i18nmenu_localize_tree($menu);
@@ -370,7 +386,7 @@ function theme_nice_menus_tree($menu_nam
   // Otherwise just set a title and move on.
   else {
     // Get the title from the DB since we don't have it in the $menu.
-    $result = db_result(db_query("SELECT title FROM {menu_custom} WHERE menu_name = '%s'", $menu_name));
+    $result = db_query("SELECT title FROM {menu_custom} WHERE menu_name = :menu_name", array(':menu_name' => $menu_name))->fetchField();
     $title = check_plain($result);
   }
 
@@ -380,7 +396,7 @@ function theme_nice_menus_tree($menu_nam
   if ($menu) {
     // Set the total menu depth counting from this parent if we need it.
     $depth =  ($depth > 0) ? ($parent_depth + $depth) : $depth;
-    $output['content'] .= theme('nice_menus_build', $menu, $depth, $trail);
+    $output['content'] .= theme('nice_menus_build', array('menu' => $menu, 'depth' => $depth, 'trail' => $trail));
   }
 
   return $output;
@@ -397,7 +413,10 @@ function theme_nice_menus_tree($menu_nam
  * @param $trail
  *   An array of parent menu items.
  */
-function theme_nice_menus_build($menu, $depth = -1, $trail = NULL) {
+function theme_nice_menus_build($variables) {
+  $menu  = $variables['menu'];
+  $depth = $variables['depth'];
+  $trail = $variables['trail']; 
   $output = '';
   foreach ($menu as $menu_item) {
     $mlid = $menu_item['link']['mlid'];
@@ -406,7 +425,7 @@ function theme_nice_menus_build($menu, $
       // Build class name based on menu path
       // e.g. to give each menu item individual style.
       // Strip funny symbols.
-      $clean_path = str_replace(array('http://', 'www', '<', '>', '&', '=', '?', ':'), '', $menu_item['link']['href']);
+      $clean_path = str_replace(array('http://', 'www', '<', '>', '&', '=', '?', ':'), '', $menu_item['link']['link_path']);
       // Convert slashes to dashes.
       $clean_path = str_replace('/', '-', $clean_path);
       $class = 'menu-path-'. $clean_path;
@@ -416,7 +435,7 @@ function theme_nice_menus_build($menu, $
       // If it has children build a nice little tree under it.
       if ((!empty($menu_item['link']['has_children'])) && (!empty($menu_item['below'])) && $depth != 0) {
         // Keep passing children into the function 'til we get them all.
-        $children = theme('nice_menus_build', $menu_item['below'], $depth, $trail);
+        $children = theme('nice_menus_build', array('menu' => $menu_item['below'], 'depth' => $depth, 'trail' => $trail));
         // Set the class to parent only of children are displayed.
         $parent_class = $children ? 'menuparent ' : '';
         $output .= '<li id="menu-'. $mlid .'" class="'. $parent_class . $class .'">'. theme('menu_item_link', $menu_item['link']);
@@ -460,10 +479,16 @@ function theme_nice_menus_build($menu, $
  * @return
  *   An HTML string of Nice menu links.
  */
-function theme_nice_menus($id, $menu_name, $mlid, $direction = 'right', $depth = -1, $menu = NULL) {
-  $output = array();
+function theme_nice_menus($variables) {  
+  $id = $variables['id'];
+  $menu_name = $variables['menu_name'];
+  $mlid = $variables['mlid'];
+  $direction = $variables['direction'];
+  $depth = $variables['depth'];
+  $menu = $variables['menu'];
 
-  if ($menu_tree = theme('nice_menus_tree', $menu_name, $mlid, $depth, $menu)) {
+  $output = array();                                      
+  if ($menu_tree = theme('nice_menus_tree', array('menu_name' => $menu_name, 'mlid' => $mlid, 'depth' => $depth, 'menu' => $menu))) {
     if ($menu_tree['content']) {
       $output['content'] = '<ul class="nice-menu nice-menu-'. $direction .'" id="nice-menu-'. $id .'">'. $menu_tree['content'] .'</ul>'."\n";
       $output['subject'] = $menu_tree['subject'];
@@ -487,9 +512,12 @@ function theme_nice_menus($id, $menu_nam
  * @return
  *   An HTML string of Nice menu primary links.
  */
-function theme_nice_menus_primary_links($direction = 'down', $depth = -1, $menu = NULL) {
+function theme_nice_menus_primary_links($variables) {
+  $direction = $variables['direction'];
+  $depth = $variables['depth'];
+  $menu = $variables['menu'];
   $menu_name = variable_get('menu_primary_links_source', 'primary-links');
-  $output = theme('nice_menus', 0, $menu_name, 0, $direction, $depth, $menu);
+  $output = theme('nice_menus', array('id' => 0, 'menu_name' => $menu_name, $mlid => 0, 'direction' => $direction, 'depth' => $depth, 'menu' => $menu));
   return $output['content'];
 }
 
@@ -510,7 +538,7 @@ function theme_nice_menus_primary_links(
  */
 function theme_nice_menus_secondary_links($direction = 'down', $depth = -1, $menu = NULL) {
   $menu_name = variable_get('menu_secondary_links_source', 'secondary-links');
-  $output = theme('nice_menus', 0, $menu_name, 0, $direction, $depth, $menu);
+  $output = theme('nice_menus', array('id' => 0, 'menu_name' => $menu_name, 'mlid' => 0, 'direction' => $direction, 'depth' => $depth, 'menu' => $menu));
   return $output['content'];
 }
 
@@ -520,21 +548,21 @@ function theme_nice_menus_secondary_link
  * DEPRECATED theme function. Please switch to theme_nice_menus_tree().
  */
 function theme_nice_menu_tree($menu_name, $mlid = NULL, $depth = -1, $menu = NULL) {
-  return theme('nice_menus_tree', $menu_name, $mlid = NULL, $depth = -1, $menu = NULL);
+  return theme('nice_menus_tree', array('menu_name' => $menu_name, 'mlid' => $mlid = NULL, 'depth' => $depth = -1, 'menu' => $menu = NULL));
 }
 
 /**
  * DEPRECATED theme function. Please switch to theme_nice_menus_build().
  */
 function theme_nice_menu_build($menu, $depth = -1, $trail = NULL) {
-  return theme('nice_menus_build', $menu, $depth = -1, $trail = NULL);
+  return theme('nice_menus_build', array('menu' => $menu, 'depth' => $depth = -1, 'trail' => $trail = NULL));
 }
 
 /**
  * DEPRECATED theme function. Please switch to theme_nice_menus().
  */
 function theme_nice_menu($id, $menu_name, $mlid, $direction = 'right', $depth = -1, $menu = NULL) {
-  return theme('nice_menus', $id, $menu_name, $mlid, $direction = 'right', $depth = -1, $menu = NULL);
+  return theme('nice_menus', array('id' => $id, 'menu_name' => $menu_name, 'mlid' => $mlid, 'direction' => $direction = 'right', 'depth' => $depth = -1, 'menu' => $menu = NULL));
 }
 
 /**
@@ -542,5 +570,5 @@ function theme_nice_menu($id, $menu_name
  * theme_nice_menus_primary_links().
  */
 function theme_nice_menu_primary_links($direction = 'down', $depth = -1, $menu = NULL) {
-  return theme('nice_menus_primary_links', $direction = 'down', $depth = -1, $menu = NULL);
+  return theme('nice_menus_primary_links', array('direction' => $direction = 'down', 'depth' => $depth = -1, 'menu' => $menu = NULL));
 }
