From cd2e7e875aa748c7486263aa59334271cf9cf496 Mon Sep 17 00:00:00 2001 From: Angie Byron <webchick@24967.no-reply.drupal.org> Date: Sat, 17 Oct 2009 01:15:40 +0000 Subject: [PATCH] #511286 follow-up: Committed rest of stuff. --- includes/menu.inc | 69 +++++++++++++++++++++++++++++++++++ profiles/default/default.info | 1 + themes/seven/page.tpl.php | 1 + themes/seven/style.css | 7 ++++ 4 files changed, 78 insertions(+) diff --git a/includes/menu.inc b/includes/menu.inc index 40992d92861d..a8742f2ca17f 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -2258,6 +2258,75 @@ function _menu_navigation_links_rebuild($menu) { } } +/** + * Clone an array of menu links. + * + * @param $links + * An array of menu links to clone. + * @param $menu_name + * (optional) The name of a menu that the links will be cloned for. If not + * set, the cloned links will be in the same menu as the original set of + * links that were passed in. + * @return + * An array of menu links with the same properties as the passed-in array, + * but with the link identifiers removed so that a new link will be created + * when any of them is passed in to menu_link_save(). + * + * @see menu_link_save() + */ +function menu_links_clone($links, $menu_name = NULL) { + foreach ($links as &$link) { + unset($link['mlid']); + unset($link['plid']); + if (isset($menu_name)) { + $link['menu_name'] = $menu_name; + } + } + return $links; +} + +/** + * Returns an array containing all links for a menu. + * + * @param $menu_name + * The name of the menu whose links should be returned. + * @return + * An array of menu links. + */ +function menu_load_links($menu_name) { + $links = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC)) + ->fields('ml') + ->condition('ml.menu_name', $menu_name) + // Order by weight so as to be helpful for menus that are only one level + // deep. + ->orderBy('weight') + ->execute() + ->fetchAll(); + + foreach ($links as &$link) { + $link['options'] = unserialize($link['options']); + } + return $links; +} + +/** + * Deletes all links for a menu. + * + * @param $menu_name + * The name of the menu whose links will be deleted. + */ +function menu_delete_links($menu_name) { + $links = menu_load_links($menu_name); + foreach ($links as $link) { + // To speed up the deletion process, we reset some link properties that + // would trigger re-parenting logic in _menu_delete_item() and + // _menu_update_parental_status(). + $link['has_children'] = FALSE; + $link['plid'] = 0; + _menu_delete_item($link); + } +} + /** * Delete one or several menu links. * diff --git a/profiles/default/default.info b/profiles/default/default.info index f379c7f136cd..7e205eba5bb3 100644 --- a/profiles/default/default.info +++ b/profiles/default/default.info @@ -14,6 +14,7 @@ dependencies[] = path dependencies[] = taxonomy dependencies[] = dblog dependencies[] = search +dependencies[] = shortcut dependencies[] = toolbar dependencies[] = field_ui dependencies[] = file diff --git a/themes/seven/page.tpl.php b/themes/seven/page.tpl.php index eee8cc667932..71e7e0bf76e0 100644 --- a/themes/seven/page.tpl.php +++ b/themes/seven/page.tpl.php @@ -4,6 +4,7 @@ <div id="branding" class="clearfix"> <?php print $breadcrumb; ?> <?php if ($title): ?><h1 class="page-title"><?php print $title; ?></h1><?php endif; ?> + <?php if (isset($add_to_shortcuts)): ?><?php print $add_to_shortcuts; ?><?php endif; ?> <?php if ($primary_local_tasks): ?><ul class="tabs primary"><?php print render($primary_local_tasks); ?></ul><?php endif; ?> </div> diff --git a/themes/seven/style.css b/themes/seven/style.css index 2a838b4a01dc..c88a7b267efa 100644 --- a/themes/seven/style.css +++ b/themes/seven/style.css @@ -735,3 +735,10 @@ body.overlay #page { body.overlay #block-system-main { padding: 20px; } + +/* Shortcut theming */ +div.add-to-shortcuts { + float: left; + margin-left: 6px; + margin-top: 6px; +} -- GitLab