You are here

function translation_overview_translation_link in Translation Overview 6.2

Same name and namespace in other branches
  1. 6 translation_overview.module \translation_overview_translation_link()

Build a link to the translated node.

Parameters

$node Source node object:

$translation_node Optional, translated node.:

$language Language code.:

$show_long Boolean, indicating if a longer version of the text should: be displayed.

Return value

Link to the node if the user has permission or else just text.

3 calls to translation_overview_translation_link()
translation_overview_assignment_page in ./translation_overview.pages.inc
translation_overview_manager_page in ./translation_overview.pages.inc
Translation overview page.
translation_overview_node_form in ./translation_overview.pages.inc
Overview page for a node's translations.

File

./translation_overview.module, line 260

Code

function translation_overview_translation_link($node, $translation_node = NULL, $language, $show_long = FALSE) {
  $link = array(
    'path' => 'node/' . $node->nid,
    'options' => array(),
  );
  $priorities = translation_overview_get_node_priority($node);
  $properties = array(
    'priority' => isset($priorities[$language]) ? $priorities[$language] : TRANSLATION_OVERVIEW_NORMAL,
    'published' => $node->status,
    'show_long' => $show_long,
    'has_note' => FALSE,
  );
  if ($language == $node->language) {
    $properties['has_note'] = !empty($node->field_translator_note[0]['value']);
    return theme('translation_overview_translation_link', 'original', $link, $properties);
  }

  // Determine the status of the translation.
  if (!empty($translation_node->nid)) {
    $properties['has_note'] = !empty($translation_node->field_translator_note[0]['value']);
    if (node_access('update', $translation_node)) {
      $link['path'] = "node/{$translation_node->nid}/edit";
      $link['options']['query'] = drupal_get_destination();
    }
    else {
      $link['path'] = 'node/' . $translation_node->nid;
    }
    if ($translation_node->translate) {
      return theme('translation_overview_translation_link', 'outofdate', $link, $properties);
    }
    return theme('translation_overview_translation_link', 'current', $link, $properties);
  }

  // Assume it's missing, see if we can create a translation.
  if (node_access('create', $node)) {
    $link['path'] = 'node/add/' . str_replace('_', '-', $node->type);
    $link['options']['query'] = array(
      'destination' => $_GET['q'],
      'translation' => $node->nid,
      'language' => $language,
    );
  }
  else {
    $link = array();
  }
  return theme('translation_overview_translation_link', 'missing', $link, $properties);
}