Projet

Général

Profil

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

root / drupal7 / sites / all / themes / bootstrap / templates / menu / menu-local-action.func.php @ 27370441

1
<?php
2
/**
3
 * @file
4
 * Stub file for bootstrap_menu_local_action().
5
 */
6

    
7
/**
8
 * Returns HTML for a single local action link.
9
 *
10
 * @param array $variables
11
 *   An associative array containing:
12
 *   - element: A render element containing:
13
 *     - #link: A menu link array with 'title', 'href', and 'localized_options'
14
 *       keys.
15
 *
16
 * @return string
17
 *   The constructed HTML.
18
 *
19
 * @see theme_menu_local_action()
20
 *
21
 * @ingroup theme_functions
22
 */
23
function bootstrap_menu_local_action($variables) {
24
  $link = $variables['element']['#link'];
25

    
26
  $options = isset($link['localized_options']) ? $link['localized_options'] : array();
27

    
28
  // If the title is not HTML, sanitize it.
29
  if (empty($options['html'])) {
30
    $link['title'] = check_plain($link['title']);
31
  }
32

    
33
  $icon = _bootstrap_iconize_text($link['title']);
34

    
35
  // Format the action link.
36
  $output = '';
37
  if (isset($link['href'])) {
38
    // Turn link into a mini-button and colorize based on title.
39
    if ($class = _bootstrap_colorize_text($link['title'])) {
40
      if (!isset($options['attributes']['class'])) {
41
        $options['attributes']['class'] = array();
42
      }
43
      $string = is_string($options['attributes']['class']);
44
      if ($string) {
45
        $options['attributes']['class'] = explode(' ', $options['attributes']['class']);
46
      }
47
      $options['attributes']['class'][] = 'btn';
48
      $options['attributes']['class'][] = 'btn-xs';
49
      $options['attributes']['class'][] = 'btn-' . $class;
50
      if ($string) {
51
        $options['attributes']['class'] = implode(' ', $options['attributes']['class']);
52
      }
53
    }
54
    // Force HTML so we can render any icon that may have been added.
55
    $options['html'] = !empty($options['html']) || !empty($icon) ? TRUE : FALSE;
56
    $output .= l($icon . $link['title'], $link['href'], $options);
57
  }
58
  else {
59
    $output .= $icon . $link['title'];
60
  }
61

    
62
  return $output;
63
}