Issues (1839)

drupal/sites/all/themes/zen/template.php (3 issues)

1
<?php
2
/**
3
 * @file
4
 * Contains theme override functions and preprocess functions 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
 *   http://drupal.org/node/193318
12
 */
13
14
// Auto-rebuild the theme registry during theme development.
15
if (theme_get_setting('zen_rebuild_registry')) {
16
  drupal_rebuild_theme_registry();
17
}
18
19
20
/**
21
 * Implements HOOK_theme().
22
 */
23
function zen_theme(&$existing, $type, $theme, $path) {
24
  // When #341140 is fixed, replace _zen_path() with drupal_get_path().
25
  include_once './' . _zen_path() . '/zen-internals/template.theme-registry.inc';
26
  return _zen_theme($existing, $type, $theme, $path);
27
}
28
29
/**
30
 * Return a themed breadcrumb trail.
31
 *
32
 * @param $breadcrumb
33
 *   An array containing the breadcrumb links.
34
 * @return
35
 *   A string containing the breadcrumb output.
36
 */
37
function zen_breadcrumb($breadcrumb) {
38
  // Determine if we are to display the breadcrumb.
39
  $show_breadcrumb = theme_get_setting('zen_breadcrumb');
40
  if ($show_breadcrumb == 'yes' || $show_breadcrumb == 'admin' && arg(0) == 'admin') {
41
42
    // Optionally get rid of the homepage link.
43
    $show_breadcrumb_home = theme_get_setting('zen_breadcrumb_home');
44
    if (!$show_breadcrumb_home) {
45
      array_shift($breadcrumb);
46
    }
47
48
    // Return the breadcrumb with separators.
49
    if (!empty($breadcrumb)) {
50
      $breadcrumb_separator = theme_get_setting('zen_breadcrumb_separator');
51
      $trailing_separator = $title = '';
52
      if (theme_get_setting('zen_breadcrumb_title')) {
53
        if ($title = drupal_get_title()) {
54
          $trailing_separator = $breadcrumb_separator;
55
        }
56
      }
57
      elseif (theme_get_setting('zen_breadcrumb_trailing')) {
58
        $trailing_separator = $breadcrumb_separator;
59
      }
60
      return '<div class="breadcrumb">' . implode($breadcrumb_separator, $breadcrumb) . "$trailing_separator$title</div>";
61
    }
62
  }
63
  // Otherwise, return an empty string.
64
  return '';
65
}
66
67
/**
68
 * Return a themed set of links.
69
 *
70
 * @param $links
71
 *   A keyed array of links to be themed.
72
 * @param $attributes
73
 *   A keyed array of attributes
74
 * @param $heading
75
 *   An optional keyed array or a string for a heading to precede the links.
76
 *   When using an array the following keys can be used:
77
 *     - text: the heading text
78
 *     - level: the heading level (e.g. 'h2', 'h3')
79
 *     - class: (optional) a string of the CSS classes for the heading
80
 *   When using a string it will be used as the text of the heading and the
81
 *   level will default to 'h2'.
82
 *   Headings should be used on navigation menus and any list of links that
83
 *   consistently appears on multiple pages. To make the heading invisible
84
 *   use the 'element-invisible' CSS class. Do not use 'display:none', which
85
 *   removes it from screen-readers and assistive technology. Headings allow
86
 *   screen-reader and keyboard only users to navigate to or skip the links.
87
 *   See http://juicystudio.com/article/screen-readers-display-none.php
88
 *   and http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.
89
 * @return
90
 *   A string containing an unordered list of links.
91
 */
