Projet

Général

Profil

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

root / drupal7 / sites / all / themes / bootstrap / theme / menu / menu-local-action.func.php @ 87dbc3bf

1
<?php
2
/**
3
 * @file
4
 * menu-local-action.func.php
5
 */
6

    
7
/**
8
 * Overrides theme_menu_local_action().
9
 */
10
function bootstrap_menu_local_action($variables) {
11
  $link = $variables['element']['#link'];
12

    
13
  $options = isset($link['localized_options']) ? $link['localized_options'] : array();
14

    
15
  // If the title is not HTML, sanitize it.
16
  if (empty($options['html'])) {
17
    $link['title'] = check_plain($link['title']);
18
  }
19

    
20
  $icon = _bootstrap_iconize_button($link['title']);
21

    
22
  // Format the action link.
23
  $output = '<li>';
24
  if (isset($link['href'])) {
25
    // Turn link into a mini-button and colorize based on title.
26
    if ($class = _bootstrap_colorize_button($link['title'])) {
27
      if (!isset($options['attributes']['class'])) {
28
        $options['attributes']['class'] = array();
29
      }
30
      $string = is_string($options['attributes']['class']);
31
      if ($string) {
32
        $options['attributes']['class'] = explode(' ', $options['attributes']['class']);
33
      }
34
      $options['attributes']['class'][] = 'btn';
35
      $options['attributes']['class'][] = 'btn-xs';
36
      $options['attributes']['class'][] = $class;
37
      if ($string) {
38
        $options['attributes']['class'] = implode(' ', $options['attributes']['class']);
39
      }
40
    }
41
    // Force HTML so we can add the icon rendering element.
42
    $options['html'] = TRUE;
43
    $output .= l($icon . $link['title'], $link['href'], $options);
44
  }
45
  else {
46
    $output .= $icon . $link['title'];
47
  }
48
  $output .= "</li>\n";
49

    
50
  return $output;
51
}