Wiki4Games talk:RatingBar

From Wiki4Games
Jump to: navigation, search
Please use the appropriate forum instead of this talk page to discuss bugs and issues about this extension. This will make problems easier to follow individually (and will accessorily make our database grow much slower). Thanks


Contents

die("MySQL query failed")

David, I've noticed you changed die(" Error: ".mysql_error()) into die("MySQL query failed"). Why? The first one outputs a more precise error, but there might be other differences I'm not aware of. Franck Dernoncourt 11:02, 20 February 2009 (CET)

You don't want to help hackers, do you? ;) mysql_error() is good for debugging but not for prod. So you can put them back for debug (I changed them now so we don't forget later) if you think it's useful (which I doubt since the probability of having such trivial queries fail is pretty low IMO), but in the final version there should be an unhelpful error message (same kind of story as with PHP's display_error=off). Patheticcockroach 11:15, 20 February 2009 (CET)
ok, sounds rational (I thought it was about standard specifications) Thanks ;-) Franck Dernoncourt 11:39, 20 February 2009 (CET)
I created a new section intitled "To be done before release" so as we don't forget that kind of changes before releasing the extension Franck Dernoncourt 12:40, 20 February 2009 (CET)

Star Rating

I'm the owner of a Wiki and think your extension is absolutely awesome and does exactly what I need. The only "problem" I have with it is that I need the extension to display 1-5 or 1-10 stars (I tried JSKitRating but it loads the .js files externally and is extremely slow). My question: I do realise that you have better things to do other than rewriting your extension to suit my needs, therefore I would sponsor the extension with 150 $ (can't afford more) if you take time to change the extension. In addition I'm quite sure that there is sufficient demand for a good "star rating" extension. Thanks in advance. 91.198.227.49 (talkcontribs) forgot to sign this comment.

I guess we'll try to work on it this month then. The resulting extension would still be licensed under GPL v3. This will probably be 1-5 stars, 1-10 would require too small stars I think. Can't promise anything since I'm still not really good at JS/AJAX, and the stars version would require quite much of it... What's your wiki btw? Patheticcockroach 14:26, 7 April 2009 (CEST)
Thanks for the quick answer. The Wiki is http://www.flyerwiki.net/. I guess you are right with the amount of stars. What do you think when you will be able to complete the changes? At the moment I'm thinking of using a Wordpress integration for the ratings but I do not really want to go there as WP requires a lot of maintenance work. I know the 150 $ are not exactly much money but I would donate that amount if it would increase the dedication of the project. Cheers and greetings from cold Glasgow, Andrew --62.149.18.147 14:48, 7 April 2009 (CEST)
I don't think WP requires that much maintenance, but probably integrating it into MW does ;) I can't tell you about the time it will take to do the changes until I actually start to work on the code (so most likely this week-end). It should be much faster than FluxBB though :D And it should be done at worst by the end of April. Patheticcockroach 15:15, 7 April 2009 (CEST)
Thanks again! I signed up so I will follow changes. That sounds realy good. Yeah, WP integration is a b... Feel free to contact me on the talk page for help or sponsorship. Have a nice day. Greetings from Glasgow --Flyerwiki 15:27, 7 April 2009 (CEST)
Well, I'm staying on the end of April - week-end of May 1 as the likely release date. The current code isn't really very clean and easy to modify, and I'd like to try not to make it worse when adding the new function ;) Patheticcockroach 22:42, 12 April 2009 (CEST)
Work in progress in the Sandbox. We'll need to either get our own star pictures, or see if we can contact the author of the current stars, or get a GFDL/GPL one from Wikimedia Commons. As usual the tables are creating problem (you'll notice that the stars don't work properly if you place them inside a table). Patheticcockroach 15:24, 17 April 2009 (CEST)
In regards to star graphics have a look at the star graphics here [1]. I can send you the graphics for this if you are interested. -- RamenLover
I looked at it and it appears that the plainlinks class is throwing it off, I took it off and the stars light up as you hover over them, there is still a white box around it in the table however adding a few lines to the common.css page should fix it. It's been a while since I've worked with css but I think that this should fix it:
table.infobox {
        background-color: transparent;
}
table.infobox tr {
        background-color: #f9f9f9;
}
Redekopmark 20:28, 17 April 2009 (CEST)
Nice find... of course we use links to display the stars using to the hover property, so the plainlinks class has the power to ruin this :/ I should have thought about that :) The white box is very unobtrusive, I can hardly see it on my not-so-great screen. If it's just around the stars, I think it's because the star picture we use for development has a non-transparent background. I'll look more into it later, I'm getting tired today. Thanks for helping :) Patheticcockroach 21:27, 17 April 2009 (CEST)

I'm sorry for the late respond ... I just created a simple (and single) star on photoshop which can be downloaded here: http://flyerwiki.net/agr/star.zip (I included the .psd file as proof that I created it). If you give me information on required formats I will create something more suitable (similar to: http://en.wikipedia.org/wiki/Template:Rating-5 ). If you wish to use these stars: https://wiki4games.com/extensions/RatingBar/starrating.gif I will rebuild them for the usage of the extension. Cheers --Flyerwiki 21:46, 27 April 2009 (CEST)

Actually, since you are the one sponsoring the stars, I don't mind if you choose the kind of design you want for them ;) I chose the picture we are currently using because it's the first I found and it looked good, but I wouldn't mind using another picture (and anyway, that's easy to change as long as the size remains the same), particularly if it's a bit smaller. For the planned design though, I need the same picture variations (i.e. empty star, filled star and filled darker star - but no need for a half-filled version), and the format of choice is, of course, png :). Finally, I'm currently very stuck by a display bug in MSIE: the star rating looks terrible in MSIE 7 if placed inside a table. How bad is this limitation for you? I mean, can we keep the current version with an explicit "contraindication" to place it in a table or should we find a work around (will likely involve an important rewrite of the involved part)? I'll be offline for a seminar until Thursday evening, so no update from me until then... :( Patheticcockroach 23:30, 27 April 2009 (CEST)
Hi there, I just created a not as good looking copy of the stars you are using now: http://flyerwiki.net/agr/star-01.zip (as usual the .psd file included as proof). As I have my final exams on Friday, I am not able to invest too much time until next Monday. I will sit down and put more effort in to it and create something "more pretty" within the next couple of days. MISE: I personally do not use it and do not like it... But I had a look in to the stats and saw that still 55% of my users us that dreadful browser. I was not able to test it and therefore can't tell how bad/good it looks in MISE ..... I think this extension will gain a lot of interest as there is no working extension available that does the trick! Cheers, Andrew --Flyerwiki 17:47, 29 April 2009 (CEST)
These stars look great. I added them to the dev version of the extension. Actually, the MSIE bug is the same as what we already have in the gradient version of the rating bar: calling the extension within a <center> tag breaks it. Since <center> is deprecated, and since I really can't see a fix, we'll leave it this way (still, I've already completely rewritten the star part only to find out it didn't solve the bug... :/). Anyway, you can see the current star version in the sandbox, and I'll most likely publish it tomorrow. Patheticcockroach 21:20, 2 May 2009 (CEST)
This extension rocks :-) I think that as soon as it is released, people using it (and me) will try to find a workaround. I couldn't have a look at "more pretty" stars, but will do as soon as the extension is released, as it then enables me to play about with it. Greetings from cold Glasgow--Flyerwiki 10:28, 5 May 2009 (CEST)
Thanks, it is actually released, btw ;) => http://files.wiki4games.com/dev/RatingBar-1.1-b1.7z Called beta, but just because we didn't take a long time to check for bugs. There is most likely no regression, while several former bugs are fixed. Patheticcockroach 18:43, 5 May 2009 (CEST)

