You are here

function template_preprocess_styles in Styles 7

Same name and namespace in other branches
  1. 6.2 themes/styles.theme.inc \template_preprocess_styles()
  2. 6 themes/styles.theme.inc \template_preprocess_styles()
  3. 7.2 themes/styles.theme.inc \template_preprocess_styles()

Preprocess for theme_styles().

File

./styles.module, line 96
Bundles similar display formatters together.

Code

function template_preprocess_styles(&$variables) {
  $field_type = $variables['field_type'];
  $style_name = $variables['style_name'];
  $variables['output'] = '';
  $presets = styles_presets();
  $containers = styles_containers();
  $container = $containers[$field_type]['containers'];
  foreach ($container as $container_name => $styles) {
    $variables['container'] = $styles;
    $variables['container_name'] = $variables['container']['name'];
    $callback = $styles['filter callback'];
    if (function_exists($callback)) {
      if (call_user_func_array($callback, array(
        $variables,
      ))) {
        if (!empty($presets[$field_type][$style_name][$container_name])) {
          $variables['preset'] = array_pop($presets[$field_type][$style_name][$container_name]);
          $variables['preset_name'] = $variables['preset']['name'];
          $variables['output'] = theme($styles['themes']['styles'], $variables);
          $variables['classes_array'][] = 'styles-field-' . $field_type;
          $variables['classes_array'][] = 'styles-style-' . $style_name;
          $variables['classes_array'][] = 'styles-container-' . $variables['container_name'];
          $variables['classes_array'][] = 'styles-preset-' . $variables['preset_name'];
          $variables['classes'] = implode(' ', $variables['classes_array']);
          break;
        }
      }
    }
  }
}