function _color_page_alter

7.x color.module _color_page_alter(&$vars)
6.x color.module _color_page_alter(&$vars)

Callback for the theme to alter the resources used.

1 call to _color_page_alter()
phptemplate_preprocess_page in drupal-6.x/themes/garland/template.php
Override or insert PHPTemplate variables into the templates.

File

drupal-6.x/modules/color/color.module, line 69

Code

function _color_page_alter(&$vars) {
  global $language, $theme_key;

  // Override stylesheets.
  $color_paths = variable_get('color_' . $theme_key . '_stylesheets', array());
  if (!empty($color_paths)) {
    // Loop over theme CSS files and try to rebuild CSS array with rewritten
    // stylesheets. Keep the orginal order intact for CSS cascading.
    $new_theme_css = array();

    foreach ($vars['css']['all']['theme'] as $old_path => $old_preprocess) {
      // Add the non-colored stylesheet first as we might not find a
      // re-colored stylesheet for replacement later.
      $new_theme_css[$old_path] = $old_preprocess;

      // Loop over the path array with recolored CSS files to find matching
      // paths which could replace the non-recolored paths.
      foreach ($color_paths as $color_path) {
        // Color module currently requires unique file names to be used,
        // which allows us to compare different file paths.
        if (basename($old_path) == basename($color_path)) {
          // Pull out the non-colored and add rewritten stylesheet.
          unset($new_theme_css[$old_path]);
          $new_theme_css[$color_path] = $old_preprocess;

          // If the current language is RTL and the CSS file had an RTL variant,
          // pull out the non-colored and add rewritten RTL stylesheet.
          if ($language->direction == LANGUAGE_RTL) {
            $rtl_old_path = str_replace('.css', '-rtl.css', $old_path);
            $rtl_color_path = str_replace('.css', '-rtl.css', $color_path);
            if (file_exists($rtl_color_path)) {
              unset($new_theme_css[$rtl_old_path]);
              $new_theme_css[$rtl_color_path] = $old_preprocess;
            }
          }
          break;
        }
      }
    }
    $vars['css']['all']['theme'] = $new_theme_css;
    $vars['styles'] = drupal_get_css($vars['css']);
  }

  // Override logo.
  $logo = variable_get('color_' . $theme_key . '_logo', NULL);
  if ($logo && $vars['logo'] && preg_match('!' . $theme_key . '/logo.png$!', $vars['logo'])) {
    $vars['logo'] = base_path() . $logo;
  }
}