Is there a way to insert the stars to a page by just doing a small thing like <w4g_ratingstar /> ? 88.79.192.2 11:26, 27 May 2009 (CEST) AndiRay

I think the best way would be to make the call usable in a template. Redekopmark posted the solution in the paragraph "3rd hook method?", all we need is to apply it while making sure we don't break compatibility with old code and don't add too much unneeded code (creating 2 possibilities to call the same function generates duplicates, we need to keep this to a minimum). Anyway, no dev from me until my exams (17 June), and probably not too much either afterwards unless Flyerwiki, who seems to be AWOL, decides to reappear. This extension isn't the point of W4G. We developed it because we needed it, we shared it because we like MW and open source, but now it takes a lot of time off the primary goal of the wiki. If it helped pay the bills it would be okay, if it doesn't I prefer to focus on the primary objective. Patheticcockroach 18:54, 27 May 2009 (CEST)
Have never been away :-) I wasn't able to get the RatingBar to run, therefore I have been following the discussions on the errors. As soon as things work I will make new "Stars" and have a look at the IE problems. (.....and good luck for your exams) Cheers --Flyerwiki 12:12, 31 May 2009 (CEST)
I was honestly worried that you might have run under a car or something ^^ What kind of error did you get while trying to run the extension? Patheticcockroach 13:44, 31 May 2009 (CEST)

Problem...

First of all, I really like this extension. I am having a problem, however. When I add it to my page, it works fine in preview mode, but when I save the page, the rating bar does not appear and I get the message, "You need to enable Javascript to vote". Javascript IS enabled. Can you help? Mathsinger 19:33, 9 April 2009 (CEST)

