MediawikiExtensions/Top Categories

A new extension to display the "Top Categories" automatically ,ordered by number of pages in them.

10

extension source
setHook( "topcat", "renderTopCat" ); }

function renderTopCat( $input ) {

$input = mysql_escape_string($input);

if (is_int($input)){ $limit = $input; } else { $limit = 5; }
 * 1) check if input is integer else set to 5

$hd = mysql_connect("localhost", "wikiuser", "password") or die ("Unable to connect"); mysql_select_db ("wikidb", $hd) or die ("Unable to select database");

$res= mysql_query("SELECT cl_to, COUNT(*) AS total FROM categorylinks GROUP BY cl_to ORDER BY total DESC LIMIT $input", $hd) or die ("Unable to run query");

$output=" ";

return $output; }