92
function zen_links($links, $attributes = array('class' => 'links'), $heading = '') {
93
  global $language;
94
  $output = '';
95
96
  if (count($links) > 0) {
97
    // Treat the heading first if it is present to prepend it to the
98
    // list of links.
99
    if (!empty($heading)) {
100
      if (is_string($heading)) {
101
        // Prepare the array that will be used when the passed heading
102
        // is a string.
103
        $heading = array(
104
          'text' => $heading,
105
          // Set the default level of the heading.
106
          'level' => 'h2',
107
        );
108
      }
109
      $output .= '<' . $heading['level'];
110
      if (!empty($heading['class'])) {
111
        $output .= drupal_attributes(array('class' => $heading['class']));
112
      }
113
      $output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>';
114
    }
115
116
    $output .= '<ul'. drupal_attributes($attributes) .'>';
117
118
    $num_links = count($links);
119
    $i = 1;
120
121
    foreach ($links as $key => $link) {
122
      $class = $key;
123
124
      // Add first, last and active classes to the list of links to help out themers.
125
      if ($i == 1) {
126
        $class .= ' first';
127
      }
128
      if ($i == $num_links) {
129
        $class .= ' last';
130
      }
131
      if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
132
          && (empty($link['language']) || $link['language']->language == $language->language)) {
133
        $class .= ' active';
134
      }
135
      $output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
136
137
      if (isset($link['href'])) {
138
        // Pass in $link as $options, they share the same keys.
139
        $output .= l($link['title'], $link['href'], $link);
140
      }
141
      else if (!empty($link['title'])) {
142
        // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
143
        if (empty($link['html'])) {
144
          $link['title'] = check_plain($link['title']);
145
        }
146
        $span_attributes = '';
147
        if (isset($link['attributes'])) {
148
          $span_attributes = drupal_attributes($link['attributes']);
149
        }
150
        $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
151
      }
152
153
      $i++;
154
      $output .= "</li>\n";
155
    }
156
157
    $output .= '</ul>';
158
  }
159
160
  return $output;
161
}
162
163
/**
164
 * Implements theme_menu_item_link()
165
 */
166
function zen_menu_item_link($link) {
167
  if (empty($link['localized_options'])) {
168
    $link['localized_options'] = array();
169
  }
170
171
  // If an item is a LOCAL TASK, render it as a tab
172
  if ($link['type'] & MENU_IS_LOCAL_TASK) {
173
    $link['title'] = '<span class="tab">' . check_plain($link['title']) . '</span>';
174
    $link['localized_options']['html'] = TRUE;
175
  }
176
177
  return l($link['title'], $link['href'], $link['localized_options']);
178
}
179
180
/**
181
 * Duplicate of theme_menu_local_tasks() but adds clearfix to tabs.
182
 */
183
function zen_menu_local_tasks() {
184
  $output = '';
185
186
  // CTools requires a different set of local task functions.
187
  if (module_exists('ctools')) {
188
    ctools_include('menu');
189
    $primary = ctools_menu_primary_local_tasks();
190
    $secondary = ctools_menu_secondary_local_tasks();
191
  }
192
  else {
193
    $primary = menu_primary_local_tasks();
194
    $secondary = menu_secondary_local_tasks();
195
  }
196
197
  if ($primary) {
198
    $output .= '<ul class="tabs primary clearfix">' . $primary . '</ul>';
199
  }
200
  if ($secondary) {
201
    $output .= '<ul class="tabs secondary clearfix">' . $secondary . '</ul>';
202
  }
203
204
  return $output;
205
}
206
207
/**
208
 * Return a set of blocks available for the current user.
209
 *
210
 * @param $region
211
 *   Which set of blocks to retrieve.
212
 * @param $show_blocks
213
 *   A boolean to determine whether to render sidebar regions or not. Should be
214
 *   the same value as passed to theme_page.
215
 * @return
216
 *   A string containing the themed blocks for this region.
217
 *
218
 * @see zen_show_blocks_discovery()
219
 */
220
function zen_blocks($region, $show_blocks = NULL) {
221
  // Since Drupal 6 doesn't pass $show_blocks to theme_blocks, we manually call
222
  // theme('blocks', NULL, $show_blocks) so that this function can remember the
223
  // value on later calls.
224
  static $render_sidebars = TRUE;
225
  if (!is_null($show_blocks)) {
226
    $render_sidebars = $show_blocks;
227
  }
228
229
  // If zen_blocks was called with a NULL region, its likely we were just
230
  // setting the $render_sidebars static variable.
231
  if ($region) {
232
    $output = '';
233
234
    // If $renders_sidebars is FALSE, don't render any region whose name begins
235
    // with "sidebar_".
236
    if ($render_sidebars || (strpos($region, 'sidebar_') !== 0)) {
237
      // Allow context module to set blocks.
238
      if (function_exists('context_blocks')) {
239
        $output = context_blocks($region);
240
      }
241
      else {
242
        foreach (block_list($region) as $key => $block) {
243
          // $key == module_delta
244
          $output .= theme('block', $block);
245
        }
246
      }
247
    }
248
249
    // Add any content assigned to this region through drupal_set_content() calls.
250
    $output .= drupal_get_content($region);
251
252
    $elements['#children'] = $output;
253
    $elements['#region'] = $region;
254
255
    // Set the theme hook suggestions.
256
    $hook = array('region_' . $region);
257
    if (strpos($region, 'sidebar_') === 0) {
258
      $hook[] = 'region_sidebar';
259
    }
260
    $hook[] = 'region';
261
    return $output ? theme($hook, $elements) : '';
262
  }
263
}
264
265
/**
266
 * Examine the $show_blocks variable before template_preprocess_page() is called.
267
 *
268
 * @param $vars
269
 *   An array of variables to pass to the page template.
270
 *
271
 * @see zen_blocks()
272
 */
