translation.pages.inc

User page callbacks for the translation module.

Archivo

drupal-6.x/modules/translation/translation.pages.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * User page callbacks for the translation module.
  5. */
  6. /**
  7. * Overview page for a node's translations.
  8. *
  9. * @param $node
  10. * Node object.
  11. */
  12. function translation_node_overview($node) {
  13. if ($node->tnid) {
  14. // Already part of a set, grab that set.
  15. $tnid = $node->tnid;
  16. $translations = translation_node_get_translations($node->tnid);
  17. }
  18. else {
  19. // We have no translation source nid, this could be a new set, emulate that.
  20. $tnid = $node->nid;
  21. $translations = array($node->language => $node);
  22. }
  23. $header = array(t('Language'), t('Title'), t('Status'), t('Operations'));
  24. foreach (language_list() as $language) {
  25. $options = array();
  26. $language_name = $language->name;
  27. if (isset($translations[$language->language])) {
  28. // Existing translation in the translation set: display status.
  29. // We load the full node to check whether the user can edit it.
  30. $translation_node = node_load($translations[$language->language]->nid);
  31. $title = l($translation_node->title, 'node/'. $translation_node->nid);
  32. if (node_access('update', $translation_node)) {
  33. $options[] = l(t('edit'), "node/$translation_node->nid/edit");
  34. }
  35. $status = $translation_node->status ? t('Published') : t('Not published');
  36. $status .= $translation_node->translate ? ' - <span class="marker">'. t('outdated') .'</span>' : '';
  37. if ($translation_node->nid == $tnid) {
  38. $language_name = t('<strong>@language_name</strong> (source)', array('@language_name' => $language_name));
  39. }
  40. }
  41. else {
  42. // No such translation in the set yet: help user to create it.
  43. $title = t('n/a');
  44. if (node_access('create', $node)) {
  45. $options[] = l(t('add translation'), 'node/add/'. str_replace('_', '-', $node->type), array('query' => "translation=$node->nid&language=$language->language"));
  46. }
  47. $status = t('Not translated');
  48. }
  49. $rows[] = array($language_name, $title, $status, implode(" | ", $options));
  50. }
  51. drupal_set_title(t('Translations of %title', array('%title' => $node->title)));
  52. return theme('table', $header, $rows);
  53. }

Functions

Nombreorden descendente Descripción
translation_node_overview Overview page for a node's translations.