Projet

Général

Profil

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

root / drupal7 / sites / all / themes / bootstrap / templates / bootstrap / bootstrap-carousel.vars.php @ eefc2ac0

1 caf16a48 Assos Assos
<?php
2 eefc2ac0 Assos Assos
3 caf16a48 Assos Assos
/**
4
 * @file
5
 * Stub file for "bootstrap_carousel" theme hook [pre]process functions.
6
 */
7
8
/**
9
 * Pre-processes variables for the "bootstrap_carousel" theme hook.
10
 *
11
 * See template for list of available variables.
12
 *
13 eefc2ac0 Assos Assos
 * @param array $variables
14
 *   An associative array of variables, passed by reference.
15
 *
16 caf16a48 Assos Assos
 * @see bootstrap-carousel.tpl.php
17
 *
18
 * @ingroup theme_preprocess
19
 */
20 eefc2ac0 Assos Assos
function bootstrap_preprocess_bootstrap_carousel(array &$variables) {
21 caf16a48 Assos Assos
  $variables['attributes']['class'][] = 'carousel';
22
  $variables['attributes']['class'][] = 'slide';
23
  $variables['attributes']['data-ride'] = 'carousel';
24
  if (empty($variables['attributes']['id'])) {
25
    $variables['attributes']['id'] = drupal_html_id('carousel');
26
  }
27
  $default_data_attributes = array(
28
    'interval' => 5000,
29
    'pause' => TRUE,
30
    'wrap' => TRUE,
31
  );
32
  foreach ($default_data_attributes as $name => $value) {
33
    if ($variables[$name] !== $value) {
34
      // Convert PHP booleans to the JSON equivalent, otherwise they'll be
35
      // interpreted as integers when they're parsed.
36
      if (is_bool($variables[$name])) {
37
        $variables[$name] = $variables[$name] ? 'true' : 'false';
38
      }
39
      $variables['attributes']['data-' . $name] = $variables[$name];
40
    }
41
  }
42
}
43
44
/**
45
 * Processes variables for the "bootstrap_carousel" theme hook.
46
 *
47
 * See template for list of available variables.
48
 *
49 eefc2ac0 Assos Assos
 * @param array $variables
50
 *   An associative array of variables, passed by reference.
51
 *
52 caf16a48 Assos Assos
 * @see bootstrap-carousel.tpl.php
53
 *
54
 * @ingroup theme_process
55
 */
56 eefc2ac0 Assos Assos
function bootstrap_process_bootstrap_carousel(array &$variables) {
57 caf16a48 Assos Assos
  $variables['target'] = '#' . $variables['attributes']['id'];
58
  $variables['attributes'] = drupal_attributes($variables['attributes']);
59
60
  // Ensure the item arrays are constructed properly for the template.
61
  foreach ($variables['items'] as $delta => $item) {
62
    // Convert items that are string into the appropriate array structure.
63
    if (is_string($item)) {
64
      $variables['items'][$delta] = array(
65
        'image' => $item,
66
      );
67
    }
68
    // Populate defaults.
69
    $variables['items'][$delta] += array(
70
      'title' => NULL,
71
      'description' => NULL,
72
      'url' => NULL,
73
    );
74 1f623f01 Assos Assos
75
    if (!empty($variables['items'][$delta]['title'])) {
76 7547bb19 Assos Assos
      $variables['items'][$delta]['title'] = is_scalar($item['title']) ? filter_xss_admin($item['title']) : render($item['title']);
77 1f623f01 Assos Assos
    }
78
79
    if (!empty($variables['items'][$delta]['description'])) {
80 7547bb19 Assos Assos
      $variables['items'][$delta]['description'] = is_scalar($item['description']) ? filter_xss_admin($item['description']) : render($item['description']);
81 1f623f01 Assos Assos
    }
82
83 caf16a48 Assos Assos
  }
84
}