summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries2014-03-05 20:35:46 (GMT)
committerDries2014-03-05 20:35:46 (GMT)
commit141d7d90e7cc5020ee984217d3a18b1903a9029f (patch)
tree172a48ee44f0871bc63869536506c3c9588b300d
parent1d58c60abc94c66ed722d8a10f2b868a48d8baf9 (diff)
Issue #2209035 by pwolanin: Remove remaining/stray menu_link references from book module code.
-rw-r--r--core/modules/book/book.info.yml1
-rw-r--r--core/modules/book/book.install11
-rw-r--r--core/modules/book/book.module13
-rw-r--r--core/modules/book/lib/Drupal/book/BookManager.php9
-rw-r--r--core/modules/book/templates/book-tree.html.twig14
5 files changed, 35 insertions, 13 deletions
diff --git a/core/modules/book/book.info.yml b/core/modules/book/book.info.yml
index 5c9eab9..a2322e0 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 1a31749..34db3f1 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 29b7460..48c81d5 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',
),
@@ -715,6 +719,13 @@ function template_preprocess_book_node_export_html(&$variables) {
}
/**
+ * 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.
*
* @param array $variables
diff --git a/core/modules/book/lib/Drupal/book/BookManager.php b/core/modules/book/lib/Drupal/book/BookManager.php
index 3a099c5..594e713 100644
--- a/core/modules/book/lib/Drupal/book/BookManager.php
+++ b/core/modules/book/lib/Drupal/book/BookManager.php
@@ -546,8 +546,8 @@ class BookManager implements BookManagerInterface {
// 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 @@ class BookManager implements BookManagerInterface {
$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 0000000..d940a46
--- /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>