diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-08-24 01:49:41 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-08-24 01:49:41 +0000 |
commit | 03a5563b899bf47d29914c812c5153fd725d6d46 (patch) | |
tree | e9d58feae8aa1569e68666742a38f8b0a7ee8d76 /modules/book | |
parent | 8765df6593758591c5efb00f850552f617590834 (diff) | |
download | brdo-03a5563b899bf47d29914c812c5153fd725d6d46.tar.gz brdo-03a5563b899bf47d29914c812c5153fd725d6d46.tar.bz2 |
#509584 by pwolanin: Various API fixes for menu_tree_data() including depth param.
Diffstat (limited to 'modules/book')
-rw-r--r-- | modules/book/book.module | 26 | ||||
-rw-r--r-- | modules/book/book.test | 2 |
2 files changed, 16 insertions, 12 deletions
diff --git a/modules/book/book.module b/modules/book/book.module index fa433fd4c..4385805d7 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -600,14 +600,15 @@ function book_update_bid($book_link) { * A linear array of menu links in the order that the links are shown in the * menu, so the previous and next pages are the elements before and after the * element corresponding to $node. The children of $node (if any) will come - * immediately after it in the array. + * immediately after it in the array, and links will only be fetched as deep + * as one level deeper than $book_link. */ function book_get_flat_menu($book_link) { $flat = &drupal_static(__FUNCTION__, array()); if (!isset($flat[$book_link['mlid']])) { // Call menu_tree_all_data() to take advantage of the menu system's caching. - $tree = menu_tree_all_data($book_link['menu_name'], $book_link); + $tree = menu_tree_all_data($book_link['menu_name'], $book_link, $book_link['depth'] + 1); $flat[$book_link['mlid']] = array(); _book_flatten_menu($tree, $flat[$book_link['mlid']]); } @@ -1156,16 +1157,16 @@ function book_link_load($mlid) { * The root of the subtree will be the link passed as a parameter, so the * returned tree will contain this item and all its descendents in the menu tree. * - * @param $item + * @param $link * A fully loaded menu link. * @return * An subtree of menu links in an array, in the order they should be rendered. */ -function book_menu_subtree_data($item) { +function book_menu_subtree_data($link) { $tree = &drupal_static(__FUNCTION__, array()); - // Generate a cache ID (cid) specific for this $menu_name and $item. - $cid = 'links:' . $item['menu_name'] . ':subtree-cid:' . $item['mlid']; + // Generate a cache ID (cid) specific for this $menu_name and $link. + $cid = 'links:' . $link['menu_name'] . ':subtree-cid:' . $link['mlid']; if (!isset($tree[$cid])) { $cache = cache_get($cid, 'cache_menu'); @@ -1188,15 +1189,18 @@ function book_menu_subtree_data($item) { $query->fields($book_alias); $query->fields($menu_router_alias, array('load_functions', 'to_arg_functions', 'access_callback', 'access_arguments', 'page_callback', 'page_arguments', 'title', 'title_callback', 'title_arguments', 'type')); $query->fields('ml'); - $query->condition('menu_name', $item['menu_name']); - for ($i = 1; $i <= MENU_MAX_DEPTH && $item["p$i"]; ++$i) { - $query->condition("p$i", $item["p$i"]); + $query->condition('menu_name', $link['menu_name']); + for ($i = 1; $i <= MENU_MAX_DEPTH && $link["p$i"]; ++$i) { + $query->condition("p$i", $link["p$i"]); } for ($i = 1; $i <= MENU_MAX_DEPTH; ++$i) { $query->orderBy("p$i"); } - - $data['tree'] = menu_tree_data($query->execute(), array(), $item['depth']); + $links = array(); + foreach ($query->execute() as $item) { + $links[] = $item; + } + $data['tree'] = menu_tree_data($links, array(), $link['depth']); $data['node_links'] = array(); menu_tree_collect_node_links($data['tree'], $data['node_links']); // Compute the real cid for book subtree data. diff --git a/modules/book/book.test b/modules/book/book.test index bfb093f02..e382f1d99 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('Prevoius page link found.')); + $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.')); } if ($up) { |