You are here

function colors_create_css in Colors 7

Same name and namespace in other branches
  1. 8 colors.module \colors_create_css()

Retrieves or generates a CSS file with a given module's selector.

Parameters

string $caller: A module that implements hook_colors_build_selector().

Return value

string The filename of the generated CSS.

1 call to colors_create_css()
colors_css_clear in ./colors.module
Removes the generated CSS file, optionally recreating it.

File

./colors.module, line 299
Provides an API to match selectors with a color configuration.

Code

function colors_create_css($caller) {
  ctools_include('css');
  $filename = ctools_css_retrieve($caller . ':colors');
  if (!$filename) {
    colors_include_api();
    $css = array();
    $delta = 0;
    foreach (module_invoke_all('colors_info') as $module => $info) {
      if (!variable_get('colors_' . $module . '_enabled', FALSE)) {
        continue;
      }
      $weight = variable_get('colors_weight_' . $module, $delta - 100);
      if (!isset($css[$weight])) {
        $css[$weight] = '';
      }
      foreach (colors_get_module_colors($module) as $selector => $colors) {
        $css[$weight] .= colors_build_css($selector, $colors, $caller);
      }
      $delta++;
    }
    ksort($css);
    $filename = ctools_css_store($caller . ':colors', implode("\n", $css));
  }
  return $filename;
}