Index: modules/aggregator/aggregator.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.test,v
retrieving revision 1.31
diff -u -p -r1.31 aggregator.test
--- modules/aggregator/aggregator.test 24 Aug 2009 17:11:42 -0000 1.31
+++ modules/aggregator/aggregator.test 31 Aug 2009 13:59:45 -0000
@@ -252,7 +252,7 @@ EOF;
// Post 5 articles.
for ($i = 0; $i < 5; $i++) {
$edit = array();
- $edit['title'] = $this->randomName();
+ $edit["title[$langcode][0][value]"] = $this->randomName();
$edit["body[$langcode][0][value]"] = $this->randomName();
$this->drupalPost('node/add/article', $edit, t('Save'));
}
Index: modules/blog/blog.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog/blog.test,v
retrieving revision 1.18
diff -u -p -r1.18 blog.test
--- modules/blog/blog.test 22 Aug 2009 00:58:52 -0000 1.18
+++ modules/blog/blog.test 31 Aug 2009 13:59:45 -0000
@@ -151,16 +151,16 @@ class BlogTestCase extends DrupalWebTest
if ($response == 200) {
// Edit blog node.
$edit = array();
- $edit['title'] = 'node/' . $node->nid;
$langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = 'node/' . $node->nid;
$edit["body[$langcode][0][value]"] = $this->randomName(256);
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
- $this->assertRaw(t('Blog entry %title has been updated.', array('%title' => $edit['title'])), t('Blog node was edited'));
+ $this->assertRaw(t('Blog entry %title has been updated.', array('%title' => $edit["title[$langcode][0][value]"])), t('Blog node was edited'));
// Delete blog node.
$this->drupalPost('node/' . $node->nid . '/delete', array(), t('Delete'));
$this->assertResponse($response);
- $this->assertRaw(t('Blog entry %title has been deleted.', array('%title' => $edit['title'])), t('Blog node was deleted'));
+ $this->assertRaw(t('Blog entry %title has been deleted.', array('%title' => $edit["title[$langcode][0][value]"])), t('Blog node was deleted'));
}
}
Index: modules/book/book.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.admin.inc,v
retrieving revision 1.21
diff -u -p -r1.21 book.admin.inc
--- modules/book/book.admin.inc 22 Aug 2009 14:34:18 -0000 1.21
+++ modules/book/book.admin.inc 31 Aug 2009 15:08:11 -0000
@@ -78,7 +78,7 @@ function book_admin_settings_validate($f
* @ingroup forms.
*/
function book_admin_edit($form_state, $node) {
- drupal_set_title($node->title);
+ drupal_set_title(node_get_title($node));
$form = array();
$form['#node'] = $node;
_book_admin_table($node, $form);
Index: modules/book/book.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.pages.inc,v
retrieving revision 1.15
diff -u -p -r1.15 book.pages.inc
--- modules/book/book.pages.inc 17 Aug 2009 07:12:15 -0000 1.15
+++ modules/book/book.pages.inc 31 Aug 2009 15:08:11 -0000
@@ -90,7 +90,7 @@ function book_export_html($nid) {
* Menu callback; show the outline form for a single node.
*/
function book_outline($node) {
- drupal_set_title($node->title);
+ drupal_set_title(node_get_title($node));
return drupal_get_form('book_outline_form', $node);
}
Index: modules/book/book.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.test,v
retrieving revision 1.16
diff -u -p -r1.16 book.test
--- modules/book/book.test 24 Aug 2009 01:49:41 -0000 1.16
+++ modules/book/book.test 31 Aug 2009 15:08:11 -0000
@@ -154,7 +154,7 @@ class BookTestCase extends DrupalWebTest
function generateOutlinePattern($nodes) {
$outline = '';
foreach ($nodes as $node) {
- $outline .= '(node\/' . $node->nid . ')(.*?)(' . $node->title . ')(.*?)';
+ $outline .= '(node\/' . $node->nid . ')(.*?)(' . node_get_title($node) . ')(.*?)';
}
return '/
/s';
@@ -172,8 +172,8 @@ class BookTestCase extends DrupalWebTest
static $number = 0; // Used to ensure that when sorted nodes stay in same order.
$edit = array();
- $edit['title'] = $number . ' - SimpleTest test node ' . $this->randomName(10);
$langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = $number . ' - SimpleTest test node ' . $this->randomName(10);
$edit["body[$langcode][0][value]"] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32);
$edit['book[bid]'] = $book_nid;
@@ -188,7 +188,7 @@ class BookTestCase extends DrupalWebTest
}
// Check to make sure the book node was created.
- $node = $this->drupalGetNodeByTitle($edit['title']);
+ $node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$this->assertNotNull(($node === FALSE ? NULL : $node), t('Book node found in database.'));
$number++;
Index: modules/comment/comment.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.pages.inc,v
retrieving revision 1.24
diff -u -p -r1.24 comment.pages.inc
--- modules/comment/comment.pages.inc 1 Aug 2009 05:58:18 -0000 1.24
+++ modules/comment/comment.pages.inc 31 Aug 2009 15:08:11 -0000
@@ -29,7 +29,7 @@
*/
function comment_reply($node, $pid = NULL) {
// Set the breadcrumb trail.
- drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title, 'node/' . $node->nid)));
+ drupal_set_breadcrumb(array(l(t('Home'), NULL), l(node_get_title($node), 'node/' . $node->nid)));
$op = isset($_POST['op']) ? $_POST['op'] : '';
$build = array();
Index: modules/comment/comment.tokens.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.tokens.inc,v
retrieving revision 1.1
diff -u -p -r1.1 comment.tokens.inc
--- modules/comment/comment.tokens.inc 19 Aug 2009 20:19:36 -0000 1.1
+++ modules/comment/comment.tokens.inc 31 Aug 2009 15:08:11 -0000
@@ -205,7 +205,8 @@ function comment_tokens($type, $tokens,
case 'node':
$node = node_load($comment->nid);
- $replacements[$original] = $sanitize ? filter_xss($node->title) : $node->title;
+ $title = node_get_title($node);
+ $replacements[$original] = $sanitize ? filter_xss($title) : $title;
break;
}
}
Index: modules/dblog/dblog.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/dblog/dblog.test,v
retrieving revision 1.28
diff -u -p -r1.28 dblog.test
--- modules/dblog/dblog.test 22 Aug 2009 00:58:52 -0000 1.28
+++ modules/dblog/dblog.test 31 Aug 2009 13:59:45 -0000
@@ -266,7 +266,8 @@ class DBLogTestCase extends DrupalWebTes
// Create node using form to generate add content event (which is not triggered by drupalCreateNode).
$edit = $this->getContent($type);
- $title = $edit['title'];
+ $langcode = FIELD_LANGUAGE_NONE;
+ $title = $edit["title[$langcode][0][value]"];
$this->drupalPost('node/add/' . $type, $edit, t('Save'));
$this->assertResponse(200);
// Retrieve node object.
@@ -320,19 +321,19 @@ class DBLogTestCase extends DrupalWebTes
* @return array Content.
*/
private function getContent($type) {
+ $langcode = FIELD_LANGUAGE_NONE;
switch ($type) {
case 'poll':
$content = array(
- 'title' => $this->randomName(8),
+ "title[$langcode][0][value]" => $this->randomName(8),
'choice[new:0][chtext]' => $this->randomName(32),
'choice[new:1][chtext]' => $this->randomName(32),
);
break;
default:
- $langcode = FIELD_LANGUAGE_NONE;
$content = array(
- 'title' => $this->randomName(8),
+ "title[$langcode][0][value]" => $this->randomName(8),
"body[$langcode][0][value]" => $this->randomName(32),
);
break;
Index: modules/field/field.attach.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.attach.inc,v
retrieving revision 1.44
diff -u -p -r1.44 field.attach.inc
--- modules/field/field.attach.inc 31 Aug 2009 06:37:36 -0000 1.44
+++ modules/field/field.attach.inc 31 Aug 2009 13:59:45 -0000
@@ -1079,8 +1079,11 @@ function field_attach_query_revisions($f
* @endcode
*/
function field_attach_view($obj_type, $object, $build_mode = 'full', $langcode = NULL) {
- // If no language is provided use the current UI language.
- $options = array('language' => field_multilingual_valid_language($langcode, FALSE));
+ // If no language is provided use the current language or FIELD_LANGUAGE_NONE.
+ if (empty($langcode)) {
+ $langcode = field_multilingual_get_current_language($obj_type);
+ }
+ $options = array('language' => $langcode);
// Let field modules sanitize their data for output.
$null = NULL;
Index: modules/field/field.multilingual.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.multilingual.inc,v
retrieving revision 1.1
diff -u -p -r1.1 field.multilingual.inc
--- modules/field/field.multilingual.inc 22 Aug 2009 00:58:52 -0000 1.1
+++ modules/field/field.multilingual.inc 31 Aug 2009 14:12:17 -0000
@@ -31,8 +31,8 @@ function field_multilingual_available_la
$field_name = $field['field_name'];
if (!isset($field_languages[$field_name]) || !empty($suggested_languages)) {
- $obj_info = field_info_fieldable_types($obj_type);
- if (!empty($obj_info['translation_handlers']) && $field['translatable']) {
+ $translation_handlers = field_multilingual_check_translation_handlers($obj_type);
+ if ($translation_handlers && $field['translatable']) {
$available_languages = field_multilingual_content_languages();
// The returned languages are a subset of the intersection of enabled ones
// and suggested ones.
@@ -74,7 +74,10 @@ function field_multilingual_content_lang
/**
* Check if a module is registered as a translation handler for a given entity.
- *
+ *
+ * If no handler is passed, simply check if there is any translation hanlder
+ * defined for the give entity type.
+ *
* @param $obj_type
* The type of the entity whose fields are to be translated.
* @param $handler
@@ -82,9 +85,9 @@ function field_multilingual_content_lang
* @return
* TRUE, if the handler is allowed to manage field translations.
*/
-function field_multilingual_check_translation_handler($obj_type, $handler) {
+function field_multilingual_check_translation_handlers($obj_type, $handler = NULL) {
$obj_info = field_info_fieldable_types($obj_type);
- return isset($obj_info['translation_handlers'][$handler]);
+ return isset($handler) ? isset($obj_info['translation_handlers'][$handler]) : !empty($obj_info['translation_handlers']);
}
/**
@@ -121,3 +124,16 @@ function field_multilingual_valid_langua
// @todo Throw a more specific exception.
throw new FieldException('No valid content language could be found.');
}
+
+/**
+ * Return the appropriate field language according to the entity info.
+ *
+ * @return
+ * The current language if the given entity has translation handlers,
+ * FIELD_LANGUAGE_NONE otherwise.
+ */
+function field_multilingual_get_current_language($obj_type) {
+ global $language;
+ $translation_handlers = field_multilingual_check_translation_handlers($obj_type);
+ return $translation_handlers ? $language->language : FIELD_LANGUAGE_NONE;
+}
Index: modules/file/tests/file.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/file/tests/file.test,v
retrieving revision 1.1
diff -u -p -r1.1 file.test
--- modules/file/tests/file.test 29 Aug 2009 12:52:32 -0000 1.1
+++ modules/file/tests/file.test 31 Aug 2009 13:59:45 -0000
@@ -87,8 +87,9 @@ class FileFieldTestCase extends DrupalWe
* Upload a file to a node.
*/
function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE) {
+ $langcode = FIELD_LANGUAGE_NONE;
$edit = array(
- 'title' => $this->randomName(),
+ "title[$langcode][0][value]" => $this->randomName(),
'revision' => (string) (int) $new_revision,
);
@@ -344,7 +345,8 @@ class FileFieldValidateTestCase extends
$test_file = $this->getTestFile('text');
// Try to post a new node without uploading a file.
- $edit = array('title' => $this->randomName());
+ $langcode = FIELD_LANGUAGE_NONE;
+ $edit = array("title[$langcode][0][value]" => $this->randomName());
$this->drupalPost('node/add/' . $type_name, $edit, t('Save'));
$this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('Node save failed when required file field was empty.'));
@@ -361,7 +363,7 @@ class FileFieldValidateTestCase extends
$this->createFileField($field_name, $type_name, array('cardinality' => FIELD_CARDINALITY_UNLIMITED), array('required' => '1'));
// Try to post a new node without uploading a file in the multivalue field.
- $edit = array('title' => $this->randomName());
+ $edit = array("title[$langcode][0][value]" => $this->randomName());
$this->drupalPost('node/add/' . $type_name, $edit, t('Save'));
$this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('Node save failed when required multiple value file field was empty.'));
Index: modules/filter/filter.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.test,v
retrieving revision 1.39
diff -u -p -r1.39 filter.test
--- modules/filter/filter.test 29 Aug 2009 03:55:44 -0000 1.39
+++ modules/filter/filter.test 31 Aug 2009 13:59:45 -0000
@@ -110,14 +110,14 @@ class FilterAdminTestCase extends Drupal
$extra_text = 'text';
$edit = array();
- $edit['title'] = $this->randomName();
$langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = $this->randomName();
$edit["body[$langcode][0][value]"] = $body . '' . $extra_text . '';
$edit["body[$langcode][0][value_format]"] = $filtered;
$this->drupalPost('node/add/page', $edit, t('Save'));
- $this->assertRaw(t('Page %title has been created.', array('%title' => $edit['title'])), t('Filtered node created.'));
+ $this->assertRaw(t('Page %title has been created.', array('%title' => $edit["title[$langcode][0][value]"])), t('Filtered node created.'));
- $node = $this->drupalGetNodeByTitle($edit['title']);
+ $node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$this->assertTrue($node, t('Node found in database.'));
$this->drupalGet('node/' . $node->nid);
Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.515
diff -u -p -r1.515 forum.module
--- modules/forum/forum.module 29 Aug 2009 05:46:02 -0000 1.515
+++ modules/forum/forum.module 31 Aug 2009 14:15:01 -0000
@@ -548,7 +548,6 @@ function forum_block_view($delta = '') {
*/
function forum_form($node, $form_state) {
$type = node_type_get_type($node);
- $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#default_value' => !empty($node->title) ? $node->title : '', '#required' => TRUE, '#weight' => -5);
if (!empty($node->nid)) {
$vid = variable_get('forum_nav_vocabulary', 0);
Index: modules/forum/forum.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.test,v
retrieving revision 1.29
diff -u -p -r1.29 forum.test
--- modules/forum/forum.test 25 Aug 2009 21:53:47 -0000 1.29
+++ modules/forum/forum.test 31 Aug 2009 13:59:45 -0000
@@ -234,7 +234,7 @@ class ForumTestCase extends DrupalWebTes
$langcode = FIELD_LANGUAGE_NONE;
$edit = array(
- 'title' => $title,
+ "title[$langcode][0][value]" => $title,
"body[$langcode][0][value]" => $body,
'taxonomy[1]' => $tid
);
@@ -321,13 +321,13 @@ class ForumTestCase extends DrupalWebTes
if ($response == 200) {
// Edit forum node (including moving it to another forum).
$edit = array();
- $edit['title'] = 'node/' . $node->nid;
$langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = 'node/' . $node->nid;
$edit["body[$langcode][0][value]"] = $this->randomName(256);
$edit['taxonomy[1]'] = $this->root_forum['tid']; // Assumes the topic is initially associated with $forum.
$edit['shadow'] = TRUE;
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
- $this->assertRaw(t('Forum topic %title has been updated.', array('%title' => $edit['title'])), t('Forum node was edited'));
+ $this->assertRaw(t('Forum topic %title has been updated.', array('%title' => $edit["title[$langcode][0][value]"])), t('Forum node was edited'));
// Verify topic was moved to a different forum.
$forum_tid = db_query("SELECT tid FROM {forum} WHERE nid = :nid AND vid = :vid", array(
@@ -339,7 +339,7 @@ class ForumTestCase extends DrupalWebTes
// Delete forum node.
$this->drupalPost('node/' . $node->nid . '/delete', array(), t('Delete'));
$this->assertResponse($response);
- $this->assertRaw(t('Forum topic %title has been deleted.', array('%title' => $edit['title'])), t('Forum node was deleted'));
+ $this->assertRaw(t('Forum topic %title has been deleted.', array('%title' => $edit["title[$langcode][0][value]"])), t('Forum node was deleted'));
}
}
Index: modules/locale/locale.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.test,v
retrieving revision 1.40
diff -u -p -r1.40 locale.test
--- modules/locale/locale.test 28 Aug 2009 14:40:12 -0000 1.40
+++ modules/locale/locale.test 31 Aug 2009 13:59:45 -0000
@@ -1388,7 +1388,7 @@ class LocaleContentFunctionalTest extend
$node_body = $this->randomName();
$edit = array(
'type' => 'page',
- 'title' => $node_title,
+ 'title' => array(FIELD_LANGUAGE_NONE => array(array('value' => $node_title))),
'body' => array(FIELD_LANGUAGE_NONE => array(array('value' => $node_body))),
'language' => $langcode,
);
Index: modules/node/node.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v
retrieving revision 1.64
diff -u -p -r1.64 node.admin.inc
--- modules/node/node.admin.inc 25 Aug 2009 10:27:14 -0000 1.64
+++ modules/node/node.admin.inc 31 Aug 2009 15:08:11 -0000
@@ -335,7 +335,7 @@ function _node_mass_update_batch_process
$node = _node_mass_update_helper($nid, $updates);
// Store result for post-processing in the finished callback.
- $context['results'][] = l($node->title, 'node/' . $node->nid);
+ $context['results'][] = l(node_get_title($node), 'node/' . $node->nid);
// Update our progress information.
$context['sandbox']['progress']++;
Index: modules/node/node.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.install,v
retrieving revision 1.28
diff -u -p -r1.28 node.install
--- modules/node/node.install 22 Aug 2009 00:58:54 -0000 1.28
+++ modules/node/node.install 31 Aug 2009 13:59:45 -0000
@@ -451,7 +451,7 @@ function node_update_7005() {
}
/**
- * Convert body and teaser from node properties to fields, and migrate status/comment/promote/moderate and sticky columns to the {node_revision} table.
+ * Convert title, body and teaser from node properties to fields, and migrate status/comment/promote/moderate and sticky columns to the {node_revision} table.
*/
function node_update_7006(&$context) {
$ret = array('#finished' => 0);
@@ -463,9 +463,9 @@ function node_update_7006(&$context) {
if (!isset($context['total'])) {
// Initial invocation.
- // Re-save node types to create body field instances.
+ // Re-save node types to create title and body field instances.
foreach ($node_types as $type => $info) {
- if ($info->has_body) {
+ if ($info->has_title || $info->has_body) {
node_type_save($info);
}
}
@@ -510,6 +510,7 @@ function node_update_7006(&$context) {
'vid' => $revision->vid,
'type' => $revision->type,
);
+ $node->title[FIELD_LANGUAGE_NONE][0]['value'] = $revision->title;
if (!empty($revision->teaser) && $revision->teaser != text_summary($revision->body)) {
$node->body[FIELD_LANGUAGE_NONE][0]['summary'] = $revision->teaser;
}
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1116
diff -u -p -r1.1116 node.module
--- modules/node/node.module 29 Aug 2009 21:05:16 -0000 1.1116
+++ modules/node/node.module 31 Aug 2009 15:09:57 -0000
@@ -206,19 +206,7 @@ function node_field_build_modes($obj_typ
* Implement hook_field_extra_fields().
*/
function node_field_extra_fields($bundle) {
- $extra = array();
-
- if ($type = node_type_get_type($bundle)) {
- if ($type->has_title) {
- $extra['title'] = array(
- 'label' => $type->title_label,
- 'description' => t('Node module element.'),
- 'weight' => -5,
- );
- }
- }
-
- return $extra;
+ return array();
}
/**
@@ -240,7 +228,7 @@ function node_title_list($result, $title
$items = array();
$num_rows = FALSE;
foreach ($result as $node) {
- $items[] = l($node->title, 'node/' . $node->nid, !empty($node->comment_count) ? array('attributes' => array('title' => format_plural($node->comment_count, '1 comment', '@count comments'))) : array());
+ $items[] = l(node_get_title($node), 'node/' . $node->nid, !empty($node->comment_count) ? array('attributes' => array('title' => format_plural($node->comment_count, '1 comment', '@count comments'))) : array());
$num_rows = TRUE;
}
@@ -552,6 +540,48 @@ function node_configure_fields($type) {
field_delete_instance($instance);
}
+ // Add the title field if not present.
+ $field = field_info_field('title');
+ $instance = field_info_instance('title', $type->type);
+
+ if (empty($field)) {
+ $field = array(
+ 'field_name' => 'title',
+ 'type' => 'text',
+ );
+ $field = field_create_field($field);
+ }
+ if (empty($instance)) {
+ $weight = -5;
+ $instance = array(
+ 'field_name' => 'title',
+ 'bundle' => $type->type,
+ 'label' => $type->title_label,
+ 'widget_type' => 'text',
+ 'widget' => array(
+ 'weight' => $weight,
+ ),
+ 'required' => TRUE,
+ 'locked' => TRUE,
+ 'display' => array(
+ 'full' => array(
+ 'label' => 'hidden',
+ 'type' => 'hidden',
+ 'weight' => $weight,
+ ),
+ 'teaser' => array(
+ 'label' => 'hidden',
+ 'type' => 'hidden',
+ 'weight' => $weight,
+ ),
+ ),
+ );
+ field_create_instance($instance);
+ }
+ else {
+ $instance['label'] = $type->title_label;
+ field_update_instance($instance);
+ }
}
/**
@@ -870,6 +900,15 @@ function node_save($node) {
$node->timestamp = REQUEST_TIME;
$update_node = TRUE;
+ // When converting $node-title to fields we preserved the {node}.title db
+ // column, hence we need to temporarily set a string value into $node->title
+ // to make drupal_write_record behave properly.
+ // After this we restore the field data structure to the previous node title
+ // field.
+ $title_field = $node->title;
+ $langcode = (!empty($node->language)) ? $node->language : FIELD_LANGUAGE_NONE;
+ $node->title = $title_field[$langcode][0]['value'];
+
// Generate the node table query and the node_revisions table query.
if ($node->is_new) {
drupal_write_record('node', $node);
@@ -894,6 +933,9 @@ function node_save($node) {
->execute();
}
+ // Restore the title field data structure after db storage.
+ $node->title = $title_field;
+
// Call the node specific callback (if any). This can be
// node_invoke($node, 'insert') or
// node_invoke($node, 'update').
@@ -1060,7 +1102,7 @@ function node_build_content($node, $buil
$links['node_readmore'] = array(
'title' => t('Read more'),
'href' => 'node/' . $node->nid,
- 'attributes' => array('rel' => 'tag', 'title' => strip_tags($node->title))
+ 'attributes' => array('rel' => 'tag', 'title' => strip_tags(node_get_title($node)))
);
}
$node->content['links']['node'] = array(
@@ -1090,7 +1132,7 @@ function node_build_content($node, $buil
*/
function node_show($node, $message = FALSE) {
if ($message) {
- drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title, '%date' => format_date($node->revision_timestamp))), PASS_THROUGH);
+ drupal_set_title(t('Revision of %title from %date', array('%title' => node_get_title($node), '%date' => format_date($node->revision_timestamp))), PASS_THROUGH);
}
// Update the history table, stating that this user viewed this node.
@@ -1124,7 +1166,7 @@ function template_preprocess_node(&$vari
$variables['date'] = format_date($node->created);
$variables['name'] = theme('username', $node);
$variables['node_url'] = url('node/' . $node->nid);
- $variables['title'] = check_plain($node->title);
+ $variables['title'] = check_plain(node_get_title($node));
$variables['page'] = (bool)menu_get_object();
if (!empty($node->in_preview)) {
@@ -1365,7 +1407,7 @@ function node_search_execute($keys = NUL
$results[] = array(
'link' => url('node/' . $item->sid, array('absolute' => TRUE)),
'type' => check_plain(node_type_get_name($node)),
- 'title' => $node->title,
+ 'title' => node_get_title($node),
'user' => theme('username', $node),
'date' => $node->changed,
'node' => $node,
@@ -1641,7 +1683,7 @@ function node_menu() {
);
}
$items['node/%node'] = array(
- 'title callback' => 'node_page_title',
+ 'title callback' => 'node_get_title',
'title arguments' => array(1),
'page callback' => 'node_page_view',
'page arguments' => array(1),
@@ -1715,10 +1757,11 @@ function node_menu() {
}
/**
- * Title callback.
+ * Return the proper node title translation according to the current language.
*/
-function node_page_title($node) {
- return $node->title;
+function node_get_title($node) {
+ $langcode = field_multilingual_get_current_language('node');
+ return (isset($node->title[$langcode][0]['value'])) ? $node->title[$langcode][0]['value'] : NULL;
}
/**
@@ -1823,7 +1866,7 @@ function node_feed($nids = FALSE, $chann
$item_text .= drupal_render($node->content) . $links;
}
- $items .= format_rss_item($node->title, $node->link, $item_text, $node->rss_elements);
+ $items .= format_rss_item(node_get_title($node), $node->link, $item_text, $node->rss_elements);
}
$channel_defaults = array(
@@ -1924,7 +1967,7 @@ function node_page_default() {
* Menu callback; view a single node.
*/
function node_page_view($node) {
- drupal_set_title($node->title);
+ drupal_set_title(node_get_title($node));
return node_show($node);
}
@@ -1958,7 +2001,7 @@ function _node_index_node($node) {
$node = node_build_content($node, 'search_index');
$node->rendered = drupal_render($node->content);
- $text = '
' . check_plain($node->title) . '
' . $node->rendered;
+ $text = '' . check_plain(node_get_title($node)) . '
' . $node->rendered;
// Fetch extra data normally not visible
$extra = module_invoke_all('node_update_index', $node);
@@ -2752,23 +2795,7 @@ function _node_access_rebuild_batch_fini
* Implement hook_form().
*/
function node_content_form($node, $form_state) {
-
- $type = node_type_get_type($node);
-
- $form = array();
-
- if ($type->has_title) {
- $form['title'] = array(
- '#type' => 'textfield',
- '#title' => check_plain($type->title_label),
- '#required' => TRUE,
- '#default_value' => $node->title,
- '#maxlength' => 255,
- '#weight' => -5,
- );
- }
-
- return $form;
+ return array();
}
/**
@@ -2917,7 +2944,7 @@ function node_action_info() {
*/
function node_publish_action($node, $context = array()) {
$node->status = 1;
- watchdog('action', 'Set @type %title to published.', array('@type' => node_type_get_name($node), '%title' => $node->title));
+ watchdog('action', 'Set @type %title to published.', array('@type' => node_type_get_name($node), '%title' => node_get_title($node)));
}
/**
@@ -2926,7 +2953,7 @@ function node_publish_action($node, $con
*/
function node_unpublish_action($node, $context = array()) {
$node->status = 0;
- watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => $node->title));
+ watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => node_get_title($node)));
}
/**
@@ -2935,7 +2962,7 @@ function node_unpublish_action($node, $c
*/
function node_make_sticky_action($node, $context = array()) {
$node->sticky = 1;
- watchdog('action', 'Set @type %title to sticky.', array('@type' => node_type_get_name($node), '%title' => $node->title));
+ watchdog('action', 'Set @type %title to sticky.', array('@type' => node_type_get_name($node), '%title' => node_get_title($node)));
}
/**
@@ -2944,7 +2971,7 @@ function node_make_sticky_action($node,
*/
function node_make_unsticky_action($node, $context = array()) {
$node->sticky = 0;
- watchdog('action', 'Set @type %title to unsticky.', array('@type' => node_type_get_name($node), '%title' => $node->title));
+ watchdog('action', 'Set @type %title to unsticky.', array('@type' => node_type_get_name($node), '%title' => node_get_title($node)));
}
/**
@@ -2953,7 +2980,7 @@ function node_make_unsticky_action($node
*/
function node_promote_action($node, $context = array()) {
$node->promote = 1;
- watchdog('action', 'Promoted @type %title to front page.', array('@type' => node_type_get_name($node), '%title' => $node->title));
+ watchdog('action', 'Promoted @type %title to front page.', array('@type' => node_type_get_name($node), '%title' => node_get_title($node)));
}
/**
@@ -2962,7 +2989,7 @@ function node_promote_action($node, $con
*/
function node_unpromote_action($node, $context = array()) {
$node->promote = 0;
- watchdog('action', 'Removed @type %title from front page.', array('@type' => node_type_get_name($node), '%title' => $node->title));
+ watchdog('action', 'Removed @type %title from front page.', array('@type' => node_type_get_name($node), '%title' => node_get_title($node)));
}
/**
@@ -2971,7 +2998,7 @@ function node_unpromote_action($node, $c
*/
function node_save_action($node) {
node_save($node);
- watchdog('action', 'Saved @type %title', array('@type' => node_type_get_name($node), '%title' => $node->title));
+ watchdog('action', 'Saved @type %title', array('@type' => node_type_get_name($node), '%title' => node_get_title($node)));
}
/**
@@ -2981,7 +3008,7 @@ function node_save_action($node) {
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, '%name' => $owner_name));
+ watchdog('action', 'Changed owner of @type %title to uid %name.', array('@type' => node_type_get_type($node), '%title' => node_get_title($node), '%name' => $owner_name));
}
function node_assign_owner_action_form($context) {
@@ -3060,9 +3087,9 @@ function node_unpublish_by_keyword_actio
*/
function node_unpublish_by_keyword_action($node, $context) {
foreach ($context['keywords'] as $keyword) {
- if (strpos(drupal_render(node_build(clone $node)), $keyword) !== FALSE || strpos($node->title, $keyword) !== FALSE) {
+ if (strpos(drupal_render(node_build(clone $node)), $keyword) !== FALSE || strpos(node_get_title($node), $keyword) !== FALSE) {
$node->status = 0;
- watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => $node->title));
+ watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => node_get_title($node)));
break;
}
}
Index: modules/node/node.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v
retrieving revision 1.78
diff -u -p -r1.78 node.pages.inc
--- modules/node/node.pages.inc 25 Aug 2009 10:27:14 -0000 1.78
+++ modules/node/node.pages.inc 31 Aug 2009 15:08:11 -0000
@@ -12,7 +12,7 @@
*/
function node_page_edit($node) {
$type_name = node_type_get_name($node);
- drupal_set_title(t('Edit @type @title', array('@type' => $type_name, '@title' => $node->title)), PASS_THROUGH);
+ drupal_set_title(t('Edit @type @title', array('@type' => $type_name, '@title' => node_get_title($node))), PASS_THROUGH);
return drupal_get_form($node->type . '_node_form', $node);
}
@@ -151,9 +151,6 @@ function node_form(&$form_state, $node)
if ($extra = node_invoke($node, 'form', $form_state)) {
$form = array_merge_recursive($form, $extra);
}
- if (!isset($form['title']['#weight'])) {
- $form['title']['#weight'] = -5;
- }
$form['#node'] = $node;
@@ -404,8 +401,8 @@ function node_form_submit($form, &$form_
$insert = empty($node->nid);
node_save($node);
$node_link = l(t('view'), 'node/' . $node->nid);
- $watchdog_args = array('@type' => $node->type, '%title' => $node->title);
- $t_args = array('@type' => node_type_get_name($node), '%title' => $node->title);
+ $watchdog_args = array('@type' => $node->type, '%title' => node_get_title($node));
+ $t_args = array('@type' => node_type_get_name($node), '%title' => node_get_title($node));
if ($insert) {
watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
@@ -454,7 +451,7 @@ function node_delete_confirm(&$form_stat
);
return confirm_form($form,
- t('Are you sure you want to delete %title?', array('%title' => $node->title)),
+ t('Are you sure you want to delete %title?', array('%title' => node_get_title($node))),
isset($_GET['destination']) ? $_GET['destination'] : 'node/' . $node->nid,
t('This action cannot be undone.'),
t('Delete'),
@@ -469,8 +466,8 @@ function node_delete_confirm_submit($for
if ($form_state['values']['confirm']) {
$node = node_load($form_state['values']['nid']);
node_delete($form_state['values']['nid']);
- watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
- drupal_set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => $node->title)));
+ watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => node_get_title($node)));
+ drupal_set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => node_get_title($node))));
}
$form_state['redirect'] = '';
@@ -480,7 +477,7 @@ function node_delete_confirm_submit($for
* 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)), PASS_THROUGH);
+ drupal_set_title(t('Revisions for %title', array('%title' => node_get_title($node))), PASS_THROUGH);
$header = array(t('Revision'), array('data' => t('Operations'), 'colspan' => 2));
Index: modules/node/node.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.test,v
retrieving revision 1.43
diff -u -p -r1.43 node.test
--- modules/node/node.test 29 Aug 2009 04:16:15 -0000 1.43
+++ modules/node/node.test 31 Aug 2009 15:08:11 -0000
@@ -187,15 +187,16 @@ class PageEditTestCase extends DrupalWeb
*/
function testPageEdit() {
$langcode = FIELD_LANGUAGE_NONE;
+ $title_key = "title[$langcode][0][value]";
$body_key = "body[$langcode][0][value]";
// Create node to edit.
$edit = array();
- $edit['title'] = $this->randomName(8);
+ $edit[$title_key] = $this->randomName(8);
$edit[$body_key] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Save'));
// Check that the node exists in the database.
- $node = $this->drupalGetNodeByTitle($edit['title']);
+ $node = $this->drupalGetNodeByTitle($edit[$title_key]);
$this->assertTrue($node, t('Node found in database.'));
// Check that "edit" link points to correct page.
@@ -206,18 +207,18 @@ class PageEditTestCase extends DrupalWeb
// Check that the title and body fields are displayed with the correct values.
$this->assertLink(t('Edit'), 0, t('Edit tab found.'));
- $this->assertFieldByName('title', $edit['title'], t('Title field displayed.'));
+ $this->assertFieldByName($title_key, $edit[$title_key], t('Title field displayed.'));
$this->assertFieldByName($body_key, $edit[$body_key], t('Body field displayed.'));
// Edit the content of the node.
$edit = array();
- $edit['title'] = $this->randomName(8);
+ $edit[$title_key] = $this->randomName(8);
$edit[$body_key] = $this->randomName(16);
// Stay on the current page, without reloading.
$this->drupalPost(NULL, $edit, t('Save'));
// Check that the title and body fields are displayed with the updated values.
- $this->assertText($edit['title'], t('Title displayed.'));
+ $this->assertText($edit[$title_key], t('Title displayed.'));
$this->assertText($edit[$body_key], t('Body displayed.'));
// Login as a second administrator user.
@@ -226,13 +227,13 @@ class PageEditTestCase extends DrupalWeb
// Edit the same node, creating a new revision.
$this->drupalGet("node/$node->nid/edit");
$edit = array();
- $edit['title'] = $this->randomName(8);
+ $edit[$title_key] = $this->randomName(8);
$edit[$body_key] = $this->randomName(16);
$edit['revision'] = TRUE;
$this->drupalPost(NULL, $edit, t('Save'));
// Ensure that the node revision has been created.
- $revised_node = $this->drupalGetNodeByTitle($edit['title']);
+ $revised_node = $this->drupalGetNodeByTitle($edit[$title_key]);
$this->assertNotIdentical($node->vid, $revised_node->vid, 'A new revision has been created.');
// Ensure that the node author is preserved when it was not changed in the
// edit form.
@@ -266,21 +267,22 @@ class PagePreviewTestCase extends Drupal
*/
function testPagePreview() {
$langcode = FIELD_LANGUAGE_NONE;
+ $title_key = "title[$langcode][0][value]";
$body_key = "body[$langcode][0][value]";
// Fill in node creation form and preview node.
$edit = array();
- $edit['title'] = $this->randomName(8);
+ $edit[$title_key] = $this->randomName(8);
$edit[$body_key] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Preview'));
// Check that the preview is displaying the title and body.
$this->assertTitle(t('Preview | Drupal'), t('Page title is preview.'));
- $this->assertText($edit['title'], t('Title displayed.'));
+ $this->assertText($edit[$title_key], t('Title displayed.'));
$this->assertText($edit[$body_key], t('Body displayed.'));
// Check that the title and body fields are displayed with the correct values.
- $this->assertFieldByName('title', $edit['title'], t('Title field displayed.'));
+ $this->assertFieldByName($title_key, $edit[$title_key], t('Title field displayed.'));
$this->assertFieldByName($body_key, $edit[$body_key], t('Body field displayed.'));
}
@@ -289,24 +291,25 @@ class PagePreviewTestCase extends Drupal
*/
function testPagePreviewWithRevisions() {
$langcode = FIELD_LANGUAGE_NONE;
+ $title_key = "title[$langcode][0][value]";
$body_key = "body[$langcode][0][value]";
// Force revision on page content.
variable_set('node_options_page', array('status', 'revision'));
// Fill in node creation form and preview node.
$edit = array();
- $edit['title'] = $this->randomName(8);
+ $edit[$title_key] = $this->randomName(8);
$edit[$body_key] = $this->randomName(16);
$edit['log'] = $this->randomName(32);
$this->drupalPost('node/add/page', $edit, t('Preview'));
// Check that the preview is displaying the title and body.
$this->assertTitle(t('Preview | Drupal'), t('Page title is preview.'));
- $this->assertText($edit['title'], t('Title displayed.'));
+ $this->assertText($edit[$title_key], t('Title displayed.'));
$this->assertText($edit[$body_key], t('Body displayed.'));
// Check that the title and body fields are displayed with the correct values.
- $this->assertFieldByName('title', $edit['title'], t('Title field displayed.'));
+ $this->assertFieldByName($title_key, $edit[$title_key], t('Title field displayed.'));
$this->assertFieldByName($body_key, $edit[$body_key], t('Body field displayed.'));
// Check that the log field has the correct value.
@@ -336,16 +339,16 @@ class PageCreationTestCase extends Drupa
function testPageCreation() {
// Create a node.
$edit = array();
- $edit['title'] = $this->randomName(8);
$langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = $this->randomName(8);
$edit["body[$langcode][0][value]"] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Save'));
// Check that the page has been created.
- $this->assertRaw(t('!post %title has been created.', array('!post' => 'Page', '%title' => $edit['title'])), t('Page created.'));
+ $this->assertRaw(t('!post %title has been created.', array('!post' => 'Page', '%title' => $edit["title[$langcode][0][value]"])), t('Page created.'));
// Check that the node exists in the database.
- $node = $this->drupalGetNodeByTitle($edit['title']);
+ $node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$this->assertTrue($node, t('Node found in database.'));
}
}
@@ -445,11 +448,12 @@ class NodeTitleXSSTestCase extends Drupa
$web_user = $this->drupalCreateUser(array('create page content', 'edit any page content'));
$this->drupalLogin($web_user);
- $xss = '';
-
+ $xss = '';
+ $langcode = FIELD_LANGUAGE_NONE;
$edit = array(
- 'title' => $xss . $this->randomName(),
+ "title[$langcode][0][value]" => $xss . $this->randomName(),
);
+
$this->drupalPost('node/add/page', $edit, t('Preview'));
$this->assertNoRaw($xss, t('Harmful tags are escaped when previewing a node.'));
@@ -457,7 +461,7 @@ class NodeTitleXSSTestCase extends Drupa
$this->drupalGet('node/' . $node->nid);
// assertTitle() decodes HTML-entities inside the element.
- $this->assertTitle($edit['title'] . ' | Drupal', t('Title is diplayed when viewing a node.'));
+ $this->assertTitle($edit["title[$langcode][0][value]"] . ' | Drupal', t('Title is diplayed when viewing a node.'));
$this->assertNoRaw($xss, t('Harmful tags are escaped when viewing a node.'));
$this->drupalGet('node/' . $node->nid . '/edit');
@@ -526,13 +530,13 @@ class NodePostSettingsTestCase extends D
// Create a node.
$edit = array();
- $edit['title'] = $this->randomName(8);
$langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = $this->randomName(8);
$edit["body[$langcode][0][value]"] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Save'));
// Check that the post information is displayed.
- $node = $this->drupalGetNodeByTitle($edit['title']);
+ $node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$this->assertRaw('', t('Post information is displayed.'));
}
@@ -548,13 +552,13 @@ class NodePostSettingsTestCase extends D
// Create a node.
$edit = array();
- $edit['title'] = $this->randomName(8);
$langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = $this->randomName(8);
$edit["body[$langcode][0][value]"] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Save'));
// Check that the post information is displayed.
- $node = $this->drupalGetNodeByTitle($edit['title']);
+ $node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$this->assertNoRaw('', t('Post information is not displayed.'));
}
}
@@ -899,7 +903,7 @@ class NodeAdminTestCase extends DrupalWe
$node3 = $this->drupalCreateNode(array('type' => 'page'));
$this->drupalGet('admin/content');
- $this->assertText($node1->title, t('Node appears on the node administration listing.'));
+ $this->assertText(node_get_title($node1), t('Node appears on the node administration listing.'));
// Filter the node listing by status.
$edit = array(
@@ -908,8 +912,8 @@ class NodeAdminTestCase extends DrupalWe
);
$this->drupalPost('admin/content', $edit, t('Filter'));
$this->assertRaw(t('%type is %value', array('%type' => t('status'), '%value' => t('published'))), t('The node administration listing is filtered by status.'));
- $this->assertText($node1->title, t('Published node appears on the node administration listing.'));
- $this->assertNoText($node2->title, t('Unpublished node does not appear on the node administration listing.'));
+ $this->assertText(node_get_title($node1), t('Published node appears on the node administration listing.'));
+ $this->assertNoText(node_get_title($node2), t('Unpublished node does not appear on the node administration listing.'));
// Filter the node listing by content type.
$edit = array(
Index: modules/node/node.tokens.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.tokens.inc,v
retrieving revision 1.2
diff -u -p -r1.2 node.tokens.inc
--- modules/node/node.tokens.inc 23 Aug 2009 13:02:38 -0000 1.2
+++ modules/node/node.tokens.inc 31 Aug 2009 15:08:11 -0000
@@ -134,7 +134,7 @@ function node_tokens($type, $tokens, arr
break;
case 'title':
- $replacements[$original] = $sanitize ? check_plain($node->title) : $node->title;
+ $replacements[$original] = $sanitize ? check_plain(node_get_title($node)) : node_get_title($node);
break;
case 'body':
Index: modules/path/path.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.test,v
retrieving revision 1.20
diff -u -p -r1.20 path.test
--- modules/path/path.test 28 Aug 2009 14:40:12 -0000 1.20
+++ modules/path/path.test 31 Aug 2009 13:59:45 -0000
@@ -212,8 +212,8 @@ class PathLanguageTestCase extends Drupa
$this->drupalGet('node/' . $english_node->nid . '/translate');
$this->clickLink(t('add translation'));
$edit = array();
- $edit['title'] = $this->randomName();
$langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = $this->randomName();
$edit["body[$langcode][0][value]"] = $this->randomName();
$edit['path'] = $this->randomName();
$this->drupalPost(NULL, $edit, t('Save'));
@@ -223,7 +223,7 @@ class PathLanguageTestCase extends Drupa
// Ensure the node was created.
// Check to make sure the node was created.
- $french_node = $this->drupalGetNodeByTitle($edit['title']);
+ $french_node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$this->assertTrue(($french_node), 'Node found in database.');
// Confirm that the alias works.
Index: modules/poll/poll.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v
retrieving revision 1.311
diff -u -p -r1.311 poll.module
--- modules/poll/poll.module 29 Aug 2009 05:46:03 -0000 1.311
+++ modules/poll/poll.module 31 Aug 2009 15:08:11 -0000
@@ -222,14 +222,6 @@ function poll_form($node, $form_state) {
'#cache' => TRUE,
);
- $form['title'] = array(
- '#type' => 'textfield',
- '#title' => check_plain($type->title_label),
- '#required' => TRUE,
- '#default_value' => $node->title,
- '#weight' => -5,
- );
-
if (isset($form_state['choice_count'])) {
$choice_count = $form_state['choice_count'];
}
@@ -706,7 +698,7 @@ function poll_vote($form, &$form_state)
function template_preprocess_poll_vote(&$variables) {
$form = $variables['form'];
$variables['choice'] = drupal_render($form['choice']);
- $variables['title'] = check_plain($form['#node']->title);
+ $variables['title'] = check_plain(node_get_title($form['#node']));
$variables['vote'] = drupal_render($form['vote']);
$variables['rest'] = drupal_render_children($form);
$variables['block'] = $form['#block'];
@@ -738,7 +730,7 @@ function poll_view_results($node, $build
}
}
- return theme('poll_results', $node->title, $poll_results, $total_votes, isset($node->links) ? $node->links : array(), $block, $node->nid, isset($node->vote) ? $node->vote : NULL);
+ return theme('poll_results', node_get_title($node), $poll_results, $total_votes, isset($node->links) ? $node->links : array(), $block, $node->nid, 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.20
diff -u -p -r1.20 poll.pages.inc
--- modules/poll/poll.pages.inc 29 Jul 2009 06:39:34 -0000 1.20
+++ modules/poll/poll.pages.inc 31 Aug 2009 15:08:11 -0000
@@ -51,7 +51,7 @@ function poll_page() {
*/
function poll_votes($node) {
$votes_per_page = 20;
- drupal_set_title($node->title);
+ drupal_set_title(node_get_title($node));
$header[] = array('data' => t('Visitor'), 'field' => 'u.name');
$header[] = array('data' => t('Vote'), 'field' => 'pc.chtext');
@@ -91,7 +91,7 @@ function poll_votes($node) {
* Callback for the 'results' tab for polls you can vote on
*/
function poll_results($node) {
- drupal_set_title($node->title);
+ drupal_set_title(node_get_title($node));
$node->show_results = TRUE;
return node_show($node);
}
Index: modules/poll/poll.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.test,v
retrieving revision 1.22
diff -u -p -r1.22 poll.test
--- modules/poll/poll.test 17 Aug 2009 07:12:16 -0000 1.22
+++ modules/poll/poll.test 31 Aug 2009 13:59:45 -0000
@@ -56,9 +56,10 @@ class PollTestCase extends DrupalWebTest
$max_new_choices = $index == 0 ? 2 : 5;
$already_submitted_choices = array_slice($choices, 0, $index);
$new_choices = array_values(array_slice($choices, $index, $max_new_choices));
-
+
+ $langcode = FIELD_LANGUAGE_NONE;
$edit = array(
- 'title' => $title
+ "title[$langcode][0][value]" => $title
);
foreach ($already_submitted_choices as $k => $text) {
$edit['choice[chid:' . $k . '][chtext]'] = $text;
@@ -331,8 +332,9 @@ class PollJSAddChoice extends DrupalWebT
$web_user = $this->drupalCreateUser(array('create poll content', 'access content'));
$this->drupalLogin($web_user);
$this->drupalGet('node/add/poll');
+ $langcode = FIELD_LANGUAGE_NONE;
$edit = array(
- 'title' => $this->randomName(),
+ "title[$langcode][0][value]" => $this->randomName(),
'choice[new:0][chtext]' => $this->randomName(),
'choice[new:1][chtext]' => $this->randomName(),
);
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.145
diff -u -p -r1.145 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php 27 Aug 2009 20:25:28 -0000 1.145
+++ modules/simpletest/drupal_web_test_case.php 31 Aug 2009 14:51:08 -0000
@@ -694,7 +694,7 @@ class DrupalWebTestCase extends DrupalTe
// Populate defaults array.
$settings += array(
'body' => array(FIELD_LANGUAGE_NONE => array(array())),
- 'title' => $this->randomName(8),
+ 'title' => array(FIELD_LANGUAGE_NONE => array(array())),
'comment' => 2,
'changed' => REQUEST_TIME,
'moderate' => 0,
@@ -725,6 +725,13 @@ class DrupalWebTestCase extends DrupalTe
}
}
+ // Merge title field value and format separately.
+ $title = array(
+ 'value' => $this->randomName(8),
+ 'format' => FILTER_FORMAT_DEFAULT
+ );
+ $settings['title'][FIELD_LANGUAGE_NONE][0] += $title;
+
// Merge body field value and format separately.
$body = array(
'value' => $this->randomName(32),
Index: modules/system/system.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.test,v
retrieving revision 1.74
diff -u -p -r1.74 system.test
--- modules/system/system.test 26 Aug 2009 10:53:45 -0000 1.74
+++ modules/system/system.test 31 Aug 2009 15:08:11 -0000
@@ -548,13 +548,13 @@ class AccessDeniedTestCase extends Drupa
$this->drupalPost('admin/settings/site-information', array('site_403' => 'node/' . $node->nid), t('Save configuration'));
$this->drupalGet('admin');
- $this->assertText($node->title, t('Found the custom 403 page'));
+ $this->assertText(node_get_title($node), t('Found the custom 403 page'));
// Logout and check that the user login block is shown on custom 403 pages.
$this->drupalLogout();
$this->drupalGet('admin');
- $this->assertText($node->title, t('Found the custom 403 page'));
+ $this->assertText(node_get_title($node), t('Found the custom 403 page'));
$this->assertText(t('User login'), t('Blocks are shown on the custom 403 page'));
// Log back in and remove the custom 403 page.
@@ -616,7 +616,7 @@ class PageNotFoundTestCase extends Drupa
$this->assertText(t('Page not found'), t('Found the default 404 page'));
$edit = array(
- 'title' => $this->randomName(10),
+ 'title' => array(FIELD_LANGUAGE_NONE => array(array('value' => $this->randomName(10)))),
'body' => array(FIELD_LANGUAGE_NONE => array(array('value' => $this->randomName(100)))),
);
$node = $this->drupalCreateNode($edit);
@@ -625,7 +625,7 @@ class PageNotFoundTestCase extends Drupa
$this->drupalPost('admin/settings/site-information', array('site_404' => 'node/' . $node->nid), t('Save configuration'));
$this->drupalGet($this->randomName(10));
- $this->assertText($node->title, t('Found the custom 404 page'));
+ $this->assertText(node_get_title($node), t('Found the custom 404 page'));
}
}
@@ -811,16 +811,16 @@ class PageTitleFiltering extends DrupalW
// Generate node content.
$langcode = FIELD_LANGUAGE_NONE;
$edit = array(
- 'title' => '!SimpleTest! ' . $title . $this->randomName(20),
+ "title[$langcode][0][value]" => '!SimpleTest! ' . $title . $this->randomName(20),
"body[$langcode][0][value]" => '!SimpleTest! test body' . $this->randomName(200),
);
// Create the node with HTML in the title.
$this->drupalPost('node/add/page', $edit, t('Save'));
- $node = $this->drupalGetNodeByTitle($edit['title']);
+ $node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$this->assertNotNull($node, 'Node created and found in database');
$this->drupalGet("node/" . $node->nid);
- $this->assertText(check_plain($edit['title']), 'Check to make sure tags in the node title are converted.');
+ $this->assertText(check_plain($edit["title[$langcode][0][value]"]), 'Check to make sure tags in the node title are converted.');
}
}
@@ -1203,7 +1203,7 @@ class TokenReplaceTestCase extends Drupa
$source .= '[date:short]'; // Short date format of REQUEST_TIME
$source .= '[bogus:token]'; // Nonexistent token, should be untouched
- $target = check_plain($node->title);
+ $target = check_plain(node_get_title($node));
$target .= check_plain($account->name);
$target .= format_interval(REQUEST_TIME - $node->created, 2);
$target .= check_plain($user->name);
@@ -1221,9 +1221,9 @@ class TokenReplaceTestCase extends Drupa
$raw_tokens = array('title' => '[node:title]');
$generated = token_generate('node', $raw_tokens, array('node' => $node));
- $this->assertFalse(strcmp($generated['[node:title]'], check_plain($node->title)), t('Token sanitized.'));
+ $this->assertFalse(strcmp($generated['[node:title]'], check_plain(node_get_title($node))), t('Token sanitized.'));
$generated = token_generate('node', $raw_tokens, array('node' => $node), array('sanitize' => FALSE));
- $this->assertFalse(strcmp($generated['[node:title]'], $node->title), t('Unsanitized token generated properly.'));
+ $this->assertFalse(strcmp($generated['[node:title]'], node_get_title($node)), t('Unsanitized token generated properly.'));
}
}
Index: modules/taxonomy/taxonomy.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.test,v
retrieving revision 1.46
diff -u -p -r1.46 taxonomy.test
--- modules/taxonomy/taxonomy.test 25 Aug 2009 21:53:48 -0000 1.46
+++ modules/taxonomy/taxonomy.test 31 Aug 2009 13:59:45 -0000
@@ -451,14 +451,14 @@ class TaxonomyTermTestCase extends Taxon
// Post an article.
$edit = array();
- $edit['title'] = $this->randomName();
$langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = $this->randomName();
$edit["body[$langcode][0][value]"] = $this->randomName();
$edit['taxonomy[' . $this->vocabulary->vid . ']'] = $term1->tid;
$this->drupalPost('node/add/article', $edit, t('Save'));
// Check that the term is displayed when the node is viewed.
- $node = $this->drupalGetNodeByTitle($edit['title']);
+ $node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$this->drupalGet('node/' . $node->nid);
$this->assertText($term1->name, t('Term is displayed when viewing the node.'));
@@ -491,14 +491,14 @@ class TaxonomyTermTestCase extends Taxon
$this->randomName(),
);
$edit = array();
- $edit['title'] = $this->randomName();
+ $langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = $this->randomName();
// Insert the terms in a comma separated list. Vocabulary 1 is a
// free-tagging field created by the default profile.
$edit['taxonomy[tags][' . $this->vocabulary->vid . ']'] = implode(', ', $terms);
- $langcode = FIELD_LANGUAGE_NONE;
$edit["body[$langcode][0][value]"] = $this->randomName();
$this->drupalPost('node/add/article', $edit, t('Save'));
- $this->assertRaw(t('@type %title has been created.', array('@type' => t('Article'), '%title' => $edit['title'])), t('The node was created successfully'));
+ $this->assertRaw(t('@type %title has been created.', array('@type' => t('Article'), '%title' => $edit["title[$langcode][0][value]"])), t('The node was created successfully'));
foreach ($terms as $term) {
$this->assertText($term, t('The term was saved and appears on the node page'));
}
Index: modules/translation/translation.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/translation/translation.test,v
retrieving revision 1.17
diff -u -p -r1.17 translation.test
--- modules/translation/translation.test 22 Aug 2009 00:58:55 -0000 1.17
+++ modules/translation/translation.test 31 Aug 2009 13:59:45 -0000
@@ -59,11 +59,11 @@ class TranslationTestCase extends Drupal
// Attempt a resubmission of the form - this emulates using the back button
// to return to the page then resubmitting the form without a refresh.
$edit = array();
- $edit['title'] = $this->randomName();
$langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = $this->randomName();
$edit["body[$langcode][0][value]"] = $this->randomName();
$this->drupalPost('node/add/page', $edit, t('Save'), array('query' => array('translation' => $node->nid, 'language' => 'es')));
- $duplicate = $this->drupalGetNodeByTitle($edit['title']);
+ $duplicate = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$this->assertEqual($duplicate->tnid, 0, t('The node does not have a tnid.'));
// Update original and mark translation as outdated.
@@ -128,15 +128,15 @@ class TranslationTestCase extends Drupal
*/
function createPage($title, $body, $language) {
$edit = array();
- $edit['title'] = $title;
$langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = $title;
$edit["body[$langcode][0][value]"] = $body;
$edit['language'] = $language;
$this->drupalPost('node/add/page', $edit, t('Save'));
- $this->assertRaw(t('Page %title has been created.', array('%title' => $edit['title'])), t('Page created.'));
+ $this->assertRaw(t('Page %title has been created.', array('%title' => $edit["title[$langcode][0][value]"])), t('Page created.'));
// Check to make sure the node was created.
- $node = $this->drupalGetNodeByTitle($edit['title']);
+ $node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$this->assertTrue($node, t('Node found in database.'));
return $node;
@@ -154,14 +154,14 @@ class TranslationTestCase extends Drupal
$this->drupalGet('node/add/page', array('query' => array('translation' => $nid, 'language' => $language)));
$edit = array();
- $edit['title'] = $title;
$langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = $title;
$edit["body[$langcode][0][value]"] = $body;
$this->drupalPost(NULL, $edit, t('Save'));
- $this->assertRaw(t('Page %title has been created.', array('%title' => $edit['title'])), t('Translation created.'));
+ $this->assertRaw(t('Page %title has been created.', array('%title' => $edit["title[$langcode][0][value]"])), t('Translation created.'));
// Check to make sure that translation was successful.
- $node = $this->drupalGetNodeByTitle($edit['title']);
+ $node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$this->assertTrue($node, t('Node found in database.'));
return $node;
Index: modules/trigger/trigger.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/trigger/trigger.test,v
retrieving revision 1.16
diff -u -p -r1.16 trigger.test
--- modules/trigger/trigger.test 22 Aug 2009 00:58:55 -0000 1.16
+++ modules/trigger/trigger.test 31 Aug 2009 13:59:45 -0000
@@ -37,15 +37,15 @@ class TriggerContentTestCase extends Dru
$web_user = $this->drupalCreateUser(array('create page content', 'access content', 'administer nodes'));
$this->drupalLogin($web_user);
$edit = array();
- $edit['title'] = '!SimpleTest test node! ' . $this->randomName(10);
$langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = '!SimpleTest test node! ' . $this->randomName(10);
$edit["body[$langcode][0][value]"] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32);
$edit[$info['property']] = !$info['expected'];
$this->drupalPost('node/add/page', $edit, t('Save'));
// Make sure the text we want appears.
- $this->assertRaw(t('!post %title has been created.', array('!post' => 'Page', '%title' => $edit['title'])), t('Make sure the page has actually been created'));
+ $this->assertRaw(t('!post %title has been created.', array('!post' => 'Page', '%title' => $edit["title[$langcode][0][value]"])), t('Make sure the page has actually been created'));
// Action should have been fired.
- $loaded_node = $this->drupalGetNodeByTitle($edit['title']);;
+ $loaded_node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);;
$this->assertTrue($loaded_node->$info['property'] == $info['expected'], t('Make sure the @action action fired.', array('@action' => $info['name'])));
// Leave action assigned for next test