Stats
StatsFooter is an action I cobbled together from existing actions, (highscores.php, ownedpages.php, countusers.php) it is intended to be used in the footer, as seen at DescentiaPedia. I have not tested this to see if it can be used in a page. Nor have I tested this in any version of wikka other than 1.1.6.4. Here is the code:statsft.php (line 1)
- <?php
- /**
- * Displays a list of top contributors, ranked by number of pages owned, edits or comments.
- * Displays number/ percent of pages owned by current user, total pages of wiki.
- * Displays number of registered users.
- *
- * @package Actions
- * @version $Id: highscores.php 820 2007-11-23 09:21:08Z DotMG $
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
- * @filesource
- *
- * @author Chris Tessmer ... highscores.php, ownedpages.php (original code)
- * @author {@link http://wikkawiki.org/DarTar Dario Taraborelli} (adding action parameters, styling, accessibility)
- * @author {@link http://wikkawiki.org/WillyPs W. P. Sullivan} Hacked together code from several actions, removed unneeded code, and format for use in the footer.
- * ToDo: Change count user to reflect the number of actual users, instead of the total number of users in the database.
- */
- //define:
- //i18n USE WIKI FORMATTING... %s will be replaced by the appropriate numerical value.
- // count the number of users
- $userdata = $this->LoadSingle("SELECT count(*) as num FROM ".$this->config["table_prefix"]."users ");
- $users = $userdata["num"];
- // stats about user... logged in?
- ($this->GetUser() && $username = $this->GetUserName()))
- {
- $str = 'SELECT COUNT(*) FROM '.$this->config["table_prefix"].'pages WHERE `owner` ';
- $str .= "= '" . $this->GetUserName() . "' AND `latest` = 'Y'";
- $countQuery = $this->Query( $str );
- // get the total # of pages
- $str = 'SELECT COUNT(*) FROM '.$this->config["table_prefix"].'pages WHERE `latest` = \'Y\' ';
- $totalQuery = $this->Query( $str );
- //make a string to print... for logged in users
- }else{
- //output for not logged in user
- }
- $limit = STATS_TOP_QTY;
- // query for top contributers
- $query = 'SELECT COUNT(*) AS cnt, `name` FROM '.$this->GetConfigValue('table_prefix').'users, '.$this->GetConfigValue('table_prefix').'pages WHERE `name` = `owner` AND `latest` = "Y" GROUP BY name ORDER BY cnt DESC LIMIT '.$limit;
- $total = $this->getCount('pages', "`latest` = 'Y'");
- //fetch data
- $rank_query = $this->Query($query);
- $i = 0;
- $str = '';
- {
- $i++;
- if ($i < $limit)
- {$str .= ' | '."\n";
- }else{
- $str .= '<br />';
- }
- }
- // print it out...
- echo '<span class="clip">'. $str .'</span>';
- echo '<br /><span class="clip">'. ($this->Format($output)).'</span>';
- ?>
See also:
ActionsInFooter
Categories:
CategoryStyle