Index: audio_import.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/contrib/import/audio_import.module,v
retrieving revision 1.9
diff -u -p -r1.9 audio_import.module
--- audio_import.module	30 Sep 2008 03:54:29 -0000	1.9
+++ audio_import.module	21 Dec 2008 22:21:24 -0000
@@ -5,8 +5,8 @@
 function audio_import_help($section, $arg) {
   switch ($section) {
     case 'admin/content/audio_import':
-      return '<p>'. t("Import multiple audio files and save them as audio nodes. The files will be moved from their location into the audio module's files directory. ")
-        . t("Searching for files ending with %extensions in %dirpath directory.", array('%dirpath' => realpath(variable_get('audio_import_path', '')), '%extensions' => variable_get('audio_allowed_extensions', 'mp3 wav ogg'))) .'</p>';
+      return '<p>'. t("Import multiple audio files and save them as audio nodes. The files will be moved from their location into the audio module's files directory. ") .'</p>'
+        .'<p>'. t("Searching for files ending with %extensions in %dirpath directory.", array('%dirpath' => realpath(variable_get('audio_import_path', '')), '%extensions' => variable_get('audio_allowed_extensions', 'mp3 wav ogg'))) .'</p>';
     case 'admin/help#audio':
       return '<p>'. t("The audio_import module allows users with 'administer audio' permission to import audio files and create audio nodes from them. ") .'</p>';
     case 'admin/settings/audio_import':
Index: audio_import.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/contrib/import/audio_import.pages.inc,v
retrieving revision 1.2
diff -u -p -r1.2 audio_import.pages.inc
--- audio_import.pages.inc	30 Sep 2008 04:43:07 -0000	1.2
+++ audio_import.pages.inc	21 Dec 2008 22:21:24 -0000
@@ -29,6 +29,13 @@ function audio_import_form() {
   $files = file_scan_directory($dirpath, $filemask);
   ksort($files);
 
+  // When the form gets too large we end up running out of memory submitting it.
+  // To avoid this we use a pager and rather than setting up all the variables
+  // ourself we just send in a fake query and then select the desired part of
+  // the files array.
+  $page_size = variable_get('audio_import_page_size', 50);
+  pager_query('SELECT %d', $page_size, 0, 'SELECT %d', array(count($files)));
+  $files = array_slice($files, $GLOBALS['pager_page_array'][0] * $page_size, $page_size);
 
   if ($files) {
     if (module_exists('taxonomy')) {
@@ -91,6 +98,8 @@ function audio_import_form() {
       }
     }
 
+    $form['pager'] = array('#value' => theme('pager', NULL, $page_size, 0));
+
     // Put the titles into an array.
     $form['files']['import']['#tree'] = TRUE;
     $form['files']['title']['#tree'] = TRUE;
@@ -120,7 +129,8 @@ function audio_import_form() {
 }
 
 function theme_audio_import_form($form) {
-  $output = '';
+  $output = drupal_render($form['token_help']);
+
   if (!empty($form['file_list']['#value'])) {
     $type = node_get_types('type', $form['#node_type']);
     $header = array(theme('table_select_header_cell'), t('Name'), t('Size'), check_plain($type->title_label), check_plain($type->body_label));
