root / drupal7 / sites / all / themes / bootstrap / templates / system / button.func.php @ eefc2ac0
1 |
<?php
|
---|---|
2 |
|
3 |
/**
|
4 |
* @file
|
5 |
* Stub file for bootstrap_button().
|
6 |
*/
|
7 |
|
8 |
/**
|
9 |
* Returns HTML for a button form element.
|
10 |
*
|
11 |
* @param array $variables
|
12 |
* An associative array containing:
|
13 |
* - element: An associative array containing the properties of the element.
|
14 |
* Properties used: #attributes, #button_type, #name, #value.
|
15 |
*
|
16 |
* @return string
|
17 |
* The constructed HTML.
|
18 |
*
|
19 |
* @see theme_button()
|
20 |
*
|
21 |
* @ingroup theme_functions
|
22 |
*/
|
23 |
function bootstrap_button(array $variables) { |
24 |
$element = $variables['element']; |
25 |
$text = $element['#value']; |
26 |
|
27 |
// Allow button text to be appear hidden.
|
28 |
// @see https://www.drupal.org/node/2327437
|
29 |
if (!empty($element['#hide_text']) || $element['#icon_position'] === 'icon_only') { |
30 |
$text = '<span class="sr-only">' . $text . '</span>'; |
31 |
} |
32 |
|
33 |
// Add icons before or after the value.
|
34 |
// @see https://www.drupal.org/node/2219965
|
35 |
if (!empty($element['#icon']) && ($icon = render($element['#icon']))) { |
36 |
// Add icon position class.
|
37 |
_bootstrap_add_class('icon-' . drupal_html_class($element['#icon_position'] === 'icon_only' ? 'only' : $element['#icon_position']), $element); |
38 |
|
39 |
if ($element['#icon_position'] === 'after') { |
40 |
$text .= ' ' . $icon; |
41 |
} |
42 |
else {
|
43 |
$text = $icon . ' ' . $text; |
44 |
} |
45 |
} |
46 |
|
47 |
// This line break adds inherent margin between multiple buttons.
|
48 |
return '<button' . drupal_attributes($element['#attributes']) . '>' . filter_xss_admin($text) . "</button>\n"; |
49 |
} |