Projet

Général

Profil

Paste
Télécharger (24,5 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / zen / template.php @ 87dbc3bf

1
<?php
2
/**
3
 * @file
4
 * Contains functions to alter Drupal's markup for the Zen theme.
5
 *
6
 * IMPORTANT WARNING: DO NOT MODIFY THIS FILE.
7
 *
8
 * The base Zen theme is designed to be easily extended by its sub-themes. You
9
 * shouldn't modify this or any of the CSS or PHP files in the root zen/ folder.
10
 * See the online documentation for more information:
11
 *   https://drupal.org/documentation/theme/zen
12
 */
13

    
14
// Auto-rebuild the theme registry during theme development.
15
if (theme_get_setting('zen_rebuild_registry') && !defined('MAINTENANCE_MODE')) {
16
  // Rebuild .info data.
17
  system_rebuild_theme_data();
18
  // Rebuild theme registry.
19
  drupal_theme_rebuild();
20
}
21

    
22

    
23
/**
24
 * Implements HOOK_theme().
25
 */
26
function zen_theme(&$existing, $type, $theme, $path) {
27
  include_once './' . drupal_get_path('theme', 'zen') . '/zen-internals/template.theme-registry.inc';
28
  return _zen_theme($existing, $type, $theme, $path);
29
}
30

    
31
/**
32
 * Return a themed breadcrumb trail.
33
 *
34
 * @param $variables
35
 *   - title: An optional string to be used as a navigational heading to give
36
 *     context for breadcrumb links to screen-reader users.
37
 *   - title_attributes_array: Array of HTML attributes for the title. It is
38
 *     flattened into a string within the theme function.
39
 *   - breadcrumb: An array containing the breadcrumb links.
40
 * @return
41
 *   A string containing the breadcrumb output.
42
 */
43
function zen_breadcrumb($variables) {
44
  $breadcrumb = $variables['breadcrumb'];
45
  $output = '';
46

    
47
  // Determine if we are to display the breadcrumb.
48
  $show_breadcrumb = theme_get_setting('zen_breadcrumb');
49
  if ($show_breadcrumb == 'yes' || $show_breadcrumb == 'admin' && arg(0) == 'admin') {
50

    
51
    // Optionally get rid of the homepage link.
52
    $show_breadcrumb_home = theme_get_setting('zen_breadcrumb_home');
53
    if (!$show_breadcrumb_home) {
54
      array_shift($breadcrumb);
55
    }
56

    
57
    // Return the breadcrumb with separators.
58
    if (!empty($breadcrumb)) {
59
      $breadcrumb_separator = filter_xss_admin(theme_get_setting('zen_breadcrumb_separator'));
60
      $trailing_separator = $title = '';
61
      if (theme_get_setting('zen_breadcrumb_title')) {
62
        $item = menu_get_item();
63
        if (!empty($item['tab_parent'])) {
64
          // If we are on a non-default tab, use the tab's title.
65
          $breadcrumb[] = check_plain($item['title']);
66
        }
67
        else {
68
          $breadcrumb[] = drupal_get_title();
69
        }
70
      }
71
      elseif (theme_get_setting('zen_breadcrumb_trailing')) {
72
        $trailing_separator = $breadcrumb_separator;
73
      }
74

    
75
      // Provide a navigational heading to give context for breadcrumb links to
76
      // screen-reader users.
77
      if (empty($variables['title'])) {
78
        $variables['title'] = t('You are here');
79
      }
80
      // Unless overridden by a preprocess function, make the heading invisible.
81
      if (!isset($variables['title_attributes_array']['class'])) {
82
        $variables['title_attributes_array']['class'][] = 'element-invisible';
83
      }
84

    
85
      // Build the breadcrumb trail.
86
      $output = '<nav class="breadcrumb" role="navigation">';
87
      $output .= '<h2' . drupal_attributes($variables['title_attributes_array']) . '>' . $variables['title'] . '</h2>';
88
      $output .= '<ol><li>' . implode($breadcrumb_separator . '</li><li>', $breadcrumb) . $trailing_separator . '</li></ol>';
89
      $output .= '</nav>';
90
    }
91
  }
92

    
93
  return $output;
94
}
95

    
96
/**
97
 * Override or insert variables into the html template.
98
 *
99
 * @param $variables
100
 *   An array of variables to pass to the theme template.
101
 * @param $hook
102
 *   The name of the template being rendered. This is usually "html", but can
103
 *   also be "maintenance_page" since zen_preprocess_maintenance_page() calls
104
 *   this function to have consistent variables.
105
 */
106
function zen_preprocess_html(&$variables, $hook) {
107
  // Add variables and paths needed for HTML5 and responsive support.
108
  $variables['base_path'] = base_path();
109
  $variables['path_to_zen'] = drupal_get_path('theme', 'zen');
110
  // Get settings for HTML5 and responsive support. array_filter() removes
111
  // items from the array that have been disabled.
112
  $html5_respond_meta = array_filter((array) theme_get_setting('zen_html5_respond_meta'));
113
  $variables['add_respond_js']          = in_array('respond', $html5_respond_meta);
114
  $variables['add_html5_shim']          = in_array('html5', $html5_respond_meta);
115
  $variables['default_mobile_metatags'] = in_array('meta', $html5_respond_meta);
116

    
117
  // If the user is silly and enables Zen as the theme, add some styles.
118
  if ($GLOBALS['theme'] == 'zen') {
119
    include_once './' . $variables['path_to_zen'] . '/zen-internals/template.zen.inc';
120
    _zen_preprocess_html($variables, $hook);
121
  }
122

    
123
  // Attributes for html element.
124
  $variables['html_attributes_array'] = array(
125
    'lang' => $variables['language']->language,
126
    'dir' => $variables['language']->dir,
127
  );
128

    
129
  // Send X-UA-Compatible HTTP header to force IE to use the most recent
130
  // rendering engine or use Chrome's frame rendering engine if available.
131
  // This also prevents the IE compatibility mode button to appear when using
132
  // conditional classes on the html tag.
133
  if (is_null(drupal_get_http_header('X-UA-Compatible'))) {
134
    drupal_add_http_header('X-UA-Compatible', 'IE=edge,chrome=1');
135
  }
136

    
137
  $variables['skip_link_anchor'] = check_plain(theme_get_setting('zen_skip_link_anchor'));
138
  $variables['skip_link_text']   = check_plain(theme_get_setting('zen_skip_link_text'));
139

    
140
  // Return early, so the maintenance page does not call any of the code below.
141
  if ($hook != 'html') {
142
    return;
143
  }
144

    
145
  // Serialize RDF Namespaces into an RDFa 1.1 prefix attribute.
146
  if ($variables['rdf_namespaces']) {
147
    $prefixes = array();
148
    foreach (explode("\n  ", ltrim($variables['rdf_namespaces'])) as $namespace) {
149
      // Remove xlmns: and ending quote and fix prefix formatting.
150
      $prefixes[] = str_replace('="', ': ', substr($namespace, 6, -1));
151
    }
152
    $variables['rdf_namespaces'] = ' prefix="' . implode(' ', $prefixes) . '"';
153
  }
154

    
155
  // Classes for body element. Allows advanced theming based on context
156
  // (home page, node of certain type, etc.)
157
  if (!$variables['is_front']) {
158
    // Add unique class for each page.
159
    $path = drupal_get_path_alias($_GET['q']);
160
    // Add unique class for each website section.
161
    list($section, ) = explode('/', $path, 2);
162
    $arg = explode('/', $_GET['q']);
163
    if ($arg[0] == 'node' && isset($arg[1])) {
164
      if ($arg[1] == 'add') {
165
        $section = 'node-add';
166
      }
167
      elseif (isset($arg[2]) && is_numeric($arg[1]) && ($arg[2] == 'edit' || $arg[2] == 'delete')) {
168
        $section = 'node-' . $arg[2];
169
      }
170
    }
171
    $variables['classes_array'][] = drupal_html_class('section-' . $section);
172
  }
173
  if (theme_get_setting('zen_wireframes')) {
174
    $variables['classes_array'][] = 'with-wireframes'; // Optionally add the wireframes style.
175
  }
176
  // Store the menu item since it has some useful information.
177
  $variables['menu_item'] = menu_get_item();
178
  if ($variables['menu_item']) {
179
    switch ($variables['menu_item']['page_callback']) {
180
      case 'views_page':
181
        // Is this a Views page?
182
        $variables['classes_array'][] = 'page-views';
183
        break;
184
      case 'page_manager_blog':
185
      case 'page_manager_blog_user':
186
      case 'page_manager_contact_site':
187
      case 'page_manager_contact_user':
188
      case 'page_manager_node_add':
189
      case 'page_manager_node_edit':
190
      case 'page_manager_node_view_page':
191
      case 'page_manager_page_execute':
192
      case 'page_manager_poll':
193
      case 'page_manager_search_page':
194
      case 'page_manager_term_view_page':
195
      case 'page_manager_user_edit_page':
196
      case 'page_manager_user_view_page':
197
        // Is this a Panels page?
198
        $variables['classes_array'][] = 'page-panels';
199
        break;
200
    }
201
  }
202
}
203

    
204
/**
205
 * Override or insert variables into the html templates.
206
 *
207
 * @param $variables
208
 *   An array of variables to pass to the theme template.
209
 * @param $hook
210
 *   The name of the template being rendered ("html" in this case.)
211
 */
212
function zen_process_html(&$variables, $hook) {
213
  // Flatten out html_attributes.
214
  $variables['html_attributes'] = drupal_attributes($variables['html_attributes_array']);
215
}
216

    
217
/**
218
 * Override or insert variables in the html_tag theme function.
219
 */
220
function zen_process_html_tag(&$variables) {
221
  $tag = &$variables['element'];
222

    
223
  if ($tag['#tag'] == 'style' || $tag['#tag'] == 'script') {
224
    // Remove redundant type attribute and CDATA comments.
225
    unset($tag['#attributes']['type'], $tag['#value_prefix'], $tag['#value_suffix']);
226

    
227
    // Remove media="all" but leave others unaffected.
228
    if (isset($tag['#attributes']['media']) && $tag['#attributes']['media'] === 'all') {
229
      unset($tag['#attributes']['media']);
230
    }
231
  }
232
}
233

    
234
/**
235
 * Implement hook_html_head_alter().
236
 */
237
function zen_html_head_alter(&$head) {
238
  // Simplify the meta tag for character encoding.
239
  if (isset($head['system_meta_content_type']['#attributes']['content'])) {
240
    $head['system_meta_content_type']['#attributes'] = array('charset' => str_replace('text/html; charset=', '', $head['system_meta_content_type']['#attributes']['content']));
241
  }
242
}
243

    
244
/**
245
 * Override or insert variables into the page template.
246
 *
247
 * @param $variables
248
 *   An array of variables to pass to the theme template.
249
 * @param $hook
250
 *   The name of the template being rendered ("page" in this case.)
251
 */
252
function zen_preprocess_page(&$variables, $hook) {
253
  // Find the title of the menu used by the secondary links.
254
  $secondary_links = variable_get('menu_secondary_links_source', 'user-menu');
255
  if ($secondary_links) {
256
    $menus = function_exists('menu_get_menus') ? menu_get_menus() : menu_list_system_menus();
257
    $variables['secondary_menu_heading'] = $menus[$secondary_links];
258
  }
259
  else {
260
    $variables['secondary_menu_heading'] = '';
261
  }
262
}
263

    
264
/**
265
 * Override or insert variables into the maintenance page template.
266
 *
267
 * @param $variables
268
 *   An array of variables to pass to the theme template.
269
 * @param $hook
270
 *   The name of the template being rendered ("maintenance_page" in this case.)
271
 */
272
function zen_preprocess_maintenance_page(&$variables, $hook) {
273
  zen_preprocess_html($variables, $hook);
274
  // There's nothing maintenance-related in zen_preprocess_page(). Yet.
275
  //zen_preprocess_page($variables, $hook);
276
}
277

    
278
/**
279
 * Override or insert variables into the maintenance page template.
280
 *
281
 * @param $variables
282
 *   An array of variables to pass to the theme template.
283
 * @param $hook
284
 *   The name of the template being rendered ("maintenance_page" in this case.)
285
 */
286
function zen_process_maintenance_page(&$variables, $hook) {
287
  zen_process_html($variables, $hook);
288
  // Ensure default regions get a variable. Theme authors often forget to remove
289
  // a deleted region's variable in maintenance-page.tpl.
290
  foreach (array('header', 'navigation', 'highlighted', 'help', 'content', 'sidebar_first', 'sidebar_second', 'footer', 'bottom') as $region) {
291
    if (!isset($variables[$region])) {
292
      $variables[$region] = '';
293
    }
294
  }
295
}
296

    
297
/**
298
 * Override or insert variables into the node templates.
299
 *
300
 * @param $variables
301
 *   An array of variables to pass to the theme template.
302
 * @param $hook
303
 *   The name of the template being rendered ("node" in this case.)
304
 */
305
function zen_preprocess_node(&$variables, $hook) {
306
  // Add $unpublished variable.
307
  $variables['unpublished'] = (!$variables['status']) ? TRUE : FALSE;
308

    
309
  // Add pubdate to submitted variable.
310
  $variables['pubdate'] = '<time pubdate datetime="' . format_date($variables['node']->created, 'custom', 'c') . '">' . $variables['date'] . '</time>';
311
  if ($variables['display_submitted']) {
312
    $variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['pubdate']));
313
  }
