Projet

Général

Profil

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

root / drupal7 / sites / all / themes / bootstrap / theme / bootstrap / bootstrap-btn-dropdown.func.php @ 87dbc3bf

1
<?php
2
/**
3
 * @file
4
 * bootstrap-btn-dropdown.func.php
5
 */
6

    
7
/**
8
 * Implements theme_bootstrap_btn_dropdown().
9
 */
10
function theme_bootstrap_btn_dropdown($variables) {
11
  $type_class = '';
12
  $sub_links = '';
13

    
14
  $variables['attributes']['class'][] = 'btn-group';
15
  // Type class.
16
  if (isset($variables['type'])) {
17
    $type_class .= ' btn-' . $variables['type'];
18
  }
19
  else {
20
    $type_class .= ' btn-default';
21
  }
22

    
23
  // Start markup.
24
  $output = '<div' . drupal_attributes($variables['attributes']) . '>';
25

    
26
  // Add as string if its not a link.
27
  if (is_array($variables['label'])) {
28
    $output .= l($variables['label']['title'], $$variables['label']['href'], $variables['label']);
29
  }
30
  $output .= '<a class="btn' . $type_class . ' dropdown-toggle" data-toggle="dropdown" href="#">';
31

    
32
  // It is a link, create one.
33
  if (is_string($variables['label'])) {
34
    $output .= check_plain($variables['label']);
35
  }
36
  if (is_array($variables['links'])) {
37
    $sub_links = theme('links', array(
38
      'links' => $variables['links'],
39
      'attributes' => array(
40
        'class' => array('dropdown-menu'),
41
      ),
42
    ));
43
  }
44
  // Finish markup.
45
  $output .= '<span class="caret"></span></a>' . $sub_links . '</div>';
46
  return $output;
47
}