1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Menu callbacks for contextual links and tabs added by DS.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Menu callback: redirect to manage display.
|
10
|
*/
|
11
|
function ds_contextual_page_tab($object, $entity_type) {
|
12
|
|
13
|
switch ($entity_type) {
|
14
|
case 'node':
|
15
|
$bundle = $object->type;
|
16
|
$view_mode = (!empty($object->ds_switch)) ? $object->ds_switch : 'full';
|
17
|
|
18
|
// Let's always go back to the node page.
|
19
|
$destination = 'node/' . $object->nid;
|
20
|
break;
|
21
|
case 'user':
|
22
|
$bundle = 'user';
|
23
|
$view_mode = 'full';
|
24
|
$destination = 'user/' . $object->uid;
|
25
|
break;
|
26
|
case 'taxonomy_term':
|
27
|
$bundle = $object->vocabulary_machine_name;
|
28
|
$view_mode = 'full';
|
29
|
$destination = 'taxonomy/term/' . $object->tid;
|
30
|
break;
|
31
|
}
|
32
|
|
33
|
// Check if we have a configured layout. Do not fallback to default.
|
34
|
$layout = ds_get_layout($entity_type, $bundle, $view_mode, FALSE);
|
35
|
|
36
|
// Get the manage display URI.
|
37
|
$admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
|
38
|
|
39
|
// Check view mode settings.
|
40
|
$view_mode_settings = field_view_mode_settings($entity_type, $bundle);
|
41
|
$overriden = (!empty($view_mode_settings[$view_mode]['custom_settings']) ? TRUE : FALSE);
|
42
|
|
43
|
if (empty($layout) && !$overriden) {
|
44
|
$admin_path .= '/display';
|
45
|
}
|
46
|
else {
|
47
|
$admin_path .= '/display/' . $view_mode;
|
48
|
}
|
49
|
|
50
|
drupal_goto($admin_path, array('query' => array('destination' => $destination)));
|
51
|
}
|