\n"; } /** * Checks for an image icon and returns a complete image tag or a text * string with the text icon based on what is found and user prefs. * * @param string $icon_theme_path User's chosen icon set * @param string $icon_name File name of the desired icon * @param string $text_icon Text-based icon to display if desired * @param string $alt_text Optional. Text for alt/title attribute of image * @param integer $w Optional. Width of requested image. * @param integer $h Optional. Height of requested image. * @return string $icon String containing icon that can be echo'ed * @author Steve Brown * @since 1.5.2 */ function getIcon($icon_theme_path, $icon_name, $text_icon, $alt_text='', $w=NULL, $h=NULL) { $icon = ''; if (is_null($icon_theme_path)) { $icon = $text_icon; } else { $icon_path = getIconPath($icon_theme_path, $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 (!is_null($icon_path)) { global $oTemplate; $oTemplate->assign('src', $icon_path); $oTemplate->assign('alt', $alt_text); $oTemplate->assign('title', $alt_text); $oTemplate->assign('width', $w); $oTemplate->assign('height', $h); // blank other attributes because the template // object might already contain values due to // having been used to show another image before // this one // $oTemplate->assign('onclick', ''); $oTemplate->assign('align', ''); $oTemplate->assign('border', ''); $oTemplate->assign('hspace', ''); $oTemplate->assign('vspace', ''); $oTemplate->assign('class', ''); $oTemplate->assign('id', ''); $icon = $oTemplate->fetch('image.tpl'); } else { $icon = $text_icon; } } return $icon; } /** * 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 $fallback_icon_theme_path; 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 fallback } elseif (!is_null($fallback_icon_theme_path) && is_file($fallback_icon_theme_path . $icon_name)) { return $fallback_icon_theme_path . $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. //FIXME: I think this is needless since there is no reason templates cannot just call directly to show_readable_size * * @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); }