This documentation is a bit outdated, the functionality is now provided with a slightly different implementation as Special:UsersEditCount . |
This is an explanation on how to implement the Special:ActiveUsers page which lists users by their total number of edits.
InstallationEdit
- Copy the source in the section below into a new SpecialActiveUsers.php file in your Wiki includes\specials directory.
- In the includes directory, modify QueryPage.php with the line at the top of the $wgQueryPages array:
-
array( 'ActiveUsersPage', 'ActiveUsers'),
-
- In the includes directory, modify SpecialPage.php and add a line in the $wgSpecialPages array:
-
'ActiveUsers' => new SpecialPage( 'ActiveUsers'),
- Or, if the array has not yet been created, add the following lines immediately beneath the
global $wgSpecialPages;
line: -
$wgSpecialPages = array(
'ActiveUsers' => new SpecialPage( 'ActiveUsers')
);
-
- Modify MessagesEn.php (for standard English) in the languages\messages directory (depending on Wiki version) and add the following line anywhere below the
$messages = array(
line, but before the);
at the end of the file:-
'activeusers' => 'Active Users',
-
- Note there are other ways to add a special page which are better and don't require as many modifications to PHP files (it makes upgrading harder the way I've done it).
SourceEdit
When copying make sure there are no extra blank lines at the end of the file (results in RSS feed errors), and do not copy the <pre></pre>
tags if using the edit window.
<?php /** * * @package MediaWiki * @subpackage SpecialPage */ /** * */ require_once("QueryPage.php"); /** * SpecialActiveUsers extends QueryPage. It is used to return the users * with the most edits in the database. * @package MediaWiki * @subpackage SpecialPage */ class ActiveUsersPage extends QueryPage { function getName() { return "ActiveUsers"; } /** * */ function isExpensive() { return true; } function isSyndicated() { return false; } function getSQL() { $dbr =& wfGetDB( DB_SLAVE ); $page = $dbr->tableName( 'page' ); $name = $dbr->addQuotes( $this->getName() ); return "SELECT rev_user, rev_user_text as type, Count(rev_user) as value FROM revision WHERE rev_user > 0 GROUP BY rev_user"; } function sortDescending() { return true; } function formatResult( $skin, $result ) { global $wgLang, $wgContLang; $user = null; $user =& User::newFromName($result->type); if (is_null($user)) { return "{$result->type} has {$result->value} edits."; } else { $title = $user->getUserPage(); # $title = Title::makeTitle( $result->namespace, $result->title ); $link = $skin->makeLinkObj( $title, $wgContLang->convert( $title->getPrefixedText() ) ); return "<b>{$link}</b> has {$result->value} edits."; } } } /** * constructor */ function wfSpecialActiveUsers() { list( $limit, $offset ) = wfCheckLimits(); $spp = new ActiveUsersPage(); return $spp->doQuery( $offset, $limit ); } ?>