Ajax Rating script with Toplist

Inleiding

This article contains the update of the Ajax Rating script V2 with first version of Toplist. Please understand that this is the first demo..

Some weird thing is causing the script to work differently in Mediawiki 1.11 and 1.93 so choose one of the two codes for $title in row 51.

You can find the toplist in the top of your special page under 'A top list'

Within LeerWiki.nl you can find it at http://www.leerwiki.nl/Speciaal:RatingOverview

Where must the script be put ? Thank you very much

Stappen

<?php
require('Ratings/_drawrating.php'); 
if (&nbsp;! defined( 'MEDIAWIKI' ) )
	die();

$wgExtensionCredits['parserhook'][] = array(
'name' => 'AJAX RATING BAR V2 14-07-2007 Based on Masugadesign',
'author' => 'Boudewijn Vahrmeijer',
'url' => 'http://www.leerwiki.nl',
'version' => '1.11,1.10.1/1.9.3/1.9.2/1.8.2',
'description' => 'Ajax Rating Bar for MediaWiki',
);

$pathToRating='/extensions/Ratings/';

    
$wgHooks['BeforePageDisplay'][] = array("wfRateArticleForm");
function wfRateArticleForm(&$out) {
	global $wgArticle,$pathToRating;
	if ($wgArticle==null) return $out;	
	if ($wgArticle->getTitle()->mNamespace&nbsp;!= 0) return  $out;

	$out->mBodytext.='<script type="text/javascript" language="javascript" src="'.$pathToRating.'js/behavior.js"></script>';
	$out->mBodytext.='<script type="text/javascript" language="javascript" src="'.$pathToRating.'js/rating.js"></script>';
	$out->mBodytext.='<link rel="stylesheet" type="text/css" href="'.$pathToRating.'css/rating.css" />';
	$out->mBodytext.=rating_bar($wgArticle->getID(),5);

	return $out;
}

$wgExtensionFunctions[] = 'setupSpecialToprating';
function setupSpecialToprating() {
    global $IP, $wgMessageCache;
    require_once($IP.'/includes/SpecialPage.php');
    SpecialPage::addPage(new SpecialPage('RatingOverview', <i>, true, 'spTopList', false));</i>

    # Messages used in this extension
$wgMessageCache->addMessage('ratingoverview', 'A Top Rating Overview');
}

function spTopList() {
    global $wgOut, $wgParser, $wgUser;
require('Ratings/_config-rating.php');
$result=mysql_query("SELECT * FROM $rating_dbname.$rating_tableName ORDER BY total_value DESC")or die(" Error: ".mysql_error());

$i='<table border="1" style="border:1px;border-color:black;">
<tr><td>Position</td><td>Title</td><td>Value</td><td>Total Votes</td></tr>';
<p>while ($row = mysql_fetch_assoc($result)) {
</p>
<ol><li><ol><li><ol><li><ol><li><ol><li>FOR VERSIONS 1.11 #################:
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
<p>    $title=Title::newFromID($row["id"]);
</p>
<ol><li><ol><li><ol><li><ol><li><ol><li>FOR LOWER VERSIONS AS 1.93
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
<p>//	 $atitle=Title::newFromID($row["id"]);
//	 if(is_object($atitle)){
//	    $title=$atitle->getIndexTitle();
//		}
</p>
<ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li><ol><li>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
</li></ol>
<p>    if(!$title==<i>){</i>
    $a=$a+1;
</p>
    $i.= '<tr><td>'.$a.'</td>';
    $i.= '<td><a href="/article/article/view/?slug=%27.%24title.%27">'.$title.'</a> </td>';
    $i.= '<td>'.$row["total_value"].'</td>';
    $i.= '<td>'.$row["total_votes"].'</td></tr>';
<p>    }
}
</p>
$i.='</table>';
<p>$wgOut->addWikiText($i);
</p><p>}
?>
</p>

Risico's en Tips

To do:

  • Parser integration
  • Include a ranking order
  • Exlude pages

Please supply your suggestions in the discussion page!