Index: filefield.theme.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/filefield/filefield.theme.inc,v retrieving revision 1.6 diff -u -r1.6 filefield.theme.inc --- filefield.theme.inc 23 Jul 2008 17:20:49 -0000 1.6 +++ filefield.theme.inc 12 Mar 2009 03:06:21 -0000 @@ -12,7 +12,9 @@ /** * Return an image with an appropriate icon for the given file. - * Remember to pass a file object and not an array. + * + * @param $file + * A file object for which to make an icon. */ function theme_filefield_icon($file) { if (is_object($file)) { @@ -22,23 +24,50 @@ $dashed_mime = strtr($mime, array('/' => '-')); - if ($icon_url = _filefield_icon_url($file)) { + if ($icon_url = filefield_icon_url($file)) { $icon = ''; } return '
'; } -function _filefield_icon_url($file) { +/** + * Given a file object, create a URL to a matching icon. + * + * @param $file + * A file object. + * @param $theme + * Optional. The theme to be used for the icon. Defaults to the value of + * the "filefield_icon_theme" variable. + * @return + * A URL string to the icon, or FALSE if an appropriate icon could not be + * found. + */ +function filefield_icon_url($file, $theme = NULL) { global $base_url; - $theme = variable_get('filefield_icon_theme', 'protocons'); - if ($iconpath = _filefield_icon_path($file, $theme)) { + if ($iconpath = filefield_icon_path($file, $theme)) { return $base_url .'/'. $iconpath; } return FALSE; } -function _filefield_icon_path($file, $theme = 'protocons') { +/** + * Given a file object, create a URL to a matching icon. + * + * @param $file + * A file object. + * @param $theme + * Optional. The theme to be used for the icon. Defaults to the value of + * the "filefield_icon_theme" variable. + * @return + * A string to the icon as a local path, or FALSE if an appropriate icon could + * not be found. + */ +function filefield_icon_path($file, $theme = NULL) { + if (!isset($theme)) { + $theme = variable_get('filefield_icon_theme', 'protocons'); + } + // If there's an icon matching the exact mimetype, go for it. $dashed_mime = strtr($file['filemime'], array('/' => '-')); if ($iconpath = _filefield_create_icon_path($dashed_mime, $theme)) {