You are here

function om_system_process_html in OM Tools 8.2

Same name and namespace in other branches
  1. 8 tools/system/system.inc \om_system_process_html()
  2. 7.2 tools/system/system.inc \om_system_process_html()
  3. 7 tools/system/system.inc \om_system_process_html()

Override or insert om variables into the templates.

File

tools/system/system.inc, line 64
System Tools

Code

function om_system_process_html(&$vars) {
  $system_defaults = $vars['om_system_tools_values'];
  if (isset($system_defaults['system_mediaqueries_switch']) && $system_defaults['system_mediaqueries_switch'] == 1) {
    $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);
}