314

    
315
  // Add a class for the view mode.
316
  if (!$variables['teaser']) {
317
    $variables['classes_array'][] = 'view-mode-' . $variables['view_mode'];
318
  }
319

    
320
  // Add a class to show node is authored by current user.
321
  if ($variables['uid'] && $variables['uid'] == $GLOBALS['user']->uid) {
322
    $variables['classes_array'][] = 'node-by-viewer';
323
  }
324

    
325
  $variables['title_attributes_array']['class'][] = 'node__title';
326
  $variables['title_attributes_array']['class'][] = 'node-title';
327
}
328

    
329
/**
330
 * Override or insert variables into the comment templates.
331
 *
332
 * @param $variables
333
 *   An array of variables to pass to the theme template.
334
 * @param $hook
335
 *   The name of the template being rendered ("comment" in this case.)
336
 */
337
function zen_preprocess_comment(&$variables, $hook) {
338
  // If comment subjects are disabled, don't display them.
339
  if (variable_get('comment_subject_field_' . $variables['node']->type, 1) == 0) {
340
    $variables['title'] = '';
341
  }
342

    
343
  // Add pubdate to submitted variable.
344
  $variables['pubdate'] = '<time pubdate datetime="' . format_date($variables['comment']->created, 'custom', 'c') . '">' . $variables['created'] . '</time>';
345
  $variables['submitted'] = t('!username replied on !datetime', array('!username' => $variables['author'], '!datetime' => $variables['pubdate']));
346

    
347
  // Zebra striping.
348
  if ($variables['id'] == 1) {
349
    $variables['classes_array'][] = 'first';
350
  }
351
  if ($variables['id'] == $variables['node']->comment_count) {
352
    $variables['classes_array'][] = 'last';
353
  }
354
  $variables['classes_array'][] = $variables['zebra'];
355

    
356
  $variables['title_attributes_array']['class'][] = 'comment__title';
357
  $variables['title_attributes_array']['class'][] = 'comment-title';
358
}
359

    
360
/**
361
 * Preprocess variables for region.tpl.php
362
 *
363
 * @param $variables
364
 *   An array of variables to pass to the theme template.
365
 * @param $hook
366
 *   The name of the template being rendered ("region" in this case.)
367
 */
