root / drupal7 / sites / all / themes / bootstrap / templates / bootstrap / bootstrap-carousel.vars.php @ eefc2ac0
1 |
<?php
|
---|---|
2 |
|
3 |
/**
|
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 |
* @param array $variables
|
14 |
* An associative array of variables, passed by reference.
|
15 |
*
|
16 |
* @see bootstrap-carousel.tpl.php
|
17 |
*
|
18 |
* @ingroup theme_preprocess
|
19 |
*/
|
20 |
function bootstrap_preprocess_bootstrap_carousel(array &$variables) { |
21 |
$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 |
* @param array $variables
|
50 |
* An associative array of variables, passed by reference.
|
51 |
*
|
52 |
* @see bootstrap-carousel.tpl.php
|
53 |
*
|
54 |
* @ingroup theme_process
|
55 |
*/
|
56 |
function bootstrap_process_bootstrap_carousel(array &$variables) { |
57 |
$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 |
|
75 |
if (!empty($variables['items'][$delta]['title'])) { |
76 |
$variables['items'][$delta]['title'] = is_scalar($item['title']) ? filter_xss_admin($item['title']) : render($item['title']); |
77 |
} |
78 |
|
79 |
if (!empty($variables['items'][$delta]['description'])) { |
80 |
$variables['items'][$delta]['description'] = is_scalar($item['description']) ? filter_xss_admin($item['description']) : render($item['description']); |
81 |
} |
82 |
|
83 |
} |
84 |
} |