aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/classes/ElggMenuBuilder.php2
-rw-r--r--engine/classes/ElggMenuItem.php12
-rw-r--r--engine/lib/admin.php86
-rw-r--r--engine/lib/navigation.php42
-rw-r--r--engine/lib/users.php15
-rw-r--r--js/lib/ui.js17
-rw-r--r--views/default/admin/overview/statistics.php (renamed from views/default/admin/overview.php)0
-rw-r--r--views/default/css/admin.php53
-rw-r--r--views/default/css/elements/navigation.php64
-rw-r--r--views/default/layout/elements/sidebar.php5
-rw-r--r--views/default/navigation/menu/elements/group.php19
-rw-r--r--views/default/navigation/menu/elements/item.php17
-rw-r--r--views/default/navigation/menu/page.php29
13 files changed, 198 insertions, 163 deletions
diff --git a/engine/classes/ElggMenuBuilder.php b/engine/classes/ElggMenuBuilder.php
index 3528eaef8..f51ec8c62 100644
--- a/engine/classes/ElggMenuBuilder.php
+++ b/engine/classes/ElggMenuBuilder.php
@@ -32,7 +32,7 @@ class ElggMenuBuilder {
$this->selectFromContext();
- $selected = $this->findSelected();
+ $this->selected = $this->findSelected();
$this->setupSections();
diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php
index 2205ebc89..40df8f182 100644
--- a/engine/classes/ElggMenuItem.php
+++ b/engine/classes/ElggMenuItem.php
@@ -21,7 +21,7 @@ class ElggMenuItem {
/**
* @var string The menu url
*/
- protected $url;
+ protected $url = null;
/**
* @var array Page context array
@@ -68,7 +68,9 @@ class ElggMenuItem {
public function __construct($name, $title, $url) {
$this->name = $name;
$this->title = $title;
- $this->url = elgg_normalize_url($url);
+ if ($url) {
+ $this->url = elgg_normalize_url($url);
+ }
}
/**
@@ -82,7 +84,7 @@ class ElggMenuItem {
* @return ElggMenuItem or NULL on error
*/
public static function factory($options) {
- if (!isset($options['name']) || !isset($options['title']) || !isset($options['url'])) {
+ if (!isset($options['name']) || !isset($options['title'])) {
return NULL;
}
@@ -323,8 +325,10 @@ class ElggMenuItem {
* @return string
*/
public function getLink(array $vars = array()) {
- $vars['href'] = $this->url;
$vars['text'] = $this->title;
+ if ($this->url) {
+ $vars['href'] = $this->url;
+ }
return elgg_view('output/url', $vars);
}
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index 106e899f9..0fa3c95a5 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -32,13 +32,14 @@ function extend_elgg_admin_page($new_admin_view, $view = 'admin/main', $priority
}
/**
- * Calculate the plugin settings submenu.
+ * Create the plugin settings submenu.
+ *
* This is done in a separate function called from the admin
* page handler because of performance concerns.
*
* @return void
*/
-function elgg_admin_add_plugin_settings_sidemenu() {
+function elgg_admin_add_plugin_settings_menu() {
global $CONFIG;
if (!$installed_plugins = get_installed_plugins()) {
@@ -46,12 +47,7 @@ function elgg_admin_add_plugin_settings_sidemenu() {
return FALSE;
}
- $parent_item = array(
- 'text' => elgg_echo('admin:plugin_settings'),
- 'id' => 'admin:plugin_settings'
- );
-
- elgg_add_submenu_item($parent_item, 'admin');
+ elgg_add_admin_menu_item('plugin_settings', elgg_echo('admin:plugin_settings'));
foreach ($installed_plugins as $plugin_id => $info) {
if (!$info['active']) {
@@ -59,20 +55,14 @@ function elgg_admin_add_plugin_settings_sidemenu() {
}
if (elgg_view_exists("settings/{$plugin_id}/edit")) {
- $item = array(
- 'text' => $info['manifest']['name'],
- 'href' => "pg/admin/plugin_settings/$plugin_id",
- 'parent_id' => 'admin:plugin_settings'
- );
-
- elgg_add_submenu_item($item, 'admin');
+ elgg_add_admin_menu_item($plugin_id, $info['manifest']['name'], 'plugin_settings');
}
}
}
/**
* Add an admin area section or child section.
- * This is a wrapper for elgg_add_admin_item(array(...), 'admin').
+ * This is a wrapper for elgg_register_menu_item().
*
* Used in conjuction with http://elgg.org/admin/section_id/child_section style
* page handler.
@@ -83,27 +73,22 @@ function elgg_admin_add_plugin_settings_sidemenu() {
*
* @return bool
*/
-function elgg_add_admin_submenu_item($section_id, $section_title, $parent_id = NULL) {
- global $CONFIG;
+function elgg_add_admin_menu_item($section_id, $section_title, $parent_id = NULL) {
// in the admin section parents never have links
if ($parent_id) {
$href = "pg/admin/$parent_id/$section_id";
- } elseif ($section_id == 'overview') {
- $href = "pg/admin/$section_id";
-
} else {
$href = NULL;
}
- $item = array(
- 'text' => $section_title,
- 'href' => $href,
- 'id' => $section_id,
- 'parent_id' => $parent_id
- );
-
- return elgg_add_submenu_item($item, 'admin');
+ return elgg_register_menu_item('page', array(
+ 'name' => $section_id,
+ 'url' => $href,
+ 'title' => $section_title,
+ 'context' => 'admin',
+ 'parent_name' => $parent_id,
+ ));
}
/**
@@ -132,34 +117,29 @@ function admin_init() {
elgg_register_action('profile/fields/reorder', '', 'admin');
// admin area overview and basic site settings
- elgg_add_admin_submenu_item('overview', elgg_echo('admin:overview'));
+ elgg_add_admin_menu_item('overview', elgg_echo('admin:overview'));
+ elgg_add_admin_menu_item('statistics', elgg_echo('admin:statistics'), 'overview');
- elgg_add_admin_submenu_item('site', elgg_echo('admin:site'));
- elgg_add_admin_submenu_item('basic', elgg_echo('admin:site:basic'), 'site');
- elgg_add_admin_submenu_item('advanced', elgg_echo('admin:site:advanced'), 'site');
+ // site
+ elgg_add_admin_menu_item('site', elgg_echo('admin:site'));
+ elgg_add_admin_menu_item('site_basic', elgg_echo('admin:site:basic'), 'site');
+ elgg_add_admin_menu_item('site_advanced', elgg_echo('admin:site:advanced'), 'site');
// appearance
- elgg_add_admin_submenu_item('appearance', elgg_echo('admin:appearance'));
-
- //elgg_add_admin_submenu_item('basic', elgg_echo('admin:appearance'), 'appearance');
- elgg_add_admin_submenu_item('menu_items', elgg_echo('admin:menu_items'), 'appearance');
+ elgg_add_admin_menu_item('appearance', elgg_echo('admin:appearance'));
+ elgg_add_admin_menu_item('menu_items', elgg_echo('admin:menu_items'), 'appearance');
+ elgg_add_admin_menu_item('profile_fields', elgg_echo('admin:profile:fields'), 'appearance');
// users
- elgg_add_admin_submenu_item('users', elgg_echo('admin:users'));
- elgg_add_admin_submenu_item('online', elgg_echo('admin:users:online'), 'users');
- elgg_add_admin_submenu_item('newest', elgg_echo('admin:users:newest'), 'users');
- elgg_add_admin_submenu_item('add', elgg_echo('admin:users:add'), 'users');
+ elgg_add_admin_menu_item('users', elgg_echo('admin:users'));
+ elgg_add_admin_menu_item('users_online', elgg_echo('admin:users:online'), 'users');
+ elgg_add_admin_menu_item('users_newest', elgg_echo('admin:users:newest'), 'users');
+ elgg_add_admin_menu_item('users_add', elgg_echo('admin:users:add'), 'users');
// plugins
- elgg_add_admin_submenu_item('plugins', elgg_echo('admin:plugins'));
- elgg_add_admin_submenu_item('simple', elgg_echo('admin:plugins:simple'), 'plugins');
- elgg_add_admin_submenu_item('advanced', elgg_echo('admin:plugins:advanced'), 'plugins');
-
- // handled in the admin sidemenu so we don't have to generate this on every page load.
- //elgg_add_admin_submenu_item('plugin_settings', elgg_echo('admin:plugin_settings'));
-
- // default profile fields admin item
- elgg_add_admin_submenu_item('profile_fields', elgg_echo('admin:profile:fields'), 'appearance');
+ elgg_add_admin_menu_item('plugins', elgg_echo('admin:plugins'));
+ elgg_add_admin_menu_item('plugins_simple', elgg_echo('admin:plugins:simple'), 'plugins');
+ elgg_add_admin_menu_item('plugins_advanced', elgg_echo('admin:plugins:advanced'), 'plugins');
register_page_handler('admin', 'admin_settings_page_handler');
}
@@ -186,14 +166,14 @@ function admin_settings_page_handler($page) {
global $CONFIG;
admin_gatekeeper();
- elgg_admin_add_plugin_settings_sidemenu();
+ elgg_admin_add_plugin_settings_menu();
elgg_set_context('admin');
elgg_unregister_css('screen');
// default to overview
if (!isset($page[0]) || empty($page[0])) {
- $page = array('overview');
+ $page = array('overview', 'statistics');
}
// was going to fix this in the page_handler() function but
@@ -206,7 +186,7 @@ function admin_settings_page_handler($page) {
// special page for plugin settings since we create the form for them
if ($page[0] == 'plugin_settings' && isset($page[1])
- && elgg_view_exists("settings/{$page[1]}/edit")) {
+ && elgg_view_exists("settings/{$page[1]}/edit")) {
$view = '/admin/components/plugin_settings';
$vars['plugin'] = $page[1];
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index ed19976cd..773e6f25b 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -88,20 +88,6 @@ function elgg_unregister_menu_item($menu_name, $item_name) {
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,
- 'href' => $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.
@@ -112,7 +98,35 @@ function add_submenu_item($label, $link, $group = 'default', $onclick = false, $
if ($context == 'main') {
$context = 'all';
}
+
+ $item = array(
+ 'name' => $label,
+ 'title' => $label,
+ 'url' => $link,
+ 'context' => $context,
+ 'section' => $group,
+ );
+
+ if ($selected) {
+ $item['selected'] = true;
+ }
+
+ if ($onclick) {
+ $js = "onclick=\"javascript:return confirm('" . elgg_echo('deleteconfirm') . "')\"";
+ $item['vars'] = array('js' => $js);
+ }
+
+ return elgg_register_menu_item('page', $item);
+/*
+ $item = array(
+ 'text' => $label,
+ 'href' => $link,
+ 'selected' => $selected
+ );
+
return elgg_add_submenu_item($item, $context, $group);
+ *
+ */
}
/**
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 6fe400f62..25b269873 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -1299,13 +1299,20 @@ function request_user_validation($user_guid) {
* @return void
*/
function collections_submenu_items() {
- global $CONFIG;
+
$user = get_loggedin_user();
- add_submenu_item(elgg_echo('friends:collections'),
- $CONFIG->wwwroot . "pg/collections/" . $user->username);
+ elgg_register_menu_item('page', array(
+ 'name' => 'friends:collections',
+ 'title' => elgg_echo('friends:collections'),
+ 'url' => "pg/collections/$user->username",
+ ));
- add_submenu_item(elgg_echo('friends:collections:add'), $CONFIG->wwwroot . "pg/collections/add");
+ elgg_register_menu_item('page', array(
+ 'name' => 'friends:collections',
+ 'title' => elgg_echo('friends:collections:add'),
+ 'url' => "pg/collections/add",
+ ));
}
/**
diff --git a/js/lib/ui.js b/js/lib/ui.js
index c7eda593c..02d49794d 100644
--- a/js/lib/ui.js
+++ b/js/lib/ui.js
@@ -7,6 +7,9 @@ elgg.ui.init = function () {
});
$('.elgg-toggle').live('click', elgg.ui.toggle);
+
+ $('.elgg-menu-parent').live('click', elgg.ui.menuToggle);
+
$('a.collapsibleboxlink').click(elgg.ui.toggleCollapsibleBox);
@@ -39,9 +42,21 @@ elgg.ui.toggle = function(event) {
event.preventDefault();
}
+/**
+ * Toggles a child menu when the parent is clicked
+ *
+ * @param {Object} event
+ * @return void
+ */
+elgg.ui.menuToggle = function(event) {
+ $(this).siblings().slideToggle('medium');
+ $(this).toggleClass('elgg-menu-closed elgg-menu-opened');
+ event.preventDefault();
+}
+
// reusable generic hidden panel
elgg.ui.toggleCollapsibleBox = function () {
- $(this.parentNode.parentNode).children(".collapsible_box").slideToggle("fast");
+ //$(this.parentNode.parentNode).children(".collapsible_box").slideToggle("fast");
return false;
};
diff --git a/views/default/admin/overview.php b/views/default/admin/overview/statistics.php
index 1785864e7..1785864e7 100644
--- a/views/default/admin/overview.php
+++ b/views/default/admin/overview/statistics.php
diff --git a/views/default/css/admin.php b/views/default/css/admin.php
index c73bbfe42..ce31a0036 100644
--- a/views/default/css/admin.php
+++ b/views/default/css/admin.php
@@ -106,48 +106,27 @@ table.mceLayout {
.elgg-admin h6 {
color:#666666;
}
-.elgg-admin .elgg-sidebar .submenu {
- margin:0;
- padding:0;
- list-style: none;
- background-color: transparent;
- background-image: none;
- -webkit-box-shadow: none;
- -moz-box-shadow: none;
- -webkit-border-radius: 0;
- -moz-border-radius: 0;
-}
-.elgg-admin .submenu li.selected a,
-.elgg-admin .submenu li.selected li.selected a,
-.elgg-admin .submenu li.selected li.selected li.selected a {
- background-color: black;
- color:white;
-}
-.elgg-admin .submenu li a {
- display:block;
+
+.elgg-page-menu a {
+ display: block;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
- background-color:white;
- margin:0 0 3px 0;
- padding:2px 4px 2px 8px;
- color:#333333;
-}
-.elgg-admin .submenu li a:hover {
- background-color:black;
- color:white;
- text-decoration:none;
+ background-color: white;
+ margin: 0 0 3px 0;
+ padding: 2px 4px 2px 8px;
+ color: #333333;
}
-.elgg-admin .submenu ul.child {
- margin-bottom:10px;
+.elgg-page-menu a:hover {
+ background-color: black;
+ color: white;
+ text-decoration: none;
}
-.elgg-admin .submenu .child li a {
- margin-left:15px;
- background-color:#dedede;
- color:#333333;
+.elgg-page-menu li.selected > a {
+ background-color: black;
+ color: white;
}
-.elgg-admin .submenu .child li a:hover {
- background-color:black;
- color:white;
+.elgg-page-menu li.selected > ul {
+ display: block;
}
.admin_settings h3 {
diff --git a/views/default/css/elements/navigation.php b/views/default/css/elements/navigation.php
index 7975dde25..359e10be4 100644
--- a/views/default/css/elements/navigation.php
+++ b/views/default/css/elements/navigation.php
@@ -223,57 +223,27 @@
color: white;
text-decoration: none;
}
-.elgg-page-menu .selected a {
+.elgg-page-menu li.selected > a {
background-color: #4690D6;
color: white;
}
-
-.submenu {
- margin:0;
- padding:0;
- list-style: none;
+.elgg-page-menu .elgg-child-menu {
+ display: none;
+ margin-left: 15px;
}
-.submenu ul {
- margin-bottom:0;
- padding-left:0;
- list-style: none;
+.elgg-menu-closed:before, .elgg-menu-opened:before {
+ display: inline-block;
+ padding-right: 4px;
}
-.submenu li.selected a,
-.submenu li.selected li.selected a,
-.submenu li.selected li.selected li.selected a {
- background: #4690D6;
- color:white;
+.elgg-menu-closed:before {
+ content: "\002B";
}
-.submenu li a {
- display:block;
- -webkit-border-radius: 8px;
- -moz-border-radius: 8px;
- background-color:white;
- margin:0 0 3px 0;
- padding:2px 4px 2px 8px;
-}
-.submenu li a:hover {
- background:#0054A7;
- color:white;
- text-decoration:none;
-}
-.submenu .child li a {
- margin-left:15px;
- background-color:white;
- color:#4690D6;
-}
-.submenu .child li a:hover {
- background:#0054A7;
- color:white;
- text-decoration:none;
+.elgg-menu-opened:before {
+ content: "\002D";
}
-
-.elgg-owner-block-menu li {
- float: left;
- width: 50%;
- font-size: 90%;
-}
-
+/* ***************************************
+ HOVER MENU
+*************************************** */
.elgg-hover-menu {
display: none;
position: absolute;
@@ -309,3 +279,9 @@
color: white;
background-color: red;
}
+
+.elgg-owner-block-menu li {
+ float: left;
+ width: 50%;
+ font-size: 90%;
+}
diff --git a/views/default/layout/elements/sidebar.php b/views/default/layout/elements/sidebar.php
index c03700c8a..f2071adb5 100644
--- a/views/default/layout/elements/sidebar.php
+++ b/views/default/layout/elements/sidebar.php
@@ -24,10 +24,7 @@ END;
echo elgg_view('layout/elements/owner_block');
echo elgg_view('navigation/sidebar_menu');
-echo elgg_view_menu('page', array(
- 'sort_by' => 'name',
- 'class' => 'elgg-page-menu',
-));
+echo elgg_view_menu('page', array('sort_by' => 'name'));
// optional 'sidebar' parameter
if (isset($vars['sidebar'])) {
diff --git a/views/default/navigation/menu/elements/group.php b/views/default/navigation/menu/elements/group.php
new file mode 100644
index 000000000..09474ea67
--- /dev/null
+++ b/views/default/navigation/menu/elements/group.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Menu group
+ *
+ * @uses $vars['items']
+ * @uses $vars['class']
+ * @uses $vars['section']
+ */
+
+$class = elgg_get_array_value('class', $vars, '');
+if (isset($vars['section'])) {
+ $class = "$class elgg-section-{$vars['section']}";
+}
+
+echo "<ul class=\"$class\">";
+foreach ($vars['items'] as $menu_item) {
+ echo elgg_view('navigation/menu/elements/item', array('item' => $menu_item));
+}
+echo '</ul>';
diff --git a/views/default/navigation/menu/elements/item.php b/views/default/navigation/menu/elements/item.php
index f6959b2f4..7903dbdc0 100644
--- a/views/default/navigation/menu/elements/item.php
+++ b/views/default/navigation/menu/elements/item.php
@@ -7,4 +7,19 @@ if ($item->getSelected()) {
$class = 'class="selected"';
}
-echo "<li $class>{$item->getLink()}</li>";
+$link_vars = array();
+
+$children = $item->getChildren();
+if ($children) {
+ $link_vars['class'] = 'elgg-menu-parent elgg-menu-closed';
+}
+
+echo "<li $class>";
+echo $item->getLink($link_vars);
+if ($children) {
+ echo elgg_view('navigation/menu/elements/group', array(
+ 'items' => $children,
+ 'class' => 'elgg-menu elgg-child-menu',
+ ));
+}
+echo '</li>';
diff --git a/views/default/navigation/menu/page.php b/views/default/navigation/menu/page.php
new file mode 100644
index 000000000..00fa1ef51
--- /dev/null
+++ b/views/default/navigation/menu/page.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Page menu
+ *
+ * @uses $vars['menu']
+ * @uses $vars['selected_item']
+ * @uses $vars['class']
+ */
+
+$class = 'elgg-menu elgg-page-menu';
+if (isset($vars['class'])) {
+ $class = "$class {$vars['class']}";
+}
+
+if (isset($vars['selected_item'])) {
+ $parent = $vars['selected_item']->getParent();
+ while ($parent) {
+ $parent->setSelected();
+ $parent = $parent->getParent();
+ }
+}
+
+foreach ($vars['menu'] as $section => $menu_items) {
+ echo elgg_view('navigation/menu/elements/group', array(
+ 'items' => $menu_items,
+ 'section' => $section,
+ 'class' => $class,
+ ));
+}