You are here

function pay_node_node_view in Pay 7

Implements hook_node_view().

File

modules/pay_node/pay_node.module, line 84

Code

function pay_node_node_view($node, $view_mode = 'full') {

  // Add the payment acceptance form to the node display.
  // Determine the selected theme function for this node type.
  if ($view_mode == 'teaser') {
    $theme = variable_get('pay_node_display_teaser_' . $node->type, '');
  }
  else {
    $theme = variable_get('pay_node_display_' . $node->type, 'pay_form_default');
  }

  // Do not include anything for 'tab' or empty functions (hidden).
  if (in_array($theme, array(
    '',
    'tab',
  ))) {
    return;
  }

  // Add the pay_form's content to the node display.
  if (isset($node->pay_form->pfid)) {
    if (function_exists('content_extra_field_weight')) {
      $weight = content_extra_field_weight($node->type, 'pay_node');
    }
    else {
      $weight = 25;
    }

    // TODO Please change this theme call to use an associative array for the $variables parameter.
    $node->content['pay_node'] = array(
      '#type' => 'markup',
      '#value' => theme($theme, $node->pay_form),
      '#weight' => $weight,
    );
  }
}