Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/filebrowser/README.txt,v retrieving revision 1.7.4.1 diff -u -r1.7.4.1 README.txt --- README.txt 3 Jul 2008 18:51:35 -0000 1.7.4.1 +++ README.txt 22 Aug 2008 02:51:45 -0000 @@ -14,8 +14,11 @@ - Node-based. All features available to nodes, such as path aliasing and access control can now be applied to directory listings. - Settings to limit exploration of subdirectories. - - + - File icons. This module includes part of the Tango Icon Library for use as file + icons. Many common file types are supported by default. To extend the icons you + may alter those in the "modules/filebrowser/icons" directory or override those + with your own in an "icons" directory in your theme. The file naming convention + is FILETYPE-icon.png e.g. a PHP file would need a "PHP-icon.png" icon. Fundamental changes from earlier branches: - Path aliasing is now provided by path.module since directory listings are now nodes. \ No newline at end of file Index: filebrowser.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/filebrowser/filebrowser.module,v retrieving revision 1.9.2.8.2.26 diff -u -r1.9.2.8.2.26 filebrowser.module --- filebrowser.module 20 Aug 2008 00:50:28 -0000 1.9.2.8.2.26 +++ filebrowser.module 22 Aug 2008 02:51:45 -0000 @@ -199,6 +199,7 @@ // Set the proper MIME type of the file if possible. // Try two different ways, first using Fileinfo which is the proper way // to do it. If that fails, try the deprecated mime_content_type(). + $mime_type = FALSE; if (function_exists('finfo_open')) { $handle = @finfo_open(FILEINFO_MIME); $mime_type = @finfo_file($handle, $file); @@ -462,18 +463,76 @@ * can also be requested with the second parameter. */ function filebrowser_get_fileicon($fullpath = NULL, $iconname = NULL) { + static $file_mapping = array( + 'mp3' => 'audio', + 'ogg' => 'audio', + 'oga' => 'audio', + 'm4a' => 'audio', + 'aac' => 'audio', + 'wma' => 'audio', + 'jpeg' => 'image', + 'jpg' => 'image', + 'png' => 'image', + 'gif' => 'image', + 'bmp' => 'image', + 'tif' => 'image', + 'tiff' => 'image', + 'avi' => 'video', + 'mov' => 'video', + 'mp4' => 'video', + 'm4v' => 'video', + 'mpg' => 'video', + 'mpeg' => 'video', + 'wmv' => 'video', + '3gp' => 'video', + 'ogv' => 'audio', + 'rar' => 'archive', + 'zip' => 'archive', + 'gz' => 'archive', + '7z' => 'archive', + 'txt' => 'plaintext', + 'rtf' => 'plaintext', + 'css' => 'plaintext', + 'ods' => 'spreadsheet', + 'xls' => 'spreadsheet', + 'xlsx' => 'spreadsheet', + 'odt' => 'document', + 'doc' => 'document', + 'docx' => 'document', + 'pdf' => 'document', + 'odp' => 'presentation', + 'ppt' => 'presentation', + 'pptx' => 'presentation' + ); // Determine the type of file found. - if (isset($fullpath)) { + if (!isset($iconname) && isset($fullpath)) { $iconname = (is_dir($fullpath) ? 'folder' : preg_replace("!^.+\\.([^\\.]+)$!", "\\1", $fullpath)); } - else if (!isset($iconname)) { - $iconname = 'default'; - } + + $mappedname = isset($file_mapping[$iconname])?$file_mapping[$iconname]:NULL; // Check to make sure the icon we want exists. - $icon_path = drupal_get_path('module', 'filebrowser') . "/icons/file-$iconname.png"; + // We search in the following order: + // 1 - theme directory/specific extension + // 2 - theme directory/mapped filetype + // 3 - module directory/specific extension + // 4 - module directory/mapped filetype + $icon_path = path_to_theme() . "/icons/$iconname-icon.png"; if (!file_exists($icon_path)) { - $iconname = 'default'; + if ($mappedname) { + $icon_path = path_to_theme() . "/icons/$mappedname-icon.png"; + } + if (!file_exists($icon_path)) { + $icon_path = drupal_get_path('module', 'filebrowser') . "/icons/$iconname-icon.png"; + if (!file_exists($icon_path)) { + if ($mappedname) { + $icon_path = drupal_get_path('module', 'filebrowser') . "/icons/$mappedname-icon.png"; + } + if (!file_exists($icon_path)) { + $icon_path = drupal_get_path('module', 'filebrowser') . "/icons/default-icon.png"; + } + } + } } return theme('image', $icon_path); } @@ -505,7 +564,7 @@ // Deal with folders. foreach ($folders as $foldername => $data) { $table_rows_unsorted[$foldername] = array( - array('data' => filebrowser_get_fileicon($data['path']), 'style' => 'width:1%;'), + array('data' => filebrowser_get_fileicon($data['path'], $foldername=='..'?'parent':NULL), 'style' => 'width:1%;'), l($foldername, $data['url']) . theme('mark', $data['status']), '' );