1
|
<?php
|
2
|
global $_theme_name;
|
3
|
$_theme_name = $GLOBALS['theme_key'];
|
4
|
|
5
|
/**
|
6
|
* @file
|
7
|
* Provides frequently used functions that load something, ususally CSS or JS
|
8
|
* files, or that provide assistance to those loaders.
|
9
|
*/
|
10
|
|
11
|
/**
|
12
|
* Load stylesheet to set the layout.
|
13
|
*
|
14
|
* Each time you save the theme settings MAYO builds a layout stylesheet:
|
15
|
* The file is named: themeName.responsive.layout.css
|
16
|
*
|
17
|
* @param $path
|
18
|
* @param $theme_name
|
19
|
*/
|
20
|
function mayo_load_layout_css($path, $theme_name) {
|
21
|
global $_theme_name;
|
22
|
// Get the info file data
|
23
|
$info = mayo_get_info($theme_name);
|
24
|
|
25
|
// Load the responsive layout
|
26
|
$filepath = $path . '/' . $theme_name . '.responsive.layout.css';
|
27
|
$media_query = 'only screen'; // keyword "only" hide this from unsupporting user agents
|
28
|
mayo_load_subtheme_responsive_styles($filepath, $media_query, $theme_name, $weight = 0);
|
29
|
}
|
30
|
|
31
|
/**
|
32
|
* Load Sub-theme Responsive Stylesheets.
|
33
|
* Wrapper function for drupal_add_css() that takes advantage of Drupals's
|
34
|
* CSS aggregation logic to trick Drupal into always loading responsive
|
35
|
* stylesheets in link elements.
|
36
|
*
|
37
|
* This is almost always called from mayo_preprocess_html(), only in
|
38
|
* a rare instance might this be called from a sub-theme (to load additional
|
39
|
* responsive stylesheets).
|
40
|
*
|
41
|
* @param $filepath, path to the CSS file.
|
42
|
* @param $media_query, the media query from theme settings.
|
43
|
* @param $theme_name, the active theme.
|
44
|
* @param $weight, optional.
|
45
|
*/
|
46
|
function mayo_load_subtheme_responsive_styles($filepath, $media_query, $theme_name, $weight = 0) {
|
47
|
if (file_exists($filepath)) {
|
48
|
drupal_add_css($filepath, array(
|
49
|
'preprocess' => variable_get('preprocess_css', '') == 1 ? TRUE : FALSE,
|
50
|
'group' => CSS_THEME,
|
51
|
'media' => $media_query,
|
52
|
'every_page' => TRUE,
|
53
|
'weight' => $weight,
|
54
|
)
|
55
|
);
|
56
|
}
|
57
|
}
|