ds.contextual.inc 1.4 KB

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