Added statistics block
This commit is contained in:
52
root/language/en/mods/portal/portal_statistics_module.php
Normal file
52
root/language/en/mods/portal/portal_statistics_module.php
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Portal - Clock
|
||||||
|
* @version $Id$
|
||||||
|
* @copyright (c) 2009, 2010 Board3 Portal Team
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DO NOT CHANGE
|
||||||
|
*/
|
||||||
|
if (!defined('IN_PHPBB'))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($lang) || !is_array($lang))
|
||||||
|
{
|
||||||
|
$lang = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEVELOPERS PLEASE NOTE
|
||||||
|
//
|
||||||
|
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
|
||||||
|
//
|
||||||
|
// Placeholders can now contain order information, e.g. instead of
|
||||||
|
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
|
||||||
|
// translators to re-order the output of data while ensuring it remains correct
|
||||||
|
//
|
||||||
|
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
|
||||||
|
// equally where a string contains only two placeholders which are used to wrap text
|
||||||
|
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
|
||||||
|
$lang = array_merge($lang, array(
|
||||||
|
'ST_TOP' => 'Totals',
|
||||||
|
'ST_TOP_ANNS' => 'Total Announcements:',
|
||||||
|
'ST_TOP_STICKYS'=> 'Total Stickies:',
|
||||||
|
'ST_TOT_ATTACH' => 'Total Attachments:',
|
||||||
|
'TOPICS_PER_DAY_OTHER' => 'Topics per day: <strong>%d</strong>',
|
||||||
|
'TOPICS_PER_DAY_ZERO' => 'Topics per day: <strong>0</strong>',
|
||||||
|
'POSTS_PER_DAY_OTHER' => 'Posts per day: <strong>%d</strong>',
|
||||||
|
'POSTS_PER_DAY_ZERO' => 'Posts per day: <strong>0</strong>',
|
||||||
|
'USERS_PER_DAY_OTHER' => 'Users per day: <strong>%d</strong>',
|
||||||
|
'USERS_PER_DAY_ZERO' => 'Users per day: <strong>0</strong>',
|
||||||
|
'TOPICS_PER_USER_OTHER' => 'Topics per user: <strong>%d</strong>',
|
||||||
|
'TOPICS_PER_USER_ZERO' => 'Topics per user: <strong>0</strong>',
|
||||||
|
'POSTS_PER_USER_OTHER' => 'Posts per user: <strong>%d</strong>',
|
||||||
|
'POSTS_PER_USER_ZERO' => 'Posts per user: <strong>0</strong>',
|
||||||
|
'POSTS_PER_TOPIC_OTHER' => 'Posts per topic: <strong>%d</strong>',
|
||||||
|
'POSTS_PER_TOPIC_ZERO' => 'Posts per topic: <strong>0</strong>',
|
||||||
|
));
|
||||||
|
|
||||||
|
?>
|
||||||
200
root/portal/modules/portal_statistics.php
Normal file
200
root/portal/modules/portal_statistics.php
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Portal - Statistics
|
||||||
|
* @version $Id$
|
||||||
|
* @copyright (c) 2009, 2010 Board3 Portal Team
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
if (!defined('IN_PHPBB'))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package Statistics
|
||||||
|
*/
|
||||||
|
class portal_statistics_module
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Allowed columns: Just sum up your options (Exp: left + right = 10)
|
||||||
|
* top 1
|
||||||
|
* left 2
|
||||||
|
* center 4
|
||||||
|
* right 8
|
||||||
|
* bottom 16
|
||||||
|
*/
|
||||||
|
var $columns = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default modulename
|
||||||
|
*/
|
||||||
|
var $name = 'STATISTICS';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default module-image:
|
||||||
|
* file must be in "{T_THEME_PATH}/images/portal/"
|
||||||
|
*/
|
||||||
|
var $image_src = 'portal_statistics.png';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* module-language file
|
||||||
|
* file must be in "language/{$user->lang}/mods/portal/"
|
||||||
|
*/
|
||||||
|
var $language = 'portal_statistics_module';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* custom acp template
|
||||||
|
* file must be in "adm/style/portal/"
|
||||||
|
*/
|
||||||
|
var $custom_acp_tpl = '';
|
||||||
|
|
||||||
|
function get_template_side($module_id)
|
||||||
|
{
|
||||||
|
global $config, $template, $user;
|
||||||
|
|
||||||
|
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
|
||||||
|
$total_posts = $config['num_posts'];
|
||||||
|
$total_topics = $config['num_topics'];
|
||||||
|
$total_users = $config['num_users'];
|
||||||
|
$total_files = $config['num_files'];
|
||||||
|
|
||||||
|
$l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
|
||||||
|
$l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
|
||||||
|
$l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';
|
||||||
|
|
||||||
|
// avarage stat
|
||||||
|
$board_days = (time() - $config['board_startdate']) / 86400;
|
||||||
|
|
||||||
|
$topics_per_day = ($total_topics) ? round($total_topics / $board_days, 0) : 0;
|
||||||
|
$posts_per_day = ($total_posts) ? round($total_posts / $board_days, 0) : 0;
|
||||||
|
$users_per_day = round($total_users / $board_days, 0);
|
||||||
|
$topics_per_user = ($total_topics) ? round($total_topics / $total_users, 0) : 0;
|
||||||
|
$posts_per_user = ($total_posts) ? round($total_posts / $total_users, 0) : 0;
|
||||||
|
$posts_per_topic = ($total_topics) ? round($total_posts / $total_topics, 0) : 0;
|
||||||
|
|
||||||
|
if ($topics_per_day > $total_topics)
|
||||||
|
{
|
||||||
|
$topics_per_day = $total_topics;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($posts_per_day > $total_posts)
|
||||||
|
{
|
||||||
|
$posts_per_day = $total_posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($users_per_day > $total_users)
|
||||||
|
{
|
||||||
|
$users_per_day = $total_users;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($topics_per_user > $total_topics)
|
||||||
|
{
|
||||||
|
$topics_per_user = $total_topics;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($posts_per_user > $total_posts)
|
||||||
|
{
|
||||||
|
$posts_per_user = $total_posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($posts_per_topic > $total_posts)
|
||||||
|
{
|
||||||
|
$posts_per_topic = $total_posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
$l_topics_per_day_s = ($total_topics == 0) ? 'TOPICS_PER_DAY_ZERO' : 'TOPICS_PER_DAY_OTHER';
|
||||||
|
$l_posts_per_day_s = ($total_posts == 0) ? 'POSTS_PER_DAY_ZERO' : 'POSTS_PER_DAY_OTHER';
|
||||||
|
$l_users_per_day_s = ($total_users == 0) ? 'USERS_PER_DAY_ZERO' : 'USERS_PER_DAY_OTHER';
|
||||||
|
$l_topics_per_user_s = ($total_topics == 0) ? 'TOPICS_PER_USER_ZERO' : 'TOPICS_PER_USER_OTHER';
|
||||||
|
$l_posts_per_user_s = ($total_posts == 0) ? 'POSTS_PER_USER_ZERO' : 'POSTS_PER_USER_OTHER';
|
||||||
|
$l_posts_per_topic_s = ($total_posts == 0) ? 'POSTS_PER_TOPIC_ZERO' : 'POSTS_PER_TOPIC_OTHER';
|
||||||
|
|
||||||
|
$topics_count = $this->get_topics_count();
|
||||||
|
|
||||||
|
|
||||||
|
// Assign specific vars
|
||||||
|
$template->assign_vars(array(
|
||||||
|
'S_DISPLAY_ADVANCED_STAT' => true,
|
||||||
|
'TOTAL_POSTS' => sprintf($user->lang[$l_total_post_s], $total_posts),
|
||||||
|
'TOTAL_TOPICS' => sprintf($user->lang[$l_total_topic_s], $total_topics),
|
||||||
|
'TOTAL_USERS' => sprintf($user->lang[$l_total_user_s], $total_users),
|
||||||
|
'NEWEST_USER' => sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
|
||||||
|
'S_ANN' => $topics_count[POST_ANNOUNCE],
|
||||||
|
'S_SCT' => $topics_count[POST_STICKY],
|
||||||
|
'S_TOT_ATTACH' => ($config['allow_attachments']) ? $total_files : 0,
|
||||||
|
|
||||||
|
// avarage stat
|
||||||
|
'TOPICS_PER_DAY' => sprintf($user->lang[$l_topics_per_day_s], $topics_per_day),
|
||||||
|
'POSTS_PER_DAY' => sprintf($user->lang[$l_posts_per_day_s], $posts_per_day),
|
||||||
|
'USERS_PER_DAY' => sprintf($user->lang[$l_users_per_day_s], $users_per_day),
|
||||||
|
'TOPICS_PER_USER' => sprintf($user->lang[$l_topics_per_user_s], $topics_per_user),
|
||||||
|
'POSTS_PER_USER' => sprintf($user->lang[$l_posts_per_user_s], $posts_per_user),
|
||||||
|
'POSTS_PER_TOPIC' => sprintf($user->lang[$l_posts_per_topic_s], $posts_per_topic),
|
||||||
|
));
|
||||||
|
return 'statistics_side.html';
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_template_acp($module_id)
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'title' => 'STATISTICS',
|
||||||
|
'vars' => array(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API functions
|
||||||
|
*/
|
||||||
|
function install($module_id)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function uninstall($module_id)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Better function with only one query
|
||||||
|
function get_topics_count()
|
||||||
|
{
|
||||||
|
global $db, $user;
|
||||||
|
|
||||||
|
$return_ary = array(
|
||||||
|
POST_ANNOUNCE => 0,
|
||||||
|
POST_STICKY => 0,
|
||||||
|
);
|
||||||
|
|
||||||
|
$sql_in = array(
|
||||||
|
POST_ANNOUNCE,
|
||||||
|
POST_STICKY,
|
||||||
|
);
|
||||||
|
|
||||||
|
$sql = 'SELECT DISTINCT(topic_id) AS topic_id, topic_type AS type
|
||||||
|
FROM ' . TOPICS_TABLE . '
|
||||||
|
WHERE ' . $db->sql_in_set('topic_type', $sql_in, false);
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
switch($row['type'])
|
||||||
|
{
|
||||||
|
case POST_ANNOUNCE:
|
||||||
|
++$return_ary[POST_ANNOUNCE];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case POST_STICKY:
|
||||||
|
++$return_ary[POST_STICKY];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
return $return_ary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<!--version $Id$ //-->
|
||||||
|
{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{$IMAGE_SRC}" width="16" height="16" alt="" /> <!-- ENDIF -->{L_STATISTICS}{$LR_BLOCK_H_R}
|
||||||
|
<strong>{L_ST_TOP}</strong><br />
|
||||||
|
{TOTAL_POSTS}<br />
|
||||||
|
{TOTAL_TOPICS}<br />
|
||||||
|
{L_ST_TOP_ANNS} <strong>{S_ANN}</strong><br />
|
||||||
|
{L_ST_TOP_STICKYS} <strong>{S_SCT}</strong><br />
|
||||||
|
{L_ST_TOT_ATTACH} <strong>{S_TOT_ATTACH}</strong><br />
|
||||||
|
|
||||||
|
<hr class="dashed" />
|
||||||
|
{TOPICS_PER_DAY}<br />
|
||||||
|
{POSTS_PER_DAY}<br />
|
||||||
|
{USERS_PER_DAY}<br />
|
||||||
|
{TOPICS_PER_USER}<br />
|
||||||
|
{POSTS_PER_USER}<br />
|
||||||
|
{POSTS_PER_TOPIC}<br />
|
||||||
|
<hr class="dashed" />
|
||||||
|
|
||||||
|
{TOTAL_USERS}<br />
|
||||||
|
{NEWEST_USER}
|
||||||
|
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}
|
||||||
BIN
root/styles/prosilver/theme/images/portal/portal_statistics.png
Normal file
BIN
root/styles/prosilver/theme/images/portal/portal_statistics.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Reference in New Issue
Block a user