? magic_tabs.patch
? magic_tabs_css_ids.patch
? yh1.patch
Index: magic_tabs.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/magic_tabs/Attic/magic_tabs.module,v
retrieving revision 1.3.2.9
diff -u -u -p -r1.3.2.9 magic_tabs.module
--- magic_tabs.module	20 Jul 2008 16:09:37 -0000	1.3.2.9
+++ magic_tabs.module	27 Jul 2008 20:11:20 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: magic_tabs.module,v 1.3.2.9 2008/07/20 16:09:37 yhager Exp $
+// $Id: magic_tabs.module,v 1.3.2.8 2008/07/17 18:14:27 yhager Exp $
 
 function magic_tabs_get($callback, $active = 'first', $_ajax = FALSE) {
   global $theme;
@@ -26,18 +26,11 @@ function magic_tabs_get($callback, $acti
     magic_tabs_register_callback($callback);
   }
 
-  if (magic_tabs_check_callback($callback)) {
-    $tabs = call_user_func($callback);
-  } else {
+  if (!magic_tabs_check_callback($callback)) {
     // callback not registered. report and bail out
     watchdog('magic_tabs', t('User %user tried to use a callback %callback without it being registered first.', array('%user' => $user->name, '%callback' => $callback)), WATCHDOG_WARNING);
     return;
   }
-  // go back to our path
-  if ($_ajax) {
-    unset($_menu['items']);
-    menu_set_active_item($q);
-  }
 
   $output = '';
   $index = 0;
@@ -51,14 +44,30 @@ function magic_tabs_get($callback, $acti
   }
   if (!is_numeric($active)) {
     switch ($active) {
-      case 'first':
-        $active = 0;
-        break;
       case 'last':
-        $active = count($tabs)-1;
+        $active = -1;
         break;
+      default: // case 'first', but cover up for garbage
+        $active = 0;
     }
   }
+
+  $tabs = call_user_func($callback, $active);
+
+  // go back to our original path
+  if ($_ajax) {
+    unset($_menu['items']);
+    menu_set_active_item($q);
+  }
+
+  if (empty($tabs)) {
+    return;
+  }
+
+  // ensure $active is within limits and positive
+  $tabs_count = count($tabs);
+  $active = ($active + $tabs_count) % $tabs_count;
+  
   // extract titles and contents
   foreach ($tabs as $tab) {
     $title = $tab['title'] ? $tab['title'] : t('Tab %index', array('%index' => $index));
@@ -172,18 +181,18 @@ function theme_magic_tabs($callback, $it
 /**
  * Example callback function
  */
-function magic_tabs_example_callback() {
+function magic_tabs_example_callback($active = 0) {
   $tabs[] = array(
     'title' => t('First magic tab'),
     'content' => t('Content of first magic tab'),
   );
   $tabs[] = array(
     'title' => t('Second magic tab'),
-    'content' => t('Content of second magic tab'),
+    'content' => t('Content of the second magic tab'),
   );
   $tabs[] = array(
-    'title' => t('Third and last magic tab'),
-    'content' => t('Content of the third magic tab'),
+    'title' => t('Third magic tab'),
+    'content' => ($active == 2 || $active == -1) ? magic_tabs_get('magic_tabs_inline_callback') : '',
   );
   /*
    ** Uncomment to display a custom block with $bid==2
@@ -201,3 +210,15 @@ function magic_tabs_example_callback() {
   return $tabs;
 }
 
+function magic_tabs_inline_callback() {
+  $tabs[] = array(
+    'title' => t('First nested magic tab'),
+    'content' => t('Content of first nested magic tab'),
+  );
+  $tabs[] = array(
+    'title' => t('2nd nested magic tab'),
+    'content' => t('Content of the second nested magic tab'),
+  );
+  return $tabs;
+}
+
