Projet

Général

Profil

Révision 1f623f01

Ajouté par Assos Assos il y a plus de 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/themes/bootstrap/templates/menu/menu-link.func.php
22 22
  $element = $variables['element'];
23 23
  $sub_menu = '';
24 24

  
25
  $title = $element['#title'];
26
  $href = $element['#href'];
27
  $options = !empty($element['#localized_options']) ? $element['#localized_options'] : array();
28
  $attributes = !empty($element['#attributes']) ? $element['#attributes'] : array();
29

  
25 30
  if ($element['#below']) {
26 31
    // Prevent dropdown functions from being added to management menu so it
27 32
    // does not affect the navbar module.
......
32 37
      // Add our own wrapper.
33 38
      unset($element['#below']['#theme_wrappers']);
34 39
      $sub_menu = '<ul class="dropdown-menu">' . drupal_render($element['#below']) . '</ul>';
40

  
35 41
      // Generate as standard dropdown.
36
      $element['#title'] .= ' <span class="caret"></span>';
37
      $element['#attributes']['class'][] = 'dropdown';
38
      $element['#localized_options']['html'] = TRUE;
42
      $title .= ' <span class="caret"></span>';
43
      $attributes['class'][] = 'dropdown';
44

  
45
      $options['html'] = TRUE;
39 46

  
40 47
      // Set dropdown trigger element to # to prevent inadvertant page loading
41 48
      // when a submenu link is clicked.
42
      $element['#localized_options']['attributes']['data-target'] = '#';
43
      $element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';
44
      $element['#localized_options']['attributes']['data-toggle'] = 'dropdown';
49
      $options['attributes']['data-target'] = '#';
50
      $options['attributes']['class'][] = 'dropdown-toggle';
51
      $options['attributes']['data-toggle'] = 'dropdown';
45 52
    }
46 53
  }
47
  // On primary navigation menu, class 'active' is not set on active menu item.
48
  // @see https://drupal.org/node/1896674
49
  if (($element['#href'] == $_GET['q'] || ($element['#href'] == '<front>' && drupal_is_front_page())) && (empty($element['#localized_options']['language']))) {
50
    $element['#attributes']['class'][] = 'active';
54

  
55
  // Filter the title if the "html" is set, otherwise l() will automatically
56
  // sanitize using check_plain(), so no need to call that here.
57
  if (!empty($options['html'])) {
58
    $title = _bootstrap_filter_xss($title);
51 59
  }
52
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
53
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
60

  
61
  return '<li' . drupal_attributes($attributes) . '>' . l($title, $href, $options) . $sub_menu . "</li>\n";
54 62
}
55 63

  
56 64
/**
......
59 67
function bootstrap_menu_link__book_toc(array $variables) {
60 68
  $element = $variables['element'];
61 69
  $sub_menu = drupal_render($element['#below']);
62
  $element['#attributes']['role'] = 'presentation';
70

  
71
  $title = $element['#title'];
72
  $href = $element['#href'];
73
  $options = !empty($element['#localized_options']) ? $element['#localized_options'] : array();
74
  $attributes = !empty($element['#attributes']) ? $element['#attributes'] : array();
75
  $attributes['role'] = 'presentation';
76

  
77
  // Header.
63 78
  $link = TRUE;
64
  if ($element['#title'] && $element['#href'] === FALSE) {
65
    $element['#attributes']['class'][] = 'dropdown-header';
79
  if ($title && $href === FALSE) {
80
    $attributes['class'][] = 'dropdown-header';
66 81
    $link = FALSE;
67 82
  }
68
  elseif ($element['#title'] === FALSE && $element['#href'] === FALSE) {
69
    $element['#attributes']['class'][] = 'divider';
83
  // Divider.
84
  elseif ($title === FALSE && $href === FALSE) {
85
    $attributes['class'][] = 'divider';
70 86
    $link = FALSE;
71 87
  }
72
  elseif (($element['#href'] == $_GET['q'] || ($element['#href'] == '<front>' && drupal_is_front_page())) && (empty($element['#localized_options']['language']))) {
73
    $element['#attributes']['class'][] = 'active';
88
  // Active.
89
  elseif (($href == $_GET['q'] || ($href == '<front>' && drupal_is_front_page())) && (empty($options['language']))) {
90
    $attributes['class'][] = 'active';
91
  }
92

  
93
  // Filter the title if the "html" is set, otherwise l() will automatically
94
  // sanitize using check_plain(), so no need to call that here.
95
  if (!empty($options['html'])) {
96
    $title = _bootstrap_filter_xss($title);
74 97
  }
98

  
99
  // Convert to a link.
75 100
  if ($link) {
76
    $element['#title'] = l($element['#title'], $element['#href'], $element['#localized_options']);
101
    $title = l($title, $href, $options);
77 102
  }
78
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $element['#title'] . $sub_menu . "</li>\n";
103

  
104
  return '<li' . drupal_attributes($attributes) . '>' . $title . $sub_menu . "</li>\n";
79 105
}

Formats disponibles : Unified diff