summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-08-04 20:40:01 +0000
committerDries Buytaert <dries@buytaert.net>2004-08-04 20:40:01 +0000
commitc71bfded3dea1754633f29ac8e81fb3ab46b766a (patch)
tree77a7a843b7b6d9c0f857c749b9acbab19c1f8e94 /includes
parenta52cf8297aa8c012065a4cb4e3f6a6ee3e258fc1 (diff)
downloadbrdo-c71bfded3dea1754633f29ac8e81fb3ab46b766a.tar.gz
brdo-c71bfded3dea1754633f29ac8e81fb3ab46b766a.tar.bz2
- Patch #9657: more intelligent theme() function. Hopefully, Adrian will be
able to use this patch too.
Diffstat (limited to 'includes')
-rw-r--r--includes/tablesort.inc2
-rw-r--r--includes/theme.inc23
2 files changed, 18 insertions, 7 deletions
diff --git a/includes/tablesort.inc b/includes/tablesort.inc
index e80eb544f..56d805e1b 100644
--- a/includes/tablesort.inc
+++ b/includes/tablesort.inc
@@ -77,8 +77,8 @@ function tablesort_header($cell, $header, $ts) {
if ($cell['data'] == $ts['name']) {
$ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc');
$cell['class'] = 'active';
- $image = '&nbsp;<img src="' . theme('image', 'arrow-' . $ts['sort'] . '.png') . '" alt="'. t('sort icon') .'" />';
$title = ($ts['sort'] == 'asc' ? t('sort ascending') : t('sort descending'));
+ $image = '&nbsp;'. theme('image', 'misc/arrow-'. $ts['sort'] .'.png', t('sort icon'), $title);
}
else {
// If the user clicks a different header, we want to sort ascending initially.
diff --git a/includes/theme.inc b/includes/theme.inc
index c43b45df6..60f9dfe43 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -235,13 +235,22 @@ function theme_links($links, $delimiter = ' | ') {
/**
* Return a themed image.
*
- * @param $name
- * The name of the image file.
+ * @param $path
+ * The path of the image file.
+ * @param $alt
+ * The alternative text for text-based browsers.
+ * @param $title
+ * The title text is displayed when the image is hovered in some popular browsers.
+ * @param $attr
+ * Attributes placed in the img tag.
+ * This parameter overrides the default auto-detection of width and height.
* @return
- * The pathname of the themed image.
+ * A string containing the image tag.
*/
-function theme_image($name) {
- return 'misc/'. $name;
+function theme_image($path, $alt = NULL, $title = NULL, $attr = NULL) {
+ if (isset($attr) || (file_exists($path) && (list($width, $height, $type, $attr) = getimagesize($path)))) {
+ return "<img src=\"$path\" $attr alt=\"$alt\" title=\"$title\" />";
+ }
}
/**
@@ -511,7 +520,9 @@ function theme_error($message) {
* Return code that emits an XML icon.
*/
function theme_xml_icon($url) {
- return '<div class="xml-icon"><a href="'. $url .'"><img src="misc/xml.png" width="36" height="14" alt="'. t('XML feed') .'" /></a></div>';
+ if ($image = theme('image', 'misc/xml.png', t('XML feed'), t('XML feed'))) {
+ return '<div class="xml-icon"><a href="'. $url .'">'. $image. '</a></div>';
+ }
}
/**