--- disknode.inc.orig	2007-08-30 04:42:35.000000000 +0300
+++ disknode.inc	2007-11-06 05:42:39.000000000 +0200
@@ -95,43 +95,62 @@
   return $items;
 }
 
-if (intval(variable_get("disknode_maxfiles", 1)) == 1) {
-
-  function theme_disknode_links($file)
-  {
-	/*
-    $links = array();
-    $links[] = t('Downloads: %counter', array('%counter' => $file->downloads));
-	echo('@@');
-    //$links[] = l(t('download'), "disknode/get/".$file->fid."/".rawurlencode($file->filename), array("title" => "Download ".$file->filename , "rel" => "nofollow" ), "download")." (".format_size($file->filesize).")";
-    return $links;
-	*/
-	
+/**
+ * If only one file is attached to the node, and if Disknode is configured to
+ * a maximum of one attached file, then we print the link to this one file
+ * during hook_link().
+ */
+function theme_disknode_one_link($file)
+{
   $links = array();
+  
   $links['disknode_download_counter'] = array(
-	'title' => t('Downloads: !counter', array('!counter' => $file->downloads)),
+    'title' => t('Downloads: !counter', array('!counter' => $file->downloads)),
   );
   $links['disknode_download_link'] = array(
-	'title' => t('download'),
-	'href' => "disknode/get/".$file->fid."/".rawurlencode($file->filename),
-	'attributes' => array("title" => "Download ".$file->filename , "rel" => "nofollow", "type" => "application/octet-stream" )
+    'title' => t('download'),
+    'href' => "disknode/get/$file->fid/". rawurlencode($file->filename),
+    'attributes' => array(
+      'title' => t('Download @file', array('@file' => $file->filename)),
+      'rel' => 'nofollow',
+      'type' => 'application/octet-stream',
+    )
   );
   $links['disknode_download_size'] = array(
-	'title' => t('(!size)', array('!size' => format_size($file->filesize))),
+    'title' => t('(!size)', array('!size' => format_size($file->filesize))),
   );
-  return $links;
-  }
 
+  return $links;
 }
-else {
 
-  function theme_disknode_links($file)
-  {
-    $links = array();
-    $links[] = l(t('%filename', array("%filename" => $file->filename)), "disknode/get/".$file->fid."/".rawurlencode($file->filename), array("title" => "Download ".$file->filename , "rel" => "nofollow" ), "download")." ".t('(%counter %dl | %size)', array('%counter' => $file->downloads, '%dl' => format_plural($file->downloads, 'download', 'downloads'), '%size' => format_size($file->filesize)));
-    return $links;
-  }
+/**
+ * If more than one file is attached to the node, we print their links in a
+ * table.
+ *
+ * TODO: the right place to call this is from hook_nodeapi($op=='view'),
+ * and it should be done --when the maintainers decide to end the 'backward
+ * compatibility' of the source code.
+ */
+function theme_disknode_multiple_links($files)
+{
+  $links = array();
 
+  $header = array(t('File'), t('Size'), t('Downloads count'));
+  $rows = array();
+  foreach ($files as $file) {
+    $rows[] = array(
+      l($file->filename, "disknode/get/$file->fid/". rawurlencode($file->filename)),
+      format_size($file->filesize),
+      $file->downloads,
+    );
+  }
+  $output = theme('table', $header, $rows);
+
+  $links['disknode_files'] = array(
+    'title' => $output,
+    'html' => TRUE,
+  );
+  return $links;
 }
 
 /**
@@ -139,10 +158,11 @@
  */
 function __disknode_link($type, $node = 0, $main = 0) {
   $links = array();
-  if ($type == 'node' /*&& $node->type == 'disknode'*/ && is_array($node->disknodefiles)) {
-    foreach ($node->disknodefiles as $file)
-    {
-      $links = theme('disknode_links', $file);
+  if ($type == 'node' && is_array($node->disknodefiles) && $node->disknodefiles) {
+    if (variable_get("disknode_maxfiles", 1) == 1 && count($node->disknodefiles) == 1) {
+      $links = theme('disknode_one_link', $node->disknodefiles[0]);
+    } else {
+      $links = theme('disknode_multiple_links', $node->disknodefiles);
     }
   }
   return $links;