273
function zen_show_blocks_discovery(&$vars) {
274
  if ($vars['show_blocks'] == FALSE) {
275
    // Allow zen_blocks() to statically cache the $show_blocks variable. A TRUE
276
    // value is assumed, so we only need to override when $show_blocks is FALSE.
277
    theme('blocks', NULL, FALSE);
278
  }
279
}
280
281
/**
282
 * Override or insert variables into templates before other preprocess functions have run.
283
 *
284
 * @param $vars
285
 *   An array of variables to pass to the theme template.
286
 * @param $hook
287
 *   The name of the template being rendered.
288
 */
289
function zen_preprocess(&$vars, $hook) {
290
  // In D6, the page.tpl uses a different variable name to hold the classes.
291
  $key = ($hook == 'page' || $hook == 'maintenance_page') ? 'body_classes' : 'classes';
292
293
  // Create a D7-standard classes_array variable.
294
  if (array_key_exists($key, $vars)) {
295
    // Views (and possibly other modules) have templates with a $classes
296
    // variable that isn't a string, so we leave those variables alone.
297
    if (is_string($vars[$key])) {
298
      $vars['classes_array'] = explode(' ', $hook . ' ' . $vars[$key]);
299
      unset($vars[$key]);
300
    }
301
  }
302
  else {
303
    $vars['classes_array'] = array($hook);
304
  }
305
  // Add support for Skinr
306
  if (!empty($vars['skinr']) && array_key_exists('classes_array', $vars)) {
307
    $vars['classes_array'][] = $vars['skinr'];
308
  }
309
}
310
311
/**
312
 * Override or insert variables into the page templates.
313
 *
314
 * @param $vars
315
 *   An array of variables to pass to the theme template.
316
 * @param $hook
317
 *   The name of the template being rendered ("page" in this case.)
318
 */
319
function zen_preprocess_page(&$vars, $hook) {
320
  // If the user is silly and enables Zen as the theme, add some styles.
321
  if ($GLOBALS['theme'] == 'zen') {
322
    include_once './' . _zen_path() . '/zen-internals/template.zen.inc';
323
    _zen_preprocess_page($vars, $hook);
324
  }
325
  // Add conditional stylesheets.
326
  elseif (!module_exists('conditional_styles')) {
327
    $language = $GLOBALS['language']->direction == LANGUAGE_RTL ? '_rtl' : '';
328
    $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'] . $language, '');
329
    $vars['styles'] .= $vars['conditional_styles'];
330
  }
331
332
  // Classes for body element. Allows advanced theming based on context
333
  // (home page, node of certain type, etc.)
334
  // Remove the mostly useless page-ARG0 class.
335
  if ($index = array_search(preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-'. drupal_strtolower(arg(0))), $vars['classes_array'])) {
336
    unset($vars['classes_array'][$index]);
337
  }
338
  if (!$vars['is_front']) {
339
    // Add unique class for each page.
340
    $path = drupal_get_path_alias($_GET['q']);
341
    $vars['classes_array'][] = drupal_html_class('page-' . $path);
342
    // Add unique class for each website section.
343
    list($section, ) = explode('/', $path, 2);
344
    if (arg(0) == 'node') {
345
      if (arg(1) == 'add') {
346
        $section = 'node-add';
347
      }
348
      elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
349
        $section = 'node-' . arg(2);
350
      }
351
    }
352
    $vars['classes_array'][] = drupal_html_class('section-' . $section);
353
  }
354
  if (theme_get_setting('zen_wireframes')) {
355
    $vars['classes_array'][] = 'with-wireframes'; // Optionally add the wireframes style.
356
  }
357
  // We need to re-do the $layout and body classes because
358
  // template_preprocess_page() assumes sidebars are named 'left' and 'right'.
359
  $vars['layout'] = 'none';
360
  if (!empty($vars['sidebar_first'])) {
361
    $vars['layout'] = 'first';
362
  }
363
  if (!empty($vars['sidebar_second'])) {
364
    $vars['layout'] = ($vars['layout'] == 'first') ? 'both' : 'second';
365
  }
366
  // If the layout is 'none', then template_preprocess_page() will already have
367
  // set a 'no-sidebars' class since it won't find a 'left' or 'right' sidebar.
368
  if ($vars['layout'] != 'none') {
369
    // Remove the incorrect 'no-sidebars' class.
370
    if ($index = array_search('no-sidebars', $vars['classes_array'])) {
371
      unset($vars['classes_array'][$index]);
372
    }
373
    // Set the proper layout body classes.
374
    if ($vars['layout'] == 'both') {
375
      $vars['classes_array'][] = 'two-sidebars';
376
    }
377
    else {
378
      $vars['classes_array'][] = 'one-sidebar';
379
      $vars['classes_array'][] = 'sidebar-' . $vars['layout'];
380
    }
381
  }
382
  // Store the menu item since it has some useful information.
383
  $vars['menu_item'] = menu_get_item();
384
  switch ($vars['menu_item']['page_callback']) {
385
    case 'views_page':
386
      // Is this a Views page?
387
      $vars['classes_array'][] = 'page-views';
388
      break;
389
    case 'page_manager_page_execute':
390
    case 'page_manager_node_view':
391
    case 'page_manager_contact_site':
392
      // Is this a Panels page?
393
      $vars['classes_array'][] = 'page-panels';
394
      break;
395
  }
396
}
397
398
/**
399
 * Override or insert variables into the maintenance page template.
400
 *
401
 * @param $vars
402
 *   An array of variables to pass to the theme template.
403
 * @param $hook
404
 *   The name of the template being rendered ("maintenance_page" in this case.)
405
 */
