Projet

Général

Profil

Paste
Télécharger (21,2 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / rubik / template.php @ e5461e73

1
<?php
2
/*
3
 * Implements hook_preprocess_html().
4
 */
5
function rubik_preprocess_html(&$vars) {
6
  if (theme_get_setting('rubik_inline_field_descriptions')) {
7
    $vars['classes_array'][] = 'rubik-inline-field-descriptions';
8
  }
9

    
10
   // add in a specific stylesheet for overrides in IE7. (BLAH)
11
  drupal_add_css(drupal_get_path('theme', 'rubik') . '/ie.css', array(
12
    'browsers' => array(
13
      '!IE' => FALSE,
14
    ),
15
    'weight' => 500,
16
    'group' => 5000,
17
    'every_page' => TRUE,
18
  ));
19

    
20
}
21

    
22
/**
23
 * Implements hook_css_alter().
24
 * @TODO: Do this in .info once http://drupal.org/node/575298 is committed.
25
 */
26
function rubik_css_alter(&$css) {
27
  if (isset($css['modules/overlay/overlay-child.css'])) {
28
    $css['modules/overlay/overlay-child.css']['data'] = drupal_get_path('theme', 'rubik') . '/overlay-child.css';
29
  }
30
  if (isset($css['modules/shortcut/shortcut.css'])) {
31
    $css['modules/shortcut/shortcut.css']['data'] = drupal_get_path('theme', 'rubik') . '/shortcut.css';
32
  }
33
}
34

    
35
/**
36
 * Implementation of hook_theme().
37
 */
38
function rubik_theme() {
39
  $items = array();
40

    
41
  // Content theming.
42
  $items['help'] =
43
  $items['node'] =
44
  $items['comment'] =
45
  $items['comment_wrapper'] = array(
46
    'path' => drupal_get_path('theme', 'rubik') .'/templates',
47
    'template' => 'object',
48
  );
49
  $items['node']['template'] = 'node';
50

    
51
  // Help pages really need help. See preprocess_page().
52
  $items['help_page'] = array(
53
    'variables' => array('content' => array()),
54
    'path' => drupal_get_path('theme', 'rubik') .'/templates',
55
    'template' => 'object',
56
    'preprocess functions' => array(
57
      'template_preprocess',
58
      'rubik_preprocess_help_page',
59
    ),
60
    'process functions' => array('template_process'),
61
  );
62

    
63
  if (!theme_get_setting('rubik_disable_sidebar_in_form')) {
64
    // Form layout: default (2 column).
65
    $items['block_add_block_form'] =
66
    $items['block_admin_configure'] =
67
    $items['comment_form'] =
68
    $items['contact_admin_edit'] =
69
    $items['contact_mail_page'] =
70
    $items['contact_mail_user'] =
71
    $items['filter_admin_format_form'] =
72
    $items['forum_form'] =
73
    $items['locale_languages_edit_form'] =
74
    $items['menu_edit_menu'] =
75
    $items['menu_edit_item'] =
76
    $items['node_type_form'] =
77
    $items['path_admin_form'] =
78
    $items['system_settings_form'] =
79
    $items['system_themes_form'] =
80
    $items['system_modules'] =
81
    $items['system_actions_configure'] =
82
    $items['taxonomy_form_term'] =
83
    $items['taxonomy_form_vocabulary'] =
84
    $items['user_profile_form'] =
85
    $items['user_admin_access_add_form'] = array(
86
      'render element' => 'form',
87
      'path' => drupal_get_path('theme', 'rubik') .'/templates',
88
      'template' => 'form-default',
89
      'preprocess functions' => array(
90
        'rubik_preprocess_form_buttons',
91
      ),
92
    );
93

    
94
    // These forms require additional massaging.
95
    $items['confirm_form'] = array(
96
      'render element' => 'form',
97
      'path' => drupal_get_path('theme', 'rubik') .'/templates',
98
      'template' => 'form-simple',
99
      'preprocess functions' => array(
100
        'rubik_preprocess_form_confirm'
101
      ),
102
    );
103
    $items['node_form'] = array(
104
      'render element' => 'form',
105
      'path' => drupal_get_path('theme', 'rubik') .'/templates',
106
      'template' => 'form-default',
107
      'preprocess functions' => array(
108
        'rubik_preprocess_form_buttons',
109
        'rubik_preprocess_form_node',
110
      ),
111
    );
112
  }
113
  return $items;
114
}
115

    
116
/**
117
 * Preprocessor for theme('page').
118
 */
119
function rubik_preprocess_page(&$vars) {
120
  // Show a warning if base theme is not present.
121
  if (!function_exists('tao_theme') && user_access('administer site configuration')) {
122
    drupal_set_message(t('The Rubik theme requires the !tao base theme in order to work properly.', array('!tao' => l('Tao', 'http://drupal.org/project/tao'))), 'warning');
123
  }
124

    
125
  // Set a page icon class.
126
  $vars['page_icon_class'] = ($item = menu_get_item()) ? implode(' ' , _rubik_icon_classes($item['href'])) : '';
127

    
128
  // Help pages. They really do need help.
129
  if (strpos($_GET['q'], 'admin/help/') === 0 && isset($vars['page']['content']['system_main']['main']['#markup'])) {
130
    $vars['page']['content']['system_main']['main']['#markup'] = theme('help_page', array('content' => $vars['page']['content']['system_main']['main']['#markup']));
131
  }
132

    
133
  // Clear out help text if empty.
134
  if (empty($vars['help']) || !(strip_tags($vars['help']))) {
135
    $vars['help'] = '';
136
  }
137

    
138
  // Process local tasks. This will get called for rubik and its subthemes.
139
  _rubik_local_tasks($vars);
140

    
141
  // Overlay is enabled.
142
  $vars['overlay'] = (module_exists('overlay') && overlay_get_mode() === 'child');
143

    
144
  // Disable sticky in the sidebar. Set option in JS
145
  $disable_sticky = theme_get_setting('rubik_disable_sticky_sidebar');
146
  drupal_add_js(array('rubik' => array('disable_sticky' => $disable_sticky)), array('type' => 'setting'));
147

    
148
}
149

    
150
/**
151
 * Preprocessor for theme('fieldset').
152
 */
153
function rubik_preprocess_fieldset(&$vars) {
154
  if (!empty($vars['element']['#collapsible'])) {
155
    $vars['title'] = "<span class='icon'></span>" . $vars['title'];
156
  }
157
}
158

    
159
/**
160
 * Preprocessor for handling form button for most forms.
161
 */
162
function rubik_preprocess_form_buttons(&$vars) {
163
  if (!empty($vars['form']['actions'])) {
164
    $vars['actions'] = $vars['form']['actions'];
165
    unset($vars['form']['actions']);
166
  }
167
}
168

    
169
/**
170
 * Preprocessor for theme('confirm_form').
171
 */
172
function rubik_preprocess_form_confirm(&$vars) {
173
  // Move the title from the page title (usually too big and unwieldy)
174
  $title = filter_xss_admin(drupal_get_title());
175
  $vars['form']['description']['#type'] = 'item';
176
  $vars['form']['description']['#value'] = empty($vars['form']['description']['#value']) ?
177
    "<strong>{$title}</strong>" :
178
    "<strong>{$title}</strong><p>{$vars['form']['description']['#value']}</p>";
179
  drupal_set_title(t('Please confirm'));
180
}
181

    
182
/**
183
 * Preprocessor for theme('node_form').
184
 */
185
function rubik_preprocess_form_node(&$vars) {
186
  $vars['sidebar'] = isset($vars['sidebar']) ? $vars['sidebar'] : array();
187
  $map = array();
188
  // Support field_group if present.
189
  if (module_exists('field_group')) {
190
    $map += array(
191
      'group_sidebar' => 'sidebar',
192
      'group_footer' => 'footer',
193
    );
194
  }
195
  // Support nodeformcols if present.
196
  if (module_exists('nodeformcols')) {
197
    $map += array(
198
      'nodeformcols_region_right' => 'sidebar',
199
      'nodeformcols_region_footer' => 'footer',
200
      'nodeformcols_region_main' => NULL,
201
    );
202
  }
203
    if (isset($map)) {
204
    foreach ($map as $region => $target) {
205
      if (isset($vars['form'][$region])) {
206
        if (isset($vars['form'][$region]['#prefix'], $vars['form'][$region]['#suffix'])) {
207
          unset($vars['form'][$region]['#prefix']);
208
          unset($vars['form'][$region]['#suffix']);
209
        }
210
        if (isset($vars['form'][$region]['actions'], $vars['form'][$region]['actions'])) {
211
          $vars['actions'] = $vars['form'][$region]['actions'];
212
          unset($vars['form'][$region]['actions']);
213
        }
214
        if (isset($target)) {
215
          $vars[$target] = $vars['form'][$region];
216
          unset($vars['form'][$region]);
217
        }
218
      }
219
    }
220
  }
221
  // Default to showing taxonomy in sidebar if nodeformcols is not present.
222
  elseif (isset($vars['form']['taxonomy']) && empty($vars['sidebar'])) {
223
    $vars['sidebar']['taxonomy'] = $vars['form']['taxonomy'];
224
    unset($vars['form']['taxonomy']);
225
  }
226
}
227

    
228
/**
229
 * Preprocessor for theme('button').
230
 */
231
function rubik_preprocess_button(&$vars) {
232
  if (isset($vars['element']['#value'])) {
233
    $classes = array(
234
      t('Save') => 'yes',
235
      t('Submit') => 'yes',
236
      t('Yes') => 'yes',
237
      t('Add') => 'add',
238
      t('Delete') => 'remove',
239
      t('Remove') => 'remove',
240
      t('Cancel') => 'no',
241
      t('No') => 'no',
242
    );
243
    foreach ($classes as $search => $class) {
244
      if (strpos($vars['element']['#value'], $search) !== FALSE) {
245
        $vars['element']['#attributes']['class'][] = 'button-' . $class;
246
        break;
247
      }
248
    }
249
  }
250
}
251

    
252
/**
253
 * Preprocessor for theme('help').
254
 */
255
function rubik_preprocess_help(&$vars) {
256
  $vars['hook'] = 'help';
257
  $vars['attr']['id'] = 'help-text';
258
  $class = 'path-admin-help clear-block toggleable';
259
  $vars['attr']['class'] = isset($vars['attr']['class']) ? "{$vars['attr']['class']} $class" : $class;
260
  $help = menu_get_active_help();
261
  if (($test = strip_tags($help)) && !empty($help)) {
262
    // Thankfully this is static cached.
263
    $vars['attr']['class'] .= menu_secondary_local_tasks() ? ' with-tabs' : '';
264

    
265
    $vars['is_prose'] = TRUE;
266
    $vars['layout'] = TRUE;
267
    $vars['content'] = "<span class='icon'></span>" . $help;
268

    
269
    // Link to help section.
270
    $item = menu_get_item('admin/help');
271
    if ($item && $item['path'] === 'admin/help' && $item['access']) {
272
      $vars['links'] = l(t('More help topics'), 'admin/help');
273
    }
274
  }
275
}
276

    
277
/**
278
 * Preprocessor for theme('help_page').
279
 */
280
function rubik_preprocess_help_page(&$vars) {
281
  $vars['hook'] = 'help-page';
282

    
283
  $vars['title_attributes_array']['class'][] = 'help-page-title';
284
  $vars['title_attributes_array']['class'][] = 'clearfix';
285

    
286
  $vars['content_attributes_array']['class'][] = 'help-page-content';
287
  $vars['content_attributes_array']['class'][] = 'clearfix';
288
  $vars['content_attributes_array']['class'][] = 'prose';
289

    
290
  $vars['layout'] = TRUE;
291

    
292
  // Truly hackish way to navigate help pages.
293
  $module_info = system_rebuild_module_data();
294
  $empty_arg = drupal_help_arg();
295
  $modules = array();
296
  foreach (module_implements('help', TRUE) as $module) {
297
    if (module_invoke($module, 'help', "admin/help#$module", $empty_arg)) {
298
      $modules[$module] = $module_info[$module]->info['name'];
299
    }
300
  }
301
  asort($modules);
302

    
303
  $links = array();
304
  foreach ($modules as $module => $name) {
305
    $links[] = array('title' => $name, 'href' => "admin/help/{$module}");
306
  }
307
  $vars['links'] = theme('links', array('links' => $links));
308
}
309

    
310
/**
311
 * Preprocessor for theme('node').
312
 */
313
function rubik_preprocess_node(&$vars) {
314
  $vars['layout'] = TRUE;
315
  if ($vars['display_submitted']) {
316
    $vars['submitted'] = _rubik_submitted($vars['node']);
317
  }
318
}
319

    
320
/**
321
 * Preprocessor for theme('comment').
322
 */
323
function rubik_preprocess_comment(&$vars) {
324
  $vars['layout'] = TRUE;
325
  $vars['submitted'] = _rubik_submitted($vars['comment']);
326
}
327

    
328
/**
329
 * Preprocessor for theme('comment_wrapper').
330
 */
331
function rubik_preprocess_comment_wrapper(&$vars) {
332
  $vars['hook'] = 'box';
333
  $vars['layout'] = FALSE;
334
  $vars['title'] = t('Comments');
335

    
336
  $vars['attributes_array']['id'] = 'comments';
337

    
338
  $vars['title_attributes_array']['class'][] = 'box-title';
339
  $vars['title_attributes_array']['class'][] = 'clearfix';
340

    
341
  $vars['content_attributes_array']['class'][] = 'box-content';
342
  $vars['content_attributes_array']['class'][] = 'clearfix';
343
  $vars['content_attributes_array']['class'][] = 'prose';
344

    
345
  $vars['content'] = drupal_render_children($vars['content']);
346
}
347

    
348
/**
349
 * Preprocessor for theme('admin_block').
350
 */
351
function rubik_preprocess_admin_block(&$vars) {
352
  // Add icon and classes to admin block titles.
353
  if (isset($vars['block']['href'])) {
354
    $vars['block']['localized_options']['attributes']['class'] =  _rubik_icon_classes($vars['block']['href']);
355
  }
356
  $vars['block']['localized_options']['html'] = TRUE;
357
  if (isset($vars['block']['link_title'])) {
358
    $vars['block']['title'] = l("<span class='icon'></span>" . filter_xss_admin($vars['block']['title']), $vars['block']['href'], $vars['block']['localized_options']);
359
  }
360

    
361
  if (empty($vars['block']['content'])) {
362
    $vars['block']['content'] = "<div class='admin-block-description description'>{$vars['block']['description']}</div>";
363
  }
364
}
365

    
366
/**
367
 * Override of theme('breadcrumb').
368
 */
369
function rubik_breadcrumb($vars) {
370
  $output = '';
371

    
372
  // Add current page onto the end.
373
  if (!drupal_is_front_page()) {
374
    $item = menu_get_item();
375
    $end = end($vars['breadcrumb']);
376
    if ($end && strip_tags($end) !== $item['title']) {
377
      $vars['breadcrumb'][] = (isset($item['localized_options']['html']) && $item['localized_options']['html']) ? $item['title'] : check_plain($item['title']);
378
    }
379
  }
380

    
381
  // Optional: Add the site name to the front of the stack.
382
  if (!empty($vars['prepend'])) {
383
    $site_name = empty($vars['breadcrumb']) ? "<strong>". check_plain(variable_get('site_name', '')) ."</strong>" : l(variable_get('site_name', ''), '<front>', array('purl' => array('disabled' => TRUE)));
384
    array_unshift($vars['breadcrumb'], $site_name);
385
  }
386

    
387
  $depth = 0;
388
  foreach ($vars['breadcrumb'] as $link) {
389

    
390
    // If the item isn't a link, surround it with a strong tag to format it like
391
    // one.
392
    if (!preg_match('/^<a/', $link) && !preg_match('/^<strong/', $link)) {
393
      $link = '<strong>' . $link . '</strong>';
394
    }
395

    
396
    $output .= "<span class='breadcrumb-link breadcrumb-depth-{$depth}'>{$link}</span>";
397
    $depth++;
398
  }
399
  return $output;
400
}
401

    
402
/**
403
 * Override of theme('filter_guidelines').
404
 */
405
function rubik_filter_guidelines($variables) {
406
  return '';
407
}
408

    
409
/**
410
 * Override of theme('node_add_list').
411
 */
412
function rubik_node_add_list($vars) {
413
  $content = $vars['content'];
414

    
415
  $output = "<ul class='admin-list'>";
416
  if ($content) {
417
    foreach ($content as $item) {
418
      $item['title'] = "<span class='icon'></span>" . filter_xss_admin($item['title']);
419
      if (isset($item['localized_options']['attributes']['class'])) {
420
        $item['localized_options']['attributes']['class'] += _rubik_icon_classes($item['href']);
421
      }
422
      else {
423
        $item['localized_options']['attributes']['class'] = _rubik_icon_classes($item['href']);
424
      }
425
      $item['localized_options']['html'] = TRUE;
426
      $output .= "<li>";
427
      $output .= l($item['title'], $item['href'], $item['localized_options']);
428
      $output .= '<div class="description">'. filter_xss_admin($item['description']) .'</div>';
429
      $output .= "</li>";
430
    }
431
  }
432
  $output .= "</ul>";
433
  return $output;
434
}
435

    
436
/**
437
 * Override of theme_admin_block_content().
438
 */
439
function rubik_admin_block_content($vars) {
440
  $content = $vars['content'];
441

    
442
  $output = '';
443
  if (!empty($content)) {
444

    
445
    foreach ($content as $k => $item) {
446

    
447
      //-- Safety check for invalid clients of the function
448
      if (empty($content[$k]['localized_options']['attributes']['class'])) {
449
        $content[$k]['localized_options']['attributes']['class'] = array();
450
      }
451
      if (!is_array($content[$k]['localized_options']['attributes']['class'])) {
452
        $content[$k]['localized_options']['attributes']['class'] = array($content[$k]['localized_options']['attributes']['class']);
453
      }
454

    
455
      $content[$k]['title'] = "<span class='icon'></span>" . filter_xss_admin($item['title']);
456
      $content[$k]['localized_options']['html'] = TRUE;
457
      if (!empty($content[$k]['localized_options']['attributes']['class'])) {
458
        $content[$k]['localized_options']['attributes']['class'] += _rubik_icon_classes($item['href']);
459
      }
460
      else {
461
        $content[$k]['localized_options']['attributes']['class'] = _rubik_icon_classes($item['href']);
462
      }
463
    }
464
    $output = system_admin_compact_mode() ? '<ul class="admin-list admin-list-compact">' : '<ul class="admin-list">';
465
    foreach ($content as $item) {
466
      $output .= '<li class="leaf">';
467
      $output .= l($item['title'], $item['href'], $item['localized_options']);
468
      if (isset($item['description']) && !system_admin_compact_mode()) {
469
        $output .= "<div class='description'>{$item['description']}</div>";
470
      }
471
      $output .= '</li>';
472
    }
473
    $output .= '</ul>';
474
  }
475
  return $output;
476
}
477

    
478
/**
479
 * Override of theme('admin_drilldown_menu_item_link').
480
 */
481
function rubik_admin_drilldown_menu_item_link($link) {
482
  $link['localized_options'] = empty($link['localized_options']) ? array() : $link['localized_options'];
483
  $link['localized_options']['html'] = TRUE;
484
  if (!isset($link['localized_options']['attributes']['class'])) {
485
    $link['localized_options']['attributes']['class'] = _rubik_icon_classes($link['href']);
486
  }
487
  else {
488
    $link['localized_options']['attributes']['class'] += _rubik_icon_classes($link['href']);
489
  }
490
  $link['description'] = check_plain(truncate_utf8(strip_tags($link['description']), 150, TRUE, TRUE));
491
  $link['description'] = "<span class='icon'></span>" . $link['description'];
492
  $link['title'] .= !empty($link['description']) ? "<span class='menu-description'>{$link['description']}</span>" : '';
493
  $link['title'] = filter_xss_admin($link['title']);
494
  return l($link['title'], $link['href'], $link['localized_options']);
495
}
496

    
497
/**
498
 * Preprocessor for theme('textfield').
499
 */
500
function rubik_preprocess_textfield(&$vars) {
501
  if ($vars['element']['#size'] >= 30 && empty($vars['element']['#field_prefix']) && empty($vars['element']['#field_suffix'])) {
502
    $vars['element']['#size'] = '';
503
    if (!isset($vars['element']['#attributes']['class'])
504
      || !is_array($vars['element']['#attributes']['class'])) {
505
       $vars['element']['#attributes']['class'] = array();
506
    }
507
    $vars['element']['#attributes']['class'][] = 'fluid';
508
  }
509
}
510

    
511
/**
512
 * Override of theme('menu_local_task').
513
 */
514
function rubik_menu_local_task($variables) {
515
  $link = $variables['element']['#link'];
516
  $link_text = $link['title'];
517

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

    
522
    // If the link does not contain HTML already, check_plain() it now.
523
    // After we set 'html'=TRUE the link will not be sanitized by l().
524
    if (empty($link['localized_options']['html'])) {
525
      $link['title'] = check_plain($link['title']);
526
    }
527
    $link['localized_options']['html'] = TRUE;
528
    $link_text = t('!local-task-title!active', array('!local-task-title' => $link['title'], '!active' => $active));
529
  }
530

    
531
  // Render child tasks if available.
532
  $children = '';
533
  if (element_children($variables['element'])) {
534
    $children = drupal_render_children($variables['element']);
535
    $children = "<ul class='secondary-tabs links clearfix'>{$children}</ul>";
536
  }
537

    
538
  return '<li' . (!empty($variables['element']['#active']) ? ' class="active"' : '') . '>' . l($link_text, $link['href'], $link['localized_options']) . $children . "</li>\n";
539
}
540

    
541
/**
542
 * Helper function for cloning and drupal_render()'ing elements.
543
 */
