aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-09 16:59:00 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-09 16:59:00 +0000
commitc94eb1a1cc386d58980357c63300e3479487f475 (patch)
tree2bd890a21456cec120794ef10710129988302477
parent55bc92537a7bd0fde6e860551ee70edd4fae34a3 (diff)
downloadelgg-c94eb1a1cc386d58980357c63300e3479487f475.tar.gz
elgg-c94eb1a1cc386d58980357c63300e3479487f475.tar.bz2
Introducing the submenu
git-svn-id: https://code.elgg.org/elgg/trunk@1371 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/elgglib.php51
-rw-r--r--views/default/canvas_header/submenu_template.php10
-rw-r--r--views/default/page_elements/title.php7
3 files changed, 64 insertions, 4 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 722591ab4..d0ecc8bf4 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -481,10 +481,57 @@
*/
function elgg_view_title($title) {
- return elgg_view('page_elements/title', array('title' => $title));
+ $title = elgg_view('page_elements/title', array('title' => $title));
+
+ return $title;
+
+ }
+
+ /**
+ * Adds an item to the submenu
+ *
+ * @param string $label The human-readable label
+ * @param string $link The URL of the submenu item
+ */
+ function add_submenu_item($label, $link) {
+
+ global $CONFIG;
+ add_to_register('submenu',$label,$link);
+
+ }
+
+ /**
+ * Gets a formatted list of submenu items
+ *
+ * @return string List of items
+ */
+ function get_submenu() {
+
+ $submenu = "";
+
+ if ($submenu_register = get_register('submenu')) {
+ foreach($submenu_register as $item) {
+
+ if (substr_count($item->value, $item->value)) {
+ $selected = true;
+ } else {
+ $selected = false;
+ }
+ $submenu .= elgg_view('canvas_header/submenu_template',
+ array(
+ 'href' => $item->value,
+ 'label' => $item->name,
+ 'selected' => $selected,
+ ));
+
+ }
+ }
+
+ return $submenu;
}
+
/**
* Automatically views comments and a comment form relating to the given entity
*
@@ -778,7 +825,7 @@
global $CONFIG;
- if (empty($register_name) || empty($subregister_name) || empty($children_array))
+ if (empty($register_name) || empty($subregister_name))
return false;
if (!isset($CONFIG->registers))
diff --git a/views/default/canvas_header/submenu_template.php b/views/default/canvas_header/submenu_template.php
new file mode 100644
index 000000000..ff43ac153
--- /dev/null
+++ b/views/default/canvas_header/submenu_template.php
@@ -0,0 +1,10 @@
+<?php
+
+ if (isset($vars['selected']) && $vars['selected'] == true) {
+ $selected = "class=\"selected\"";
+ } else {
+ $selected = "";
+ }
+
+?>
+<li <?php echo $selected; ?>><a href="<?php echo $vars['href']; ?>"><?php echo $vars['label']; ?></a></li> \ No newline at end of file
diff --git a/views/default/page_elements/title.php b/views/default/page_elements/title.php
index aa1946514..aac3babae 100644
--- a/views/default/page_elements/title.php
+++ b/views/default/page_elements/title.php
@@ -16,19 +16,22 @@
$page_owner = page_owner();
$page_owner_user = get_user($page_owner);
+ $submenu = get_submenu(); // elgg_view('canvas_header/submenu');
+ if (!empty($submenu)) $submenu = "<ul>" . $submenu . "</ul>";
+
if($page_owner && $page_owner_user->guid != $_SESSION['user']->getGUID()) {
$info = "<h2>" . $vars['title'] . "</h2>";
$icon = elgg_view("profile/icon",array('entity' => $page_owner_user, 'size' => 'tiny'));
$display = "<div id=\"canvas_header\">";
$display .= "<div id=\"canvas_header_icon\">" . $icon . "</div>";
$display .= "<div id=\"canvas_header_content\">" . $info . "</div>";
- $display .= "<div id=\"canvas_header_submenu\">" . elgg_view("canvas_header/submenu") . "</div>"; // plugins can extend this to add menu options
+ $display .= "<div id=\"canvas_header_submenu\">" . $submenu . "</div>"; // plugins can extend this to add menu options
$display .= "</div>";
} else {
$info = "<h2>" . $vars['title'] . "</h2>";
$display = "<div id=\"canvas_header\">";
$display .= "<div id=\"canvas_header_content\">" . $info . "</div>";
- $display .= "<div id=\"canvas_header_submenu\">" . elgg_view("canvas_header/submenu") . "</div>"; // plugins can extend this to add menu options
+ $display .= "<div id=\"canvas_header_submenu\">" . $submenu . "</div>"; // plugins can extend this to add menu options
$display .= "</div>";
}