Révision eefc2ac0
Ajouté par Assos Assos il y a plus de 6 ans
drupal7/sites/all/themes/bootstrap/includes/pre-render.inc | ||
---|---|---|
1 | 1 |
<?php |
2 |
|
|
2 | 3 |
/** |
3 | 4 |
* @file |
4 | 5 |
* pre-render.inc |
... | ... | |
14 | 15 |
return $element; |
15 | 16 |
} |
16 | 17 |
|
17 |
// Only add the "form-control" class for specific element input types. |
|
18 |
$types = array( |
|
19 |
// Core. |
|
18 |
// Only add the "form-control" class to supported theme hooks. |
|
19 |
$theme_hooks = array( |
|
20 | 20 |
'password', |
21 |
'password_confirm', |
|
22 |
'machine_name', |
|
23 | 21 |
'select', |
24 | 22 |
'textarea', |
25 | 23 |
'textfield', |
24 |
); |
|
26 | 25 |
|
26 |
// Additionally, support some popular 3rd-party modules that don't follow |
|
27 |
// standards by creating custom theme hooks to use in their element types. |
|
28 |
$types = array( |
|
27 | 29 |
// Elements module (HTML5). |
28 | 30 |
'date', |
29 | 31 |
'datefield', |
... | ... | |
45 | 47 |
'webform_number', |
46 | 48 |
); |
47 | 49 |
|
48 |
// Add necessary classes for specific types. |
|
49 |
if ($type = !empty($element['#type']) ? $element['#type'] : FALSE) { |
|
50 |
if (in_array($type, $types) || ($type === 'file' && empty($element['#managed_file']))) { |
|
51 |
$element['#attributes']['class'][] = 'form-control'; |
|
52 |
} |
|
53 |
if ($type === 'machine_name') { |
|
54 |
$element['#wrapper_attributes']['class'][] = 'form-inline'; |
|
55 |
} |
|
50 |
// Determine element theme hook. |
|
51 |
$theme = !empty($element['#theme']) ? $element['#theme'] : FALSE; |
|
52 |
|
|
53 |
// Handle array of theme hooks, just use first one (rare, but could happen). |
|
54 |
if (is_array($theme)) { |
|
55 |
$theme = array_shift($theme); |
|
56 |
} |
|
57 |
|
|
58 |
// Remove any suggestions. |
|
59 |
$parts = explode('__', $theme); |
|
60 |
$theme = array_shift($parts); |
|
61 |
|
|
62 |
// Determine element type. |
|
63 |
$type = !empty($element['#type']) ? $element['#type'] : FALSE; |
|
64 |
|
|
65 |
// Add necessary classes for specific element types/theme hooks. |
|
66 |
if (($theme && in_array($theme, $theme_hooks)) || ($type && in_array($type, $types)) || ($type === 'file' && empty($element['#managed_file']))) { |
|
67 |
$element['#attributes']['class'][] = 'form-control'; |
|
68 |
} |
|
69 |
if ($type === 'machine_name') { |
|
70 |
$element['#wrapper_attributes']['class'][] = 'form-inline'; |
|
56 | 71 |
} |
57 | 72 |
|
58 | 73 |
// Add smart descriptions to the element, if necessary. |
Formats disponibles : Unified diff
Weekly update of contrib modules