? Copy of audio.install_to_core
? test.patch
? contrib/import/.audio_import.module.swp
? getid3/changelog.txt
? getid3/dependencies.txt
? getid3/getid3
? getid3/helperapps
? getid3/license.commercial.txt
? getid3/license.txt
? getid3/readme.txt
? getid3/structure.txt
Index: audio.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/audio.install,v
retrieving revision 1.15
diff -u -r1.15 audio.install
--- audio.install	30 Jul 2007 22:25:05 -0000	1.15
+++ audio.install	31 Jul 2007 03:25:56 -0000
@@ -16,7 +16,11 @@
           `play_count` int(10) unsigned NOT NULL default '0',
           `download_count` int(10) unsigned NOT NULL default '0',
           `downloadable` tinyint(1) NOT NULL default '1',
-          `fileformat` varchar(10) NOT NULL default '',
+          `file_format` varchar(10) NOT NULL default '',
+          `file_mime` varchar(255) NOT NULL default '',
+          `file_name` varchar(255) NOT NULL default '',
+          `file_path` varchar(255) NOT NULL default '',
+          `file_size` int(10) unsigned NOT NULL default '0',
           `sample_rate` int(10) unsigned NOT NULL default '0',
           `channel_mode` varchar(10) NOT NULL default '',
           `bitrate` float unsigned NOT NULL default '0',
