Projet

Général

Profil

Paste
Télécharger (6,19 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / bootstrap / bootstrap.api.php @ 7547bb19

1
<?php
2
/**
3
 * @file
4
 * List of available hook and alter APIs for use in your sub-theme.
5
 */
6

    
7
/**
8
 * @defgroup api APIs
9
 *
10
 * List of available hook and alter APIs for use in your sub-theme.
11
 *
12
 * @{
13
 */
14

    
15
/**
16
 * Allows sub-themes to alter the array used for colorizing text.
17
 *
18
 * @param array $texts
19
 *   An associative array containing the text and classes to be matched, passed
20
 *   by reference.
21
 *
22
 * @see _bootstrap_colorize_text()
23
 */
24
function hook_bootstrap_colorize_text_alter(&$texts) {
25
  // This matches the exact string: "My Unique Button Text".
26
  $texts['matches'][t('My Unique Button Text')] = 'primary';
27

    
28
  // This would also match the string above, however the class returned would
29
  // also be the one above; "matches" takes precedence over "contains".
30
  $texts['contains'][t('Unique')] = 'notice';
31

    
32
  // Remove matching for strings that contain "apply":
33
  unset($texts['contains'][t('Apply')]);
34

    
35
  // Change the class that matches "Rebuild" (originally "warning"):
36
  $texts['contains'][t('Rebuild')] = 'success';
37
}
38

    
39
/**
40
 * Allows sub-themes to alter the array used for associating an icon with text.
41
 *
42
 * @param array $texts
43
 *   An associative array containing the text and icons to be matched, passed
44
 *   by reference.
45
 *
46
 * @see _bootstrap_iconize_text()
47
 */
48
function hook_bootstrap_iconize_text_alter(&$texts) {
49
  // This matches the exact string: "My Unique Button Text".
50
  $texts['matches'][t('My Unique Button Text')] = 'heart';
51

    
52
  // This would also match the string above, however the class returned would
53
  // also be the one above; "matches" takes precedence over "contains".
54
  $texts['contains'][t('Unique')] = 'bullhorn';
55

    
56
  // Remove matching for strings that contain "filter":
57
  unset($texts['contains'][t('Filter')]);
58

    
59
  // Change the icon that matches "Upload" (originally "upload"):
60
  $texts['contains'][t('Upload')] = 'ok';
61
}
62

    
63
/**
64
 * This hook allows sub-themes to process all form elements.
65
 *
66
 * For this hook to be recognized, it must reside directly inside the
67
 * template.php file or via a file that is directly included into template.php.
68
 *
69
 * Any time a hook is added or removed, the Drupal cache must be completely
70
 * cleared and rebuilt for the changes to take effect.
71
 *
72
 * Implementations of this hook should check to see if the element has a
73
 * property named #bootstrap_ignore_process and check if it is set to TRUE.
74
 * If it is, the hook should immediately return with the unaltered element.
75
 *
76
 * @param array $element
77
 *   The element array, this is NOT passed by reference and must return the
78
 *   altered element instead.
79
 * @param array $form_state
80
 *   The form state array, passed by reference.
81
 * @param array $form
82
 *   The complete form array, passed by reference.
83
 *
84
 * @return array
85
 *   The altered element array.
86
 *
87
 * @see bootstrap_element_info_alter()
88
 * @see form_builder()
89
 * @see drupal_process_form()
90
 */
91
function hook_form_process($element, &$form_state, &$form) {
92
  return $element;
93
}
94

    
95
/**
96
 * This hook allows sub-themes to process a specific form element type.
97
 *
98
 * For this hook to be recognized, it must reside directly inside the
99
 * template.php file or via a file that is directly included into template.php.
100
 *
101
 * Any time a hook is added or removed, the Drupal cache must be completely
102
 * cleared and rebuilt for the changes to take effect.
103
 *
104
 * If there is a matching "form_process_HOOK" function already defined
105
 * (provided by core), it will be replaced. The theme replacing it will be
106
 * responsible for fully processing the element as it was prior.
107
 *
108
 * Implementations of this hook should check to see if the element has a
109
 * property named #bootstrap_ignore_process and check if it is set to TRUE.
110
 * If it is, the hook should immediately return with the unaltered element.
111
 *
112
 * @param array $element
113
 *   The element array, this is NOT passed by reference and must return the
114
 *   altered element instead.
115
 * @param array $form_state
116
 *   The form state array, passed by reference.
117
 * @param array $form
118
 *   The complete form array, passed by reference.
119
 *
120
 * @return array
121
 *   The altered element array.
122
 *
123
 * @see bootstrap_element_info_alter()
124
 * @see form_builder()
125
 * @see drupal_process_form()
126
 */
127
function hook_form_process_HOOK($element, &$form_state, &$form) {
128
  return $element;
129
}
130

    
131
/**
132
 * This hook allows sub-themes to alter all elements before it's rendered.
133
 *
134
 * For this hook to be recognized, it must reside directly inside the
135
 * template.php file or via a file that is directly included into template.php.
136
 *
137
 * Any time a hook is added or removed, the Drupal cache must be completely
138
 * cleared and rebuilt for the changes to take effect.
139
 *
140
 * Implementations of this hook should check to see if the element has a
141
 * property named #bootstrap_ignore_pre_render and check if it is set to TRUE.
142
 * If it is, the hook should immediately return with the unaltered element.
143
 *
144
 * @param array $element
145
 *   The element array, this is NOT passed by reference and must return the
146
 *   altered element instead.
147
 *
148
 * @return array
149
 *   The altered element array.
150
 *
151
 * @see bootstrap_element_info_alter()
152
 */
153
function hook_pre_render($element) {
154
  return $element;
155
}
156

    
157
/**
158
 * This hook allows sub-themes to alter a specific element before it's rendered.
159
 *
160
 * For this hook to be recognized, it must reside directly inside the
161
 * template.php file or via a file that is directly included into template.php.
162
 *
163
 * Any time a hook is added or removed, the Drupal cache must be completely
164
 * cleared and rebuilt for the changes to take effect.
165
 *
166
 * If there is a matching "form_pre_render_HOOK" function already defined
167
 * (provided by core), it will be replaced. The theme replacing it will be
168
 * responsible for fully processing the element as it was prior.
169
 *
170
 * Implementations of this hook should check to see if the element has a
171
 * property named #bootstrap_ignore_pre_render and check if it is set to TRUE.
172
 * If it is, the hook should immediately return with the unaltered element.
173
 *
174
 * @param array $element
175
 *   The element array, this is NOT passed by reference and must return the
176
 *   altered element instead.
177
 *
178
 * @return array
179
 *   The altered element array.
180
 *
181
 * @see bootstrap_element_info_alter()
182
 */
183
function hook_pre_render_HOOK($element) {
184
  return $element;
185
}
186

    
187
/**
188
 * @} End of "defgroup subtheme_api".
189
 */