html.vars.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * @file
  4. * Stub file for "html" theme hook [pre]process functions.
  5. */
  6. /**
  7. * Pre-processes variables for the "html" theme hook.
  8. *
  9. * See template for list of available variables.
  10. *
  11. * @see html.tpl.php
  12. *
  13. * @ingroup theme_preprocess
  14. */
  15. function bootstrap_preprocess_html(&$variables) {
  16. // Backport from Drupal 8 RDFa/HTML5 implementation.
  17. // @see https://www.drupal.org/node/1077566
  18. // @see https://www.drupal.org/node/1164926
  19. // HTML element attributes.
  20. $variables['html_attributes_array'] = array(
  21. 'lang' => $variables['language']->language,
  22. 'dir' => $variables['language']->dir,
  23. );
  24. // Override existing RDF namespaces to use RDFa 1.1 namespace prefix bindings.
  25. if (function_exists('rdf_get_namespaces')) {
  26. $rdf = array('prefix' => array());
  27. foreach (rdf_get_namespaces() as $prefix => $uri) {
  28. $rdf['prefix'][] = $prefix . ': ' . $uri;
  29. }
  30. if (!$rdf['prefix']) {
  31. $rdf = array();
  32. }
  33. $variables['rdf_namespaces'] = drupal_attributes($rdf);
  34. }
  35. // BODY element attributes.
  36. $variables['body_attributes_array'] = array(
  37. 'role' => 'document',
  38. 'class' => &$variables['classes_array'],
  39. );
  40. $variables['body_attributes_array'] += $variables['attributes_array'];
  41. // Navbar position.
  42. switch (bootstrap_setting('navbar_position')) {
  43. case 'fixed-top':
  44. $variables['body_attributes_array']['class'][] = 'navbar-is-fixed-top';
  45. break;
  46. case 'fixed-bottom':
  47. $variables['body_attributes_array']['class'][] = 'navbar-is-fixed-bottom';
  48. break;
  49. case 'static-top':
  50. $variables['body_attributes_array']['class'][] = 'navbar-is-static-top';
  51. break;
  52. }
  53. }
  54. /**
  55. * Processes variables for the "html" theme hook.
  56. *
  57. * See template for list of available variables.
  58. *
  59. * @see html.tpl.php
  60. *
  61. * @ingroup theme_process
  62. */
  63. function bootstrap_process_html(&$variables) {
  64. $variables['html_attributes'] = drupal_attributes($variables['html_attributes_array']);
  65. $variables['body_attributes'] = drupal_attributes($variables['body_attributes_array']);
  66. }