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