add purge link when folder contains subfolders.
[squirrelmail.git] / templates / util_css.php
CommitLineData
343200c7 1<?php
2/**
3 * util_css.php
4 *
5 * CSS Utility functions for use with all templates. Do not echo output here!
6 *
7 * @copyright &copy; 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 * Function to list files within a css directory, used when querying for theme directories
16 *
17**/
18function list_css_files($cssdir,$cssroot) {
19 if (!$cssroot OR !$cssdir) return false;
20 $files=array();
21 if (is_dir($cssdir)) {
22 if ($dh = opendir($cssdir)) {
23 while (($file = readdir($dh)) !== false) {
24 if ((strlen($file)>3) AND strtolower(substr($file,strlen($file)-3,3))=='css') {
25 $files[$file]="$cssroot/$file";
26 }
27 }
28 }
29 closedir($dh);
30 }
31 if (count($files)>0) {
32// sort($files);
33 return $files;
34 }
35 return false;
36}
37
38/**
39 * Function to create stylesheet links that will work for multiple browsers
40 *
41**/
42function css_link($url, $name = null, $alt = true, $mtype = 'screen', $xhtml_end='/') {
43 global $http_site_root;
44
45 if ( empty($url) )
46 return '';
47 // set to lower case to avoid errors
48 $browser_user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
49
50 if (stristr($browser_user_agent, "msie 4"))
51 {
52 $browser = 'msie4';
53 $dom_browser = false;
54 $is_IE = true;
55 }
56 elseif (stristr($browser_user_agent, "msie"))
57 {
58 $browser = 'msie';
59 $dom_browser = true;
60 $is_IE = true;
61 }
62
63 if ((strpos($url, '-ie')!== false) and !$is_IE) {
64 //not IE, so don't render this sheet
65 return;
66 }
67
68 if ( strpos($url, 'print') !== false )
69 $mtype = 'print';
70
71 $href = 'href="'.$url.'" ';
72 $media = 'media="'.$mtype.'" ';
73
74 if ( empty($name) ) {
75 $title = '';
76 $rel = 'rel="stylesheet" ';
77 } else {
78 $title = empty($name) ? '' : 'title="'.$name.'" ';
79 $rel = 'rel="'.( $alt ? 'alternate ' : '' ).'stylesheet" ';
80 }
81
82 return ' <link '.$media.$title.$rel.'type="text/css" '.$href." $xhtml_end>\n";
83}
84
85