aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/admin.php139
-rw-r--r--engine/lib/elgglib.php20
-rw-r--r--engine/tests/ui/submenu.php26
-rw-r--r--views/default/admin/components/admin_page_layout.php36
-rw-r--r--views/default/admin/components/sidemenu.php105
-rw-r--r--views/default/navigation/submenu_item.php16
-rw-r--r--views/default/output/url.php13
-rw-r--r--views/default/page_elements/owner_block.php9
8 files changed, 135 insertions, 229 deletions
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index 73e891332..81ef69baf 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -34,54 +34,75 @@ function extend_elgg_admin_page($new_admin_view, $view = 'admin/main', $priority
}
/**
- * Add an admin area section or child section (aka tab).
+ * Calculate the plugin settings submenu.
+ * This is done in a separate function called from the admin
+ * page handler because of performance concerns.
*
- * Used in conjuction with http://elgg.org/admin/section/child_section style
- * page handler.
- *
- * @param string $section_id Globally unique section id.
- * @param string $section_title Human readable section title.
- * @param string $parent_id If a child section, the parent section id. Cannot have grandchildren.
*/
-function elgg_add_admin_section($section_id, $section_title, $parent_id = NULL) {
+function elgg_admin_add_plugin_settings_sidemenu() {
global $CONFIG;
- if (!isset($CONFIG->admin_sections)) {
- $CONFIG->admin_sections = array();
+ if (!$installed_plugins = get_installed_plugins()) {
+ // nothing added because no items
+ return FALSE;
}
- // have to support adding a child section to a missing parent
- // because of plugin order problems. A plugin can extend
- // an admin section added by different plugin lower in the load priority.
- if ($parent_id) {
- if (!isset($CONFIG->admin_sections[$parent_id])) {
- $CONFIG->admin_sections[$parent_id] = array('children' => array());
- }
+ $parent_item = array(
+ 'text' => elgg_echo('admin:plugin_settings'),
+ 'id' => 'admin:plugin_settings'
+ );
+
+ elgg_add_submenu_item($parent_item, 'admin');
- if (!isset($CONFIG->admin_sections[$parent_id][$section_id])) {
- $CONFIG->admin_sections[$parent_id]['children'][$section_id] = array('title' => $section_title);
- return TRUE;
- } else {
- return FALSE;
+ foreach ($installed_plugins as $plugin_id => $info) {
+ if (!$info['active']) {
+ continue;
}
- } else {
- // children can be defined before parents
- if (!isset($CONFIG->admin_sections[$section_id])) {
- $CONFIG->admin_sections[$section_id] = array(
- 'title' => $section_title,
- 'children' => array()
- );
- return TRUE;
- } else {
- // allow to define this since children can be defined before the parent.
- $CONFIG->admin_sections[$section_id] = array(
- 'title' => $section_title
+
+ if (elgg_view_exists("settings/{$plugin_id}/edit")) {
+ $item = array(
+ 'text' => $info['manifest']['name'],
+ 'href' => "{$CONFIG->url}pg/admin/plugin_settings/$plugin_id",
+ 'parent_id' => 'admin:plugin_settings'
);
+
+ elgg_add_submenu_item($item, 'admin');
}
}
}
/**
+ * Add an admin area section or child section.
+ * This is a wrapper for elgg_add_admin_item(array(...), 'admin').
+ *
+ * Used in conjuction with http://elgg.org/admin/section_id/child_section style
+ * page handler.
+ *
+ * @param string $section_id
+ * @param string $section_title Human readable section title.
+ * @param string $parent_id If a child section, the parent section id.
+ */
+function elgg_add_admin_submenu_item($section_id, $section_title, $parent_id = NULL) {
+ global $CONFIG;
+
+ // in the admin section parents never have links
+ if ($parent_id) {
+ $href = "{$CONFIG->url}pg/admin/$parent_id/$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');
+}
+
+/**
* Initialise the admin page.
*/
function admin_init() {
@@ -99,31 +120,30 @@ function admin_init() {
register_action('admin/plugins/simple_update_states', FALSE, '', TRUE);
-
// admin area overview and basic site settings
- elgg_add_admin_section('overview', elgg_echo('admin:overview'));
- elgg_add_admin_section('site', elgg_echo('admin:site'));
- elgg_add_admin_section('basic', elgg_echo('admin:site:basic'), 'site');
- elgg_add_admin_section('advanced', elgg_echo('admin:site:advanced'), 'site');
+ elgg_add_admin_submenu_item('overview', elgg_echo('admin:overview'));
+ elgg_add_admin_submenu_item('site', elgg_echo('admin:site'));
+ elgg_add_admin_submenu_item('basic', elgg_echo('admin:site:basic'), 'admin:overview:site');
+ elgg_add_admin_submenu_item('advanced', elgg_echo('admin:site:advanced'), 'admin:overview:site');
// appearance
- elgg_add_admin_section('appearance', elgg_echo('admin:appearance'));
- //elgg_add_admin_section('basic', elgg_echo('admin:appearance'), 'appearance');
- elgg_add_admin_section('menu_items', elgg_echo('admin:menu_items'), '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');
// users
- elgg_add_admin_section('users', elgg_echo('admin:users'));
- elgg_add_admin_section('online', elgg_echo('admin:users:online'), 'users');
- elgg_add_admin_section('add', elgg_echo('admin:users:add'), 'users');
- elgg_add_admin_section('find', elgg_echo('admin:users:find'), '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('add', elgg_echo('admin:users:add'), 'users');
+ elgg_add_admin_submenu_item('find', elgg_echo('admin:users:find'), 'users');
// plugins
- elgg_add_admin_section('plugins', elgg_echo('admin:plugins'));
- elgg_add_admin_section('simple', elgg_echo('admin:plugins:simple'), 'plugins');
- elgg_add_admin_section('advanced', elgg_echo('admin:plugins:advanced'), '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_section('plugin_settings', elgg_echo('admin:plugin_settings'));
+ //elgg_add_admin_submenu_item('plugin_settings', elgg_echo('admin:plugin_settings'));
register_page_handler('admin', 'admin_settings_page_handler');
}
@@ -138,6 +158,8 @@ function admin_settings_page_handler($page) {
global $CONFIG;
admin_gatekeeper();
+ elgg_admin_add_plugin_settings_sidemenu();
+ set_context('admin');
// default to overview
if (!isset($page[0]) || empty($page[0])) {
@@ -169,7 +191,18 @@ function admin_settings_page_handler($page) {
$content = elgg_echo('admin:unknown_section');
}
- $body = elgg_view('admin/components/admin_page_layout', array('content' => $content, 'page' => $page));
+ //$body = elgg_view('admin/components/admin_page_layout', array('content' => $content, 'page' => $page));
+
+ $notices_html = '';
+ if ($notices = elgg_get_admin_notices()) {
+ foreach ($notices as $notice) {
+ $notices_html .= elgg_view_entity($notice);
+ }
+
+ $content = "<div class=\"admin_notices\">$notices_html</div>$content";
+ }
+
+ $body = elgg_view_layout('one_column_with_sidebar', $content);
page_draw($title, $body);
}
@@ -179,7 +212,7 @@ function admin_settings_page_handler($page) {
* The id is a unique ID that can be cleared once the admin
* completes the action.
*
- * eg: add_admin_notice('twitter_service_no_api',
+ * eg: add_admin_notice('twitter_services_no_api',
* 'Before your users can use Twitter services on this site, you must set up
* the Twitter API key in the <a href="link">Twitter Services Settings</a>');
*
@@ -198,7 +231,7 @@ function elgg_add_admin_notice($id, $message) {
return $admin_notice->save();
}
- return false;
+ return FALSE;
}
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 1c0d1cfc1..8d41de1cc 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -910,7 +910,7 @@ function add_submenu_item($label, $link, $group = 'default', $onclick = false, $
$item = array(
'text' => $label,
- 'url' => $link,
+ 'href' => $link,
'selected' => $selected
);
@@ -1003,7 +1003,7 @@ function elgg_add_submenu_item(array $item, $context = 'all', $group = 'default'
* @param bool $sort Sort the menu items alphabetically
* @since 1.8
*/
-function elgg_prepare_submenu($context = 'main', $sort = TRUE) {
+function elgg_prepare_submenu($context = 'main', $sort = FALSE) {
global $CONFIG;
if (!isset($CONFIG->submenu_items) || !($CONFIG->submenu_items)) {
@@ -1052,9 +1052,9 @@ function elgg_prepare_submenu($context = 'main', $sort = TRUE) {
}
// if the parent doesn't have a url, make it the first child item.
- if (isset($item->children) && $item->children && !$item->url) {
+ if (isset($item->children) && $item->children && !$item->href) {
$child = $item->children[0];
- while ($child && !isset($child->url)) {
+ while ($child && !isset($child->href)) {
if (isset($child->children) && isset($child->children[0])) {
$child = $child->children[0];
} else {
@@ -1062,11 +1062,11 @@ function elgg_prepare_submenu($context = 'main', $sort = TRUE) {
}
}
- if ($child && isset($child->url)) {
- $item->url = $child->url;
+ if ($child && isset($child->href)) {
+ $item->href = $child->href;
} else {
// @todo There are no URLs anywhere in this tree.
- $item->url = $CONFIG->url;
+ $item->href = $CONFIG->url;
}
}
}
@@ -1139,14 +1139,14 @@ function elgg_get_submenu($context = NULL, $sort = FALSE) {
while ($item = current($items)) {
$t = '';
// ignore parents created by a child but parent never defined properly
- if (!isset($item->text) || !isset($item->url) || !($item->text) || !($item->url)) {
+ if (!isset($item->text) || !isset($item->href) || !($item->text) || !($item->href)) {
next($items);
continue;
}
// try to guess if this should be selected if they don't specify
- if ((!isset($item->selected) || $item->selected === NULL) && isset($item->url)) {
- $item->selected = elgg_http_url_is_identical($_SERVER['REQUEST_URI'], $item->url);
+ if ((!isset($item->selected) || $item->selected === NULL) && isset($item->href)) {
+ $item->selected = elgg_http_url_is_identical($_SERVER['REQUEST_URI'], $item->href);
}
// traverse up the parent tree if matached to mark all parents as selected/expanded.
diff --git a/engine/tests/ui/submenu.php b/engine/tests/ui/submenu.php
index d7a156417..745364890 100644
--- a/engine/tests/ui/submenu.php
+++ b/engine/tests/ui/submenu.php
@@ -20,7 +20,7 @@ $url = "{$CONFIG->url}engine/tests/ui/submenu.php";
$items = array(
array(
'text' => 'Upper level 1',
- 'url' => "$url?upper_level_1",
+ 'href' => "$url?upper_level_1",
'id' => 'ul1'
),
array(
@@ -30,50 +30,50 @@ $items = array(
),
array(
'text' => 'Sub CD',
- 'url' => "$url?sub_cd",
+ 'href' => "$url?sub_cd",
'parent_id' => 'cd'
),
array(
'text' => 'Cup',
- 'url' => "$url?cup",
+ 'href' => "$url?cup",
'id' => 'cup'
),
array(
'text' => 'Phone',
- 'url' => "$url?phone",
+ 'href' => "$url?phone",
'id' => 'phone',
'parent_id' => 'cup'
),
array(
'text' => 'Wallet',
- 'url' => "$url?wallet",
+ 'href' => "$url?wallet",
'id' => 'wallet',
'parent_id' => 'phone'
),
array(
'text' => 'Upper level',
- 'url' => "$url?upper_level",
+ 'href' => "$url?upper_level",
'id' => 'ul'
),
array(
'text' => 'Sub Upper level',
- 'url' => "$url?sub_upper_level",
+ 'href' => "$url?sub_upper_level",
'parent_id' => 'ul'
),
array(
'text' => 'Root',
- 'url' => $url,
+ 'href' => $url,
),
array(
'text' => 'I am an orphan',
- 'url' => 'http://google.com',
+ 'href' => 'http://google.com',
'parent_id' => 'missing_parent'
),
array(
'text' => 'JS Test',
- 'url' => 'http://elgg.org',
+ 'href' => 'http://elgg.org',
'vars' => array('js' => 'onclick="alert(\'Link to \' + $(this).attr(\'href\') + \'!\'); return false;"')
)
);
@@ -86,10 +86,10 @@ add_submenu_item('Old Onclick Test', 'http://elgg.com', NULL, TRUE);
add_submenu_item('Old Selected Test', 'http://elgg.com', NULL, '', TRUE);
-elgg_add_submenu_item(array('text' => 'Not Main Test', 'url' => "$url?not_main_test"), 'not_main', 'new_menu');
-elgg_add_submenu_item(array('text' => 'Not Main C Test', 'url' => "$url?not_main_c_test"), 'not_main', 'new_menu');
+elgg_add_submenu_item(array('text' => 'Not Main Test', 'href' => "$url?not_main_test"), 'not_main', 'new_menu');
+elgg_add_submenu_item(array('text' => 'Not Main C Test', 'href' => "$url?not_main_c_test"), 'not_main', 'new_menu');
-elgg_add_submenu_item(array('text' => 'All test', 'url' => "$url?all"), 'all');
+elgg_add_submenu_item(array('text' => 'All test', 'href' => "$url?all"), 'all');
//set_context('not_main');
diff --git a/views/default/admin/components/admin_page_layout.php b/views/default/admin/components/admin_page_layout.php
deleted file mode 100644
index 4f2a67d48..000000000
--- a/views/default/admin/components/admin_page_layout.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * Elgg admin page layout. Includes the admin sidebar and the ownerblock (for legacy support)
- *
- * @package Elgg
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/
- */
-
-$notices_html = '';
-if ($notices = elgg_get_admin_notices()) {
- foreach ($notices as $notice) {
- $notices_html .= elgg_view_entity($notice);
- }
-}
-
-?>
-<div id="elgg_content" class="clearfloat sidebar">
- <div id="elgg_sidebar">
- <?php
- echo elgg_view('admin/components/sidemenu', $vars);
- echo '<hr />';
- echo elgg_view('page_elements/owner_block');
- ?>
- </div>
-
- <div id="elgg_page_contents" class="clearfloat">
- <?php
- if ($notices) {
- echo "<div class=\"admin_notices\">$notices_html</div>";
- }
- echo $vars['content'];
- ?>
- </div>
-</div>
diff --git a/views/default/admin/components/sidemenu.php b/views/default/admin/components/sidemenu.php
deleted file mode 100644
index 4e02eecd9..000000000
--- a/views/default/admin/components/sidemenu.php
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-/**
- * Elgg admin sidebar
- *
- * @package Elgg
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/
- */
-
-$sections = $vars['config']->admin_sections;
-$current_section = $vars['page'][0];
-$child_section = (isset($vars['page'][1])) ? $vars['page'][1] : NULL;
-
-// "Plugin Settings" is a special sidemenu item that is added automatically
-// it's calculated here instead of in admin_init() because of preformance concerns.
-$installed_plugins = get_installed_plugins();
-$plugin_settings_children = $sort = array();
-foreach ($installed_plugins as $plugin_id => $info) {
- if (!$info['active']) {
- continue;
- }
-
- // @todo might not need to check if plugin is enabled here because
- // this view wouldn't exist if it's not. right?
- if (is_plugin_enabled($plugin_id) && elgg_view_exists("settings/{$plugin_id}/edit")) {
- $plugin_settings_children[$plugin_id] = array(
- 'title' => $info['manifest']['name']
- );
- $sort[] = elgg_strtolower($info['manifest']['name']);
- }
-}
-
-array_multisort($sort, SORT_ASC, SORT_STRING, $plugin_settings_children);
-
-if ($plugin_settings_children) {
- // merge in legacy support with new support.
- if (!isset($sections['plugin_settings'])) {
- $sections['plugin_settings'] = array(
- 'title' => elgg_echo('admin:plugin_settings'),
- 'children' => $plugin_settings_children
- );
- } else {
- $sections['plugin_settings']['title'] = elgg_echo('admin:plugin_settings');
- if (isset($sections['plugin_settings']['children'])) {
- $children = array_merge($plugin_settings_children, $sections['plugin_settings']['children']);
- $sections['plugin_settings']['children'] = $children;
- }
- }
-}
-
-?>
-
-<ul class="admin submenu">
- <?php foreach ($sections as $id => $info) {
- $parent_class = ($current_section == $id) ? 'selected' : '';
- $link = "{$vars['url']}pg/admin/$id";
-
- $expand_child = $children_menu = $expanded = '';
- // parent menu items with children default to the first child element.
- if (isset($info['children']) && $info['children']) {
- $link = '';
- if ($current_section == $id) {
- $hidden = '';
- $expanded = '-';
- } else {
- $hidden = 'style="display: none;"';
- $expanded = '+';
- }
- $expand_child = "<span class=\"expand_child\">$expanded</span> ";
- $children_menu = "<ul class=\"admin child_submenu\" $hidden>";
- foreach ($info['children'] as $child_id => $child_info) {
- $child_selected = ($child_section == $child_id) ? "class=\"selected\"" : '';
- $child_link = "{$vars['url']}pg/admin/$id/$child_id";
- if (!$link) {
- $link = $child_link;
- }
- $children_menu .= "<li $child_selected><a href=\"$child_link\">{$child_info['title']}</a></li>";
- }
- $children_menu .= '</ul>';
- }
-
- $parent_class = ($parent_class) ? "class=\"$parent_class\"" : '';
-
- echo "<li $parent_class><a href=\"$link\">$expand_child{$info['title']}</a>
- $children_menu
- </li>";
- }
- ?>
-</ul>
-
-<script type="text/javascript">
- $('a span.expand_child').click(function() {
- var submenu = $(this).parent().parent().find('ul.child_submenu');
- submenu.slideToggle();
-
- if ($(this).html() == '+') {
- $(this).html('-');
- } else {
- $(this).html('+');
- }
-
- return false;
- });
-</script> \ No newline at end of file
diff --git a/views/default/navigation/submenu_item.php b/views/default/navigation/submenu_item.php
index c64f8a679..ff2cc48d1 100644
--- a/views/default/navigation/submenu_item.php
+++ b/views/default/navigation/submenu_item.php
@@ -13,7 +13,7 @@
$group = (isset($vars['group'])) ? $vars['group'] : 'default';
$item = (isset($vars['item'])) ? $vars['item'] : FALSE;
-$children_html = (isset($vars['children_html'])) ? $vars['children_html'] : FALSE;
+$children_html = (isset($vars['children_html'])) ? $vars['children_html'] : '';
if ($item) {
@@ -34,8 +34,16 @@ if ($item) {
$child_indicator = "<span class=\"child_indicator\">$child_indicator </span>";
}
- $url = htmlentities($item->url);
+ $url = htmlentities($item->href);
$text = $child_indicator . htmlentities($item->text);
+
+ $link_vars = array_merge($vars, array(
+ 'href' => $item->href,
+ 'text' => $text,
+ 'encode_text' => FALSE
+ ));
+
+ $link = elgg_view('output/url', $link_vars);
}
-?>
-<li <?php echo $selected; ?>><a href="<?php echo $url; ?>" <?php echo $js; ?>><?php echo $text; ?></a><?php echo $children_html; ?></li>
+
+echo "<li $selected>$link$children_html</li>";
diff --git a/views/default/output/url.php b/views/default/output/url.php
index 87d3a68a1..19ad331e1 100644
--- a/views/default/output/url.php
+++ b/views/default/output/url.php
@@ -10,7 +10,8 @@
*
* @uses string $vars['href'] The string to display in the <a></a> tags
* @uses string $vars['text'] The string between the <a></a> tags.
- * @uses bool $vars['target'] Set the target="" attribute.
+ * @uses string $vars['target'] Set the target="" attribute.
+ * @uses bool $vars['encode_text'] Run $vars['text'] through htmlentities()?
* @uses string $vars['class'] what to add in class=""
* @uses string $vars['js'] Javascript to insert in <a> tag
* @uses bool $vars['is_action'] Is this a link to an action?
@@ -39,13 +40,17 @@ if (!empty($url)) {
}
if (array_key_exists('text', $vars) && $vars['text']) {
- $text = htmlentities($vars['text'], ENT_QUOTES, 'UTF-8');
+ if (isset($vars['encode_text']) && $vars['encode_text']) {
+ $text = htmlentities($vars['text'], ENT_QUOTES, 'UTF-8');
+ } else {
+ $text = $vars['text'];
+ }
} else {
$text = htmlentities($url, ENT_QUOTES, 'UTF-8');
}
- if ((substr_count($url, "http://") == 0) && (substr_count($url, "https://") == 0)) {
- $url = "http://" . $url;
+ if ((substr_count($url, "http://") == 0) && (substr_count($url, "https://") == 0)) {
+ $url = "http://" . $url;
}
if (array_key_exists('is_action', $vars) && $vars['is_action']) {
diff --git a/views/default/page_elements/owner_block.php b/views/default/page_elements/owner_block.php
index a45fad826..ef77d6895 100644
--- a/views/default/page_elements/owner_block.php
+++ b/views/default/page_elements/owner_block.php
@@ -38,14 +38,14 @@ if(is_plugin_enabled('profile')) {
}
$display = "<div class='owner_block_icon'>" . $icon . "</div>";
$display .= "<div class='owner_block_contents clearfloat'>" . $info;
-
+
if ($owner->briefdescription) {
$desc = $owner->briefdescription;
$display .= "<p class='profile_info briefdescription'>" . $desc . "</p>";
}
$display .= "<p class='profile_info location'>{$location}</p>";
$display .= "</div>"; // close owner_block_contents
-
+
$contents .= "<div id='owner_block' class='radius8'>".$display."</div>";
}
}
@@ -58,9 +58,10 @@ if (isset($vars['content']))
$contents .= $vars['content'];
// Initialise the current tool/page submenu (plugins can add to the submenu)
-$submenu = get_submenu();
+$submenu = elgg_get_submenu();
+
if (!empty($submenu))
- $contents .= $submenu;
+ $contents .= $submenu;
if (!empty($contents)) {
echo $contents;