Code coverage for /20081101/modules/translation/translation.pages.inc

Line #Times calledCode
1
<?php
2
// $Id: translation.pages.inc,v 1.7 2008/10/13 00:33:05 webchick Exp $
3
4
/**
5
 * @file
6
 * User page callbacks for the translation module.
7
 */
8
9
/**
10
 * Overview page for a node's translations.
11
 *
12
 * @param $node
13
 *   Node object.
14
 */
152
function translation_node_overview($node) {
162
  if ($node->tnid) {
17
    // Already part of a set, grab that set.
181
    $tnid = $node->tnid;
191
    $translations = translation_node_get_translations($node->tnid);
201
  }
21
  else {
22
    // We have no translation source nid, this could be a new set, emulate
that.
231
    $tnid = $node->nid;
241
    $translations = array($node->language => $node);
25
  }
26
272
  $header = array(t('Language'), t('Title'), t('Status'), t('Operations'));
28
292
  foreach (language_list() as $language) {
302
    $options = array();
312
    $language_name = $language->name;
322
    if (isset($translations[$language->language])) {
33
      // Existing translation in the translation set: display status.
34
      // We load the full node to check whether the user can edit it.
352
      $translation_node =
node_load($translations[$language->language]->nid);
362
      $title = l($translation_node->title, 'node/' .
$translation_node->nid);
372
      if (node_access('update', $translation_node)) {
382
        $options[] = l(t('edit'), "node/$translation_node->nid/edit");
392
      }
402
      $status = $translation_node->status ? t('Published') : t('Not
published');
412
      $status .= $translation_node->translate ? ' - <span class="marker">'
. t('outdated') . '</span>' : '';
422
      if ($translation_node->nid == $tnid) {
432
        $language_name = t('<strong>@language_name</strong> (source)',
array('@language_name' => $language_name));
442
      }
452
    }
46
    else {
47
      // No such translation in the set yet: help user to create it.
481
      $title = t('n/a');
491
      if (node_access('create', $node)) {
501
        $options[] = l(t('add translation'), 'node/add/' . str_replace('_',
'-', $node->type), array('query' =>
"translation=$node->nid&language=$language->language"));
511
      }
521
      $status = t('Not translated');
53
    }
542
    $rows[] = array($language_name, $title, $status, implode(" | ",
$options));
552
  }
56
572
  drupal_set_title(t('Translations of %title', array('%title' =>
$node->title)), PASS_THROUGH);
582
  return theme('table', $header, $rows);
590
}
602