29997535 |
1 | <?php |
2 | /** |
3 | * util_global.php |
4 | * |
5 | * Utility functions for use with all templates. Do not echo output here! |
6 | * |
7 | * @copyright © 1999-2006 The SquirrelMail Project Team |
8 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
9 | * @version $Id$ |
10 | * @package squirrelmail |
11 | * @subpackage templates |
12 | */ |
13 | |
14 | /** |
15 | * Checks for an image icon and returns a complete HTML img tag or a text |
16 | * string with the text icon based on what is found and user prefs. |
17 | * |
18 | * @param string $icon_theme_path User's chosen icon set |
19 | * @param string $icon_name File name of the desired icon |
20 | * @param string $text_icon Text-based icon to display if desired |
21 | * @param string $alt_text Optional. Text for alt/title attribute of image |
22 | * @param integer $w Optional. Width of requested image. |
23 | * @param integer $h Optional. Height of requested image. |
24 | * @return string $icon String containing icon that can be echo'ed |
25 | * @author Steve Brown |
26 | * @since 1.5.2 |
27 | */ |
28 | function getIcon($icon_theme_path, $icon_name, $text_icon, $alt_text='', $w=NULL, $h=NULL) { |
29 | $icon = ''; |
30 | if (is_null($icon_theme_path)) { |
31 | $icon = $text_icon; |
32 | } else { |
33 | // Desired icon exists in the current theme? |
34 | if (is_file($icon_theme_path . $icon_name)) { |
35 | $icon_path = $icon_theme_path . $icon_name; |
36 | |
37 | // Icon not found, return the SQM default icon |
38 | } elseif (is_file(SM_PATH . 'images/themes/default/'.$icon_name)) { |
39 | $icon_path = SM_PATH . 'images/themes/default/'.$icon_name; |
40 | } |
41 | |
42 | // If we found an icon, build an img tag to display it. If we didn't |
43 | // find an image, we will revert back to the text icon. |
44 | if (!is_null($icon_path)) { |
45 | $icon = '<img src="'.$icon_path.'" ' . |
46 | (!empty($alt_text) ? 'alt="'.$alt_text.'" title="'.$alt_text.'" ' : '') . |
47 | (!is_null($w) ? 'width="'.$w.'" ' : '') . |
48 | (!is_null($h) ? 'height="'.$h.'" ' : '') . |
49 | ' />'; |
50 | } else { |
51 | $icon = $text_icon; |
52 | } |
53 | } |
54 | return $icon; |
55 | } |
56 | ?> |