Projet

Général

Profil

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

root / drupal7 / sites / all / themes / rubik / template.php @ 2734bffc

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') . '/css/ie.css', array(
12
    'browsers' => array(
13
      '!IE' => FALSE,
14
    ),
15
    'weight' => 500,
16
    'group' => 5000,
17
    'every_page' => TRUE,
18
  ));
19

    
20
  // Disable sticky in the sidebar. Set option in JS
21
  $disable_sticky = theme_get_setting('rubik_disable_sticky_sidebar');
22
  drupal_add_js(array('rubik' => array('disable_sticky' => $disable_sticky)), array('type' => 'setting'));
23
}
24

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

    
38
/**
39
 * Implementation of hook_theme().
40
 */
41
function rubik_theme() {
42
  $items = array();
43

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

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

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

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

    
119
/**
120
 * Preprocessor for theme('page').
121
 */
122
function rubik_preprocess_page(&$vars) {
123
  // Show a warning if base theme is not present.
124
  if (!function_exists('tao_theme') && user_access('administer site configuration')) {
125
    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');
126
  }
127

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

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

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

    
141
  // Process local tasks. This will get called for rubik and its subthemes.
142
  _rubik_local_tasks($vars);
143

    
144
  // Overlay is enabled.
145
  $vars['overlay'] = (module_exists('overlay') && overlay_get_mode() === 'child');
146
}
147

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

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

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

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

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

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

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

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

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

    
281
  $vars['title_attributes_array']['class'][] = 'help-page-title';
282
  $vars['title_attributes_array']['class'][] = 'clearfix';
283

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

    
288
  $vars['layout'] = TRUE;
289

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

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

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

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

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

    
334
  $vars['attributes_array']['id'] = 'comments';
335

    
336
  $vars['title_attributes_array']['class'][] = 'box-title';
337
  $vars['title_attributes_array']['class'][] = 'clearfix';
338

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

    
343
  $vars['content'] = drupal_render_children($vars['content']);
344
}
345

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

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

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

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

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

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

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

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

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

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

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

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

    
440
  $output = '';
441
  if (!empty($content)) {
442

    
443
    foreach ($content as $k => $item) {
444

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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