From 141d7d90e7cc5020ee984217d3a18b1903a9029f Mon Sep 17 00:00:00 2001 From: Dries <dries@buytaert.net> Date: Wed, 5 Mar 2014 15:35:46 -0500 Subject: [PATCH] Issue #2209035 by pwolanin: Remove remaining/stray menu_link references from book module code. --- core/modules/book/book.info.yml | 1 - core/modules/book/book.install | 11 ++++------- core/modules/book/book.module | 13 ++++++++++++- core/modules/book/lib/Drupal/book/BookManager.php | 9 +++++---- core/modules/book/templates/book-tree.html.twig | 14 ++++++++++++++ 5 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 core/modules/book/templates/book-tree.html.twig diff --git a/core/modules/book/book.info.yml b/core/modules/book/book.info.yml index 5c9eab98273d..a2322e036dcd 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 1a31749f149a..34db3f17dfe7 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 29b7460cc8cc..48c81d56dbf3 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -29,7 +29,7 @@ function book_help($path, $arg) { $output .= '<dt>' . t('Book navigation') . '</dt>'; $output .= '<dd>' . 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 <a href='!admin-block'>Blocks administration page</a>. 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'))) . '</dd>'; $output .= '<dt>' . t('Collaboration') . '</dt>'; - $output .= '<dd>' . 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.') . '</dd>'; + $output .= '<dd>' . 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.') . '</dd>'; $output .= '<dt>' . t('Printing books') . '</dt>'; $output .= '<dd>' . t("Users with the <em>View printer-friendly books</em> permission can select the <em>printer-friendly version</em> 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.") . '</dd>'; $output .= '</dl>'; @@ -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 3a099c5c8f20..594e7134f19b 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 000000000000..d940a462bf6b --- /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 + */ +#} +<ul class="menu">{{ tree }}</ul> -- GitLab