From aa011b14603ba807121c811399685895a9c75d67 Mon Sep 17 00:00:00 2001 From: brettp Date: Sat, 8 May 2010 03:42:23 +0000 Subject: Added new submenu system. Added elgg_http_url_is_identical(). Moved canvas_header/submenu* to navigation/submenu*. Added UI test for submenu. git-svn-id: http://code.elgg.org/elgg/trunk@5982 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 477 +++++++++++++++++++++++++++++++++++--------- engine/tests/ui/submenu.php | 97 +++++++++ 2 files changed, 476 insertions(+), 98 deletions(-) create mode 100644 engine/tests/ui/submenu.php (limited to 'engine') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 1f51d7cb2..16ace68be 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -249,10 +249,10 @@ function elgg_view($view, $vars = array(), $bypass = false, $debug = false, $vie $viewtype = elgg_get_viewtype(); } - // Viewtypes can only be alphanumeric + // Viewtypes can only be alphanumeric if (preg_match('[\W]', $viewtype)) { - return ''; - } + return ''; + } // Set up any extensions to the requested view if (isset($CONFIG->views->extensions[$view])) { @@ -757,7 +757,7 @@ function elgg_view_annotation(ElggAnnotation $annotation, $bypass = true, $debug function elgg_view_entity_list($entities, $count, $offset, $limit, $fullview = true, $viewtypetoggle = true, $pagination = true) { $count = (int) $count; $limit = (int) $limit; - + // do not require views to explicitly pass in the offset if (!$offset = (int) $offset) { $offset = sanitise_int(get_input('offset', 0)); @@ -900,131 +900,317 @@ function elgg_view_title($title, $submenu = false) { } /** - * Adds an item to the submenu + * Deprecated by elgg_add_submenu_item() + * + * @see elgg_add_submenu_item() + * @deprecated 1.8 + */ +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); + + $item = array( + 'text' => $label, + 'url' => $link, + 'selected' => $selected + ); + + if (!$group) { + $group = 'default'; + } + + if ($onclick) { + $js = "onclick=\"javascript:return confirm('". elgg_echo('deleteconfirm') . "')\""; + $item['vars'] = array('js' => $js); + } + // submenu items were added in the page setup hook usually by checking + // the context. We'll pass in the current context here, which will + // emulate that effect. + // if context == 'main' (default) it probably means they always wanted + // the menu item to show up everywhere. + $context = get_context(); + + if ($context == 'main') { + $context = 'all'; + } + 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 $label The human-readable label - * @param string $link The URL of the submenu item - * @param boolean $onclick Used to provide a JS popup to confirm delete - * @param mixed $selected BOOL to force on/off, NULL to allow auto selection + * @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