368
function zen_preprocess_region(&$variables, $hook) {
369
  // Sidebar regions get some extra classes and a common template suggestion.
370
  if (strpos($variables['region'], 'sidebar_') === 0) {
371
    $variables['classes_array'][] = 'column';
372
    $variables['classes_array'][] = 'sidebar';
373
    // Allow a region-specific template to override Zen's region--sidebar.
374
    array_unshift($variables['theme_hook_suggestions'], 'region__sidebar');
375
  }
376
  // Use a template with no wrapper for the content region.
377
  elseif ($variables['region'] == 'content') {
378
    // Allow a region-specific template to override Zen's region--no-wrapper.
379
    array_unshift($variables['theme_hook_suggestions'], 'region__no_wrapper');
380
  }
381
  // Add a SMACSS-style class for header region.
382
  elseif ($variables['region'] == 'header') {
383
    array_unshift($variables['classes_array'], 'header__region');
384
  }
385
}
386

    
387
/**
388
 * Override or insert variables into the block templates.
389
 *
390
 * @param $variables
391
 *   An array of variables to pass to the theme template.
392
 * @param $hook
393
 *   The name of the template being rendered ("block" in this case.)
394
 */
395
function zen_preprocess_block(&$variables, $hook) {
396
  // Use a template with no wrapper for the page's main content.
397
  if ($variables['block_html_id'] == 'block-system-main') {
398
    $variables['theme_hook_suggestions'][] = 'block__no_wrapper';
399
  }
400

    
401
  // Classes describing the position of the block within the region.
402
  if ($variables['block_id'] == 1) {
403
    $variables['classes_array'][] = 'first';
404
  }
405
  // The last_in_region property is set in zen_page_alter().
406
  if (isset($variables['block']->last_in_region)) {
407
    $variables['classes_array'][] = 'last';
408
  }
409
  $variables['classes_array'][] = $variables['block_zebra'];
410

    
411
  $variables['title_attributes_array']['class'][] = 'block__title';
412
  $variables['title_attributes_array']['class'][] = 'block-title';
413

    
414
  // Add Aria Roles via attributes.
415
  switch ($variables['block']->module) {
416
    case 'system':
417
      switch ($variables['block']->delta) {
418
        case 'main':
419
          // Note: the "main" role goes in the page.tpl, not here.
420
          break;
421
        case 'help':
422
        case 'powered-by':
423
          $variables['attributes_array']['role'] = 'complementary';
424
          break;
425
        default:
426
          // Any other "system" block is a menu block.
427
          $variables['attributes_array']['role'] = 'navigation';
428
          break;
429
      }
430
      break;
431
    case 'menu':
432
    case 'menu_block':
433
    case 'blog':
434
    case 'book':
435
    case 'comment':
436
    case 'forum':
437
    case 'shortcut':
438
    case 'statistics':
439
      $variables['attributes_array']['role'] = 'navigation';
440
      break;
441
    case 'search':
442
      $variables['attributes_array']['role'] = 'search';
443
      break;
444
    case 'help':
445
    case 'aggregator':
446
    case 'locale':
447
    case 'poll':
448
    case 'profile':
449
      $variables['attributes_array']['role'] = 'complementary';
450
      break;
451
    case 'node':
452
      switch ($variables['block']->delta) {
453
        case 'syndicate':
454
          $variables['attributes_array']['role'] = 'complementary';
455
          break;
456
        case 'recent':
457
          $variables['attributes_array']['role'] = 'navigation';
458
          break;
459
      }
460
      break;
461
    case 'user':
462
      switch ($variables['block']->delta) {
463
        case 'login':
464
          $variables['attributes_array']['role'] = 'form';
465
          break;
466
        case 'new':
467
        case 'online':
468
          $variables['attributes_array']['role'] = 'complementary';
469
          break;
470
      }
471
      break;
472
  }
473
}
474

    
475
/**
476
 * Override or insert variables into the block templates.
477
 *
478
 * @param $variables
479
 *   An array of variables to pass to the theme template.
480
 * @param $hook
481
 *   The name of the template being rendered ("block" in this case.)
482
 */
