--- backup_migrate.module	Thu Feb 17 14:42:41 2011
+++ backup_migrate.module	Thu Feb 17 21:07:03 2011
@@ -17,69 +17,67 @@
  * Implementation of hook_help().
  */
 function backup_migrate_help($section, $arg) {
-  $help = array(
-    array(
-      'body' => 
-       t('Backup and Migrate makes the task of backing up your Drupal database and migrating data from one Drupal install to another easier. It provides a function to backup the entire database to file or download, and to restore from a previous backup. You can also schedule the backup operation. Compression of backup files is also supported.  The database backup files created with this module can be imported into this or any other Drupal installation with the !restorelink, or you can use a database tool such as <a href="!phpmyadminurl">phpMyAdmin</a> or the mysql command line command.',
-         array(
-            '!restorelink' => user_access('restore from backup') ? l(t('restore feature'), BACKUP_MIGRATE_MENU_PATH . '/restore') : t('restore feature'), 
-            '!phpmyadminurl' => 'http://www.phpmyadmin.net'
-          )
-        )
-    ),
-    BACKUP_MIGRATE_MENU_PATH => array(
-      'title' => t('Quick Backup Tab'),
-      'body' => t('Use this form to run simple manual backups of your database. Visit the !helppage for more help using this module', 
-                  array('!helppage' => l(t('help page'), 'admin/help/backup_migrate'))),
-    ),
-    BACKUP_MIGRATE_MENU_PATH . '/export/advanced' => array(
-      'title' => t('Advanced Backup Tab'),
-      'body' => t('Use this form to run manual backups of your database with more advanced options. If you have any !profilelink saved you can load those settings. You can save any of the changes you make to these settings as a new settings profile.', 
-                  array("!profilelink" => user_access('administer backup and migrate') ? l(t('settings profiles'), BACKUP_MIGRATE_MENU_PATH . '/profile') : t('settings profiles'), '!restorelink' => user_access('restore from backup') ? l(t('restore feature'), BACKUP_MIGRATE_MENU_PATH . '/restore') : t('restore feature'), '!phpmyadminurl' => 'http://www.phpmyadmin.net')),
-    ),
-    BACKUP_MIGRATE_MENU_PATH . '/restore' => array(
-      'title' => t('Restore Tab'),
-      'body' => t('Upload a backup and migrate backup file. The restore function will not work with database dumps from other sources such as phpMyAdmin.'),
-    ),
-    BACKUP_MIGRATE_MENU_PATH . '/destination' => array(
-      'title' => t('Destinations'),
-      'body' => t('Destinations are the places you can save your backup files to or them load from.'),
-      'more' => t('Files can be saved to a directory on your web server, downloaded to your desktop or emailed to a specified email account. From the Destinations tab you can create, delete and edit destinations or list the files which have already been backed up to the available destinations.'),
-    ),
-    BACKUP_MIGRATE_MENU_PATH . '/profile' => array(
-      'title' => t('Profiles'),
-      'body' => t('Profiles are saved backup settings. Profiles store your table exclusion settings as well as your backup file name, compression and timestamp settings. You can use profiles in !schedulelink and for !manuallink.',
-                  array('!schedulelink' => user_access('administer backup and migrate') ? l(t('schedules'), BACKUP_MIGRATE_MENU_PATH . '/schedule') : t('settings profiles'), '!manuallink' => user_access('perform backups') ? l(t('manual backups'), BACKUP_MIGRATE_MENU_PATH) : t('manual backups'))),
-      'more' => t('You can create new profiles using the add profiles tab or by checking the "Save these settings" button on the advanced backup page.'),
-    ),
-    BACKUP_MIGRATE_MENU_PATH . '/schedule' => array(
-      'title' => t('Scheduling'),
-      'body' => t('Automatically backup up your database on a regular schedule using <a href="!cronurl">cron</a>.', 
-                  array('!cronurl' => 'http://drupal.org/cron')),
-      'more' => t('Each schedule will run a maximum of once per cron run, so they will not run more frequently than your cron is configured to run. If you specify a number of backups to keep for a schedule, old backups will be deleted as new ones created. <strong>If specifiy a number of files to keep other backup files in that schedule\'s destination will get deleted</strong>.'),
-    ),
-  );
-
-  if (isset($help[$section])) {
-    return $help[$section]['body'];
+  $help = null;
+  switch ($section) {
+    case BACKUP_MIGRATE_MENU_PATH:
+      $help = t('Use this form to run simple manual backups of your database. Visit the !helppage for more help using this module',
+                array('!helppage' => l(t('help page'), 'admin/help/backup_migrate')));
+      break;
+    case BACKUP_MIGRATE_MENU_PATH . '/export/advanced':
+      $help = t('Use this form to run manual backups of your database with more advanced options. If you have any !profilelink saved you can load those settings. You can save any of the changes you make to these settings as a new settings profile.',
+                array("!profilelink" => user_access('administer backup and migrate') ? l(t('settings profiles'), BACKUP_MIGRATE_MENU_PATH . '/profile') : t('settings profiles'), '!restorelink' => user_access('restore from backup') ? l(t('restore feature'), BACKUP_MIGRATE_MENU_PATH . '/restore') : t('restore feature'), '!phpmyadminurl' => 'http://www.phpmyadmin.net'));
+      break;
+    case BACKUP_MIGRATE_MENU_PATH . '/restore':
+      $help = t('Upload a backup and migrate backup file. The restore function will not work with database dumps from other sources such as phpMyAdmin.');
+      break;
+    case BACKUP_MIGRATE_MENU_PATH . '/destination':
+      $help = t('Destinations are the places you can save your backup files to or them load from.');
+      break;
+    case BACKUP_MIGRATE_MENU_PATH . '/profile':
+      $help = t('Profiles are saved backup settings. Profiles store your table exclusion settings as well as your backup file name, compression and timestamp settings. You can use profiles in !schedulelink and for !manuallink.',
+                array('!schedulelink' => user_access('administer backup and migrate') ? l(t('schedules'), BACKUP_MIGRATE_MENU_PATH . '/schedule') : t('settings profiles'), '!manuallink' => user_access('perform backups') ? l(t('manual backups'), BACKUP_MIGRATE_MENU_PATH) : t('manual backups')));
+      break;
+    case BACKUP_MIGRATE_MENU_PATH . '/schedule':
+      $help = t('Automatically backup up your database on a regular schedule using <a href="!cronurl">cron</a>.',
+                array('!cronurl' => 'http://drupal.org/cron'));
+      break;
+    case 'admin/advanced_help':
+      // help link on module list page (admin/modules/list) or advanced help module (admin/advanced_help/backup_migrate)
+      // use $arg to see if it is for this module
+      if ($arg[2] != 'backup_migrate') {
+        break;
+      }
+      // explicit fall through
+    case 'admin/help#backup_migrate':
+      // help page
+      // Assemble help page based on all strings above plus more
+      $restorelink = user_access('restore from backup') ? l(t('restore feature'), BACKUP_MIGRATE_MENU_PATH . '/restore') : t('restore feature');
+      $help  = '<p>';
+      $help .= t('Backup and Migrate makes the task of backing up your Drupal database and migrating data from one Drupal install to another easier. It provides a function to backup the entire database to file or download, and to restore from a previous backup. You can also schedule the backup operation. Compression of backup files is also supported.  The database backup files created with this module can be imported into this or any other Drupal installation with the !restorelink, or you can use a database tool such as <a href="!phpmyadminurl">phpMyAdmin</a> or the mysql command line command.',
+                array('!restorelink' => $restorelink, '!phpmyadminurl' => 'http://www.phpmyadmin.net'));
+      $help .= '<\p>';
+      $help .= backup_migrate_help_section(t('Quick Backup Tab'), BACKUP_MIGRATE_MENU_PATH);
+      $help .= backup_migrate_help_section(t('Advanced Backup Tab'), BACKUP_MIGRATE_MENU_PATH . '/export/advanced');
+      $help .= backup_migrate_help_section(t('Restore Tab'), BACKUP_MIGRATE_MENU_PATH . '/restore');
+      $help .= backup_migrate_help_section(t('Destinations'), BACKUP_MIGRATE_MENU_PATH . '/destination', t('Files can be saved to a directory on your web server, downloaded to your desktop or emailed to a specified email account. From the Destinations tab you can create, delete and edit destinations or list the files which have already been backed up to the available destinations.'));
+      $help .= backup_migrate_help_section(t('Profiles'), BACKUP_MIGRATE_MENU_PATH . '/profile', t('You can create new profiles using the add profiles tab or by checking the "Save these settings" button on the advanced backup page.'));
+      $help .= backup_migrate_help_section(t('Scheduling'), BACKUP_MIGRATE_MENU_PATH . '/schedule', t('Each schedule will run a maximum of once per cron run, so they will not run more frequently than your cron is configured to run. If you specify a number of backups to keep for a schedule, old backups will be deleted as new ones created. <strong>If specifiy a number of files to keep other backup files in that schedule\'s destination will get deleted</strong>.'));
+      break;
   }
+  return $help;
+}
 
-  if ($section == 'admin/help#backup_migrate') {
-    $out = "";
-    foreach ($help as $key => $section) {
-      if (@$section['title']) {
-        if (!is_numeric($key)) {
-          $section['title'] = l($section['title'], $key);
-        }
-        $out .= "<h3>". $section['title'] ."</h3>";
-      }
-      $out .= "<p>". $section['body'] ."</p>";
-      if (!empty($section['more'])) {
-        $out .= "<p>". $section['more'] ."</p>";
-      }
-    }
-    return $out;
+/**
+ * helper method for hook_help to create parts of the help page
+ */
+function backup_migrate_help_section($title, $section, $more = null) {
+  $help = '';
+  $help .= '<h3>' . l($title, $section) . '</h3>';
+  $help .= '<p>' . backup_migrate_help($section, null) . '</p>';
+  if ($more !== null) {
+    $help .= '<p>' . $more . '</p>';
   }
+  return $help;
 }
 
 /**
