diff options
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/ajax.class.php | 2 | ||||
-rw-r--r-- | lib/class/ampache_rss.class.php | 2 | ||||
-rw-r--r-- | lib/class/playlist_object.abstract.php | 2 | ||||
-rw-r--r-- | lib/class/ui.class.php | 59 |
4 files changed, 62 insertions, 3 deletions
diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php index de217330..04098861 100644 --- a/lib/class/ajax.class.php +++ b/lib/class/ajax.class.php @@ -123,7 +123,7 @@ class Ajax { $class = ' class="' . $class . '"'; } - $string = get_user_icon($icon,$alt); + $string = UI::get_icon($icon,$alt); // Generate an <a> so that it's more compliant with older // browsers (ie :hover actions) and also to unify linkbuttons diff --git a/lib/class/ampache_rss.class.php b/lib/class/ampache_rss.class.php index 3b567937..3056e9cf 100644 --- a/lib/class/ampache_rss.class.php +++ b/lib/class/ampache_rss.class.php @@ -113,7 +113,7 @@ class Ampache_RSS { // Default to now playing $type = self::validate_type($type); - $string = '<a href="' . Config::get('web_path') . '/rss.php?type=' . $type . '">' . get_user_icon('feed', T_('RSS Feed')) . '</a>'; + $string = '<a href="' . Config::get('web_path') . '/rss.php?type=' . $type . '">' . UI::get_icon('feed', T_('RSS Feed')) . '</a>'; return $string; diff --git a/lib/class/playlist_object.abstract.php b/lib/class/playlist_object.abstract.php index 48eefb0d..d232d6d7 100644 --- a/lib/class/playlist_object.abstract.php +++ b/lib/class/playlist_object.abstract.php @@ -40,7 +40,7 @@ abstract class playlist_object extends database_object { public function format() { $this->f_name = UI::truncate($this->name,Config::get('ellipse_threshold_title')); - $this->f_type = ($this->type == 'private') ? get_user_icon('lock', T_('Private')) : ''; + $this->f_type = ($this->type == 'private') ? UI::get_icon('lock', T_('Private')) : ''; $client = new User($this->user); diff --git a/lib/class/ui.class.php b/lib/class/ui.class.php index c3d69198..f37c5a36 100644 --- a/lib/class/ui.class.php +++ b/lib/class/ui.class.php @@ -27,6 +27,7 @@ class UI { private static $_classes; private static $_ticker; + private static $_icon_cache; public function __construct($data) { return false; @@ -104,6 +105,64 @@ class UI { } /** + * get_icon + * + * Returns an <img> tag for the specified icon + */ + public static function get_icon($name, $title = null, $id = null) { + if (is_array($name)) { + $hover_name = $name[1]; + $name = $name[0]; + } + + $title = $title ?: T_(ucfirst($name)); + + $icon_url = self::_find_icon($name); + if ($hover_name) { + $hover_url = self::_find_icon($hover_text); + } + + $tag = '<img src="' . $icon_url . '" '; + + if ($id) { + $tag .= 'id="' . $id . '" '; + } + + $tag .= 'alt="' . $title . '" '; + $tag .= 'title="' . $title . '" '; + + if ($hover_name) { + $tag .= 'onmouseover="this.src=\'' . $hover_url . '\'; return true;"'; + $tag .= 'onmouseout="this.src=\'' . $icon_url . '\'; return true;" '; + } + + $tag .= '/>'; + return $tag; + } + + /** + * _find_icon + * + * Does the finding icon thing + */ + private static function _find_icon($name) { + if ($url = self::$_icon_cache[$name]) { + return $url; + } + + $filename = 'icon_' . $name . '.png'; + $path = Config::get('theme_path') . '/images/icons/'; + if (!file_exists(Config::get('prefix') . $path . $filename)) { + $path = '/images/'; + } + $url = Config::get('web_path') . $path . $filename; + self::$_icon_cache[$name] = $url; + + return $url; + } + + + /** * show_header * * For now this just shows the header template |