本文整理汇总了PHP中NewsStory::GetStats方法的典型用法代码示例。如果您正苦于以下问题:PHP NewsStory::GetStats方法的具体用法?PHP NewsStory::GetStats怎么用?PHP NewsStory::GetStats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NewsStory
的用法示例。
在下文中一共展示了NewsStory::GetStats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Stats
/**
* Statistics about stories, topics and authors
*
* You can reach the statistics from the admin part of the news module by clicking on the "Statistics" tabs
* The number of visible elements in each table is equal to the module's option called "storycountadmin"
* There are 3 kind of different statistics :
* - Topics statistics
* For each topic you can see its number of articles, the number of time each topics was viewed, the number
* of attached files, the number of expired articles and the number of unique authors.
* - Articles statistics
* This part is decomposed in 3 tables :
* a) Most readed articles
* This table resumes, for all the news in your database, the most readed articles.
* The table contains, for each news, its topic, its title, the author and the number of views.
* b) Less readed articles
* That's the opposite action of the previous table and its content is the same
* c) Best rated articles
* You will find here the best rated articles, the content is the same that the previous tables, the last column is just changing and contains the article's rating
* - Authors statistics
* This part is also decomposed in 3 tables
* a) Most readed authors
* To create this table, the program compute the total number of reads per author and displays the most readed author and the number of views
* b) Best rated authors
* To created this table's content, the program compute the rating's average of each author and create a table
* c) Biggest contributors
* The goal of this table is to know who is creating the biggest number of articles.
*/
function Stats()
{
global $xoopsModule, $xoopsConfig, $xoopsModuleConfig;
xoops_cp_header();
$myts =& MyTextSanitizer::getInstance();
if (file_exists(XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php')) {
include_once XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php';
} else {
include_once XOOPS_ROOT_PATH . '/modules/news/language/english/main.php';
}
adminmenu(6);
$news = new NewsStory();
$stats = array();
$stats = $news->GetStats($xoopsModuleConfig['storycountadmin']);
$totals = array(0, 0, 0, 0, 0);
printf("<h1>%s</h1>\n", _AM_NEWS_STATS);
// First part of the stats, everything about topics
$storiespertopic = $stats['storiespertopic'];
$readspertopic = $stats['readspertopic'];
$filespertopic = $stats['filespertopic'];
$expiredpertopic = $stats['expiredpertopic'];
$authorspertopic = $stats['authorspertopic'];
$class = '';
echo "<div style='text-align: center;'><b>" . _AM_NEWS_STATS0 . "</b><br />\n";
echo "<table border='1' width='100%'><tr class='bg3'><td align='center'>" . _AM_TOPIC . "</td><td align='center'>" . _NW_ARTICLES . "</td><td>" . _NW_VIEWS . "</td><td>" . _AM_UPLOAD_ATTACHFILE . "</td><td>" . _AM_EXPARTS . "</td><td>" . _AM_NEWS_STATS1 . "</td></tr>";
foreach ($storiespertopic as $topicid => $data) {
$url = XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/index.php?storytopic=" . $topicid;
$views = 0;
if (array_key_exists($topicid, $readspertopic)) {
$views = $readspertopic[$topicid];
}
$attachedfiles = 0;
if (array_key_exists($topicid, $filespertopic)) {
$attachedfiles = $filespertopic[$topicid];
}
$expired = 0;
if (array_key_exists($topicid, $expiredpertopic)) {
$expired = $expiredpertopic[$topicid];
}
$authors = 0;
if (array_key_exists($topicid, $authorspertopic)) {
$authors = $authorspertopic[$topicid];
}
$articles = $data['cpt'];
$totals[0] += $articles;
$totals[1] += $views;
$totals[2] += $attachedfiles;
$totals[3] += $expired;
$class = $class == 'even' ? 'odd' : 'even';
printf("<tr class='" . $class . "'><td align='left'><a href='%s' target ='_blank'>%s</a></td><td align='right'>%u</td><td align='right'>%u</td><td align='right'>%u</td><td align='right'>%u</td><td align='right'>%u</td></tr>\n", $url, $myts->displayTarea($data['topic_title']), $articles, $views, $attachedfiles, $expired, $authors);
}
$class = $class == 'even' ? 'odd' : 'even';
printf("<tr class='" . $class . "'><td align='center'><b>%s</b></td><td align='right'><b>%u</b></td><td align='right'><b>%u</b></td><td align='right'><b>%u</b></td><td align='right'><b>%u</b></td><td> </td>\n", _AM_NEWS_STATS2, $totals[0], $totals[1], $totals[2], $totals[3]);
echo "</table></div><br /><br /><br />";
// Second part of the stats, everything about stories
// a) Most readed articles
$mostreadednews = $stats['mostreadednews'];
echo "<div style='text-align: center;'><b>" . _AM_NEWS_STATS3 . "</b><br /><br />" . _AM_NEWS_STATS4 . "<br />\n";
echo "<table border='1' width='100%'><tr class='bg3'><td align='center'>" . _AM_TOPIC . "</td><td align='center'>" . _AM_TITLE . "</td><td>" . _AM_POSTER . "</td><td>" . _NW_VIEWS . "</td></tr>\n";
foreach ($mostreadednews as $storyid => $data) {
$url1 = XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/index.php?storytopic=" . $data['topicid'];
$url2 = XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/article.php?storyid=" . $storyid;
$url3 = XOOPS_URL . '/userinfo.php?uid=' . $data['uid'];
$class = $class == 'even' ? 'odd' : 'even';
printf("<tr class='" . $class . "'><td align='left'><a href='%s' target ='_blank'>%s</a></td><td align='left'><a href='%s' target='_blank'>%s</a></td><td><a href='%s' target='_blank'>%s</a></td><td align='right'>%u</td></tr>\n", $url1, $myts->displayTarea($data['topic_title']), $url2, $myts->displayTarea($data['title']), $url3, $myts->htmlSpecialChars($news->uname($data['uid'])), $data['counter']);
}
echo "</table>";
// b) Less readed articles
$lessreadednews = $stats['lessreadednews'];
echo '<br /><br />' . _AM_NEWS_STATS5;
echo "<table border='1' width='100%'><tr class='bg3'><td align='center'>" . _AM_TOPIC . "</td><td align='center'>" . _AM_TITLE . "</td><td>" . _AM_POSTER . "</td><td>" . _NW_VIEWS . "</td></tr>\n";
foreach ($lessreadednews as $storyid => $data) {
$url1 = XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/index.php?storytopic=" . $data['topicid'];
//.........这里部分代码省略.........