web/drupal/modules/translation/translation.pages.inc
branchdrupal
changeset 74 0ff3ba646492
equal deleted inserted replaced
73:fcf75e232c5b 74:0ff3ba646492
       
     1 <?php
       
     2 // $Id: translation.pages.inc,v 1.2.2.1 2008/09/30 10:50:43 goba 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  */
       
    15 function translation_node_overview($node) {
       
    16   if ($node->tnid) {
       
    17     // Already part of a set, grab that set.
       
    18     $tnid = $node->tnid;
       
    19     $translations = translation_node_get_translations($node->tnid);
       
    20   }
       
    21   else {
       
    22     // We have no translation source nid, this could be a new set, emulate that.
       
    23     $tnid = $node->nid;
       
    24     $translations = array($node->language => $node);
       
    25   }
       
    26 
       
    27   $header = array(t('Language'), t('Title'), t('Status'), t('Operations'));
       
    28 
       
    29   foreach (language_list() as $language) {
       
    30     $options = array();
       
    31     $language_name = $language->name;
       
    32     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.
       
    35       $translation_node = node_load($translations[$language->language]->nid);
       
    36       $title = l($translation_node->title, 'node/'. $translation_node->nid);
       
    37       if (node_access('update', $translation_node)) {
       
    38         $options[] = l(t('edit'), "node/$translation_node->nid/edit");
       
    39       }
       
    40       $status = $translation_node->status ? t('Published') : t('Not published');
       
    41       $status .= $translation_node->translate ? ' - <span class="marker">'. t('outdated') .'</span>' : '';
       
    42       if ($translation_node->nid == $tnid) {
       
    43         $language_name = t('<strong>@language_name</strong> (source)', array('@language_name' => $language_name));
       
    44       }
       
    45     }
       
    46     else {
       
    47       // No such translation in the set yet: help user to create it.
       
    48       $title = t('n/a');
       
    49       if (node_access('create', $node)) {
       
    50         $options[] = l(t('add translation'), 'node/add/'. str_replace('_', '-', $node->type), array('query' => "translation=$node->nid&language=$language->language"));
       
    51       }
       
    52       $status = t('Not translated');
       
    53     }
       
    54     $rows[] = array($language_name, $title, $status, implode(" | ", $options));
       
    55   }
       
    56 
       
    57   drupal_set_title(t('Translations of %title', array('%title' => $node->title)));
       
    58   return theme('table', $header, $rows);
       
    59 }