diff options
Diffstat (limited to 'modules/node')
-rw-r--r-- | modules/node/node.install | 6 | ||||
-rw-r--r-- | modules/node/node.pages.inc | 2 | ||||
-rw-r--r-- | modules/node/node.test | 26 | ||||
-rw-r--r-- | modules/node/node.tpl.php | 7 |
4 files changed, 27 insertions, 14 deletions
diff --git a/modules/node/node.install b/modules/node/node.install index ddb571ebd..2c7e6f843 100644 --- a/modules/node/node.install +++ b/modules/node/node.install @@ -511,15 +511,15 @@ function node_update_7006(&$context) { 'type' => $revision->type, ); if (!empty($revision->teaser) && $revision->teaser != text_summary($revision->body)) { - $node->body[0]['summary'] = $revision->teaser; + $node->body[FIELD_LANGUAGE_NONE][0]['summary'] = $revision->teaser; } // Do this after text_summary() above. $break = '<!--break-->'; if (substr($revision->body, 0, strlen($break)) == $break) { $revision->body = substr($revision->body, strlen($break)); } - $node->body[0]['value'] = $revision->body; - $node->body[0]['format'] = $revision->format; + $node->body[FIELD_LANGUAGE_NONE][0]['value'] = $revision->body; + $node->body[FIELD_LANGUAGE_NONE][0]['format'] = $revision->format; // This is a core update and no contrib modules are enabled yet, so // we can assume default field storage for a faster update. field_sql_storage_field_storage_write('node', $node, FIELD_STORAGE_INSERT, array()); diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc index 2c1b942d6..df66459e6 100644 --- a/modules/node/node.pages.inc +++ b/modules/node/node.pages.inc @@ -285,7 +285,7 @@ function node_form(&$form_state, $node) { $form['#theme'] = array($node->type . '_node_form', 'node_form'); $form['#builder_function'] = 'node_form_submit_build_node'; - field_attach_form('node', $node, $form, $form_state); + field_attach_form('node', $node, $form, $form_state, $node->language); return $form; } diff --git a/modules/node/node.test b/modules/node/node.test index b567ba77d..8e771282f 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -141,7 +141,7 @@ class NodeRevisionsTestCase extends DrupalWebTestCase { // Confirm the correct revision text appears on "view revisions" page. $this->drupalGet("node/$node->nid/revisions/$node->vid/view"); - $this->assertText($node->body[0]['value'], t('Correct text displays for version.')); + $this->assertText($node->body[FIELD_LANGUAGE_NONE][0]['value'], t('Correct text displays for version.')); // Confirm the correct log message appears on "revisions overview" page. $this->drupalGet("node/$node->nid/revisions"); @@ -155,7 +155,7 @@ class NodeRevisionsTestCase extends DrupalWebTestCase { array('@type' => 'Page', '%title' => $nodes[1]->title, '%revision-date' => format_date($nodes[1]->revision_timestamp))), t('Revision reverted.')); $reverted_node = node_load($node->nid); - $this->assertTrue(($nodes[1]->body[0]['value'] == $reverted_node->body[0]['value']), t('Node reverted correctly.')); + $this->assertTrue(($nodes[1]->body[FIELD_LANGUAGE_NONE][0]['value'] == $reverted_node->body[FIELD_LANGUAGE_NONE][0]['value']), t('Node reverted correctly.')); // Confirm revisions delete properly. $this->drupalPost("node/$node->nid/revisions/{$nodes[1]->vid}/delete", array(), t('Delete')); @@ -186,7 +186,8 @@ class PageEditTestCase extends DrupalWebTestCase { * Check node edit functionality. */ function testPageEdit() { - $body_key = 'body[0][value]'; + $langcode = FIELD_LANGUAGE_NONE; + $body_key = "body[$langcode][0][value]"; // Create node to edit. $edit = array(); $edit['title'] = $this->randomName(8); @@ -241,7 +242,8 @@ class PagePreviewTestCase extends DrupalWebTestCase { * Check the node preview functionality. */ function testPagePreview() { - $body_key = 'body[0][value]'; + $langcode = FIELD_LANGUAGE_NONE; + $body_key = "body[$langcode][0][value]"; // Fill in node creation form and preview node. $edit = array(); @@ -263,7 +265,8 @@ class PagePreviewTestCase extends DrupalWebTestCase { * Check the node preview functionality, when using revisions. */ function testPagePreviewWithRevisions() { - $body_key = 'body[0][value]'; + $langcode = FIELD_LANGUAGE_NONE; + $body_key = "body[$langcode][0][value]"; // Force revision on page content. variable_set('node_options_page', array('status', 'revision')); @@ -311,7 +314,8 @@ class PageCreationTestCase extends DrupalWebTestCase { // Create a node. $edit = array(); $edit['title'] = $this->randomName(8); - $edit['body[0][value]'] = $this->randomName(16); + $langcode = FIELD_LANGUAGE_NONE; + $edit["body[$langcode][0][value]"] = $this->randomName(16); $this->drupalPost('node/add/page', $edit, t('Save')); // Check that the page has been created. @@ -377,7 +381,7 @@ class SummaryLengthTestCase extends DrupalWebTestCase { function testSummaryLength() { // Create a node to view. $settings = array( - 'body' => array(array('value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae arcu at leo cursus laoreet. Curabitur dui tortor, adipiscing malesuada tempor in, bibendum ac diam. Cras non tellus a libero pellentesque condimentum. What is a Drupalism? Suspendisse ac lacus libero. Ut non est vel nisl faucibus interdum nec sed leo. Pellentesque sem risus, vulputate eu semper eget, auctor in libero. Ut fermentum est vitae metus convallis scelerisque. Phasellus pellentesque rhoncus tellus, eu dignissim purus posuere id. Quisque eu fringilla ligula. Morbi ullamcorper, lorem et mattis egestas, tortor neque pretium velit, eget eleifend odio turpis eu purus. Donec vitae metus quis leo pretium tincidunt a pulvinar sem. Morbi adipiscing laoreet mauris vel placerat. Nullam elementum, nisl sit amet scelerisque malesuada, dolor nunc hendrerit quam, eu ultrices erat est in orci. Curabitur feugiat egestas nisl sed accumsan.')), + 'body' => array(FIELD_LANGUAGE_NONE => array(array('value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae arcu at leo cursus laoreet. Curabitur dui tortor, adipiscing malesuada tempor in, bibendum ac diam. Cras non tellus a libero pellentesque condimentum. What is a Drupalism? Suspendisse ac lacus libero. Ut non est vel nisl faucibus interdum nec sed leo. Pellentesque sem risus, vulputate eu semper eget, auctor in libero. Ut fermentum est vitae metus convallis scelerisque. Phasellus pellentesque rhoncus tellus, eu dignissim purus posuere id. Quisque eu fringilla ligula. Morbi ullamcorper, lorem et mattis egestas, tortor neque pretium velit, eget eleifend odio turpis eu purus. Donec vitae metus quis leo pretium tincidunt a pulvinar sem. Morbi adipiscing laoreet mauris vel placerat. Nullam elementum, nisl sit amet scelerisque malesuada, dolor nunc hendrerit quam, eu ultrices erat est in orci. Curabitur feugiat egestas nisl sed accumsan.'))), 'promote' => 1, ); $node = $this->drupalCreateNode($settings); @@ -500,7 +504,8 @@ class NodePostSettingsTestCase extends DrupalWebTestCase { // Create a node. $edit = array(); $edit['title'] = $this->randomName(8); - $edit['body[0][value]'] = $this->randomName(16); + $langcode = FIELD_LANGUAGE_NONE; + $edit["body[$langcode][0][value]"] = $this->randomName(16); $this->drupalPost('node/add/page', $edit, t('Save')); // Check that the post information is displayed. @@ -521,7 +526,8 @@ class NodePostSettingsTestCase extends DrupalWebTestCase { // Create a node. $edit = array(); $edit['title'] = $this->randomName(8); - $edit['body[0][value]'] = $this->randomName(16); + $langcode = FIELD_LANGUAGE_NONE; + $edit["body[$langcode][0][value]"] = $this->randomName(16); $this->drupalPost('node/add/page', $edit, t('Save')); // Check that the post information is displayed. @@ -764,7 +770,7 @@ class NodeSaveTestCase extends DrupalWebTestCase { $title = $this->randomName(8); $node = array( 'title' => $title, - 'body' => array(array('value' => $this->randomName(32))), + 'body' => array(FIELD_LANGUAGE_NONE => array(array('value' => $this->randomName(32)))), 'uid' => $this->web_user->uid, 'type' => 'article', 'nid' => $test_nid, diff --git a/modules/node/node.tpl.php b/modules/node/node.tpl.php index 8aa31ca04..6ca204a5d 100644 --- a/modules/node/node.tpl.php +++ b/modules/node/node.tpl.php @@ -59,6 +59,13 @@ * - $logged_in: Flags true when the current user is a logged-in member. * - $is_admin: Flags true when the current user is an administrator. * + * Field variables: for each field instance attached to the node a corresponding + * variable is defined, e.g. $node->body becomes $body. When needing to access + * a field's raw values, developers/themers are strongly encouraged to use these + * variables. Otherwise they will have to explicitly specify the desired field + * language, e.g. $node->body['en'], thus overriding any language negotiation + * rule that was previously applied. + * * @see template_preprocess() * @see template_preprocess_node() * @see template_process() |