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 column, 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.
 * 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;
 * $wgW4GRB_Settings['ajax-fresh-data']: boolean, whether or not you want to use AJAX to display an uncached rating to visitor. Set to false if you need to restrict database queries (only affects slave databases). Default: true.
 * $wgW4GRB_Settings['allow-unoptimized-queries']: boolean, whether or not to allow queries which need some extra calculations in MySQL. They're not that terrible, this thing is just here as an emergency switch in case someone keeps running demanding queries on a very large database. Default: true.
 * $wgW4GRB_Settings['anonymous-voting-enabled']: boolean, whether or not anonymous (=not logged-in user) voting is enabled. Default: false.
 * $wgW4GRB_Settings['auto-include']: boolean, whether or not to automatically include the rating bar at the bottom of every page. Default: false.
 * $wgW4GRB_Settings['default-items-per-list']: default amount of items that will be displayed in a top list (NB: this CAN be higher than max-items-per-list by design). Default: not fixed, may change.
 * $wgW4GRB_Settings['fix-spaces']: boolean, whether or not you want to enable auto replacing of spaces with underscore (and vice versa) when needed in page/category name input, so that spaces and underscores can be used indifferently (otherwise the user must sometimes write underscores, and sometimes not - a bit annoying indeed). Default: true.
 * $wgW4GRB_Settings['max-bars-per-page']: maximum amount of bars that can be included within one page (this doesn't count the auto-included bar). Default: not fixed, may change.
 * $wgW4GRB_Settings['max-items-per-list']: maximum amount of items that can be displayed in a top list. Default: not fixed, may change.
 * $wgW4GRB_Settings['max-lists-per-page']: maximum amount of lists that can be displayed in a single page. Default: not fixed, may change.
 * $wgW4GRB_Settings['multivote-cooldown']: time, in seconds, to consider that the same IP = the same person to prevent multivote. Default: 36000*24*7 (1 week).
 * $wgW4GRB_Settings['show-mismatching-bar']: boolean, whether or not to display the name of the page being voted on if it's not the same as the page on which the bar is displayed. Default: true.
 * $wgW4GRB_Settings['show-voter-names']: boolean, whether or not it's possible to publicly link user names to their ratings. Default: false.

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
 * La Frikipedia
 * Leibowitz's Candle
 * CodeMinima: The Minimal Code Site
 * lawiki: the law student wiki
 * 1-pp.ru - Russian educational wiki