You are here

function domain_source_node_view in Domain Access 7.2

Same name and namespace in other branches
  1. 7.3 domain_source/domain_source.module \domain_source_node_view()

Implements hook_node_view()

Display debugging information for a node.

File

domain_source/domain_source.module, line 233
Creates a source domain for linking to content from other domains.

Code

function domain_source_node_view($node, $view_mode) {
  if (empty($node->nid) || !in_array($view_mode, array(
    'full',
    'teaser',
  ))) {
    return;
  }
  if (variable_get('domain_debug', 0) && user_access('set domain access') && isset($node->domain_source)) {
    $source = domain_get_node_match($node->nid);
    $extra = ' ';
    $use_active = db_query("SELECT domain_id FROM {domain_source} WHERE nid = :nid", array(
      ':nid' => $node->nid,
    ))
      ->fetchField();
    if ($use_active === FALSE) {
      $extra .= t('(determined automatically)');
    }
    elseif ($use_active == DOMAIN_SOURCE_USE_ACTIVE) {
      $extra .= t('(using active domain)');
    }
    if (!isset($node->content['domain']['#markup'])) {
      $node->content['domain']['#markup'] = '';
    }
    $node->content['domain']['#markup'] .= '<p>' . t('<strong>Source domain</strong>: %source', array(
      '%source' => $source['sitename'],
    )) . $extra . '</p>';
  }
}