406
function zen_preprocess_maintenance_page(&$vars, $hook) {
407
  // If Zen is the maintenance theme, add some styles.
408
  if ($GLOBALS['theme'] == 'zen') {
409
    include_once './' . _zen_path() . '/zen-internals/template.zen.inc';
410
    _zen_preprocess_page($vars, $hook);
411
  }
412
  // Add conditional stylesheets.
413
  elseif (!module_exists('conditional_styles')) {
414
    $language = $GLOBALS['language']->direction == LANGUAGE_RTL ? '_rtl' : '';
415
    $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'] . $language, '');
416
    $vars['styles'] .= $vars['conditional_styles'];
417
  }
418
}
419
420
/**
421
 * Override or insert variables into the node templates.
422
 *
423
 * @param $vars
424
 *   An array of variables to pass to the theme template.
425
 * @param $hook
426
 *   The name of the template being rendered ("node" in this case.)
427
 */
428
function zen_preprocess_node(&$vars, $hook) {
429
  // Create the build_mode variable.
430
  switch ($vars['node']->build_mode) {
431
    case NODE_BUILD_NORMAL:
432
      if ($vars['node']->build_mode === NODE_BUILD_NORMAL) {
433
        $vars['build_mode'] = $vars['teaser'] ? 'teaser' : 'full';
434
      }
435
      else {
436
        $vars['build_mode'] = $vars['node']->build_mode;
437
      }
438
      break;
439
    case NODE_BUILD_PREVIEW:
440
      $vars['build_mode'] = 'preview';
441
      break;
442
    case NODE_BUILD_SEARCH_INDEX:
443
      $vars['build_mode'] = 'search_index';
444
      break;
445
    case NODE_BUILD_SEARCH_RESULT:
446
      $vars['build_mode'] = 'search_result';
447
      break;
448
    case NODE_BUILD_RSS:
449
      $vars['build_mode'] = 'rss';
450
      break;
451
    case NODE_BUILD_PRINT:
452
      $vars['build_mode'] = 'print';
453
      break;
454
    default:
0 ignored issues
show
DEFAULT keyword must be indented 4 spaces from SWITCH keyword
Loading history...
DEFAULT case must have a breaking statement
Loading history...
455
      $vars['build_mode'] = $vars['node']->build_mode;
456
  }
457
458
  // Create the user_picture variable.
459
  $vars['user_picture'] = $vars['picture'];
460
461
  // Create the Drupal 7 $display_submitted variable.
462
  $vars['display_submitted'] = theme_get_setting('toggle_node_info_' . $vars['node']->type);
463
464
  // Special classes for nodes.
465
  // Class for node type: "node-type-page", "node-type-story", "node-type-my-custom-type", etc.
466
  $vars['classes_array'][] = drupal_html_class('node-type-' . $vars['type']);
467
  if ($vars['promote']) {
468
    $vars['classes_array'][] = 'node-promoted';
469
  }
470
  if ($vars['sticky']) {
471
    $vars['classes_array'][] = 'node-sticky';
472
  }
473
  if (!$vars['status']) {
474
    $vars['classes_array'][] = 'node-unpublished';
475
    $vars['unpublished'] = TRUE;
476
  }
477
  else {
478
    $vars['unpublished'] = FALSE;
479
  }
480
  if ($vars['uid'] && $vars['uid'] == $GLOBALS['user']->uid) {
481
    $vars['classes_array'][] = 'node-by-viewer'; // Node is authored by current user.
482
  }
483
  if ($vars['teaser']) {
484
    $vars['classes_array'][] = 'node-teaser'; // Node is displayed as teaser.
485
  }
486
  if (isset($vars['preview'])) {
487
    $vars['classes_array'][] = 'node-preview';
488
  }
489
  $vars['classes_array'][] = 'build-mode-' . $vars['build_mode'] ;
0 ignored issues
show
Space found before semicolon; expected "];" but found "] ;"
Loading history...
490
}
491
492
/**
493
 * Override or insert variables into the comment templates.
494
 *
495
 * @param $vars
496
 *   An array of variables to pass to the theme template.
497
 * @param $hook
498
 *   The name of the template being rendered ("comment" in this case.)
499
 */
