]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
welcome to the admin dashboard
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 24 Jan 2011 02:02:46 +0000 (02:02 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 24 Jan 2011 02:02:46 +0000 (02:02 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7922 36083f99-b078-4883-b0ff-0f9b5a30f544

16 files changed:
engine/lib/admin.php
engine/lib/widgets.php
languages/en.php
mod/developers/languages/en.php
mod/developers/start.php
mod/thewire/start.php
views/default/admin/dashboard.php [new file with mode: 0644]
views/default/admin/overview/statistics.php [deleted file]
views/default/admin/statistics/overview.php [new file with mode: 0644]
views/default/css/admin.php
views/default/layout/shells/widgets.php
views/default/layout/shells/widgets/add_panel.php
views/default/navigation/menu/elements/item.php
views/default/widgets/content_stats/content.php [new file with mode: 0644]
views/default/widgets/new_users/content.php [new file with mode: 0644]
views/default/widgets/online_users/content.php [new file with mode: 0644]

index 1e8d51cdf986577d4b65181d6cd2960021ca9685..c8254a0ffcd0f3b0cbc5e887b2542aecfd48638f 100644 (file)
@@ -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
index e11e4b8e326b3765a45cd4efd1839e041f7210c5..9a092e92d26331bae6c878298e9ab6c67c3bd5e3 100644 (file)
@@ -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;
+                       }
                }
        }
 
index bf344527321b34a77106a0aece6b98473a883a89..d02a13f23cdb517518d2fda91944d8b745af90f7 100644 (file)
@@ -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...",
index 644acfb5fd508b0cad68bb132b4dd92ba9805a24..bd16a8c61e7925714ba0690326df8a109f0a97c8 100644 (file)
@@ -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);
index ba84c323485c1c0d96e73edc1edfe16f42c7ae58..04c83bdded72817d1da23d7271d7b647a9edf9f6 100644 (file)
@@ -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() {
index abb0cb01965c439d20bfb1a00e515d2970046e45..6aba3aff6e320e1ba5187bc783005c95085abfe7 100644 (file)
@@ -1,5 +1,34 @@
 <?php
 
+function rest_wire_post($username, $text) {
+       login(get_user(2));
+       
+    $user = get_user_by_username($username);
+    if (!$user) {
+        throw new InvalidParameterException('Bad username');
+    }
+
+    $obj = new ElggObject();
+    $obj->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
 
                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 (file)
index 0000000..57e1530
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+elgg_set_page_owner_guid(get_loggedin_userid());
+
+$params = array(
+       'num_columns' => 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 (file)
index 52bd4dd..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-/**
- * Elgg statistics screen
- *
- * @package Elgg
- * @subpackage Core
- */
-
-// Work out number of users
-$users_stats = get_number_users();
-$total_users = get_number_users(true);
-
-// Get version information
-$version = get_version();
-$release = get_version(true);
-
-echo elgg_view('admin/statistics/extend');
-
-?>
-<div class="elgg-module elgg-inline-module">
-       <div class="elgg-head">
-               <h3><?php echo elgg_echo('admin:statistics:label:basic'); ?></h3>
-       </div>
-       <div class="elgg-body">
-               <table class="elgg-table-alt">
-                       <tr class="odd">
-                               <td><b><?php echo elgg_echo('admin:statistics:label:version'); ?> :</b></td>
-                               <td><?php echo elgg_echo('admin:statistics:label:version:release'); ?> - <?php echo $release; ?>, <?php echo elgg_echo('admin:statistics:label:version:version'); ?> - <?php echo $version; ?></td>
-                       </tr>
-                       <tr class="even">
-                               <td><b><?php echo elgg_echo('admin:statistics:label:numusers'); ?> :</b></td>
-                               <td><?php echo $users_stats; ?> <?php echo elgg_echo('active'); ?> / <?php echo $total_users; ?> <?php echo elgg_echo('total') ?></td>
-                       </tr>
-               </table>
-       </div>
-</div>
-
-<?php
-
-// Get entity statistics
-$entity_stats = get_entity_statistics();
-$even_odd = "";
-?>
-<div class="elgg-module elgg-inline-module">
-       <div class="elgg-head">
-               <h3><?php echo elgg_echo('admin:statistics:label:numentities'); ?></h3>
-       </div>
-       <div class="elgg-body">
-               <table class="elgg-table-alt">
-               <?php
-                       foreach ($entity_stats as $k => $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
-                                               <tr class="{$even_odd}">
-                                                       <td>{$a}:</td>
-                                                       <td>{$b}</td>
-                                               </tr>
-END;
-                               }
-                       }
-               ?>
-               </table>
-       </div>
-</div>
\ 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 (file)
index 0000000..09678fc
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+/**
+ * Elgg statistics screen
+ *
+ * @package Elgg
+ * @subpackage Core
+ */
+
+// Work out number of users
+$users_stats = get_number_users();
+$total_users = get_number_users(true);
+
+// Get version information
+$version = get_version();
+$release = get_version(true);
+
+?>
+<div class="admin_settings site_stats">
+       <?php echo elgg_view('overview/extend'); ?>
+       <h3><?php echo elgg_echo('admin:statistics:label:basic'); ?></h3>
+       <table class="styled">
+               <tr class="odd">
+                       <td class="column-one"><b><?php echo elgg_echo('admin:statistics:label:version'); ?> :</b></td>
+                       <td><?php echo elgg_echo('admin:statistics:label:version:release'); ?> - <?php echo $release; ?>, <?php echo elgg_echo('admin:statistics:label:version:version'); ?> - <?php echo $version; ?></td>
+               </tr>
+               <tr class="even">
+                       <td class="column-one"><b><?php echo elgg_echo('admin:statistics:label:numusers'); ?> :</b></td>
+                       <td><?php echo $users_stats; ?> <?php echo elgg_echo('active'); ?> / <?php echo $total_users; ?> <?php echo elgg_echo('total') ?></td>
+               </tr>
+
+       </table>
+</div>
+
+<?php
+
+
+// Get entity statistics
+$entity_stats = get_entity_statistics();
+$even_odd = "";
+?>
+<div class="admin_settings site_entities">
+       <h3><?php echo elgg_echo('admin:statistics:label:numentities'); ?></h3>
+       <table class="styled">
+               <?php
+                       foreach ($entity_stats as $k => $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
+                                               <tr class="{$even_odd}">
+                                                       <td class="column-one">{$a}:</td>
+                                                       <td>{$b}</td>
+                                               </tr>
+END;
+                               }
+                       }
+               ?>
+       </table>
+</div>
\ No newline at end of file
index d92cf968c1edcef123302275345f5bb2b79b0b5a..9735de87f88aa0a286307974a78b596eaae9f577 100644 (file)
@@ -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;
+}
+
+<?php //@todo location-dependent style: make an extension of elgg-gallery ?>
+.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;
+}
+
+<?php //@todo Convert to elgg-state-*? ?>
+.elgg-widget-available {
+       color: #333333;
+       cursor: pointer;
+}
+.elgg-widget-available:hover {
+       border-color: #aaaaaa;
+}
+.elgg-widget-unavailable {
+       color: #888888;
+}
+<?php //@todo extend elgg-module.  Still too many location-dependent/overly-qualified styles ?>
+.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(<?php echo elgg_get_site_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(<?php echo elgg_get_site_url(); ?>_graphics/elgg_sprites.png) no-repeat -198px 3px;
+}
+a.elgg-widget-edit-button {
+       right: 25px;
+       background:transparent url(<?php echo elgg_get_site_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;
+}
+
 
 
 
index 82489b37f645eddf1c5091ae2b73571bedf391eb..656a0e4c3fafd5e21cea303bb049818c9a0894cc 100644 (file)
@@ -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);
 }