Does it work on the demo page? (I mean, here) If yes, could you post a link to your wiki? And finally (last question ;)), what browser do you use? Patheticcockroach 19:51, 9 April 2009 (CEST)
The web site I am working on is on an intranet. I have fixed the problem by modifying the code in ratingbar.php as follows; the four lines I changed are marked with my initials and the date. Mathsinger 15:16, 14 April 2009 (CEST)
// The callback function for converting the input text to HTML output
function render_w4g_ratingbar( $input, $argv, $parser ) {
        
        // Check if there isn't any other rating bar on the same page
        global $alreadyratingbar;
        if ( $alreadyratingbar ) return '<span class="w4g_ratinglist-error">You can\'t display over 1 rating bar on the same page.</br></span>';
        $alreadyratingbar = true;
        
        // Get some variables
        require ('config.php');
        
        /* Disable cache
        header("Cache-Control: no-cache");
        header("Pragma: nocache");
        $parser->disableCache();      */
        global $wgScriptPath;  /* sdc 14 Apr 2009 */
        
        // Set the style sheet
        $parser->mOutput->addHeadItem('<link rel="stylesheet" type="text/css" href="'.$wgScriptPath.'/extensions/RatingBar/styles.css"/>');  /* sdc 14 Apr 2009 */
        
        // Set the ajax script file
        $parser->mOutput->addHeadItem('<script type="text/javascript" src="'.$wgScriptPath.'/extensions/RatingBar/script.js"></script>');  /* sdc 14 Apr 2009 */
        
        // Global object variables
        global $wgUser; // For $wgUser->getID();
        global $wgOut; // For $wgOut->getPageTitle();
        
        
        // Gets $page_id
        if( isset( $argv['idpage'] ) && '{{FULLPAGENAME}}' != $argv['idpage'] )    {
                $page_id = $argv['idpage'];
        } else {
                $page_id = $parser->getTitle();
        }
        // Cleans $page_id
        $page_id_js=str_replace("U","Ux55",$page_id);
        $page_id_js=mysql_real_escape_string(str_replace($stupid_characters,$stupid_characters_codes,$page_id_js));
        //$page_id_js=str_replace(" "," ",$page_id_js);
        $page_id=mysql_real_escape_string($page_id);
        
        // Initiating some variables
        $output="";
        $user_rating=0;
        $ip = $_SERVER['REMOTE_ADDR'];
        
        // What's the current rating?
        $query = mysql_query("SELECT AVG(rating) FROM ".$ratingbar_dbname.".".$ratingbar_tablename." WHERE page_id='".$page_id."';") or die("Sorry, MySQL query failed.");
        $line = mysql_fetch_array($query);
        $average_rating = intval($line[0]);
        
        $output .= '<span id="w4g_rb_area">'; // Open the AJAX field
        $output .= 'Current user rating: <b>'.$average_rating.'% </b>';
        
        // How many users voted?
        $query = mysql_query("SELECT count(*) FROM ".$ratingbar_dbname.".".$ratingbar_tablename." WHERE page_id='".$page_id."';") or die("MySQL query failed");
        $line = mysql_fetch_array($query);
        $output .= '('.$line[0].' votes) <br/>';
                
        $output .= '</span>'; // Close the AJAX field

        // You MUST leave the following line break, otherwise MediaWiki won't be able to display the rating bar in a table. (Parsing error: a <p> tag will otherwise be added AFTER <script type="text/javascript">, causing trouble)
        $output .= ' 
<script type="text/javascript">
//<![CDATA[
var average_rating='.$average_rating.';
var user_rating=0;
var pid="'.$page_id_js.'";
var base_query_url="'.$wgScriptPath.'/extensions/RatingBar/doqueries.php";   /* sdc 14 Apr 2009 */
query2page(base_query_url+"?act=load\x26pid="+pid,"w4g_rb_area",2);
var query_url = base_query_url+"?pid="+pid;
//]]>
</script>
<div id="rating_box">
<div id="rating_target" onmouseout="updatebox(\'rating_target\',user_rating)"><span class="w4g_rb_nojs"> You need to enable Javascript to vote</span>
</div>
<div id="rating_text"></div>
</div>
<script type="text/javascript">
//<![CDATA[
loadbox("rating_target");
updatebox("rating_target",average_rating);
//]]>
</script>
';

        return $output;
}
Thanks. In fact I already noticed that "extensions/RatingBar/" should be put as a configuration variable... but I didn't think about the $wgScriptPath part. Now I wonder if it would be better to do "$wgScriptPath.$extension_path_config_variable" or just "$extension_path_config_variable" alone... I guess I'll need to have a look at what other extensions do. Patheticcockroach 11:16, 15 April 2009 (CEST)
Didn't now either about $wgScriptPath, thanks your help sdc! Franck Dernoncourt 15:30, 15 April 2009 (CEST)
I'm having the same problem, it keeps coming up with the message "You need to enable Javascript to vote", I made the changes listed above and it didn't make any difference. I also have $wgUseAjax set to true in local settings. any ideas on what's going wrong? Redekopmark 21:52, 16 April 2009 (CEST)
Just a bit more info about the problem for me, here is the wiki that I'm trying to get it to work, and I tried using it in Chrome, firefox and opera, all of which loaded it properly on you demo page. Thanks Redekopmark 05:52, 17 April 2009 (CEST)
I think this is linked to what I posted just above, e.g. the extension path is hardcoded (while it shouldn't be), and you put the extension in a folder named differently than "extensions/RatingBar/": the extension tries to load "/w/extensions/RatingBar/styles.css" but gets a 404. Strangely though, I don't even see the Javascript in the net log of Firebug. Btw, I don't think $wgUseAjax matters for the extension to work properly. Patheticcockroach 08:09, 17 April 2009 (CEST)
Thanks for your help, it turns out I had it in extensions/ratingbar instead of the proper extensions/RatingBar. I fixed that and now it looks like everything is working good Redekopmark 08:49, 17 April 2009 (CEST)
No problem, it's a mistake on the extension's side, we should let the user choose any path they want... The hardcoded path was used during development and we forgot to make it configurable. We'll fix that after the star rating option. Patheticcockroach 09:01, 17 April 2009 (CEST)
Looks like I spoke to soon about it working, now the rating bar shows up but it doesn't recognize when a user is logged in and just says that "you must log in or register to vote", and if you try to vote anyways it displays a MySQL warning from the doqueries.php page. however when you are not logged in it acts just as it should and doesn't give off any warnings when you click. Sorry about all the questions but I guess this is what the beta/rc stage is for isn't it Redekopmark 10:08, 17 April 2009 (CEST)
It would feel better on the forums for such a long thread wouldn't it? ;) Anyway, when I try to vote while not being logged in, I get a warning message, on line 76. Did you configure the extension properly? I'm thinking notably about $table_prefix. Otherwise could you post your configuration? (don't forget to remove the password +/- database connection info) Patheticcockroach 10:28, 17 April 2009 (CEST)
I think I configured it properly, although I've never had to manually configure something like this before so I may have missed something, here is the config file:
<?php

/******************************************************************************
** This file is part of the Rating Bar extension for MediaWiki
** Copyright (C)2009
**             - Franck Dernoncourt <www.francky.me>
**             - PatheticCockroach <www.patheticcockroach.com>
**
** Home Page : http://www.francky.me
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either
** version 3 of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
** <http://www.gnu.org/licenses/>
*********************************************************************/
// Config page where all main variables are set

// Database settings
$ratingbar_dbhost                                       = '********'; // Usual 'localhost'
$ratingbar_dbuser                                       = '********';
$ratingbar_dbpass                                       = '********';
$ratingbar_dbname                                       = '********';
$table_prefix                                           = ''; // eg wg_
$site_name                                              = 'Adventures in Odyssey Wiki'; 
$ratingbar_tablename                                    = 'ratingbar';
$user_tablename                                         = 'user'; // Table where we check if the user exists. Default value in MediaWiki: user
$categorylinks_tablename                                = 'categorylinks'; // Table where we check if a page belongs to a category. Default value in MediaWiki: categorylinks

// User rights
$allow_display_user_votes                               = true; //  Allow any user to list another user's votes
$allow_display_user_own_votes_only                      = false; //  Allow any user to see the list of his own votes
$allow_display_voters_for_one_page                      = true; //  Allow listing voters for one page
$allow_display_latest_votes                             = true; // Allow listing latest votes

// To avoid server lag
$max_items                                              = 20; // Max number of items in an output table. If set to 0, then the max of items that can be output in a table is infinite.
$w4g_ratinglist_max_calls                               = 25; // Max number of calls to w4g_ratinglist hook on the same page. If set to 0, then the user can do an infinite number of calls to w4g_ratinglist.

// Miscellaneous settings
$unique_check                                           = 'user'; // Identification method. 3 possibles values: 'user', 'ip', 'both' 
$min_time_between_votes                                 = 24;  // Minimum time in hours between 2 votes for the same page id from the same IP. If set to 0, one IP can only vote once for a page id. You don't care if $unique_check='user'.
$max_votes_per_ip                                       = 10; // How many times the same IP can vote for the same page. If set to 0, no limit.
$items_name                                             = 'Episode'; // Default items' name visitors will be rating.
$add_special_page                                       = true; // Add a special page
$link_vote_not_logged_in                                = 'index.php?title=Special:UserLogin'; // Link when voting if the user isn't logged in
$link_vote_not_registered                               = 'index.php?title=Special:UserLogin&type=signup'; // Link when voting if the user isn't logged in

// Page ID's secial characters that get buggy if not properly formatted when being inserted in the database
$stupid_characters                                      = array('&','#','%'); 
$stupid_characters_codes                                = array('Ux26','Ux23','Ux25');

// Connect to the database. No need to change this.

$ratingbar_tablename                                    = $table_prefix.$ratingbar_tablename;
$user_tablename                                         = $table_prefix.$user_tablename;
$categorylinks_tablename                                = $table_prefix.$categorylinks_tablename;
$rating_conn = mysql_connect($ratingbar_dbhost, $ratingbar_dbuser, $ratingbar_dbpass) or die(" Error: ".mysql_error());
?>

I wasn't exactly sure about the table prefix either, in the local settings it's blank so I left it blank here to, also I'm not sure if this is related or not but for $dbhost localhost didn't work for me I had to put in the full address of where I go to reach the PhpMyAdmin page Redekopmark 10:42, 17 April 2009 (CEST)

I think I got it: replace "Adventures in Odyssey Wiki" with "Adventures+in+Odyssey+Wiki" in $site_name... MW replaces spaces with + in session names, which I didn't know :) Patheticcockroach 11:13, 17 April 2009 (CEST)
didn't change anything, maybe I should just wait until you get the config file cleared up Redekopmark 11:19, 17 April 2009 (CEST)
mkay... sorry I missed again. Since you don't have a table prefix the extension fails to find the proper session name. But you can edit the code manually: in doqueries, almost at the beginning, replace:
ini_set("session.name", $site_name."_".$table_prefix."_session");

with:

ini_set("session.name", "aiowiki_session");

Patheticcockroach 11:31, 17 April 2009 (CEST)

Thanks that fixed it, it's working good now, if I see anything else I'll let you know Redekopmark 11:42, 17 April 2009 (CEST)

I have this same error. I tried the suggestions here, but he continues. I installed here, is a wiki for tests yet (works). is verson 1.1-b1, but i tried the others too. 189.29.37.32 16:39, 19 January 2010 (CET)

3rd hook method?

Wow, think is an incredible extension, almost exactly what I have been looking for. I was wondering it is is possible to have it only display the percentage rating without the bar or a table? It would come in very handy if user wanted to create their own tables and pull the rating data off of the corresponding pages. An idea for how to use it would be

<w4g_ratingpercent idpage="Wiki4Games:RatingBar"/>

this would give an output of 93%

Kind of an addition to that would be a category average function where you name a category and it outputs the average rating of all the items in the category. it could be something like this

<w4g_ratingaverage category="Windows_games"/>

this would output a simple 96%

I have no idea how hard it would be to add these things to the extension and I know that this probably isn't the best time to ask for something like this as your target date of beginning of May is coming up soon, but I really think that these 2 additions along with have the option of a stars instead of a bar would put your extension over the top! thanks Redekopmark 23:30, 15 April 2009 (CEST)

w4g_ratingpercent sounds like a great idea, and shouldn't be that hard to implement. Maybe not for the very next version though, as the AJAX stuff is already eating dev time like mad. w4g_ratingaverage should be slightly harder, I mean, the MySQL query is a bit longer, plus I think it should be placed in the same hook as w4g_ratingpercent. Plus an option to just output the amount of votes should be added along this. But well, should be done at some point by the end of May. Patheticcockroach 08:01, 16 April 2009 (CEST)
I'm not sure if you've started on any of this yet but I believe that I have a some functioning code for the first part (where it will only display the percentage). I based it entirely on the rating bar hook that you made, here is what I added to the ratingbar.php page
// The callback function for converting the input text to HTML output
function render_w4g_ratingpercent( $input, $argv, $parser ) {
                
        // Get some variables
        require ('config.php');
        
        /* Disable cache
        header("Cache-Control: no-cache");
        header("Pragma: nocache");
        $parser->disableCache();      */
        global $wgScriptPath;  /* sdc 14 Apr 2009 */
        
        // Set the style sheet
        $parser->mOutput->addHeadItem('<link rel="stylesheet" type="text/css" href="'.$wgScriptPath.'/extensions/RatingBar/styles.css"/>');  /* sdc 14 Apr 2009 */
        
        // Set the ajax script file
        $parser->mOutput->addHeadItem('<script type="text/javascript" src="'.$wgScriptPath.'/extensions/RatingBar/script.js"></script>');  /* sdc 14 Apr 2009 */
        
        // Global object variables
        global $wgUser; // For $wgUser->getID();
        global $wgOut; // For $wgOut->getPageTitle();
        
        // Gets $page_id
        if( isset( $argv['idpage'] ) && '{{FULLPAGENAME}}' != $argv['idpage'] )    {
                $page_id = $argv['idpage'];
        } else {
                $page_id = $parser->getTitle();
        }
        // Cleans $page_id
        $page_id_js=str_replace("U","Ux55",$page_id);
        $page_id_js=mysql_real_escape_string(str_replace($stupid_characters,$stupid_characters_codes,$page_id_js));
        //$page_id_js=str_replace(" "," ",$page_id_js);
        $page_id=mysql_real_escape_string($page_id);
        
        // Initiating some variables
        $output="";
        $user_rating=0;
        $ip = $_SERVER['REMOTE_ADDR'];
        
        // What's the current rating?
        $query = mysql_query("SELECT AVG(rating) FROM ".$ratingbar_dbname.".".$ratingbar_tablename." WHERE page_id='".$page_id."';") or die("Sorry, MySQL query failed.");
        $line = mysql_fetch_array($query);
        $average_rating = intval($line[0]);
        
        $output .= '<span id="w4g_rb_area">'; // Open the field
        $output .= ''.$average_rating.'';
        $output .= '</span>'; // Close the field

        return $output;
}
Then I also added the corresponding hook to line 46. I have absolutely zero experience with writing things in php so there is probably some stuff in there that isn't needed. Redekopmark 06:19, 18 April 2009 (CEST)
There are things that could be removed depending on what complicated stuff we want to add. To simply display the average rating, there is indeed some extra code :) Anyway, for the moment I'm focusing on making the stars work, so I haven't started to work on this hook. Does it has all the functionality you wanted for it? If yes, it will be easy to remove the extra lines of code and add it in next release. Patheticcockroach 08:14, 18 April 2009 (CEST)
Yeah, it pretty much does what I want it to do, it would be nice to be able to use a template such as {{rating|Super Mario 64}} to simplify the call, I tried this but instead of giving the rating for Super Mario 64 I got the rating for {{{1}}}. I'm not sure how easy this is to do but other than that it works like I wanted to (except for the category average thing which is far behind by skills) Redekopmark 08:44, 18 April 2009 (CEST)
Actually, we've had the same kind of problem and didn't find a fix yet, for some reason it seems that MW doesn't parse the arguments sent to extension hooks :/ Patheticcockroach 10:32, 18 April 2009 (CEST)
From experience with other extensions I think you need to have the call something like {{#w4g_ratingbar: id=Super Maio 64|style=stars}} instead of using the <w4g . . . /> format. however I don't know how to change this sort of thing, Redekopmark 10:53, 18 April 2009 (CEST)
I did some clean up & added a parameter 'maxrate'. If set to 100, it means we're dealing with %.
// The callback function for converting the input text to HTML output
function render_w4g_ratingraw( $input, $argv, $parser ) {
                
        // Get some variables
        require ('config.php');
        
        // Disable cache
        header("Cache-Control: no-cache");
        header("Pragma: nocache");
        $parser->disableCache();
        
        // Add CSS
        $parser->mOutput->addHeadItem('<link rel="stylesheet" type="text/css" href="'.$path_to_w4g_rb.'styles.css"/>');
        
        // Global object variables
        global $wgOut; // For $wgOut->getPageTitle();
        
        // Gets $page_id
        if( isset( $argv['idpage'] ) && '{{FULLPAGENAME}}' != $argv['idpage'] )    {
                $page_id = $argv['idpage'];
        } else {
                $page_id = $parser->getTitle();
        }
        
        // What's the max rate?
        if( !isset( $argv['maxrate'] ) || intval($argv['maxrate']) <= 0 )       $maxrate = 100;
        else                                                                    $maxrate = intval($argv['maxrate']);
        
        // Cleans $page_id
        $page_id=mysql_real_escape_string($page_id);
        
        // What's the current rating?
        $query = mysql_query("SELECT AVG(rating) rating FROM ".$ratingbar_dbname.".".$ratingbar_tablename." WHERE page_id='".$page_id."';") or die("Sorry, MySQL query failed.");
        $line = mysql_fetch_array($query);
        $average_rating = round(intval($line['rating']) * $maxrate / 100);
        
        $output = $average_rating;

        return $output;
}

I'll add a parameter 'category' to w4g_ratingraw instead of creating another hook w4g_ratingaverage Franck Dernoncourt 15:07, 18 April 2009 (CEST)

Patheticcockroach you said that you had problems when using this extension in a template format, I looked at it and came up with a solution. I added some code to the ratingbar.php file to enable a call to the function using {{#w4g_ratingraw:}} and it seems to work good with templates, for an example see my wiki here. I uploaded my new ratingbar.php file here for you to see. I marked the lines that I added with added by Reddo in the comments. There are a few naming difference between mine and yours, mainly in my instead of having ratingraw I have ratingpercent like I posted above and my new one is called ratingraw. I hope this helps you two out in some way Redekopmark 10:03, 19 April 2009 (CEST)
Thanks, I think we'll eventually try to convert everything to a {{#w4g_ratingraw:}}-like format if this doesn't create side-effects. Or let both options. Maybe not in the very next version though... Patheticcockroach 11:38, 19 April 2009 (CEST)
Just thought I'd let you know that I made a small change to the {{#w4g_ratingraw:}} code, there was a bug in it when you used a ' in the page id. Redekopmark 10:37, 21 April 2009 (CEST)
Franck any progress on the category parameter of w4g_ratingraw? thanks 216.249.49.58 22:22, 29 May 2009 (CEST)

userID

I have problems with the option $unique_check. If I set it to user, it says, that I have to login or register - all the time, even if I am logged in or not. When I checked the variable - echo ($uid); - I found ou, that it alway -1. Then I checked the $_SESSION and is empty. Do you have any idea? 77.128.62.208 Heinrich

Could you provide me with your $site_name and $ratingbar_tablename settings as well as a link to your wiki? NB: there is a mistake in the doc, as posted in an update on the extension page on MW, $site_name should be the same as $wgDBname. Patheticcockroach 19:24, 23 April 2009 (CEST)
Edit: you can also patch the session name bug yourself: open doqueries.php and replace:
ini_set("session.name", $site_name."_".$table_prefix."_session");
with
if($table_prefix!='') $table_prefix='_'.$table_prefix;
ini_set("session.name", $site_name.$table_prefix."_session");
Patheticcockroach 19:32, 23 April 2009 (CEST)
I have changed the the SiteName to the DatabaseName and now it seems to work.
But I reinstalled it, because:
* it is not working with the FlaggedRevs, sometimes I get the massage that it is not allowed to have more than one Rating on a page. Sometimes I can't vote when I am logged in...
* The PageID changes its name in the database, it depend where i voted. PageID ist diffrent when voting http://www.kletterwiki.de/Bettlerk%C3%BCche http://www.kletterwiki.de/Bettlerküche and even this one has an other PageIP in the rating-Tabble: http://www.kletterwiki.de/?title=Bettlerküche&redirect=no... so I had up to 5 diffrent pageIDs (and 5 diffrent votings for the same page).
I found out, what the problem is with this germans special characters: the url is diffrent in some browser, and so the pageID is diffrent in IE, Firefox and Opera - very interssting. So I build a cronjob (runs evry hour), that dupplicates all the entrys with special characters --Heinrich 10:16, 17 June 2009 (CEST)
Anyway, nice extenion, but not for - at the moment, maybe later :)
77.128.61.53 11:16, 24 April 2009 (CEST)
You may want to use the idpage parameter to force the page ID:
<w4g_ratingbar idpage="Wiki4Games:RatingBar"/>
Also, you can't display several rating bars within the same page for the moment, that's why you get an error message. But it's in our todo list :-) Franck Dernoncourt 15:57, 24 April 2009 (CEST)
Thanx for the hint, but when I use this extention in a Template, it will not work, how do I use it? When I use PAGENAME, my pageID will be PAGENAME...
<w4g_ratingbar idpage="{{{PAGENAME}}}"/>
--Heinrich 10:21, 17 June 2009 (CEST)

Mysql Errors

My wiki database does not use a table prefix and I have had problems (i think) because of thiss. I followed tips here and on the mediawiki extension talk page and I think I almost have it. Main problem is when users that are not logged in try to click the rating bar a mysql error comes out :

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.bagatelle/xxx/xxx.com/extensions/RatingBar/doqueries.php on line 78

My config.php:

<?php

/****************************************************************************
**
** This file is part of the Rating Bar extension for MediaWiki
** Copyright (C)2009
**                - Franck Dernoncourt <www.francky.me>
**                - PatheticCockroach <www.patheticcockroach.com>
**
** Home Page : http://www.francky.me
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either
** version 3 of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
** <http://www.gnu.org/licenses/>
*********************************************************************/

// Config page where all main variables are set

// Database settings
$ratingbar_dbhost                                       = 'amw.asianmediawiki.com'; // Usual 'localhost'
$ratingbar_dbuser                                       = 'xxx';
$ratingbar_dbpass                                       = 'xxxxxx';
$ratingbar_dbname                                       = 'asianmediawiki1';
$table_prefix                                           = ''; // eg wg_
$site_name                                                      = 'asianmediawiki1'; // 'yoursitename' if your site is http://www.yoursitename.com
$ratingbar_tablename                            = 'ratingbar';
$user_tablename                                         = 'user'; // Table where we check if the user exists. Default value in MediaWiki: user
$categorylinks_tablename                        = 'categorylinks'; // Table where we check if a page belongs to a category. Default value in MediaWiki: categorylinks

// User rights
$allow_display_user_votes                       = true; //  Allow any user to list another user's votes
$allow_display_user_own_votes_only      = false; //  Allow any user to see the list of his own votes
$allow_display_voters_for_one_page      = true; //  Allow listing voters for one page
$allow_display_latest_votes                     = true; // Allow listing latest votes

// To avoid server lag
$max_items                                                      = 20; // Max number of items in an output table. If set to 0, then the max of items that can be output in a table is infinite.
$w4g_ratinglist_max_calls                       = 25; // Max number of calls to w4g_ratinglist hook on the same page. If set to 0, then the user can do an infinite number of calls to w4g_ratinglist.

// Miscellaneous settings
$unique_check                                           = 'user'; // Identification method. 3 possibles values: 'user', 'ip', 'both' 
$min_time_between_votes                         = 24;  // Minimum time in hours between 2 votes for the same page id from the same IP. If set to 0, one IP can only vote once for a page id. You don't care if $unique_check='user'.
$max_votes_per_ip                                       = 10; // How many times the same IP can vote for the same page. If set to 0, no limit.
$items_name                                                     = 'Video game'; // Default items' name visitors will be rating.
$add_special_page                                       = true; // Add a special page
$link_vote_not_logged_in                        = 'index.php?title=Special:UserLogin'; // Link when voting if the user isn't logged in
$link_vote_not_registered                       = 'index.php?title=Special:UserLogin&type=signup'; // Link when voting if the user isn't logged in

// Page ID's secial characters that get buggy if not properly formatted when being inserted in the database
$stupid_characters                                      = array('&','#','%'); 
$stupid_characters_codes                        = array('Ux26','Ux23','Ux25');

// Connect to the database. No need to change this.
$ratingbar_tablename = $table_prefix.$ratingbar_tablename;
$user_tablename = $table_prefix.$user_tablename;
$categorylinks_tablename = $table_prefix.$categorylinks_tablename;
$rating_conn = mysql_connect($ratingbar_dbhost, $ratingbar_dbuser, $ratingbar_dbpass) or die(" Error: ".mysql_error());

?>

I also added two changes to the doqueries.php from getting other errors and reading other people's problems. I added this at the top portion of my doqueries.php:

require_once ('config.php');

if($table_prefix!='') $table_prefix='_'.$table_prefix;
ini_set("session.name", $site_name.$table_prefix."_session");
session_start();

and I also replaced and added:

"mysql_fetch_array($query3)" to "@mysql_fetch_array($query3)" on line 76 of doqueries.php

”mysql_fetch_array($query2)” to “@mysql_fetch_array($query2)” on line 131 of doqueries.ph.

”mysql_fetch_array($query3)” to “@mysql_fetch_array($query3)” on line 133 of doqueries.php

Could you offer tips on fixing the sql error when non-logged users try to click the rating bar and let me know if the revisions I made are correct for my website? My wiki and example of the ratingbar can be found here : [2] ... thanks - RamenLover

Oops sorry. I just noticed I forgot to change line 76 to @mysql_fetch_array($query3) and it seems to work fine now!
Hmmm now registered users cannot vote. For registered users it still says you must login or register to vote. ?
Are you sure you didn't forget to upload the doqueries modified with this
if($table_prefix!='') $table_prefix='_'.$table_prefix;
ini_set("session.name", $site_name.$table_prefix."_session");
added? Otherwise, just replace this block with:
ini_set("session.name", "asianmediawiki1_session");
Patheticcockroach 16:54, 25 April 2009 (CEST)
Ooops sorry you are right! I believe it is completely sorted out now. Thanks again and if you guys need gpl star rating let me know I can send you one.
No problem. Also I'd be glad to have a look at this GPL star rating (particularly if it contains GPL star pictures). Either e-mail it to me (you have my e-mail on your wiki ;)) or upload it on the wiki here or simply just provide a link, whichever option is easiest for you :) Patheticcockroach 17:30, 25 April 2009 (CEST)

How to change "Video Games" under Display top rated to something other?

I would like to know how to change the "Video Games" sub-header that's displayed when displaying top rated items to something else? -- RamenLover

The $items_name setting should do it ^^ Patheticcockroach 18:05, 25 April 2009 (CEST)
$items_name is located in config.php --Franck Dernoncourt 18:07, 25 April 2009 (CEST)
Thank you couldn't find that in any of the files. That did the trick ... mucho gracias -- RamenLover

Usability Issue

First of all thanks again with this great plugin. I'm having a a lot fun using it right now! I have noticed that when placing a vote it's more difficult than it seems it should be to place a vote for a specific number like 70% or 100%. Personally I also don't think there's that big of difference between say a vote of 71% and 74%. Thought crossed my mind the usability aspect might be increased if you made the slider work in 5% percent increments like 0% 5% 10% 15% etc this would probably make picking the wanted rating number easier (larger target size for that specific number) ? P.S. it might just be my crappy mouse and others do not have this issue. -- RamenLover

Good idea. The only problem with it is that the gradient maybe won't look as good if we make it with a 5% increment. But still, adding it to the to do list, for later (right now we really need to focus on debugging and the stars). Patheticcockroach 19:33, 25 April 2009 (CEST)

Some Categories does not display highest rated votes

This is an odd bug I am seeing. Some categories like "Films" displays the top votes with the proper call, while certain catgories like "Actresses" does not display (even though I voted for persons in that category. As an example [3] note that the first "Highest Rating" has a mixture of "films" and "actresses" categories, but the highest rated in the category "actresses" does not display at all. Could you let me know why this occurs? -- RamenLover

Thanks for the bug report. That's an interesting, very weird bug. I don't know, maybe Franck (who did almost the totality of this part) will... On a side note when I tried to rate a director to test it made me thought that it would be good to enable "unvoting". Patheticcockroach 08:36, 26 April 2009 (CEST)
Heh unvoting would be cool a user asked me the same question (if its possible to change their vote). -- RamenLover
Changing the vote is already possible :) Only unvoting (eg just removing the vote without placing another one) isn't. Patheticcockroach 09:15, 26 April 2009 (CEST)
Could you please send me 1) a row from the categorylinks table where cl_to = "Actors" 2) the row from the category table where cat_title = "Actors"? You'll find these 2 tables in your wiki's MySQL database. Thanks for your help :) Franck Dernoncourt 11:27, 26 April 2009 (CEST)
Hello Frank not sure if this is what you're asking for (let me know if it's not) I used phpmyadmin:

