You are here

function translation_overview_translation_link in Translation Overview 6

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

Build a link to the translated node.

Parameters

$node Source node object:

$translation_nid Id of the 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.

2 calls to translation_overview_translation_link()
translation_overview_language_page in ./translation_overview.pages.inc
translation_overview_overview_page in ./translation_overview.pages.inc
Translation overview page.

File

./translation_overview.module, line 93

Code

function translation_overview_translation_link($node, $translation_nid, $language, $show_long = FALSE) {
  $path = 'node/' . $node->nid;
  $options = array();
  if ($language == $node->language) {
    return theme('translation_overview_translation_link', 'original', $path, $options, $show_long);
  }
  if (!empty($translation_nid)) {

    // Determine the status of the translation.
    $tnode = node_load($translation_nid);
    if ($tnode->nid) {
      if (node_access('update', $tnode)) {
        $path = "node/{$tnode->nid}/edit";
        $options['query'] = array(
          'destination' => $_GET['q'],
        );
      }
      else {
        $path = 'node/' . $tnode->nid;
      }
      if ($tnode->translate == 0) {
        return theme('translation_overview_translation_link', 'current', $path, $options, $show_long);
      }
      return theme('translation_overview_translation_link', 'outofdate', $path, $options, $show_long);
    }
  }

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