You are here

function forward_entity_view in Forward 7.3

Same name and namespace in other branches
  1. 8.3 forward.module \forward_entity_view()
  2. 8 forward.module \forward_entity_view()
  3. 8.2 forward.module \forward_entity_view()

Implements hook_entity_view().

File

./forward.module, line 141
Allows forwarding of entities by email, and provides a record of how often each has been forwarded.

Code

function forward_entity_view($entity, $entity_type, $view_mode, $langcode) {
  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
  $show = _forward_show_on_entity($entity_type, $entity, $bundle) && variable_get('forward_view_' . $view_mode, FALSE);
  if ($show) {
    $default_weight = 50;
    if (variable_get('forward_interface_type', 'link') == 'link') {
      $link = forward_link_create($entity_type, $entity);
      $links = array();
      $links['forward_link'] = array(
        'title' => $link['title'],
        'href' => 'forward',
        'html' => $link['html'],
        'attributes' => $link['attributes'],
        'query' => $link['query'],
      );
      $entity->content['links']['forward'] = array(
        '#theme' => 'links',
        '#links' => $links,
        '#attributes' => array(
          'class' => array(
            'links',
            'inline',
          ),
        ),
      );

      // Move to bottom of content for non-nodes; the standard node template already does this
      if ($entity_type != 'node') {
        $entity->content['links']['#weight'] = $default_weight;
      }
    }
    else {
      $entity_wrapper = entity_metadata_wrapper($entity_type, $entity);
      $output = drupal_get_form('forward_form', NULL, $entity_wrapper, TRUE);
      $entity->content['forward'] = $output;

      // Move to bottom of content for non-nodes; the standard node template already does this
      if ($entity_type != 'node') {
        $entity->content['forward']['#weight'] = $default_weight;
      }
    }
  }
}