ab1581f2 |
1 | <?php |
2 | |
3 | /** |
4 | * template.php |
5 | * |
6 | * This file is intended to contain helper functions for template sets |
7 | * that would like to use them. |
8 | FIXME: potentially create a separate directory and separate functions into different files? |
9 | * |
10 | * @copyright © 1999-2006 The SquirrelMail Project Team |
11 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
12 | * @version $Id$ |
13 | * @package squirrelmail |
14 | */ |
15 | |
16 | |
17 | /** |
18 | * Create stylesheet links that will work for multiple browsers |
19 | * |
20 | * @param string $uri The URI to the linked stylesheet. |
21 | * @param string $name The title of the stylesheet (optional; default empty). |
22 | * @param boolean $alt Whether or not this is an alternate |
23 | * stylesheet (optional; default TRUE). |
24 | * @param string $mtype The target media display type (optional; default "screen"). |
25 | * @param string $xhtml_end The XHTML-compliant close tag syntax to |
26 | * use (optional; default "/") |
27 | * |
28 | * @return string The full text of the stylesheet link. |
29 | * |
30 | */ |
31 | function create_css_link($uri, $name='', $alt=TRUE, $mtype='screen', $xhtml_end='/') { |
32 | // FIXME: Add closing / to link and meta elements only after |
33 | // switching to xhtml 1.0 Transitional. |
34 | // It is not compatible with html 4.01 Transitional |
35 | $xhtml_end=''; |
36 | |
37 | if (empty($uri)) { |
38 | return ''; |
39 | } |
40 | |
41 | // set to lower case to avoid errors |
42 | // |
43 | sqGetGlobalVar('HTTP_USER_AGENT', $browser_user_agent, SQ_SERVER); |
44 | $browser_user_agent = strtolower($browser_user_agent); |
45 | |
46 | if (stristr($browser_user_agent, "msie 4")) { |
47 | $browser = 'msie4'; |
48 | $dom_browser = false; |
49 | $is_IE = true; |
50 | } elseif (stristr($browser_user_agent, "msie")) { |
51 | $browser = 'msie'; |
52 | $dom_browser = true; |
53 | $is_IE = true; |
54 | } |
55 | |
56 | if ((strpos($uri, '-ie')!== false) and !$is_IE) { |
57 | //not IE, so don't render this sheet |
58 | return; |
59 | } |
60 | |
61 | if ( strpos($uri, 'print') !== false ) |
62 | $mtype = 'print'; |
63 | |
64 | $href = 'href="'.$uri.'" '; |
65 | $media = 'media="'.$mtype.'" '; |
66 | |
67 | if ( empty($name) ) { |
68 | $title = ''; |
69 | $rel = 'rel="stylesheet" '; |
70 | } else { |
71 | $title = 'title="'.$name.'" '; |
72 | $rel = 'rel="'.( $alt ? 'alternate ' : '' ).'stylesheet" '; |
73 | } |
74 | |
75 | return '<link '.$media.$title.$rel.'type="text/css" '.$href." $xhtml_end>\n"; |
76 | } |
77 | |
78 | |