Projet

Général

Profil

Paste
Télécharger (2,01 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / bootstrap / templates / system / table.vars.php @ 7547bb19

1
<?php
2
/**
3
 * @file
4
 * Stub file for "table" theme hook [pre]process functions.
5
 */
6

    
7
/**
8
 * Pre-processes variables for the "table" theme hook.
9
 *
10
 * See theme function for list of available variables.
11
 *
12
 * @see bootstrap_table()
13
 * @see theme_table()
14
 *
15
 * @ingroup theme_preprocess
16
 */
17
function bootstrap_preprocess_table(&$variables) {
18
  // Prepare classes array if necessary.
19
  if (!isset($variables['attributes']['class'])) {
20
    $variables['attributes']['class'] = array();
21
  }
22
  // Convert classes to an array.
23
  elseif (isset($variables['attributes']['class']) && is_string($variables['attributes']['class'])) {
24
    $variables['attributes']['class'] = explode(' ', $variables['attributes']['class']);
25
  }
26

    
27
  // Add the necessary classes to the table.
28
  _bootstrap_table_add_classes($variables['attributes']['class'], $variables);
29
}
30

    
31
/**
32
 * Helper function for adding the necessary classes to a table.
33
 *
34
 * @param array $classes
35
 *   The array of classes, passed by reference.
36
 * @param array $variables
37
 *   The variables of the theme hook, passed by reference.
38
 */
39
function _bootstrap_table_add_classes(&$classes, &$variables) {
40
  $context = $variables['context'];
41

    
42
  // Generic table class for all tables.
43
  $classes[] = 'table';
44

    
45
  // Bordered table.
46
  if (!empty($context['bordered']) || (!isset($context['bordered']) && bootstrap_setting('table_bordered'))) {
47
    $classes[] = 'table-bordered';
48
  }
49

    
50
  // Condensed table.
51
  if (!empty($context['condensed']) || (!isset($context['condensed']) && bootstrap_setting('table_condensed'))) {
52
    $classes[] = 'table-condensed';
53
  }
54

    
55
  // Hover rows.
56
  if (!empty($context['hover']) || (!isset($context['hover']) && bootstrap_setting('table_hover'))) {
57
    $classes[] = 'table-hover';
58
  }
59

    
60
  // Striped rows.
61
  if (!empty($context['striped']) || (!isset($context['striped']) && bootstrap_setting('table_striped'))) {
62
    $classes[] = 'table-striped';
63
  }
64

    
65
  // Responsive table.
66
  $variables['responsive'] = isset($context['responsive']) ? $context['responsive'] : bootstrap_setting('table_responsive');
67
}