@@ -26,16 +30,6 @@
         ) /*!40100 DEFAULT CHARACTER SET utf8 */;
       ");
       db_query("
-        CREATE TABLE  {audio_file} (
-          `vid` int(10) unsigned NOT NULL default '0',
-          `filename` varchar(255) NOT NULL default '',
-          `filepath` varchar(255) NOT NULL default '',
-          `filemime` varchar(255) NOT NULL default '',
-          `filesize` int(10) unsigned NOT NULL default '0',
-          PRIMARY KEY  (`vid`)
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;
-      ");
-      db_query("
         CREATE TABLE  {audio_metadata} (
           `vid` int(10) unsigned NOT NULL default '0',
           `tag` varchar(45) NOT NULL default '',
@@ -60,7 +54,12 @@
             download_count integer NOT NULL default '0'
                 CHECK (download_count >= 0),
             downloadable smallint NOT NULL default '1',
-            fileformat varchar(10) NOT NULL default '',
+            file_format varchar(10) NOT NULL default '',
+            file_mime varchar(255) NOT NULL default '',
+            file_name varchar(255) NOT NULL default '',
+            file_path varchar(255) NOT NULL default '',
+            file_size integer NOT NULL default '0'
+                CHECK (filesize >= 0),
             sample_rate integer NOT NULL default '0'
                 CHECK (sample_rate >= 0),
             channel_mode varchar(10) NOT NULL default '',
@@ -72,18 +71,6 @@
         );
       ");
       db_query("
-        CREATE TABLE {audio_file} (
-            vid integer NOT NULL default '0'
-                CHECK (vid >= 0),
-            filename varchar(255) NOT NULL default '',
-            filepath varchar(255) NOT NULL default '',
-            filemime varchar(255) NOT NULL default '',
-            filesize integer NOT NULL default '0'
-                CHECK (filesize >= 0),
-            PRIMARY KEY  (vid)
-        );
-      ");
-      db_query("
         CREATE TABLE {audio_metadata} (
             vid integer NOT NULL default '0'
                 CHECK (vid >= 0),
@@ -333,4 +320,59 @@
   }
 
   return $ret;
-}
\ No newline at end of file
+}
+
+/**
+ * Move the fields from {audio_file} to {audio} and add remote URL fields.
+ */
+function audio_update_5202() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("ALTER TABLE {audio}
+        CHANGE COLUMN `fileformat` `file_format` varchar(10) NOT NULL default '',
+        ADD COLUMN `file_mime` varchar(255) NOT NULL default '' AFTER `file_format`, 
+        ADD COLUMN `file_name` varchar(255) NOT NULL default '' AFTER `file_mime`,
+        ADD COLUMN `file_path` varchar(255) NOT NULL default '' AFTER `file_name`,
+        ADD COLUMN `file_size` INTEGER UNSIGNED NOT NULL default 0 AFTER `file_path`,
+        ADD COLUMN `remote_url` varchar(255) NOT NULL default '' AFTER `file_size`,
+        ADD COLUMN `remote_size` INTEGER UNSIGNED NOT NULL default 0 AFTER `remote_url`
+      ");
+      $ret[] = update_sql("UPDATE {audio} a INNER JOIN {audio_file} af ON a.vid = af.vid SET a.file_name = af.filename, a.file_path = af.filepath, a.file_mime = af.filemime, a.file_size = af.filesize");
+      $ret[] = update_sql("DROP TABLE {audio_file}");
+      break;
+  }
+
+  // Build an array of conversions. First the hard coded values...
+  $tokens = array(
+    '[audio-filename]' => '[audio-file-name]',
+    '[audio-filepath]' => '[audio-file-path]',
+    '[audio-filemime]' => '[audio-file-mime]',
+    '[audio-filesize]' => '[audio-file-size]',
+  );
+  // ...then the tags.
+  foreach (audio_get_tags_allowed() as $tag) {
+    $tokens['!'. $tag] = '[audio-tag-'. strtr($tag, '_', '-') .']';
+  }
+
+  // Gather a list of all the different title formats and then replace them
+  // with the new token based equivalents.
+  $result = db_query('SELECT DISTINCT title_format FROM {audio}');
+  while ($o = db_fetch_object($result)) {
+    $new_value = strtr($o->title_format, $tokens);
+    if ($new_value != $o->title_format) {
+      db_query("UPDATE {audio} SET title_format = '%s' WHERE title_format = '%s'", $new_value, $o->title_format);
+    }
+  }
+
+  // Update the default title and teaser formats.
+  foreach (array('audio_default_title_format', 'audio_teaser_format') as $variable) {
+    if ($old_value = variable_get($variable, FALSE)) {
+      variable_set($variable, strtr($old_value, $tokens));
+    }
+  }
+
+  return $ret;
+}
+
Index: audio.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/audio.module,v
retrieving revision 1.120
diff -u -r1.120 audio.module
--- audio.module	31 Jul 2007 03:17:22 -0000	1.120
+++ audio.module	31 Jul 2007 03:59:13 -0000
@@ -144,15 +144,13 @@
  *       A node form is being submitted, before insertion or updates.
  *   'insert'
  *       A new audio node is being created. Changes you make to the node's
- *       audio_images, audio_file, and audio_fileinfo memebers will be saved.
+ *       audio_images and audio_file memebers will be saved.
  *   'insert revision'
  *       A new revision of an audio node is being created. Changes you make to
- *       the node's audio_images, audio_file, and audio_fileinfo memebers will
- *       be saved.
+ *       the node's audio_images and audio_file memebers will be saved.
  *   'update'
  *       Changes to an audio node are being saved. Changes you make to the
- *       node's audio_images, audio_file, and audio_fileinfo memebers will be
- *       saved.
+ *       node's audio_images and audio_file memebers will be saved.
  *   'delete'
  *       An audio node is being deleted. Remove all of the nodes files and
  *       database records.
@@ -228,7 +226,7 @@
  *   boolean indicating if it's allowed.
  */
 function _audio_allow_download($node) {
-  if (isset($node->url_download) && $node->audio_fileinfo['downloadable']) {
+  if (isset($node->url_download) && $node->audio_file['downloadable']) {
     $result = audio_invoke_audioapi('access', $node, 'download');
 
     if (in_array(TRUE, $result)) {
@@ -295,13 +293,13 @@
       );
       if($link_access){
         $links['audio_download_count'] = array(
-          'title' => t('@download_count downloads', array('@download_count' => $node->audio_fileinfo['download_count'])),
+          'title' => t('@download_count downloads', array('@download_count' => $node->audio_file['download_count'])),
         );
       }
     }
     if (_audio_allow_play($node) && $link_access) {
       $links['audio_play_count'] = array(
-        'title' => t('@play_count plays', array('@play_count' => $node->audio_fileinfo['play_count'])),
+        'title' => t('@play_count plays', array('@play_count' => $node->audio_file['play_count'])),
       );
     }
   }
@@ -331,8 +329,8 @@
             'key' => 'enclosure',
             'attributes' => array(
               'url' => $node->url_download,
-              'length' => $node->audio_file->filesize,
-              'type' => $node->audio_file->filemime,
+              'length' => $node->audio_file['file_size'],
+              'type' => $node->audio_file['file_mime']
             ));
           // Provide very basic iTunes support.
           $ret[] = array(
@@ -340,7 +338,7 @@
           );
           $ret[] = array(
             'key' => 'itunes:duration',
-            'value' => $node->audio_fileinfo['playtime'],
+            'value' => $node->audio_file['playtime'],
           );
           $ret[] = array(
             'key' => 'itunes:author',
@@ -388,12 +386,12 @@
  */
 function audio_validate(&$node, &$form) {
   $nid = ($node->nid) ? $node->nid : 'new_node';
-  if (!isset($node->audio_file) && !isset($_SESSION['audio_file'][$nid])) {
+  if (!isset($node->audio_file['file_path']) && !isset($_SESSION['audio_new_file'][$nid])) {
     form_set_error('audio_upload', t("A file must be provided. If you tried uploading a file, make sure it's less than the upload size limit."));
   }
 
   // Build the title from metadata. If there's not title format use the default.
-  if (!isset($node->title_format)) {
+  if (empty($node->title_format)) {
     $node->title_format = variable_get('audio_default_title_format', '[audio-tag-title] by [audio-tag-artist]');
   }
   form_set_value($form['title'], token_replace($node->title_format, 'node', $node));
@@ -403,28 +401,38 @@
  * Implementation of hook_load().
  */
 function audio_load($node) {
-  $ret = array();
-
   if ($node->vid) {
-    // Load the audio fields...
-    $ret['audio_fileinfo'] = db_fetch_array(db_query("SELECT * FROM {audio} WHERE vid=%d", $node->vid));
-    // ... then move some non-file info stuff out of the array
-    $ret['title_format'] = $ret['audio_fileinfo']['title_format'];
-    unset($ret['audio_fileinfo']['title_format']);
-
-    // Load the file.
-    $result = db_query('SELECT filename, filepath, filemime, filesize FROM {audio_file} f WHERE f.vid = %d', $node->vid);
-    $ret['audio_file'] = $file = db_fetch_object($result);
-    $ret['audio_fileinfo']['filesize'] = $file->filesize;
+    // This is a wonky way to load the fields but its handy right now while
+    // I'm renaming fields in the databases. 
+    $fields = db_fetch_array(db_query("SELECT * FROM {audio} WHERE vid=%d", $node->vid));
+    $ret = array(
+      'title_format' => $fields['title_format'],
+      'audio_file' => array(
+        'play_count'     => $fields['play_count'],
+        'download_count' => $fields['download_count'],
+        'downloadable'   => $fields['downloadable'],
+        'file_format'    => $fields['file_format'],
+        'file_mime'      => $fields['file_mime'],
+        'file_name'      => $fields['file_name'],
+        'file_path'      => $fields['file_path'],
+        'file_size'      => $fields['file_size'],
+        'sample_rate'    => $fields['sample_rate'],
+        'channel_mode'   => $fields['channel_mode'],
+        'bitrate'        => $fields['bitrate'],
+        'bitrate_mode'   => $fields['bitrate_mode'],
+        'playtime'       => $fields['playtime'],
+        'bitrate'        => $fields['bitrate'],
+      ),
+    );
 
-    if (file_exists($file->filepath)) {
+    if (file_exists($fields['file_path'])) {
       // TODO: should these links be by vid?
       $ret['url_play'] = url('audio/play/'. $node->nid, NULL, NULL, TRUE);
-      if ($ret['audio_fileinfo']['downloadable']) {
+      if ($ret['audio_file']['downloadable']) {
         // iTunes and other podcasting programs check the url to determine the
         // file type. we'll add the original file name on to the end. see issues
         // #35398 and #68716 for more info.
-        $url = 'audio/download/'. $node->nid .'/'. $file->filename;
+        $url = 'audio/download/'. $node->nid .'/'. $fields['file_name'];
         $ret['url_download'] = url($url , NULL, NULL, TRUE);
       }
     }
@@ -437,32 +445,29 @@
     }
 
     // Allow other modules to access newly loaded audio node.
-    $ret = array_merge($ret, audio_invoke_audioapi('load', $node));
+    return array_merge($ret, audio_invoke_audioapi('load', $node));
   }
-
-  return $ret;
+  return array();
 }
 
 /**
  * Implementation of hook_insert().
  */
 function audio_insert(&$node) {
-  file_move($node->audio_file, audio_get_directory(), FILE_EXISTS_RENAME);
+  file_move($node->audio_file['file_path'], audio_get_directory(), FILE_EXISTS_RENAME);
 
   // Notify other modules.
   audio_invoke_audioapi('insert', $node);
 
   $f = $node->audio_file;
-  $i = $node->audio_fileinfo;
-  db_query("INSERT INTO {audio_file} (vid, filename, filepath, filemime, filesize) VALUES (%d, '%s', '%s', '%s', %d)",
-    $node->vid, $f->filename, $f->filepath, $f->filemime, filesize($f->filepath));  
-  db_query("INSERT INTO {audio} (vid, nid, title_format, downloadable, fileformat, bitrate, bitrate_mode, sample_rate, channel_mode, playtime) VALUES (%d, %d, '%s', %d, '%s', %f, '%s', %d, '%s', '%s')",
-    $node->vid, $node->nid, $node->title_format, $i['downloadable'], $i['fileformat'], $i['bitrate'], $i['bitrate_mode'], $i['sample_rate'], $i['channel_mode'], $i['playtime']);
+  db_query("INSERT INTO {audio} (vid, nid, title_format, downloadable, file_format, file_name, file_path, file_mime, file_size, bitrate, bitrate_mode, sample_rate, channel_mode, playtime) 
+    VALUES (%d, %d, '%s', %d, '%s', '%s', '%s', '%s', %d, %f, '%s', %d, '%s', '%s')",
+    $node->vid, $node->nid, $node->title_format, $f['downloadable'], $f['file_format'], $f['file_name'], $f['file_path'], $f['file_mime'], filesize($f['file_path']), $f['bitrate'], $f['bitrate_mode'], $f['sample_rate'], $f['channel_mode'], $f['playtime']);
 
   _audio_save_tags_to_db($node);
   
   // Unset the new file flag incase this node is re-saved.
-  unset($node->audio_file->newfile);
+  unset($node->audio_file['newfile']);
 }
 
 /**
@@ -471,24 +476,21 @@
  * If a new file wasn't uploaded, make a copy of the existing file.
  */
 function audio_insert_revision($node) {
-  if (isset($node->audio_file->newfile)) {
-    file_move($node->audio_file, audio_get_directory(), FILE_EXISTS_RENAME);
+  if (isset($node->audio_file['newfile'])) {
+    file_move($node->audio_file['file_path'], audio_get_directory(), FILE_EXISTS_RENAME);
   }
   else {
-    $newname = file_create_filename($node->audio_file->filename, audio_get_directory());
-    file_copy($node->audio_file, $newname);
+    $newname = file_create_filename($node->audio_file['file_name'], audio_get_directory());
+    file_copy($node->audio_file['file_path'], $newname);
   }
 
   // Notify other modules.
   audio_invoke_audioapi('insert revision', $node);
 
   $f = $node->audio_file;
-  db_query("INSERT INTO {audio_file} (vid, filename, filepath, filemime, filesize) VALUES (%d, '%s', '%s', '%s', %d)",
-    $node->vid, $f->filepath, $f->filepath, $f->filemime, filesize($f->filepath));
-
-  $i = $node->audio_fileinfo;
-  db_query("INSERT INTO {audio} (vid, nid, title_format, downloadable, fileformat, bitrate, bitrate_mode, sample_rate, channel_mode, playtime) VALUES (%d, %d, '%s', %d, '%s', %f, '%s', %d, '%s', '%s')",
-    $node->vid, $node->nid, $node->title_format, $i['downloadable'], $i['fileformat'], $i['bitrate'], $i['bitrate_mode'], $i['sample_rate'], $i['channel_mode'], $i['playtime']);
+  db_query("INSERT INTO {audio} (vid, nid, title_format, downloadable, file_format, file_name, file_path, file_mime, file_size, bitrate, bitrate_mode, sample_rate, channel_mode, playtime)
+    VALUES (%d, %d, '%s', %d, '%s', '%s', '%s', '%s', %d, %f, '%s', %d, '%s', '%s')",
+    $node->vid, $node->nid, $node->title_format, $f['downloadable'], $f['file_format'], $f['file_name'], $f['file_path'], $f['file_mime'], filesize($f['file_path']), $f['bitrate'], $f['bitrate_mode'], $f['sample_rate'], $f['channel_mode'], $f['playtime']);
 
   _audio_save_tags_to_db($node);
 }
@@ -502,15 +504,15 @@
     return audio_insert_revision($node);
   }
 
-  if (isset($node->audio_file->newfile)) {
-    unset($node->audio_file->newfile);
+  if (isset($node->audio_file['newfile'])) {
+    unset($node->audio_file['newfile']);
 
     // Remove the old file.
-    $oldfile = db_fetch_object(db_query('SELECT filepath FROM {audio_file} f WHERE f.vid = %d', $node->vid));
-    file_delete($oldfile->filepath);
+    $oldfile = db_fetch_object(db_query('SELECT file_path FROM {audio} f WHERE f.vid = %d', $node->vid));
+    file_delete($oldfile->file_path);
 
     // Save the new one.
-    file_move($node->audio_file, audio_get_directory(), FILE_EXISTS_RENAME);
+    file_move($node->audio_file['file_path'], audio_get_directory(), FILE_EXISTS_RENAME);
   }
 
   // Notify other modules.
@@ -520,13 +522,11 @@
   // records. it takes a bit longer but it allows us to carry on if one of the
   // records wasn't created by audio_insert().
   db_query("DELETE FROM {audio} WHERE vid=%d", $node->vid);
-  db_query("DELETE FROM {audio_file} WHERE vid=%d", $node->vid);
-  $i = $node->audio_fileinfo;
-  db_query("INSERT INTO {audio} (vid, nid, title_format, play_count, download_count, downloadable, fileformat, bitrate, bitrate_mode, sample_rate, channel_mode, playtime) VALUES (%d, %d, '%s', %d, %d, %d, '%s', %f, '%s', %d, '%s', '%s')",
-    $node->vid, $node->nid, $node->title_format, $i['play_count'], $i['download_count'], $i['downloadable'], $i['fileformat'], $i['bitrate'], $i['bitrate_mode'], $i['sample_rate'], $i['channel_mode'], $i['playtime']);
+
   $f = $node->audio_file;
-  db_query("INSERT INTO {audio_file} (vid, filename, filepath, filemime, filesize) VALUES (%d, '%s', '%s', '%s', %d)",
-    $node->vid, $f->filename, $f->filepath, $f->filemime, filesize($f->filepath));
+  db_query("INSERT INTO {audio} (vid, nid, title_format, play_count, download_count, downloadable, file_format, file_name, file_path, file_mime, file_size, bitrate, bitrate_mode, sample_rate, channel_mode, playtime)
+    VALUES (%d, %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', %d, %f, '%s', %d, '%s', '%s')",
+    $node->vid, $node->nid, $node->title_format, $f['play_count'], $f['download_count'], $f['downloadable'], $f['file_format'], $f['file_name'], $f['file_path'], $f['file_mime'], filesize($f['file_path']), $f['bitrate'], $f['bitrate_mode'], $f['sample_rate'], $f['channel_mode'], $f['playtime']);
 
   _audio_save_tags_to_db($node);
 }
@@ -538,13 +538,12 @@
   // Notify other modules.
   audio_invoke_audioapi('delete', $node);
 
-  $result = db_query('SELECT vid FROM {audio} WHERE nid = %d', $node->nid);
+  $result = db_query('SELECT vid, file_path FROM {audio} WHERE nid = %d', $node->nid);
   while ($o = db_fetch_object($result)) {
-    if ($filepath = db_result(db_query('SELECT filepath FROM {audio_file} WHERE vid = %d', $o->vid))) {
-      file_delete($filepath);
+    if (isset($o->file_path)) {
+      file_delete($o->file_path);
     }
     db_query('DELETE FROM {audio_metadata} WHERE vid = %d', $o->vid);
-    db_query('DELETE FROM {audio_file} WHERE vid = %d', $o->vid);
   }
   db_query('DELETE FROM {audio} WHERE nid = %d', $node->nid);
 }
@@ -556,12 +555,11 @@
   // Notify other modules.
   audio_invoke_audioapi('delete revision', $node);
 
-  if ($filepath = db_result(db_query('SELECT filepath FROM {audio_file} WHERE vid = %d', $node->vid))) {
-    file_delete($filepath);
+  if ($file_path = db_result(db_query('SELECT file_path FROM {audio} WHERE vid = %d', $node->vid))) {
+    file_delete($file_path);
   }
 
   db_query('DELETE FROM {audio_metadata} WHERE vid = %d', $node->vid);
-  db_query('DELETE FROM {audio_file} WHERE vid = %d', $node->vid);
   db_query('DELETE FROM {audio} WHERE vid = %d', $node->vid);
 }
 
@@ -580,8 +578,8 @@
   // session for this node. This is so if you upload a file, then decide you
   // don't want it and reload the form (without posting), the files will be
   // discarded.
-  if(count($_POST) == 0) {
-    unset($_SESSION['audio_file'][$nid]);
+  if (count($_POST) == 0) {
+    unset($_SESSION['audio_new_file'][$nid]);
   }
 
   // Check for an upload.
@@ -599,16 +597,16 @@
       $temppath = file_directory_temp() . '/audio/';
       file_check_directory($temppath, TRUE);
 
-      $node->audio_file = file_save_upload($file, $temppath .'/'. $file->filename, FILE_EXISTS_REPLACE);
-      $node->audio_file->newfile = TRUE;
-
-      $node->audio_tags = array();
-
-      $node->audio_fileinfo = array(
+      $file = file_save_upload($file, $temppath .'/'. $file->filename, FILE_EXISTS_REPLACE);
+      $node->audio_file = array(
+        'newfile' => TRUE,
         'play_count' => 0,
         'download_count' => 0,
-        'filesize' => filesize($node->audio_file->filepath),
         'downloadable' => (bool) $_POST['audio_fileinfo']['downloadable'],
+        'file_name' => $file->filename,
+        'file_path' => $file->filepath,
+        'file_mime' => $file->filemime,
+        'file_size' => filesize($node->audio_file['file_path']),
       );
 
       // Allow other modules to modify the node.
@@ -618,18 +616,15 @@
       // form. Note that we do this after calling we called our api hook with
       // the upload operation, it gives the audio_id3 module a chance to read
       // the tags.
-      $_POST['audio_fileinfo'] = $node->audio_fileinfo;
+      $_POST['audio_file'] = $node->audio_file;
       $_POST['audio_tags'] = $node->audio_tags;
 
-      $_SESSION['audio_file'][$nid] = $node->audio_file;
+      $_SESSION['audio_new_file'][$nid] = $node->audio_file['file_path'];
     }
   }
-
-  if (!empty($_SESSION['audio_file'][$nid])) {
-    $node->audio_file = $_SESSION['audio_file'][$nid];
-  }
-  else {
-    $_SESSION['audio_file'][$nid] = $node->audio_file;
+  // Assign a newly uploaded file that's being previewed.
+  else if (isset($_SESSION['audio_new_file'][$nid])) {
+    $node->audio_file['file_path'] = $_SESSION['audio_new_file'][$nid];
   }
 
   audio_invoke_audioapi('prepare', $node);
@@ -646,7 +641,7 @@
     $form['title']['title_format'] = array(
       '#type' => 'textfield',
       '#title' => check_plain($type->title_label),
-      '#default_value' => isset($node->title_format) ? $node->title_format : variable_get('audio_default_title_format', '[audio-tag-title] by [audio-tag-artist]'),
+      '#default_value' => !empty($node->title_format) ? $node->title_format : variable_get('audio_default_title_format', '[audio-tag-title] by [audio-tag-artist]'),
       '#description' => t("The title can use the file's metadata. You can use the tokens listed below to insert information into the title."),
       '#required' => TRUE,
       
@@ -669,125 +664,139 @@
       '#default_value' => $node->body,
       '#rows' => 5,
       '#required' => ($type->min_word_count > 0),
-      );
+    );
     $form['body_filter']['format'] = filter_form($node->format);
   }
 
   $form['#attributes'] = array('enctype' => 'multipart/form-data');
-  $form['audio_fileinfo'] = array(
+  $form['audio_file'] = array(
     '#type' => 'fieldset',
     '#title' => t('Audio File Info'),
     '#collapsible'=> TRUE,
     '#weight' => -1,
     '#tree' => TRUE,
   );
-  $form['audio_fileinfo']['filepath'] = array(
-    '#type' => 'item',
-    '#title' => t('Current File'),
-    '#value' => t('No file is attached.'),
-    '#weight' => -1,
+  // Store the non-user editable file information as values.
+  $form['audio_file']['file_path'] = array(
+    '#type' => 'value',
+    '#value' => $node->audio_file['file_path'],
   );
-  $form['audio_fileinfo']['audio_upload'] = array(
-    '#tree' => FALSE, 
-    '#type' => 'file',
-    '#title' => t('Add a new audio file'),
-    '#description' => t('Click "Browse..." to select an audio file to upload. Only files with the following extensions are allowed: %allowed-extensions.', array('%allowed-extensions' => variable_get('audio_allowed_extensions', 'mp3 wav ogg'))) .'<br />'
-      . t('<strong>NOTE:</strong> the current PHP configuration limits uploads to %maxsize.', array('%maxsize' => format_size(file_upload_max_size()))),
-    '#weight' => 19,
+  $form['audio_file']['file_name'] = array(
+    '#type' => 'value',
+    '#value' => $node->audio_file['file_name'],
   );
-  $form['audio_fileinfo']['downloadable'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Allow file downloads.'),
-    '#default_value' => isset($node->audio_fileinfo['downloadable']) ? $node->audio_fileinfo['downloadable'] : variable_get('audio_default_downloadable', 1),
-    '#description' => t('If checked, a link will be displayed allowing visitors to download this audio file on to their own computer.') .'<br />'
-      . t('<strong>WARNING:</strong> even if you leave this unchecked, clever users will be able to find a way to download the file. This just makes them work a little harder to find the link.'),
-    '#weight' => 20,
+  $form['audio_file']['file_mime'] = array(
+    '#type' => 'value',
+    '#value' => $node->audio_file['file_mime'],
   );
 
-
-  // If we've got a file, add the fields for editing meta data and displaying
-  // the file's info.
+  // Place a visible copy of the file path on the form (after removing the
+  // directory info from non-admins).
+  $file_path = $node->audio_file['file_path'];
+  if (!user_access('administer audio')) {
+    $file_path = basename($file_path);
+  }
+  $form['audio_file']['display_file_path'] = array(
+    '#type' => 'item',
+    '#title' => t('Current File'),
+    '#value' => isset($file_path) ? $file_path : t('No file is attached.'),
+  );
+  
+  // If we've got a file, add the file information fields.
   if (isset($node->audio_file)) {
-    $form['audio_tags'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Audio Metadata'),
-      '#collapsible'=> TRUE,
-      '#tree' => TRUE,
-      '#weight' => -3,
-    );
-    // Delegate out the dirty work of building form elements.
-    foreach (audio_get_tag_settings() as $tag => $tag_settings) {
-      $form['audio_tags'][$tag] = _audio_build_tag_form($tag, $tag_settings, $node->audio_tags[$tag]);
-    }
-
-    // Hide the directory information from non-admins.
-    $file_path = $node->audio_file->filepath;
-    if (!user_access('administer audio')) {
-      $file_path = basename($file_path);
-    }
-    $form['audio_fileinfo']['filepath']['#value'] = $file_path;
-    $form['audio_fileinfo']['audio_upload']['#title'] = t('Replace this with a new file');
-    $form['audio_fileinfo']['fileformat'] = array(
+    $form['audio_file']['file_format'] = array(
       '#type' => 'select',
       '#title' => t('Format'),
-      '#default_value' => $node->audio_fileinfo['fileformat'],
+      '#default_value' => $node->audio_file['file_format'],
       '#options' => drupal_map_assoc(array('', 'aac', 'ac3', 'au', 'avr', 'flac', 'midi', 'mod', 'mp3', 'mpc', 'ogg', 'voc'), 'drupal_strtoupper'),
     );
-    $form['audio_fileinfo']['filesize'] = array(
+    $form['audio_file']['file_size'] = array(
       '#type' => 'textfield',
       '#title' => t('Size (in bytes)'),
-      '#default_value' => $node->audio_fileinfo['filesize'],
+      '#default_value' => $node->audio_file['file_size'],
     );
-    $form['audio_fileinfo']['playtime'] = array(
+    $form['audio_file']['playtime'] = array(
       '#type' => 'textfield',
       '#title' => t('Length'),
-      '#default_value' => $node->audio_fileinfo['playtime'],
+      '#default_value' => $node->audio_file['playtime'],
       '#description' => t('The format is hours:minutes:seconds.'),
     );
-    $form['audio_fileinfo']['sample_rate'] = array(
+    $form['audio_file']['sample_rate'] = array(
       '#type' => 'select',
       '#title' => t('Sample rate'),
-      '#default_value' => $node->audio_fileinfo['sample_rate'],
+      '#default_value' => $node->audio_file['sample_rate'],
       '#options' => array('' => '', '48000' => '48,000 Hz', '44100' => '44,100 Hz', '32000' => '32,000 Hz', '22050' => '22,050 Hz', '11025' => '11,025 Hz', '8000' => '8,000 Hz',),
     );
-    $form['audio_fileinfo']['channel_mode'] = array(
+    $form['audio_file']['channel_mode'] = array(
       '#type' => 'select',
       '#title' => t('Channel mode'),
-      '#default_value' => $node->audio_fileinfo['channel_mode'],
+      '#default_value' => $node->audio_file['channel_mode'],
       '#options' => array('stereo' => t('Stereo'), 'mono' => t('Mono'),),
     );
-    $form['audio_fileinfo']['bitrate'] = array(
+    $form['audio_file']['bitrate'] = array(
       '#type' => 'textfield',
       '#title' => t('Bitrate'),
-      '#default_value' => $node->audio_fileinfo['bitrate'],
+      '#default_value' => $node->audio_file['bitrate'],
     );
-    $form['audio_fileinfo']['bitrate_mode'] = array(
-      '#type' => 'textfield',
+    $form['audio_file']['bitrate_mode'] = array(
+      '#type' => 'select',
       '#title' => t('Bitrate mode'),
-      '#default_value' => $node->audio_fileinfo['bitrate_mode'],
+      '#default_value' => $node->audio_file['bitrate_mode'],
+      '#options' => array('' => '', 'cbr' => t('Constant'), 'vbr' => t('Variable')),
     );
 
     // Users shouldn't be able to change the play and download counts so we'll
     // put these for viewing...
-    $form['audio_fileinfo']['display_play_count'] = array(
+    $form['audio_file']['display_play_count'] = array(
       '#type' => 'item',
       '#title' => t('Play count'),
-      '#value' => $node->audio_fileinfo['play_count'],
+      '#value' => $node->audio_file['play_count'],
     );
-    $form['audio_fileinfo']['display_download_count'] = array(
+    $form['audio_file']['display_download_count'] = array(
       '#type' => 'item',
       '#title' => t('Download count'),
-      '#value' => $node->audio_fileinfo['download_count'],
+      '#value' => $node->audio_file['download_count'],
     );
     // ...and these are what we'll save back to the node.
-    $form['audio_fileinfo']['play_count'] = array(
+    $form['audio_file']['play_count'] = array(
       '#type' => 'value',
-      '#value' => $node->audio_fileinfo['play_count'],
+      '#value' => $node->audio_file['play_count'],
     );
-    $form['audio_fileinfo']['download_count'] = array(
+    $form['audio_file']['download_count'] = array(
       '#type' => 'value',
-      '#value' => $node->audio_fileinfo['download_count'],
+      '#value' => $node->audio_file['download_count'],
+    );
+  }
+  
+  $form['audio_file']['audio_upload'] = array(
+    '#tree' => FALSE, 
+    '#type' => 'file',
+    '#title' => !isset($node->audio_file) ? t('Add a new audio file') : t('Replace this with a new file'),
+    '#description' => t('Click "Browse..." to select an audio file to upload. Only files with the following extensions are allowed: %allowed-extensions.', array('%allowed-extensions' => variable_get('audio_allowed_extensions', 'mp3 wav ogg'))) .'<br />'
+      . t('<strong>NOTE:</strong> the current PHP configuration limits uploads to %maxsize.', array('%maxsize' => format_size(file_upload_max_size()))),
+  );
+  $form['audio_file']['downloadable'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Allow file downloads.'),
+    '#default_value' => isset($node->audio_file['downloadable']) ? $node->audio_file['downloadable'] : variable_get('audio_default_downloadable', 1),
+    '#description' => t('If checked, a link will be displayed allowing visitors to download this audio file on to their own computer.') .'<br />'
+      . t('<strong>WARNING:</strong> even if you leave this unchecked, clever users will be able to find a way to download the file. This just makes them work a little harder to find the link.'),
+  );
+
+
+  // If we've got a file, add the fields for editing meta data.
+  if (isset($node->audio_file)) {
+    $form['audio_tags'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Audio Metadata'),
+      '#collapsible'=> TRUE,
+      '#tree' => TRUE,
+      '#weight' => -3,
     );
+    // Delegate out the dirty work of building form elements.
+    foreach (audio_get_tag_settings() as $tag => $tag_settings) {
+      $form['audio_tags'][$tag] = _audio_build_tag_form($tag, $tag_settings, $node->audio_tags[$tag]);
+    }
   }
 
   return $form;
@@ -837,11 +846,12 @@
  * Implementation of hook_submit().
  */
 function audio_submit(&$node) {
-  // Use the the file was stored in the session during audio_prepare().
+  // If a new file was stored in the session move it into the $node.
   $nid = ($node->nid) ? $node->nid : 'new_node';
-  if (isset($_SESSION['audio_file'][$nid])) {
-    $node->audio_file = $_SESSION['audio_file'][$nid];
-    unset($_SESSION['audio_file'][$nid]);
+  if (isset($_SESSION['audio_new_file'][$nid])) {
+    $node->audio_file['file_path'] = $_SESSION['audio_new_file'][$nid];
+    $node->audio_file['newfile'] = TRUE;
+    unset($_SESSION['audio_new_file'][$nid]);
   }
   audio_invoke_audioapi('submit', $node);
 }
@@ -1367,7 +1377,7 @@
   $output = '';
 
   if (_audio_allow_play($node)) {
-    $format = $node->audio_fileinfo['fileformat'];
+    $format = $node->audio_file['file_format'];
     if (!isset($playername)) {
       $playername = variable_get('audio_player_'. $format, '1pixelout');
     }
@@ -1405,9 +1415,9 @@
   // them.
   if (preg_match('/[^-\w]/', $string)) {
     // Remove accents...
-    $string = strtr($string, 'ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ', 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy');
+    $string = strtr($string, 'ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½', 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy');
     // ...convert to equivalent chars...
-    $string = strtr($string, array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u'));
+    $string = strtr($string, array('ï¿½' => 'TH', 'ï¿½' => 'th', 'ï¿½' => 'DH', 'ï¿½' => 'dh', 'ï¿½' => 'ss', 'ï¿½' => 'OE', 'ï¿½' => 'oe', 'ï¿½' => 'AE', 'ï¿½' => 'ae', 'ï¿½' => 'u'));
     // ... and remove anything else that's not alphanumeric and replace it with an underscore.
     $string = preg_replace('/[^-\w]+/', '_', $string);
   }
@@ -1440,7 +1450,7 @@
       // The mime_header_encode function does not (yet) support
       // quoted-string encoding of ASCII strings with special
       // characters.  See discussion at http://drupal.org/node/82614
-      $filename = $node->audio_file->filename;
+      $filename = $node->audio_file['file_name'];
       // If the string contains non-ASCII characters, process it through
       // the mime_header_encode function.
       if (preg_match('/[^\x20-\x7E]/', $filename)) {
@@ -1452,11 +1462,11 @@
         $filename = '"'. str_replace('"', '\"', $filename) .'"';
       }
       $headers = array(
-        'Content-Type: '. mime_header_encode($node->audio_file->filemime),
-        'Content-Length: '. $node->audio_file->filesize,
+        'Content-Type: '. mime_header_encode($node->audio_file['file_mime']),
+        'Content-Length: '. $node->audio_file['file_size'],
         'Content-Disposition: attachment; filename='. $filename,
       );
-      audio_file_transfer($node->audio_file->filepath, $headers);
+      audio_file_transfer($node->audio_file['file_path'], $headers);
     }
     drupal_access_denied();
   }
@@ -1487,14 +1497,14 @@
         'Pragma: public',
         'Expires: 0',
         'Cache-Control: must-revalidate, post-check=0, pre-check=0, private',
-        'Content-Type: '. mime_header_encode($node->audio_file->filemime),
-        'Content-Length: '. $node->audio_file->filesize,
+        'Content-Type: '. mime_header_encode($node->audio_file['file_mime']),
+        'Content-Length: '. $node->audio_file['file_size'],
         'Content-Disposition: inline;',
         'Content-Transfer-Encoding: binary',
       );
       // Required for IE, otherwise Content-disposition is ignored.
       ini_set('zlib.output_compression', 'Off');
-      audio_file_transfer($node->audio_file->filepath, $headers);
+      audio_file_transfer($node->audio_file['file_path'], $headers);
     }
     drupal_access_denied();
   }
@@ -1552,7 +1562,7 @@
  * you've created it you can make any changes and then save it using
  * node_save().
  *
- * @param $filepath
+ * @param $file_path
  *   Full path to an audio file. be aware that the file will be moved into
  *   drupal's directory.
  * @param $title_format
@@ -1565,7 +1575,7 @@
  * @return
  *   A node or FALSE on error.
  */
-function audio_api_insert($filepath, $title_format = NULL, $tags = array()) {
+function audio_api_insert($file_path, $title_format = NULL, $tags = array()) {
   global $user;
 
   // Check for user permission.
@@ -1573,7 +1583,7 @@
     drupal_access_denied();
   }
 
-  $filepath = realpath($filepath);
+  $file_path = realpath($file_path);
 
   $node = new stdClass();
   $node->type = 'audio';
@@ -1588,31 +1598,25 @@
   if (module_exists('comment')) {
     $node->comment = variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);
   }
-
-  $node->title_format = $title_format;
+  
   $node->audio_tags = array();
   $node->audio_images = array();
 
-  $node->audio_file = new stdClass();
-  $node->audio_file->newfile = TRUE;
-  $node->audio_file->filename = basename($filepath);
-  $node->audio_file->filepath = $filepath;
-  if (function_exists('mime_content_type')) {
-    $node->audio_file->filemime = mime_content_type($filepath);
-  }
-  else {
-    // This may be a bad guess...
-    $node->audio_file->filemime = 'audio/mpeg';
-  }
-  $node->audio_file->filesize = filesize($filepath);
-
-  $node->audio_fileinfo = array(
+  $node->audio_file = array(
+    'newfile' => TRUE,
     'downloadable' => variable_get('audio_default_downloadable', 1),
     'play_count' => 0,
     'download_count' => 0,
-    'filesize' => $node->audio_file->filesize,
+    'file_size' => filesize($file_path),
+    'file_name' => basename($file_path),
+    'file_path' => $file_path,
+    'file_mime' => 'audio/mpeg', // This may be a bad guess...
   );
 
+  if (function_exists('mime_content_type')) {
+    $node->audio_file['file_mime'] = mime_content_type($file_path);
+  }
+
   // Allow other modules to modify the node (hopefully reading in tags).
   audio_invoke_audioapi('upload', $node);
 
@@ -1621,7 +1625,14 @@
     $node->audio_tags = $tags;
   }
 
-  // ...then save it.
+  // Build the title manually (since we don't call node_validate()).
+  $node->title_format = $title_format;
+  if (empty($node->title_format)) {
+    $node->title_format = variable_get('audio_default_title_format', '[audio-tag-title] by [audio-tag-artist]');
+  }
+  $node->title = token_replace($node->title_format, 'node', $node);
+  
+  // Save it.
   $node = node_submit($node);
   node_save($node);
 
@@ -1699,7 +1710,7 @@
  */
 function audio_is_flash_playable($node) {
   // Flash only supports a limited range of sample rates.
-  switch ($node->audio_fileinfo['sample_rate']) {
+  switch ($node->audio_file['sample_rate']) {
     case '44100': case '22050': case '11025':
       return TRUE;
     default:
@@ -1735,19 +1746,12 @@
     $tokens['audio-file-format'] = theme('audio_format_fileformat', $node->audio_fileinfo);
     
     // Raw file info.
-    $keys = array('sample_rate', 'channel_mode', 'bitrate', 'bitrate_mode', 'playtime');
+    $keys = array('file_name', 'file_path', 'file_mime', 'file_size', 'sample_rate', 'channel_mode', 'bitrate', 'bitrate_mode', 'playtime');
     foreach ($keys as $key) {
-      if (isset($node->audio_fileinfo[$key])) {
-        $tokens['audio-'. strtr($key, '_', '-')] = $node->audio_fileinfo[$key];
+      if (isset($node->audio_file[$key])) {
+        $tokens['audio-'. strtr($key, '_', '-')] = $node->audio_file[$key];
       }
     }
-    $keys = array('filename', 'filepath', 'filemime', 'filesize');
-    foreach ($keys as $key) {
-      if (isset($node->audio_file->$key)) {
-        $tokens['audio-'. strtr($key, '_', '-')] = $node->audio_file->$key;
-      }
-    }
-
     // Play and download links.
     if (isset($node->url_play)) {
       $tokens['audio-player'] = audio_get_node_player($node);
@@ -1788,10 +1792,10 @@
     $tokens['node']['audio-bitrate']      = t("Audio node bitrate, integer i.e. 19200.");
     $tokens['node']['audio-bitrate-mode'] = t("Audio node bitrate encoding mode, i.e vbr, cbr.");
     $tokens['node']['audio-playtime']     = t("Audio node play time, minutes:seconds.");
-    $tokens['node']['audio-filename']     = t("Audio node original, uploaded file name.");
-    $tokens['node']['audio-filepath']     = t("Audio node file path.");
-    $tokens['node']['audio-filemime']     = t("Audio node MIME type.");
-    $tokens['node']['audio-filesize']     = t("Audio node file size, in bytes.");
+    $tokens['node']['audio-file-name']    = t("Audio node original, uploaded file name.");
+    $tokens['node']['audio-file-path']    = t("Audio node file path.");
+    $tokens['node']['audio-file-mime']    = t("Audio node MIME type.");
+    $tokens['node']['audio-file-size']    = t("Audio node file size, in bytes.");
 
     // Play and download links.
     $tokens['node']['audio-player']       = t("Audio node player.");
Index: audio_getid3.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/audio_getid3.module,v
retrieving revision 1.30
diff -u -r1.30 audio_getid3.module
--- audio_getid3.module	30 Jul 2007 19:50:31 -0000	1.30
+++ audio_getid3.module	31 Jul 2007 04:04:44 -0000
@@ -50,12 +50,12 @@
 function audio_getid3_audio($op, &$node) {
   switch ($op) {
     case 'upload':
-      if ($info = audio_read_id3tags($node->audio_file->filepath, TRUE)) {
+      if ($info = audio_read_id3tags($node->audio_file['file_path'], TRUE)) {
         $node->audio_tags = $info['tags'];
         $node->audio_images = $info['images'];
         // use array_merge so that the play count and downloadable settings aren't
         // overwritten.
-        $node->audio_fileinfo = array_merge($node->audio_fileinfo, $info['fileinfo']);
+        $node->audio_file = array_merge($node->audio_file, $info['fileinfo']);
       }
       break;
 
@@ -124,55 +124,63 @@
     $node = $form['#node'];
 
     // file info
-    $form['audio_fileinfo']['#theme'] = 'audio_getid3_fileinfo_form';
-    $form['audio_fileinfo']['#description'] = t('This file information was loaded from the file by the getID3 library.');
+    $form['audio_file']['#theme'] = 'audio_getid3_fileinfo_form';
+    $form['audio_file']['#description'] = t('This file information was loaded from the file by the getID3 library.');
 
     // refresh the meta data everytime they display the edit form
-    $info = audio_read_id3tags($node->audio_file->filepath, FALSE);
+    $info = audio_read_id3tags($node->audio_file['file_path'], FALSE);
 
-    // put the fields on the form as hidden values so there's a copy for the preview
-    $fields = array('fileformat', 'filesize', 'playtime', 'sample_rate', 'channel_mode', 'bitrate', 'bitrate_mode');
+    // Put a copy of the fields we're overriding on the form as hidden values
+    // so there's something POSTed back for the preview.
+    $fields = array('file_format', 'file_size', 'playtime', 'sample_rate', 'channel_mode', 'bitrate', 'bitrate_mode');
     foreach ($fields as $key) {
-      $form['audio_fileinfo'][$key] = array(
+      $form['audio_file'][$key] = array(
         '#type' => 'hidden',
         '#default_value' => $info['fileinfo'][$key],
       );
     }
 
-    $form['audio_fileinfo']['display_fileformat'] = array(
-      '#type' => 'item', '#title' => t('Format'),
-      '#value' => $info['fileinfo']['fileformat'],
+    $form['audio_file']['display_file_format'] = array(
+      '#type' => 'item',
+      '#title' => t('Format'),
+      '#value' => $info['fileinfo']['file_format'],
     );
-    $form['audio_fileinfo']['display_filesize'] = array(
-      '#type' => 'item', '#title' => t('File Size'),
-      '#value' => t('@filesize bytes', array('@filesize' => number_format($info['fileinfo']['filesize']))),
+    $form['audio_file']['display_file_size'] = array(
+      '#type' => 'item',
+      '#title' => t('File Size'),
+      '#value' => t('@filesize bytes', array('@filesize' => number_format($info['fileinfo']['file_size']))),
     );
-    $form['audio_fileinfo']['display_playtime'] = array(
-      '#type' => 'item', '#title' => t('Length'),
+    $form['audio_file']['display_playtime'] = array(
+      '#type' => 'item',
+      '#title' => t('Length'),
       '#value' => $info['fileinfo']['playtime'],
     );
-    $form['audio_fileinfo']['display_sample_rate'] = array(
-      '#type' => 'item', '#title' => t('Sample rate'),
+    $form['audio_file']['display_sample_rate'] = array(
+      '#type' => 'item',
+      '#title' => t('Sample rate'),
       '#value' => t('@samplerate Hz', array('@samplerate' => number_format($info['fileinfo']['sample_rate']))),
     );
-    $form['audio_fileinfo']['display_channel_mode'] = array(
-      '#type' => 'item', '#title' => t('Channel mode'),
+    $form['audio_file']['display_channel_mode'] = array(
+      '#type' => 'item',
+      '#title' => t('Channel mode'),
       '#value' => ucfirst($info['fileinfo']['channel_mode']),
     );
-    $form['audio_fileinfo']['display_bitrate'] = array(
-      '#type' => 'item', '#title' => t('Bitrate'),
+    $form['audio_file']['display_bitrate'] = array(
+      '#type' => 'item',
+      '#title' => t('Bitrate'),
       '#value' => t('@bitrate bytes/second', array('@bitrate' => number_format($info['fileinfo']['bitrate']))),
     );
-    $form['audio_fileinfo']['display_bitrate_mode'] = array(
-      '#type' => 'item', '#title' => t('Bitrate mode'),
+    $form['audio_file']['display_bitrate_mode'] = array(
+      '#type' => 'item',
+      '#title' => t('Bitrate mode'),
       '#value' => strtoupper($info['fileinfo']['bitrate_mode']),
     );
 
-    // check that the audio is compatible with flash (mp3 with sample rate of
-    // 11, 22, or 44 khz). if it is not, display a warning.
+    // Check that the audio is compatible with Flash (MP3 with sample rate of
+    // 11, 22, or 44 kHz). Display a warning if it is not.
     switch ($info['fileinfo']['sample_rate']) {
       case '44100': case '22050': case '11025':
-        if ($info['fileinfo']['fileformat'] == 'mp3') {
+        if ($info['fileinfo']['file_format'] == 'mp3') {
           break;
         }
       default:
@@ -186,7 +194,7 @@
   $rows = array();
 
   // if we've got a file...
-  if (isset($form['fileformat'])) {
+  if (isset($form['file_format'])) {
     $row = array();
     // pull our items out of the form and put them into a table
     foreach (element_children($form) as $key) {
@@ -311,9 +319,9 @@
     'tags' => array(),
     'images' => array(),
     'fileinfo' => array(
-      'fileformat'   => $info['fileformat'],
-      'filesize'     => $info['filesize'],
-      'mimetype'     => $info['mime_type'],
+      'file_format'  => $info['fileformat'],
+      'file_size'    => $info['filesize'],
+      'file_mime'    => $info['mime_type'],
       'playtime'     => $info['playtime_string'],
       'bitrate'      => $info['audio']['bitrate'],
       'bitrate_mode' => $info['audio']['bitrate_mode'],
@@ -456,19 +464,19 @@
 
   // if there are any tags left, update the tags in the file
   if ($tags) {
-    if (preg_match('/\.ogg$/i', $node->audio_file->filepath)) {
+    if (preg_match('/\.ogg$/i', $node->audio_file['file_path'])) {
       $tagformats = array('vorbiscomment');
     }
     else {
       $tagformats = array('id3v1', 'id3v2.3');
     }
-    audio_write_id3tags($node->audio_file->filepath, $tags, $node->audio_images, $tagformats);
+    audio_write_id3tags($node->audio_file['file_path'], $tags, $node->audio_images, $tagformats);
   }
 
   // then reload them so that the node is in sync with the file/database...
-  $info = audio_read_id3tags($node->audio_file->filepath);
+  $info = audio_read_id3tags($node->audio_file['file_path']);
   // ...merge so that any non-written tags will be preserved...
   $node->audio_tags = array_merge($node->audio_tags, $info['tags']);
   // ...merge so that the playcount and downloadable options aren't overwritten.
-  $node->audio_fileinfo = array_merge($node->audio_fileinfo, $info['fileinfo']);
+  $node->audio_file = array_merge($node->audio_file, $info['fileinfo']);
 }
Index: audio_theme.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/audio_theme.inc,v
retrieving revision 1.8
diff -u -r1.8 audio_theme.inc
--- audio_theme.inc	31 Jul 2007 00:25:08 -0000	1.8
+++ audio_theme.inc	31 Jul 2007 03:25:56 -0000
@@ -23,8 +23,8 @@
         . theme('audio_format_tag', $tag, $node->audio_tags[$tag], $setting);
     }
   }
-  $items[] = '<strong>'. t('Length') .':</strong> '. theme('audio_format_filelength', $node->audio_fileinfo);
-  $items[] = '<strong>'. t('Format') .':</strong> '. theme('audio_format_fileformat', $node->audio_fileinfo);
+  $items[] = '<strong>'. t('Length') .':</strong> '. theme('audio_format_filelength', $node->audio_file);
+  $items[] = '<strong>'. t('Format') .':</strong> '. theme('audio_format_fileformat', $node->audio_file);
 
   $output = "<div class='audio-node block'>\n";
   // give audio_image.module (or a theme) a chance to display the images.
@@ -61,11 +61,11 @@
  * Return a string describing the node's file size and play time.
  *
  * @param $fileinfo
- *   Audio node's audio_fileinfo array.
+ *   Audio node's audio_file array.
  */
 function theme_audio_format_filelength($fileinfo) {
   $format = !empty($fileinfo['playtime']) ? '@playtime minutes (@filesize)' : '@filesize';
-  $args = array('@playtime' => check_plain($fileinfo['playtime']), '@filesize' => format_size($fileinfo['filesize'])); 
+  $args = array('@playtime' => check_plain($fileinfo['playtime']), '@filesize' => format_size($fileinfo['file_size'])); 
   return strtr($format, $args);
 }
 
@@ -79,8 +79,8 @@
   $format = '';
   $args = array();
   if (!empty($fileinfo['file_format'])) {
-    $format .= '@fileformat ';
-    $args['@fileformat'] = check_plain(strtoupper($fileinfo['fileformat']));
+    $format .= '@file_format ';
+    $args['@file_format'] = check_plain(strtoupper($fileinfo['file_format']));
   }
   if (!empty($fileinfo['channel_mode'])) {
     $format .= '@channel_mode ';
Index: views_audio.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/views_audio.inc,v
retrieving revision 1.9
diff -u -r1.9 views_audio.inc
--- views_audio.inc	23 Jul 2007 03:27:03 -0000	1.9
+++ views_audio.inc	31 Jul 2007 03:25:56 -0000
@@ -52,6 +52,12 @@
         'sortable' => FALSE,
         'help' => t('This will display a download link if the node allows it.'),
       ),
+      'file_size' => array(
+        'name' => t('Audio: File size'),
+        'handler' => 'views_handler_field_filesize',
+        'sortable' => TRUE,
+        'help' => t("This will display the audio file's size."),
+      ),
     ),
     'filters' => array(
       'downloadable' => array(
@@ -74,27 +80,6 @@
     ),
   );
 
-  $tables['audio_file'] = array(
-    'name' => 'audio_file',
-    'join' => array(
-      'left' => array(
-        'table' => 'audio',
-        'field' => 'vid'
-      ),
-      'right' => array(
-        'field' => 'vid'
-      )
-    ),
-    'fields' => array(
-      'filesize' => array(
-        'name' => t('Audio: File size'),
-        'handler' => 'views_handler_field_filesize',
-        'sortable' => TRUE,
-        'help' => t("This will display the audio file's size."),
-      ),
-    ),
-  );
-
   foreach (audio_get_tags_allowed() as $tag) {
     $tables['audio_metadata_'. $tag] = array(
       'name' => 'audio_metadata',
Index: contrib/feeds/audio_feeds.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/contrib/feeds/audio_feeds.module,v
retrieving revision 1.1
diff -u -r1.1 audio_feeds.module
--- contrib/feeds/audio_feeds.module	8 Apr 2007 07:44:40 -0000	1.1
+++ contrib/feeds/audio_feeds.module	31 Jul 2007 03:25:56 -0000
@@ -147,7 +147,7 @@
     if (node_access('view', $audio)) {
       $items[] = array('title' => $audio->audio_tags['title'],
                        'author' => $audio->audio_tags['artist'],
-                       'duration' => $audio->audio_fileinfo['playtime'],
+                       'duration' => $audio->audio_file['playtime'],
                        'enclosure' => array('url' => $audio->url_play)
                        );
     }
@@ -173,7 +173,7 @@
     if (node_access('view', $audio)) {
       $items[] = array('title' => $audio->audio_tags['title'],
                        'author' => $audio->audio_tags['artist'],
-                       'duration' => $audio->audio_fileinfo['playtime'],
+                       'duration' => $audio->audio_file['playtime'],
                        'enclosure' => array('url' => $audio->url_play)
                        );
     }
@@ -207,7 +207,7 @@
       $items[] = array('title' => $audio->audio_tags['title'],
                        'author' => $audio->audio_tags['artist'],      
                        'album' => $audio->audio_tags['album'],
-                       'duration' => $audio->audio_fileinfo['playtime'],
+                       'duration' => $audio->audio_file['playtime'],
                        'link' => url('node/'.$audio->nid, NULL,NULL, TRUE),
                        'image' => array('url' => $base_url .'/'. $image['filepath']),
                        'enclosure' => array('url' => $audio->url_play)
Index: contrib/feeds/audio_feeds_views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/contrib/feeds/audio_feeds_views.inc,v
retrieving revision 1.1
diff -u -r1.1 audio_feeds_views.inc
--- contrib/feeds/audio_feeds_views.inc	8 Apr 2007 07:44:40 -0000	1.1
+++ contrib/feeds/audio_feeds_views.inc	31 Jul 2007 03:25:56 -0000
@@ -60,7 +60,7 @@
   $items[] = array('title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,
                    'author' => $audio->audio_tags['artist'],      
                    'album' => $audio->audio_tags['album'],
-                   'duration' => $audio->audio_fileinfo['playtime'],
+                   'duration' => $audio->audio_file['playtime'],
                    'link' => url('node/'.$audio->nid, NULL, NULL, TRUE),
                    'image' => $image ? array('url' => $base_url .'/'. $image['filepath']) : '',
                    'enclosure' => array('url' => $audio->url_play)
@@ -91,7 +91,7 @@
     $audio = node_load($n->nid);
     $items[] = array('title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,
                      'author' => $audio->audio_tags['artist'],      
-                     'duration' => $audio->audio_fileinfo['playtime'],
+                     'duration' => $audio->audio_file['playtime'],
                      'enclosure' => array('url' => $audio->url_play)
                      );                
   }
@@ -119,7 +119,7 @@
     $audio = node_load($n->nid);
     $items[] = array('title' => $audio->audio_tags['title'] ? $audio->audio_tags['title'] : $audio->title,
                      'author' => $audio->audio_tags['artist'],      
-                     'duration' => $audio->audio_fileinfo['playtime'],
+                     'duration' => $audio->audio_file['playtime'],
                      'enclosure' => array('url' => $audio->url_play)
                      );                
   }