1. - a row from the categorylinks

cl_from  cl_to          cl_sortkey      cl_timestamp  
440      Actors         Choi, Min-sik   2007-08-01 23:31:13

2. - the row from the category

cat_id  cat_title  cat_pages  cat_subcats cat_files cat_hidden
2052    Actors          1587    0          0          0
Thanks, that's what I was looking for :) The pb is e.g. the Min-sik Choi page (http://asianmediawiki.com/Min-sik_Choi) is called "Choi, Min-sik" in the categorylinks table, and not Min-sik Choi as the rating bar extension is expecting, hence the bug. When I force the page id to have the comma, <w4g_ratingbar idpage="Choi, Min-sik"/> (btw I didn't undo my edit for you to see what I did), then everything works fine. I don't see why MW stores people (actors, actresses, directors, ...) with a comma. Did you tweak anything? Franck Dernoncourt 23:32, 26 April 2009 (CEST)
I don't think I tweaked anything for that. I just placed a {{DEFAULTSORT:Choi, Min-Shik}} at the bottom of the page to have page alphabetalized last name first. - RamenLover
Now that you mentioned it, I went back and checked for films that also uses the defaultsort tag, like the movie "The Host" which has a {{DEFAULTSORT:Host, The}} tag at the bottom of the page. After I voted for the film and gave it a high rating, it appears on the List of Highest Rated pages, but does not appear on the list for "Highest Rated Films". So the displays of stats that involves categories is not compatible with pages that uses the DEFAULTSORT call? -- RamenLover
I didn't know the DEFAULTSORT keyword, now I understand why the categorylinks' attribute is called cl_sortkey, makes sense lol. So currently the extension isn't compatible with the DEFAULTSORT call but it shouldn't be too hard to make it compatible (simply by adding a "sortkey" param that would correspond with the DEFAULTSORT call, there may be other ways to address this, I'll think about it). I'll read http://en.wikipedia.org/wiki/Wikipedia:Categorization#Setting_a_default_sort_key tomorrow, it might give some useful info. I'll let you know when I solve this bug, thanks again for your help! Franck Dernoncourt 00:14, 27 April 2009 (CEST)
No problem at all, thanks for working on a great plugin. I'll check back here on a regular basis to see if a fix has been made. --RamenLover 00:29, 27 April 2009 (CEST)
Just browsed our database a bit: in the wg_page table we can link page_title to page_id and this page_id matches cl_from from the wg_categorylinks table. Patheticcockroach 08:24, 27 April 2009 (CEST)
Yep, that what I had in mind, these links have to be recorded somewhere... Now the SQL queries are getting close to 1KiB :) Franck Dernoncourt 11:15, 27 April 2009 (CEST)
Did fix for this get included in Beta1? Thanks --- --72.204.184.167 11:10, 3 May 2009 (CEST)
Still not, sorry... Franck Dernoncourt 11:14, 3 May 2009 (CEST)
No problem. Will put off upgrading til next release then. --RamenLover 20:45, 3 May 2009 (CEST)
Hey guys any chance a fix for this bug can be released shortly? Thanks ... --72.204.184.167 22:31, 28 May 2009 (CEST)
Honestly, not a chance from me (for RL reasons as I explained somewhere else on this page), sorry. I don't know about Franck. Patheticcockroach 22:45, 28 May 2009 (CEST)

