2007-10-16 09:15:19 +00:00
|
|
|
<?php
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* User page callbacks for the translation module.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Overview page for a node's translations.
|
|
|
|
*
|
|
|
|
* @param $node
|
|
|
|
* Node object.
|
|
|
|
*/
|
2009-11-08 10:02:41 +00:00
|
|
|
function translation_node_overview($node) {
|
2007-10-16 09:15:19 +00:00
|
|
|
if ($node->tnid) {
|
|
|
|
// Already part of a set, grab that set.
|
|
|
|
$tnid = $node->tnid;
|
|
|
|
$translations = translation_node_get_translations($node->tnid);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// We have no translation source nid, this could be a new set, emulate that.
|
|
|
|
$tnid = $node->nid;
|
|
|
|
$translations = array($node->language => $node);
|
|
|
|
}
|
|
|
|
|
|
|
|
$header = array(t('Language'), t('Title'), t('Status'), t('Operations'));
|
|
|
|
|
|
|
|
foreach (language_list() as $language) {
|
|
|
|
$options = array();
|
|
|
|
$language_name = $language->name;
|
|
|
|
if (isset($translations[$language->language])) {
|
|
|
|
// Existing translation in the translation set: display status.
|
|
|
|
// We load the full node to check whether the user can edit it.
|
|
|
|
$translation_node = node_load($translations[$language->language]->nid);
|
2009-12-02 19:26:23 +00:00
|
|
|
$title = l($translation_node->title[LANGUAGE_NONE][0]['value'], 'node/' . $translation_node->nid);
|
2007-10-16 09:15:19 +00:00
|
|
|
if (node_access('update', $translation_node)) {
|
|
|
|
$options[] = l(t('edit'), "node/$translation_node->nid/edit");
|
|
|
|
}
|
|
|
|
$status = $translation_node->status ? t('Published') : t('Not published');
|
2008-04-14 17:48:46 +00:00
|
|
|
$status .= $translation_node->translate ? ' - <span class="marker">' . t('outdated') . '</span>' : '';
|
2007-10-16 09:15:19 +00:00
|
|
|
if ($translation_node->nid == $tnid) {
|
2008-10-01 13:19:29 +00:00
|
|
|
$language_name = t('<strong>@language_name</strong> (source)', array('@language_name' => $language_name));
|
2007-10-16 09:15:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// No such translation in the set yet: help user to create it.
|
|
|
|
$title = t('n/a');
|
|
|
|
if (node_access('create', $node)) {
|
2009-09-29 15:31:17 +00:00
|
|
|
$options[] = l(t('add translation'), 'node/add/' . str_replace('_', '-', $node->type), array('query' => array('translation' => $node->nid, 'language' => $language->language)));
|
2007-10-16 09:15:19 +00:00
|
|
|
}
|
|
|
|
$status = t('Not translated');
|
|
|
|
}
|
|
|
|
$rows[] = array($language_name, $title, $status, implode(" | ", $options));
|
|
|
|
}
|
|
|
|
|
2009-12-02 19:26:23 +00:00
|
|
|
drupal_set_title(t('Translations of %title', array('%title' => $node->title[LANGUAGE_NONE][0]['value'])), PASS_THROUGH);
|
2009-07-29 06:39:35 +00:00
|
|
|
|
|
|
|
$build['translation_node_overview'] = array(
|
|
|
|
'#theme' => 'table',
|
|
|
|
'#header' => $header,
|
|
|
|
'#rows' => $rows,
|
|
|
|
);
|
|
|
|
|
|
|
|
return $build;
|
2007-10-16 09:15:19 +00:00
|
|
|
}
|