544
function rubik_render_clone($elements) {
545
  static $instance;
546
  if (!isset($instance)) {
547
    $instance = 1;
548
  }
549
  foreach (element_children($elements) as $key) {
550
    if (isset($elements[$key]['#id'])) {
551
      $elements[$key]['#id'] = "{$elements[$key]['#id']}-{$instance}";
552
    }
553
  }
554
  $instance++;
555
  return drupal_render($elements);
556
}
557

    
558
function rubik_form_field_ui_field_edit_form_alter(&$form, &$form_state) { 
559
  $rubik_sidebar_field_ui = theme_get_setting('rubik_sidebar_field_ui', 'rubik');
560
  $rubik_disable_sidebar_in_form = theme_get_setting('rubik_disable_sidebar_in_form', 'rubik');
561
    if ($rubik_sidebar_field_ui == 1 && $rubik_disable_sidebar_in_form == 0) {
562
      $options = array(
563
        'default' => t('Default'),
564
        'rubik_sidebar_field' => t('Sidebar'),
565
      );
566
      $default = (isset($form_state['build_info']['args'][0]['rubik_edit_field_display'])) ? $form_state['build_info']['args'][0]['rubik_edit_field_display'] : 'default';
567
      $form['instance']['rubik_edit_field_display'] = array(
568
        '#type' => 'radios',
569
        '#title' => t('Set field display location'),
570
        '#description' => t('Choose where this field should be displayed.'),
571
        '#default_value' => $default,
572
        '#options' => $options,
573
      );
574
    }
575
  }
