diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-11 03:07:21 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-11 03:07:21 +0000 |
commit | b3265dbe174ce0efefa181b8af6c1eaea3ff22c2 (patch) | |
tree | aa7e8b709c162fd781748d8bebaa12c75727e01e /modules/book | |
parent | 64a1a0d67eb5aecc8e6d78469b19f58e8443c717 (diff) | |
download | brdo-b3265dbe174ce0efefa181b8af6c1eaea3ff22c2.tar.gz brdo-b3265dbe174ce0efefa181b8af6c1eaea3ff22c2.tar.bz2 |
#557292 by peximo, plach, catch, and yched: Convert node title to Field API.
Diffstat (limited to 'modules/book')
-rw-r--r-- | modules/book/book.admin.inc | 12 | ||||
-rw-r--r-- | modules/book/book.module | 8 | ||||
-rw-r--r-- | modules/book/book.pages.inc | 6 | ||||
-rw-r--r-- | modules/book/book.test | 12 |
4 files changed, 20 insertions, 18 deletions
diff --git a/modules/book/book.admin.inc b/modules/book/book.admin.inc index b6a7e9b5d..072908862 100644 --- a/modules/book/book.admin.inc +++ b/modules/book/book.admin.inc @@ -78,7 +78,7 @@ function book_admin_settings_validate($form, &$form_state) { * @ingroup forms. */ function book_admin_edit($form, $form_state, $node) { - drupal_set_title($node->title); + drupal_set_title($node->title[FIELD_LANGUAGE_NONE][0]['value']); $form['#node'] = $node; _book_admin_table($node, $form); $form['save'] = array( @@ -131,17 +131,19 @@ function book_admin_edit_submit($form, &$form_state) { // Update the title if changed. if ($row['title']['#default_value'] != $values['title']) { $node = node_load($values['nid'], FALSE); - $node->title = $values['title']; + $langcode = FIELD_LANGUAGE_NONE; + $node->title = array($langcode => array(array('value' => $values['title']))); $node->book['link_title'] = $values['title']; $node->revision = 1; - $node->log = t('Title changed from %original to %current.', array('%original' => $node->title, '%current' => $values['title'])); + $node->log = t('Title changed from %original to %current.', array('%original' => $node->title[$langcode][0]['value'], '%current' => $values['title'])); + node_save($node); - watchdog('content', 'book: updated %title.', array('%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid)); + watchdog('content', 'book: updated %title.', array('%title' => $node->title[$langcode][0]['value']), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid)); } } } - drupal_set_message(t('Updated book %title.', array('%title' => $form['#node']->title))); + drupal_set_message(t('Updated book %title.', array('%title' => $form['#node']->title[$langcode][0]['value']))); } /** diff --git a/modules/book/book.module b/modules/book/book.module index 3adb48741..1daf7d657 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -477,7 +477,7 @@ function _book_add_form_elements(&$form, $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; + $options[$node->nid] = $node->title[FIELD_LANGUAGE_NONE][0]['value']; } else { foreach (book_get_books() as $book) { @@ -526,7 +526,7 @@ function _book_update_outline($node) { $new = empty($node->book['mlid']); $node->book['link_path'] = 'node/' . $node->nid; - $node->book['link_title'] = $node->title; + $node->book['link_title'] = $node->title[FIELD_LANGUAGE_NONE][0]['value']; $node->book['parent_mismatch'] = FALSE; // The normal case. if ($node->book['bid'] == $node->nid) { @@ -882,7 +882,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)) . '</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[FIELD_LANGUAGE_NONE][0]['value'])) . '</p>', '#weight' => -10, ); } @@ -1103,7 +1103,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); + $variables['title'] = check_plain($variables['node']->title[FIELD_LANGUAGE_NONE][0]['value']); $variables['content'] = $variables['node']->rendered; } diff --git a/modules/book/book.pages.inc b/modules/book/book.pages.inc index 206f61b79..0162fa69e 100644 --- a/modules/book/book.pages.inc +++ b/modules/book/book.pages.inc @@ -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, 'contents' => $contents, 'depth' => $node->book['depth'])); + return theme('book_export_html', array('title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'], '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); + drupal_set_title($node->title[FIELD_LANGUAGE_NONE][0]['value']); 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); + $title = array('%title' => $node->title[FIELD_LANGUAGE_NONE][0]['value']); 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); diff --git a/modules/book/book.test b/modules/book/book.test index e382f1d99..335fa4166 100644 --- a/modules/book/book.test +++ b/modules/book/book.test @@ -110,7 +110,7 @@ class BookTestCase extends DrupalWebTestCase { // Check previous, up, and next links. if ($previous) { - $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.')); + $this->assertRaw(l('‹ ' . $previous->title[FIELD_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.')); } if ($up) { @@ -118,7 +118,7 @@ class BookTestCase extends DrupalWebTestCase { } if ($next) { - $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.')); + $this->assertRaw(l($next->title[FIELD_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.')); } // 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, t('Printer friendly title found.')); + $this->assertText($node->title[FIELD_LANGUAGE_NONE][0]['value'], t('Printer friendly title found.')); $this->assertRaw(check_markup($node->body[FIELD_LANGUAGE_NONE][0]['value'], $node->body[FIELD_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 . ')(.*?)'; + $outline .= '(node\/' . $node->nid . ')(.*?)(' . $node->title[FIELD_LANGUAGE_NONE][0]['value'] . ')(.*?)'; } return '/<div id="book-navigation-' . $this->book->nid . '"(.*?)<ul(.*?)' . $outline . '<\/ul>/s'; @@ -172,8 +172,8 @@ class BookTestCase extends DrupalWebTestCase { 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 DrupalWebTestCase { } // 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++; |