bootstrap.api.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. /**
  3. * @file
  4. * List of available hook and alter APIs for use in your sub-theme.
  5. */
  6. /**
  7. * @defgroup api APIs
  8. *
  9. * List of available hook and alter APIs for use in your sub-theme.
  10. *
  11. * @{
  12. */
  13. /**
  14. * Allows sub-themes to alter the array used for colorizing text.
  15. *
  16. * @param array $texts
  17. * An associative array containing the text and classes to be matched, passed
  18. * by reference.
  19. *
  20. * @see _bootstrap_colorize_text()
  21. */
  22. function hook_bootstrap_colorize_text_alter(array &$texts) {
  23. // This matches the exact string: "My Unique Button Text".
  24. $texts['matches'][t('My Unique Button Text')] = 'primary';
  25. // This would also match the string above, however the class returned would
  26. // also be the one above; "matches" takes precedence over "contains".
  27. $texts['contains'][t('Unique')] = 'notice';
  28. // Remove matching for strings that contain "apply":
  29. unset($texts['contains'][t('Apply')]);
  30. // Change the class that matches "Rebuild" (originally "warning"):
  31. $texts['contains'][t('Rebuild')] = 'success';
  32. }
  33. /**
  34. * Allows sub-themes to alter the array used for associating an icon with text.
  35. *
  36. * @param array $texts
  37. * An associative array containing the text and icons to be matched, passed
  38. * by reference.
  39. *
  40. * @see _bootstrap_iconize_text()
  41. */
  42. function hook_bootstrap_iconize_text_alter(array &$texts) {
  43. // This matches the exact string: "My Unique Button Text".
  44. $texts['matches'][t('My Unique Button Text')] = 'heart';
  45. // This would also match the string above, however the class returned would
  46. // also be the one above; "matches" takes precedence over "contains".
  47. $texts['contains'][t('Unique')] = 'bullhorn';
  48. // Remove matching for strings that contain "filter":
  49. unset($texts['contains'][t('Filter')]);
  50. // Change the icon that matches "Upload" (originally "upload"):
  51. $texts['contains'][t('Upload')] = 'ok';
  52. }
  53. /**
  54. * This hook allows sub-themes to process all form elements.
  55. *
  56. * For this hook to be recognized, it must reside directly inside the
  57. * template.php file or via a file that is directly included into template.php.
  58. *
  59. * Any time a hook is added or removed, the Drupal cache must be completely
  60. * cleared and rebuilt for the changes to take effect.
  61. *
  62. * Implementations of this hook should check to see if the element has a
  63. * property named #bootstrap_ignore_process and check if it is set to TRUE.
  64. * If it is, the hook should immediately return with the unaltered element.
  65. *
  66. * @param array $element
  67. * The element array, this is NOT passed by reference and must return the
  68. * altered element instead.
  69. * @param array $form_state
  70. * The form state array, passed by reference.
  71. * @param array $form
  72. * The complete form array, passed by reference.
  73. *
  74. * @return array
  75. * The altered element array.
  76. *
  77. * @see bootstrap_element_info_alter()
  78. * @see form_builder()
  79. * @see drupal_process_form()
  80. */
  81. function hook_form_process(array $element, array &$form_state, array &$form) {
  82. return $element;
  83. }
  84. /**
  85. * This hook allows sub-themes to process a specific form element type.
  86. *
  87. * For this hook to be recognized, it must reside directly inside the
  88. * template.php file or via a file that is directly included into template.php.
  89. *
  90. * Any time a hook is added or removed, the Drupal cache must be completely
  91. * cleared and rebuilt for the changes to take effect.
  92. *
  93. * If there is a matching "form_process_HOOK" function already defined
  94. * (provided by core), it will be replaced. The theme replacing it will be
  95. * responsible for fully processing the element as it was prior.
  96. *
  97. * Implementations of this hook should check to see if the element has a
  98. * property named #bootstrap_ignore_process and check if it is set to TRUE.
  99. * If it is, the hook should immediately return with the unaltered element.
  100. *
  101. * @param array $element
  102. * The element array, this is NOT passed by reference and must return the
  103. * altered element instead.
  104. * @param array $form_state
  105. * The form state array, passed by reference.
  106. * @param array $form
  107. * The complete form array, passed by reference.
  108. *
  109. * @return array
  110. * The altered element array.
  111. *
  112. * @see bootstrap_element_info_alter()
  113. * @see form_builder()
  114. * @see drupal_process_form()
  115. */
  116. function hook_form_process_HOOK(array $element, array &$form_state, array &$form) {
  117. return $element;
  118. }
  119. /**
  120. * This hook allows sub-themes to alter all elements before it's rendered.
  121. *
  122. * For this hook to be recognized, it must reside directly inside the
  123. * template.php file or via a file that is directly included into template.php.
  124. *
  125. * Any time a hook is added or removed, the Drupal cache must be completely
  126. * cleared and rebuilt for the changes to take effect.
  127. *
  128. * Implementations of this hook should check to see if the element has a
  129. * property named #bootstrap_ignore_pre_render and check if it is set to TRUE.
  130. * If it is, the hook should immediately return with the unaltered element.
  131. *
  132. * @param array $element
  133. * The element array, this is NOT passed by reference and must return the
  134. * altered element instead.
  135. *
  136. * @return array
  137. * The altered element array.
  138. *
  139. * @see bootstrap_element_info_alter()
  140. */
  141. function hook_pre_render(array $element) {
  142. return $element;
  143. }
  144. /**
  145. * This hook allows sub-themes to alter a specific element before it's rendered.
  146. *
  147. * For this hook to be recognized, it must reside directly inside the
  148. * template.php file or via a file that is directly included into template.php.
  149. *
  150. * Any time a hook is added or removed, the Drupal cache must be completely
  151. * cleared and rebuilt for the changes to take effect.
  152. *
  153. * If there is a matching "form_pre_render_HOOK" function already defined
  154. * (provided by core), it will be replaced. The theme replacing it will be
  155. * responsible for fully processing the element as it was prior.
  156. *
  157. * Implementations of this hook should check to see if the element has a
  158. * property named #bootstrap_ignore_pre_render and check if it is set to TRUE.
  159. * If it is, the hook should immediately return with the unaltered element.
  160. *
  161. * @param array $element
  162. * The element array, this is NOT passed by reference and must return the
  163. * altered element instead.
  164. *
  165. * @return array
  166. * The altered element array.
  167. *
  168. * @see bootstrap_element_info_alter()
  169. */
  170. function hook_pre_render_HOOK(array $element) {
  171. return $element;
  172. }
  173. /**
  174. * @} End of "defgroup subtheme_api".
  175. */