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

Line #Times calledCode
1
<?php
2
// $Id: translation.pages.inc,v 1.3 2008/04/14 17:48:42 dries 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
 */
151
function translation_node_overview($node) {
161
  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.
230
    $tnid = $node->nid;
240
    $translations = array($node->language => $node);
25
  }
26
271
  $header = array(t('Language'), t('Title'), t('Status'),
t('Operations'));
28
291
  foreach (language_list() as $language) {
301
    $options = array();
311
    $language_name = $language->name;
321
    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.
351
      $translation_node =
node_load($translations[$language->language]->nid);
361
      $title = l($translation_node->title, 'node/' .
$translation_node->nid);
371
      if (node_access('update', $translation_node)) {
381
        $options[] = l(t('edit'), "node/$translation_node->nid/edit");
391
      }
401
      $status = $translation_node->status ? t('Published') : t('Not
published');
411
      $status .= $translation_node->translate ? ' - <span class="marker">'
. t('outdated') . '</span>' : '';
421
      if ($translation_node->nid == $tnid) {
431
        $language_name = '<strong>' . $language_name . '</strong>
(source)';
441
      }
451
    }
46
    else {
47
      // No such translation in the set yet: help user to create it.
480
      $title = t('n/a');
490
      if (node_access('create', $node)) {
500
        $options[] = l(t('add translation'), 'node/add/' . str_replace('_',
'-', $node->type), array('query' =>
"translation=$node->nid&language=$language->language"));
510
      }
520
      $status = t('Not translated');
53
    }
541
    $rows[] = array($language_name, $title, $status, implode(" | ",
$options));
551
  }
56
571
  drupal_set_title(t('Translations of %title', array('%title' =>
$node->title)));
581
  return theme('table', $header, $rows);
590
}
601