root / drupal7 / sites / all / themes / bootstrap / templates / system / button.vars.php @ eefc2ac0
1 |
<?php
|
---|---|
2 |
|
3 |
/**
|
4 |
* @file
|
5 |
* Stub file for "button" theme hook [pre]process functions.
|
6 |
*/
|
7 |
|
8 |
/**
|
9 |
* Pre-processes variables for the "button" theme hook.
|
10 |
*
|
11 |
* See theme function for list of available variables.
|
12 |
*
|
13 |
* @param array $variables
|
14 |
* An associative array of variables, passed by reference.
|
15 |
*
|
16 |
* @see bootstrap_button()
|
17 |
* @see theme_button()
|
18 |
*
|
19 |
* @ingroup theme_preprocess
|
20 |
*/
|
21 |
function bootstrap_preprocess_button(array &$variables) { |
22 |
$element = &$variables['element']; |
23 |
|
24 |
// Drupal buttons should be of type 'submit'.
|
25 |
// @see https://www.drupal.org/node/2540452
|
26 |
$element['#attributes']['type'] = 'submit'; |
27 |
|
28 |
// Set the element's other attributes.
|
29 |
element_set_attributes($element, array('id', 'name', 'value')); |
30 |
|
31 |
// Add the base Bootstrap button class.
|
32 |
$element['#attributes']['class'][] = 'btn'; |
33 |
|
34 |
// Add button size, if necessary.
|
35 |
if ($size = bootstrap_setting('button_size')) { |
36 |
$element['#attributes']['class'][] = $size; |
37 |
} |
38 |
|
39 |
// Colorize button.
|
40 |
_bootstrap_colorize_button($element);
|
41 |
|
42 |
// Iconize button.
|
43 |
_bootstrap_iconize_button($element);
|
44 |
|
45 |
// Add in the button type class.
|
46 |
$element['#attributes']['class'][] = 'form-' . $element['#button_type']; |
47 |
|
48 |
// Ensure that all classes are unique, no need for duplicates.
|
49 |
$element['#attributes']['class'] = array_unique($element['#attributes']['class']); |
50 |
} |