You are here

function civicrm_entity_page_view in CiviCRM Entity 7.2

Loads UI controller and generates view pages for civicrm entities

Parameters

$entity:

string $entity_type:

Return value

string content

1 string reference to 'civicrm_entity_page_view'
CivicrmEntityUIController::hook_menu in ./civicrm_entity_ui_controller.inc
Provides definitions for implementing hook_menu().

File

./civicrm_entity.module, line 3883

Code

function civicrm_entity_page_view($entity, $entity_type) {
  $content = "";
  if (!empty($entity->id)) {
    $id = $entity->id;
  }
  elseif (!is_object($entity) && is_numeric($entity)) {
    $id = $entity;
  }
  if (!empty($entity) && is_object($entity)) {
    if ($entity_type == 'civicrm_contact') {

      //for some reason the is_deleted column of the contact record is coming to the entity

      // as contact_is_deleted ...special handling to have the page value set properly
      $entity->is_deleted = $entity->contact_is_deleted;
    }
    $content_array = entity_view($entity_type, array(
      $entity->id => $entity,
    ));
    $content = drupal_render($content_array);
    $label = entity_label($entity_type, $entity);
  }
  else {
    $content = '<p>No ' . $entity_type . ' record found for id: ' . $id . '</p>';
  }
  if (!empty($label) && ($entity_type == 'civicrm_event' || $entity_type == 'civicrm_contact' || $entity_type == 'civicrm_group')) {
    drupal_set_title($label);
  }
  else {
    $formatted_entity_title = ucwords(str_replace('_', ' ', $entity_type));
    drupal_set_title($formatted_entity_title . ' ' . $id);
  }
  return $content;
}