You are here

views_table_highlighter.module in Views Table Highlighter 6

Same filename and directory in other branches
  1. 7 views_table_highlighter.module

File

views_table_highlighter.module
View source
<?php

/**
 * Implements hook_init().
 */
function views_table_highlighter_init() {
  drupal_add_css(drupal_get_path('module', 'views_table_highlighter') . '/views_table_highlighter.css');
}

/**
 * Implements hook_views_api().
 */
function views_table_highlighter_views_api() {
  return array(
    'api' => 2.0,
  );
}

/**
 * Implements hook_preprocess().
 */
function views_table_highlighter_preprocess(&$variables, $hook) {
  if (substr($hook, 0, strlen('views_view_table')) === 'views_view_table' && isset($variables['view']->style_plugin->options['views_table_highlighter'])) {
    foreach ($variables['view']->result as $i => $fieldset) {
      $GLOBALS['views_table_highlighter_fieldset'] = (array) $fieldset;
      $color = drupal_eval('<?php extract($GLOBALS["views_table_highlighter_fieldset"]); ' . $variables['view']->style_options['views_table_highlighter']['code']);
      if ($color) {
        $variables['row_classes'][$i][] = "views-table-highlighter-{$color}";
      }
    }
  }
}