Projet

Général

Profil

Révision 4eeb3b46

Ajouté par Assos Assos il y a presque 8 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/themes/bootstrap/includes/common.inc
69 69

  
70 70
  $html = FALSE;
71 71
  $type = !empty($element['#type']) ? $element['#type'] : FALSE;
72
  if (!$input_only || !empty($target['#input']) || !empty($element['#smart_description']) || !empty($target['#smart_description'])) {
73
    if (!empty($element['#description']) && empty($target['#attributes']['title']) && empty($target['#attributes']['data-toggle'])) {
74
      if (_bootstrap_is_simple_string($element['#description'], $length, $allowed_tags, $html)) {
75
        // Default property (on the element itself).
76
        $property = 'attributes';
77

  
78
        // Add the tooltip to the #label_attributes property for 'checkbox'
79
        // and 'radio' elements.
80
        if ($type === 'checkbox' || $type === 'radio') {
81
          $property = 'label_attributes';
82
        }
83
        // Add the tooltip to the #wrapper_attributes property for 'checkboxes'
84
        // and 'radios' elements.
85
        elseif ($type === 'checkboxes' || $type === 'radios') {
86
          $property = 'wrapper_attributes';
87
        }
88
        // Add the tooltip to the #input_group_attributes property for elements
89
        // that have valid input groups set.
90
        elseif ((!empty($element['#field_prefix']) || !empty($element['#field_suffix'])) && (!empty($element['#input_group']) || !empty($element['#input_group_button']))) {
91
          $property = 'input_group_attributes';
92
        }
93 72

  
94
        // Retrieve the proper attributes array.
95
        $attributes = &_bootstrap_get_attributes($target, $property);
73
  // Return if element or target shouldn't have "simple" tooltip descriptions.
74
  if (($input_only && !isset($target['#input']))
75
    // Ignore text_format elements.
76
    // @see https://www.drupal.org/node/2478339
77
    || $type === 'text_format'
96 78

  
97
        // Set the tooltip attributes.
98
        $attributes['title'] = $allowed_tags !== FALSE ? filter_xss($element['#description'], $allowed_tags) : $element['#description'];
99
        $attributes['data-toggle'] = 'tooltip';
100
        if ($html || $allowed_tags === FALSE) {
101
          $attributes['data-html'] = 'true';
102
        }
79
    // Ignore if the actual element has no #description set.
80
    || empty($element['#description'])
103 81

  
104
        // Remove the element description so it isn't (re-)rendered later.
105
        unset($element['#description']);
106
      }
107
    }
82
    // Ignore if the target element already has a "data-toggle" attribute set.
83
    || !empty($target['#attributes']['data-toggle'])
84

  
85
    // Ignore if the target element is #disabled.
86
    || isset($target['#disabled'])
87

  
88
    // Ignore if either the actual element or target element has an explicit
89
    // #smart_description property set to FALSE.
90
    || (isset($element['#smart_description']) && !$element['#smart_description'])
91
    || (isset($target['#smart_description']) && !$target['#smart_description'])
92

  
93
    // Ignore if the description is not "simple".
94
    || !_bootstrap_is_simple_string($element['#description'], $length, $allowed_tags, $html)
95
  ) {
96
    // Set the both the actual element and the target element
97
    // #smart_description property to FALSE.
98
    $element['#smart_description'] = FALSE;
99
    $target['#smart_description'] = FALSE;
100
    return;
108 101
  }
102

  
103
  // Default property (on the element itself).
104
  $property = 'attributes';
105

  
106
  // Add the tooltip to the #label_attributes property for 'checkbox'
107
  // and 'radio' elements.
108
  if ($type === 'checkbox' || $type === 'radio') {
109
    $property = 'label_attributes';
110
  }
111
  // Add the tooltip to the #wrapper_attributes property for 'checkboxes'
112
  // and 'radios' elements.
113
  elseif ($type === 'checkboxes' || $type === 'radios') {
114
    $property = 'wrapper_attributes';
115
  }
116
  // Add the tooltip to the #input_group_attributes property for elements
117
  // that have valid input groups set.
118
  elseif ((!empty($element['#field_prefix']) || !empty($element['#field_suffix'])) && (!empty($element['#input_group']) || !empty($element['#input_group_button']))) {
119
    $property = 'input_group_attributes';
120
  }
121

  
122
  // Retrieve the proper attributes array.
123
  $attributes = &_bootstrap_get_attributes($target, $property);
124

  
125
  // Set the tooltip attributes.
126
  $attributes['title'] = $allowed_tags !== FALSE ? filter_xss($element['#description'], $allowed_tags) : $element['#description'];
127
  $attributes['data-toggle'] = 'tooltip';
128
  if ($html || $allowed_tags === FALSE) {
129
    $attributes['data-html'] = 'true';
130
  }
131

  
132
  // Remove the element description so it isn't (re-)rendered later.
133
  unset($element['#description']);
109 134
}
110 135

  
111 136
/**
......
1175 1200

  
1176 1201
    // Iterate over the preprocess functions.
1177 1202
    foreach ($registry[$hook]['preprocess functions'] as $function) {
1178
      if (function_exists($function)) {
1203
      // Ensure that the function is not this one (recursive) and exists.
1204
      if ($function !== __FUNCTION__ && function_exists($function)) {
1179 1205
        // Invoke theme hook suggestion preprocess function.
1180 1206
        $function($variables, $hook);
1181 1207

  

Formats disponibles : Unified diff