You are here

function crm_core_contact_view_page in CRM Core 7

Same name and namespace in other branches
  1. 8 modules/crm_core_contact/legacy/plugins/tasks/view.inc \crm_core_contact_view_page()
  2. 8.2 modules/crm_core_contact/legacy/plugins/tasks/view.inc \crm_core_contact_view_page()

Entry point for our overridden crm_core_contact view.

This function asks its assigned handlers who, if anyone, would like to run with it. If no one does, it passes through to Drupal core's crm_core_contact view, which is crm_core_contact().

1 string reference to 'crm_core_contact_view_page'
crm_core_contact_view_menu_alter in modules/crm_core_contact/plugins/tasks/view.inc
Callback defined by crm_core_contact_view_page_manager_tasks().

File

modules/crm_core_contact/plugins/tasks/view.inc, line 81
Handle the 'crm_core_contact view' override task.

Code

function crm_core_contact_view_page($crm_core_contact) {

  // Load my task plugin
  $task = page_manager_get_task('view');

  // Load the crm_core_contact into a context.
  ctools_include('context');
  ctools_include('context-task-handler');

  // We need to mimic Drupal's behavior of setting the crm_core_contact title here.
  drupal_set_title(crm_core_contact_title($crm_core_contact));
  $uri = entity_uri('crm_core_contact', $crm_core_contact);

  // Set the crm_core_contact path as the canonical URL to prevent duplicate content.
  drupal_add_html_head_link(array(
    'rel' => 'canonical',
    'href' => url($uri['path'], $uri['options']),
  ), TRUE);

  // Set the non-aliased path as a default shortlink.
  drupal_add_html_head_link(array(
    'rel' => 'shortlink',
    'href' => url($uri['path'], array_merge($uri['options'], array(
      'alias' => TRUE,
    ))),
  ), TRUE);
  $contexts = ctools_context_handler_get_task_contexts($task, '', array(
    $crm_core_contact,
  ));
  $output = ctools_context_handler_render($task, '', $contexts, array(
    $crm_core_contact->contact_id,
  ));
  if ($output != FALSE) {
    return $output;
  }
  $function = 'crm_core_contact_view';
  foreach (module_implements('page_manager_override') as $module) {
    $call = $module . '_page_manager_override';
    if (($rc = $call('crm_core_contact_view')) && function_exists($rc)) {
      $function = $rc;
      break;
    }
  }

  // Otherwise, fall back.
  return $function($crm_core_contact);
}