Projet

Général

Profil

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

root / drupal7 / sites / all / themes / bootstrap / templates / bootstrap / bootstrap-panel.vars.php @ 7547bb19

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

    
7
/**
8
 * Pre-processes variables for the "bootstrap_panel" theme hook.
9
 *
10
 * See template for list of available variables.
11
 *
12
 * @see bootstrap-panel.tpl.php
13
 *
14
 * @ingroup theme_preprocess
15
 */
16
function bootstrap_preprocess_bootstrap_panel(&$variables) {
17
  $element = &$variables['element'];
18

    
19
  // Set the element's attributes.
20
  element_set_attributes($element, array('id'));
21

    
22
  // Retrieve the attributes for the element.
23
  $attributes = &_bootstrap_get_attributes($element);
24

    
25
  // Add panel and panel-default classes.
26
  $attributes['class'][] = 'panel';
27
  $attributes['class'][] = 'panel-default';
28

    
29
  // states.js requires form-wrapper on fieldset to work properly.
30
  $attributes['class'][] = 'form-wrapper';
31

    
32
  // Handle collapsible panels.
33
  $variables['collapsible'] = FALSE;
34
  if (isset($element['#collapsible'])) {
35
    $variables['collapsible'] = $element['#collapsible'];
36
  }
37
  $variables['collapsed'] = FALSE;
38
  if (isset($element['#collapsed'])) {
39
    $variables['collapsed'] = $element['#collapsed'];
40
  }
41
  // Force grouped fieldsets to not be collapsible (for vertical tabs).
42
  if (!empty($element['#group'])) {
43
    $variables['collapsible'] = FALSE;
44
    $variables['collapsed'] = FALSE;
45
  }
46
  // Collapsible elements need an ID, so generate one if necessary.
47
  if (!isset($attributes['id']) && $variables['collapsible']) {
48
    $attributes['id'] = drupal_html_id('bootstrap-panel');
49
  }
50

    
51
  // Set the target if the element has an id.
52
  $variables['target'] = NULL;
53
  if (isset($attributes['id'])) {
54
    $variables['target'] = '#' . $attributes['id'] . ' > .collapse';
55
  }
56

    
57
  // Build the panel content.
58
  $variables['content'] = $element['#children'];
59
  if (isset($element['#value'])) {
60
    $variables['content'] .= $element['#value'];
61
  }
62

    
63
  // Iterate over optional variables.
64
  $keys = array(
65
    'description',
66
    'prefix',
67
    'suffix',
68
    'title',
69
  );
70
  foreach ($keys as $key) {
71
    $variables[$key] = !empty($element["#$key"]) ? $element["#$key"] : FALSE;
72
  }
73

    
74
  // Add the attributes.
75
  $variables['attributes'] = $attributes;
76
}
77

    
78
/**
79
 * Processes variables for the "bootstrap_panel" theme hook.
80
 *
81
 * See template for list of available variables.
82
 *
83
 * @see bootstrap-panel.tpl.php
84
 *
85
 * @ingroup theme_process
86
 */
87
function bootstrap_process_bootstrap_panel(&$variables) {
88
  $variables['attributes'] = drupal_attributes($variables['attributes']);
89
  if (!empty($variables['title'])) {
90
    $variables['title'] = filter_xss_admin(render($variables['title']));
91
  }
92
  if (!empty($variables['description'])) {
93
    $variables['description'] = filter_xss_admin(render($variables['description']));
94
  }
95
}