diff --git a/core/modules/book/book.info.yml b/core/modules/book/book.info.yml index 5c9eab98273dc61fdc1f031c13c897688d2dfe17..a2322e036dcd3f7979624a086ff1440fd38a7774 100644 --- a/core/modules/book/book.info.yml +++ b/core/modules/book/book.info.yml @@ -5,6 +5,5 @@ package: Core version: VERSION core: 8.x dependencies: - - menu_link - node configure: book.settings diff --git a/core/modules/book/book.install b/core/modules/book/book.install index 1a31749f149a4113abd5a6c2d9c5d5e24fed0661..34db3f17dfe7fdfa06aa9d3b808f2548a1052f8f 100644 --- a/core/modules/book/book.install +++ b/core/modules/book/book.install @@ -9,11 +9,8 @@ * Implements hook_uninstall(). */ function book_uninstall() { - // Delete menu links. - db_delete('menu_links') - ->condition('module', 'book') - ->execute(); - menu_cache_clear_all(); + // Clear book data out of the cache. + \Drupal::cache('menu')->deleteAll(); } /** @@ -21,7 +18,7 @@ function book_uninstall() { */ function book_schema() { $schema['book'] = array( - 'description' => 'Stores book outline information. Uniquely connects each node in the outline to a link in {menu_links}', + 'description' => 'Stores book outline information. Uniquely defines the location of each node in the book outline', 'fields' => array( 'nid' => array( 'type' => 'int', @@ -38,7 +35,7 @@ function book_schema() { 'description' => "The book ID is the {book}.nid of the top-level page.", ), 'pid' => array( - 'description' => 'The parent ID (pid) is the id of the node above in the hierarchy, or zero if the node is at the top level in its menu.', + 'description' => 'The parent ID (pid) is the id of the node above in the hierarchy, or zero if the node is at the top level in its outline.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 29b7460cc8cce025cfadc7b8a4abf07119cd27c4..48c81d56dbf367e76f0cbf80bc62c90b2192585c 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -29,7 +29,7 @@ function book_help($path, $arg) { $output .= '
' . t('Book navigation') . '
'; $output .= '
' . t("Book pages have a default book-specific navigation block. This navigation block contains links that lead to the previous and next pages in the book, and to the level above the current page in the book's structure. This block can be enabled on the Blocks administration page. For book pages to show up in the book navigation, they must be added to a book outline.", array('!admin-block' => \Drupal::url('block.admin_display'))) . '
'; $output .= '
' . t('Collaboration') . '
'; - $output .= '
' . t('Books can be created collaboratively, as they allow users with appropriate permissions to add pages into existing books, and add those pages to a custom table of contents menu.') . '
'; + $output .= '
' . t('Books can be created collaboratively, as they allow users with appropriate permissions to add pages into existing books, and add those pages to a custom table of contents.') . '
'; $output .= '
' . t('Printing books') . '
'; $output .= '
' . t("Users with the View printer-friendly books permission can select the printer-friendly version link visible at the bottom of a book page's content to generate a printer-friendly display of the page and all of its subsections.") . '
'; $output .= ''; @@ -50,6 +50,10 @@ function book_theme() { 'variables' => array('book_link' => NULL), 'template' => 'book-navigation', ), + 'book_tree' => array( + 'render element' => 'tree', + 'template' => 'book-tree', + ), 'book_link' => array( 'render element' => 'element', ), @@ -714,6 +718,13 @@ function template_preprocess_book_node_export_html(&$variables) { $variables['content'] = $variables['node']->rendered; } +/** + * Implements template_preprocess_HOOK() for theme_book_tree(). + */ +function template_preprocess_book_tree(&$variables) { + $variables['tree'] = $variables['tree']['#children']; +} + /** * Returns HTML for a book link and subtree. * diff --git a/core/modules/book/lib/Drupal/book/BookManager.php b/core/modules/book/lib/Drupal/book/BookManager.php index 3a099c5c8f20c3c12d1f5ebc540558b05f1cf735..594e7134f19bf218f5263c1b9bd184101f06eb4c 100644 --- a/core/modules/book/lib/Drupal/book/BookManager.php +++ b/core/modules/book/lib/Drupal/book/BookManager.php @@ -546,8 +546,8 @@ public function bookTreeOutput(array $tree) { // Make sure drupal_render() does not re-order the links. $build['#sorted'] = TRUE; // Add the theme wrapper for outer markup. - // Allow menu-specific theme overrides. - $build['#theme_wrappers'][] = 'menu_tree__book_toc_' . $data['link']['nid']; + // Allow book-specific theme overrides. + $build['#theme_wrappers'][] = 'book_tree__book_toc_' . $data['link']['bid']; } return $build; @@ -919,8 +919,9 @@ protected function _menu_tree_check_access(&$tree) { $this->_menu_tree_check_access($tree[$key]['below']); } // The weights are made a uniform 5 digits by adding 50000 as an offset. - // After _menu_link_translate(), $item['title'] has the localized link title. - // Adding the mlid to the end of the index insures that it is unique. + // After calling $this->bookLinkTranslate(), $item['title'] has the + // translated title. Adding the nid to the end of the index insures that + // it is unique. $new_tree[(50000 + $item['weight']) . ' ' . $item['title'] . ' ' . $item['nid']] = $tree[$key]; } } diff --git a/core/modules/book/templates/book-tree.html.twig b/core/modules/book/templates/book-tree.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..d940a462bf6bce01903ae66abf4008c362670523 --- /dev/null +++ b/core/modules/book/templates/book-tree.html.twig @@ -0,0 +1,14 @@ +{# +/** + * @file + * Returns HTML for a wrapper for a book sub-tree. + * + * Available variables: + * - tree: An HTML string containing the tree's items. + * + * @see template_preprocess_book_tree() + * + * @ingroup themeable + */ +#} +