1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* All Process functions for templates and theme fucntions.
|
6 |
|
|
*
|
7 |
|
|
* If you need to add or modify process functions do it in your sub-theme.
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
/**
|
11 |
|
|
* Process variables for html.tpl.php
|
12 |
|
|
*/
|
13 |
|
|
function adaptivetheme_process_html(&$vars) {
|
14 |
|
|
// Flatten attributes arrays
|
15 |
|
|
$vars['html_attributes'] = empty($vars['html_attributes_array']) ? '' : drupal_attributes($vars['html_attributes_array']);
|
16 |
|
|
|
17 |
|
|
// $rdf_namespaces is kept to maintain backwards compatibility, and because we
|
18 |
|
|
// only want this to print once in html.tpl.php, and not in every conditional
|
19 |
|
|
// comment for IE.
|
20 |
|
|
$vars['rdf_namespaces'] = empty($vars['rdf_namespaces_array']) ? '' : drupal_attributes($vars['rdf_namespaces_array']);
|
21 |
|
|
|
22 |
74f6bef0
|
Assos Assos
|
// Render polyfills
|
23 |
|
|
if ($vars['polyfills']) {
|
24 |
|
|
$vars['polyfills'] = drupal_render($vars['polyfills']);
|
25 |
85ad3d82
|
Assos Assos
|
}
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
/**
|
29 |
|
|
* Process variables for the html tag
|
30 |
|
|
*/
|
31 |
|
|
function adaptivetheme_process_html_tag(&$vars) {
|
32 |
|
|
$tag = &$vars['element'];
|
33 |
|
|
if ($tag['#tag'] === 'style' || $tag['#tag'] === 'script') {
|
34 |
|
|
// Remove redundant type attribute and CDATA comments.
|
35 |
|
|
unset($tag['#attributes']['type'], $tag['#value_prefix'], $tag['#value_suffix']);
|
36 |
|
|
// Remove media="all" but leave others unaffected.
|
37 |
|
|
if (isset($tag['#attributes']['media']) && $tag['#attributes']['media'] === 'all') {
|
38 |
|
|
unset($tag['#attributes']['media']);
|
39 |
|
|
}
|
40 |
|
|
}
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
/**
|
44 |
|
|
* Process variables for page.tpl.php
|
45 |
|
|
*/
|
46 |
|
|
function adaptivetheme_process_page(&$vars) {
|
47 |
|
|
global $theme_key;
|
48 |
|
|
$theme_name = $theme_key;
|
49 |
|
|
|
50 |
|
|
// Attributes
|
51 |
|
|
$vars['page_attributes'] = empty($vars['page_attributes_array']) ? '' : drupal_attributes($vars['page_attributes_array']);
|
52 |
|
|
$vars['header_attributes'] = empty($vars['header_attributes_array']) ? '' : drupal_attributes($vars['header_attributes_array']);
|
53 |
|
|
$vars['branding_attributes'] = empty($vars['branding_attributes_array']) ? '' : drupal_attributes($vars['branding_attributes_array']);
|
54 |
|
|
$vars['hgroup_attributes'] = empty($vars['hgroup_attributes_array']) ? '' : drupal_attributes($vars['hgroup_attributes_array']);
|
55 |
|
|
$vars['site_name_attributes'] = empty($vars['site_name_attributes_array']) ? '' : drupal_attributes($vars['site_name_attributes_array']);
|
56 |
|
|
$vars['site_slogan_attributes'] = empty($vars['site_slogan_attributes_array']) ? '' : drupal_attributes($vars['site_slogan_attributes_array']);
|
57 |
|
|
$vars['content_header_attributes'] = empty($vars['content_header_attributes_array']) ? '' : drupal_attributes($vars['content_header_attributes_array']);
|
58 |
|
|
$vars['footer_attributes'] = empty($vars['footer_attributes_array']) ? '' : drupal_attributes($vars['footer_attributes_array']);
|
59 |
|
|
|
60 |
|
|
// Theme the menu bars
|
61 |
|
|
if (!empty($vars['primary_navigation'])) {
|
62 |
74f6bef0
|
Assos Assos
|
$vars['primary_navigation'] = theme('menubar', array('menu' => $vars['primary_navigation'],'type' => 'primary'));
|
63 |
85ad3d82
|
Assos Assos
|
}
|
64 |
|
|
if (!empty($vars['secondary_navigation'])) {
|
65 |
|
|
$vars['secondary_navigation'] = theme('menubar', array('menu' => $vars['secondary_navigation'], 'type' => 'secondary'));
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
// Generate the wrapper element for the main content
|
69 |
|
|
$vars['tag'] = $vars['title'] ? 'section' : 'div';
|
70 |
|
|
|
71 |
|
|
// Process enabled Extensions
|
72 |
|
|
if (at_get_setting('enable_extensions', $theme_name) === 1) {
|
73 |
|
|
if (at_get_setting('enable_markup_overides', $theme_name) === 1) {
|
74 |
|
|
// Add page template suggestions per node type, but make the suggestion weak
|
75 |
|
|
// so other suggestions can easily override it.
|
76 |
|
|
if (at_get_setting('page_content_type_suggestions', $theme_name) === 1) {
|
77 |
|
|
if (isset($vars['node'])) {
|
78 |
74f6bef0
|
Assos Assos
|
$suggestion = 'page__' . $vars['node']->type;
|
79 |
85ad3d82
|
Assos Assos
|
array_unshift($vars['theme_hook_suggestions'], $suggestion);
|
80 |
|
|
}
|
81 |
|
|
}
|
82 |
|
|
// Force full width wrapper template suggestion if enabled
|
83 |
|
|
if (at_get_setting('page_full_width_wrappers', $theme_name) === 1) {
|
84 |
|
|
array_unshift($vars['theme_hook_suggestions'], 'page__full_width_wrappers');
|
85 |
|
|
}
|
86 |
|
|
// Remove the frontpage title if set in theme settings
|
87 |
|
|
if (at_get_setting('frontpage_remove_title') === 1 && $vars['is_front'] === TRUE) {
|
88 |
|
|
$vars['title'] = '';
|
89 |
|
|
}
|
90 |
|
|
}
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
// Page template suggestions for Panels pages
|
94 |
|
|
if (module_exists('page_manager')) {
|
95 |
|
|
if($panel_page = page_manager_get_current_page()) {
|
96 |
|
|
// add a generic suggestion for all panel pages
|
97 |
|
|
$suggestions[] = 'page__panels';
|
98 |
|
|
// add the panel page machine name to the template suggestions
|
99 |
|
|
$suggestions[] = 'page__' . $panel_page['name'];
|
100 |
|
|
// merge the suggestions in to the existing suggestions (as more specific than the existing suggestions)
|
101 |
|
|
$vars['theme_hook_suggestions'] = array_merge($vars['theme_hook_suggestions'], $suggestions);
|
102 |
|
|
}
|
103 |
|
|
}
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
/**
|
107 |
|
|
* Process variables for region.tpl.php
|
108 |
|
|
*/
|
109 |
|
|
function adaptivetheme_process_region(&$vars) {
|
110 |
|
|
// Initialize and populate the outer wrapper variables
|
111 |
|
|
$vars['outer_prefix'] = '<div class="' . $vars['classes'] . '">';
|
112 |
|
|
$vars['outer_suffix'] = '</div>';
|
113 |
|
|
|
114 |
|
|
// Initialize and populate the inner wrapper variables
|
115 |
|
|
$vars['inner_prefix'] = '<div class="region-inner clearfix">';
|
116 |
|
|
$vars['inner_suffix'] = '</div>';
|
117 |
|
|
|
118 |
|
|
// Some regions need different or no markup
|
119 |
|
|
// Use a region template with no wrappers for the main content
|
120 |
|
|
if ($vars['region'] === 'content') {
|
121 |
|
|
$vars['outer_prefix'] = '';
|
122 |
|
|
$vars['outer_suffix'] = '';
|
123 |
|
|
$vars['inner_prefix'] = '';
|
124 |
|
|
$vars['inner_suffix'] = '';
|
125 |
|
|
}
|
126 |
|
|
// Menu bar needs an id, nav class and no inner wrapper
|
127 |
|
|
if ($vars['region'] === 'menu_bar') {
|
128 |
|
|
$vars['outer_prefix'] = '<div id="menu-bar" class="nav clearfix">';
|
129 |
|
|
$vars['inner_prefix'] = '';
|
130 |
|
|
$vars['inner_suffix'] = '';
|
131 |
|
|
}
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
/**
|
135 |
|
|
* Process variables for block.tpl.php
|
136 |
|
|
*/
|
137 |
|
|
function adaptivetheme_process_block(&$vars) {
|
138 |
|
|
// Now we know all the block $tag's, we can generate our wrapper, $tag is
|
139 |
|
|
// set in preprocess. We cant introduce these in preprocess due to attributes
|
140 |
|
|
// and classes not being flattened untill we hit process.
|
141 |
|
|
$vars['outer_prefix'] = '<' . $vars['tag'] . ' id="' . $vars['block_html_id'] . '" class="' . $vars['classes'] . '" ' . $vars['attributes'] . '>';
|
142 |
|
|
$vars['outer_suffix'] = '</' . $vars['tag'] . '>';
|
143 |
|
|
|
144 |
74f6bef0
|
Assos Assos
|
// Block inner attributes
|
145 |
|
|
$vars['block_inner_attributes'] = empty($vars['block_inner_attributes_array']) ? '' : drupal_attributes($vars['block_inner_attributes_array']);
|
146 |
|
|
|
147 |
|
|
// Populate the default inner wrappers
|
148 |
|
|
$vars['inner_prefix'] = '<div' . $vars['block_inner_attributes'] . '>';
|
149 |
|
|
$vars['inner_suffix'] = '</div>';
|
150 |
|
|
|
151 |
85ad3d82
|
Assos Assos
|
// Wrap the content variable in a div with attributes
|
152 |
|
|
$vars['content_processed'] = '<div' . $vars['content_attributes'] . '>' . $vars['content'] . '</div>';
|
153 |
|
|
|
154 |
|
|
// The menu bar region gets special treatment for the block template
|
155 |
|
|
if ($vars['block']->region === 'menu_bar') {
|
156 |
|
|
$vars['inner_prefix'] = '';
|
157 |
|
|
$vars['inner_suffix'] = '';
|
158 |
|
|
$vars['content_processed'] = $vars['content']; // remove the default wrapper
|
159 |
|
|
}
|
160 |
74f6bef0
|
Assos Assos
|
// Navigation or menu blocks get special treatment in these regions
|
161 |
|
|
if ($vars['block']->region === 'leaderboard' || $vars['block']->region === 'header') {
|
162 |
|
|
if ($vars['tag'] == 'nav') {
|
163 |
|
|
$vars['content_processed'] = $vars['content']; // remove the default wrapper
|
164 |
|
|
}
|
165 |
|
|
}
|
166 |
85ad3d82
|
Assos Assos
|
|
167 |
|
|
// Some blocks look bad with wrappers so we strip them
|
168 |
|
|
if ($vars['block']->region === 'content') {
|
169 |
|
|
$vars['inner_prefix'] = '';
|
170 |
|
|
$vars['inner_suffix'] = '';
|
171 |
|
|
$vars['content_processed'] = $vars['content'];
|
172 |
|
|
}
|
173 |
|
|
if ($vars['block']->module === 'panels_mini') {
|
174 |
|
|
$vars['inner_prefix'] = '';
|
175 |
|
|
$vars['inner_suffix'] = '';
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
// Provide additional suggestions so the block__menu suggestion can be overridden easily
|
179 |
|
|
$vars['theme_hook_suggestions'][] = 'block__' . $vars['block']->region . '__' . $vars['block']->module;
|
180 |
|
|
$vars['theme_hook_suggestions'][] = 'block__' . $vars['block']->region . '__' . $vars['block']->delta;
|
181 |
|
|
}
|
182 |
|
|
|
183 |
|
|
/**
|
184 |
|
|
* Process variables for node.tpl.php
|
185 |
|
|
*/
|
186 |
|
|
function adaptivetheme_process_node(&$vars) {
|
187 |
|
|
global $theme_key;
|
188 |
|
|
$theme_name = $theme_key;
|
189 |
|
|
|
190 |
|
|
// Strip default drupal classes if not required
|
191 |
|
|
if (at_get_setting('extra_article_classes', $theme_name) === 0) {
|
192 |
|
|
$classes = explode(' ', $vars['classes']);
|
193 |
|
|
$striped_classes = array('node-sticky', 'node-promoted', 'node-teaser', 'node-preview');
|
194 |
|
|
foreach ($striped_classes as $class) {
|
195 |
|
|
if (in_array($class, $classes)) {
|
196 |
|
|
$classes = str_replace($class, '', $classes);
|
197 |
|
|
}
|
198 |
|
|
}
|
199 |
|
|
$vars['classes'] = trim(implode(' ', $classes));
|
200 |
|
|
}
|
201 |
|
|
|
202 |
|
|
// Flatten the additional wrapper attributes array
|
203 |
|
|
$vars['header_attributes'] = empty($vars['header_attributes_array']) ? '' : drupal_attributes($vars['header_attributes_array']);
|
204 |
|
|
$vars['footer_attributes'] = empty($vars['footer_attributes_array']) ? '' : drupal_attributes($vars['footer_attributes_array']);
|
205 |
|
|
$vars['links_attributes'] = empty($vars['links_attributes_array']) ? '' : drupal_attributes($vars['links_attributes_array']);
|
206 |
|
|
|
207 |
74f6bef0
|
Assos Assos
|
// If a panels layout is being rendered by Display Suite in a node we wrap the
|
208 |
85ad3d82
|
Assos Assos
|
// the layout in markup to make the themers life a little easier and remove
|
209 |
|
|
// the requirement to add a DS template override.
|
210 |
|
|
if (isset($vars['rendered_by_ds']) && $vars['rendered_by_ds'] == TRUE) {
|
211 |
74f6bef0
|
Assos Assos
|
$vars['panel_prefix'] = '<article id="node-' . $vars['node']->nid . '" class="' . $vars['classes'] . ' rendered-by-ds clearfix"' . $vars['attributes'] . '>';
|
212 |
|
|
$vars['panel_prefix'] .= render($vars['title_prefix']);
|
213 |
|
|
$vars['panel_prefix'] .= render($vars['title_suffix']);
|
214 |
85ad3d82
|
Assos Assos
|
$vars['panel_suffix'] = '</article>';
|
215 |
|
|
}
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
/**
|
219 |
|
|
* Process variables for comment.tpl.php
|
220 |
|
|
*/
|
221 |
|
|
function adaptivetheme_process_comment(&$vars) {
|
222 |
|
|
global $theme_key;
|
223 |
|
|
$theme_name = $theme_key;
|
224 |
|
|
|
225 |
|
|
// Strip default drupal classes if not required.
|
226 |
|
|
if (at_get_setting('extra_comment_classes', $theme_name) === 0) {
|
227 |
|
|
$classes = explode(' ', $vars['classes']);
|
228 |
|
|
$striped_classes = array('comment-by-anonymous', 'comment-by-node-autho', 'comment-by-viewer', 'comment-new');
|
229 |
|
|
foreach ($striped_classes as $class) {
|
230 |
|
|
if (in_array($class, $classes)) {
|
231 |
|
|
$classes = str_replace($class, '', $classes);
|
232 |
|
|
}
|
233 |
|
|
}
|
234 |
|
|
$vars['classes'] = trim(implode(' ', $classes));
|
235 |
|
|
}
|
236 |
|
|
|
237 |
|
|
// Flatten the additional wrapper attributes array
|
238 |
|
|
$vars['header_attributes'] = empty($vars['header_attributes_array']) ? '' : drupal_attributes($vars['header_attributes_array']);
|
239 |
|
|
$vars['footer_attributes'] = empty($vars['footer_attributes_array']) ? '' : drupal_attributes($vars['footer_attributes_array']);
|
240 |
|
|
$vars['links_attributes'] = empty($vars['links_attributes_array']) ? '' : drupal_attributes($vars['links_attributes_array']);
|
241 |
|
|
}
|
242 |
|
|
|
243 |
|
|
/**
|
244 |
|
|
* Process variables for adaptivtheme_menubar()
|
245 |
|
|
*/
|
246 |
|
|
function adaptivetheme_process_menubar(&$vars) {
|
247 |
|
|
// The default theme implementation is a function, so template_process() does
|
248 |
|
|
// not automatically run, so we need to flatten the classes and attributes
|
249 |
|
|
// here. For best performance, only call drupal_attributes() when needed, and
|
250 |
|
|
// note that template_preprocess_menubar() does not initialize the
|
251 |
|
|
// *_attributes_array variables.
|
252 |
|
|
$vars['classes'] = implode(' ', $vars['classes_array']);
|
253 |
|
|
$vars['attributes'] = empty($vars['attributes_array']) ? '' : drupal_attributes($vars['attributes_array']);
|
254 |
|
|
$vars['content_attributes'] = empty($vars['content_attributes_array']) ? '' : drupal_attributes($vars['content_attributes_array']);
|
255 |
|
|
}
|
256 |
|
|
|
257 |
|
|
/**
|
258 |
|
|
* Process variables for maintenance-page.tpl.php
|
259 |
|
|
*/
|
260 |
|
|
function adaptivetheme_process_maintenance_page(&$vars) {
|
261 |
74f6bef0
|
Assos Assos
|
// Render polyfills
|
262 |
|
|
if ($vars['polyfills']) {
|
263 |
|
|
$vars['polyfills'] = drupal_render($vars['polyfills']);
|
264 |
85ad3d82
|
Assos Assos
|
}
|
265 |
74f6bef0
|
Assos Assos
|
}
|
266 |
|
|
|
267 |
|
|
/**
|
268 |
|
|
* Process variables for user-profile.tpl.php
|
269 |
|
|
*/
|
270 |
|
|
function adaptivetheme_process_user_profile(&$vars) {
|
271 |
|
|
// If a panels layout is rendered by Display Suite in a user profile we wrap the
|
272 |
|
|
// the layout in markup to make the themers life a little easier and remove
|
273 |
|
|
// the requirement to add a DS template override.
|
274 |
|
|
if (isset($vars['rendered_by_ds']) && $vars['rendered_by_ds'] == TRUE) {
|
275 |
|
|
$vars['panel_prefix'] = '<article id="user-' . $vars['user']->uid . '" class="' . $vars['classes'] . ' rendered-by-ds clearfix"' . $vars['attributes'] . '>';
|
276 |
|
|
$vars['panel_suffix'] = '</article>';
|
277 |
85ad3d82
|
Assos Assos
|
}
|
278 |
|
|
} |