X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=templates%2Futil_global.php;h=9ef9e040eca869e7ed834c8bf55df816f4a80446;hp=62ce430988fc7a3de6bf85241bcb73abb72a2cfb;hb=b2c3dc092aa1df94a5db56a94917fe14982e4be6;hpb=2198d485d5b406f3f007f5c0146b275fb8272326 diff --git a/templates/util_global.php b/templates/util_global.php index 62ce4309..9ef9e040 100644 --- a/templates/util_global.php +++ b/templates/util_global.php @@ -30,20 +30,14 @@ function getIcon($icon_theme_path, $icon_name, $text_icon, $alt_text='', $w=NULL if (is_null($icon_theme_path)) { $icon = $text_icon; } else { - // Desired icon exists in the current theme? - if (is_file($icon_theme_path . $icon_name)) { - $icon_path = $icon_theme_path . $icon_name; + $icon_path = getIconPath($icon_theme_path, $icon_name); - // Icon not found, return the SQM default icon - } elseif (is_file(SM_PATH . 'images/themes/default/'.$icon_name)) { - $icon_path = SM_PATH . 'images/themes/default/'.$icon_name; - } - // If we found an icon, build an img tag to display it. If we didn't // find an image, we will revert back to the text icon. - if (isset($icon_path) && !is_null($icon_path)) { + if (!is_null($icon_path)) { $icon = ''; @@ -53,4 +47,63 @@ function getIcon($icon_theme_path, $icon_name, $text_icon, $alt_text='', $w=NULL } return $icon; } -?> \ No newline at end of file + +/** + * Gets the path to the specified icon or returns NULL if the image is not + * found. This has been separated from getIcon to allow the path to be fetched + * for use w/ third party packages, e.g. dTree. + * + * @param string $icon_theme_path User's chosen icon set + * @param string $icon_name File name of the desired icon + * @return string $icon String containing path to icon that can be used in + * an IMG tag, or NULL if the image is not found. + * @author Steve Brown + * @since 1.5.2 + */ +function getIconPath ($icon_theme_path, $icon_name) { + global $default_icon_theme; + + if (is_null($icon_theme_path)) + return NULL; + + // Desired icon exists in the current theme? + if (is_file($icon_theme_path . $icon_name)) { + return $icon_theme_path . $icon_name; + + // Icon not found, check for the admin-specified default + } elseif (!is_null($default_icon_theme) && is_file($default_icon_theme . $icon_name)) { + return $default_icon_theme . $icon_name; + + // Icon not found, return the SQM default icon + } elseif (is_file(SM_PATH . 'images/themes/default/'.$icon_name)) { + return SM_PATH . 'images/themes/default/'.$icon_name; + } + + return NULL; +} + +/** + * Display error messages for use in footer.tpl + * + * @author Steve Brown + * @since 1.5.2 + **/ +function displayErrors () { + global $oErrorHandler; + + if ($oErrorHandler) { + $oErrorHandler->displayErrors(); + } +} + +/** + * Make the internal show_readable_size() function available to templates. + * + * @param int size to be converted to human-readable + * @return string human-readable form + * @since 1.5.2 + **/ +function humanReadableSize ($size) { + return show_readable_size($size); +} +