Projet

Général

Profil

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

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

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
  $title = $link['title'];
26
  $icon = _bootstrap_iconize_text($title);
27
  $href = !empty($link['href']) ? $link['href'] : FALSE;
28
  $options = isset($link['localized_options']) ? $link['localized_options'] : array();
29

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

    
52
  // Filter the title if the "html" is set, otherwise l() will automatically
53
  // sanitize using check_plain(), so no need to call that here.
54
  if (!empty($options['html'])) {
55
    $title = _bootstrap_filter_xss($title);
56
  }
57

    
58
  return $href ? l($icon . $title, $href, $options) : $icon . $title;
59
}