×
Create a new article
Write your page title here:
We currently have 3,187 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,187Articles

    MediawikiExtensions/Top Pages

    A new extension to display the most popular wiki pages, ordered by number of hits.

    example[edit]

    <toppages>10</toppages>


    result[edit]

    <toppages>10</toppages>

    extension source[edit]

    <?php
    # Top Pages Mediawiki extension
    # display a list of the most popular pages on the wiki
    # <toppages>23</toppages>
    # where "23" would be the number of results to display
    # by mutante 31.10.2005
    
    $wgExtensionFunctions[] = "wfTopPagesExtension";
    
    function wfTopPagesExtension() {
    global $wgParser;
    $wgParser->setHook( "toppages", "renderTopPages" );
    }
    
    function renderTopPages( $input ) {
    
    $input = mysql_escape_string($input);
    
    # check if input is integer else set to 5
    if (is_int($input)){
    $limit = $input;
    } else {
    $limit = 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 cur_title,cur_counter from cur order by cur_counter DESC limit $input", $hd) or die ("Unable to run query");
    
    $output="<table border=\"1\"><tr><th colspan=\"2\" align=\"center\">Top $input wiki pages</th></tr><tr><th align=\"right\">page</th><th align=\"right\"># of hits</th></tr>";
    
    while ($row = mysql_fetch_assoc($res))
    {
    $page = $row["cur_title"];
    $hits = $row["cur_counter"];
    $output.="<tr><td align=\"right\"><a href=\"http://s23.org/wiki/$page\">$page</a></td><td align=\"right\">$hits</td></tr>";
    }
    $output.="</table>";
    
    return $output;
    }
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.