From dbdf001b867cb686beb6113d329eaa42b02ed4ca Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 27 Jan 2011 13:01:46 +0000 Subject: removed menu code introduced for elgg.com that did not make it into 1.8 git-svn-id: http://code.elgg.org/elgg/trunk@7949 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 10 +- engine/lib/navigation.php | 532 ++++++-------------------------------------- engine/tests/ui/submenu.php | 6 + 3 files changed, 78 insertions(+), 470 deletions(-) (limited to 'engine') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index f925429de..e8d47eaca 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -476,11 +476,11 @@ function sanitise_filepath($path, $append_slash = TRUE) { * @param array $children_array Optionally, an array of children * * @return true|false Depending on success - * @todo Can be deprecated when the new menu system is introduced. + * @deprecated 1.8 */ function add_to_register($register_name, $subregister_name, $subregister_value, $children_array = array()) { - + elgg_deprecated_notice("add_to_register() has been deprecated", 1.8); global $CONFIG; if (empty($register_name) || empty($subregister_name)) { @@ -517,9 +517,10 @@ $children_array = array()) { * * @return true|false Depending on success * @since 1.7.0 - * @todo Can be deprecated when the new menu system is introduced. + * @deprecated 1.8 */ function remove_from_register($register_name, $subregister_name) { + elgg_deprecated_notice("remove_from_register() has been deprecated", 1.8); global $CONFIG; if (empty($register_name) || empty($subregister_name)) { @@ -572,9 +573,10 @@ function make_register_object($register_name, $register_value, $children_array = * @param string $register_name The name of the register * * @return array|false Depending on success - * @todo Can be deprecated when the new menu system is introduced. + * @deprecated 1.8 */ function get_register($register_name) { + elgg_deprecated_notice("get_register() has been deprecated", 1.8); global $CONFIG; if (isset($CONFIG->registers[$register_name])) { diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php index a6554fd99..155392645 100644 --- a/engine/lib/navigation.php +++ b/engine/lib/navigation.php @@ -72,9 +72,61 @@ function elgg_unregister_menu_item($menu_name, $item_name) { } /** - * Deprecated by elgg_add_submenu_item() + * Adds a breadcrumb to the breadcrumbs stack. + * + * @param string $title The title to display + * @param string $link Optional. The link for the title. + * + * @return void + * @since 1.8.0 + * + * @link http://docs.elgg.org/Tutorials/UI/Breadcrumbs + */ +function elgg_push_breadcrumb($title, $link = NULL) { + global $CONFIG; + if (!is_array($CONFIG->breadcrumbs)) { + $CONFIG->breadcrumbs = array(); + } + + // avoid key collisions. + $CONFIG->breadcrumbs[] = array('title' => $title, 'link' => $link); +} + +/** + * Removes last breadcrumb entry. + * + * @return array popped item. + * @since 1.8.0 + * @link http://docs.elgg.org/Tutorials/UI/Breadcrumbs + */ +function elgg_pop_breadcrumb() { + global $CONFIG; + + if (is_array($CONFIG->breadcrumbs)) { + array_pop($CONFIG->breadcrumbs); + } + + return FALSE; +} + +/** + * Returns all breadcrumbs as an array of array('title' => 'Readable Title', 'link' => 'URL') * - * @see elgg_add_submenu_item() + * @return array Breadcrumbs + * @since 1.8.0 + * @link http://docs.elgg.org/Tutorials/UI/Breadcrumbs + */ +function elgg_get_breadcrumbs() { + global $CONFIG; + + return (is_array($CONFIG->breadcrumbs)) ? $CONFIG->breadcrumbs : array(); +} + + +/** + * Deprecated by elgg_register_menu_item(). Set $menu_name to 'page'. + * + * @see elgg_register_menu_item() * @deprecated 1.8 * * @param string $label The label @@ -86,7 +138,7 @@ function elgg_unregister_menu_item($menu_name, $item_name) { * @return bool */ function add_submenu_item($label, $link, $group = 'default', $onclick = false, $selected = NULL) { - elgg_deprecated_notice('add_submenu_item was deprecated by elgg_add_submenu_item', 1.8); + elgg_deprecated_notice('add_submenu_item was deprecated by elgg_register_menu_item', 1.8); // submenu items were added in the page setup hook usually by checking // the context. We'll pass in the current context here, which will @@ -117,364 +169,22 @@ function add_submenu_item($label, $link, $group = 'default', $onclick = false, $ } return elgg_register_menu_item('page', $item); -/* - $item = array( - 'text' => $label, - 'href' => $link, - 'selected' => $selected - ); - - return elgg_add_submenu_item($item, $context, $group); - * - */ -} - -/** - * Add an entry to the submenu. - * - * @param array $item The item as: - * - * array( - * 'title' => 'Text to display', - * 'url' => 'URL of the link', - * 'id' => 'entry_unique_id' //used by children items to identify parents - * 'parent_id' => 'id_of_parent', - * 'selected' => BOOL // Is this item selected? (If NULL or unset will attempt to guess) - * 'vars' => array() // Array of vars to pass to the navigation/submenu_item view - * ) - * - * - * @param string $context Context in which to display this menu item. 'all' - * will make it show up all the time. Use sparingly. - * @param string $group Group for the item. Each submenu group has its own