483
function zen_process_block(&$variables, $hook) {
484
  // Drupal 7 should use a $title variable instead of $block->subject.
485
  $variables['title'] = isset($variables['block']->subject) ? $variables['block']->subject : '';
486
}
487

    
488
/**
489
 * Implements hook_page_alter().
490
 *
491
 * Look for the last block in the region. This is impossible to determine from
492
 * within a preprocess_block function.
493
 *
494
 * @param $page
495
 *   Nested array of renderable elements that make up the page.
496
 */
497
function zen_page_alter(&$page) {
498
  // Look in each visible region for blocks.
499
  foreach (system_region_list($GLOBALS['theme'], REGIONS_VISIBLE) as $region => $name) {
500
    if (!empty($page[$region])) {
501
      // Find the last block in the region.
502
      $blocks = array_reverse(element_children($page[$region]));
503
      while ($blocks && !isset($page[$region][$blocks[0]]['#block'])) {
504
        array_shift($blocks);
505
      }
506
      if ($blocks) {
507
        $page[$region][$blocks[0]]['#block']->last_in_region = TRUE;
508
      }
509
    }
510
  }
511
}
512

    
513
/**
514
 * Implements hook_form_BASE_FORM_ID_alter().
515
 *
516
 * Prevent user-facing field styling from screwing up node edit forms by
517
 * renaming the classes on the node edit form's field wrappers.
518
 */
