User:Robchurch/TopContributors

 */ if( defined( 'MEDIAWIKI' ) ) {

$wgExtensionFunctions[] = 'efTopContributorsSetup'; $wgExtensionCredits['parserhook'][] = array(		'name' => 'Top Contributors',		'author' => 'Rob Church',		'description' => 'Lists the ten most active contributors to a wiki',	); /**	 * Extension setup function */	function efTopContributorsSetup { global $wgParser; $wgParser->setHook( 'topcontributors', 'efTopContributors' ); }	/**	 * Hook callback *	 * @param string $input * @param array $args * @param Parser $parser * @return string */	function efTopContributors( $input, $args, $parser ) { $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select(			'revision',			array( 'rev_user', 'rev_user_text', 'COUNT(*) AS `count`' ),			array,			__METHOD__,			array( 'GROUP BY' => 'rev_user_text', 'ORDER BY' => 'count DESC', 'LIMIT' => '10', )		);		if( $res && $dbr->numRows( $res ) > 0 ) { $out = ' '; $skin = $parser->getOptions->getSkin; while( $row = $dbr->fetchObject( $res ) ) { $out .= ''. $skin->userLink( $row->rev_user, $row->rev_user_text ) . ' [' . $row->count. ']'; }			$dbr->freeResult( $res ); return $out. ' ';		} else { return ''; }	}

} else { echo( "This file is an extension to the MediaWiki software, and cannot be used standalone.\n" ); exit( 1 ); }

?>