Error: Sorry, MySQL query failed.

Hi, i install 1.1-b1 version, follow all the steps in instalation, but always i try to preview or save a page with rating bar i get the a mysql query failed. I recheck all steps, but don't know what could be happening.--189.31.42.212 18:45, 6 May 2009 (CEST)

Are you sure you created the table, and that you created it with a proper name? (ie table named "[$table_prefix][$ratingbar_tablename]") 92.135.55.170 18:56, 6 May 2009 (CEST)
Yes, i'm sure. i follow the instructions in mediawiki. Also tried the previously version, drop and after creat again the table, try with a diferent prefix, but nothing works.--189.74.55.23 05:31, 7 May 2009 (CEST)
Please replace ratingbar.php (of version 1.1-b1) with this debug version, it should give a more detailed error message. Patheticcockroach 12:06, 8 May 2009 (CEST)
Thanks for the help Patheticcockroach, the error message is: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE page_id='Gggggggg at line 1 on line 548. This could be related with pt-br language of my wiki?--201.67.110.189 05:40, 10 May 2009 (CEST)
Possibly if you entered funky characters in the page_id field or somewhere in config.php. What did you enter as page_id and what's the name of the page where you tried to include the bar? Also, could you replace (on line 548):
$query = mysql_query("SELECT AVG(rating) FROM ".$ratingbar_dbname.".".$ratingbar_tablename." WHERE page_id='".$page_id."';") or die("Error: ".mysql_error()." on line ".__LINE__);
with:
$query = mysql_query("SELECT AVG(rating) FROM ".$ratingbar_dbname.".".$ratingbar_tablename." WHERE page_id='".$page_id."';") or die("Error: ".mysql_error()." on line ". __LINE__ ."<br/>Query: SELECT AVG(rating) FROM ".$ratingbar_dbname.".".$ratingbar_tablename." WHERE page_id='".$page_id."';");
Patheticcockroach 08:22, 10 May 2009 (CEST)
I tried without idpage, with id "Test", with id "Wiki4Games talk:RatingBar", nothing works, the page title is Test. The new error message is: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE page_id='Test at line 1 on line 548
Query: SELECT AVG(rating) FROM . WHERE page_id='Test';--189.10.78.26 15:53, 11 May 2009 (CEST)
Very weird, it looks like $ratingbar_dbname and $ratingbar_tablename (in config.php) are empty (they should appear around the dot in "FROM . WHERE")... 80.82.238.62 16:18, 11 May 2009 (CEST)
Hi, in config.php $ratingbar_dbname='wiki' and $ratingbar_tablename='ratingbar', all they are correct.--200.103.54.65 03:53, 13 May 2009 (CEST)
Sorry, I really don't see what could be wrong... anyone else with the same problem? Patheticcockroach 20:57, 13 May 2009 (CEST)
Yes i have the same Problem:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE page_id='Native Language Support at line 1 on line 549
Query: SELECT AVG(rating) FROM . WHERE page_id='Native Language Support';
German MediaWiki 1.14 on XAMPP for Windows with PHP 5.29 and MySQL 5.1.33
Greetings MoJoe
Any page where I could see that live? The problem with this bug is that I found no way to reproduce it, so I can hardly work on it :/ Patheticcockroach 18:57, 27 May 2009 (CEST)
No Problem my Wiki is portable, i can send you the complete wiki, please send me a mail, if you want to get it. Thank you MoJoe
Just sent you an e-mail Patheticcockroach 18:11, 28 May 2009 (CEST)
Hi, any news with the fix of this problem?--Knight Rider 04:27, 10 June 2009 (CEST)
As I posted higher, no debugging from me until after my exams (particularly since we already debugged quite many things in 1.1-b1, so the remaining bugs are either complicated or tedious to fix. Patheticcockroach 07:17, 10 June 2009 (CEST)

My Solution

I had this exact problem, everything setup correctly via instructions, but getting the MySQL error. The steps I had to take to fix:

  1. Replace require statements
    Replace all instances of require ('config.php'); with require ( dirname( __FILE__ ) . '/config.php');
    I don't know if it was pulling a bad directory, or I had another config.php in some other path... but this seemed to be the convention other extensions used.
  2. Edit the query statements to include the ` character
    Replace all instances of ".$ratingbar_dbname.".".$ratingbar_tablename." with `".$ratingbar_dbname."`.`".$ratingbar_tablename."`
    My queries failed until I put ` characters around the db and table names


205.175.225.28 16:57, 20 October 2009 (CEST) (cedarrapidsboy)

Jave Script Error with page titles having /

Found this odd bug today. Pages that have / in the article page title will show this error output under the Ratings bar call :

Current user rating: 0% (0 votes)
You need to enable Javascript to vote

as examples here are some pages on my wiki 301/302, So-yeon Kim (11/02/1980), Takashi Ito (11/21/1976). All other pages without / works fine and does not have this error message. -- --RamenLover 15:19, 13 May 2009 (CEST)

  1. Upgrade to 1.1-b1 ;)
  2. In config.php, configure $path_to_w4g_rb starting with / (eg '/extensions/RatingBar/' instead of 'extensions/RatingBar/')
  3. If that doesn't fix it, still in config.php, find the lines about $stupid_characters and replace them with:
