root / drupal7 / sites / all / themes / bootstrap / templates / system / button.func.php @ 749b8a23
1 | caf16a48 | Assos Assos | <?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 | |||
25 | // Allow button text to be appear hidden.
|
||
26 | // @see https://www.drupal.org/node/2327437
|
||
27 | $text = !empty($element['#hide_text']) ? '<span class="element-invisible">' . $element['#value'] . '</span>' : $element['#value']; |
||
28 | |||
29 | // Add icons before or after the value.
|
||
30 | // @see https://www.drupal.org/node/2219965
|
||
31 | if (!empty($element['#icon'])) { |
||
32 | if ($element['#icon_position'] === 'before') { |
||
33 | $text = $element['#icon'] . ' ' . $text; |
||
34 | } |
||
35 | elseif ($element['#icon_position'] === 'after') { |
||
36 | $text .= ' ' . $element['#icon']; |
||
37 | } |
||
38 | } |
||
39 | |||
40 | // This line break adds inherent margin between multiple buttons.
|
||
41 | return '<button' . drupal_attributes($element['#attributes']) . '>' . $text . "</button>\n"; |
||
42 | } |