I've put together an extension for rating articles
if anyone is
interested. It's just a first version and hasn't been tested much, but
the details can be found here:
[..snip..]
I'd appreciate feedback if anyone has any.
Some technical feedback:
1) I think you may need to max the rating out at 5.
E.g. I entered this malicious input to try and ballot-stuff the ratings:
http://wiki16.wikidiy.com/Special:RateArticle?page_id=10743&rating=99999
And then the rating of the loan article comes out as 5 stars. I would expect it to come
out at 4.1 (or something like that), based
on my prior ratings, if it was being capped at 5.
2) You might not want to show the "rate this article" bit when there is no
article (e.g. non-existent
http://wiki16.wikidiy.com/FAKE-FAKE-FAKE page shows the ratings). Maybe something along
these lines in wfRateArticleForm() function
in RateArticle.php :
$page_id = $wgArticle->getID();
+ if (!$page_id) return;
3) Trivial stuff in wfSpecialRateArticle() function :
$rat_page = $wgRequest->getVal("page_id");
$rat_user = $wgUser->getID();
$rat_user_text = $wgUser->getName();
$rat_rating = $wgRequest->getVal('rating');
$dbw =& wfGetDB( DB_MASTER );
$dbw->insert( 'rating',
array( 'rat_page' => $rat_page,
'rat_user' => $rat_user,
'rat_user_text' => $rat_user_text,
'rat_rating' => $rat_rating),
$fname);
Maybe getInt() instead of getVal() for the "page_id" and 'rating'
fields? Maybe verify that the page_id corresponds to a valid
existing page?
4) Maybe a max of one rating per user per page? (Perhaps later votes overwrite/overrule
earlier votes? Or just discard later votes?)
5) Fatal error on
http://wiki16.wikidiy.com/Special:ListRatings (probably due to some of
the bad input I introduced in doing the
above testing - Sorry). The special page should be ideally be robust against bad input
though, e.g.:
$t = Title::newFromID($row->rat_page);
+ if (is_null($t)) continue;
$wgOut->addHTML("<li>" . $sk->makeLinkObj($t,
$t->getFullText() ) . " ({$row->C}, {$row->R})</li>");
(or something along those lines).
All the best,
Nick.