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 ++- languages/en.php | 13 ++- mod/developers/languages/en.php | 9 ++ mod/developers/start.php | 4 +- mod/thewire/start.php | 41 ++++++- views/default/admin/dashboard.php | 11 ++ views/default/admin/overview/statistics.php | 84 --------------- views/default/admin/statistics/overview.php | 77 ++++++++++++++ views/default/css/admin.php | 124 +++++++++++++++++++++- views/default/layout/shells/widgets.php | 9 +- views/default/layout/shells/widgets/add_panel.php | 10 +- views/default/navigation/menu/elements/item.php | 4 +- views/default/widgets/content_stats/content.php | 18 ++++ views/default/widgets/new_users/content.php | 7 ++ views/default/widgets/online_users/content.php | 3 + 16 files changed, 357 insertions(+), 107 deletions(-) create mode 100644 views/default/admin/dashboard.php delete mode 100644 views/default/admin/overview/statistics.php create mode 100644 views/default/admin/statistics/overview.php create mode 100644 views/default/widgets/content_stats/content.php create mode 100644 views/default/widgets/new_users/content.php create mode 100644 views/default/widgets/online_users/content.php 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; + } } } diff --git a/languages/en.php b/languages/en.php index bf3445273..d02a13f23 100644 --- a/languages/en.php +++ b/languages/en.php @@ -515,7 +515,9 @@ $english = array( 'admin' => "Administration", 'admin:description' => "The admin panel allows you to control all aspects of the system, from user management to how plugins behave. Choose an option below to get started.", - 'admin:overview' => 'Overview', + 'admin:statistics' => "Statistics", + 'admin:statistics:overview' => 'Overview', + 'admin:appearance' => 'Appearance', 'admin:utilities' => 'Utilities', @@ -536,6 +538,14 @@ $english = array( 'admin:site:opt:linktext' => "Configure site...", 'admin:site:access:warning' => "Changing the access setting only affects the permissions on content created in the future.", + 'admin:dashboard' => 'Dashboard', + 'admin:widget:online_users' => 'Online users', + 'admin:widget:online_users:help' => 'Lists the users currently on the site', + 'admin:widget:new_users' => 'New users', + 'admin:widget:new_users:help' => 'Lists the newest users', + 'admin:widget:content_stats' => 'Content Statistics', + 'admin:widget:content_stats:help' => 'Keep track of the content created by your users', + /** * Plugins */ @@ -589,7 +599,6 @@ $english = array( 'admin:plugins:dependencies:local_value' => 'Actual value', 'admin:plugins:dependencies:comment' => 'Comment', - 'admin:overview:statistics' => "Statistics", 'admin:statistics:description' => "This is an overview of statistics on your site. If you need more detailed statistics, a professional administration feature is available.", 'admin:statistics:opt:description' => "View statistical information about users and objects on your site.", 'admin:statistics:opt:linktext' => "View statistics...", diff --git a/mod/developers/languages/en.php b/mod/developers/languages/en.php index 644acfb5f..bd16a8c61 100644 --- a/mod/developers/languages/en.php +++ b/mod/developers/languages/en.php @@ -9,6 +9,15 @@ $english = array( 'admin:developers' => 'Developers', 'admin:developers:settings' => 'Settings', 'admin:developers:preview' => 'CSS Preview', + + // settings + 'developers:label:simple_cache' => '', + 'developers:help:simple_cache' => '', + 'developers:label:views_cache' => '', + 'developers:help:views_cache' => '', + 'developers:label:' => '', + 'developers:help:' => '', + ); add_translation('en', $english); diff --git a/mod/developers/start.php b/mod/developers/start.php index ba84c3234..04c83bdde 100644 --- a/mod/developers/start.php +++ b/mod/developers/start.php @@ -6,8 +6,10 @@ elgg_register_event_handler('init', 'system', 'developers_init'); function developers_init() { - elgg_register_event_handler('pagesetup', 'system', 'developers_setup_menu'); + + $action_base = elgg_get_plugin_path() . 'developers/actions/developers'; + elgg_register_action('developers/settings', "$action_base/settings.php", 'admin'); } function developers_setup_menu() { diff --git a/mod/thewire/start.php b/mod/thewire/start.php index abb0cb019..6aba3aff6 100644 --- a/mod/thewire/start.php +++ b/mod/thewire/start.php @@ -1,5 +1,34 @@ subtype = 'thewire'; + $obj->owner_guid = $user->guid; + $obj->access_id = ACCESS_PUBLIC; + $obj->method = 'api'; + $obj->description = elgg_substr(strip_tags($text), 0, 140); + + $guid = $obj->save(); + + add_to_river('river/object/thewire/create', + 'create', + $user->guid, + $obj->guid + ); + + return 'success'; +} + + + + /** * Elgg wire plugin * The wire is simple twitter like plugin that allows users to post notes to the wire @@ -19,7 +48,17 @@ function thewire_init() { - // Set up menu for logged in users + expose_function('wire.post', + 'rest_wire_post', + array( 'username' => array ('type' => 'string'), + 'text' => array ('type' => 'string'), + ), + 'Post a status update to the wire', + 'POST', + false, + false); + +// Set up menu for logged in users $item = new ElggMenuItem('thewire', elgg_echo('thewire:title'), 'pg/thewire'); elgg_register_menu_item('site', $item); diff --git a/views/default/admin/dashboard.php b/views/default/admin/dashboard.php new file mode 100644 index 000000000..57e15308d --- /dev/null +++ b/views/default/admin/dashboard.php @@ -0,0 +1,11 @@ + 2, + 'exact_match' => true, +); +$widgets = elgg_view_layout('widgets', $params); + +echo $widgets; \ No newline at end of file diff --git a/views/default/admin/overview/statistics.php b/views/default/admin/overview/statistics.php deleted file mode 100644 index 52bd4ddb2..000000000 --- a/views/default/admin/overview/statistics.php +++ /dev/null @@ -1,84 +0,0 @@ - -
-
-

-
-
- - - - - - - - - -
: - , -
: /
-
-
- - -
-
-

-
-
- - $entry) { - arsort($entry); - foreach ($entry as $a => $b) { - - //This function controls the alternating class - $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; - - if ($a == "__base__") { - $a = elgg_echo("item:{$k}"); - if (empty($a)) - $a = $k; - } else { - if (empty($a)) { - $a = elgg_echo("item:{$k}"); - } else { - $a = elgg_echo("item:{$k}:{$a}"); - } - - if (empty($a)) { - $a = "$k $a"; - } - } - echo <<< END - - - - -END; - } - } - ?> -
{$a}:{$b}
-
-
\ No newline at end of file diff --git a/views/default/admin/statistics/overview.php b/views/default/admin/statistics/overview.php new file mode 100644 index 000000000..09678fc9a --- /dev/null +++ b/views/default/admin/statistics/overview.php @@ -0,0 +1,77 @@ + +
+ +

+ + + + + + + + + + +
: - , -
: /
+
+ + +
+

+ + $entry) { + arsort($entry); + foreach ($entry as $a => $b) { + + //This function controls the alternating class + $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; + + if ($a == "__base__") { + $a = elgg_echo("item:{$k}"); + if (empty($a)) + $a = $k; + } else { + if (empty($a)) { + $a = elgg_echo("item:{$k}"); + } else { + $a = elgg_echo("item:{$k}:{$a}"); + } + + if (empty($a)) { + $a = "$k $a"; + } + } + echo <<< END + + + + +END; + } + } + ?> +
{$a}:{$b}
+
\ No newline at end of file diff --git a/views/default/css/admin.php b/views/default/css/admin.php index d92cf968c..9735de87f 100644 --- a/views/default/css/admin.php +++ b/views/default/css/admin.php @@ -385,7 +385,7 @@ input { -webkit-border-radius: 5px; -moz-border-radius: 5px; } -input[type="submit"], .elgg-submit-button { +input[type="submit"], .elgg-submit-button, .elgg-action-button { font-size: 14px; font-weight: bold; color: white; @@ -400,12 +400,12 @@ input[type="submit"], .elgg-submit-button { cursor: pointer; outline: none; } -input[type="submit"]:hover, .elgg-submit-button:hover { +input[type="submit"]:hover, .elgg-submit-button:hover, .elgg-action-button:hover { color: white; background-color: #000000; text-decoration: none; } -.elgg-submit-button { +.elgg-submit-button, .elgg-action-button { padding: 4px 8px; } /* *************************************** @@ -446,6 +446,124 @@ input[type="submit"]:hover, .elgg-submit-button:hover { border-color: #555555; } +/* *************************************** + WIDGETS +*************************************** */ +.elgg-widgets { + float: right; + min-height: 30px; +} +.elgg-widget-add-control { + text-align: right; + margin: 5px 5px 15px; +} +.elgg-widgets-add-panel { + padding: 10px; + margin: 0 5px 15px; + background: #eeeeee; + border: 1px solid #cccccc; +} + + +.elgg-widgets-add-panel ul { + padding: 0; + margin: 0; +} +.elgg-widgets-add-panel li { + float: left; + margin: 2px 10px; + list-style: none; + width: 200px; + padding: 4px; + background-color: #eeeeee; + border: 1px solid #cccccc; + font-weight: bold; +} +.elgg-widgets-add-panel li a { + display: block; +} + + +.elgg-widget-available { + color: #333333; + cursor: pointer; +} +.elgg-widget-available:hover { + border-color: #aaaaaa; +} +.elgg-widget-unavailable { + color: #888888; +} + +.elgg-widget { + background-color: #dedede; + padding: 1px; + margin: 0 5px 15px; + position: relative; +} +.elgg-widget:hover { + background-color: #cccccc; +} +.elgg-widget-title { + background-color: #f5f5f5; + height: 30px; + line-height: 30px; + overflow: hidden; +} +.elgg-widget-title h3 { + float: left; + padding: 0 45px 0 20px; + color: #333333; +} +.elgg-widget-controls a { + position: absolute; + top: 5px; + display: block; + width: 18px; + height: 18px; + border: 1px solid transparent; +} +a.elgg-widget-collapse-button { + left: 5px; + background:transparent url(_graphics/elgg_sprites.png) no-repeat 0px -385px; +} +.elgg-widget-controls a.elgg-widget-collapsed { + background-position: 0px -365px; +} +a.elgg-widget-delete-button { + right: 5px; + background:transparent url(_graphics/elgg_sprites.png) no-repeat -198px 3px; +} +a.elgg-widget-edit-button { + right: 25px; + background:transparent url(_graphics/elgg_sprites.png) no-repeat -300px -1px; +} +a.elgg-widget-edit-button:hover, a.elgg-widget-delete-button:hover { + border: 1px solid #cccccc; +} +.elgg-widget-container { + border-top: 1px solid #dedede; + background-color: white; + width: 100%; + overflow: hidden; +} +.elgg-widget-edit { + display: none; + width: 96%; + padding: 2%; + border-bottom: 1px solid #dedede; +} +.elgg-widget-content { + padding: 10px; +} +.drag-handle { + cursor: move; +} +.elgg-widget-placeholder { + border: 2px dashed #dedede; + margin-bottom: 15px; +} + diff --git a/views/default/layout/shells/widgets.php b/views/default/layout/shells/widgets.php index 82489b37f..656a0e4c3 100644 --- a/views/default/layout/shells/widgets.php +++ b/views/default/layout/shells/widgets.php @@ -2,14 +2,16 @@ /** * Elgg widgets layout * - * @uses $vars['box'] Optional display box at the top of layout - * @uses $vars['num_columns'] Number of widget columns for this layout - * @uses $vars['show_add_widgets'] Display the add widgets button and panel + * @uses $vars['box'] Optional display box at the top of layout + * @uses $vars['num_columns'] Number of widget columns for this layout (3) + * @uses $vars['show_add_widgets'] Display the add widgets button and panel (true) + * @uses $vars['exact_match'] Widgets must match the current context (false) */ $box = elgg_get_array_value('box', $vars, ''); $num_columns = elgg_get_array_value('num_columns', $vars, 3); $show_add_widgets = elgg_get_array_value('show_add_widgets', $vars, true); +$exact_match = elgg_get_array_value('exact_match', $vars, false); $owner = elgg_get_page_owner(); $context = elgg_get_context(); @@ -24,6 +26,7 @@ if (elgg_can_edit_widget_layout($context)) { $params = array( 'widgets' => $widgets, 'context' => $context, + 'exact_match' => $exact_match, ); echo elgg_view('layout/shells/widgets/add_panel', $params); } diff --git a/views/default/layout/shells/widgets/add_panel.php b/views/default/layout/shells/widgets/add_panel.php index 1e2dc3bbc..2d2a05a08 100644 --- a/views/default/layout/shells/widgets/add_panel.php +++ b/views/default/layout/shells/widgets/add_panel.php @@ -1,9 +1,17 @@ getSelected()) { $class = 'class="selected"'; + $link_class = 'elgg-menu-opened'; } $link_vars = array(); $children = $item->getChildren(); if ($children) { - $link_vars['class'] = 'elgg-menu-parent elgg-menu-closed'; + $link_vars['class'] = "elgg-menu-parent $link_class"; } echo "
  • "; diff --git a/views/default/widgets/content_stats/content.php b/views/default/widgets/content_stats/content.php new file mode 100644 index 000000000..b5ea00e18 --- /dev/null +++ b/views/default/widgets/content_stats/content.php @@ -0,0 +1,18 @@ +'; +foreach ($object_stats as $subtype => $num) { + $name = elgg_echo("item:object:$subtype"); + echo "$name$num"; +} +echo ''; diff --git a/views/default/widgets/new_users/content.php b/views/default/widgets/new_users/content.php new file mode 100644 index 000000000..cfa7d8bda --- /dev/null +++ b/views/default/widgets/new_users/content.php @@ -0,0 +1,7 @@ + 'user', + 'subtype'=> null, + 'full_view' => FALSE +)); \ No newline at end of file diff --git a/views/default/widgets/online_users/content.php b/views/default/widgets/online_users/content.php new file mode 100644 index 000000000..e1ff69811 --- /dev/null +++ b/views/default/widgets/online_users/content.php @@ -0,0 +1,3 @@ +