$stupid_characters                                 = array('&','#','%','/'); 
$stupid_characters_codes                        = array('Ux26','Ux23','Ux25','Ux2f');
Hope this fixes it... Patheticcockroach 20:57, 13 May 2009 (CEST)
Thanks upgrading to 1.1-b1 and chaning path to "/extensions/RatingBar/" did the trick.
Hello after the upgrade I now notice that all pages have a "You need to enable Javascript to vote" after the upgrade to Beta1. When I did the upgrade I overwrote the prior version which I made fixes too (from reading prior posts) because my wiki doesn't have a table prefix. I thought this would have been fixed in beta1. So from a comment left on the extension page should I switch to the dev version or is there is something I need to change in my extension files? Thanks! --RamenLover 23:38, 15 May 2009 (CEST)
Do you think it might be caused by the extension path? My wiki is installed in the root director rather than the more traditional /w .. --RamenLover 08:25, 16 May 2009 (CEST)
Sorry for late reply, I wasn't on my dev computer last time I checked. Looks like you simply forgot to put a slash at the end of $path_to_w4g_rb (eg you wrote '/extensions/RatingBar' instead of '/extensions/RatingBar/') Patheticcockroach 09:14, 16 May 2009 (CEST)
Hey not a problem. I now added the trailing slash and still not getting any love :(. Still shows the you need to enable Java error. --RamenLover 09:29, 16 May 2009 (CEST)
When I try to access for instance http://asianmediawiki.com/extensions/RatingBar/styles.css, I get a 403 error (forbidden). Don't you have some paranoid .htaccess file which blocks a little too much stuff? ;) If yes, you should add one with "allow from all" in the extension's folder. Patheticcockroach 09:39, 16 May 2009 (CEST)
Hey sorry about that. Not sure why the extensions folder has such heavy restrictions (I added the "allow from all" into the extensions folder but still seems to give out 403's). I don't want to change anything that's not necessary. Do you think I can just send you or paste anything specific you want to see? When I upgraded I overwrote all the old files and only changes I made were to the config.php ... --RamenLover 09:49, 16 May 2009 (CEST)
Normally just placing a .htaccess file in the extension's folder (ie in "/extensions/RatingBar/", not necessarily in "/extensions/") should do the trick. Maybe try with:
order deny,allow
allow from all
Otherwise, I don't really see what could be the problem. Version 1.1 brings no structural changes to the extension (it still calls the same CSS and javascript files, and the same PHP files, just one additional picture in case of a star rating): if 1.0 works without a 403, I don't see how 1.1 could get one :/ Patheticcockroach 10:10, 16 May 2009 (CEST)
Whew... thanks for the last bit of info it got me to nail down the problem. I did add the htaccess and still did not work. I then checked files from other extensions in the /extension directory and they opened fine from the browser. Then I went back and checked the file permissions on the individual files in the Rating Bar folder and they were set up only for the user to read and write while all others did not have read permissions. Also for your next release do you think you can compress your extension with something other than 7z? I'm on Linux and had no easy way to decompress the 7z file format. So I went a round a bout way, launching Windows in virtual machine, extracting it (i think this is how the files got the messed up file permissions) and then transferring it to my Linux machine to ultimately send it to my host. Other archives like .rar and .zip and .gz and what not are fine, this was my first time coming across the 7z format. But changing the file permissions solved my problem (my files had messed up file permissions). Thanks for your help... much obliged! --RamenLover 10:35, 16 May 2009 (CEST)
Ah, user permissions... the very thing I've always hated on Linux, now cleverly ported to Vista, making Windows for the first time as poorly user-friendly as Linux. Awesome move from M$ to promote open source :D On Linux you have p7zip, which is painless to install on Ubuntu (or maybe it's an equivalent, searching the package manager for 7zip or LZMA should find it) (I don't remember exactly how it does, but globally it installs like a plugin for the existing archive manager). But yeah, I compressed it without thinking much with my usual archiver and forgot to configure it to zip. I should make a zip version, or better a tar.gz... Patheticcockroach 11:01, 16 May 2009 (CEST)

From Lee: I have a You need to enable Javascript to vote error too. I've tried all the fixes I can find without success. Wiki page is here http://sal.dynadsl.com/IL2Wiki/index.php/Mods_Popularity 220.253.135.180 (talkcontribs) forgot to sign this comment.

Try this: http://bbs.wiki4games.com/showthread.php?tid=15 WonderAlice 17:25, 31 July 2009 (CEST)

Lee said: I tried adding a "/" to the start of the path, but that did not work.

I only have this problem when viewing the page in normal (short url) mode. That is, when I am in preview, the star ratings appear to work fine. If I view the page using the traditional http://...index.php?title=xxxxx URL, the star ratings work fine. But, when viewed with my short URL, http://.../wiki/xxxxx, I get the javascript error.  :( 205.175.225.28 17:01, 20 October 2009 (CEST)(cedarrapidsboy)
NM, fixed by earlier post by Mathsinger

Rating bar error

Notice: Undefined variable: add_special_page in /home/wiki4games/www/extensions/RatingBar/ratingbar.php on line 53

found that, as I have been on Anden21's User page. undefined varables cause errors. I don't know which var, but it makes the error... Viraba 21:10, 29 May 2009 (CEST)

It's okay, it's a warning that showed up on every page while I was debugging some other stuff... We'll have to make sure we fix it for the next version though, warning messages pop up quite horribly on MW ^^ Patheticcockroach 21:14, 29 May 2009 (CEST)
I downloaded today (24. June 2009) the version 1.1-b1 and I also got this error because in the file ratingbar.php the first 'require ('config.php');' line at the top was commented out:
// Get some variables
// require ('config.php');
Removing the '//' in the second line fixed the problem as the variable 'add_special_page' is defined in config.php and needed for adding the special page. 141.14.23.99 11:29, 24 June 2009 (CEST)

You need to enable Javascript to vote

I have just installed the latest version of the script on a brand new mediawiki installation. I get a "You need to enable Javascript to vote", whenever I am on a page where the URL says .../wiki/Article instead of .../w/index.php?title=Article. In otherwords, when I have "pretty URLs" turned on, the rating bar does not work, and just says I need javascript, but when pretty URLs are turned off, it works perfectly. Any quick fixes for this? I'd imagine others must have this problem, too. --WikiWorker 07:31, 5 November 2009 (CET)

Did you try this too? => http://bbs.wiki4games.com/showthread.php?tid=36 Patheticcockroach 07:38, 5 November 2009 (CET)
I tried, but I'm pretty sure I did it wrong, since I was guessing whether parts of his code were replacing other parts, or if they were brand new sections of code that were being placed in. First I did a combination of the two, since some lines logically appeared to be replacements of existing text, and others did not. It did not work. Then I tried just replaced the sections from // Global object variables to // Gets $page_id with the whole, unadulterated section suggested, but also with no luck. If there was an explanation of what to do with each bit of text, or if you could just post a replacement ratingbar.php file for people using short URLs, it would be really helpful! --WikiWorker 15:23, 5 November 2009 (CET)

I am also using pretty URLs with MOD_REWRITE and was getting this JavaScript error on the final output page (preview page was fine). I found a solution that some might consider dirty, but it works for me: At line 35 when you set $path_to_w4g_rb use the FULL, absolute, non-rewritten path starting with http://. 63.249.90.51 (talkcontribs) forgot to sign this comment.

Self-reply: after more work, it seems that this creates a problem when someone views from http://domain.com as opposed to http://www.domain.com (and maybe vice versa, depending on what you defined in the $path). Both current statistics and voting-submission disappear, yet the bar/stars still show up. Rather than try to fight this bug, it may be simplest to just tell your users to be sure the www. is there on the address bar if they want to vote/see votes. 63.249.114.163 (talkcontribs) forgot to sign this comment.
I think a solution to that could be to configure $path_to_w4g_rb to something based on the absolute path but without http://yourdomain.com. e.g. If your wiki is on www.mywiki.com/wiki and the rating bar is on www.mywiki.com/wiki/extensions/ratingbar, did you try $path_to_w4g_rb="/wiki/extensions/ratingbar"? Also, you don't need to involve the users in getting them to the www. (or www-less) version, you can set up a redirect between the two versions. Not only this will help you have a more coherent "URL image", but also search engines might like it better (notably, ppl who link to you will likely always use the version you choose, since usually when making a link you copy-paste the URL in your browser address bar). For instance, here, [anything].wiki4games.com forwards to wiki4games.com. Patheticcockroach 07:39, 21 May 2010 (CEST)

Problem with acents in titles

Hi, in all page titles having characters with accents (like á, à, é, ç) this characters are replaces by another strange characters like á --Knight Rider 05:51, 22 March 2010 (CET)

anyone??--187.7.197.143 21:43, 26 March 2010 (CET)
The extension was programmed with this wiki, in English, in mind. Lots of special characters create problems which I don't have the time to try to fix at the moment. Sorry. Patheticcockroach 21:55, 26 March 2010 (CET)

My Solution

Hi added this line mysql_query("SET NAMES 'utf8'"); into doqueries.php, after the line session_start();. It worked for me.

It's important to check the column charset of the field page_id, it would be utf8 and the column collate utf8_bin. Moreover the table charset should be utf8 too.

If you use the parameter category the charset codes of the table categorylinks should coincide with ratingbar table.

Regards

mw 1.16 compatability

how well does this work with 1.16? i know that the new version works well with it but my wiki wants to keep the anon voting ability which is only available in this one, i know that there were a lot of things that broke from 1.15 to 1.16 and i just want to double check before i upgrade, thanks Redekopmark 22:13, 13 September 2010 (CEST)

As you can see, this version of the extension is still running here. It doesn't seem to cause any problems, and also we've run it alone for a few days after the MW 1.16 update without noticing any issues. No particular work has been done between Rating Bar v1 and W4G Rating bar v2 to make the second more compatible with MW 1.16. The main difference is that v1 uses some now useless legacy functions which v2 doesn't use, thus v2's incompatibility with MW <1.16. MediaWiki isn't like Firefox, they don't break about every extensions with each new version ;) Patheticcockroach 09:57, 14 September 2010 (CEST)
okay, thanks i didn't know that v1 was still in use here, i know that extensions usually don't break from version to version but DPL (most used extension on our wiki) broke when going to 1.16 and this is the second most used extensino i just wanted to make sure that it wouldn't break too, thanks Redekopmark 10:06, 14 September 2010 (CEST)

Dynamically Generate User's Vote List?

Hi guys, I want to make a page on my wiki with a w4g_ratinglist user="whoever"/ tag such that the "whoever" will change dynamically based on the the user viewing the page. As in, whoever visits the "Your Votes" page will simply see a list of their own votes.

Unfortunately (and bizarrely), MediaWiki doesn't seem to have a magic word like {{USERNAME}} that I could plug in there so that the username would simply be outputted into the tag when it parses the page. Or does it?

Any ideas? 63.249.115.191 (talkcontribs) forgot to sign this comment.

Well, because of the MediaWiki cache, such a variable wouldn't actually output the current user's name but would instead output the name of the last user whose visit generated a cache refresh. Or, to work, it would need to disable the cache on the page where it's loaded, and I don't believe MediaWiki are willing to allow a variable to have such a power. So probably it indeed doesn't exist. For the functionality you describe we'd need to implement a special page, which isn't on our schedule yet (NB: also RatingBar isn't maintained anymore, it's been replaced by Wiki4Games:W4G Rating Bar. Patheticcockroach 08:28, 7 November 2010 (CET)
actually extensions can disable the cache, this extension sounds like just the thing you're looking for Redekopmark 08:34, 7 November 2010 (CET)
Yup, both the old and new version of the Rating Bar can disable the cache indeed ;) (although the new version should do it more parsimoniously) What I meant was I don't believe MediaWiki would include in the core a variable which would give any user the ability to kill the cache. Great extension you spotted otherwise. On a side note, this old version of the Rating Bar can't take a variable like {{USERNAME}} as a parameter, and I don't remember if the new version can for the toplists (MW 1.16 added the ability for a tag to parse MediaWiki variables, but I don't remember if I used it :s). Patheticcockroach 08:49, 7 November 2010 (CET)