Commit 147bb138 authored by webchick's avatar webchick
Browse files

#571654 follow-up by chx, peximo, plach, sun, et al:

Roll-back of node titles as fields. The Entity Translation module in
contrib can add this back, but for everyone else it creates a *huge* WTF.
Apologies for how late this is coming, but better now than post-alpha. :\
parent 364238c5
......@@ -253,7 +253,7 @@ EOF;
// Post 5 articles.
for ($i = 0; $i < 5; $i++) {
$edit = array();
$edit["title[$langcode][0][value]"] = $this->randomName();
$edit['title'] = $this->randomName();
$edit["body[$langcode][0][value]"] = $this->randomName();
$this->drupalPost('node/add/article', $edit, t('Save'));
}
......
......@@ -138,29 +138,29 @@ class BlogTestCase extends DrupalWebTestCase {
// View blog node.
$this->drupalGet('node/' . $node->nid);
$this->assertResponse(200);
$this->assertTitle($node->title[LANGUAGE_NONE][0]['value'] . ' | Drupal', t('Blog node was displayed'));
$this->assertTitle($node->title . ' | Drupal', t('Blog node was displayed'));
$this->assertText(t('Home ' . $crumb . ' Blogs ' . $crumb . ' @name' . $quote . 's blog', array('@name' => format_username($node_user))), t('Breadcrumbs were displayed'));
// View blog edit node.
$this->drupalGet('node/' . $node->nid . '/edit');
$this->assertResponse($response);
if ($response == 200) {
$this->assertTitle('Edit Blog entry ' . $node->title[LANGUAGE_NONE][0]['value'] . ' | Drupal', t('Blog edit node was displayed'));
$this->assertTitle('Edit Blog entry ' . $node->title . ' | Drupal', t('Blog edit node was displayed'));
}
if ($response == 200) {
// Edit blog node.
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = 'node/' . $node->nid;
$edit["title"] = '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[$langcode][0][value]"])), t('Blog node was edited'));
$this->assertRaw(t('Blog entry %title has been updated.', array('%title' => $edit["title"])), 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[$langcode][0][value]"])), t('Blog node was deleted'));
$this->assertRaw(t('Blog entry %title has been deleted.', array('%title' => $edit["title"])), t('Blog node was deleted'));
}
}
......
......@@ -72,7 +72,7 @@ function book_admin_settings_validate($form, &$form_state) {
* @ingroup forms.
*/
function book_admin_edit($form, $form_state, $node) {
drupal_set_title($node->title[LANGUAGE_NONE][0]['value']);
drupal_set_title($node->title);
$form['#node'] = $node;
_book_admin_table($node, $form);
$form['save'] = array(
......@@ -126,18 +126,18 @@ function book_admin_edit_submit($form, &$form_state) {
if ($row['title']['#default_value'] != $values['title']) {
$node = node_load($values['nid'], FALSE);
$langcode = LANGUAGE_NONE;
$node->title = array($langcode => array(array('value' => $values['title'])));
$node->title = $values['title'];
$node->book['link_title'] = $values['title'];
$node->revision = 1;
$node->log = t('Title changed from %original to %current.', array('%original' => $node->title[$langcode][0]['value'], '%current' => $values['title']));
$node->log = t('Title changed from %original to %current.', array('%original' => $node->title, '%current' => $values['title']));
node_save($node);
watchdog('content', 'book: updated %title.', array('%title' => $node->title[$langcode][0]['value']), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid));
watchdog('content', 'book: updated %title.', array('%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid));
}
}
}
drupal_set_message(t('Updated book %title.', array('%title' => $form['#node']->title[$langcode][0]['value'])));
drupal_set_message(t('Updated book %title.', array('%title' => $form['#node']->title)));
}
/**
......
......@@ -511,7 +511,7 @@ function _book_add_form_elements(&$form, &$form_state, $node) {
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[LANGUAGE_NONE][0]['value'];
$options[$node->nid] = $node->title;
}
else {
foreach (book_get_books() as $book) {
......@@ -560,7 +560,7 @@ function _book_update_outline($node) {
$new = empty($node->book['mlid']);
$node->book['link_path'] = 'node/' . $node->nid;
$node->book['link_title'] = $node->title[LANGUAGE_NONE][0]['value'];
$node->book['link_title'] = $node->title;
$node->book['parent_mismatch'] = FALSE; // The normal case.
if ($node->book['bid'] == $node->nid) {
......@@ -916,7 +916,7 @@ function book_form_node_delete_confirm_alter(&$form, $form_state) {
if (isset($node->book) && $node->book['has_children']) {
$form['book_warning'] = array(
'#markup' => '<p>' . 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[LANGUAGE_NONE][0]['value'])) . '</p>',
'#markup' => '<p>' . 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)) . '</p>',
'#weight' => -10,
);
}
......@@ -1139,7 +1139,7 @@ function book_node_export($node, $children = '') {
*/
function template_preprocess_book_node_export_html(&$variables) {
$variables['depth'] = $variables['node']->book['depth'];
$variables['title'] = check_plain($variables['node']->title[LANGUAGE_NONE][0]['value']);
$variables['title'] = check_plain($variables['node']->title);
$variables['content'] = $variables['node']->rendered;
}
......
......@@ -79,7 +79,7 @@ function book_export_html($nid) {
$contents = book_export_traverse($tree, 'book_node_export');
}
return theme('book_export_html', array('title' => $node->title[LANGUAGE_NONE][0]['value'], 'contents' => $contents, 'depth' => $node->book['depth']));
return theme('book_export_html', array('title' => $node->title, 'contents' => $contents, 'depth' => $node->book['depth']));
}
else {
drupal_access_denied();
......@@ -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[LANGUAGE_NONE][0]['value']);
drupal_set_title($node->title);
return drupal_get_form('book_outline_form', $node);
}
......@@ -188,7 +188,7 @@ function book_outline_form_submit($form, &$form_state) {
*/
function book_remove_form($form, &$form_state, $node) {
$form['#node'] = $node;
$title = array('%title' => $node->title[LANGUAGE_NONE][0]['value']);
$title = array('%title' => $node->title);
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);
......
......@@ -110,7 +110,7 @@ class BookTestCase extends DrupalWebTestCase {
// Check previous, up, and next links.
if ($previous) {
$this->assertRaw(l('‹ ' . $previous->title[LANGUAGE_NONE][0]['value'], 'node/' . $previous->nid, array('attributes' => array('class' => array('page-previous'), 'title' => t('Go to previous page')))), t('Previous page link found.'));
$this->assertRaw(l('‹ ' . $previous->title, 'node/' . $previous->nid, array('attributes' => array('class' => array('page-previous'), 'title' => t('Go to previous page')))), t('Previous page link found.'));
}
if ($up) {
......@@ -118,7 +118,7 @@ class BookTestCase extends DrupalWebTestCase {
}
if ($next) {
$this->assertRaw(l($next->title[LANGUAGE_NONE][0]['value'] . ' ›', 'node/' . $next->nid, array('attributes' => array('class' => array('page-next'), 'title' => t('Go to next page')))), t('Next page link found.'));
$this->assertRaw(l($next->title . ' ›', 'node/' . $next->nid, array('attributes' => array('class' => array('page-next'), 'title' => t('Go to next page')))), t('Next page link found.'));
}
// Compute the expected breadcrumb.
......@@ -140,7 +140,7 @@ class BookTestCase extends DrupalWebTestCase {
// Check printer friendly version.
$this->drupalGet('book/export/html/' . $node->nid);
$this->assertText($node->title[LANGUAGE_NONE][0]['value'], t('Printer friendly title found.'));
$this->assertText($node->title, t('Printer friendly title found.'));
$this->assertRaw(check_markup($node->body[LANGUAGE_NONE][0]['value'], $node->body[LANGUAGE_NONE][0]['format']), t('Printer friendly body found.'));
$number++;
......@@ -154,7 +154,7 @@ class BookTestCase extends DrupalWebTestCase {
function generateOutlinePattern($nodes) {
$outline = '';
foreach ($nodes as $node) {
$outline .= '(node\/' . $node->nid . ')(.*?)(' . $node->title[LANGUAGE_NONE][0]['value'] . ')(.*?)';
$outline .= '(node\/' . $node->nid . ')(.*?)(' . $node->title . ')(.*?)';
}
return '/<div id="book-navigation-' . $this->book->nid . '"(.*?)<ul(.*?)' . $outline . '<\/ul>/s';
......@@ -173,7 +173,7 @@ class BookTestCase extends DrupalWebTestCase {
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $number . ' - SimpleTest test node ' . $this->randomName(10);
$edit["title"] = $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 DrupalWebTestCase {
}
// Check to make sure the book node was created.
$node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$node = $this->drupalGetNodeByTitle($edit['title']);
$this->assertNotNull(($node === FALSE ? NULL : $node), t('Book node found in database.'));
$number++;
......
......@@ -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[LANGUAGE_NONE][0]['value'], 'node/' . $node->nid)));
drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title, 'node/' . $node->nid)));
$op = isset($_POST['op']) ? $_POST['op'] : '';
$build = array();
......
......@@ -210,7 +210,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
case 'node':
$node = node_load($comment->nid);
$title = $node->title[LANGUAGE_NONE][0]['value'];
$title = $node->title;
$replacements[$original] = $sanitize ? filter_xss($title) : $title;
break;
}
......
......@@ -266,7 +266,7 @@ class DBLogTestCase extends DrupalWebTestCase {
// Create node using form to generate add content event (which is not triggered by drupalCreateNode).
$edit = $this->getContent($type);
$langcode = LANGUAGE_NONE;
$title = $edit["title[$langcode][0][value]"];
$title = $edit["title"];
$this->drupalPost('node/add/' . $type, $edit, t('Save'));
$this->assertResponse(200);
// Retrieve node object.
......@@ -324,7 +324,7 @@ class DBLogTestCase extends DrupalWebTestCase {
switch ($type) {
case 'poll':
$content = array(
"title[$langcode][0][value]" => $this->randomName(8),
"title" => $this->randomName(8),
'choice[new:0][chtext]' => $this->randomName(32),
'choice[new:1][chtext]' => $this->randomName(32),
);
......@@ -332,7 +332,7 @@ class DBLogTestCase extends DrupalWebTestCase {
default:
$content = array(
"title[$langcode][0][value]" => $this->randomName(8),
"title" => $this->randomName(8),
"body[$langcode][0][value]" => $this->randomName(32),
);
break;
......
......@@ -1333,7 +1333,7 @@ function hook_field_storage_pre_insert($obj_type, $object, &$skip_fields) {
foreach ($language as $delta) {
$query->values(array(
'nid' => $object->nid,
'title' => $object->title[LANGUAGE_NONE][0]['value'],
'title' => $object->title,
'tid' => $delta['value'],
'sticky' => $object->sticky,
'created' => $object->created,
......
......@@ -90,7 +90,7 @@ class FileFieldTestCase extends DrupalWebTestCase {
function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE) {
$langcode = LANGUAGE_NONE;
$edit = array(
"title[$langcode][0][value]" => $this->randomName(),
"title" => $this->randomName(),
'revision' => (string) (int) $new_revision,
);
......@@ -347,7 +347,7 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
// Try to post a new node without uploading a file.
$langcode = LANGUAGE_NONE;
$edit = array("title[$langcode][0][value]" => $this->randomName());
$edit = array("title" => $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.'));
......@@ -364,7 +364,7 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
$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[$langcode][0][value]" => $this->randomName());
$edit = array('title' => $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.'));
......
......@@ -290,13 +290,13 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $this->randomName();
$edit["title"] = $this->randomName();
$edit["body[$langcode][0][value]"] = $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[$langcode][0][value]"])), t('Filtered node created.'));
$this->assertRaw(t('Page %title has been created.', array('%title' => $edit["title"])), t('Filtered node created.'));
$node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$node = $this->drupalGetNodeByTitle($edit["title"]);
$this->assertTrue($node, t('Node found in database.'));
$this->drupalGet('node/' . $node->nid);
......
......@@ -502,7 +502,7 @@ function forum_field_storage_pre_insert($obj_type, $object, &$skip_fields) {
foreach ($language as $item) {
$query->values(array(
'nid' => $object->nid,
'title' => $object->title[LANGUAGE_NONE][0]['value'],
'title' => $object->title,
'tid' => $item['tid'],
'sticky' => $object->sticky,
'created' => $object->created,
......@@ -536,7 +536,7 @@ function forum_field_storage_pre_update($obj_type, $object, &$skip_fields) {
foreach ($language as $item) {
$query->values(array(
'nid' => $object->nid,
'title' => $object->title[LANGUAGE_NONE][0]['value'],
'title' => $object->title,
'tid' => $item['tid'],
'sticky' => $object->sticky,
'created' => $object->created,
......@@ -677,6 +677,12 @@ function forum_block_view_pre_render($elements) {
*/
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)) {
$forum_terms = $node->taxonomy_forums;
......
......@@ -267,7 +267,7 @@ class ForumTestCase extends DrupalWebTestCase {
$langcode = LANGUAGE_NONE;
$edit = array(
"title[$langcode][0][value]" => $title,
"title" => $title,
"body[$langcode][0][value]" => $body,
"taxonomy_forums[$langcode]" => $tid,
);
......@@ -342,27 +342,27 @@ class ForumTestCase extends DrupalWebTestCase {
// View forum node.
$this->drupalGet('node/' . $node->nid);
$this->assertResponse(200);
$this->assertTitle($node->title[LANGUAGE_NONE][0]['value'] . ' | Drupal', t('Forum node was displayed'));
$this->assertTitle($node->title . ' | Drupal', t('Forum node was displayed'));
$this->assertText(t('Home ' . $crumb . ' Forums ' . $crumb . ' @container ' . $crumb . ' @forum', array('@container' => $this->container['name'], '@forum' => $this->forum['name'])), t('Breadcrumbs were displayed'));
// View forum edit node.
$this->drupalGet('node/' . $node->nid . '/edit');
$this->assertResponse($response);
if ($response == 200) {
$this->assertTitle('Edit Forum topic ' . $node->title[LANGUAGE_NONE][0]['value'] . ' | Drupal', t('Forum edit node was displayed'));
$this->assertTitle('Edit Forum topic ' . $node->title . ' | Drupal', t('Forum edit node was displayed'));
}
if ($response == 200) {
// Edit forum node (including moving it to another forum).
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = 'node/' . $node->nid;
$edit["title"] = 'node/' . $node->nid;
$edit["body[$langcode][0][value]"] = $this->randomName(256);
// Assume the topic is initially associated with $forum.
$edit["taxonomy_forums[$langcode]"] = $this->root_forum['tid'];
$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[$langcode][0][value]"])), t('Forum node was edited'));
$this->assertRaw(t('Forum topic %title has been updated.', array('%title' => $edit["title"])), 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(
......@@ -374,7 +374,7 @@ class ForumTestCase extends DrupalWebTestCase {
// 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[$langcode][0][value]"])), t('Forum node was deleted'));
$this->assertRaw(t('Forum topic %title has been deleted.', array('%title' => $edit['title'])), t('Forum node was deleted'));
}
}
......
......@@ -1340,11 +1340,11 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
// Confirm English language path alias works.
$this->drupalGet($english_path);
$this->assertText($node->title[LANGUAGE_NONE][0]['value'], t('English alias works.'));
$this->assertText($node->title, t('English alias works.'));
// Confirm custom language path alias works.
$this->drupalGet($prefix . '/' . $custom_language_path);
$this->assertText($node->title[LANGUAGE_NONE][0]['value'], t('Custom language alias works.'));
$this->assertText($node->title, t('Custom language alias works.'));
$this->drupalLogout();
}
......@@ -1451,7 +1451,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
$node_body = $this->randomName();
$edit = array(
'type' => 'page',
'title' => array(LANGUAGE_NONE => array(array('value' => $node_title))),
'title' => $node_title,
'body' => array($langcode => array(array('value' => $node_body))),
'language' => $langcode,
);
......@@ -1711,7 +1711,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
function testMultilingualNodeForm() {
// Create page content.
$langcode = LANGUAGE_NONE;
$title_key = "title[$langcode][0][value]";
$title_key = "title";
$title_value = $this->randomName(8);
$body_key = "body[$langcode][0][value]";
$body_value = $this->randomName(16);
......@@ -1750,7 +1750,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
function testMultilingualDisplaySettings() {
// Create page content.
$langcode = LANGUAGE_NONE;
$title_key = "title[$langcode][0][value]";
$title_key = "title";
$title_value = $this->randomName(8);
$body_key = "body[$langcode][0][value]";
$body_value = $this->randomName(16);
......
......@@ -490,7 +490,7 @@ function menu_node_save($node) {
$link['link_path'] = "node/$node->nid";
// If not already set, use the node's title as link title attribute.
if (empty($link['options']['attributes']['title']) && !$link['customized']) {
$link['options']['attributes']['title'] = trim($node->title[LANGUAGE_NONE][0]['value']);
$link['options']['attributes']['title'] = trim($node->title);
}
if (!menu_link_save($link)) {
drupal_set_message(t('There was an error saving the menu link.'), 'error');
......
......@@ -317,7 +317,7 @@ class MenuTestCase extends DrupalWebTestCase {
// Verify menu link link.
$this->clickLink($title);
$title = $parent_node->title[LANGUAGE_NONE][0]['value'];
$title = $parent_node->title;
$this->assertTitle(t("@title | Drupal", array('@title' => $title)), t('Parent menu link link target was correct'));
}
......@@ -327,7 +327,7 @@ class MenuTestCase extends DrupalWebTestCase {
// Verify menu link link.
$this->clickLink($title);
$title = $item_node->title[LANGUAGE_NONE][0]['value'];
$title = $item_node->title;
$this->assertTitle(t("@title | Drupal", array('@title' => $title)), t('Menu link link target was correct'));
}
......@@ -557,7 +557,7 @@ class MenuNodeTestCase extends DrupalWebTestCase {
$node_title = $this->randomName();
$language = LANGUAGE_NONE;
$edit = array(
"title[$language][0][value]" => $node_title,
"title" => $node_title,
"body[$language][0][value]" => $this->randomString(),
);
$this->drupalPost('node/add/page', $edit, t('Save'));
......
......@@ -345,7 +345,7 @@ function _node_mass_update_batch_process($nodes, $updates, &$context) {
$node = _node_mass_update_helper($nid, $updates);
// Store result for post-processing in the finished callback.
$context['results'][] = l($node->title[LANGUAGE_NONE][0]['value'], 'node/' . $node->nid);
$context['results'][] = l($node->title, 'node/' . $node->nid);
// Update our progress information.
$context['sandbox']['progress']++;
......@@ -470,7 +470,7 @@ function node_admin_nodes() {
'title' => array(
'data' => array(
'#type' => 'link',
'#title' => $node->title[LANGUAGE_NONE][0]['value'],
'#title' => $node->title,
'#href' => 'node/' . $node->nid,
'#options' => $l_options,
'#suffix' => ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))),
......
......@@ -443,9 +443,9 @@ function node_update_7006(&$context) {
if (!isset($context['total'])) {
// Initial invocation.
// Re-save node types to create title and body field instances.
// Re-save node types to create body field instances.
foreach ($node_types as $type => $info) {
if ($info->has_title || $info->has_body) {
if ($info->has_body) {
node_type_save($info);
}
}
......@@ -490,7 +490,7 @@ function node_update_7006(&$context) {
'vid' => $revision->vid,
'type' => $revision->type,
);
$node->title[LANGUAGE_NONE][0]['value'] = $revision->title;
$node->title = $revision->title;
if (!empty($revision->teaser) && $revision->teaser != text_summary($revision->body)) {
$node->body[LANGUAGE_NONE][0]['summary'] = $revision->teaser;
}
......
......@@ -597,52 +597,27 @@ function node_configure_fields($type) {
elseif (!empty($instance)) {
field_delete_instance($instance);
}
}
if ($type->has_title) {
// Add the title field if not present.
$field = field_info_field('title');
$instance = field_info_instance('node', 'title', $type->type);
/**
* Implements hook_field_extra_fields().
*/
function node_field_extra_fields() {
$extra = array();
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',
'object_type' => 'node',
'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' => 'text_default',
'weight' => $weight,
),
'teaser' => array(
'label' => 'hidden',
'type' => 'text_default',
'weight' => $weight,
),
foreach (node_type_get_types() as $type) {
if ($type->has_title) {
$extra['node'][$type->type] = array(
'title' => array(
'label' => $type->title_label,
'description' => t('Node module element.'),
'weight' => -5,
),
);
field_create_instance($instance);
}
else {
$instance['label'] = $type->title_label;
field_update_instance($instance);
}
}
return $extra;
}
/**
......@@ -1007,14 +982,6 @@ function node_save($node) {
$node->timestamp = REQUEST_TIME;
$update_node = TRUE;
// When converting the title property to fields we preserved the {node}.title
// db column for performance, setting the default language value into this
// column. After this we restore the field data structure to the previous node
// title field.
$title_field = $node->title;
$langcode = 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);
......@@ -1039,9 +1006,6 @@ 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').
......@@ -1252,7 +1216,7 @@ function node_build_content($node, $view_mode = 'full') {
$links['node_readmore'] = array(
'title' => t('Read more'),
'href' => 'node/' . $node->nid,
'attributes' => array('rel' => 'tag', 'title' => strip_tags($node->title[LANGUAGE_NONE][0]['value']))
'attributes' => array('rel' => 'tag', 'title' => strip_tags($node->title))