root / drupal7 / sites / all / themes / bootstrap / templates / system / html.vars.php @ 388c412d
1 |
<?php
|
---|---|
2 |
/**
|
3 |
* @file
|
4 |
* Stub file for "html" theme hook [pre]process functions.
|
5 |
*/
|
6 |
|
7 |
/**
|
8 |
* Pre-processes variables for the "html" theme hook.
|
9 |
*
|
10 |
* See template for list of available variables.
|
11 |
*
|
12 |
* @see html.tpl.php
|
13 |
*
|
14 |
* @ingroup theme_preprocess
|
15 |
*/
|
16 |
function bootstrap_preprocess_html(&$variables) { |
17 |
// Backport from Drupal 8 RDFa/HTML5 implementation.
|
18 |
// @see https://www.drupal.org/node/1077566
|
19 |
// @see https://www.drupal.org/node/1164926
|
20 |
|
21 |
// Create a dedicated attributes array for the HTML element.
|
22 |
// By default, core does not provide a way to target the HTML element.
|
23 |
// The only arrays currently available technically belong to the BODY element.
|
24 |
$variables['html_attributes_array'] = array( |
25 |
'lang' => $variables['language']->language, |
26 |
'dir' => $variables['language']->dir, |
27 |
); |
28 |
|
29 |
// Override existing RDF namespaces to use RDFa 1.1 namespace prefix bindings.
|
30 |
if (function_exists('rdf_get_namespaces')) { |
31 |
$rdf = array('prefix' => array()); |
32 |
foreach (rdf_get_namespaces() as $prefix => $uri) { |
33 |
$rdf['prefix'][] = $prefix . ': ' . $uri; |
34 |
} |
35 |
if (!$rdf['prefix']) { |
36 |
$rdf = array(); |
37 |
} |
38 |
$variables['rdf_namespaces'] = drupal_attributes($rdf); |
39 |
} |
40 |
|
41 |
// Create a dedicated attributes array for the BODY element.
|
42 |
if (!isset($variables['body_attributes_array'])) { |
43 |
$variables['body_attributes_array'] = array(); |
44 |
} |
45 |
|
46 |
// Ensure there is at least a class array.
|
47 |
if (!isset($variables['body_attributes_array']['class'])) { |
48 |
$variables['body_attributes_array']['class'] = array(); |
49 |
} |
50 |
|
51 |
// Navbar position.
|
52 |
switch (bootstrap_setting('navbar_position')) { |
53 |
case 'fixed-top': |
54 |
$variables['body_attributes_array']['class'][] = 'navbar-is-fixed-top'; |
55 |
break;
|
56 |
|
57 |
case 'fixed-bottom': |
58 |
$variables['body_attributes_array']['class'][] = 'navbar-is-fixed-bottom'; |
59 |
break;
|
60 |
|
61 |
case 'static-top': |
62 |
$variables['body_attributes_array']['class'][] = 'navbar-is-static-top'; |
63 |
break;
|
64 |
} |
65 |
} |
66 |
|
67 |
/**
|
68 |
* Processes variables for the "html" theme hook.
|
69 |
*
|
70 |
* See template for list of available variables.
|
71 |
*
|
72 |
* **WARNING**: It is not recommended that this function be copied to a
|
73 |
* sub-theme. There is rarely any need to process the same variables twice.
|
74 |
*
|
75 |
* If you need to add something to the "html_attributes_array" or
|
76 |
* "body_attributes_array" arrays, you should do so in a hook_preprocess_html()
|
77 |
* function since process functions will always run after all preprocess
|
78 |
* functions have been executed.
|
79 |
*
|
80 |
* If there is a need to implement a hook_process_html() function in your
|
81 |
* sub-theme (to process your own custom variables), ensure that it doesn't
|
82 |
* add this base theme's logic and risk introducing breakage and performance
|
83 |
* issues.
|
84 |
*
|
85 |
* @see html.tpl.php
|
86 |
*
|
87 |
* @ingroup theme_process
|
88 |
*/
|
89 |
function bootstrap_process_html(&$variables) { |
90 |
// Merge in (not reference!) core's ambiguous and separate "attribute" and
|
91 |
// "class" arrays. These arrays are meant for the BODY element, but it must
|
92 |
// be done at the process level in case sub-themes wish to add classes to
|
93 |
// core's non-standard arrays (which are for the BODY element only).
|
94 |
// @see https://www.drupal.org/node/2868426
|
95 |
$variables['body_attributes_array'] = drupal_array_merge_deep($variables['body_attributes_array'], $variables['attributes_array']); |
96 |
|
97 |
// Use this project's class helper (to eliminate any duplicate classes).
|
98 |
_bootstrap_add_class($variables['classes_array'], $variables, 'body_attributes_array'); |
99 |
|
100 |
// Finally, convert the arrays into proper attribute strings.
|
101 |
$variables['html_attributes'] = drupal_attributes($variables['html_attributes_array']); |
102 |
$variables['body_attributes'] = drupal_attributes($variables['body_attributes_array']); |
103 |
} |