519
function zen_form_node_form_alter(&$form, &$form_state, $form_id) {
520
  // Remove if #1245218 is backported to D7 core.
521
  foreach (array_keys($form) as $item) {
522
    if (strpos($item, 'field_') === 0) {
523
      if (!empty($form[$item]['#attributes']['class'])) {
524
        foreach ($form[$item]['#attributes']['class'] as &$class) {
525
          // Core bug: the field-type-text-with-summary class is used as a JS hook.
526
          if ($class != 'field-type-text-with-summary' && strpos($class, 'field-type-') === 0 || strpos($class, 'field-name-') === 0) {
527
            // Make the class different from that used in theme_field().
528
            $class = 'form-' . $class;
529
          }
530
        }
531
      }
532
    }
533
  }
534
}
535

    
536
/**
537
 * Returns HTML for primary and secondary local tasks.
538
 *
539
 * @ingroup themeable
540
 */
541
function zen_menu_local_tasks(&$variables) {
542
  $output = '';
543

    
544
  // Add theme hook suggestions for tab type.
545
  foreach (array('primary', 'secondary') as $type) {
546
    if (!empty($variables[$type])) {
547
      foreach (array_keys($variables[$type]) as $key) {
548
        if (isset($variables[$type][$key]['#theme']) && ($variables[$type][$key]['#theme'] == 'menu_local_task' || is_array($variables[$type][$key]['#theme']) && in_array('menu_local_task', $variables[$type][$key]['#theme']))) {
549
          $variables[$type][$key]['#theme'] = array('menu_local_task__' . $type, 'menu_local_task');
550
        }
551
      }
552
    }
553
  }
554

    
555
  if (!empty($variables['primary'])) {
556
    $variables['primary']['#prefix'] = '<h2 class="element-invisible">' . t('Primary tabs') . '</h2>';
557
    $variables['primary']['#prefix'] .= '<ul class="tabs-primary tabs primary">';
558
    $variables['primary']['#suffix'] = '</ul>';
559
    $output .= drupal_render($variables['primary']);
560
  }
561
  if (!empty($variables['secondary'])) {
562
    $variables['secondary']['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2>';
563
    $variables['secondary']['#prefix'] .= '<ul class="tabs-secondary tabs secondary">';
564
    $variables['secondary']['#suffix'] = '</ul>';
565
    $output .= drupal_render($variables['secondary']);
566
  }
567

    
568
  return $output;
569
}
570

    
571
/**
572
 * Returns HTML for a single local task link.
573
 *
574
 * @ingroup themeable
575
 */
576
function zen_menu_local_task($variables) {
577
  $type = $class = FALSE;
578

    
579
  $link = $variables['element']['#link'];
580
  $link_text = $link['title'];
581

    
582
  // Check for tab type set in zen_menu_local_tasks().
583
  if (is_array($variables['element']['#theme'])) {
584
    $type = in_array('menu_local_task__secondary', $variables['element']['#theme']) ? 'tabs-secondary' : 'tabs-primary';
585
  }
586

    
587
  // Add SMACSS-style class names.
588
  if ($type) {
589
    $link['localized_options']['attributes']['class'][] = $type . '__tab-link';
590
    $class = $type . '__tab';
591
  }
592

    
593
  if (!empty($variables['element']['#active'])) {
594
    // Add text to indicate active tab for non-visual users.
595
    $active = ' <span class="element-invisible">' . t('(active tab)') . '</span>';
596

    
597
    // If the link does not contain HTML already, check_plain() it now.
598
    // After we set 'html'=TRUE the link will not be sanitized by l().
599
    if (empty($link['localized_options']['html'])) {
600
      $link['title'] = check_plain($link['title']);
601
    }
602
    $link['localized_options']['html'] = TRUE;
603
    $link_text = t('!local-task-title!active', array('!local-task-title' => $link['title'], '!active' => $active));
604

    
605
    if (!$type) {
606
      $class = 'active';
607
    }
608
    else {
609
      $link['localized_options']['attributes']['class'][] = 'is-active';
610
      $class .= ' is-active';
611
    }
612
  }
613

    
614
  return '<li' . ($class ? ' class="' . $class . '"' : '') . '>' . l($link_text, $link['href'], $link['localized_options']) . "</li>\n";
615
}
616

    
617
/**
618
 * Implements hook_preprocess_menu_link().
619
 */
620
function zen_preprocess_menu_link(&$variables, $hook) {
621
  foreach ($variables['element']['#attributes']['class'] as $key => $class) {
622
    switch ($class) {
623
      // Menu module classes.
624
      case 'expanded':
625
      case 'collapsed':
626
      case 'leaf':
627
      case 'active':
628
      // Menu block module classes.
629
      case 'active-trail':
630
        array_unshift($variables['element']['#attributes']['class'], 'is-' . $class);
631
        break;
632
      case 'has-children':
633
        array_unshift($variables['element']['#attributes']['class'], 'is-parent');
634
        break;
635
    }
636
  }
637
  array_unshift($variables['element']['#attributes']['class'], 'menu__item');
638
  if (empty($variables['element']['#localized_options']['attributes']['class'])) {
639
    $variables['element']['#localized_options']['attributes']['class'] = array();
640
  }
641
  else {
642
    foreach ($variables['element']['#localized_options']['attributes']['class'] as $key => $class) {
643
      switch ($class) {
644
        case 'active':
645
        case 'active-trail':
646
          array_unshift($variables['element']['#localized_options']['attributes']['class'], 'is-' . $class);
647
          break;
648
      }
649
    }
650
  }
651
  array_unshift($variables['element']['#localized_options']['attributes']['class'], 'menu__link');
652
}
653

    
654
/**
655
 * Returns HTML for status and/or error messages, grouped by type.
656
 */
657
function zen_status_messages($variables) {
658
  $display = $variables['display'];
659
  $output = '';
660

    
661
  $status_heading = array(
662
    'status' => t('Status message'),
663
    'error' => t('Error message'),
664
    'warning' => t('Warning message'),
665
  );
666
  foreach (drupal_get_messages($display) as $type => $messages) {
667
    $output .= "<div class=\"messages--$type messages $type\">\n";
668
    if (!empty($status_heading[$type])) {
669
      $output .= '<h2 class="element-invisible">' . $status_heading[$type] . "</h2>\n";
670
    }
671
    if (count($messages) > 1) {
672
      $output .= " <ul class=\"messages__list\">\n";
673
      foreach ($messages as $message) {
674
        $output .= '  <li class=\"messages__item\">' . $message . "</li>\n";
675
      }
676
      $output .= " </ul>\n";
677
    }
678
    else {
679
      $output .= $messages[0];
680
    }
681
    $output .= "</div>\n";
682
  }
683
  return $output;
684
}
685

    
686
/**
687
 * Returns HTML for a marker for new or updated content.
688
 */
689
function zen_mark($variables) {
690
  $type = $variables['type'];
691

    
692
  if ($type == MARK_NEW) {
693
    return ' <mark class="new">' . t('new') . '</mark>';
694
  }
695
  elseif ($type == MARK_UPDATED) {
696
    return ' <mark class="updated">' . t('updated') . '</mark>';
697
  }
698
}
699

    
700
/**
701
 * Alters the default Panels render callback so it removes the panel separator.
702
 */
703
function zen_panels_default_style_render_region($variables) {
704
  return implode('', $variables['panes']);
705
}