diff --git a/e107_plugins/forum/forum_stats.php b/e107_plugins/forum/forum_stats.php
index e1a88e2371..1f25a71392 100644
--- a/e107_plugins/forum/forum_stats.php
+++ b/e107_plugins/forum/forum_stats.php
@@ -7,7 +7,6 @@
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
-
if(!defined('e107_INIT'))
{
require_once(__DIR__.'/../../class2.php');
@@ -19,42 +18,46 @@
exit;
}
+//class forumStats // Why a class? Why instatiate?
+//{
+ require_once(HEADERF);
+// private $from = 0;
+// private $view = 20;
-class forumStats
-{
-
- private $from = 0;
- private $view = 20;
-
-
+// $from = 0;
+// $view = 20;
- function __construct()
- {
+// function __construct()
+// {
//include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_stats.php');
//e107::lan('forum','front');
e107::lan('forum', "front", true);
e107::css('forum', 'forum.css');
- }
+// }
- function init()
- {
+// function init()
+// {
$sql = e107::getDb();
$tp = e107::getParser();
$ns = e107::getRender();
$frm = e107::getForm();
+ $template = e107::getTemplate('forum','forum_stats');
+ $sc = e107::getScBatch('stats', 'forum');
- require_once(e_PLUGIN.'forum/forum_class.php');
+// $sc['TOTAL_POSTS']= 5000000;
+// var_dump ($sc);
+// require_once(e_PLUGIN.'forum/forum_class.php'); // Really needed ? No call to the class is made....
$gen = e107::getDate();
- $forum = new e107forum;
+// $forum = new e107forum;
- $total_posts = $sql->count('forum_post');
- $total_topics = $sql->count('forum_thread');
- $total_replies = $total_posts - $total_topics;
- $total_views = 0;
+// $total_posts = $sql->count('forum_post'); // há mais
+// $total_topics = $sql->count('forum_thread'); // há mais
+// $total_replies = $total_posts - $total_topics; // há mais
+/* $total_views = 0;
$query = 'SELECT sum(thread_views) AS total FROM `#forum_thread` ';
if ($sql->gen($query))
@@ -62,34 +65,44 @@ function init()
$row = $sql->fetch();
$total_views = $row['total'];
}
+*/
- $firstpost = $sql->select('forum_post', 'post_datestamp', 'post_datestamp > 0 ORDER BY post_datestamp ASC LIMIT 0,1', 'default');
- $fp = $sql->fetch();
+// $firstpost = $sql->select('forum_post', 'post_datestamp', 'post_datestamp > 0 ORDER BY post_datestamp ASC LIMIT 0,1', 'default'); // Var not used
+ $sql->select('forum_post', 'post_datestamp', 'post_datestamp > 0 ORDER BY post_datestamp ASC LIMIT 0,1', 'default');
+ $fp = $sql->fetch();
$fp = is_array($fp) ? $fp : array();
+// var_dump ($row);
+// var_dump ($fp);
+
+// $sc->setVars(array('open_ds' => ((int) varset($fp['post_datestamp']))));
+ $SCvars_0['open_ds'] = (int) varset($fp['post_datestamp']);
- $open_ds = (int) varset($fp['post_datestamp']);
- $open_date = $gen->convert_date($open_ds, 'long');
- $open_since = $gen -> computeLapse($open_ds);
- $open_days = floor((time()-$open_ds) / 86400);
- $postsperday = ($open_days < 1 ? $total_posts : round($total_posts / $open_days));
+// $open_ds = (int) varset($fp['post_datestamp']);
+// $open_date = $gen->convert_date($open_ds, 'long');
+// $open_since = $gen -> computeLapse($open_ds);
+// $open_days = floor((time()-$open_ds) / 86400);
+// $postsperday = ($open_days < 1 ? $total_posts : round($total_posts / $open_days));
global $mySQLdefaultdb;
$query = "SHOW TABLE STATUS FROM `{$mySQLdefaultdb}`";
$sql->gen($query);
$array = $sql -> db_getList();
- $db_size = 0;
- $avg_row_len = 0;
+// $db_size = 0;
+// $avg_row_len = 0;
foreach($array as $table)
{
if($table['Name'] == MPREFIX.'forum_post')
{
- $db_size = eHelper::parseMemorySize($table['Data_length']);
- $avg_row_len = eHelper::parseMemorySize($table['Avg_row_length']);
+// $db_size = eHelper::parseMemorySize($table['Data_length']);
+// $avg_row_len = eHelper::parseMemorySize($table['Avg_row_length']);
+
+ $SCvars_0['db_size'] = eHelper::parseMemorySize($table['Data_length'])??0;
+ $SCvars_0['avg_row_len'] = eHelper::parseMemorySize($table['Avg_row_length']??0);
break;
}
}
-
+/*
$query = "
SELECT ft.thread_id, ft.thread_user, ft.thread_name, ft.thread_total_replies, ft.thread_datestamp, f.forum_sef, f.forum_class, u.user_name, u.user_id FROM #forum_thread as ft
LEFT JOIN #user AS u ON ft.thread_user = u.user_id
@@ -100,7 +113,8 @@ function init()
$sql->gen($query);
$most_activeArray = $sql->db_getList();
-
+*/
+/*
$query = "
SELECT ft.*, f.forum_class, f.forum_sef, u.user_name, u.user_id FROM #forum_thread as ft
LEFT JOIN #user AS u ON ft.thread_user = u.user_id
@@ -110,7 +124,7 @@ function init()
$sql->gen($query);
$most_viewedArray = $sql->db_getList();
-
+*/
/*$sql->select("user", "user_id, user_name, user_forums", "ORDER BY user_forums DESC LIMIT 0, 10", "no_where");
$posters = $sql -> db_getList();
$top_posters = array();
@@ -123,7 +137,7 @@ function init()
// get all replies
- $query = "
+/* $query = "
SELECT COUNT(fp.post_id) AS post_count, u.user_name, u.user_id, fp.post_thread FROM #forum_post as fp
LEFT JOIN #user AS u ON fp.post_user = u.user_id
GROUP BY fp.post_user
@@ -142,9 +156,9 @@ function init()
$topReplier[] = intval($poster['user_id']);
$top_posters[] = array("user_id" => $poster['user_id'], "user_name" => vartrue($poster['user_name'],LAN_ANONYMOUS), "user_forums" => $poster['post_count'], "percentage" => $percent);
}
- // end build top posters
+*/ // end build top posters
- $ids = implode(',', $topReplier);
+/* $ids = implode(',', $topReplier);
// find topics by top 10 users
$query = "
@@ -169,7 +183,6 @@ function init()
}
// sort
-
arsort($top_repliers_sort, SORT_NUMERIC);
// build top repliers
@@ -177,7 +190,8 @@ function init()
{
$top_repliers[] = $top_repliers_data[$uid];
}
-
+*/
+/*
// get all replies
$query = "
SELECT COUNT(ft.thread_id) AS thread_count, u.user_name, u.user_id FROM #forum_thread as ft
@@ -194,7 +208,7 @@ function init()
$percent = round(($poster['thread_count'] / $total_topics) * 100, 2);
$top_topic_starters[] = array("user_id" => $poster['user_id'], "user_name" => vartrue($poster['user_name'],LAN_ANONYMOUS), "user_forums" => $poster['thread_count'], "percentage" => $percent);
}
-
+*/
/*
$query = "
SELECT SUBSTRING_INDEX(thread_user,'.',1) AS t_user, COUNT(SUBSTRING_INDEX(ft.thread_user,'.',1)) AS ucount, u.user_name, u.user_id FROM #forum_t as ft
@@ -235,7 +249,8 @@ function init()
- $text_0 = "
+/*
+ $text_0 = ($template['text_0']??"
".LAN_FORUM_6001.": | {$open_date} |
".LAN_FORUM_6002.": | {$open_since} |
@@ -246,11 +261,13 @@ function init()
".LAN_FORUM_6014.": | {$postsperday} |
".LAN_FORUM_6006.": | {$db_size} |
".LAN_FORUM_6007.": | {$avg_row_len} |
-
";
-
-
-
+ ");
+*/ // Templates are always defined in the template file, by default.... No need for this hardcode
+//var_dump ($SCvars_0);
+ $sc->setVars($SCvars_0);
+ $text_0 = $tp->parseTemplate($template['text_0'], true, $sc);
+/*
$text_1 = "
@@ -263,43 +280,86 @@ function init()
";
-
- $count=1;
-
- foreach($most_activeArray as $ma)
- {
- if($ma['user_name'])
- {
+*/
+// $text_1 = $tp->parseTemplate($template['text_1']['start'], true);
+// $count=1;
+// $fstatsSCvars['count'] = 1;
+
+// foreach($most_activeArray as $ma)
+// {
+// if($ma['user_name'])
+// {
//$uinfo = "{$ma['user_name']}"; //TODO SEf Url .
+/*
$uparams = array('id' => $ma['user_id'], 'name' => $ma['user_name']);
$link = e107::getUrl()->create('user/profile/view', $uparams);
$uinfo = "".$ma['user_name']."";
- }
- else
- {
- $tmp = explode(chr(1), $ma['thread_anon']);
- $uinfo = $tp->toHTML($tmp[0]);
- }
-
- $ma['thread_sef'] = eHelper::title2sef($ma['thread_name'],'dashl');
- $url = e107::url('forum','topic', $ma);
-
- $text_1 .= "
-
-
-
-
-
-
-
- ";
-
- $count++;
- }
-
- $text_1 .= "
";
+*/
+// $uinfo = " $ma['user_id'], 'name' => $ma['user_name']))."'>".$ma['user_name']."";
+// }
+// else
+// {
+// $tmp = explode(chr(1), $ma['thread_anon']);
+// $uinfo = $tp->toHTML($tmp[0]);
+// }
+
+// $ma['thread_sef'] = eHelper::title2sef($ma['thread_name'],'dashl');
+// $url = e107::url('forum','topic', $ma);
+
+// $text_1 .= $tp->parseTemplate($template['text_1']['item'], true, $sc);
+
+// $count++;
+// }
+/*
+$query = "
+SELECT ft.thread_id, ft.thread_user, ft.thread_name, ft.thread_total_replies, ft.thread_datestamp, f.forum_sef, f.forum_class, u.user_name, u.user_id FROM #forum_thread as ft
+LEFT JOIN #user AS u ON ft.thread_user = u.user_id
+LEFT JOIN #forum AS f ON f.forum_id = ft.thread_forum_id
+WHERE ft.thread_active > 0
+AND f.forum_class IN (".USERCLASS_LIST.")
+ORDER BY ft.thread_total_replies DESC LIMIT 0,10";
+*/
+////$sql->gen($query);
+//$most_activeArray =
+
+//// foreach($sql->db_getList() as $SCvars_1['ma'])
+//// {
+// if($fstatsSCvars['ma']['user_name'])
+// {
+ //$uinfo = "{$ma['user_name']}"; //TODO SEf Url .
+/*
+ $uparams = array('id' => $ma['user_id'], 'name' => $ma['user_name']);
+ $link = e107::getUrl()->create('user/profile/view', $uparams);
+ $uinfo = "".$ma['user_name']."";
+*/
+// $uinfo = " $fstatsSCvars['ma']['user_id'], 'name' => $fstatsSCvars['ma']['user_name']))."'>".$fstatsSCvars['ma']['user_name']."";
+// }
+// else
+// {
+// $tmp = explode(chr(1), $fstatsSCvars['ma']['thread_anon']);
+// $uinfo = $tp->toHTML($tmp[0]);
+// }
+
+// $fstatsSCvars['ma']['thread_sef'] = eHelper::title2sef($fstatsSCvars['ma']['thread_name'],'dashl');
+// $url = e107::url('forum','topic', $fstatsSCvars['ma']);
+
+//// $sc->setVars($SCvars_1);
+//// $text_1 .= $tp->parseTemplate($template['text_1']['item'], true, $sc);
+
+// $fstatsSCvars['count']++;
+//// }
+//// $text_1 .= $tp->parseTemplate($template['text_1']['end'], true, $sc);
+
+ $text_1 = FS_render_table("
+SELECT ft.thread_id, ft.thread_user, ft.thread_name, ft.thread_total_replies, ft.thread_datestamp, f.forum_sef, f.forum_class, u.user_name, u.user_id FROM #forum_thread as ft
+LEFT JOIN #user AS u ON ft.thread_user = u.user_id
+LEFT JOIN #forum AS f ON f.forum_id = ft.thread_forum_id
+WHERE ft.thread_active > 0
+AND f.forum_class IN (".USERCLASS_LIST.")
+ORDER BY ft.thread_total_replies DESC LIMIT 0,10", $template['text_1'], $sc);
+/*
$text_2 = "
@@ -346,10 +406,15 @@ function init()
}
$text_2 .= "
";
+*/
+ $text_2 = FS_render_table("
+ SELECT ft.*, f.forum_class, f.forum_sef, u.user_name, u.user_id FROM #forum_thread as ft
+ LEFT JOIN #user AS u ON ft.thread_user = u.user_id
+ LEFT JOIN #forum AS f ON f.forum_id = ft.thread_forum_id
+ WHERE f.forum_class IN (".USERCLASS_LIST.")
+ ORDER BY ft.thread_views DESC LIMIT 0,10", $template['text_2'], $sc);
-
-
-
+/*
$text_3 = "
@@ -372,7 +437,7 @@ function init()
-
";
@@ -383,8 +448,45 @@ function init()
$text_3 .= "
";
+*/
+
+ $query = "
+ SELECT COUNT(fp.post_id) AS post_count, u.user_name, u.user_id, fp.post_thread FROM #forum_post as fp
+ LEFT JOIN #user AS u ON fp.post_user = u.user_id
+ GROUP BY fp.post_user
+ ORDER BY post_count DESC LIMIT 0,10";
+
+ $sql->gen($query);
+ $top_repliers_data = $sql->db_getList('ALL', false, false, 'user_id');
+// $top_repliers_data = $sql->retrieve($query,true);
+
+ // build top posters meanwhile
+ $top_posters = array();
+ $topReplier = array();
+ $temp = call_user_func('plugin_forum_stats_shortcodes::sc_total_posts');
+// var_dump ($temp);
+ foreach($top_repliers_data as $poster)
+ {
+// $percent = round(($poster['post_count'] / call_user_func('plugin_forum_stats_shortcodes::sc_total_posts')) * 100, 2);
+ $percent = round(($poster['post_count'] / $sc->sc_total_posts()) * 100, 2);
+// var_dump ($percent);
+ $topReplier[] = intval($poster['user_id']);
+ $top_posters[] = array("user_id" => $poster['user_id'], "user_name" => vartrue($poster['user_name'],LAN_ANONYMOUS), "user_forums" => $poster['post_count'], "percentage" => $percent);
+ }
+
+ $text_3 = FS_render_table($top_posters, $template['text_3'], $sc);
+
+
+
+
+
+
+
+
+
+/*
$text_4 = "
@@ -406,15 +508,39 @@ function init()
-
+
";
$count++;
}
$text_4 .= "
";
+*/
+ // get all replies
+ $query = "
+ SELECT COUNT(ft.thread_id) AS thread_count, u.user_name, u.user_id FROM #forum_thread as ft
+ LEFT JOIN #user AS u ON ft.thread_user = u.user_id
+ GROUP BY ft.thread_user
+ ORDER BY thread_count DESC LIMIT 0,10";
+
+ $sql->gen($query);
+ $top_topic_starters_data = $sql->db_getList();
+ $top_topic_starters = array();
+
+ foreach($top_topic_starters_data as $poster)
+ {
+// $percent = round(($poster['thread_count'] / call_user_func('plugin_forum_stats_shortcodes::sc_total_topics')) * 100, 2);
+ $percent = round(($poster['thread_count'] / $sc->sc_total_topics()) * 100, 2);
+ $top_topic_starters[] = array("user_id" => $poster['user_id'], "user_name" => vartrue($poster['user_name'],LAN_ANONYMOUS), "user_forums" => $poster['thread_count'], "percentage" => $percent);
+ }
+ $text_4 = FS_render_table($top_topic_starters, $template['text_4'], $sc);
+
+
+
+
+/*
$text_5 = "
@@ -437,7 +563,7 @@ function init()
-
+
";
@@ -445,20 +571,85 @@ function init()
}
$text_5 .= '
';
+*/
+ $ids = implode(',', $topReplier);
+
+ // find topics by top 10 users
+ $query = "
+ SELECT COUNT(ft.thread_id) AS thread_count, u.user_id FROM #forum_thread as ft
+ LEFT JOIN #user AS u ON ft.thread_user = u.user_id
+ WHERE u.user_id IN ({$ids}) GROUP BY ft.thread_user";
+
+ $sql->gen($query);
+ $top_repliers_data_c = $sql->db_getList('ALL', false, false, 'user_id');
+
+ $top_repliers = array();
+ $top_repliers_sort = array();
+ foreach($top_repliers_data as $uid => $poster)
+ {
+ $poster['post_count'] = $poster['post_count'] - $top_repliers_data_c[$uid]['thread_count'];
+// $percent = round(($poster['post_count'] / call_user_func('plugin_forum_stats_shortcodes::sc_total_replies')) * 100, 2);
+ $percent = round(($poster['post_count'] / $sc->sc_total_replies()) * 100, 2);
+ $top_repliers_sort[$uid] = $poster['post_count'];
+ //$top_repliers[$uid] = $poster;
+ $top_repliers_data[$uid]['user_forums'] = $poster['post_count'];
+ $top_repliers_data[$uid]['percentage'] = $percent;
+ //$top_repliers_data[$uid] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['post_count'], "percentage" => $percent);
+ }
+
+ // sort
+ arsort($top_repliers_sort, SORT_NUMERIC);
+
+ // build top repliers
+ foreach ($top_repliers_sort as $uid => $c)
+ {
+ $top_repliers[] = $top_repliers_data[$uid];
+ }
+
+ $text_5 = FS_render_table($top_repliers, $template['text_5'], $sc);
+
+
+
+
+
+
+
+ if(!defined("TAB_ORDER")){ define("TAB_ORDER","0,1,2,3,4,5"); }
+// if(!defined("TAB_ORDER")){ define("TAB_ORDER","2,3,1,0,5,4"); }
+
+ $taborder = explode(",",TAB_ORDER);
+ $captions = array('0'=>LAN_FORUM_6000, '1'=>LAN_FORUM_0011, '2'=>LAN_FORUM_6010, '3'=>LAN_FORUM_0010, '4'=>LAN_FORUM_6011, '5'=>LAN_FORUM_6012);
+ $orderedtabs = array_replace(array_flip($taborder), $captions);
+
+// var_dump ($taborder);
+// var_dump ($orderedtabs);
if(deftrue('BOOTSTRAP'))
{
- $tabs = array();
+// $tabs = array();
+/*
$tabs[0] = array('caption'=>LAN_FORUM_6000, 'text'=>$text_0);
$tabs[1] = array('caption'=>LAN_FORUM_0011, 'text'=>$text_1);
$tabs[2] = array('caption'=>LAN_FORUM_6010, 'text'=>$text_2);
$tabs[3] = array('caption'=>LAN_FORUM_0010, 'text'=>$text_3);
$tabs[4] = array('caption'=>LAN_FORUM_6011, 'text'=>$text_4);
$tabs[5] = array('caption'=>LAN_FORUM_6012, 'text'=>$text_5);
-
- $frm = e107::getForm();
+*/
+ foreach ($orderedtabs as $tabk => $tabv) {
+ $tabs[] = array('caption'=>$tabv, 'text'=>${'text_' . $tabk});
+ }
+
+/*
+ $tabs[] = array('caption'=>LAN_FORUM_6000, 'text'=>$text_0);
+ $tabs[] = array('caption'=>LAN_FORUM_0011, 'text'=>$text_1);
+ $tabs[] = array('caption'=>LAN_FORUM_6010, 'text'=>$text_2);
+ $tabs[] = array('caption'=>LAN_FORUM_0010, 'text'=>$text_3);
+ $tabs[] = array('caption'=>LAN_FORUM_6011, 'text'=>$text_4);
+ $tabs[] = array('caption'=>LAN_FORUM_6012, 'text'=>$text_5);
+*/
+// $frm = e107::getForm();
$breadarray = array(
array('text'=> e107::pref('forum','title', defset('LAN_PLUGIN_FORUM_NAME')), 'url' => e107::url('forum','index') ),
@@ -468,11 +659,29 @@ function init()
$text = $frm->breadcrumb($breadarray);
e107::breadcrumb($breadarray); // assign to {---BREADCRUMB---}
-
- $text = "". $text . e107::getForm()->tabs($tabs)."
";
+// $text = "". $text . e107::getForm()->tabs($tabs)."
";
+// var_dump ($template['tab_start']);
+// var_dump (isset($template['tab_start']));
+// $text = ($template['start']??""). $text . $frm->tabs($tabs, array("scroll" => true)).($template['end']??"
"); // Template is always defined, it is loaded from plugin first, so defaults are always there
+ $text .= $template['start']. $text . $frm->tabs($tabs, array("scroll" => true)).$template['end'];
}
else
{
+/*
+ $text ="
+ ".LAN_FORUM_6000."
". $text_0 .
+ "".LAN_FORUM_0011."
". $text_1 .
+ "".LAN_FORUM_6010."
". $text_2 .
+ "".LAN_FORUM_0010."
".$text_3 .
+ "".LAN_FORUM_6011."
". $text_4 .
+ "".LAN_FORUM_6012."
". $text_5;
+*/
+ $text = null;
+ foreach ($orderedtabs as $tabk => $tabv) {
+ $text .= "".$tabv."
".${'text_' . $tabk};
+ }
+
+/*
$text ="
".LAN_FORUM_6000."
". $text_0 .
"".LAN_FORUM_0011."
". $text_1 .
@@ -480,20 +689,67 @@ function init()
"".LAN_FORUM_0010."
".$text_3 .
"".LAN_FORUM_6011."
". $text_4 .
"".LAN_FORUM_6012."
". $text_5;
+*/
}
$text .= "".e107::getForm()->pagination(e107::url('forum','index'), LAN_BACK)."
";
- $ns -> tablerender(LAN_FORUM_6013, $text, 'forum-stats');
+// $ns -> tablerender(LAN_FORUM_6013, $text, 'forum-stats');
- }
+ $sc->setVars($fstatsSCvars);
+//var_dump ($text);
+//var_dump ($sc);
- function showBar($perc)
+ echo $ns->tablerender(LAN_FORUM_6013, $tp->parseTemplate($text, true, $sc), 'forum-stats');
+// }
+/*
+ function showBar($perc) /// PARA TIRAR
{
return e107::getForm()->progressBar('prog',$perc);
}
+*/
+ function FS_render_table($query, $template, &$sc)
+ {
+ $sc->count = 1;
+ is_array($query) ? null : $sql = e107::getDb();
+ $tp = e107::getParser();
+
+ $text = $tp->parseTemplate($template['start'], true);
+ is_array($query) ? null : $sql->gen($query);
+//$most_activeArray =
+ foreach((is_array($query) ? $query : $sql->db_getList()) as $SCvars['ma'])
+ {
+// if($fstatsSCvars['ma']['user_name'])
+// {
+ //$uinfo = "{$ma['user_name']}"; //TODO SEf Url .
+/*
+ $uparams = array('id' => $ma['user_id'], 'name' => $ma['user_name']);
+ $link = e107::getUrl()->create('user/profile/view', $uparams);
+ $uinfo = "".$ma['user_name']."";
+*/
+// $uinfo = " $fstatsSCvars['ma']['user_id'], 'name' => $fstatsSCvars['ma']['user_name']))."'>".$fstatsSCvars['ma']['user_name']."";
+// }
+// else
+// {
+// $tmp = explode(chr(1), $fstatsSCvars['ma']['thread_anon']);
+// $uinfo = $tp->toHTML($tmp[0]);
+// }
+
+// $fstatsSCvars['ma']['thread_sef'] = eHelper::title2sef($fstatsSCvars['ma']['thread_name'],'dashl');
+// $url = e107::url('forum','topic', $fstatsSCvars['ma']);
+
+ $sc->setVars($SCvars);
+ $text .= $tp->parseTemplate($template['item'], true, $sc);
+
+// $fstatsSCvars['count']++;
+ }
+ $text .= $tp->parseTemplate($template['end'], true, $sc);
+
+ return $text;
+ }
+/*
function topPosters() // from top.php - unused.
{
$pref = e107::pref('core');
@@ -513,7 +769,7 @@ function topPosters() // from top.php - unused.
if ($this->subaction == 'forum' || $this->subaction == 'all')
{
require_once (e_PLUGIN.'forum/forum_class.php');
- $forum = new e107forum();
+// $forum = new e107forum();
$qry = "
SELECT ue.*, u.* FROM `#user_extended` AS ue
@@ -577,10 +833,10 @@ function topPosters() // from top.php - unused.
}
}
+*/
-
-
+/*
function mostActiveTopics() // from top.php - unused.
{
//require_once (e_HANDLER.'userclass_class.php');
@@ -669,12 +925,13 @@ function mostActiveTopics() // from top.php - unused.
}
+*/
-}
+//}
-$frmStats = new forumStats;
-require_once(HEADERF);
-$frmStats->init();
+//$frmStats = new forumStats;
+//require_once(HEADERF);
+//$frmStats->init();
require_once(FOOTERF);
diff --git a/e107_plugins/forum/shortcodes/batch/stats_shortcodes.php b/e107_plugins/forum/shortcodes/batch/stats_shortcodes.php
new file mode 100644
index 0000000000..72e38980a8
--- /dev/null
+++ b/e107_plugins/forum/shortcodes/batch/stats_shortcodes.php
@@ -0,0 +1,154 @@
+forum_rules = function_exists('forum_rules') ? forum_rules('check') : '';
+ $this->gen = e107::getDate();
+ $this->sql = e107::getDb();
+ $this->count = 1;
+// $this->prefs = e107::pref('forum');
+/*
+$this->sql->select('forum_post', 'post_datestamp', 'post_datestamp > 0 ORDER BY post_datestamp ASC LIMIT 0,1', 'default');
+ $fp = $this->sql->fetch();
+ $fp = is_array($fp) ? $fp : array();
+// var_dump ($row);
+// var_dump ($fp);
+ $this->open_ds_in = (int) varset($fp['post_datestamp']);
+*/
+}
+
+ function sc_open_date()
+ {
+//var_dump ($this->var['open_ds']);
+//var_dump ($this->open_ds_in);
+//var_dump ("PLUGIN");
+ return $this->gen->convert_date($this->var['open_ds'], 'long');
+ }
+
+ function sc_open_since()
+ {
+ return $this->gen->computeLapse($this->var['open_ds']);
+ }
+
+ function sc_postsperday()
+ {
+ $open_days = floor((time()-$this->var['open_ds']) / 86400);
+ return ($open_days < 1 ? $this->sc_total_posts() : round($this->sc_total_posts() / $open_days));
+ }
+
+ function sc_total_views()
+ {
+ $total_views = 0;
+
+ // $sql = e107::getDb();
+ if ($this->sql->gen('SELECT sum(thread_views) AS total FROM `#forum_thread` '))
+ {
+ $row = $this->sql->fetch();
+ $total_views = $row['total'];
+ }
+ return $total_views;
+ }
+
+ function sc_total_posts(){
+ return e107::getDb()->count('forum_post');
+ }
+
+ function sc_total_topics(){
+ return e107::getDb()->count('forum_thread');
+ }
+
+ function sc_total_replies(){
+ return $this->sc_total_posts() - $this->sc_total_topics();
+ }
+
+ function sc_db_size(){
+ return $this->var['db_size'];
+ }
+
+ function sc_avg_row_len(){
+ return $this->var['avg_row_len'];
+ }
+
+ function sc_uinfo(){
+//var_dump ($this->var);
+ if($this->var['ma']['user_name'])
+ {
+ //$uinfo = "{$ma['user_name']}"; //TODO SEf Url .
+/*
+ $uparams = array('id' => $ma['user_id'], 'name' => $ma['user_name']);
+ $link = e107::getUrl()->create('user/profile/view', $uparams);
+ $uinfo = "".$ma['user_name']."";
+*/
+ return " $this->var['ma']['user_id'], 'name' => $this->var['ma']['user_name']))."'>".$this->var['ma']['user_name']."";
+ }
+ else
+ {
+ $tmp = explode(chr(1), $this->var['ma']['thread_anon']);
+ return e107::getParser()->toHTML($tmp[0]);
+ }
+ }
+
+ function sc_url(){
+ $this->var['ma']['thread_sef'] = eHelper::title2sef($this->var['ma']['thread_name'],'dashl');
+ return e107::url('forum','topic', $this->var['ma']);
+ }
+
+ function sc_thread_name(){
+ return $this->var['ma']['thread_name'];
+ }
+
+ function sc_thread_total_replies(){
+ return $this->var['ma']['thread_total_replies'];
+ }
+
+ function sc_thread_views(){
+ return $this->var['ma']['thread_views'];
+ }
+
+ function sc_thread_datestamp(){
+ return $this->gen->convert_date($this->var['ma']['thread_datestamp'], "forum");
+ }
+
+ function sc_count(){
+ return $this->count++;
+ }
+
+ function sc_user_name(){
+ return $this->var['ma']['user_name'];
+ }
+
+ function sc_user_url(){
+ return e107::url('user/profile/view', $this->var['ma']);
+ }
+
+ function sc_user_forums(){
+ return $this->var['ma']['user_forums'];
+ }
+
+ function sc_user_percentage(){
+ return $this->var['ma']['percentage'];
+ }
+
+ function sc_percentage_bar(){
+ return e107::getForm()->progressBar('prog',$this->var['ma']['percentage']);
+ }
+}
\ No newline at end of file
diff --git a/e107_plugins/forum/templates/forum_stats_template.php b/e107_plugins/forum/templates/forum_stats_template.php
new file mode 100644
index 0000000000..e4e557ff24
--- /dev/null
+++ b/e107_plugins/forum/templates/forum_stats_template.php
@@ -0,0 +1,188 @@
+\n\n
\n\n{LAN=FORUM_0073} | \n
\n";
+*/
+// LEGACY definition with LAN Shortcodes ({TRACKTITLE}).....
+/*
+$FORUM_TRACK_START = "\n
\n
\n\n{TRACKTITLE} | \n
\n";
+
+ if (!isset($FORUM_TRACK_MAIN))
+ {
+ $FORUM_TRACK_MAIN = "
+
+
+
+
";
+ }
+}
+
+if (!isset($FORUM_TRACK_END))
+{
+ $FORUM_TRACK_END = "
\n
\n
";
+}
+*/
+
+
+// New in v2.x - requires a bootstrap theme be loaded.
+$FORUM_STATS_TEMPLATE['start'] = "";
+$FORUM_STATS_TEMPLATE['item'] = "";
+$FORUM_STATS_TEMPLATE['end'] = "
";
+
+$FORUM_STATS_TEMPLATE['text_0'] = "
+
+ ".LAN_FORUM_6001.": | {OPEN_DATE} |
+ ".LAN_FORUM_6002.": | {OPEN_SINCE} |
+ ".LAN_FORUM_6003.": | {TOTAL_POSTS} |
+ ".LAN_FORUM_1007.": | {TOTAL_TOPICS} |
+ ".LAN_FORUM_6004.": | {TOTAL_REPLIES} |
+ ".LAN_FORUM_6005.": | {TOTAL_VIEWS} |
+ ".LAN_FORUM_6014.": | {POSTSPERDAY} |
+ ".LAN_FORUM_6006.": | {DB_SIZE} |
+ ".LAN_FORUM_6007.": | {AVG_ROW_LEN} |
+
";
+
+$FORUM_STATS_TEMPLATE['text_1']['start'] = "
+
+
+
+ ".LAN_FORUM_6008." |
+ ".LAN_FORUM_1003." |
+ ".LAN_FORUM_0003." |
+ ".LAN_FORUM_6009." |
+ ".LAN_DATE." |
+
+
+ ";
+
+$FORUM_STATS_TEMPLATE['text_1']['item'] = "
+
+
+
+
+
+
+
+";
+
+$FORUM_STATS_TEMPLATE['text_1']['end'] = "
";
+
+$FORUM_STATS_TEMPLATE['text_2']['start'] = "
+
+
+
+ ".LAN_FORUM_6008." |
+ ".LAN_FORUM_1003." |
+ ".LAN_FORUM_1005." |
+ ".LAN_FORUM_6009." |
+ ".LAN_DATE." |
+
+
+ ";
+
+$FORUM_STATS_TEMPLATE['text_2']['item'] = "
+
+
+
+
+
+
+
+";
+
+$FORUM_STATS_TEMPLATE['text_2']['end'] = "
";
+
+$FORUM_STATS_TEMPLATE['text_3']['start'] = "
+
+
+
+ ".LAN_FORUM_6008." |
+ ".LAN_NAME." |
+ ".LAN_FORUM_2032." |
+ % |
+ |
+
+
+
+ ";
+
+$FORUM_STATS_TEMPLATE['text_3']['item'] = "
+
+
+
+
+
+
+
+";
+
+$FORUM_STATS_TEMPLATE['text_3']['end'] = "
+
";
+
+
+$FORUM_STATS_TEMPLATE['text_4']['start'] = "
+
+
+
+ ".LAN_FORUM_6008." |
+ ".LAN_NAME." |
+ ".LAN_FORUM_2032." |
+ % |
+ |
+
+
+";
+
+$FORUM_STATS_TEMPLATE['text_4']['item'] = "
+
+
+
+
+
+
+
+";
+
+$FORUM_STATS_TEMPLATE['text_4']['end'] = "
";
+
+
+$FORUM_STATS_TEMPLATE['text_5']['start'] = "
+
+
+
+ ".LAN_FORUM_6008." |
+ ".LAN_NAME." |
+ ".LAN_FORUM_2032." |
+ % |
+ |
+
+
+";
+
+$FORUM_STATS_TEMPLATE['text_5']['item'] = "
+
+
+
+
+
+
+
+";
+
+$FORUM_STATS_TEMPLATE['text_5']['end'] = "
";
\ No newline at end of file