';
@@ -487,7 +487,7 @@
* Generate an overview table of older revisions of a node.
*/
function node_revision_overview($node) {
- drupal_set_title(t('Revisions for %title', array('%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'])), PASS_THROUGH);
+ drupal_set_title(t('Revisions for %title', array('%title' => node_get_original_title($node))), PASS_THROUGH);
$header = array(t('Revision'), array('data' => t('Operations'), 'colspan' => 2));
@@ -549,8 +549,8 @@
node_save($node_revision);
- watchdog('content', '@type: reverted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title[FIELD_LANGUAGE_NONE][0]['value'], '%revision' => $node_revision->vid));
- drupal_set_message(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => node_type_get_name($node_revision), '%title' => $node_revision->title[FIELD_LANGUAGE_NONE][0]['value'], '%revision-date' => format_date($node_revision->revision_timestamp))));
+ watchdog('content', '@type: reverted %title revision %revision.', array('@type' => $node_revision->type, '%title' => node_get_original_title($node_revision), '%revision' => $node_revision->vid));
+ drupal_set_message(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => node_type_get_name($node_revision), '%title' => node_get_original_title($node_revision), '%revision-date' => format_date($node_revision->revision_timestamp))));
$form_state['redirect'] = 'node/' . $node_revision->nid . '/revisions';
}
@@ -563,8 +563,8 @@
$node_revision = $form['#node_revision'];
node_revision_delete($node_revision->vid);
- watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title[FIELD_LANGUAGE_NONE][0]['value'], '%revision' => $node_revision->vid));
- drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($node_revision->revision_timestamp), '@type' => node_type_get_name($node_revision), '%title' => $node_revision->title[FIELD_LANGUAGE_NONE][0]['value'])));
+ watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => node_get_original_title($node_revision), '%revision' => $node_revision->vid));
+ drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($node_revision->revision_timestamp), '@type' => node_type_get_name($node_revision), '%title' => node_get_original_title($node_revision))));
$form_state['redirect'] = 'node/' . $node_revision->nid;
if (db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid', array(':nid' => $node_revision->nid))->fetchField() > 1) {
$form_state['redirect'] .= '/revisions';
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1145
diff -u -r1.1145 node.module
--- modules/node/node.module 11 Oct 2009 03:07:18 -0000 1.1145
+++ modules/node/node.module 14 Oct 2009 17:35:15 -0000
@@ -578,6 +578,7 @@
$field = array(
'field_name' => 'title',
'type' => 'text',
+ 'translatable' => TRUE,
);
$field = field_create_field($field);
}
@@ -935,8 +936,7 @@
// column. After this we restore the field data structure to the previous node
// title field.
$title_field = $node->title;
- $langcode = FIELD_LANGUAGE_NONE;
- $node->title = $title_field[$langcode][0]['value'];
+ $node->title = node_get_original_title($node);
// Generate the node table query and the node_revisions table query.
if ($node->is_new) {
@@ -1157,7 +1157,7 @@
$links['node_readmore'] = array(
'title' => t('Read more'),
'href' => 'node/' . $node->nid,
- 'attributes' => array('rel' => 'tag', 'title' => strip_tags($node->title[FIELD_LANGUAGE_NONE][0]['value']))
+ 'attributes' => array('rel' => 'tag', 'title' => strip_tags(node_get_translated_title($node)))
);
}
$node->content['links']['node'] = array(
@@ -1231,7 +1231,7 @@
*/
function node_show($node, $message = FALSE) {
if ($message) {
- drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'], '%date' => format_date($node->revision_timestamp))), PASS_THROUGH);
+ drupal_set_title(t('Revision of %title from %date', array('%title' => node_get_original_title($node), '%date' => format_date($node->revision_timestamp))), PASS_THROUGH);
}
// Update the history table, stating that this user viewed this node.
@@ -1265,7 +1265,7 @@
$variables['date'] = format_date($node->created);
$variables['name'] = theme('username', array('account' => $node));
$variables['node_url'] = url('node/' . $node->nid);
- $variables['node_title'] = check_plain($node->title[FIELD_LANGUAGE_NONE][0]['value']);
+ $variables['node_title'] = check_plain(node_get_translated_title($node));
$variables['page'] = (bool)menu_get_object();
if (!empty($node->in_preview)) {
@@ -1515,7 +1515,7 @@
$results[] = array(
'link' => url('node/' . $item->sid, array('absolute' => TRUE)),
'type' => check_plain(node_type_get_name($node)),
- 'title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'],
+ 'title' => node_get_translated_title($node),
'user' => theme('username', array('account' => $node)),
'date' => $node->changed,
'node' => $node,
@@ -1997,7 +1997,7 @@
$item_text .= drupal_render($node->content) . $links;
}
- $items .= format_rss_item($node->title[FIELD_LANGUAGE_NONE][0]['value'], $node->link, $item_text, $node->rss_elements);
+ $items .= format_rss_item(node_get_translated_title($node), $node->link, $item_text, $node->rss_elements);
}
$channel_defaults = array(
@@ -2135,7 +2135,7 @@
node_build_content($node, 'search_index');
$node->rendered = drupal_render($node->content);
- $text = '' . check_plain($node->title[FIELD_LANGUAGE_NONE][0]['value']) . '
' . $node->rendered;
+ $text = '' . check_plain(node_get_translated_title($node)) . '
' . $node->rendered;
// Fetch extra data normally not visible
$extra = module_invoke_all('node_update_index', $node);
@@ -2979,7 +2979,7 @@
*/
function node_publish_action($node, $context = array()) {
$node->status = NODE_PUBLISHED;
- watchdog('action', 'Set @type %title to published.', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
+ watchdog('action', 'Set @type %title to published.', array('@type' => node_type_get_name($node), '%title' => node_get_original_title($node)));
}
/**
@@ -2988,7 +2988,7 @@
*/
function node_unpublish_action($node, $context = array()) {
$node->status = NODE_NOT_PUBLISHED;
- watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
+ watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => node_get_original_title($node)));
}
/**
@@ -2997,7 +2997,7 @@
*/
function node_make_sticky_action($node, $context = array()) {
$node->sticky = NODE_STICKY;
- watchdog('action', 'Set @type %title to sticky.', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
+ watchdog('action', 'Set @type %title to sticky.', array('@type' => node_type_get_name($node), '%title' => node_get_original_title($node)));
}
/**
@@ -3006,7 +3006,7 @@
*/
function node_make_unsticky_action($node, $context = array()) {
$node->sticky = NODE_NOT_STICKY;
- watchdog('action', 'Set @type %title to unsticky.', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
+ watchdog('action', 'Set @type %title to unsticky.', array('@type' => node_type_get_name($node), '%title' => node_get_original_title($node)));
}
/**
@@ -3015,7 +3015,7 @@
*/
function node_promote_action($node, $context = array()) {
$node->promote = NODE_PROMOTED;
- watchdog('action', 'Promoted @type %title to front page.', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
+ watchdog('action', 'Promoted @type %title to front page.', array('@type' => node_type_get_name($node), '%title' => node_get_original_title($node)));
}
/**
@@ -3024,7 +3024,7 @@
*/
function node_unpromote_action($node, $context = array()) {
$node->promote = NODE_NOT_PROMOTED;
- watchdog('action', 'Removed @type %title from front page.', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
+ watchdog('action', 'Removed @type %title from front page.', array('@type' => node_type_get_name($node), '%title' => node_get_original_title($node)));
}
/**
@@ -3033,7 +3033,7 @@
*/
function node_save_action($node) {
node_save($node);
- watchdog('action', 'Saved @type %title', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
+ watchdog('action', 'Saved @type %title', array('@type' => node_type_get_name($node), '%title' => node_get_original_title($node)));
}
/**
@@ -3043,7 +3043,7 @@
function node_assign_owner_action($node, $context) {
$node->uid = $context['owner_uid'];
$owner_name = db_query("SELECT name FROM {users} WHERE uid = :uid", array(':uid' => $context['owner_uid']))->fetchField();
- watchdog('action', 'Changed owner of @type %title to uid %name.', array('@type' => node_type_get_type($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'], '%name' => $owner_name));
+ watchdog('action', 'Changed owner of @type %title to uid %name.', array('@type' => node_type_get_type($node), '%title' => node_get_original_title($node), '%name' => $owner_name));
}
function node_assign_owner_action_form($context) {
@@ -3124,7 +3124,7 @@
foreach ($context['keywords'] as $keyword) {
if (strpos(drupal_render(node_build(clone $node)), $keyword) !== FALSE || strpos($node->title, $keyword) !== FALSE) {
$node->status = NODE_NOT_PUBLISHED;
- watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']));
+ watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => node_get_original_title($node)));
break;
}
}
@@ -3156,6 +3156,26 @@
return $requirements;
}
+function node_get_original_title($node) {
+ if (isset($node->language)) {
+ $langcode = field_multilingual_valid_language($node->language);
+ }
+ else {
+ $langcode = FIELD_LANGUAGE_NONE;
+ }
+ return $node->title[$langcode][0]['value'];
+}
+
+function node_get_translated_title($node) {
+ if (! isset($node->content['title'])) {
+ $content = node_build($node, 'full');
+ }
+ else {
+ $content = $node->content;
+ }
+ return $content['title']['items'][0]['#item']['value'];
+}
+
/**
* Controller class for nodes.
*
Index: modules/node/node.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v
retrieving revision 1.71
diff -u -r1.71 node.admin.inc
--- modules/node/node.admin.inc 11 Oct 2009 03:07:18 -0000 1.71
+++ modules/node/node.admin.inc 14 Oct 2009 17:35:14 -0000
@@ -339,7 +339,7 @@
$node = _node_mass_update_helper($nid, $updates);
// Store result for post-processing in the finished callback.
- $context['results'][] = l($node->title[FIELD_LANGUAGE_NONE][0]['value'], 'node/' . $node->nid);
+ $context['results'][] = l(node_get_original_title($node), 'node/' . $node->nid);
// Update our progress information.
$context['sandbox']['progress']++;
Index: modules/poll/poll.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v
retrieving revision 1.317
diff -u -r1.317 poll.module
--- modules/poll/poll.module 11 Oct 2009 03:07:19 -0000 1.317
+++ modules/poll/poll.module 14 Oct 2009 17:35:17 -0000
@@ -708,7 +708,7 @@
function template_preprocess_poll_vote(&$variables) {
$form = $variables['form'];
$variables['choice'] = drupal_render($form['choice']);
- $variables['title'] = check_plain($form['#node']->title[FIELD_LANGUAGE_NONE][0]['value']);
+ $variables['title'] = check_plain(node_get_translated_title($form['#node']));
$variables['vote'] = drupal_render($form['vote']);
$variables['rest'] = drupal_render_children($form);
$variables['block'] = $form['#block'];
@@ -740,7 +740,7 @@
}
}
- return theme('poll_results', array('raw_title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'], 'results' => $poll_results, 'votes' => $total_votes, 'raw_links' => isset($node->links) ? $node->links : array(), 'block' => $block, 'nid' => $node->nid, 'vote' => isset($node->vote) ? $node->vote : NULL));
+ return theme('poll_results', array('raw_title' => node_get_original_title($node), 'results' => $poll_results, 'votes' => $total_votes, 'raw_links' => isset($node->links) ? $node->links : array(), 'block' => $block, 'nid' => $node->nid, 'vote' => isset($node->vote) ? $node->vote : NULL));
}
Index: modules/poll/poll.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.pages.inc,v
retrieving revision 1.22
diff -u -r1.22 poll.pages.inc
--- modules/poll/poll.pages.inc 11 Oct 2009 03:07:19 -0000 1.22
+++ modules/poll/poll.pages.inc 14 Oct 2009 17:35:17 -0000
@@ -51,7 +51,7 @@
*/
function poll_votes($node) {
$votes_per_page = 20;
- drupal_set_title($node->title[FIELD_LANGUAGE_NONE][0]['value']);
+ drupal_set_title(node_get_translated_title($node));
$header[] = array('data' => t('Visitor'), 'field' => 'u.name');
$header[] = array('data' => t('Vote'), 'field' => 'pc.chtext');
@@ -91,7 +91,7 @@
* Callback for the 'results' tab for polls you can vote on
*/
function poll_results($node) {
- drupal_set_title($node->title[FIELD_LANGUAGE_NONE][0]['value']);
+ drupal_set_title(node_get_translated_title($node));
$node->show_results = TRUE;
return node_show($node);
}
Index: modules/book/book.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.admin.inc,v
retrieving revision 1.24
diff -u -r1.24 book.admin.inc
--- modules/book/book.admin.inc 11 Oct 2009 03:07:16 -0000 1.24
+++ modules/book/book.admin.inc 14 Oct 2009 17:35:12 -0000
@@ -78,7 +78,7 @@
* @ingroup forms.
*/
function book_admin_edit($form, $form_state, $node) {
- drupal_set_title($node->title[FIELD_LANGUAGE_NONE][0]['value']);
+ drupal_set_title(node_get_original_title($node));
$form['#node'] = $node;
_book_admin_table($node, $form);
$form['save'] = array(
@@ -131,7 +131,7 @@
// Update the title if changed.
if ($row['title']['#default_value'] != $values['title']) {
$node = node_load($values['nid'], FALSE);
- $langcode = FIELD_LANGUAGE_NONE;
+ $langcode = field_multilingual_valid_language($node->language);
$node->title = array($langcode => array(array('value' => $values['title'])));
$node->book['link_title'] = $values['title'];
$node->revision = 1;
Index: modules/book/book.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.pages.inc,v
retrieving revision 1.18
diff -u -r1.18 book.pages.inc
--- modules/book/book.pages.inc 11 Oct 2009 03:07:17 -0000 1.18
+++ modules/book/book.pages.inc 14 Oct 2009 17:35:13 -0000
@@ -90,7 +90,7 @@
* Menu callback; show the outline form for a single node.
*/
function book_outline($node) {
- drupal_set_title($node->title[FIELD_LANGUAGE_NONE][0]['value']);
+ drupal_set_title(node_get_original_title($node));
return drupal_get_form('book_outline_form', $node);
}
@@ -188,7 +188,7 @@
*/
function book_remove_form($form, &$form_state, $node) {
$form['#node'] = $node;
- $title = array('%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']);
+ $title = array('%title' => node_get_original_title($node));
if ($node->book['has_children']) {
$description = t('%title has associated child pages, which will be relocated automatically to maintain their connection to the book. To recreate the hierarchy (as it was before removing this page), %title may be added again using the Outline tab, and each of its former child pages will need to be relocated manually.', $title);
Index: modules/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.518
diff -u -r1.518 book.module
--- modules/book/book.module 11 Oct 2009 03:07:17 -0000 1.518
+++ modules/book/book.module 14 Oct 2009 17:35:13 -0000
@@ -477,7 +477,7 @@
if (isset($node->nid) && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) {
// This is the top level node in a maximum depth book and thus cannot be moved.
- $options[$node->nid] = $node->title[FIELD_LANGUAGE_NONE][0]['value'];
+ $options[$node->nid] = node_get_original_title($node);
}
else {
foreach (book_get_books() as $book) {
@@ -526,7 +526,7 @@
$new = empty($node->book['mlid']);
$node->book['link_path'] = 'node/' . $node->nid;
- $node->book['link_title'] = $node->title[FIELD_LANGUAGE_NONE][0]['value'];
+ $node->book['link_title'] = node_get_original_title($node);
$node->book['parent_mismatch'] = FALSE; // The normal case.
if ($node->book['bid'] == $node->nid) {
@@ -882,7 +882,7 @@
if (isset($node->book) && $node->book['has_children']) {
$form['book_warning'] = array(
- '#markup' => '' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', array('%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'])) . '
',
+ '#markup' => '' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', array('%title' => node_get_original_title($node))) . '
',
'#weight' => -10,
);
}
@@ -1103,7 +1103,7 @@
*/
function template_preprocess_book_node_export_html(&$variables) {
$variables['depth'] = $variables['node']->book['depth'];
- $variables['title'] = check_plain($variables['node']->title[FIELD_LANGUAGE_NONE][0]['value']);
+ $variables['title'] = check_plain(node_get_translated_title($variables['node']));
$variables['content'] = $variables['node']->rendered;
}
Index: modules/translation/translation.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/translation/translation.test,v
retrieving revision 1.19
diff -u -r1.19 translation.test
--- modules/translation/translation.test 11 Oct 2009 03:07:21 -0000 1.19
+++ modules/translation/translation.test 14 Oct 2009 17:35:17 -0000
@@ -129,7 +129,7 @@
function createPage($title, $body, $language) {
$edit = array();
$langcode = FIELD_LANGUAGE_NONE;
- $edit["title[$langcode][0][value]"] = $title;
+ $edit["title[$language][0][value]"] = $title;
$edit["body[$langcode][0][value]"] = $body;
$edit['language'] = $language;
$this->drupalPost('node/add/page', $edit, t('Save'));
Index: modules/translation/translation.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/translation/translation.pages.inc,v
retrieving revision 1.10
diff -u -r1.10 translation.pages.inc
--- modules/translation/translation.pages.inc 11 Oct 2009 03:07:21 -0000 1.10
+++ modules/translation/translation.pages.inc 14 Oct 2009 17:35:17 -0000
@@ -33,7 +33,7 @@
// 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);
- $title = l($translation_node->title[FIELD_LANGUAGE_NONE][0]['value'], 'node/' . $translation_node->nid);
+ $title = l(node_get_original_title($translation_node), 'node/' . $translation_node->nid);
if (node_access('update', $translation_node)) {
$options[] = l(t('edit'), "node/$translation_node->nid/edit");
}
@@ -54,7 +54,7 @@
$rows[] = array($language_name, $title, $status, implode(" | ", $options));
}
- drupal_set_title(t('Translations of %title', array('%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'])), PASS_THROUGH);
+ drupal_set_title(t('Translations of %title', array('%title' => node_get_original_title($node))), PASS_THROUGH);
$build['translation_node_overview'] = array(
'#theme' => 'table',
Index: modules/translation/translation.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/translation/translation.module,v
retrieving revision 1.62
diff -u -r1.62 translation.module
--- modules/translation/translation.module 11 Oct 2009 03:07:21 -0000 1.62
+++ modules/translation/translation.module 14 Oct 2009 17:35:17 -0000
@@ -202,7 +202,7 @@
$translations = translation_node_get_translations($source_node->tnid);
if (isset($translations[$language])) {
$languages = language_list();
- drupal_set_message(t('A translation of %title in %language already exists, a new %type will be created instead of a translation.', array('%title' => $source_node->title[FIELD_LANGUAGE_NONE][0]['value'], '%language' => $languages[$language]->name, '%type' => $node->type)), 'error');
+ drupal_set_message(t('A translation of %title in %language already exists, a new %type will be created instead of a translation.', array('%title' => node_get_original_title($source_node), '%language' => $languages[$language]->name, '%type' => $node->type)), 'error');
return;
}
}
Index: modules/system/system.tokens.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.tokens.inc,v
retrieving revision 1.4
diff -u -r1.4 system.tokens.inc
--- modules/system/system.tokens.inc 11 Oct 2009 03:07:20 -0000 1.4
+++ modules/system/system.tokens.inc 14 Oct 2009 17:35:17 -0000
@@ -283,7 +283,7 @@
case 'node':
if ($nid = $file->nid) {
$node = node_load($file->nid);
- $replacements[$original] = $sanitize ? filter_xss($node->title[FIELD_LANGUAGE_NONE][0]['value']) : $node->title[FIELD_LANGUAGE_NONE][0]['value'];
+ $replacements[$original] = $sanitize ? filter_xss(node_get_original_title($node)) : node_get_original_title($node);
}
break;