aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-08-14 10:47:17 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-08-14 10:47:17 +0000
commit26469396670f21e3f96922c839a397158956d351 (patch)
treefbecaac1c550af47639699a6f7a2037899fbe80b
parentf19a6d8e1980e41988531cbef263a1351a7631ea (diff)
downloadelgg-26469396670f21e3f96922c839a397158956d351.tar.gz
elgg-26469396670f21e3f96922c839a397158956d351.tar.bz2
Added the facility to group submenus
git-svn-id: https://code.elgg.org/elgg/trunk@1915 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/elgglib.php79
-rw-r--r--views/default/canvas_header/submenu_group.php14
2 files changed, 63 insertions, 30 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 763b69911..a793e7bee 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -525,10 +525,15 @@
* @param string $label The human-readable label
* @param string $link The URL of the submenu item
*/
- function add_submenu_item($label, $link) {
+ function add_submenu_item($label, $link, $group = 'main') {
global $CONFIG;
- add_to_register('submenu',$label,$link);
+ if (!isset($CONFIG->submenu)) $CONFIG->submenu = array();
+ if (!isset($CONFIG->submenu[$group])) $CONFIG->submenu[$group] = array();
+ $item = new stdClass;
+ $item->value = $link;
+ $item->name = $label;
+ $CONFIG->submenu[$group][] = $item;
}
@@ -539,52 +544,66 @@
*/
function get_submenu() {
- $submenu = "";
+ $submenu_total = "";
global $CONFIG;
- if ($submenu_register = get_register('submenu')) {
+ if (isset($CONFIG->submenu) && $submenu_register = $CONFIG->submenu) {
$preselected = false;
$comparevals = array();
$maxcompareval = 999999;
- foreach($submenu_register as $key => $item) {
+ asort($CONFIG->submenu);
+
+ foreach($submenu_register as $groupname => $submenu_register_group) {
+
+ $submenu = "";
- $comparevals[$key] = (levenshtein($item->value, $_SERVER['REQUEST_URI']));
- if ($comparevals[$key] < $maxcompareval) {
- $maxcompareval = $comparevals[$key];
- $preselected = $key;
+ foreach($submenu_register_group as $key => $item) {
+
+ $comparevals[$key] = (levenshtein($item->value, $_SERVER['REQUEST_URI']));
+ if ($comparevals[$key] < $maxcompareval) {
+ $maxcompareval = $comparevals[$key];
+ $preselected = $key;
+ }
+
}
- }
-
- foreach($submenu_register as $key => $item) {
-
- if (!$preselected) {
- if (substr_count($item->value, $_SERVER['REQUEST_URI'])) {
- $selected = true;
- } else {
- $selected = false;
- }
- } else {
- if ($key == $preselected) {
- $selected = true;
+ foreach($submenu_register_group as $key => $item) {
+
+ if (!$preselected) {
+ if (substr_count($item->value, $_SERVER['REQUEST_URI'])) {
+ $selected = true;
+ } else {
+ $selected = false;
+ }
} else {
- $selected = false;
+ if ($key == $preselected) {
+ $selected = true;
+ } else {
+ $selected = false;
+ }
}
+
+ $submenu .= elgg_view('canvas_header/submenu_template',
+ array(
+ 'href' => $item->value,
+ 'label' => $item->name,
+ 'selected' => $selected,
+ ));
+
}
- $submenu .= elgg_view('canvas_header/submenu_template',
- array(
- 'href' => $item->value,
- 'label' => $item->name,
- 'selected' => $selected,
- ));
+ $submenu_total .= elgg_view('canvas_header/submenu_group', array(
+ 'submenu' => $submenu,
+ 'group_name' => $groupname
+ ));
}
+
}
- return $submenu;
+ return $submenu_total;
}
diff --git a/views/default/canvas_header/submenu_group.php b/views/default/canvas_header/submenu_group.php
new file mode 100644
index 000000000..4ce6bce50
--- /dev/null
+++ b/views/default/canvas_header/submenu_group.php
@@ -0,0 +1,14 @@
+<?php
+
+ if (isset($vars['group_name'])) {
+ $groupname = $vars['group_name'];
+ } else {
+ $groupname = "main";
+ }
+ if (isset($vars['submenu'])) {
+
+ echo "<div class=\"submenu_group\"><div class=\"submenu_group_{$groupname}\">{$vars['submenu']}</div></div>";
+
+ }
+
+?> \ No newline at end of file