function om_system_preprocess_page in OM Tools 6.2
Same name and namespace in other branches
- 6 tools/system/system.inc \om_system_preprocess_page()
Override or insert om variables into the templates.
File
- tools/
system/ system.inc, line 45 - System Tools
Code
function om_system_preprocess_page(&$vars) {
//dsm($vars);
$system_defaults = $vars['om_system_tools_values'];
if ($system_defaults['system_mediaqueries_switch']) {
/**
* Mediaqueries
* http://plugins.jquery.com/project/MediaQueries
*
* - rename jquery.mediaqueries.js to mediaqueries.js
*
*/
drupal_add_js(drupal_get_path('module', 'om_tools') . '/contrib/mediaqueries.js', 'module');
$theme_path_default = $system_defaults['system_mediaqueries_path'];
$styles = explode(',', $system_defaults['system_mediaqueries_maxsizes']);
foreach ($styles as $key => $style) {
$media_array = explode('|', $style);
// This is put to $head instead of $styles to avoid collision with OM $styles aggregation
if (isset($media_array[1])) {
// detailed media
$style_type = '';
if (isset($media_array[0]) && !empty($media_array[0])) {
$type = $media_array[0];
$style_type .= '_' . trim($media_array[0]);
}
else {
$type = 'screen';
$style_type .= '_screen';
}
if (isset($media_array[1]) && !empty($media_array[1])) {
$min = isset($media_array[1]) ? ' and (min-width: ' . $media_array[1] . 'px)' : '';
$style_type .= '_min' . trim($media_array[1]);
}
if (isset($media_array[2]) && !empty($media_array[2])) {
$max = isset($media_array[2]) ? ' and (max-width: ' . $media_array[2] . 'px)' : '';
$style_type .= '_max' . trim($media_array[2]);
}
$type2 = isset($media_array[3]) ? ', ' . $media_array[3] : '';
$type3 = isset($media_array[4]) ? ', ' . $media_array[4] : '';
$type4 = isset($media_array[5]) ? ', ' . $media_array[5] : '';
$style_href = 'style' . $style_type . '.css';
$media = 'only ' . $type . $min . $max . $type2 . $type3 . $type4;
}
else {
// default media - screen and max-width
if (is_numeric($style)) {
$style_href = 'style' . trim($style) . '.css';
$media = 'only screen and (max-width: ' . $style . 'px)';
//$vars['css']['only screen and (max-width: ' . $style . 'px)']['module'][$theme_path_default . '/style' . trim($style) . '.css'] = TRUE;
}
}
if (!empty($media)) {
$vars['head'] .= '<link rel="stylesheet" type="text/css" href="' . base_path() . $theme_path_default . '/' . $style_href . '" media="' . $media . '" />';
}
}
}
//dsm($vars);
}