Index: modules/aggregator/aggregator.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.pages.inc,v
retrieving revision 1.15
diff -u -r1.15 aggregator.pages.inc
--- modules/aggregator/aggregator.pages.inc	16 Jul 2008 21:59:25 -0000	1.15
+++ modules/aggregator/aggregator.pages.inc	5 Aug 2008 21:49:47 -0000
@@ -272,6 +272,8 @@
     $variables['source_date'] = format_date($item->timestamp, 'custom', variable_get('date_format_medium', 'D, m/d/Y - H:i'));
   }
 
+  $variables['enclosure'] = l($item->eurl, $item->eurl);
+
   $variables['categories'] = array();
   foreach ($item->categories as $category) {
     $variables['categories'][$category->cid] = l($category->title, 'aggregator/categories/' . $category->cid);
Index: modules/aggregator/aggregator.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v
retrieving revision 1.384
diff -u -r1.384 aggregator.module
--- modules/aggregator/aggregator.module	3 Aug 2008 18:17:37 -0000	1.384
+++ modules/aggregator/aggregator.module	5 Aug 2008 21:49:47 -0000
@@ -469,6 +469,13 @@
     case 'INFO':
       $element = $name;
       break;
+    case 'ENCLOSURE':
+      if ($element == 'ITEM') {
+        $items[$item]['EURL'] = !empty($attributes['URL']) ? $attributes['URL'] : '';
+        $items[$item]['ELENGTH'] = !empty($attributes['LENGTH']) ? $attributes['LENGTH'] : '';
+        $items[$item]['ETYPE'] = !empty($attributes['TYPE']) ? $attributes['TYPE'] : '';
+      }
+      break;
     case 'ID':
       if ($element != 'ITEM') {
         $element = $name;
@@ -601,6 +608,7 @@
     case 307:
       // Filter the input data.
       if (aggregator_parse_feed($result->data, $feed)) {
+        $etag = empty($result->headers['ETag']) ? '' : $result->headers['ETag'];
         $modified = empty($result->headers['Last-Modified']) ? 0 : strtotime($result->headers['Last-Modified']);
 
         // Prepare the channel data.
@@ -622,7 +630,7 @@
           $image = NULL;
         }
 
-        $etag = empty($result->headers['ETag']) ? '' : $result->headers['ETag'];
+        $channel += array('LINK' => '', 'DESCRIPTION' => '');
         // Update the feed data.
         db_query("UPDATE {aggregator_feed} SET url = '%s', checked = %d, link = '%s', description = '%s', image = '%s', etag = '%s', modified = %d WHERE fid = %d", $feed['url'], time(), $channel['LINK'], $channel['DESCRIPTION'], $image, $etag, $modified, $feed['fid']);
 
@@ -718,9 +726,9 @@
   $items = array_reverse($items);
 
   // Initialize variables.
-  $title = $link = $author = $description = $guid = NULL;
+  $title = $link = $enclosure = $guid = NULL;
   foreach ($items as $item) {
-    unset($title, $link, $author, $description, $guid);
+    unset($title, $link, $enclosure, $guid);
 
     // Prepare the item:
     foreach ($item as $key => $value) {
@@ -760,6 +768,17 @@
       $item['DESCRIPTION'] = $item['CONTENT'];
     }
 
+    if (isset($item['EURL']) && !empty($item['EURL'])) {
+      $enclosure['url'] = $item['EURL'];
+      $enclosure['length'] = (int) $item['ELENGTH'];
+      $enclosure['type'] = $item['ETYPE'];
+    }
+    else {
+      $enclosure['url'] = '';
+      $enclosure['length'] = 0;
+      $enclosure['type'] = '';
+    }
+
     // Try to resolve and parse the item's publication date. If no date is
     // found, use the current date instead.
     $date = 'now';
@@ -793,7 +812,7 @@
       $entry = db_fetch_object(db_query("SELECT iid FROM {aggregator_item} WHERE fid = %d AND title = '%s'", $feed['fid'], $title));
     }
     $item += array('AUTHOR' => '', 'DESCRIPTION' => '');
-    aggregator_save_item(array('iid' => (isset($entry->iid) ? $entry->iid:  ''), 'fid' => $feed['fid'], 'timestamp' => $timestamp, 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION'], 'guid' => $guid));
+    aggregator_save_item(array('iid' => (isset($entry->iid) ? $entry->iid:  ''), 'fid' => $feed['fid'], 'timestamp' => $timestamp, 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION'], 'enclosure' => $enclosure, 'guid' => $guid));
   }
 
   // Remove all items that are older than flush item timer.
@@ -822,16 +841,18 @@
  */
 function aggregator_save_item($edit) {
   if ($edit['iid'] && $edit['title']) {
-    db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s', guid = '%s', timestamp = %d WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['guid'], $edit['timestamp'], $edit['iid']);
+    $enclosure = $edit['enclosure'];
+    db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s', eurl = '%s', elength = %d, etype = '%s', guid = '%s', timestamp = %d WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $enclosure['url'], $enclosure['length'], $enclosure['type'], $edit['guid'], $edit['timestamp'], $edit['iid']);
   }
   elseif ($edit['iid']) {
     db_query('DELETE FROM {aggregator_item} WHERE iid = %d', $edit['iid']);
     db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $edit['iid']);
   }
   elseif ($edit['title'] && $edit['link']) {
-    db_query("INSERT INTO {aggregator_item} (fid, title, link, author, description, timestamp, guid) VALUES (%d, '%s', '%s', '%s', '%s', %d, '%s')", $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp'], $edit['guid']);
+    $enclosure = $edit['enclosure'];
+    db_query("INSERT INTO {aggregator_item} (fid, title, link, author, description, eurl, elength, etype, timestamp, guid) VALUES (%d, '%s', '%s', '%s', '%s', '%s', %d, '%s', %d, '%s')", $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $enclosure['url'], $enclosure['length'], $enclosure['type'], $edit['timestamp'], $edit['guid']);
     $edit['iid'] = db_last_insert_id('aggregator_item', 'iid');
-    // file the items in the categories indicated by the feed
+    // File the items in the categories indicated by the feed.
     $categories = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']);
     while ($category = db_fetch_object($categories)) {
       db_query('INSERT INTO {aggregator_category_item} (cid, iid) VALUES (%d, %d)', $category->cid, $edit['iid']);
Index: modules/aggregator/aggregator.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.install,v
retrieving revision 1.16
diff -u -r1.16 aggregator.install
--- modules/aggregator/aggregator.install	15 May 2008 21:27:32 -0000	1.16
+++ modules/aggregator/aggregator.install	5 Aug 2008 21:49:46 -0000
@@ -227,6 +227,24 @@
         'size' => 'big',
         'description' => t('Body of the feed item.'),
       ),
+      'eurl' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+        'description' => t('URL to the enclosure.'),
+      ),
+      'elength' => array(
+        'type' => 'int',
+        'not null' => FALSE,
+        'description' => t('Length of the enclosure in bytes.'),
+      ),
+      'etype' => array(
+        'type' => 'varchar',
+        'length' => 32,
+        'not null' => FALSE,
+        'description' => t('Type of the enclosure, should be a standard MIME type.'),
+      ),
       'timestamp' => array(
         'type' => 'int',
         'not null' => FALSE,
@@ -247,3 +265,14 @@
 
   return $schema;
 }
+
+/**
+ * Add enclosure related fields to aggregator_item table.
+ */
+function aggregator_update_7000() {
+  $ret = array();
+  db_add_field($ret, 'aggregator_item', 'eurl', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
+  db_add_field($ret, 'aggregator_item', 'elength', array('type' => 'int', 'not null' => FALSE));
+  db_add_field($ret, 'aggregator_item', 'etype', array('type' => 'varchar', 'length' => 32, 'not null' => FALSE));
+  return $ret;
+}
Index: modules/aggregator/aggregator-item.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator-item.tpl.php,v
retrieving revision 1.2
diff -u -r1.2 aggregator-item.tpl.php
--- modules/aggregator/aggregator-item.tpl.php	15 May 2008 21:27:32 -0000	1.2
+++ modules/aggregator/aggregator-item.tpl.php	5 Aug 2008 21:49:46 -0000
@@ -37,6 +37,12 @@
   </div>
 <?php endif; ?>
 
+<?php if ($enclosure) : ?>
+  <div class="feed-item-enclosure">
+    <?php print t('Enclosure'); ?>: <?php print $enclosure; ?>
+  </div>
+<?php endif; ?>
+
 <?php if ($categories) : ?>
   <div class="feed-item-categories">
     <?php print t('Categories'); ?>: <?php print implode(', ', $categories); ?>