576

    
577
  function rubik_form_node_form_alter(&$form, $form_state) {
578
    $rubik_sidebar_field_ui = theme_get_setting('rubik_sidebar_field_ui', 'rubik');
579
    if ($rubik_sidebar_field_ui == TRUE) {
580
      if (isset($form_state['field']) && is_array($form_state['field'])) {
581
        foreach ($form_state['field'] AS $name => $field) {
582
          if (!isset($field[LANGUAGE_NONE]['instance'])) {
583
            continue;
584
          }
585
          if (isset($field[LANGUAGE_NONE]['instance']['rubik_edit_field_display'])) {
586
            $display = $field[LANGUAGE_NONE]['instance']['rubik_edit_field_display'];
587
            if ($display == 'rubik_sidebar_field') {
588
              $form[$name]['#attributes']['class'][] = 'rubik_sidebar_field';
589
            }
590
          }
591
        }
592
      }
593
    }
594
  }
595

    
596
/**
597
 * Helper function to submitted info theming functions.
598
 */
599
function _rubik_submitted($node) {
600
  $byline = t('Posted by !username', array('!username' => theme('username', array('account' => $node))));
601
  $date = format_date($node->created, 'small');
602
  return "<div class='byline'>{$byline}</div><div class='date'>$date</div>";
603
}
604

    
605
/**
606
 * Generate an icon class from a path.
607
 */
608
function _rubik_icon_classes($path) {
609
  $classes = array();
610
  $args = explode('/', $path);
611
  if ($args[0] === 'admin' || (count($args) > 1 && $args[0] === 'node' && $args[1] === 'add')) {
612
    // Add a class specifically for the current path that allows non-cascading
613
    // style targeting.
614
    $classes[] = 'path-'. str_replace('/', '-', implode('/', $args)) . '-';
615
    while (count($args)) {
616
      $classes[] = drupal_html_class('path-'. str_replace('/', '-', implode('/', $args)));
617
      array_pop($args);
618
    }
619
    return $classes;
620
  }
621
  return array();
622
}
623

    
624
function _rubik_local_tasks(&$vars) {
625
  if (!empty($vars['secondary_local_tasks']) && is_array($vars['primary_local_tasks'])) {
626
    foreach ($vars['primary_local_tasks'] as $key => $element) {
627
      if (!empty($element['#active'])) {
628
        $vars['primary_local_tasks'][$key] = $vars['primary_local_tasks'][$key] + $vars['secondary_local_tasks'];
629
        break;
630
      }
631
    }
632
  }
633
}
634