Index: modules/book/book.css =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.css,v retrieving revision 1.1 diff -u -p -r1.1 book.css --- modules/book/book.css 14 Aug 2006 07:14:49 -0000 1.1 +++ modules/book/book.css 28 Aug 2006 22:25:34 -0000 @@ -19,3 +19,12 @@ .book-navigation .page-next { text-align: left; } +.book-toc { + border-top: 1px solid #888; + border-bottom: 1px solid #888; +} +h2.book-outline { + border-top: 1px solid #888; + margin-top: 1em; + padding-top: 1em; +} Index: modules/book/book.install =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.install,v retrieving revision 1.5 diff -u -p -r1.5 book.install --- modules/book/book.install 20 Aug 2006 06:38:50 -0000 1.5 +++ modules/book/book.install 28 Aug 2006 22:25:34 -0000 @@ -1,30 +1,110 @@ array( + 'book_page' => array( 'name' => t('book page'), + 'module' => 'book_page', + 'description' => t("A book page is usually added to a book, but can also be independent. Books can represent a collaborative writing effort: users can collaborate writing the pages of the book, positioning the pages in the right order, and reviewing or modifying pages"), + ), + 'book' => array( + 'name' => t('book'), 'module' => 'book', - 'description' => t("A book is a collaborative writing effort: users can collaborate writing the pages of the book, positioning the pages in the right order, and reviewing or modifying pages previously written. So when you have some information to share or when you read a page of the book and you didn't like it, or if you think a certain page could have been written better, you can do something about it."), - ) + 'description' => t('Add a new book- this has a table of contents (for associated book pages), a list of authors, etc. Book pages (and other content) can then be added to this book'), + ), ); } @@ -27,24 +37,36 @@ function book_perm() { } /** - * Implementation of hook_access(). + * Implementation of hook_access() for a book cover. */ function book_access($op, $node) { global $user; if ($op == 'create') { - // Only registered users can create book pages. Given the nature - // of the book module this is considered to be a good/safe idea. - return user_access('create book pages'); + return user_access('create new books'); } - if ($op == 'update') { - // Only registered users can update book pages. Given the nature - // of the book module this is considered to be a good/safe idea. - // One can only update a book page if there are no suggested updates - // of that page waiting for approval. That is, only updates that - // don't overwrite the current or pending information are allowed. + if ($node->uid == $user->uid && user_access('edit own book pages')) { + return TRUE; + } + else { + // do nothing. node-access() will determine further access + } + } +} + +/** + * Implementation of hook_access() for a book page. + */ +function book_page_access($op, $node) { + global $user; + + if ($op == 'create') { + return user_access('create book pages'); + } + if ($op == 'update') { + // users with 'edit book pages' permission may edit ALL book pages. if (user_access('edit book pages') || ($node->uid == $user->uid && user_access('edit own book pages'))) { return TRUE; } @@ -61,12 +83,24 @@ function book_link($type, $node = NULL, $links = array(); + if ($type == 'node' && $node->type == 'book') { + if (book_page_access('create', $node)) { + $links['book_add_child'] = array( + 'title' => t('add child page'), + 'href' => "node/add/book_page", + 'query' => 'book='. $node->nid. '/'. $node->nid, + ); + } + return $links; + } + if ($type == 'node' && isset($node->parent)) { if (!$teaser) { - if (book_access('create', $node)) { + if (book_page_access('create', $node)) { $links['book_add_child'] = array( 'title' => t('add child page'), - 'href' => "node/add/book/parent/$node->nid" + 'href' => "node/add/book_page", + 'query' => 'book='. $node->bid. '/'. $node->nid, ); } if (user_access('see printer-friendly version')) { @@ -108,10 +142,10 @@ function book_menu($may_cache) { 'weight' => 8); $items[] = array( 'path' => 'book', - 'title' => t('books'), - 'callback' => 'book_render', - 'access' => user_access('access content'), - 'type' => MENU_SUGGESTED_ITEM); + 'title' => t('book shelf'), + 'callback' => 'book_shelf', + 'type' => MENU_NORMAL_ITEM, + 'access' => user_access('access content')); $items[] = array( 'path' => 'book/export', 'callback' => 'book_export', @@ -123,17 +157,24 @@ function book_menu($may_cache) { // We put this in !$may_cache so it's only added once per request drupal_add_css(drupal_get_path('module', 'book') .'/book.css'); + $items[] = array( + 'path' => 'node/add/book_page/select_book', + 'title' => t('New page'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('_add_page_select_book'), + 'access' => user_access('create book pages'), + 'type' => MENU_LOCAL_TASK, + 'weight' => 2); // To avoid SQL overhead, check whether we are on a node page and whether the // user is allowed to outline posts in books. if (arg(0) == 'node' && is_numeric(arg(1)) && user_access('outline posts in books')) { - // Only add the outline-tab for non-book pages: - $result = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.nid = %d AND n.type != 'book'"), arg(1)); - if (db_num_rows($result) > 0) { + $type = db_result(db_query("SELECT n.type FROM {node} n WHERE n.nid=%d",arg(1))); + if (($type) && $type != 'book') { $items[] = array( 'path' => 'node/'. arg(1) .'/outline', 'title' => t('outline'), 'callback' => 'drupal_get_form', - 'callback arguments' => array('book_outline', arg(1)), + 'callback arguments' => array('book_outline_form',arg(1)), 'access' => user_access('outline posts in books'), 'type' => MENU_LOCAL_TASK, 'weight' => 2); @@ -147,32 +188,45 @@ function book_menu($may_cache) { /** * Implementation of hook_block(). * - * Displays the book table of contents in a block when the current page is a - * single-node view of a book node. + * The navigation block displays the book table of contents in a block when the + * current page is a single-node view a node that's in the book hierarchy. The + * license block displays the license of the associated book. */ function book_block($op = 'list', $delta = 0) { $block = array(); if ($op == 'list') { - $block[0]['info'] = t('Book navigation'); + $block['navigation']['info'] = t('Book navigation'); + $block['license']['info'] = t('Book license'); return $block; } else if ($op == 'view') { - // Only display this block when the user is browsing a book: + // Book license block + // Only display this block when the user is browsing a node in the book outline (book_pages table): + if ($delta == 'license') { + if (arg(0) == 'node' && is_numeric(arg(1))) { + $result = db_query('SELECT b.book_license, n.title, nr.format FROM {book} b JOIN {book_pages} bp ON bp.bid = b.nid INNER JOIN {node} n ON n.vid = b.vid JOIN {node_revisions} nr ON nr.vid = n.vid WHERE bp.nid = %d', arg(1)); + if (db_num_rows($result) > 0) { + $book = db_fetch_object($result); + $block['subject'] = t('%book_title license', array('%book_title' => $book->title)); + $block['content'] = check_markup($book->book_license, $book->format, FALSE); + } + } + return $block; + } + // Book navigation block + // Only display this block when the user is browsing a node in the book outline (book_pages table): if (arg(0) == 'node' && is_numeric(arg(1))) { - $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d'), arg(1)); - if (db_num_rows($result) > 0) { - $node = db_fetch_object($result); - - $path = book_location($node); - $path[] = $node; - + $this_node = node_load(arg(1)); + if (isset($this_node->bid) && $this_node->type != 'book') { + $path = book_location($this_node); + $path[] = $this_node; + $expand = array(); foreach ($path as $key => $node) { $expand[] = $node->nid; } - + $block['content'] = book_page_menu_tree($this_node->bid,$path[0]->nid, 5, $expand); $block['subject'] = check_plain($path[0]->title); - $block['content'] = book_tree($expand[0], 5, $expand); } } @@ -181,68 +235,172 @@ function book_block($op = 'list', $delta } /** - * Implementation of hook_load(). + * Implementation of hook_load() for a book (cover). */ function book_load($node) { - return db_fetch_object(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid)); + return db_fetch_array(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid)); } /** - * Implementation of hook_insert(). + * Implementation of hook_insert() for a book (cover). */ function book_insert($node) { - db_query("INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->parent, $node->weight); + db_query('INSERT INTO {book} (nid, vid, book_author, book_license, weight, toc_depth) VALUES (%d, %d, "%s", "%s", %d, %d)', $node->nid, $node->vid, $node->book_author, $node->book_license, $node->weight, $node->toc_depth); + $node->bid = $node->nid; + $node->parent = 0; + book_page_insert($node); } /** - * Implementation of hook_update(). + * Implementation of hook_insert() for book pages. + */ +function book_page_insert($node) { + db_query("INSERT INTO {book_pages} (nid, bid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->bid, $node->parent, $node->weight); +} + +/** + * Implementation of hook_update() for book nodes (covers). */ function book_update($node) { if ($node->revision) { - db_query("INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->parent, $node->weight); + db_query('INSERT INTO {book} (nid, vid, book_author, book_license, weight, toc_depth) VALUES (%d, %d, "%s", "%s", %d, %d)', $node->nid, $node->vid, $node->book_author, $node->book_license, $node->weight, $node->toc_depth); } else { - db_query("UPDATE {book} SET parent = %d, weight = %d WHERE vid = %d", $node->parent, $node->weight, $node->vid); + db_query('UPDATE {book} SET book_author = "%s", weight = %d, book_license = "%s", toc_depth = %d WHERE vid = %d', $node->book_author, $node->weight, $node->book_license, $node->toc_depth, $node->vid); } + $node->bid = $node->nid; + $node->parent = 0; + book_page_update($node); } /** - * Implementation of hook_delete(). + * Implementation of hook_update().for book pages + */ +function book_page_update($node) { + db_query("UPDATE {book_pages} SET bid = %d, parent = %d, weight = %d WHERE nid = %d", $node->bid, $node->parent, $node->weight, $node->nid); +} + +/** + * Implementation of hook_delete() for book nodes (covers) */ function book_delete(&$node) { + db_query('UPDATE {book_pages} SET bid = 0 WHERE bid = %d', $node->nid); + db_query('UPDATE {book_pages} SET parent = 0 WHERE parent = %d', $node->nid); db_query('DELETE FROM {book} WHERE nid = %d', $node->nid); } /** - * Implementation of hook_submit(). + * Implementation of hook_submit() for book pages. */ -function book_submit(&$node) { +function book_page_submit(&$node) { global $user; // Set default values for non-administrators. if (!user_access('administer nodes')) { - $node->revision = 1; - $book->uid = $user->uid; - $book->name = $user->uid ? $user->name : ''; + $node->revision = TRUE; + $node->uid = $user->uid; //TODO: do we want these settings? } } /** - * Implementation of hook_form(). + * Implementation of hook_form() for a book */ function book_form(&$node) { - $type = node_get_types('type', $node); - if ($node->nid && !$node->parent && !user_access('create new books')) { - $form['parent'] = array('#type' => 'value', '#value' => $node->parent); + + $form['title'] = array('#type' => 'textfield', + '#title' => t('Title'), + '#required' => TRUE, + '#default_value' => $node->title, + '#weight' => -5, + '#description' => t('Title of the whole book.'), + ); + $form['body_filter']['body'] = array('#type' => 'textarea', + '#title' => t('Body'), + '#default_value' => $node->body, + '#rows' => 20, + '#required' => TRUE, + '#description' => t('The content of book cover.'), + ); + $form['weight'] = array( + '#type' => 'weight', + '#title' => t('Book weight'), + '#default_value' => (isset($node->weight) ? $node->weight : 0), + '#delta' => 15, + '#description' => t('Books are ordered first by weight and then by title.'), + ); + $form['body_filter']['format'] = filter_form($node->format); + $form['book_author'] = array('#type' => 'textfield', + '#title' => t('Author'), + '#required' => FALSE, + '#default_value' => $node->book_author, + '#description' => t('The author of all the book pages that will be added to this book. The author can be a single person, or a collective. Leave blank if you do not wish to display the authoring information on the book cover.'), + ); + $form['book_license'] = array('#type' => 'textarea', + '#title' => t('License'), + '#default_value' => $node->book_license, + '#rows' => 5, + '#required' => FALSE, + '#description' => t('The license of all the book pages within this book. This information can be displayed within a block on each relevant book page. Leave blank if you do not wish to display any license information. The input format is the same as the one selected for the body.'), + ); + $form['toc_depth'] = array( + '#type' => 'select', + '#title' => t('Preferred depth for table of contents display'), + '#default_value' => (($node->toc_depth > 0) ? $node->toc_depth : 5), + '#options' => array( + 1 => '1', + 2 => '2', + 3 => '3', + 4 => '4', + 5 => '5', + 6 => '6', + 7 => '7', + 8 => '8', + 9 => '9', + 10 => '10', + 15 => '15', + 20 => '20', ), + '#description' => t('The table of contents on the book page will be displayed to this depth (depending upon your theme).'), + ); + + return $form; +} + + +/** + * Implementation of hook_form() for a book page. + */ +function book_page_form(&$node) { + + // looking for url like node/add/book-page?book=$bid/$parent + if ((arg(1)=='add') && isset($_GET['book'])) { + $book = explode('/', $_GET['book']); + if (is_numeric($book[0]) && is_numeric($book[1])){ + $node->bid = $book[0]; //needs to be validated below + $node->parent = $book[1]; + if (!array_key_exists($node->bid, _list_books())) { + $node->bid = 0; + $node->parent = 0; + } + } } - else { - $form['parent'] = array('#type' => 'select', - '#title' => t('Parent'), - '#default_value' => ($node->parent ? $node->parent : arg(4)), - '#options' => book_toc($node->nid), - '#weight' => -4, - '#description' => user_access('create new books') ? t('The parent section in which to place this page. Note that each page whose parent is <top-level> is an independent, top-level book.') : t('The parent that this page belongs in.'), - ); + elseif (arg(2) == 'book-page') { + drupal_goto('node/add/book_page/select_book'); } + + if (!isset($node->bid)) { + $node->bid = 0; + } + if (!isset($node->parent)) { + $node->parent = $node->bid; + } + + $form = _book_parent_and_log_form($node); + + $form['bid'] = array ( + '#type' => 'value', + '#value' => $node->bid, + ); + + $type = node_get_types('type', $node); $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), @@ -258,128 +416,289 @@ function book_form(&$node) { ); $form['body_filter']['format'] = filter_form($node->format); + return $form; +} + +/** + * Helper function: generate a form for setting the parent, log message, and weight. + */ +function _book_parent_and_log_form($node) { + $form=array(); + + if ($node->bid != 0 && array_key_exists($node->bid, $all_books = _list_books())) { + $form_parent_title = t('Position in the book %book', array('%book' => $all_books[$node->bid])); + } + else { + $node->bid = 0; + $form_parent_title = t('Parent'); + } + + $form['parent'] = array( + '#type' => 'select', + '#title' => $form_parent_title, + '#default_value' => $node->parent, + '#options' => select_book_page_parent($node->nid, $node->bid), + '#weight' => -4, + '#description' => t('The parent that this page belongs under. "Top level" means the highest level within this book.'), + ); + $form['log'] = array( '#type' => 'textarea', '#title' => t('Log message'), + '#rows' => 2, '#weight' => 5, '#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.'), ); - if (user_access('administer nodes')) { - $form['weight'] = array('#type' => 'weight', - '#title' => t('Weight'), - '#default_value' => $node->weight, + if (user_access('outline posts in books')) { + $form['weight'] = array( + '#type' => 'weight', + '#title' => t('Book outline weight'), + '#default_value' => (isset($node->weight) ? $node->weight : 0), '#delta' => 15, - '#weight' => 5, + '#weight' => 6, '#description' => t('Pages at a given level are ordered first by weight and then by title.'), - ); + ); } else { - // If a regular user updates a book page, we preserve the node weight; otherwise + // If a regular user updates a book page, we preserve the node weight; otherwise // we use 0 as the default for new pages $form['weight'] = array( - '#type' => 'value', - '#value' => isset($node->weight) ? $node->weight : 0, - ); + '#type' => 'value', + '#value' => (isset($node->weight) ? $node->weight : 0), + ); } - return $form; } /** - * Implementation of function book_outline() - * Handles all book outline operations. + * Helper function: return an array of available books as (bid => title). */ -function book_outline($nid) { - $node = node_load($nid); - $page = book_load($node); +function _list_books(){ + static $books = NULL; + + if (empty($books)) { + $result = db_query(db_rewrite_sql('SELECT b.nid, n.title FROM {book} b JOIN {node} n ON n.vid = b.vid ORDER BY b.weight ASC, n.title ASC')); + $books = array(); + $books[0] = t('Independent, top-level book page'); + while ($book = db_fetch_object($result)) { + $books[$book->nid] = $book->title; + } + } + return $books; +} + +/** + * Helper function: generate a select form listing available books. + */ +function _book_select_form($default_bid = 0, $nid, $note = NULL){ - $form['parent'] = array('#type' => 'select', - '#title' => t('Parent'), - '#default_value' => $page->parent, - '#options' => book_toc($node->nid), - '#description' => t('The parent page in the book.'), - ); - $form['weight'] = array('#type' => 'weight', - '#title' => t('Weight'), - '#default_value' => $page->weight, - '#delta' => 15, - '#description' => t('Pages at a given level are ordered first by weight and then by title.'), + $books = _list_books(); + + $form = array(); + $form['bid'] = array( + '#type' => 'select', + '#title' => t('Select a book'), + '#default_value' => $default_bid, + '#options' => $books, + '#description' => t('Select the book you wish to add/move your page to.'), + '#weight' => 50, + ); + $form['nid'] = array( + '#type' => 'value', + '#value' => $nid, ); - $form['log'] = array('#type' => 'textarea', - '#title' => t('Log message'), - '#description' => t('An explanation to help other authors understand your motivations to put this post into the book.'), + if ($note) { + $form['note'] = array( + '#value' => '
'. $note. '
', + '#weight' => 52, + ); + } + + return $form; +} + +/** + * Prints a list of books in which the user can add pages. + */ +function _add_page_select_book() { + + $form = _book_select_form(0,0,t("After choosing a book, you will be able to edit your page and position it within the book.")); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Select book'), + '#weight' => 65, ); + return $form; +} + +/** + * Menu call back: Select a book to move a page to. + */ +function _add_page_select_book_submit($form_id, $form) { - $form['nid'] = array('#type' => 'value', '#value' => $nid); - if ($page->nid) { - $form['update'] = array('#type' => 'submit', + drupal_goto('node/add/book-page','book='. $form['bid']. '/'. $form['bid']); +} + +/** + * Menu call back: handle all book outline operations on individual nodes. + */ +function book_outline_form($nid){ + + $node = node_load($nid); + + if ($node->type == 'book') { + return array(); + } + + if (isset($node->bid)) { // node is already part of the book outline + + $form = _book_parent_and_log_form($node); + + $form['outline_heading'] = array( + '#value' => ''. $license .'
'; + return $output; +} + +/** +* Implementation of hook_view() for a book cover. +*/ +function book_view(&$node, $teaser = FALSE, $page = FALSE) { + $node = node_prepare($node, $teaser); + if (!empty($node->book_author)) { + $node->content['book_author'] = array( + '#value' => theme('book_author', $node->book_author), + '#weight' => -1, + ); + $node->teaser = ''. $node->teaser; + } + if (!empty($node->book_license)) { + $node->book_license = check_markup($node->book_license, $node->format, FALSE); + $node->content['book_license'] = array( + '#value' => theme('book_license', $node->book_license) , + '#weight' => 100, + ); + } + if (!$teaser) { + $node->content['book_toc'] = array( + '#value' => theme('book_toc', $node), + '#weight' => 200, + ); + } + return $node; +} + +/** + * Create formatted html for the table of contents displayed on book $node. + * + * @ingroup themeable + */ +function theme_book_toc($node) { + $toc = ''. t('There are no child pages for %book', array ('%book' => $node->title)). '
', + ); + } return $form; } @@ -903,7 +1383,7 @@ function book_admin_edit($nid) { * Menu callback; displays a listing of all orphaned book pages. */ function book_admin_orphan() { - $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.status, b.parent FROM {node} n INNER JOIN {book} b ON n.vid = b.vid')); + $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.status, bp.parent FROM {node} n INNER JOIN {book_pages} bp ON n.nid = bp.nid')); $pages = array(); while ($page = db_fetch_object($result)) { @@ -920,12 +1400,12 @@ function book_admin_orphan() { } if (count($orphans)) { + $form['table'] = _book_admin_table($orphans); $form['save'] = array( '#type' => 'submit', '#value' => t('Save book pages'), ); - } else { $form['error'] = array('#value' => ''. t('There are no orphan pages.') .'
'); @@ -963,7 +1443,7 @@ function book_admin_edit_submit($form_id */ function book_admin($nid = 0) { if ($nid) { - return book_admin_edit($nid); + return drupal_get_form('book_admin_edit',$nid); } else { return book_admin_overview(); @@ -974,13 +1454,40 @@ function book_admin($nid = 0) { * Returns an administrative overview of all books. */ function book_admin_overview() { - $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = 0 ORDER BY b.weight, n.title')); - while ($book = db_fetch_object($result)) { - $rows[] = array(l($book->title, "node/$book->nid"), l(t('outline'), "admin/content/book/$book->nid")); - } - $headers = array(t('Book'), t('Operations')); + $output = ''; - return theme('table', $headers, $rows); + // List all books + $result = db_query(db_rewrite_sql('SELECT bp.*, n.title FROM {book_pages} bp INNER JOIN {node} n ON n.nid = bp.nid WHERE bp.parent = 0 ORDER BY bp.weight ASC, n.title ASC')); + $all_books = array(); + $all_independent = array(); + while ($node = db_fetch_object($result)) { + if ($node->bid == $node->nid) { + $all_books[$node->nid] = $node->title; + } + else { + $all_independent[$node->nid] = $node->title; + } + } + $rows = array(); + foreach ($all_books as $nid => $title) { + $rows[] = array(l($title, 'node/'. $nid), l(t('administer'), 'admin/content/book/'. $nid)); + } + if (count($rows)) { + $headers = array(t('Book'), t('Operations')); + $output .= theme('table', $headers, $rows); + $output .= ''. t('The book content type is suited for creating structured, multi-page hypertexts such as site resource guides, manuals, and Frequently Asked Questions (FAQs). It permits a document to have chapters, sections, subsections, etc. Authors with suitable permissions can add pages to a collaborative book, placing them into the existing document by adding them to a table of contents menu. ') .'
'; - $output .= ''. t('Books have additional previous, up, and next navigation elements at the bottom of each page for moving through the text. Additional navigation may be provided by enabling the book navigation block on the block administration page.', array('@admin-block' => url('admin/build/block'))) .'
'; - $output .= ''. t('Users can select the printer-friendly version link visible at the bottom of a book page to generate a printer-friendly display of the page and all of its subsections. ') .'
'; - $output .= ''. t('Administrators can view a book outline, from which is it possible to change the titles of sections, and their weight (thus reordering sections). From this outline, it is also possible to edit and/or delete book pages. Many content types besides pages (for example, blog entries, stories, and polls) can be added to a collaborative book by choosing the outline tab when viewing the post.') .'
'; + $output = ''. t("The book module is suited for creating structured, multi-page hypertexts such as site resource guides, manuals, and Frequently Asked Questions (FAQs). It permits a document to have chapters, sections, subsections, etc. This module provides two content types: the 'book and 'book_page' types. A 'book' node can be thought of as the book's cover and table of contents, while book pages are the organized content associated with a book."); + $output .= '
'. t("Users with the 'outline books' permission can also add nodes of any type to a book, placing them into the existing document by adding them to the book outline via the %outline tab. This tab also provides a means for reorganizing the book one page at a time, including associating it with a different book or changing its positon inthe book relative to other pages.", array('%outline' => t('outline'))) .'
'; + $output .= ''. t('Book pages have additional previous, %up, and next navigation elements at the bottom of each page for moving through the text. Additional navigation may be provided by enabling the %navigation block on the block administration page.', array('%up' => t('up'), '%navigation' => t('Book navigation'),'!admin-block' => url('admin/build/block'))) .'
'; + $output .= ''. t('Users can click the %child-page link visible at the bottom of a book page to add a new page to the current book and automatically position it as a sub-page of the page they are viewing',array('%child-page' => t('add child page'))). '
'; + $output .= ''. t('Select the %printer-friendly link visible at the bottom of a book page to generate a printer-friendly display of the page and all of its subsections. ',array('%printer-friendly' => t('printer-friendly version'))) .'
'; + $output .= ''. t('Administrators can view the book outline, from which is it possible to change the titles of pages, and their weight (thus reordering sections). From this outline, it is also possible to edit and/or delete book pages. Many content types besides pages (for example, blog entries, stories, and polls) can be added to a collaborative book by choosing the outline tab when viewing the post.') .'
'; $output .= t('You can
'. t('For more information please read the configuration and customization handbook Book page.', array('@book' => 'http://drupal.org/handbook/modules/book/')) .'
'; +', array('!node-add-book' => url('node/add/book'), '!node-add-book-page' => url('node/add/book-page'), '!admin-content-book' => url('admin/content/book'), '!admin-content-types-book' => url('admin/content/types/book'), '!admin-content-types-book-page' => url('admin/content/types/book-page'), '%navigation' => t('Book navigation'), '%license' => t('Book license'), '!admin-block' => url('admin/build/block'), '!admin-access' => url('admin/user/access'))); + $output .= ''. t('For more information please read the book module handbook section on Drupal.org.', array('!book' => 'http://drupal.org/handbook/modules/book/')) .'
'; return $output; case 'admin/settings/modules#description': return t('Allows users to collaboratively author a book.'); @@ -1013,8 +1523,28 @@ function book_help($section) { } if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'outline') { - return t('The outline feature allows you to include posts in the book hierarchy.', array('@book' => url('book'))); + return t('The outline feature allows you to organize posts in the book hierarchy.', array('!book' => url('book'))); } } - +/** + * Implementation of hook_form_alter() + */ +function book_form_alter($form_id, &$form) { + switch($form_id) { + case 'node_delete_confirm': + $node = node_load($form['nid']['#value']); + if ($node->type == 'book') { + $form['book'] = array( + '#value' => t('Note that all book pages belonging to this book (if any) will no longer be associated with any book.'), + ); + } + else { + if (isset($node->bid)) { + $form['book'] = array( + '#value' => t('Note that child pages in the book outline (if any) will be orphaned. You may want to move any child pages first.'), + ); + } + } + } +}