diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-12 22:37:10 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-12 22:37:10 +0000 |
commit | 5582e8070201138cc8ce76a3b900d3f1fbbc3337 (patch) | |
tree | 1555462cc44ecbc333b1f78eabd8e2851d201b0b | |
parent | f93f66516b0ef1a2f36af5e5836772e0cce57468 (diff) | |
download | elgg-5582e8070201138cc8ce76a3b900d3f1fbbc3337.tar.gz elgg-5582e8070201138cc8ce76a3b900d3f1fbbc3337.tar.bz2 |
- Moved statistics to their own component views. Yay.
Marcus Povey
git-svn-id: https://code.elgg.org/elgg/trunk@906 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/admin.php | 2 | ||||
-rw-r--r-- | engine/lib/statistics.php | 78 | ||||
-rw-r--r-- | views/default/admin/statistics.php | 60 | ||||
-rw-r--r-- | views/default/admin/statistics_opt/basic.php | 28 | ||||
-rw-r--r-- | views/default/admin/statistics_opt/numentities.php | 40 | ||||
-rw-r--r-- | views/default/admin/statistics_opt/online.php | 19 |
6 files changed, 134 insertions, 93 deletions
diff --git a/engine/lib/admin.php b/engine/lib/admin.php index f1e088eca..3c34b51c1 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -39,8 +39,6 @@ */ function admin_init() { - global $CONFIG; - // Add plugin main menu option (last) extend_elgg_admin_page('admin/main_opt/statistics', 'admin/main'); extend_elgg_admin_page('admin/main_opt/site', 'admin/main'); diff --git a/engine/lib/statistics.php b/engine/lib/statistics.php index f5bf23250..844cbfa01 100644 --- a/engine/lib/statistics.php +++ b/engine/lib/statistics.php @@ -2,7 +2,8 @@ /** * Elgg statistics library. * This file contains a number of functions for obtaining statistics about the running system. - * These statistics are mainly used by the administration pages. + * These statistics are mainly used by the administration pages, and is also where the basic views for statistics + * are added. * * @package Elgg * @subpackage Core @@ -50,40 +51,53 @@ return $entity_stats; } - /** - * Return the number of users registered in the system. - * - * @return int - */ - function get_number_users() - { - global $CONFIG; + /** + * Return the number of users registered in the system. + * + * @return int + */ + function get_number_users() + { + global $CONFIG; - $result = get_data_row("SELECT count(*) as count from {$CONFIG->dbprefix}entities where type='user'"); + $result = get_data_row("SELECT count(*) as count from {$CONFIG->dbprefix}entities where type='user'"); - if ($result) - return $result->count; + if ($result) + return $result->count; - return false; - } + return false; + } + + /** + * Report how many users are currently online + * + * @return int + */ + function get_number_online() + { + // TODO: get logged in users somehow + } - /** - * Report how many users are currently online - * - * @return int - */ - function get_number_online() - { - // TODO: get logged in users somehow - } + /** + * Return a list of how many users are currently online. + * + * @param int $limit Number of users to return + */ + function get_online_users($limit = 10) + { + // TODO: Writeme + } - /** - * Return a list of how many users are currently online. - * - * @param int $limit Number of users to return - */ - function get_online_users($limit = 10) - { - // TODO: Writeme - } + /** + * Initialise the statistics admin page. + */ + function statistics_init() + { + extend_elgg_admin_page('admin/statistics_opt/basic', 'admin/statistics'); + extend_elgg_admin_page('admin/statistics_opt/numentities', 'admin/statistics'); + extend_elgg_admin_page('admin/statistics_opt/online', 'admin/statistics'); + } + + /// Register init function + register_elgg_event_handler('init','system','statistics_init'); ?> diff --git a/views/default/admin/statistics.php b/views/default/admin/statistics.php index 984205c8f..4c2035f0d 100644 --- a/views/default/admin/statistics.php +++ b/views/default/admin/statistics.php @@ -14,62 +14,4 @@ echo "<p>" . nl2br(elgg_echo("admin:statistics:description")) . "</p>"; - - - // Get entity statistics - $entity_stats = get_entity_statistics(); - - // Work out number of users - $users_stats = get_number_users(); - - // users online - $users_online = get_number_online(); - - - -?> -<div> - <h2><?php echo elgg_echo('admin:statistics:label:basic'); ?></h2> - <table> - <tr> - <td><b><?php echo elgg_echo('admin:statistics:label:numusers'); ?> :</b></td> - <td><?php echo $users_stats; ?></td> - </tr> - <tr> - <td><b><?php echo elgg_echo('admin:statistics:label:numonline'); ?> :</b></td> - <td><?php echo $users_online; ?></td> - </tr> - </table> -</div> - -<div> - <h2><?php echo elgg_echo('admin:statistics:label:numentities'); ?></h2> - <table> - <?php - foreach ($entity_stats as $k => $entry) - { - echo "<table>"; - foreach ($entry as $a => $b) - { - if ($a == "__base__") - $a=$k; - else - $a = "$k $a"; - echo <<< END - <tr> - <td><b>$a :</b></td> - <td>$b</td> - </tr> -END; - } - echo "</table>"; - } - ?> - </table> -</div> - -<div> - <h2><?php echo sprintf(elgg_echo('admin:statistics:label:onlineusers'), 10); ?></h2> - - -</div>
\ No newline at end of file +?>
\ No newline at end of file diff --git a/views/default/admin/statistics_opt/basic.php b/views/default/admin/statistics_opt/basic.php new file mode 100644 index 000000000..e2d58827b --- /dev/null +++ b/views/default/admin/statistics_opt/basic.php @@ -0,0 +1,28 @@ +<?php + /** + * Elgg statistics screen + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Marcus Povey + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + */ + + // Get entity statistics + $entity_stats = get_entity_statistics(); +?> +<div> + <h2><?php echo elgg_echo('admin:statistics:label:basic'); ?></h2> + <table> + <tr> + <td><b><?php echo elgg_echo('admin:statistics:label:numusers'); ?> :</b></td> + <td><?php echo $users_stats; ?></td> + </tr> + <tr> + <td><b><?php echo elgg_echo('admin:statistics:label:numonline'); ?> :</b></td> + <td><?php echo $users_online; ?></td> + </tr> + </table> +</div>
\ No newline at end of file diff --git a/views/default/admin/statistics_opt/numentities.php b/views/default/admin/statistics_opt/numentities.php new file mode 100644 index 000000000..c50949809 --- /dev/null +++ b/views/default/admin/statistics_opt/numentities.php @@ -0,0 +1,40 @@ +<?php + /** + * Elgg statistics screen + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Marcus Povey + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + */ + + // Work out number of users + $users_stats = get_number_users(); +?> +<div> + <h2><?php echo elgg_echo('admin:statistics:label:numentities'); ?></h2> + <table> + <?php + foreach ($entity_stats as $k => $entry) + { + echo "<table>"; + foreach ($entry as $a => $b) + { + if ($a == "__base__") + $a=$k; + else + $a = "$k $a"; + echo <<< END + <tr> + <td><b>$a :</b></td> + <td>$b</td> + </tr> +END; + } + echo "</table>"; + } + ?> + </table> +</div>
\ No newline at end of file diff --git a/views/default/admin/statistics_opt/online.php b/views/default/admin/statistics_opt/online.php new file mode 100644 index 000000000..2a9532470 --- /dev/null +++ b/views/default/admin/statistics_opt/online.php @@ -0,0 +1,19 @@ +<?php + /** + * Elgg statistics screen + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Marcus Povey + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + */ + + // users online + $users_online = get_number_online(); +?> + +<div> + <h2><?php echo sprintf(elgg_echo('admin:statistics:label:onlineusers'), 10); ?></h2> +</div>
\ No newline at end of file |