1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Custom theme functions and theme function overrides.
|
6 |
|
|
*
|
7 |
|
|
* If you need to add or modify theme functions do it in your sub-theme.
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
/**
|
11 |
|
|
* Implements hook_theme()
|
12 |
|
|
*
|
13 |
|
|
* @param $existing
|
14 |
|
|
* @param $type
|
15 |
|
|
* @param $theme
|
16 |
|
|
* @param $path
|
17 |
|
|
*
|
18 |
|
|
* @see http://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_theme/7
|
19 |
|
|
*/
|
20 |
|
|
function adaptivetheme_theme($existing, $type, $theme, $path) {
|
21 |
|
|
return array(
|
22 |
|
|
'menubar' => array(
|
23 |
|
|
'render element' => 'element',
|
24 |
|
|
),
|
25 |
|
|
);
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
/**
|
29 |
|
|
* Returns HTML for a menubar.
|
30 |
|
|
*
|
31 |
|
|
* The contents is normally one of Drupals magic menu variables, such as the
|
32 |
|
|
* Main menu or User menu (secondary menu), but could be any menu you wish to
|
33 |
|
|
* wrap in navigation menu type markup and classes.
|
34 |
|
|
*
|
35 |
|
|
* @param $vars
|
36 |
|
|
* An array containing:
|
37 |
|
|
* - $menubar_id: CSS id for theming the menubar
|
38 |
|
|
* - $menu: Holds the themed menu (normally using theme_links())
|
39 |
|
|
* - the usual $classes, $attributes, $content attributes etc
|
40 |
|
|
*
|
41 |
|
|
* @see adaptivetheme_preprocess_menubar()
|
42 |
|
|
* @see adaptivetheme_process_menubar()
|
43 |
|
|
*/
|
44 |
|
|
function adaptivetheme_menubar($vars) {
|
45 |
|
|
$output = '';
|
46 |
|
|
$output .= '<div id="' . $vars['menubar_id'] . '" class="' . $vars['classes'] . '"' . $vars['attributes'] . '>';
|
47 |
|
|
$output .= '<nav ' . $vars['content_attributes'] . '>';
|
48 |
|
|
$output .= $vars['menu'];
|
49 |
|
|
$output .= '</nav></div>';
|
50 |
|
|
return $output;
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
/**
|
54 |
|
|
* Helper function for theming main and secondary variables.
|
55 |
|
|
* Provides 7.x-2.x backward compatibility, not used in 7.x-3.x, instead we now
|
56 |
|
|
* use a proper theme function so themers can override it.
|
57 |
|
|
*
|
58 |
|
|
* @param $menu
|
59 |
|
|
* @param $type
|
60 |
|
|
*/
|
61 |
|
|
function _theme_menu_variables($menu, $type) {
|
62 |
|
|
$output = '<div id="' . $type . '-menu-bar" class="nav"><nav class="clearfix">' . $menu . '</nav></div>';
|
63 |
|
|
return $output;
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
/**
|
67 |
|
|
* Returns HTML for a breadcrumb trail.
|
68 |
|
|
*
|
69 |
74f6bef0
|
Assos Assos
|
* Adaptivetheme renders breadcrumbs as an ordered list (<ol>...</ol>), wrapping
|
70 |
|
|
* crumbs in li elements and the seperators in span elements. Additionally .crumb,
|
71 |
|
|
* .crumb-first and .crumb-last classes are printed on the li elements. We also
|
72 |
|
|
* remove some silly breadcrumbs from various pages.
|
73 |
85ad3d82
|
Assos Assos
|
*
|
74 |
|
|
* @param $vars
|
75 |
|
|
* An associative array containing:
|
76 |
|
|
* - breadcrumb: An array containing the breadcrumb links.
|
77 |
|
|
*/
|
78 |
|
|
function adaptivetheme_breadcrumb($vars) {
|
79 |
|
|
global $theme_key;
|
80 |
|
|
$theme_name = $theme_key;
|
81 |
|
|
$breadcrumb = $vars['breadcrumb'];
|
82 |
|
|
|
83 |
|
|
if (at_get_setting('breadcrumb_display', $theme_name) == 1) {
|
84 |
|
|
|
85 |
|
|
if (at_get_setting('breadcrumb_home', $theme_name) == 0) {
|
86 |
|
|
array_shift($breadcrumb);
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
// Remove the rather pointless breadcrumbs for reset password and user
|
90 |
74f6bef0
|
Assos Assos
|
// register pages, they link to the page you are on, doh!
|
91 |
85ad3d82
|
Assos Assos
|
if (arg(0) === 'user' && (arg(1) === 'password' || arg(1) === 'register')) {
|
92 |
|
|
array_pop($breadcrumb);
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
if (!empty($breadcrumb)) {
|
96 |
|
|
|
97 |
|
|
$separator = filter_xss_admin(at_get_setting('breadcrumb_separator', $theme_name));
|
98 |
|
|
|
99 |
|
|
// Push the page title onto the end of the breadcrumb array
|
100 |
|
|
if (at_get_setting('breadcrumb_title', $theme_name) == 1) {
|
101 |
74f6bef0
|
Assos Assos
|
if ($page_title = drupal_get_title()) {
|
102 |
|
|
$breadcrumb[] = '<span class="crumb-title">' . $page_title . '</span>';
|
103 |
|
|
}
|
104 |
85ad3d82
|
Assos Assos
|
}
|
105 |
|
|
|
106 |
|
|
$class = 'crumb';
|
107 |
|
|
end($breadcrumb);
|
108 |
|
|
$last = key($breadcrumb);
|
109 |
|
|
|
110 |
|
|
$output = '';
|
111 |
|
|
if (at_get_setting('breadcrumb_label', $theme_name) == 1) {
|
112 |
74f6bef0
|
Assos Assos
|
$output = '<div id="breadcrumb" class="clearfix"><nav class="breadcrumb-wrapper with-breadcrumb-label clearfix" role="navigation" aria-labelledby="breadcrumb-label">';
|
113 |
|
|
$output .= '<h2 id="breadcrumb-label" class="breadcrumb-label">' . t('You are here') . '</h2>';
|
114 |
85ad3d82
|
Assos Assos
|
}
|
115 |
|
|
else {
|
116 |
74f6bef0
|
Assos Assos
|
$output = '<div id="breadcrumb" class="clearfix"><nav class="breadcrumb-wrapper clearfix" role="navigation" aria-labelledby="breadcrumb-label">';
|
117 |
|
|
$output .= '<h2 id="breadcrumb-label" class="element-invisible">' . t('You are here') . '</h2>';
|
118 |
85ad3d82
|
Assos Assos
|
}
|
119 |
|
|
$output .= '<ol id="crumbs" class="clearfix">';
|
120 |
74f6bef0
|
Assos Assos
|
foreach ($breadcrumb as $key => $crumb) {
|
121 |
85ad3d82
|
Assos Assos
|
if ($key == $last && count($breadcrumb) != 1) {
|
122 |
|
|
$class = 'crumb crumb-last';
|
123 |
|
|
}
|
124 |
|
|
if ($key == 0) {
|
125 |
74f6bef0
|
Assos Assos
|
$output .= '<li class="' . $class . ' crumb-first">' . $crumb . '</li>';
|
126 |
85ad3d82
|
Assos Assos
|
}
|
127 |
|
|
else {
|
128 |
74f6bef0
|
Assos Assos
|
$output .= '<li class="' . $class . '"><span class="crumb-separator">' . $separator . '</span>' . $crumb . '</li>';
|
129 |
85ad3d82
|
Assos Assos
|
}
|
130 |
|
|
}
|
131 |
|
|
$output .= '</ol></nav></div>';
|
132 |
|
|
|
133 |
|
|
return $output;
|
134 |
|
|
}
|
135 |
|
|
}
|
136 |
|
|
else {
|
137 |
|
|
return;
|
138 |
|
|
}
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
/**
|
142 |
|
|
* Returns HTML for status and/or error messages, grouped by type.
|
143 |
|
|
*
|
144 |
|
|
* Adaptivetheme adds a div wrapper with CSS id.
|
145 |
|
|
*
|
146 |
|
|
* An invisible heading identifies the messages for assistive technology.
|
147 |
|
|
* Sighted users see a colored box. See http://www.w3.org/TR/WCAG-TECHS/H69.html
|
148 |
|
|
* for info.
|
149 |
|
|
*
|
150 |
|
|
* @param $vars
|
151 |
|
|
* An associative array containing:
|
152 |
|
|
* - display: (optional) Set to 'status' or 'error' to display only messages
|
153 |
|
|
* of that type.
|
154 |
|
|
*/
|
155 |
|
|
function adaptivetheme_status_messages($vars) {
|
156 |
74f6bef0
|
Assos Assos
|
$display = drupal_get_messages($vars['display']);
|
157 |
85ad3d82
|
Assos Assos
|
$output = '';
|
158 |
|
|
|
159 |
74f6bef0
|
Assos Assos
|
if (count($display) > 0) {
|
160 |
|
|
$status_heading = array(
|
161 |
|
|
'status' => t('Status message'),
|
162 |
|
|
'error' => t('Error message'),
|
163 |
|
|
'warning' => t('Warning message'),
|
164 |
|
|
);
|
165 |
|
|
foreach ($display as $type => $messages) {
|
166 |
|
|
$output .= "<div class=\"messages $type\">";
|
167 |
|
|
if (!empty($status_heading[$type])) {
|
168 |
|
|
$output .= '<h2 class="element-invisible">' . $status_heading[$type] . "</h2>";
|
169 |
|
|
}
|
170 |
|
|
if (count($messages) > 1) {
|
171 |
|
|
$output .= " <ul>";
|
172 |
|
|
foreach ($messages as $message) {
|
173 |
|
|
$output .= ' <li class="message-item">' . $message . "</li>";
|
174 |
|
|
}
|
175 |
|
|
$output .= " </ul>";
|
176 |
|
|
}
|
177 |
|
|
else {
|
178 |
|
|
$output .= $messages[0];
|
179 |
85ad3d82
|
Assos Assos
|
}
|
180 |
74f6bef0
|
Assos Assos
|
$output .= "</div>";
|
181 |
85ad3d82
|
Assos Assos
|
}
|
182 |
74f6bef0
|
Assos Assos
|
if ($output != ''){
|
183 |
|
|
$output = "<div id=\"messages\">" . $output . "</div>";
|
184 |
85ad3d82
|
Assos Assos
|
}
|
185 |
|
|
}
|
186 |
74f6bef0
|
Assos Assos
|
|
187 |
85ad3d82
|
Assos Assos
|
return $output;
|
188 |
|
|
}
|
189 |
|
|
|
190 |
|
|
/**
|
191 |
|
|
* Returns HTML for a list or nested list of items.
|
192 |
|
|
*
|
193 |
|
|
* Adaptivetheme overrides this in order to insert extra classes into list
|
194 |
|
|
* items, including first, last and odd/even zebra classes.
|
195 |
|
|
*
|
196 |
|
|
* @param $vars
|
197 |
|
|
* An associative array containing:
|
198 |
|
|
* - items: An array of items to be displayed in the list. If an item is a
|
199 |
|
|
* string, then it is used as is. If an item is an array, then the "data"
|
200 |
|
|
* element of the array is used as the contents of the list item. If an item
|
201 |
|
|
* is an array with a "children" element, those children are displayed in a
|
202 |
|
|
* nested list. All other elements are treated as attributes of the list
|
203 |
|
|
* item element.
|
204 |
|
|
* - title: The title of the list.
|
205 |
|
|
* - type: The type of list to return (e.g. "ul", "ol").
|
206 |
|
|
* - attributes: The attributes applied to the list element.
|
207 |
|
|
*/
|
208 |
|
|
function adaptivetheme_item_list($vars) {
|
209 |
|
|
global $theme_key;
|
210 |
|
|
$theme_name = $theme_key;
|
211 |
|
|
|
212 |
|
|
$items = $vars['items'];
|
213 |
|
|
$title = $vars['title'];
|
214 |
|
|
$type = $vars['type'];
|
215 |
|
|
$attributes = $vars['attributes'];
|
216 |
|
|
|
217 |
74f6bef0
|
Assos Assos
|
// If a class exists use it on the wrapper, for Drupal core this mainly applies
|
218 |
|
|
// to the pager, so you get the wrapper class .item-list-pager
|
219 |
|
|
if (isset($attributes['class'])) {
|
220 |
|
|
$output = '<div class="item-list item-list-' . $attributes['class'][0] . '">';
|
221 |
|
|
}
|
222 |
|
|
else {
|
223 |
|
|
$output = '<div class="item-list">';
|
224 |
|
|
}
|
225 |
85ad3d82
|
Assos Assos
|
|
226 |
|
|
if (isset($title) && $title !== '') {
|
227 |
|
|
$output .= '<h3>' . $title . '</h3>';
|
228 |
|
|
}
|
229 |
|
|
|
230 |
|
|
if (!empty($items)) {
|
231 |
|
|
$output .= "<$type" . drupal_attributes($attributes) . '>';
|
232 |
|
|
$num_items = count($items);
|
233 |
|
|
foreach ($items as $i => $item) {
|
234 |
|
|
$attributes = array();
|
235 |
|
|
$children = array();
|
236 |
74f6bef0
|
Assos Assos
|
$data = '';
|
237 |
85ad3d82
|
Assos Assos
|
if (is_array($item)) {
|
238 |
|
|
foreach ($item as $key => $value) {
|
239 |
|
|
if ($key == 'data') {
|
240 |
|
|
$data = $value;
|
241 |
|
|
}
|
242 |
|
|
elseif ($key == 'children') {
|
243 |
|
|
$children = $value;
|
244 |
|
|
}
|
245 |
|
|
else {
|
246 |
|
|
$attributes[$key] = $value;
|
247 |
|
|
}
|
248 |
|
|
}
|
249 |
|
|
}
|
250 |
|
|
else {
|
251 |
|
|
$data = $item;
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
if (count($children) > 0) {
|
255 |
|
|
// Render nested list.
|
256 |
|
|
$data .= theme_item_list(array('items' => $children, 'title' => NULL, 'type' => $type, 'attributes' => $attributes));
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
if (at_get_setting('extra_item_list_classes', $theme_name) == 1) {
|
260 |
|
|
if ($i & 1) {
|
261 |
|
|
$attributes['class'][] = 'odd';
|
262 |
|
|
}
|
263 |
|
|
else {
|
264 |
|
|
$attributes['class'][] = 'even';
|
265 |
|
|
}
|
266 |
|
|
if ($i == 0) {
|
267 |
|
|
$attributes['class'][] = 'first';
|
268 |
|
|
}
|
269 |
|
|
if ($i == $num_items - 1) {
|
270 |
|
|
$attributes['class'][] = 'last';
|
271 |
|
|
}
|
272 |
|
|
}
|
273 |
|
|
$output .= '<li' . drupal_attributes($attributes) . '>' . $data . "</li>"; // no new line!
|
274 |
|
|
}
|
275 |
|
|
$output .= "</$type>";
|
276 |
|
|
}
|
277 |
|
|
$output .= '</div>';
|
278 |
|
|
|
279 |
|
|
return $output;
|
280 |
|
|
}
|
281 |
|
|
|
282 |
|
|
// Dont run this if the DHTML module is running, it borks its output!
|
283 |
|
|
if (!function_exists('dhtml_menu_init')) {
|
284 |
|
|
/**
|
285 |
|
|
* Returns HTML for a wrapper for a menu sub-tree.
|
286 |
|
|
*
|
287 |
|
|
* Adaptivetheme overrides this to insert the clearfix class.
|
288 |
|
|
*
|
289 |
|
|
* @param $vars
|
290 |
|
|
* An associative array containing:
|
291 |
|
|
* - tree: An HTML string containing the tree's items.
|
292 |
|
|
*
|
293 |
|
|
* @see template_preprocess_menu_tree()
|
294 |
|
|
*/
|
295 |
|
|
function adaptivetheme_menu_tree($vars) {
|
296 |
|
|
return '<ul class="menu clearfix">' . $vars['tree'] . '</ul>';
|
297 |
|
|
}
|
298 |
|
|
|
299 |
|
|
/**
|
300 |
|
|
* Returns HTML for a menu link and submenu.
|
301 |
|
|
*
|
302 |
|
|
* Adaptivetheme overrides this to insert extra classes including a depth
|
303 |
|
|
* class and a menu id class. It can also wrap menu items in span elements.
|
304 |
|
|
*
|
305 |
|
|
* @param $vars
|
306 |
|
|
* An associative array containing:
|
307 |
|
|
* - element: Structured array data for a menu link.
|
308 |
|
|
*/
|
309 |
|
|
function adaptivetheme_menu_link(array $vars) {
|
310 |
|
|
global $theme_key;
|
311 |
|
|
$theme_name = $theme_key;
|
312 |
|
|
|
313 |
|
|
$element = $vars['element'];
|
314 |
|
|
$sub_menu = '';
|
315 |
|
|
|
316 |
|
|
if ($element['#below']) {
|
317 |
|
|
$sub_menu = drupal_render($element['#below']);
|
318 |
|
|
}
|
319 |
|
|
|
320 |
|
|
if (at_get_setting('extra_menu_classes', $theme_name) == 1 && !empty($element['#original_link'])) {
|
321 |
|
|
if (!empty($element['#original_link']['depth'])) {
|
322 |
|
|
$element['#attributes']['class'][] = 'menu-depth-' . $element['#original_link']['depth'];
|
323 |
|
|
}
|
324 |
|
|
if (!empty($element['#original_link']['mlid'])) {
|
325 |
|
|
$element['#attributes']['class'][] = 'menu-item-' . $element['#original_link']['mlid'];
|
326 |
|
|
}
|
327 |
|
|
}
|
328 |
|
|
|
329 |
|
|
if (at_get_setting('menu_item_span_elements', $theme_name) == 1 && !empty($element['#title'])) {
|
330 |
|
|
$element['#title'] = '<span>' . $element['#title'] . '</span>';
|
331 |
|
|
$element['#localized_options']['html'] = TRUE;
|
332 |
|
|
}
|
333 |
|
|
|
334 |
74f6bef0
|
Assos Assos
|
if (at_get_setting('unset_menu_titles', $theme_name) == 1 /* && !empty($element['#localized_options']['attributes']['title']) */) {
|
335 |
85ad3d82
|
Assos Assos
|
unset($element['#localized_options']['attributes']['title']);
|
336 |
|
|
}
|
337 |
|
|
|
338 |
74f6bef0
|
Assos Assos
|
// Possible feature to show menu descriptions in span elements
|
339 |
|
|
//if ($element['#original_link']['menu_name'] == "main-menu" && isset($element['#localized_options']['attributes']['title'])){
|
340 |
|
|
// $element['#title'] = '<span class="title">' . $element['#title'] . '</span>';
|
341 |
|
|
// $element['#title'] .= '<span class="description">' . $element['#localized_options']['attributes']['title'] . '</span>';
|
342 |
|
|
// $element['#localized_options']['html'] = TRUE;
|
343 |
|
|
//}
|
344 |
|
|
|
345 |
85ad3d82
|
Assos Assos
|
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
|
346 |
|
|
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>";
|
347 |
|
|
}
|
348 |
|
|
}
|
349 |
|
|
|
350 |
|
|
/**
|
351 |
|
|
* Returns HTML for a set of links.
|
352 |
|
|
*
|
353 |
|
|
* @param $vars
|
354 |
|
|
* An associative array containing:
|
355 |
|
|
* - links: An associative array of links to be themed. The key for each link
|
356 |
|
|
* is used as its CSS class. Each link should be itself an array, with the
|
357 |
|
|
* following elements:
|
358 |
|
|
* - title: The link text.
|
359 |
|
|
* - href: The link URL. If omitted, the 'title' is shown as a plain text
|
360 |
|
|
* item in the links list.
|
361 |
|
|
* - html: (optional) Whether or not 'title' is HTML. If set, the title
|
362 |
|
|
* will not be passed through check_plain().
|
363 |
|
|
* - attributes: (optional) Attributes for the anchor, or for the <span> tag
|
364 |
|
|
* used in its place if no 'href' is supplied. If element 'class' is
|
365 |
|
|
* included, it must be an array of one or more class names.
|
366 |
|
|
* If the 'href' element is supplied, the entire link array is passed to l()
|
367 |
|
|
* as its $options parameter.
|
368 |
|
|
* - attributes: A keyed array of attributes for the UL containing the
|
369 |
|
|
* list of links.
|
370 |
|
|
* - heading: (optional) A heading to precede the links. May be an associative
|
371 |
|
|
* array or a string. If it's an array, it can have the following elements:
|
372 |
|
|
* - text: The heading text.
|
373 |
|
|
* - level: The heading level (e.g. 'h2', 'h3').
|
374 |
|
|
* - class: (optional) An array of the CSS classes for the heading.
|
375 |
|
|
* When using a string it will be used as the text of the heading and the
|
376 |
|
|
* level will default to 'h2'. Headings should be used on navigation menus
|
377 |
|
|
* and any list of links that consistently appears on multiple pages. To
|
378 |
|
|
* make the heading invisible use the 'element-invisible' CSS class. Do not
|
379 |
|
|
* use 'display:none', which removes it from screen-readers and assistive
|
380 |
|
|
* technology. Headings allow screen-reader and keyboard only users to
|
381 |
|
|
* navigate to or skip the links. See
|
382 |
|
|
* http://juicystudio.com/article/screen-readers-display-none.php and
|
383 |
|
|
* http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.
|
384 |
|
|
*/
|
385 |
|
|
function adaptivetheme_links($vars) {
|
386 |
|
|
$links = $vars['links'];
|
387 |
|
|
$attributes = $vars['attributes'];
|
388 |
|
|
$heading = $vars['heading'];
|
389 |
|
|
global $language_url;
|
390 |
|
|
$output = '';
|
391 |
|
|
|
392 |
|
|
if (count($links) > 0) {
|
393 |
|
|
$output = '';
|
394 |
|
|
|
395 |
|
|
if (!empty($heading)) {
|
396 |
|
|
if (is_string($heading)) {
|
397 |
|
|
$heading = array(
|
398 |
|
|
'text' => $heading,
|
399 |
|
|
'level' => 'h2',
|
400 |
|
|
);
|
401 |
|
|
}
|
402 |
|
|
$output .= '<' . $heading['level'];
|
403 |
|
|
if (!empty($heading['class'])) {
|
404 |
|
|
$output .= drupal_attributes(array('class' => $heading['class']));
|
405 |
|
|
}
|
406 |
74f6bef0
|
Assos Assos
|
if (!empty($heading['id'])) {
|
407 |
|
|
$output .= drupal_attributes(array('id' => $heading['id']));
|
408 |
|
|
}
|
409 |
85ad3d82
|
Assos Assos
|
$output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>';
|
410 |
|
|
}
|
411 |
|
|
|
412 |
|
|
$output .= '<ul' . drupal_attributes($attributes) . '>';
|
413 |
|
|
$num_links = count($links);
|
414 |
|
|
$i = 1;
|
415 |
|
|
|
416 |
|
|
foreach ($links as $key => $link) {
|
417 |
74f6bef0
|
Assos Assos
|
|
418 |
|
|
// Extra menu classes
|
419 |
85ad3d82
|
Assos Assos
|
if (at_get_setting('extra_menu_classes')) {
|
420 |
|
|
$class = array($key);
|
421 |
|
|
if ($i == 1) {
|
422 |
|
|
$class[] = 'first';
|
423 |
|
|
}
|
424 |
|
|
if ($i == $num_links) {
|
425 |
|
|
$class[] = 'last';
|
426 |
|
|
}
|
427 |
|
|
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
|
428 |
|
|
&& (empty($link['language']) || $link['language']->language == $language_url->language)) {
|
429 |
|
|
$class[] = 'active';
|
430 |
|
|
}
|
431 |
|
|
$output .= '<li' . drupal_attributes(array('class' => $class)) . '>';
|
432 |
|
|
}
|
433 |
|
|
else {
|
434 |
|
|
$output .= '<li>';
|
435 |
|
|
}
|
436 |
74f6bef0
|
Assos Assos
|
|
437 |
85ad3d82
|
Assos Assos
|
if (isset($link['href'])) {
|
438 |
|
|
if (at_get_setting('menu_item_span_elements')) {
|
439 |
|
|
$link['title'] = '<span>' . $link['title'] . '</span>';
|
440 |
|
|
$link['html'] = TRUE;
|
441 |
|
|
}
|
442 |
|
|
$output .= l($link['title'], $link['href'], $link);
|
443 |
|
|
}
|
444 |
|
|
elseif (!empty($link['title'])) {
|
445 |
|
|
if (empty($link['html'])) {
|
446 |
|
|
$link['title'] = check_plain($link['title']);
|
447 |
|
|
}
|
448 |
|
|
$span_attributes = '';
|
449 |
|
|
if (isset($link['attributes'])) {
|
450 |
|
|
$span_attributes = drupal_attributes($link['attributes']);
|
451 |
|
|
}
|
452 |
|
|
$output .= '<span' . $span_attributes . '>' . $link['title'] . '</span>';
|
453 |
|
|
}
|
454 |
|
|
|
455 |
|
|
$i++;
|
456 |
|
|
$output .= "</li>";
|
457 |
|
|
}
|
458 |
|
|
|
459 |
|
|
$output .= '</ul>';
|
460 |
|
|
}
|
461 |
|
|
|
462 |
|
|
return $output;
|
463 |
|
|
}
|
464 |
|
|
|
465 |
|
|
/**
|
466 |
|
|
* Returns HTML for a field.
|
467 |
|
|
*
|
468 |
|
|
* Adaptivetheme overrides this in order to better support HTML5 by setting the
|
469 |
|
|
* wrapper as section or div element depending on whether a title is used or not.
|
470 |
|
|
* Fields have no title, instead it treats the field lable as if it were a title
|
471 |
|
|
* and wraps it in h2 elements.
|
472 |
|
|
*
|
473 |
|
|
* This is the default theme implementation to display the value of a field.
|
474 |
|
|
* Theme developers who are comfortable with overriding theme functions may do
|
475 |
|
|
* so in order to customize this markup. This function can be overridden with
|
476 |
|
|
* varying levels of specificity. For example, for a field named 'body'
|
477 |
|
|
* displayed on the 'article' content type, any of the following functions will
|
478 |
|
|
* override this default implementation. The first of these functions that
|
479 |
|
|
* exists is used:
|
480 |
|
|
* - THEMENAME_field__body__article()
|
481 |
|
|
* - THEMENAME_field__article()
|
482 |
|
|
* - THEMENAME_field__body()
|
483 |
|
|
* - THEMENAME_field()
|
484 |
|
|
*
|
485 |
|
|
* Theme developers who prefer to customize templates instead of overriding
|
486 |
|
|
* functions may copy the "field.tpl.php" from the "modules/field/theme" folder
|
487 |
|
|
* of the Drupal installation to somewhere within the theme's folder and
|
488 |
|
|
* customize it, just like customizing other Drupal templates such as
|
489 |
|
|
* page.tpl.php or node.tpl.php. However, it takes longer for the server to
|
490 |
|
|
* process templates than to call a function, so for websites with many fields
|
491 |
|
|
* displayed on a page, this can result in a noticeable slowdown of the website.
|
492 |
|
|
* For these websites, developers are discouraged from placing a field.tpl.php
|
493 |
|
|
* file into the theme's folder, but may customize templates for specific
|
494 |
|
|
* fields. For example, for a field named 'body' displayed on the 'article'
|
495 |
|
|
* content type, any of the following templates will override this default
|
496 |
|
|
* implementation. The first of these templates that exists is used:
|
497 |
|
|
* - field--body--article.tpl.php
|
498 |
|
|
* - field--article.tpl.php
|
499 |
|
|
* - field--body.tpl.php
|
500 |
|
|
* - field.tpl.php
|
501 |
|
|
* So, if the body field on the article content type needs customization, a
|
502 |
|
|
* field--body--article.tpl.php file can be added within the theme's folder.
|
503 |
|
|
* Because it's a template, it will result in slightly more time needed to
|
504 |
|
|
* display that field, but it will not impact other fields, and therefore,
|
505 |
|
|
* is unlikely to cause a noticeable change in website performance. A very rough
|
506 |
|
|
* guideline is that if a page is being displayed with more than 100 fields and
|
507 |
|
|
* they are all themed with a template instead of a function, it can add up to
|
508 |
|
|
* 5% to the time it takes to display that page. This is a guideline only and
|
509 |
|
|
* the exact performance impact depends on the server configuration and the
|
510 |
|
|
* details of the website.
|
511 |
|
|
*
|
512 |
|
|
* @param $vars
|
513 |
|
|
* An associative array containing:
|
514 |
|
|
* - label_hidden: A boolean indicating to show or hide the field label.
|
515 |
|
|
* - title_attributes: A string containing the attributes for the title.
|
516 |
|
|
* - label: The label for the field.
|
517 |
|
|
* - content_attributes: A string containing the attributes for the content's
|
518 |
|
|
* div.
|
519 |
|
|
* - items: An array of field items.
|
520 |
|
|
* - item_attributes: An array of attributes for each item.
|
521 |
|
|
* - classes: A string containing the classes for the wrapping div.
|
522 |
|
|
* - attributes: A string containing the attributes for the wrapping div.
|
523 |
|
|
*
|
524 |
|
|
* @see template_preprocess_field()
|
525 |
|
|
* @see template_process_field()
|
526 |
|
|
* @see field.tpl.php
|
527 |
|
|
*/
|
528 |
|
|
function adaptivetheme_field($vars) {
|
529 |
|
|
$output = '';
|
530 |
|
|
|
531 |
|
|
// Render the label, if it's not hidden.
|
532 |
|
|
if (!$vars['label_hidden']) {
|
533 |
|
|
$output .= '<h2 class="field-label"' . $vars['title_attributes'] . '>' . $vars['label'] . ': </h2>';
|
534 |
|
|
}
|
535 |
|
|
|
536 |
|
|
// Render the items.
|
537 |
|
|
$output .= '<div class="field-items"' . $vars['content_attributes'] . '>';
|
538 |
|
|
foreach ($vars['items'] as $delta => $item) {
|
539 |
|
|
$classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
|
540 |
|
|
$output .= '<div class="' . $classes . '"' . $vars['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>';
|
541 |
|
|
}
|
542 |
|
|
$output .= '</div>';
|
543 |
|
|
|
544 |
|
|
// Render the top-level wrapper element.
|
545 |
|
|
$tag = $vars['tag'];
|
546 |
|
|
$output = "<$tag class=\"" . $vars['classes'] . '"' . $vars['attributes'] . '>' . $output . "</$tag>";
|
547 |
|
|
|
548 |
|
|
return $output;
|
549 |
|
|
}
|
550 |
|
|
|
551 |
|
|
/**
|
552 |
|
|
* Returns HTML for a taxonomy field.
|
553 |
|
|
*
|
554 |
|
|
* Output taxonomy term fields as unordered lists.
|
555 |
|
|
*/
|
556 |
|
|
function adaptivetheme_field__taxonomy_term_reference($vars) {
|
557 |
|
|
$output = '';
|
558 |
|
|
|
559 |
|
|
// Render the label, if it's not hidden.
|
560 |
|
|
if (!$vars['label_hidden']) {
|
561 |
|
|
$output .= '<h2 class="field-label"' . $vars['title_attributes'] . '>' . $vars['label'] . ': </h2>';
|
562 |
|
|
}
|
563 |
|
|
|
564 |
|
|
// Render the items.
|
565 |
|
|
$output .= '<ul class="field-items"' . $vars['content_attributes'] . '>';
|
566 |
|
|
foreach ($vars['items'] as $delta => $item) {
|
567 |
|
|
$classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
|
568 |
|
|
$output .= '<li class="' . $classes . '"' . $vars['item_attributes'][$delta] . '>' . drupal_render($item) . '</li>';
|
569 |
|
|
}
|
570 |
|
|
|
571 |
|
|
$output .= '</ul>';
|
572 |
|
|
|
573 |
|
|
// Render the top-level wrapper element.
|
574 |
|
|
$tag = $vars['tag'];
|
575 |
|
|
$output = "<$tag class=\"" . $vars['classes'] . '"' . $vars['attributes'] . '>' . $output . "</$tag>";
|
576 |
|
|
|
577 |
|
|
return $output;
|
578 |
|
|
}
|
579 |
|
|
|
580 |
|
|
/**
|
581 |
|
|
* Returns HTML for an image field.
|
582 |
|
|
*
|
583 |
|
|
* Output image fields as figure with figcaption for captioning.
|
584 |
|
|
*/
|
585 |
|
|
function adaptivetheme_field__image($vars) {
|
586 |
|
|
global $theme_key;
|
587 |
|
|
$theme_name = $theme_key;
|
588 |
|
|
|
589 |
|
|
// Check if image settings are enabled
|
590 |
|
|
$image_settings_enabled = at_get_setting('enable_image_settings', $theme_name) === 1 ? TRUE : FALSE;
|
591 |
|
|
|
592 |
|
|
// Check if captions are enabled for full and/or teaser view modes
|
593 |
|
|
if ($image_settings_enabled == TRUE) {
|
594 |
|
|
$caption_full = at_get_setting('image_caption_full', $theme_name) === 1 ? TRUE : FALSE;
|
595 |
|
|
$caption_teaser = at_get_setting('image_caption_teaser', $theme_name) === 1 ? TRUE : FALSE;
|
596 |
|
|
}
|
597 |
|
|
|
598 |
|
|
$output = '';
|
599 |
|
|
|
600 |
|
|
// Render the label, if it's not hidden.
|
601 |
|
|
if (!$vars['label_hidden']) {
|
602 |
|
|
$output .= '<h2 class="field-label"' . $vars['title_attributes'] . '>' . $vars['label'] . ': </h2>';
|
603 |
|
|
}
|
604 |
|
|
|
605 |
|
|
// Render the items.
|
606 |
|
|
$output .= '<div class="field-items"' . $vars['content_attributes'] . '>';
|
607 |
|
|
|
608 |
|
|
foreach ($vars['items'] as $delta => $item) {
|
609 |
|
|
|
610 |
|
|
$classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
|
611 |
|
|
$output .= '<figure class="clearfix ' . $classes . '"' . $vars['item_attributes'][$delta] .'>';
|
612 |
|
|
$output .= drupal_render($item);
|
613 |
|
|
|
614 |
|
|
// Captions
|
615 |
|
|
if (isset($item['#item']['title']) && !empty($item['#item']['title']) && $image_settings_enabled == TRUE) {
|
616 |
|
|
|
617 |
|
|
// Ouch this is ugly, please tell me how to get the actual width of the image.
|
618 |
|
|
// image_style_load($item['#image_style']); will return the image style dimensions,
|
619 |
|
|
// but not the actual image width, which can be different, say when images
|
620 |
|
|
// scale, but I cannot decipher where these dimensions come from when
|
621 |
|
|
// the item is rendered.
|
622 |
|
|
preg_match('/< *img[^>]*width *= *["\']?([^"\']*)/i', $item['#children'], $matches);
|
623 |
|
|
$width = isset($matches[1]) ? $matches[1] . 'px' : 'auto';
|
624 |
|
|
$styles = 'style="width:' . $width . ';"';
|
625 |
|
|
|
626 |
|
|
if ($vars['field_view_mode'] == 'full') {
|
627 |
|
|
if ($caption_full == TRUE) {
|
628 |
|
|
$output .= '<figcaption class="caption full-caption"' . $styles .'>' . $item['#item']['title'] . '</figcaption>';
|
629 |
|
|
}
|
630 |
|
|
}
|
631 |
|
|
if ($vars['field_view_mode'] == 'teaser') {
|
632 |
|
|
if ($caption_teaser == TRUE) {
|
633 |
|
|
$output .= '<figcaption class="caption teaser-caption"' . $styles .'>' . $item['#item']['title'] . '</figcaption>';
|
634 |
|
|
}
|
635 |
|
|
}
|
636 |
|
|
}
|
637 |
|
|
|
638 |
|
|
$output .= '</figure>';
|
639 |
|
|
}
|
640 |
|
|
|
641 |
|
|
$output .= '</div>';
|
642 |
|
|
|
643 |
|
|
// Render the top-level wrapper element.
|
644 |
|
|
$tag = $vars['tag'];
|
645 |
|
|
$output = "<$tag class=\"" . $vars['classes'] . '"' . $vars['attributes'] . '>' . $output . "</$tag>";
|
646 |
|
|
|
647 |
|
|
return $output;
|
648 |
|
|
}
|
649 |
74f6bef0
|
Assos Assos
|
|
650 |
|
|
|
651 |
|
|
/**
|
652 |
|
|
* Table no_striping boilerplate.
|
653 |
|
|
*/
|
654 |
|
|
/*
|
655 |
|
|
function adaptivetheme_preprocess_table(&$variables) {
|
656 |
|
|
$rows = $variables['rows'];
|
657 |
|
|
foreach ($rows as $number => $row) {
|
658 |
|
|
$variables['rows'][$number]['no_striping'] = TRUE;
|
659 |
|
|
}
|
660 |
|
|
}
|
661 |
|
|
*/ |