Extension:W4G Rating Bar

W4G Rating Bar provides a page rating system. The rating bar can be either manually included on pages, using a parser function, or automatically added at the bottom of all pages, by setting  to true. Various top-lists can then be generated. W4G Rating Bar is a total rewrite of Extension:Rating Bar, which it replaces.

Functionality overview
For your users' privacy, the $wgW4GRB_Settings['show-voter-names'] setting (boolean) can be used to enable or disable the functions which link a user to their ratings.
 * displays a rating bar for [page name], scaled from 0 to 100%. (NB: to use it for the current page, you can omit [page name] but not the colon, i.e.: but not  )
 * displays the rating of [page name].
 *  can display many kinds of list:
 * Top rated pages (globally, for a category, during the last X days, among pages with at least Y votes)
 * Top voters (by amount of votes, within a category, during the last X days)
 * Latest votes for: a page, a category, or globally
 * Latest votes by a specific user

Features removed compared to the previous version

 * Anonymous voting added back in version 2.1.0.
 * Star-style bar.
 * Maximum rating configuration (always 100 now).

Upgrading from 2.0.1 to 2.1.0
To support anonymous voting, the database was slightly edited: you need to run the following query to update it: ALTER TABLE `w4grb_votes` DROP PRIMARY KEY , ADD PRIMARY KEY ( `uid`,  `pid` ,  `ip` );
 * NB: don't forget to add your table prefix if applicable.

From scratch

 * 1. Create a new folder in your  folder.
 * 2. Download the source code archive and extract it in this new folder.
 * 3. Run the following SQL query to create additional tables in your wiki's database:

CREATE TABLE IF NOT EXISTS `w4grb_votes` ( `uid` int(11) unsigned NOT NULL,  `pid` int(11) unsigned NOT NULL,  `vote` tinyint(4) unsigned NOT NULL,  `ip` varbinary(39) NOT NULL,  `time` int(11) unsigned NOT NULL,  PRIMARY KEY  (`uid`,`pid`,`ip`) ) ENGINE=InnoDB DEFAULT CHARSET=binary;

CREATE TABLE IF NOT EXISTS `w4grb_avg` ( `pid` int(10) unsigned NOT NULL,  `avg` float unsigned NOT NULL,  `n` int(10) unsigned NOT NULL,  PRIMARY KEY  (`pid`) ) ENGINE=InnoDB DEFAULT CHARSET=binary;
 * NB: don't forget to add your table prefix if applicable.

This is a PostgreSQL version from Thomas Bayen (It works for me):

drop table if exists w4grb_votes; drop table if exists w4grb_avg;

CREATE TABLE w4grb_votes ( uid numeric(11) NOT NULL,  pid numeric(11) NOT NULL,  vote numeric(4) NOT NULL,  ip bytea NOT NULL,  time numeric(11) NOT NULL,  PRIMARY KEY  (uid,pid,ip) ); ALTER TABLE w4grb_votes OWNER TO wikiuser;

CREATE TABLE w4grb_avg ( pid numeric(10) NOT NULL,  avg real NOT NULL,  n numeric(10) NOT NULL,  PRIMARY KEY  (pid) ); ALTER TABLE w4grb_avg OWNER TO wikiuser;


 * 4. Add the following code at the end of LocalSettings.php:
 * (replace, of course, with the proper path!)
 * (replace, of course, with the proper path!)
 * (replace, of course, with the proper path!)

Upgrading from Rating Bar v1.1
If you're currently using the old Rating Bar 1.1 extension, you'll need to convert the database to the new scheme. A migration tool is available starting with version 2.0-b2. This migration tool is not (and won't be) able to merge old data with new data. Also, since this version doesn't support anonymous voting, the tool won't import anonymous votes Starting with version 2.1.0 the tool will import anonymous votes (but it needs to be configured to do so, see step 2 below). To upgrade from Rating Bar v1.1:
 * 1. Follow the  instructions above.
 * 2. Go to the extension's folder and edit the parameters on lines 25-32 of.
 * 3. Add  in LocalSettings.php just after
 * 4. Go to your wiki's special page Special:W4GRBMigrate. The migration will run automatically.
 * 5. Remove  from LocalSettings.php and (optionally and after checking everything worked fine) delete the old ratingbar table.
 * 6. ... and don't forget to update the pages which use the extension: the new extension uses different tags.

Configuration
You can edit the following settings in LocalSettings.php (add them after the line which includes the extension): Example: $wgW4GRB_Settings['ajax-fresh-data']=true; $wgW4GRB_Settings['allow-unoptimized-queries']=true; $wgW4GRB_Settings['auto-include']=false; $wgW4GRB_Settings['fix-spaces']=true; $wgW4GRB_Settings['max-bars-per-page']=1; $wgW4GRB_Settings['max-items-per-list']=200; $wgW4GRB_Settings['default-items-per-list']=30; $wgW4GRB_Settings['max-lists-per-page']=5; $wgW4GRB_Settings['show-voter-names']=false; Finally, you can also control who can vote with the  right. The default values are: $wgGroupPermissions['*']['w4g_rb-canvote'] = false; $wgGroupPermissions['user']['w4g_rb-canvote'] = true; $wgGroupPermissions['autoconfirmed']['w4g_rb-canvote'] = true; $wgGroupPermissions['bot']['w4g_rb-canvote'] = false; $wgGroupPermissions['sysop']['w4g_rb-canvote'] = true; $wgGroupPermissions['bureaucrat']['w4g_rb-canvote'] = true;

Usage
A list of functions and parameters as well as syntax examples are available here: http://www.wiki4games.com/Wiki4Games:W4G_Rating_Bar/syntax.

Who's using it?
(Please add your URL to the bottom of the list.)
 * CleverTrail.com
 * Wiki4Games.com, the video game wiki
 * Nursing Home Reviews
 * Leibowitz's Candle
 * CodeMinima: The Minimal Code Site
 * 1-pp.ru - Russian educational wiki
 * CMS Wiki of the Max Planck Society
 * Russian creepypasta wiki
 * Cooking Software Australia
 * Cookpedia.co.uk (recipe pages only)
 * Polish branch of the SCP Foundation