summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-02-15 14:56:50 +0000
committerDries Buytaert <dries@buytaert.net>2004-02-15 14:56:50 +0000
commitfdea6a290745da3ad52f57c2d1d794eaa4977a6d (patch)
tree7ff35901d82ea3aa4c65ea199b2a23bf03ba5ad5
parent4f07deabcb5a618d9cd71315d5d043fa4c623b2e (diff)
downloadbrdo-fdea6a290745da3ad52f57c2d1d794eaa4977a6d.tar.gz
brdo-fdea6a290745da3ad52f57c2d1d794eaa4977a6d.tar.bz2
- Fixed two bugs in the menu system: only make a menu collapsable when it has
_visible_ children, accept 'foo/0'-style URLs (0 != NULL).
-rw-r--r--includes/menu.inc30
1 files changed, 25 insertions, 5 deletions
diff --git a/includes/menu.inc b/includes/menu.inc
index dc37df005..1350d3580 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -140,11 +140,11 @@ function menu_execute_active_handler() {
if ($_list[$path]["callback"]) {
$arg = substr($_GET["q"], strlen($path) + 1);
- if (empty($arg)) {
- return call_user_func($_list[$path]["callback"]);
+ if (isset($arg)) {
+ return call_user_func_array($_list[$path]["callback"], explode("/", $arg));
}
else {
- return call_user_func_array($_list[$path]["callback"], explode("/", $arg));
+ return call_user_func($_list[$path]["callback"]);
}
}
}
@@ -171,6 +171,23 @@ function menu_in_active_trail($path) {
}
/**
+ * Returns true when the menu has visisble children.
+ */
+function menu_has_visible_children($item) {
+ global $_list;
+
+ if ($_list[$item]['children']) {
+ foreach ($_list[$item]['children'] as $child) {
+ if ($_list[$child]['hidden'] == MENU_SHOW) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+/**
* Returns a rendered menu tree.
*/
function menu_tree($parent = "", $hidden = 0) {
@@ -191,8 +208,11 @@ function menu_tree($parent = "", $hidden = 0) {
** nor children. The latter check avoids that useless links are being
** rendered.
*/
- if (($_list[$item]["hidden"] == MENU_SHOW && ($_list[$item]["callback"] || $_list[$item]["children"])) || ($_list[$item]["hidden"] == MENU_HIDE_NOCHILD && $_list[$item]["children"])) {
- $style = ($_list[$item]["children"] ? (menu_in_active_trail($item) ? "expanded" : "collapsed") : "leaf");
+ $visible = menu_has_visible_children($item);
+ if (($_list[$item]["hidden"] == MENU_SHOW && $_list[$item]["callback"]) ||
+ ($_list[$item]["hidden"] == MENU_SHOW && $visible) ||
+ ($_list[$item]["hidden"] == MENU_HIDE_NOCHILD && $visible)) {
+ $style = ($visible ? (menu_in_active_trail($item) ? "expanded" : "collapsed") : "leaf");
$output .= "<li class=\"$style\">";
$output .= _render_item($item);
if (menu_in_active_trail($item)) {