From de3b6654ddc28fe0fc7d6e1fb615ddb4fd3e3e47 Mon Sep 17 00:00:00 2001 From: cash Date: Mon, 24 Jan 2011 02:02:46 +0000 Subject: welcome to the admin dashboard git-svn-id: http://code.elgg.org/elgg/trunk@7922 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 35 ++++++++++++++++++++++++++++------- engine/lib/widgets.php | 15 +++++++++++---- 2 files changed, 39 insertions(+), 11 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 1e8d51cdf..c8254a0ff 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -97,7 +97,7 @@ function elgg_add_admin_menu_item($section_id, $section_title, $parent_id = NULL } /** - * Initialise the admin page. + * Initialise the admin backend. * * @return void */ @@ -121,9 +121,9 @@ function admin_init() { elgg_register_action('profile/fields/delete', '', 'admin'); elgg_register_action('profile/fields/reorder', '', 'admin'); - // admin area overview and basic site settings - elgg_add_admin_menu_item('overview', elgg_echo('admin:overview')); - elgg_add_admin_menu_item('statistics', elgg_echo('admin:overview:statistics'), 'overview'); + // statistics + elgg_add_admin_menu_item('statistics', elgg_echo('admin:statistics')); + elgg_add_admin_menu_item('overview', elgg_echo('admin:statistics:overview'), 'statistics'); // site elgg_add_admin_menu_item('site', elgg_echo('admin:site')); @@ -149,6 +149,25 @@ function admin_init() { // plugins elgg_add_admin_menu_item('utilities', elgg_echo('admin:utilities')); + // dashboard + elgg_register_menu_item('page', array( + 'name' => 'dashboard', + 'url' => 'pg/admin/dashboard', + 'title' => elgg_echo('admin:dashboard'), + 'context' => 'admin', + )); + + // widgets + $widgets = array('online_users', 'new_users', 'content_stats'); + foreach ($widgets as $widget) { + elgg_register_widget_type( + $widget, + elgg_echo("admin:widget:$widget"), + elgg_echo("admin:widget:$widget:help"), + 'admin' + ); + } + register_page_handler('admin', 'admin_settings_page_handler'); } @@ -179,9 +198,9 @@ function admin_settings_page_handler($page) { elgg_unregister_css('screen'); - // default to overview + // default to dashboard if (!isset($page[0]) || empty($page[0])) { - $page = array('overview', 'statistics'); + $page = array('dashboard'); } // was going to fix this in the page_handler() function but @@ -204,7 +223,9 @@ function admin_settings_page_handler($page) { } else { $view = 'admin/' . implode('/', $page); $title = elgg_echo("admin:{$page[0]}"); - $title .= ' : ' . elgg_echo('admin:' . implode(':', $page)); + if (count($page) > 1) { + $title .= ' : ' . elgg_echo('admin:' . implode(':', $page)); + } } // allow a place to store helper views outside of the web-accessible views diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php index e11e4b8e3..9a092e92d 100644 --- a/engine/lib/widgets.php +++ b/engine/lib/widgets.php @@ -215,12 +215,13 @@ function elgg_is_widget_type($handler) { * * The widget types are stdClass objects. * - * @param string context The widget context or empty string for current context + * @param string $context The widget context or empty string for current context + * @param bool $exact Only return widgets registered for this context (false) * * @return array * @since 1.8.0 */ -function elgg_get_widget_types($context = "") { +function elgg_get_widget_types($context = "", $exact = false) { global $CONFIG; if (empty($CONFIG->widgets) || @@ -236,8 +237,14 @@ function elgg_get_widget_types($context = "") { $widgets = array(); foreach ($CONFIG->widgets->handlers as $key => $handler) { - if (in_array('all', $handler->context) || in_array($context, $handler->context)) { - $widgets[$key] = $handler; + if ($exact) { + if (in_array($context, $handler->context)) { + $widgets[$key] = $handler; + } + } else { + if (in_array('all', $handler->context) || in_array($context, $handler->context)) { + $widgets[$key] = $handler; + } } } -- cgit v1.2.3