--- inline.module.cvs	2006-05-04 03:03:00.000000000 +0200
+++ inline.module	2006-07-20 14:02:08.364539900 +0200
@@ -124,6 +124,7 @@ function _inline_fileobj(&$node, $id) {
     $n=1;
     foreach ($node->files as $file) {
       if ($n == $id) {
+        $file->url = file_create_url($file->filepath);
         return $file;
       }
       ++$n;
@@ -134,7 +135,7 @@ function _inline_fileobj(&$node, $id) {
   {
     foreach ($node->files as $file) {
       if ($file->filename == $id) {
-        //return array($file->filename, $file->filepath);
+        $file->url = file_create_url($file->filepath);
         return $file;
       }
     }
@@ -142,11 +143,43 @@ function _inline_fileobj(&$node, $id) {
   }
 }
 
+/**
+ * Theme $file as inline link.
+ * Displays file type icon if exists in ./themes/<template>/mime/<mime-type>.png.
+ * Mime types are converted to simple extensions, i.e. 'application/zip' becomes
+ * 'zip', 'image/jpeg' => 'jpeg'. If no corresponding mime file type icon is present,
+ * double quotes are preprended.
+ * 
+ * @param object $file The file object holding file information.
+ * @return Themed inline file link.
+ */
 function theme_inline_as_link($file) {
-  return l(($file->description ? $file->description : $file->name),
-    file_create_url($file->filepath),
-    array('title' => t('Download: %name (%size)',
-      array('%name' => $file->filename, '%size' => format_size($file->filesize)))));
+  // prepare link text with title or filename
+  $linktext = ($file->title ? $file->title : $file->filename);
+  
+  // prepend file type icon as separate link (if exists) or prepend plain symbol
+  // if file type icon exists, generate a separate link with the icon.
+  // if no file type icon exists, put everything into one link.
+  $mimeimg = base_path() . path_to_theme() .'/mime/'. array_pop(explode('/', $file->filemime)) .'.png';
+  if (file_exists( '.'. $mimeimg )) {
+    $fileicon = l('<img src="'. $mimeimg .'" alt="'. $file->filemime .'" style="vertical-align: bottom;" />', $file->url, array('title' => t('Download: %name (%size)', array('%name' => $file->filename, '%size' => format_size($file->filesize)))), NULL, NULL, TRUE, TRUE);
+    $fileicon.= '&nbsp;';
+  } else {
+    $fileicon = '';
+    $linktext = '&raquo;&nbsp;' . $linktext;
+  }
+  // prepare link
+  $linktext = l($linktext, $file->url, array('title' => t('Download: %name (%size)', array('%name' => $file->filename, '%size' => format_size($file->filesize)))), NULL, NULL, TRUE, TRUE);
+  
+  // prepare file link
+  $filelink = $fileicon . $linktext;
+  
+  // generate output
+  $output = '<dl class="inline">';
+  $output.= '<dt>'. $filelink .' <small>('. format_size($file->filesize) .')</small></dt>';
+  $output.= ($file->description ? '<dd><small>'. $file->description .'</small></dd>' : '');
+  $output.= '</dl>';
+  return $output;
 }
 
 function theme_inline_img($file) {
@@ -220,10 +253,13 @@ function _inline_auto_add($node) {
 function _inline_substitute_tags(&$node, $field) {
   if (preg_match_all("/\[(inline|file|attachment):([^=\\]]+)=?([^\\]]*)?\]/i", $node->$field, $match)) {
     foreach ($match[2] as $key => $value) {
-      $map[$value] = $key;
-      $titl = $match[3][$key];
-      $ytype = $match[1][$key];
+      // fetch file object
       $file = _inline_fileobj($node, $value);
+      // deal with file title
+      $title = $match[3][$key];
+      if (!empty( $title )) {
+        $file->title = $title;
+      }
       $replace = "";
       if ($file->fid != NULL) {
         //decide if we should show a link or an img tag
