1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
function alt_media_styles($conditions = array()) {
global $theme, $theme_key, $base_path;
$check_dirs = array(path_to_theme() .'/styles');
if ($theme != $theme_key) {
$check_dirs[] = path_to_theme() ."/$theme_key/styles";
}
foreach ($check_dirs as $check_dir) {
foreach (glob("$styles_dir/*.css") as $file) {
$component = basename($file, '.css');
$css_queue[$component] = $file;
}
}
$ie_styles = '';
foreach ($css_queue as $component => $file) {
$media = isset($conditions[$component]['media']) ? $conditions[$component]['media'] : 'all';
$preprocess = isset($conditions[$component]['media']) ? $conditions[$component]['preprocess'] : TRUE;
$ie_cc = isset($conditions[$component]['IE condition']) ? $conditions[$component]['IE condition'] : FALSE;
if ($ie_cc) {
$ie_styles .= "<!--[$ie_cc]>\n<style type=\"text/css\" media=\"$media\">@import \"$base_path$file\";</style>\n<![endif]-->";
}
else {
drupal_add_css($file, 'theme', $media, $preprocess);
}
}
return array('styles' => drupal_add_css(), 'IE styles' => $ie_styles);
}
|