500
function zen_preprocess_comment(&$vars, $hook) {
501
  include_once './' . _zen_path() . '/zen-internals/template.comment.inc';
502
  _zen_preprocess_comment($vars, $hook);
503
}
504
505
/**
506
 * Preprocess variables for region.tpl.php
507
 *
508
 * Prepare the values passed to the theme_region function to be passed into a
509
 * pluggable template engine.
510
 *
511
 * @see region.tpl.php
512
 */
513
function zen_preprocess_region(&$vars, $hook) {
514
  // Create the $content variable that templates expect.
515
  $vars['content'] = $vars['elements']['#children'];
516
  $vars['region'] = $vars['elements']['#region'];
517
518
  // Setup the default classes.
519
  $vars['classes_array'] = array('region', 'region-' . str_replace('_', '-', $vars['region']));
520
521
  // Sidebar regions get a couple extra classes.
522
  if (strpos($vars['region'], 'sidebar_') === 0) {
523
    $vars['classes_array'][] = 'column';
524
    $vars['classes_array'][] = 'sidebar';
525
  }
526
}
527
528
/**
529
 * Override or insert variables into the block templates.
530
 *
531
 * @param $vars
532
 *   An array of variables to pass to the theme template.
533
 * @param $hook
534
 *   The name of the template being rendered ("block" in this case.)
535
 */
536
function zen_preprocess_block(&$vars, $hook) {
537
  $block = $vars['block'];
538
539
  // Drupal 7 uses a $content variable instead of $block->content.
540
  $vars['content'] = $block->content;
541
  // Drupal 7 should use a $title variable instead of $block->subject.
542
  $vars['title'] = $block->subject;
543
544
  // Special classes for blocks.
545
  $vars['classes_array'][] = 'block-' . $block->module;
546
  // Classes describing the position of the block within the region.
547
  if ($vars['block_id'] == 1) {
548
    $vars['classes_array'][] = 'first';
549
  }
550
  if (!function_exists('context_blocks') && count(block_list($vars['block']->region)) == $vars['block_id']) {
551
    $vars['classes_array'][] = 'last';
552
  }
553
  $vars['classes_array'][] = 'region-' . $vars['block_zebra'];
554
  $vars['classes_array'][] = $vars['zebra'];
555
  $vars['classes_array'][] = 'region-count-' . $vars['block_id'];
556
  $vars['classes_array'][] = 'count-' . $vars['id'];
557
558
  // Create the block ID.
559
  $vars['block_html_id'] = 'block-' . $block->module . '-' . $block->delta;
560
561
  $vars['edit_links_array'] = array();
562
  if (theme_get_setting('zen_block_editing') && user_access('administer blocks')) {
563
    include_once './' . _zen_path() . '/zen-internals/template.block-editing.inc';
564
    zen_preprocess_block_editing($vars, $hook);
565
    $vars['classes_array'][] = 'with-block-editing';
566
  }
567
}
568
569
/**
570
 * Override or insert variables into templates after preprocess functions have run.
571
 *
572
 * @param $vars
573
 *   An array of variables to pass to the theme template.
574
 * @param $hook
575
 *   The name of the template being rendered.
576
 */