index 1e2dc3bbc716b69a0124436876c5d37385711731..2d2a05a08eac6463d40d7a6b19cdbdbbed4ee9cd 100644 (file)
@@ -1,9 +1,17 @@
 <?php
+/**
+ * Widget add panel
+ *
+ * @uses $vars['widgets']     Array of current widgets
+ * @uses $vars['context']     The context for this widget layout
+ * @uses $vars['exact_match'] Only use widgets that match the context
+ */
 
 $widgets = $vars['widgets'];
 $context = $vars['context'];
+$exact = elgg_get_array_value('exact_match', $vars, false);
 
-$widget_types = elgg_get_widget_types($context);
+$widget_types = elgg_get_widget_types($context, $exact);
 
 $current_handlers = array();
 foreach ($widgets as $column_widgets) {
index 7903dbdc074216d94e4d2592af81f94c92ba6378..7c88c344c690d554c37f62a76d862f98bf06bb40 100644 (file)
@@ -3,15 +3,17 @@
 $item = $vars['item'];
 
 $class = '';
+$link_class = 'elgg-menu-closed';
 if ($item->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 "<li $class>";
diff --git a/views/default/widgets/content_stats/content.php b/views/default/widgets/content_stats/content.php
new file mode 100644 (file)
index 0000000..b5ea00e
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Content stats widget
+ */
+
+$max = 5;
+
+$entity_stats = get_entity_statistics();
+$object_stats = $entity_stats['object'];
+arsort($object_stats);
+$object_stats = array_slice($object_stats, 0, $max);
+
+echo '<table class="elgg-table">';
+foreach ($object_stats as $subtype => $num) {
+       $name = elgg_echo("item:object:$subtype");
+       echo "<tr><td>$name</td><td>$num</td></tr>";
+}
+echo '</table>';
diff --git a/views/default/widgets/new_users/content.php b/views/default/widgets/new_users/content.php
new file mode 100644 (file)
index 0000000..cfa7d8b
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+
+echo elgg_list_entities(array(
+       'type' => '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 (file)
index 0000000..e1ff698
--- /dev/null
@@ -0,0 +1,3 @@
+<?php
+
+echo $users_online = get_online_users();
\ No newline at end of file