577
function zen_process(&$vars, $hook) {
578
  // Don't clobber Views 3 classes.
579
  if (array_key_exists('classes_array', $vars) && !array_key_exists('classes', $vars)) {
580
    $vars['classes'] = implode(' ', $vars['classes_array']);
581
  }
582
}
583
584
/**
585
 * Override or insert variables into the block templates after preprocess functions have run.
586
 *
587
 * @param $vars
588
 *   An array of variables to pass to the theme template.
589
 * @param $hook
590
 *   The name of the template being rendered ("block" in this case.)
591
 */
592
function zen_process_block(&$vars, $hook) {
593
  $vars['edit_links'] = !empty($vars['edit_links_array']) ? '<div class="edit">' . implode(' ', $vars['edit_links_array']) . '</div>' : '';
594
}
595
596
if (!function_exists('drupal_html_class')) {
597
  /**
598
   * Prepare a string for use as a valid class name.
599
   *
600
   * Do not pass one string containing multiple classes as they will be
601
   * incorrectly concatenated with dashes, i.e. "one two" will become "one-two".
602
   *
603
   * @param $class
604
   *   The class name to clean.
605
   * @return
606
   *   The cleaned class name.
607
   */
608
  function drupal_html_class($class) {
609
    // By default, we filter using Drupal's coding standards.
610
    $class = strtr(drupal_strtolower($class), array(' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => ''));
611
612
    // http://www.w3.org/TR/CSS21/syndata.html#characters shows the syntax for valid
613
    // CSS identifiers (including element names, classes, and IDs in selectors.)
614
    //
615
    // Valid characters in a CSS identifier are:
616
    // - the hyphen (U+002D)
617
    // - a-z (U+0030 - U+0039)
618
    // - A-Z (U+0041 - U+005A)
619
    // - the underscore (U+005F)
620
    // - 0-9 (U+0061 - U+007A)
621
    // - ISO 10646 characters U+00A1 and higher
622
    // We strip out any character not in the above list.
623
    $class = preg_replace('/[^\x{002D}\x{0030}-\x{0039}\x{0041}-\x{005A}\x{005F}\x{0061}-\x{007A}\x{00A1}-\x{FFFF}]/u', '', $class);
624
625
    return $class;
626
  }
627
} /* End of drupal_html_class conditional definition. */
628
629
if (!function_exists('drupal_html_id')) {
630
  /**
631
   * Prepare a string for use as a valid HTML ID and guarantee uniqueness.
632
   *
633
   * @param $id
634
   *   The ID to clean.
635
   * @return
636
   *   The cleaned ID.
637
   */
638
  function drupal_html_id($id) {
639
    $id = strtr(drupal_strtolower($id), array(' ' => '-', '_' => '-', '[' => '-', ']' => ''));
640
641
    // As defined in http://www.w3.org/TR/html4/types.html#type-name, HTML IDs can
642
    // only contain letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
643
    // colons (":"), and periods ("."). We strip out any character not in that
644
    // list. Note that the CSS spec doesn't allow colons or periods in identifiers
645
    // (http://www.w3.org/TR/CSS21/syndata.html#characters), so we strip those two
646
    // characters as well.
647
    $id = preg_replace('/[^A-Za-z0-9\-_]/', '', $id);
648
649
    return $id;
650
  }
651
} /* End of drupal_html_id conditional definition. */
652
653
/**
654
 * Returns the path to the Zen theme.
655
 *
656
 * drupal_get_filename() is broken; see #341140. When that is fixed in Drupal 6,
657
 * replace _zen_path() with drupal_get_path('theme', 'zen').
658
 */
659
function _zen_path() {
660
  static $path = FALSE;
661
  if (!$path) {
662
    $matches = drupal_system_listing('zen\.info$', 'themes', 'name', 0);
663
    if (!empty($matches['zen']->filename)) {
664
      $path = dirname($matches['zen']->filename);
665
    }
666
  }
667
  return $path;
668
}
669