PDA

View Full Version : Ajax Photo Ratings Addon


Dkozikowski
08-04-2007, 08:54 AM
http://dwilkinsjr.com/public/pixelpost/forumFiles/ajaxRate/3bigStars.jpg
AJAX RATINGS v1.0

Last updated on: November 24th, 2007

FEATURES

Main features:

Uses Ajax to rate your photos (no page refresh)!
100% degradable. Your photos still get voted if your viewer has JavaScript disabled!
Multiple checks to stop repeated voting so your results are as accurate as possible!
Utility to transfer your old ratings from Robert Prouse's ratings addon!
Your most valued visitors who comment and rate your photos will receive a personalized thank-you message!
View how many votes each image contains in seconds within the admin panel!
Multilingual capable!
Top rated, Worst rated, Least rated, Most rated statistical addon included!
Extremely flexible, well documented, multiple examples included!



SUPPORTED LANGUAGES

Current supported languages:

English
German
Polish
Dutch
Italian



ADDON INFO

Addon Type:

Normal (user end) Addon




Description:

This addon allows your visitors to rate your photos based on a scale of 1 to 10 or anywhere in between using the power of degradable ajax.




Addon Details:

Version: 1.0
Updated: November 24th 2007
Changes: See change log @ bottom
Requires Pixelpost: v1.7



LIVE EXAMPLES

Dwilkinsjr's Dev Photoblog:

See it in action (http://www.dwilkinsjr.com/dwilkinsjr/devblog/index.php)



dontlinkhere.com - Photography By Matthew Drazin:

See it in action (http://www.dontlinkhere.com/)



Frankgraave.nl Photoblog:

See it in action (http://www.frankgraave.nl/)



Rust and cobwebs | One Look Behind:

See it in action (http://photographie.one-look-behind.de/)



Raven-Photography \\ Industrial revolution:

See it in action (http://www.raven-photography.nl/)



SCREEN CAPTURES

Screen Captures:

Ajax Rater with zero (0) votes:
http://dwilkinsjr.com/public/pixelpost/forumFiles/ajaxRate/ajaxRate-no-votes.jpg


Ajax Rater with zero (0) votes on mouse hover:
http://dwilkinsjr.com/public/pixelpost/forumFiles/ajaxRate/ajaxRate-hover.jpg


Ajax Rater with one (1) vote showing personal thank-you message:
(Note: your viewers name will show if they have previously commented and have their
comment form info saved for your photoblog)
http://dwilkinsjr.com/public/pixelpost/forumFiles/ajaxRate/ajaxRate-thankyou.jpg


Ajax Rater with one (1) vote:
http://dwilkinsjr.com/public/pixelpost/forumFiles/ajaxRate/ajaxRate-rated.jpg


Ajax Rater with two (2) votes showing a total rating of 4.5:
http://dwilkinsjr.com/public/pixelpost/forumFiles/ajaxRate/ajaxRate-rated-4.5-vote.jpg


Admin Image Pane preview showing rating and cast totals:
http://dwilkinsjr.com/public/pixelpost/forumFiles/ajaxRate/ajaxRate-admin.jpg



DOCUMENTATION

Online documentation:

Ajax Rating User Guide (http://dwilkinsjr.com/public/pixelpost/forumFiles/ajaxRate/index.html)



Other documentation:

The same manual above is included with your download.



DOWNLOAD

Download:

Ajax Ratings v1.0 (http://www.pixelpost.org/extend/addons/ajax-photo-ratings/)



Donate:

Help keep this and other addons current (https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=dwilkinsjr%40dwilkinsjr%2ecom&item_name=Dwilkinsjr%27s%20Pixelpost%20Addons&page_style=PayPal&no_shipping=1&return=http%3a%2f%2fdwilkinsjr%2ecom%2fdonation%2f thankyou%2f&cancel_return=http%3a%2f%2fdwilkinsjr%2ecom%2fdona tion%2fcancel%2f&no_note=1&cn=Comments&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8)



VERSION HISTORY

Key:

[!]Important
[+]New
[-]Fixed error
Changes



Version 0.5

[!]Initial release.



Version 0.6

[+]Added new template tag to display total votes separately from the standard status message.
[+]Added new template tag to display total votes cast separately from the standard status message.
[+]Added optional admin_ajax_ratings.php addon file so you can view how many ratings each image has within your admin panel.
[+]Added new utility to completely erase the ratings data. (useful when testing)
Updated User Guide



Version 0.7

[-]Fixed the regular expression that was causing some people's photoblogs to cease proper functionality.
Updated the javascript functions to help avoid conflict between mootools and prototype packages.
[+]Added function to admin_ajax_ratings.php that removes the rating info from the database upon image deletion.
Updated User Guide



Version 1.0

[+] Multilingual capable (user and admin supported).
+] Added ajax_rating_statistics.php addon which allows you to display Top/Worst/Most/Least rated images.
Code cleanup.
[!]Jumped to version 1.0.

GeoS
08-04-2007, 09:52 AM
Im amazed :D Its sound really coooool :)

Dennis
08-04-2007, 01:01 PM
Well, I'm amazed it has entered the public phase. After an harddisk crash all the work was lost. I really like the import utility so I can transfer to the new version. :p

Dkozikowski
08-04-2007, 06:27 PM
Well, I'm amazed it has entered the public phase. After an harddisk crash all the work was lost. I really like the import utility so I can transfer to the new version. :p

LOL. Me too.

It only took 6 months ;)

Dkozikowski
08-05-2007, 02:33 AM
Im amazed :D Its sound really coooool :)

It is ;)

You should try it :)

Dkozikowski
08-06-2007, 10:47 PM
So, there have been quite a few downloads already.

Has anyone gotten this up and running on their site yet?

Care to share a link with us so others can see some live implementations?

dankster
08-07-2007, 04:19 PM
Ive installed this. VERY good documentation and very easy install.

i would however like to customize the output of the thank you message a little further. Maybe by briefly replacing the star rating with the thank you message then fading the message back to the stars keeping it all inline.

check it out at www.dontlinkhere.com

Also it would be great to have a small star rating display (not option to vote, but just displaying the current rating) in the browse pages.

so you can browse the thumbnails, and see the photos avg rating under it. that would be a cool addition.

Dkozikowski
08-07-2007, 05:54 PM
Also it would be great to have a small star rating display (not option to vote, but just displaying the current rating) in the browse pages.

so you can browse the thumbnails, and see the photos avg rating under it. that would be a cool addition.

I like it, I'll see what i can do.

Fotograave
08-09-2007, 12:25 PM
Hey,

I've also try'd this rating system, but i found a few problems.
When rating, it stores every rate somewhere. To clean it, there is a very nice tool delivered that NOT CLEANS the votes..
now i also have the problem that is doesnt say thank you! when voting, and my page refreshes after clicking the rating system...

www.frankgraave.nl

help would be great, anyone?

dankster
08-09-2007, 02:19 PM
are you sure the javascript is installed?

Fotograave
08-09-2007, 02:35 PM
yes i have it in the <head>
go: www.frankgraave.nl rate a photo and see for yourself, .. the page refreshes, and there's no Thanks for Voting!
... :(

Dkozikowski
08-09-2007, 06:34 PM
yes i have it in the <head>
go: www.frankgraave.nl rate a photo and see for yourself, .. the page refreshes, and there's no Thanks for Voting!
... :(

Try moving the Ratings JS and CSS just before the </head> tag.

You have so much javascript included in your template it's possible something is conflicting causing the ratings to not use the ajaxy way to submit. right now the ratings are being submitted like javascript is turned off (hence the refresh and no thankyou).

If moving the code does not work, try commenting out the other javascript and only leave the rating javascript in place.

Dkozikowski
08-09-2007, 06:41 PM
Hey,

I've also try'd this rating system, but i found a few problems.
When rating, it stores every rate somewhere. To clean it, there is a very nice tool delivered that NOT CLEANS the votes..
now i also have the problem that is doesnt say thank you! when voting, and my page refreshes after clicking the rating system...

www.frankgraave.nl

help would be great, anyone?

This tool is not meant to "clean" the votes. All it does is remove all the previously recorded IP addresses so previous voters can vote a 2nd time.

Using this utility should not have had any effect on the way your system handles votes.

Something else had to have changed also.

Fotograave
08-09-2007, 08:56 PM
Try moving the Ratings JS and CSS just before the </head> tag.

You have so much javascript included in your template it's possible something is conflicting causing the ratings to not use the ajaxy way to submit. right now the ratings are being submitted like javascript is turned off (hence the refresh and no thankyou).

If moving the code does not work, try commenting out the other javascript and only leave the rating javascript in place.

Thank you very much, I've put it just before my </head> line, and now its working great !, Thank you!!!!, Great rating system btw ! :) thank you!

Dkozikowski
08-09-2007, 09:41 PM
Spectacular :)

Also, just a FYI for those who would like to change the working.gif image (the spinning loader) you can grab a bunch here, http://ajaxload.info/

Flea
08-10-2007, 10:07 AM
Great work. Easy to install, good how-to, very well done!

THX!

Dkozikowski
08-10-2007, 10:56 AM
Thanks for the feedback and support everyone.


I added each one of your photoblog's to the Examples list :)

roylevi
08-10-2007, 11:27 AM
The addon looks great, so I figured I'd try it for my blog at roylevi.net (http://roylevi.net/). It's a fairly simple configuration with a modified horizon template, and just the default addons.

Problem is that after installation the site turns completely blank (firefox) or gives the common server not found error (internet explorer) whenever the addon is enabled.

There is nothing usefull in the apache logs, but I noticed that the database table is never created.

I believe I followed the instructions correctly, after they weren't very complicated. Has anyone else seen this happen or have any idea where to start troubleshooting?

Thanks

Dkozikowski
08-10-2007, 11:41 AM
Ok, are you running pixelpost v1.6?

Keep the ajax rating template tag active so your website goes blank.

login to your admin panel

now, travel back to the page were the ajax_rate template tag exists


in the url, add either ?errors or &errors

one of those will show you what is wrong.

Report your findings here.

Dkozikowski
08-10-2007, 11:56 AM
I am watching what you are doing the best I can and I am seeing 2 <AJAX_RATE> template tags trying to be used at the same time.

You must only add one template tag to your template.

roylevi
08-10-2007, 11:59 AM
Ok, are you running pixelpost v1.6?

Yes, it is pixelpost 1.6

Keep the ajax rating template tag active so your website goes blank.

login to your admin panel

now, travel back to the page were the ajax_rate template tag exists


in the url, add either ?errors or &errors

one of those will show you what is wrong.

Report your findings here.


The template tag does not impact on the problem as such. Whenever the addon is enabled from the admin panel, the site (default and showimage modules) goes blank even without any of the tags in the template. Similarly the site works fine even with the tags, as long as this particular addon remains disabled from the admin panel.

Adding ?errors or &errors doesn't give anything either. http://roylevi.net/?errors or http://roylevi.net/index.php?showimage=11&errors

Could it be something related to how ajax works with virtual hosts etc?

Dkozikowski
08-10-2007, 12:02 PM
If you can, please send me your pixelpost admin login details via private message so i can have a better look at this.

I'm not sure why this is happening as it's never been encountered before.

Dkozikowski
08-10-2007, 12:03 PM
Adding ?errors or &errors doesn't give anything either. http://roylevi.net/?errors or http://roylevi.net/index.php?showimage=11&errors


Even while logged into the admin panel?

Those URL modifiers will not work unless logged in.

roylevi
08-10-2007, 12:24 PM
I am watching what you are doing the best I can and I am seeing 2 <AJAX_RATE> template tags trying to be used at the same time.

You must only add one template tag to your template.

Ah yes, looks like I had two in there for a bit. When both are removed the site works even with the ratings addon enabled - and ?errors does give output.

When the tag is put back in, it comes out blank again - and ?errors does not give any output.

I'll PM you my logon details and would be very gratefull if you would have a quick look.

Raven
08-10-2007, 07:25 PM
Great rating system!! I also use it=)
http://www.raven-photography.nl/


I have one question. Is there a simple way to delete all the votes?

Dkozikowski
08-11-2007, 07:00 AM
Thanks,

As of right now there is no utility provided to do this but you're not the first person to ask.

I'll whip up something for the next release.

StatVoid
08-12-2007, 05:28 AM
When I add the <AJAX_RATE> tag my site (running on PP1.6) goes blank and when I do ?errors I get this message...


Warning: getimagesize(thumbnails/thumb_) [function.getimagesize]: failed to open stream: No such file or directory in /home/statvoid/public_html/index.php on line 444

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/statvoid/public_html/includes/functions.php on line 282

Warning: getimagesize(thumbnails/thumb_) [function.getimagesize]: failed to open stream: No such file or directory in /home/statvoid/public_html/index.php on line 473

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/statvoid/public_html/includes/functions.php on line 282

Warning: getimagesize(thumbnails/thumb_) [function.getimagesize]: failed to open stream: No such file or directory in /home/statvoid/public_html/index.php on line 501


Loading Image

Click anywhere to cancel
Image is Unavailable

I have no idea what the problem could be, but if you take a look at the scripts I'm running, maybe something is causing a conflict? I tried even stripping just all the other js references other than the ones needed for the rating system, yet nothing helped. It wasn't until I removed the tag itself that it worked.

Dkozikowski
08-12-2007, 08:57 AM
That's odd. Nowhere in that error output does it specifically say the ajax rating addon is the culprit. All those other warnings are not caused by my addon.

I'm not sure about this though:


Loading Image

Click anywhere to cancel
Image is Unavailable


I've never seen that before.

Try using my addon with a different "clean" template like an unmodified simple template. Let me know if it works when you switch template styles

StatVoid
08-12-2007, 02:18 PM
Odd... I get the same thing. The template I switched to was "simple," the one that comes with the PP download.


Warning: getimagesize(thumbnails/thumb_) [function.getimagesize]: failed to open stream: No such file or directory in /home/statvoid/public_html/index.php on line 444

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/statvoid/public_html/includes/functions.php on line 282

Warning: getimagesize(thumbnails/thumb_) [function.getimagesize]: failed to open stream: No such file or directory in /home/statvoid/public_html/index.php on line 473

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/statvoid/public_html/includes/functions.php on line 282

Warning: getimagesize(thumbnails/thumb_) [function.getimagesize]: failed to open stream: No such file or directory in /home/statvoid/public_html/index.php on line 501

I am guessing it has something to do with the database or an addon conflict, so I'll disable some addons one-by-one and see if anything helps. If I resolve it before a response, I'll put up what I did, otherwise consider this an unsolved mystery. heh

UPDATE
OK, I went through and disabled every single addon except for ratings and nothing changed. So it's not a conflict in that sense, but do I maybe need to have certain addons installed and active for it to work? Because I deleted some of the default addons that came with PP because they didn't serve my needs (like my tags no longer worked after I deleted the paged_archive addon). Granted it's mySql error, but I was just wondering.

And oddly enough, when I disable the ratings addon and actually can view the site, if I do ?errors, I get this (and please note, this happens with the default template also...)...

Warning: getimagesize(thumbnails/thumb_) [function.getimagesize]: failed to open stream: No such file or directory in /home/statvoid/public_html/index.php on line 444

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/statvoid/public_html/includes/functions.php on line 282

Warning: getimagesize(thumbnails/thumb_) [function.getimagesize]: failed to open stream: No such file or directory in /home/statvoid/public_html/index.php on line 473

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/statvoid/public_html/includes/functions.php on line 282

Warning: getimagesize(thumbnails/thumb_) [function.getimagesize]: failed to open stream: No such file or directory in /home/statvoid/public_html/index.php on line 501

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/statvoid/public_html/includes/functions.php on line 539

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/statvoid/public_html/includes/functions.php on line 539

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/statvoid/public_html/includes/functions.php on line 539

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/statvoid/public_html/includes/functions.php on line 539

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/statvoid/public_html/includes/functions.php on line 539

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/statvoid/public_html/includes/functions.php on line 539

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/statvoid/public_html/includes/functions.php on line 539

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/statvoid/public_html/includes/functions.php on line 539

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/statvoid/public_html/includes/functions.php on line 539

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/statvoid/public_html/includes/functions.php on line 539

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/statvoid/public_html/includes/functions.php on line 539

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/statvoid/public_html/includes/functions.php on line 539

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/statvoid/public_html/includes/functions.php on line 539

I can't seem to figure any of this out...I'm mind boggled.

StatVoid
08-12-2007, 03:04 PM
OK, I got it working now on a hunch. I originally had PHP5 enabled on my server, so I figured it was worth a shot to see what happens if I ran PHP4 and go figure, it worked. I'm guessing no, but is that a common problem?

And here's my second problem, I'm still getting this error when I do ?errors...

Warning: getimagesize(thumbnails/thumb_) [function.getimagesize]: failed to open stream: No such file or directory in /home/statvoid/public_html/index.php on line 444

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/statvoid/public_html/includes/functions.php on line 282

Warning: getimagesize(thumbnails/thumb_) [function.getimagesize]: failed to open stream: No such file or directory in /home/statvoid/public_html/index.php on line 473

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/statvoid/public_html/includes/functions.php on line 282

Warning: getimagesize(thumbnails/thumb_) [function.getimagesize]: failed to open stream: No such file or directory in /home/statvoid/public_html/index.php on line 501

Any ideas why? I even tried re-uploading all the includes files and everything but no dice.

Dkozikowski
08-12-2007, 03:17 PM
OK, so my addon works with php4 and not 5??

Odd as I develop using PHP5 and I have zero issues.

and don't wory about those other warnings. those exist from some really old code that did not get cleaned up. they do not effect the way Pixelpost functions in any way.

We're working to clean the code 100% to get rid of all warnings and notices.

StatVoid
08-12-2007, 03:46 PM
That is the case unfortunately, at least in my experience.

OK, so my addon works with php4 and not 5??

That's a relief! Thank you for all the help.

and don't wory about those other warnings. those exist from some really old code that did not get cleaned up. they do not effect the way Pixelpost functions in any way.

We're working to clean the code 100% to get rid of all warnings and notices.

I do have one suggestion/request... Among other things (like just a count of the number of comments an image has), I believe there should be a way for the addon to add something like "Current Rating" alongside the standard Title, Filename, Categories, Tags, etc that are on the Images administration panel. Anything image related should be there. While editing those specific things should be separate, it would be nice to go to the Images section and just be able to see how many comments there are or what the rating is. I dunno, that's just my $.02.

Dkozikowski
08-12-2007, 04:09 PM
That is the case unfortunately, at least in my experience.



That's a relief! Thank you for all the help.



I do have one suggestion/request... Among other things (like just a count of the number of comments an image has), I believe there should be a way for the addon to add something like "Current Rating" alongside the standard Title, Filename, Categories, Tags, etc that are on the Images administration panel. Anything image related should be there. While editing those specific things should be separate, it would be nice to go to the Images section and just be able to see how many comments there are or what the rating is. I dunno, that's just my $.02.

Thanks for the good suggestion. Next version.

Dkozikowski
08-12-2007, 08:00 PM
http://dwilkinsjr.com/public/pixelpost/forumFiles/ajaxRate/3bigStars.jpg
AJAX RATINGS v0.6

Last updated on: August 12th, 2007

VERSION HISTORY

Key:

[!]Important
[+]New
[-]Fixed error
Changes



Version 0.6

[+]Added new template tag to display total votes separately from the standard status message.
[+]Added new template tag to display total votes cast separately from the standard status message.
[+]Added optional admin_ajax_ratings.php addon file so you can view how many ratings each image has within your admin panel.
[+]Added new utility to completely erase the ratings data. (useful when testing)
Updated User Guide



DOWNLOAD

Download:

Ajax Ratings v0.6 (http://dwilkinsjr.com/public/pixelpost/myaddons/ajax_ratings_v0.6.zip)



Donate:

Help keep this and other addons current (https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=dwilkinsjr%40dwilkinsjr%2ecom&item_name=Dwilkinsjr%27s%20Pixelpost%20Addons&page_style=PayPal&no_shipping=1&return=http%3a%2f%2fdwilkinsjr%2ecom%2fdonation%2f thankyou%2f&cancel_return=http%3a%2f%2fdwilkinsjr%2ecom%2fdona tion%2fcancel%2f&no_note=1&cn=Comments&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8)



Also, a "Top Rated" addon to compliment this addon is in the works ;)

Ubbe
08-12-2007, 08:57 PM
I get a "500 Internal Server Error" When using any of the tags in my template???

StatVoid
08-12-2007, 09:06 PM
Very nice update. Upgraded immediately!

Dkozikowski
08-12-2007, 09:43 PM
I get a "500 Internal Server Error" When using any of the tags in my template???

Ive found some people to have trouble the the regular expressions being used in my addons. So I commented them out to see if that helps you.

Open the ajax_ratings.php addon file and replace all the text with the following.


<?php
/*

Written by: Dwilkinsjr
Written for: Pixelpost 1.6.0 www: http://www.pixelpost.org/
Based on: Unobtrusive AJAX Star Rating Bar ( http://www.masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar )
By: Ryan Masuga

<!--

__ _ ____ _ _
____/ / __(_) / /__(_)___ _____ (_)____
/ __ / | /| / / / / //_/ / __ \/ ___/ / / ___/ AJAX RATINGS v0.6
/ /_/ /| |/ |/ / / / ,< / / / / (__ ) / / / LAST UPDATED - AUG/12/2007
\__,_/ |__/|__/_/_/_/|_/_/_/ /_/____/_/ /_/
http://dwilkinsjr.com/___/


-->

Contact: dwilkinsjr@dwilkinsjr.com
Copyright (c) 2007 <http://wwww.dwilkinsjr.com>

License: http://www.gnu.org/copyleft/gpl.html

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 2
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.

*/

$addon_name = "<a name=\"ajaxRate\"></a>Ajax Ratings";
$addon_version = "0.6";
$addon_description = "Ajax Ratings allows your visitors to rate your photos based on a scale of 1 to 10 or anywhere in between using the power of degradable ajax.<br /><br />Please read the <a href=\"../includes/ajaxRating/readmeUserGuide.html\">Ajax Rating User Guide</a> for full installation and configuration instructions.<br /><br />New tag: <code>&lt;AJAX_RATE&gt;</code><br /><br />ADDON Author: Dwilkinsjr (<a href='http://www.dwilkinsjr.com/myaddons' target='_blank'>dwilkinsjr.com</a>) (<a href=\"http://versioncheckr.com/38/".$addon_version."/\">Check for updates</a>)";


/**
* Only run when the template tag is found on page
*
*/
if(preg_match("<AJAX_RATE.*?>", $tpl)) {

/**
* Match ALL parameters, not just the first one
*
*
preg_match("/<AJAX_RATE\s*((.*?(<.*?>)?)*)\s*>/s", $tpl, $arg_string);
$arg_string = $arg_string[1];

while($arg_string != "") {

preg_match("/^(.*?)=('|\")?(.*?)\\2\s*(.*)$/s", $arg_string, $out);

$args[$out[1]] = $out[3];
$arg_string = $out[4];
}*/

/**
* Set defaults
*
*/
$stars = "5";
$imgwidth = "30";
$info = "on";
$thankyou = "on";


/**
* Get arguments if set. If not, use default
*
*
if($args['stars']) {
$stars = $args['stars'];
$stars = eregi_replace('[^0-9]+','',$stars);
}
if($args['img_width']) {
$imgwidth = $args['img_width'];
$imgwidth = eregi_replace('[^0-9]+','',$imgwidth);
}
if($args['rate_info']) {
$info = $args['rate_info'];
$info = eregi_replace('[^a-z]+','',$info);
}
if($args['thankyou']) {
$thankyou = $args['thankyou'];
$thankyou = eregi_replace('[^a-z]+','',$thankyou);
}*/


/**
* Determine what kind of rating info needs to be displayed
*
*/
if ($thankyou == "on" && $info == "on") { $info = "1"; } else if ($thankyou == "off" && $info == "on") { $info = "2"; } else if ($thankyou == "on" && $info == "off") { $info = "3"; } else { $info = "0"; }


/**
* Check to see if the ajaxRatings table exists, if not, create it
*
*/
$query = mysql_query("SELECT `total_votes` FROM `".$pixelpost_db_prefix."ajaxRatings` LIMIT 1");

if (!$query) { mysql_query("CREATE TABLE `".$pixelpost_db_prefix."ajaxRatings` (`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(id),`img_id` INT(11) NOT NULL,`total_votes` INT(11) NOT NULL,`total_value` INT(11) NOT NULL,`used_ips` LONGTEXT NOT NULL)") or die(" Error: ".mysql_error()); }


$ip = $_SERVER['REMOTE_ADDR'];

$query = mysql_query("SELECT * FROM `".$pixelpost_db_prefix."ajaxRatings` WHERE `img_id` = '$image_id'");

if (!mysql_num_rows($query)) {

$query = mysql_query("INSERT INTO `".$pixelpost_db_prefix."ajaxRatings` (`img_id`, `total_votes`, `total_value`, `used_ips`) VALUES ('$image_id', '0', '0', '')");
$query = mysql_query("SELECT * FROM `".$pixelpost_db_prefix."ajaxRatings` WHERE `img_id` = '$image_id'");
}

$row = mysql_fetch_assoc($query);

$count = $row['total_votes'];
$current_rating = $row['total_value'];

$total_votes = @number_format($current_rating/$count,1);

$tense = ($count == 1) ? "vote" : "votes";

$voted = mysql_num_rows(mysql_query("SELECT `used_ips` FROM `".$pixelpost_db_prefix."ajaxRatings` WHERE `used_ips` LIKE '%$ip%' AND `img_id` = '$image_id'"));

$ajax_rate = "
<div class=\"ratingblock\">
<div id=\"unit_long$image_id\" align=\"center\">

<ul id=\"unit_ul$image_id\" class=\"unit-rating\" style=\"width:".$imgwidth*$stars."px;\">

<li class=\"current-rating\" style=\"width:".@number_format($current_rating/$count,2)*$imgwidth."px;\">Currently ".@number_format($current_rating/$count,2)."/".$stars."></li>\n";

for ($ncount = 1; $ncount <= $stars; $ncount++) {

if(!$voted) { $ajax_rate .= "<li><a href=\"includes/ajaxRating/db.php?j=$ncount&amp;q=$image_id&amp;t=$ip&amp;c=$stars&amp;r=$inf o&amp;i=$imgwidth&amp;n=$vinfo_name\" class=\"r".$ncount."-unit rater\" rel=\"nofollow\">$ncount</a></li>\n"; }
}

$ncount = 0;

if ($info == "1" || $info == "2") { $info = "Rating: <strong>$total_votes</strong>/$stars ($count $tense cast)"; } else { $info = ""; }

$ajax_rate .= "
</ul>

$info

</div>
</div>";

$total_votes_ajax = "<div id=\"total_votes$image_id\">$total_votes</div>";

$total_votes_cast_ajax = "<div id=\"total_votes_cast$image_id\">$count $tense cast</div>";

/**
* Ajax Rate template tag
*
*
$tpl = preg_replace("/<AJAX_RATE\s*((.*?(<.*?>)?)*)\s*>/", $ajax_rate, $tpl);*/
$tpl = ereg_replace("<AJAX_RATE>", $ajax_rate, $tpl);

$tpl = ereg_replace("<TOTAL_VOTES_AJAX_RATE>",$total_votes_ajax,$tpl);

$tpl = ereg_replace("<TOTAL_VOTES_CAST_AJAX_RATE>",$total_votes_cast_ajax,$tpl);
}
?>


Use the template tags <AJAX_RATE> / <TOTAL_VOTES_AJAX_RATE> / <TOTAL_VOTES_CAST_AJAX_RATE>


I'm off to a concert now so report back and i'll check in the morning.

Good luck!

Dkozikowski
08-13-2007, 12:39 PM
Ubbe, I noticed you got the ratings to display. Was it because of the code changes i listed above?

I also noticed the lack of AJAXy goodness. Try placing the JS code right before the </head> tag or at least after all the other JS stuff. I think there might be a conflict with some prototype / mootools stuff and i'll update that in the next release.

Ubbe
08-13-2007, 01:32 PM
Ubbe, I noticed you got the ratings to display. Was it because of the code changes i listed above?

I also noticed the lack of AJAXy goodness. Try placing the JS code right before the </head> tag or at least after all the other JS stuff. I think there might be a conflict with some prototype / mootools stuff and i'll update that in the next release.

Yep the code above made the difference.

I tried placing the scripts as the last things now.

Dkozikowski
08-13-2007, 02:38 PM
Yep the code above made the difference.

I tried placing the scripts as the last things now.

Great, well everything seems to be working 100% for you now.

I need to get to the bottom of the regular expression issue though.


Since you are one of a handful of people experiencing problems, would you be willing to test for me or give me temporary FTP access so i can test out various modifications?

I'm going to private message you some test code to try, if you don't mind that is.

[Edit]
Scratch the private message. The message was too long so it wouldn't send.

If you can, replace your current working code with the following.

If the following fails to work, just go back to using the old working code.

Let me know the outcome. Thanks!


<?php
/*

Written by: Dwilkinsjr
Written for: Pixelpost 1.6.0 www: http://www.pixelpost.org/
Based on: Unobtrusive AJAX Star Rating Bar ( http://www.masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar )
By: Ryan Masuga

<!--

__ _ ____ _ _
____/ / __(_) / /__(_)___ _____ (_)____
/ __ / | /| / / / / //_/ / __ \/ ___/ / / ___/ AJAX RATINGS v0.6
/ /_/ /| |/ |/ / / / ,< / / / / (__ ) / / / LAST UPDATED - AUG/12/2007
\__,_/ |__/|__/_/_/_/|_/_/_/ /_/____/_/ /_/
http://dwilkinsjr.com/___/


-->

Contact: dwilkinsjr@dwilkinsjr.com
Copyright (c) 2007 <http://wwww.dwilkinsjr.com>

License: http://www.gnu.org/copyleft/gpl.html

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 2
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.

*/

$addon_name = "<a name=\"ajaxRate\"></a>Ajax Ratings";
$addon_version = "0.6";
$addon_description = "Ajax Ratings allows your visitors to rate your photos based on a scale of 1 to 10 or anywhere in between using the power of degradable ajax.<br /><br />Please read the <a href=\"../includes/ajaxRating/readmeUserGuide.html\">Ajax Rating User Guide</a> for full installation and configuration instructions.<br /><br />New tag: <code>&lt;AJAX_RATE img_width=\"30px\" stars=\"5\" rate_info=\"on\" thankyou=\"on\"&gt;</code><br /><br />ADDON Author: Dwilkinsjr (<a href='http://www.dwilkinsjr.com/myaddons' target='_blank'>dwilkinsjr.com</a>) (<a href=\"http://versioncheckr.com/38/".$addon_version."/\">Check for updates</a>)";


/**
* Only run when the template tag is found on page
*
*/
if(preg_match("<AJAX_RATE.*?>", $tpl)) {

/**
* Match ALL parameters, not just the first one
*
*/
preg_match("/<AJAX_RATE\s*(.*?)\s*>/s", $tpl, $arg_string);/* preg_match("/<AJAX_RATE\s*((.*?(<.*?>)?)*)\s*>/s", $tpl, $arg_string); */
$arg_string = $arg_string[1];

echo '<pre>';
var_dump($arg_string);
echo '</pre>';

while($arg_string != "") {

preg_match("/^(.*?)=('|\")?(.*?)\\2\s*(.*)$/s", $arg_string, $out);

$args[$out[1]] = $out[3];
$arg_string = $out[4];
}

echo '<pre>';
var_dump($args);
echo '</pre>';

/**
* Set defaults
*
*/
$stars = "5";
$imgwidth = "30";
$info = "on";
$thankyou = "on";


/**
* Get arguments if set. If not, use default
*
*/
if($args['stars']) {
$stars = $args['stars'];
$stars = eregi_replace('[^0-9]+','',$stars);
}
if($args['img_width']) {
$imgwidth = $args['img_width'];
$imgwidth = eregi_replace('[^0-9]+','',$imgwidth);
}
if($args['rate_info']) {
$info = $args['rate_info'];
$info = eregi_replace('[^a-z]+','',$info);
}
if($args['thankyou']) {
$thankyou = $args['thankyou'];
$thankyou = eregi_replace('[^a-z]+','',$thankyou);
}


/**
* Determine what kind of rating info needs to be displayed
*
*/
if ($thankyou == "on" && $info == "on") { $info = "1"; } else if ($thankyou == "off" && $info == "on") { $info = "2"; } else if ($thankyou == "on" && $info == "off") { $info = "3"; } else { $info = "0"; }


/**
* Check to see if the ajaxRatings table exists, if not, create it
*
*/
$query = mysql_query("SELECT `total_votes` FROM `".$pixelpost_db_prefix."ajaxRatings` LIMIT 1");

if (!$query) { mysql_query("CREATE TABLE `".$pixelpost_db_prefix."ajaxRatings` (`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(id),`img_id` INT(11) NOT NULL,`total_votes` INT(11) NOT NULL,`total_value` INT(11) NOT NULL,`used_ips` LONGTEXT NOT NULL)") or die(" Error: ".mysql_error()); }


$ip = $_SERVER['REMOTE_ADDR'];

$query = mysql_query("SELECT * FROM `".$pixelpost_db_prefix."ajaxRatings` WHERE `img_id` = '$image_id'");

if (!mysql_num_rows($query)) {

$query = mysql_query("INSERT INTO `".$pixelpost_db_prefix."ajaxRatings` (`img_id`, `total_votes`, `total_value`, `used_ips`) VALUES ('$image_id', '0', '0', '')");
$query = mysql_query("SELECT * FROM `".$pixelpost_db_prefix."ajaxRatings` WHERE `img_id` = '$image_id'");
}

$row = mysql_fetch_assoc($query);

$count = $row['total_votes'];
$current_rating = $row['total_value'];

$total_votes = @number_format($current_rating/$count,1);

$tense = ($count == 1) ? "vote" : "votes";

$voted = mysql_num_rows(mysql_query("SELECT `used_ips` FROM `".$pixelpost_db_prefix."ajaxRatings` WHERE `used_ips` LIKE '%$ip%' AND `img_id` = '$image_id'"));

$ajax_rate = "
<div class=\"ratingblock\">
<div id=\"unit_long$image_id\" align=\"center\">

<ul id=\"unit_ul$image_id\" class=\"unit-rating\" style=\"width:".$imgwidth*$stars."px;\">

<li class=\"current-rating\" style=\"width:".@number_format($current_rating/$count,2)*$imgwidth."px;\">Currently ".@number_format($current_rating/$count,2)."/".$stars."></li>\n";

for ($ncount = 1; $ncount <= $stars; $ncount++) {

if(!$voted) { $ajax_rate .= "<li><a href=\"includes/ajaxRating/db.php?j=$ncount&amp;q=$image_id&amp;t=$ip&amp;c=$stars&amp;r=$inf o&amp;i=$imgwidth&amp;n=$vinfo_name\" class=\"r".$ncount."-unit rater\" rel=\"nofollow\">$ncount</a></li>\n"; }
}

$ncount = 0;

if ($info == "1" || $info == "2") { $info = "Rating: <strong>$total_votes</strong>/$stars ($count $tense cast)"; } else { $info = ""; }

$ajax_rate .= "
</ul>

$info

</div>
</div>";

$total_votes_ajax = "<div id=\"total_votes$image_id\">$total_votes</div>";

$total_votes_cast_ajax = "<div id=\"total_votes_cast$image_id\">$count $tense cast</div>";

/**
* Ajax Rate template tag
*
*/
$tpl = preg_replace("/<AJAX_RATE\s*(.*?)\s*>/", $ajax_rate, $tpl);
/* $tpl = preg_replace("/<AJAX_RATE\s*((.*?(<.*?>)?)*)\s*>/", $ajax_rate, $tpl); */

$tpl = ereg_replace("<TOTAL_VOTES_AJAX_RATE>",$total_votes_ajax,$tpl);

$tpl = ereg_replace("<TOTAL_VOTES_CAST_AJAX_RATE>",$total_votes_cast_ajax,$tpl);
}
?>

Ubbe
08-13-2007, 03:32 PM
With the new code I get:
--------

string(0) ""

NULL

--------
In the top of the page

Dkozikowski
08-13-2007, 04:20 PM
Ok, thanks. Thats a huge help. Dose the rating system still work though? It should but if not I'll keep working on it.

Just so you can see for yourself, using the "newer" code, place the original template tag within your image_template.html file:

<AJAX_RATE stars="5" img_width="30px" rateinfo="on" thankyou="on">

Now, refresh your page and you should see something like this:


string(54) "stars="5" img_width="30px" rateinfo="on" thankyou="on""
array(4) {
["stars"]=>
string(1) "5"
["img_width"]=>
string(4) "30px"
["rateinfo"]=>
string(2) "on"
["thankyou"]=>
string(2) "on"
}


If you do and the rating system continues to function, we've fixed the problem!

If it's fixed, continue to use the code until i release a patched version. You may remove the following 2 code blocks so the output does not show on your page.

Find and delete:

echo '<pre>';
var_dump($arg_string);
echo '</pre>';

and

echo '<pre>';
var_dump($args);
echo '</pre>';


But, if it does not work, please create a file called info.php and inside place the following:


<?php phpinfo(); ?>


Upload this to your server and point your browser to this file.

Do a search for PCRE on this page and paste the results here.

Once you have done this, remove the info.php file from your web server.

Ubbe
08-15-2007, 12:44 PM
works fine

Dkozikowski
08-15-2007, 04:21 PM
works fine

I am relieved! I'll be updating all my addons that use the old regex.

Thank you for all your help. It's been invaluable.

Cheers!

Ubbe
08-15-2007, 09:18 PM
I am relieved! I'll be updating all my addons that use the old regex.

Thank you for all your help. It's been invaluable.

Cheers!

Thank you for your addon :D

Dkozikowski
08-16-2007, 03:59 PM
http://dwilkinsjr.com/public/pixelpost/forumFiles/ajaxRate/3bigStars.jpg
AJAX RATINGS v0.7

Last updated on: August 16th, 2007

VERSION HISTORY

Key:

[!]Important
[+]New
[-]Fixed error
Changes



Version 0.7

[-]Fixed the regular expression that was causing some people's photoblogs to cease proper functionality.
Updated the javascript functions to help avoid conflict between mootools and prototype packages.
[+]Added function to admin_ajax_ratings.php that removes the rating info from the database upon image deletion.
Updated User Guide



DOWNLOAD

Download:

Ajax Ratings v0.7 (http://dwilkinsjr.com/public/pixelpost/myaddons/ajax_ratings_v0.7.zip)



Donate:

Help keep this and other addons current (https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=dwilkinsjr%40dwilkinsjr%2ecom&item_name=Dwilkinsjr%27s%20Pixelpost%20Addons&page_style=PayPal&no_shipping=1&return=http%3a%2f%2fdwilkinsjr%2ecom%2fdonation%2f thankyou%2f&cancel_return=http%3a%2f%2fdwilkinsjr%2ecom%2fdona tion%2fcancel%2f&no_note=1&cn=Comments&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8)

Josef Renklint
08-19-2007, 09:45 AM
My javascript behaves very oddly...

the rating works fine, it saves the rating data and everything, but somethings wrong with the javascript or something. The stars "jump" whenever I move the mouse over the stars. Unfortunately I can't upload a screenshot of how it looks, but if someone could help me I would be very thankful.

Thanks,

Josef

Dkozikowski
08-19-2007, 10:57 PM
This is not a javascript issue.

It's most likely a CSS issue where you have changed the default stars for something else or something smaller.

Please provide me with a link so I can see for myself.

Josef Renklint
08-20-2007, 05:52 PM
Here's a link showing the error.

http://www.fotografiker.se/test/

Dkozikowski
08-21-2007, 04:23 AM
OK. It's definitely a CSS issue. First try placing the template tag outside the div it's in right now.

This is your current code:

<a href="index.php?showimage=<IMAGE_PREVIOUS_ID>">
<img src="images/<IMAGE_NAME>" alt="<IMAGE_TITLE>" title="<IMAGE_TITLE>" width="<IMAGE_WIDTH>" height="<IMAGE_HEIGHT>" id="photo" />
</a>

<div id="image-navigate">
<span class="image-previous"><IMAGE_PREVIOUS_LINK></span>
<AJAX_RATE stars="5" img_width="30px" rateinfo="on" thankyou="on">
<span class="image-next"><IMAGE_NEXT_LINK></span>
</div>


try:


<a href="index.php?showimage=<IMAGE_PREVIOUS_ID>">
<img src="images/<IMAGE_NAME>" alt="<IMAGE_TITLE>" title="<IMAGE_TITLE>" width="<IMAGE_WIDTH>" height="<IMAGE_HEIGHT>" id="photo" />
</a>

<AJAX_RATE stars="5" img_width="30px" rateinfo="on" thankyou="on">

<div id="image-navigate">
<span class="image-previous"><IMAGE_PREVIOUS_LINK></span>
<span class="image-next"><IMAGE_NEXT_LINK></span>
</div>


If this works and the placement is not where you want it. You'll have to play with the CSS file(s) to get the positioning right.

Zenigata
08-21-2007, 07:37 PM
Hi,
I have a 404 error following this link I've found in Ajax Ratings User Guide:

http://dwilkinsjr.com/public/pixelpost/forumFiles/ajaxRate/utilities/csscalc.php

Dkozikowski
08-21-2007, 10:23 PM
Thankyou for pointing that out, but the utilities are not available on my site. If you uploaded the ajax rating files correctly, the user guide and utilities will be available to you.

Login to your admin panel, goto the addons pane and find the ajax ratings addon. You will see a link to the user guide and within the guide you will find links to the utilities.

Zenigata
08-21-2007, 11:06 PM
Found, thanks.

Zenigata
08-22-2007, 12:37 AM
Great addon: just tested in my template with my own gif.

kitkit201
08-24-2007, 07:11 PM
I was about to post a message saying that your dbsync wasn't working, but i realized that it wasn't working because you have to first load a page with the <AJAX_RATE> on it first. Then go to the Dbsync page in utilities and run that and it works from there..

Hope that helps someone.. thanks for doing this! :)

Zenigata
09-03-2007, 12:46 AM
Hi,
I want to translate the displayed words in my language (italian).

I've changed Thanks for voting in Grazie per avere votato! but I can't find how to change the words Rating and votes cast.

Please help me, thanks.

Dkozikowski
09-03-2007, 07:09 AM
OK. Here are the code snippets you need to look for. Open each file listed, search for the text provided and make your changes.

I might make this multilingual right out of the box when i have time.


in addons/ajax_ratings.php


$tense = ($count == 1) ? "vote" : "votes";


Currently ".@number_format


$info = "Rating:


in includes/ajaxRating/rpc.php


$tense = ($count == 1) ? "vote" : "votes";


Current rating.</li>


<span id=\"voted\">Rating:


".$tense." cast)<br />


<span id=\"thanks\">Thanks for voting


<span id=\"shame\">Shame on you".$name."! No double voting!</span>

Zenigata
09-03-2007, 09:42 AM
Thanks, now it works!

knel
09-07-2007, 03:19 PM
I'm having a problem, the Ajax Rating addon shows more boxes than it should... Any idea?

You can check the problem here:

www.canelson.com.ar/pixelpost


Thanks!

Finner
09-08-2007, 07:39 AM
Very nice! Clear instructions and easy to get working.
Got my own gif working with it well too - thanks for this..!

If you want to see my results - http://oculus.farfromreal.com

Dkozikowski
09-08-2007, 06:29 PM
I'm having a problem, the Ajax Rating addon shows more boxes than it should... Any idea?

You can check the problem here:

www.canelson.com.ar/pixelpost


Thanks!


You are using the standard template tag. You cannot use the standard tag when using the 14px rating block css file.

Change <AJAX_RATE> to <AJAX_RATE stars="5" width="14px">

For future reference, please refer to the documentation.

Dkozikowski
09-08-2007, 06:31 PM
Very nice! Clear instructions and easy to get working.
Got my own gif working with it well too - thanks for this..!

If you want to see my results - http://oculus.farfromreal.com

Well done. :)

Dkozikowski
09-11-2007, 07:54 AM
I am requesting the help of others with multilingual capabilities.

If you are capable of translating a few words from english to your native tongue, please see the list bellow and post your translation in the same order as seen bellow.

Thank you.


vote
votes
cast
Current rating
Currently
Rating:
Thanks for voting
Shame on you
No double voting
Rating deleted
Rating removal

Dkozikowski
09-12-2007, 01:41 AM
Polish, Italian, and Dutch languages have been submitted. German and any others would be appreciated.

Dkozikowski
09-12-2007, 06:10 AM
Sorry, for those who already translated, 2 were left out of the list above earlier.

If you could kindly translate these last two it would be appreciated.


Rating deleted
Rating removal


Thank you.

Dkozikowski
11-24-2007, 06:54 AM
http://dwilkinsjr.com/public/pixelpost/forumFiles/ajaxRate/3bigStars.jpg
AJAX RATINGS v1.0

Last updated on: November 24th, 2007

VERSION HISTORY

Key:

[!]Important
[+]New
[-]Fixed error
Changes



Version 1.0

[+] Multilingual capable (user and admin supported).
[+] Added ajax_rating_statistics.php addon which allows you to display Top/Worst/Most/Least rated images.
Code cleanup.
[!] Jumped to version 1.0.



REQUIRES

Requirements:

Pixelpost v1.7 RC1 or better



DOWNLOAD

Download:

Ajax Ratings v1.0 (http://www.pixelpost.org/extend/addons/ajax-photo-ratings/)



Donate:

Help keep this and other addons current (https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=dwilkinsjr%40dwilkinsjr%2ecom&item_name=Dwilkinsjr%27s%20Pixelpost%20Addons&page_style=PayPal&no_shipping=1&return=http%3a%2f%2fdwilkinsjr%2ecom%2fdonation%2f thankyou%2f&cancel_return=http%3a%2f%2fdwilkinsjr%2ecom%2fdona tion%2fcancel%2f&no_note=1&cn=Comments&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8)




http://dwilkinsjr.com/public/pixelpost/forumFiles/warning.png

READ THE MANUAL

If you are upgrading:

This update uses Pixelpost's v1.7 addon schema and therefor, you will need to remove old files and folders and update your template files to point the CSS and Javascript files to the correct directory.

wjarosz
01-05-2008, 12:03 AM
Great addon! I've been using it for a while and just recently upgraded to 1.7 RC1 so that I could use the statistics feature in the 1.0 release. I was able to create a "top rated" and "most rated" page (e.g. http://graphics.ucsd.edu/~wjarosz/photoblog/index.php?x=most_rated) using the provided examples, but "worst rated" and "least rated" don't seem to work for me (e.g. http://graphics.ucsd.edu/~wjarosz/photoblog/index.php?x=worst_rated). Using these options results in no output, regardless of the style used. Is this a known bug, a problem with my configuration, or am I not doing something correctly? Thanks.

wjarosz
01-05-2008, 12:08 AM
I was wondering if you would consider making the source files (.psd I presume?) of your rating graphics (stars, blocks, etc) available as part of the downloadable package? This would be useful for creating slightly modified versions of the stars, for instance with a different background color, or transparent background, etc.

Dkozikowski
01-05-2008, 01:24 AM
Great addon! I've been using it for a while and just recently upgraded to 1.7 RC1 so that I could use the statistics feature in the 1.0 release. I was able to create a "top rated" and "most rated" page (e.g. http://graphics.ucsd.edu/~wjarosz/photoblog/index.php?x=most_rated) using the provided examples, but "worst rated" and "least rated" don't seem to work for me (e.g. http://graphics.ucsd.edu/~wjarosz/photoblog/index.php?x=worst_rated). Using these options results in no output, regardless of the style used. Is this a known bug, a problem with my configuration, or am I not doing something correctly? Thanks.

There shouldn't be any bugs.

Try removing the space within the template tag between worst rated like so:

mode="worstrated"

Does this help?

Dkozikowski
01-05-2008, 01:26 AM
I was wondering if you would consider making the source files (.psd I presume?) of your rating graphics (stars, blocks, etc) available as part of the downloadable package? This would be useful for creating slightly modified versions of the stars, for instance with a different background color, or transparent background, etc.

I would love too but the Ajax Ratings Addon is based off Ryan Masuga's (http://www.masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar/) rating system. Therefor, his rating stars are being used which a PSD is unavailable for.

wjarosz
01-05-2008, 02:02 AM
For the "top rated" photos, when several photos have the same rating, is it possible to do a secondary sort based on number of votes? For instance, if we have the following images:
Photo A 3.0/5.0 (4 vote)
Photo B 5.0/5.0 (3 votes)
Photo C 4.8/5.0 (2 votes)
Photo D 5.0/5.0 (2 votes)

I would expect the "top rated" photos to be sorted as follows:
Photo B 5.0/5.0 (3 votes)
Photo D 5.0/5.0 (2 votes)
Photo C 4.8/5.0 (2 votes)
Photo A 3.0/5.0 (4 vote)

wjarosz
01-05-2008, 02:07 AM
Removing the space makes no difference.

Dkozikowski
01-05-2008, 02:35 AM
Thank you for the suggestion. I'll see what I can do.

As for the other issue, let me look over the code and do some tests.

Dkozikowski
01-05-2008, 03:01 AM
OK, I looked over the code and did some tests and I cannot reproduce the Worst Rated problem you seem to be experiencing. I even took the worst rated template tag right from your template source and tried that un-modified with my local rating stats addon and it produced code.

Maybe try re-uploading the stats addon or compare your code to mine:


<?php
/*

Written by: Dwilkinsjr
Written for: Pixelpost 1.7 www: http://www.pixelpost.org/


<!--

__ _ ____ _ _
____/ / __(_) / /__(_)___ _____ (_)____
/ __ / | /| / / / / //_/ / __ \/ ___/ / / ___/ AJAX RATING STATISTICS v0.5
/ /_/ /| |/ |/ / / / ,< / / / / (__ ) / / / LAST UPDATED - NOV/24/2007
\__,_/ |__/|__/_/_/_/|_/_/_/ /_/____/_/ /_/
http://dwilkinsjr.com/___/


-->

Contact: dwilkinsjr@dwilkinsjr.com
Copyright (c) 2007 <http://wwww.dwilkinsjr.com>

License: http://www.gnu.org/copyleft/gpl.html

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 2
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.

*/

$addon_name = "Ajax Rating Statistics";
$addon_version = "0.5";
$addon_description = "Ajax Rating Statistics allows your visitors to quickly view your top rated, worst rated, least rated, and most rated photos.<br /><br />Please read the <a href=\"../addons/_ajaxratings/ajax_ratings/docs/ratingStatisticsManual.html\">AjaxRating Statistics</a> User Guide for full configuration instructions.<br /><br />New Tag: <code>&lt;AJAX_RATING_STATS stars=\"5\" max=\"10\" style=\"table\" mode=\"top rated\"&gt;</code><br /><br />ADDON Author: Dwilkinsjr (<a href='http://www.dwilkinsjr.com/myaddons' target='_blank'>dwilkinsjr.com</a>) (<a href=\"http://versioncheckr.com/43/".$addon_version."/\">Check for updates</a>) (<a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=dwilkinsjr%40dwilkinsjr%2ecom&item_name=Dwilkinsjr%27s%20Pixelpost%20Addons&page_style=PayPal&no_shipping=1&return=http%3a%2f%2fdwilkinsjr%2ecom%2fdonation%2f thankyou%2f&cancel_return=http%3a%2f%2fdwilkinsjr%2ecom%2fdona tion%2fcancel%2f&no_note=1&cn=Comments&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8\">Donate</a>)";


/**
* Only run when the template tag is found on the page
*
*/
if(preg_match("<AJAX_RATING_STATS.*?>", $tpl)){


/**
* Match ALL tags, not just the first one
*
*/
preg_match_all("/<AJAX_RATING_STATS\s*(.*?)\s*>/s", $tpl, $tags);
$tags = $tags[1];
$i = 0;

foreach($tags as $arg_string){

/**
* Reset the arguments for each tag
*
*/
$args = '';
while($arg_string != ""){
preg_match("/^(.*?)=('|\")?(.*?)\\2\s*(.*)$/s", $arg_string, $out);

$args[$out[1]] = $out[3];
$arg_string = $out[4];
}


/**
* Set defaults
*
*/
$stars = "5";
$max = "5";
$style = "table";
$mode = "toprated";
$lang = "auto";


/**
* Get arguments if set. If not, use default
*
*/
if($args['stars']){
$stars = $args['stars'];
$stars = eregi_replace('[^0-9]+','',$stars);
}
if($args['max']){
$max = $args['max'];
$max = eregi_replace('[^0-9]+','',$max);
}
if($args['style']){
$style = $args['style'];
$style = eregi_replace('[^a-z]+','',$style);
}
if($args['mode']){
$mode = $args['mode'];
$mode = eregi_replace('[^a-z]+','',$mode);
}
if($args['language']){
$lang = $args['language'];
$lang = eregi_replace('[^a-z]+','',$lang);
}


/**
* Use whatever language the pixelpost users chooses
* (harnesses pixelposts multilingual capabilities)
*
* If no language file is found, english will default
*
*/
if($lang == "auto"){ $lang = strtolower($language_abr); }

/**
* Determine the language file to be used based on the $lang variable
*
* If no language file is present or found, use the defaults
*
*/
if(file_exists("addons/_ajaxratings/ajax_ratings/language/lang-rate-".$lang.".php")){

require_once("addons/_ajaxratings/ajax_ratings/language/lang-rate-".$lang.".php");

}else{

if(file_exists("addons/_ajaxratings/ajax_ratings/language/lang-rate-en.php")){

require_once("addons/_ajaxratings/ajax_ratings/language/lang-rate-en.php");

}else{

/**
* Language defaults (en)
*
*/
$ajax_rate_lang['lang_vote'] = "vote";
$ajax_rate_lang['lang_votes'] = "votes";
$ajax_rate_lang['lang_votes_cast'] = "cast";

}
}


$top_ajax_rate = "";

if($style == "text"){ $top_ajax_rate = "<ul class=\"top_rated\">"; }

if($mode == "toprated" OR $mode == "worstrated"){

if($mode == "toprated"){ $order = "DESC"; }else{ $order = "ASC"; }

$order_by = "total_rate";

}elseif($mode == "mostrated" OR $mode == "leastrated"){

if($mode == "mostrated"){ $order = "DESC"; }else{ $order = "ASC"; }

$order_by = "total_votes";

}


$query = mysql_query("SELECT `".$pixelpost_db_prefix."ajaxRatings`.*, `".$pixelpost_db_prefix."pixelpost`.*

FROM `".$pixelpost_db_prefix."ajaxRatings`

INNER JOIN `".$pixelpost_db_prefix."pixelpost` ON `".$pixelpost_db_prefix."pixelpost`.`id` = `".$pixelpost_db_prefix."ajaxRatings`.`img_id`

WHERE `".$pixelpost_db_prefix."pixelpost`.`datetime` <= '$cdate'

ORDER BY `".$pixelpost_db_prefix."ajaxRatings`.`$order_by` $order

LIMIT 0,$max");

while($row = mysql_fetch_array($query)){

$count = $row['total_votes'];
$current_rating = $row['total_value'];
$total_votes = $row['total_rate'];
$tense = ($count == 1) ? $ajax_rate_lang['lang_vote'] : $ajax_rate_lang['lang_votes'];

$headline = pullout($row['headline']);
$headline = htmlspecialchars($headline,ENT_QUOTES);

$img_id = $row['id'];
$image = $row['image'];

$thumb_path = str_replace("../", "", $cfgrow['thumbnailpath']);
$thumbnail = "{$thumb_path}/thumb_$image";

if($count != 0){

if($style == "text"){

$top_ajax_rate .= "<li class=\"top_rated\"><a href=\"./index.php?showimage=$img_id\">$headline</a> $total_votes/$stars ($count $tense {$ajax_rate_lang['lang_votes_cast']})</li>";

}elseif($style == "table"){

$top_ajax_rate .= "
<table border=\"0\" cellspacing=\"3\" cellpadding=\"0\" summary=\"Top Rated Photos\">
<tr>
<td><a href=\"./index.php?showimage=$img_id\"><img src=\"$thumbnail\" alt=\"$headline\" title=\"$total_votes/$stars ($count $tense {$ajax_rate_lang['lang_votes_cast']})\" class=\"thumbnails\" /></a></td>
<td><span class=\"headline\">$headline</span><br /><br /><span class=\"votes\">$total_votes/$stars ($count $tense {$ajax_rate_lang['lang_votes_cast']})</span></td>
</tr>
</table>";
}
}
}


if($style == "text"){ $top_ajax_rate .= "</ul>"; }


/**
* Only replace ONE!
*
*/
$tpl = preg_replace("/<AJAX_RATING_STATS\s*(.*?)\s*>/", $top_ajax_rate, $tpl,1);

$i++;
}
}
?>

wjarosz
01-05-2008, 07:25 AM
I compared the code you pasted with the one in my pixelpost installation. They are identical except for some minor whitespace differences. I tried your version and it makes no difference.

Could this be because some of my images have no rating at all?

wjarosz
01-07-2008, 06:58 PM
After looking through the code, I think this problem may in fact be because some of my images have no rating at all.

While troubleshooting this I noticed that if I set the max parameter to a large value, I do get a list of my worst image. The problem is, however, that the addon first queries for "max" entries, but while iterating through them it skips images that have no votes cast yet. This means that if there are at least as many images with no votes as the max parameter then there will be no output.

I can hack the php by myself, but I am definitely a php/mysql beginner so it would just be a hack. I'm guessing there is a way to restrict the query in the first place, instead of omitting results after the fact. How would I go about doing that?

Dkozikowski
01-07-2008, 09:05 PM
I'll look into it ASAP.

Dkozikowski
01-08-2008, 03:56 AM
Here you go my friend.

I'm not ready to update the extend section just yet so use the following code to replace the old addon code completely.


<?php
/*

Written by: Dwilkinsjr
Written for: Pixelpost 1.7 www: http://www.pixelpost.org/


<!--

__ _ ____ _ _
____/ / __(_) / /__(_)___ _____ (_)____
/ __ / | /| / / / / //_/ / __ \/ ___/ / / ___/ AJAX RATING STATISTICS v0.6
/ /_/ /| |/ |/ / / / ,< / / / / (__ ) / / / LAST UPDATED - JAN/8/2008
\__,_/ |__/|__/_/_/_/|_/_/_/ /_/____/_/ /_/
http://dwilkinsjr.com/___/


-->

Contact: dwilkinsjr@dwilkinsjr.com
Copyright (c) 2008 <http://wwww.dwilkinsjr.com>

License: http://www.gnu.org/copyleft/gpl.html

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 2
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.

*/

$addon_name = "Ajax Rating Statistics";
$addon_version = "0.6";
$addon_description = "Ajax Rating Statistics allows your visitors to quickly view your top rated, worst rated, least rated, and most rated photos.<br /><br />Please read the <a href=\"../addons/_ajaxratings/ajax_ratings/docs/ratingStatisticsManual.html\">AjaxRating Statistics</a> User Guide for full configuration instructions.<br /><br />New Tag: <code>&lt;AJAX_RATING_STATS stars=\"5\" max=\"10\" style=\"table\" mode=\"top rated\"&gt;</code><br /><br />ADDON Author: Dwilkinsjr (<a href='http://www.dwilkinsjr.com/myaddons' target='_blank'>dwilkinsjr.com</a>) (<a href=\"http://versioncheckr.com/43/".$addon_version."/\">Check for updates</a>) (<a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=dwilkinsjr%40dwilkinsjr%2ecom&item_name=Dwilkinsjr%27s%20Pixelpost%20Addons&page_style=PayPal&no_shipping=1&return=http%3a%2f%2fdwilkinsjr%2ecom%2fdonation%2f thankyou%2f&cancel_return=http%3a%2f%2fdwilkinsjr%2ecom%2fdona tion%2fcancel%2f&no_note=1&cn=Comments&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8\">Donate</a>)";


/**
* Only run when the template tag is found on the page
*
*/
if(preg_match("<AJAX_RATING_STATS.*?>", $tpl)){


/**
* Match ALL tags, not just the first one
*
*/
preg_match_all("/<AJAX_RATING_STATS\s*(.*?)\s*>/s", $tpl, $tags);
$tags = $tags[1];
$i = 0;

foreach($tags as $arg_string){

/**
* Reset the arguments for each tag
*
*/
$args = '';
while($arg_string != ""){
preg_match("/^(.*?)=('|\")?(.*?)\\2\s*(.*)$/s", $arg_string, $out);

$args[$out[1]] = $out[3];
$arg_string = $out[4];
}


/**
* Set defaults
*
*/
$stars = "5";
$max = "5";
$style = "table";
$mode = "toprated";
$lang = "auto";


/**
* Get arguments if set. If not, use default
*
*/
if($args['stars']){
$stars = $args['stars'];
$stars = eregi_replace('[^0-9]+','',$stars);
}
if($args['max']){
$max = $args['max'];
$max = eregi_replace('[^0-9]+','',$max);
}
if($args['style']){
$style = $args['style'];
$style = eregi_replace('[^a-z]+','',$style);
}
if($args['mode']){
$mode = $args['mode'];
$mode = eregi_replace('[^a-z]+','',$mode);
}
if($args['language']){
$lang = $args['language'];
$lang = eregi_replace('[^a-z]+','',$lang);
}


/**
* Use whatever language the pixelpost users chooses
* (harnesses pixelposts multilingual capabilities)
*
* If no language file is found, english will default
*
*/
if($lang == "auto"){ $lang = strtolower($language_abr); }

/**
* Determine the language file to be used based on the $lang variable
*
* If no language file is present or found, use the defaults
*
*/
if(file_exists("addons/_ajaxratings/ajax_ratings/language/lang-rate-".$lang.".php")){

require_once("addons/_ajaxratings/ajax_ratings/language/lang-rate-".$lang.".php");

}else{

if(file_exists("addons/_ajaxratings/ajax_ratings/language/lang-rate-en.php")){

require_once("addons/_ajaxratings/ajax_ratings/language/lang-rate-en.php");

}else{

/**
* Language defaults (en)
*
*/
$ajax_rate_lang['lang_vote'] = "vote";
$ajax_rate_lang['lang_votes'] = "votes";
$ajax_rate_lang['lang_votes_cast'] = "cast";

}
}


$ajax_rate_stats = ($style == "text") ? '<ul class="top_rated">' : '<table border="0" cellspacing="3" cellpadding="0" summary="'.$mode.' photos">';


if($mode == "toprated" OR $mode == "worstrated"){

$order = ($mode == "toprated") ? "DESC" : "ASC";
$order_by = "total_rate";

}elseif($mode == "mostrated" OR $mode == "leastrated"){

$order = ($mode == "mostrated") ? "DESC" : "ASC";
$order_by = "total_votes";

}


$query = mysql_query("SELECT `".$pixelpost_db_prefix."ajaxRatings`.*, `".$pixelpost_db_prefix."pixelpost`.*

FROM `".$pixelpost_db_prefix."ajaxRatings`

INNER JOIN `".$pixelpost_db_prefix."pixelpost` ON `".$pixelpost_db_prefix."pixelpost`.`id` = `".$pixelpost_db_prefix."ajaxRatings`.`img_id`

WHERE `".$pixelpost_db_prefix."pixelpost`.`datetime` <= '$cdate'

ORDER BY `".$pixelpost_db_prefix."ajaxRatings`.`$order_by` $order

LIMIT 0,$max");


while($row = mysql_fetch_array($query)){

$current_rating = $row['total_value'];
$total_votes = $row['total_rate'];
$count = $row['total_votes'];

$tense = ($count == 1) ? $ajax_rate_lang['lang_vote'] : $ajax_rate_lang['lang_votes'];

$headline = pullout($row['headline']);
$headline = htmlspecialchars($headline,ENT_QUOTES);

$img_id = $row['id'];
$image = $row['image'];

$thumbnail = ltrim($cfgrow['thumbnailpath'], "./")."thumb_".$image;

if($style == "text"){

$ajax_rate_stats .= "\n<li class=\"top_rated\"><a href=\"./index.php?showimage=$img_id\">$headline</a> $total_votes/$stars ($count $tense {$ajax_rate_lang['lang_votes_cast']})</li>\n";

}elseif($style == "table"){

$ajax_rate_stats .= "\n<tr>\n<td><a href=\"./index.php?showimage=$img_id\"><img src=\"$thumbnail\" alt=\"$headline\" title=\"$total_votes/$stars ($count $tense {$ajax_rate_lang['lang_votes_cast']})\" class=\"thumbnails\" /></a></td><td><span class=\"headline\">$headline</span><br /><br /><span class=\"votes\">$total_votes/$stars ($count $tense {$ajax_rate_lang['lang_votes_cast']})</span></td>\n</tr>\n";
}

}


$ajax_rate_stats .= ($style == "text") ? "</ul>" : "</table>";


/**
* Only replace ONE!
*
*/
$tpl = preg_replace("/<AJAX_RATING_STATS\s*(.*?)\s*>/", $ajax_rate_stats, $tpl,1);

$i++;
}
}
?>

TunaFish
02-02-2008, 11:07 PM
Hi there I am playing around with your addon, but I can't seem to get the parameters from the template tag working...

<AJAX_RATE img_width="30px" rate_info="off" thankyou="off">

The stars show up with the default parameters, I can't change any.

Dkozikowski
02-02-2008, 11:23 PM
What are you trying to accomplish?

TunaFish
02-03-2008, 10:02 AM
Hi I just want to display the stars, without the rate info and thank you text etc.

I read in the manual about setting the parameters in the template tag like:
<AJAX_RATE img_width="30px" rate_info="off" thankyou="off">

but non of the options work.. it's the same as I would just do a default:
<AJAX_RATE img_width="30px">

my page writes the tag as:
<div class="ratingblock">
<div id="unit_long15" align="center">
<ul id="unit_ul15" class="unit-rating" style="width:150px;">
<li class="current-rating" style="width:120px;">Currently 4.00/5></li>
</ul>
Rating: <strong>4.0</strong>/5 (1 vote cast)
</div>
</div>

I could just edit your addon files, but wondering why the parameters don't work..

Dkozikowski
02-03-2008, 02:02 PM
That is odd.

Is your PHP install compiled with the PCRE extension? It should be.

Create a file called info.php using a simple text editor and place the following code inside:

<?php phpinfo(); ?>

Upload it and point your browser to the info.php file. Search the output for PCRE. It should be there if it is installed.

TunaFish
02-03-2008, 05:52 PM
Yeah, no that's not the problem.
The problem seems to be the template... it's the Supaclean one.
http://www.pixelpost.org/extend/templates/supaclean-template/

When I do a fresh install of Pixelpost with a fresh SupaClean template I can't get the "thankyou" parameter to work either.

I must been some name spacing conflicts between the two no?

Dkozikowski
02-03-2008, 07:51 PM
I'll have a look at soon. Thanks.

TunaFish
02-08-2008, 12:07 AM
Hi again, I finally traced the problem.
Whenever I have another javascript file that uses:

window.onload = function() {myFunction()};

I think the last JS file to use basically overwrites any previous assignment to window.onload. Not good.

Also you have used:

addLoadEvent : function(func) {
var oldonload = window.onload;

if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}

What can I do about this?
thanks

Dkozikowski
02-08-2008, 02:53 PM
I'll have a crack at changing the variable names to make it more compatible with other scripts. You can try the same if you wish.

I'll also be rewriting the script to use the MooTools framework in the next month or so.

ranmajen
05-29-2008, 01:33 AM
Hi, I have just installed the addon but i have encountered a very strange problem.

http://gallery.ranmajen.net/index.php?showimage=34&category=3

You can try to vote on this photo, but after voting, the votes of all photos are the same. Seems the vote is not for a particular photo. How come? I don't know if it is caused by the url modification with category or not.

And one more point is that, in the admin panel, all voting stat can not be updated, only 0 vote.

I love to have any advices or try any suggested solutions since I really want to have this addon installed.

Thanks.

Dkozikowski
05-29-2008, 02:25 PM
That is very strange and it must be due to the category mod. Do me a favor and reset the ratings using the provided Ratting Scrubber utility. This will remove all ratings from all pictures. Once you have done this post here and let me know.

ranmajen
05-29-2008, 05:47 PM
Done, I have reset already. Please let me know what I need to do. Thanks a lot.

ranmajen
06-09-2008, 04:09 PM
Any news?

Dkozikowski
06-09-2008, 04:19 PM
I have no explanation for what is happening. I'm puzzled.

Are any core pixelpost files modified? What addons do you have installed?

Do you experience the same results if you install the addon using the simple template with no additional addons?

ranmajen
06-11-2008, 05:02 AM
When I read the data in phpadmin, all votes go to Image ID 1 even I vote for other image ID.

Addons I have used:

Advanced Pixelpost Comment Stats
GeoS Show Category ADDON
Ajax Rating Statistics
Album View
CAPTCHA addon
Most Recent Comments
Page-By-Page-Archive for category and month
Pixelpost Copy Folder
Pixelpost Latest Addition
Set Different Entry Page
Top Commenters (Advanced)
Update EXIF

ranmajen
06-11-2008, 05:08 AM
The data in phpadmin shows:

id=1, img_id=0, total_votes=2

why img_id=0?

And I haven't modified the core files.

Dkozikowski
06-12-2008, 03:38 AM
There should not be an image id of 0.

You seem to know your way around phpmyadmin so please delete the ajaxRatings database table and allow the addon to create it again.

If this does not work then I will need FTP and Pixelpost Admin access to track down the issue. You can PM me those details if need be.

ranmajen
06-16-2008, 08:08 AM
I have deleted the database and let the addon create it again. Before voting, there is no record of img_id = 0, but after one vote, img id = 0 shows up. And that vote shows up on my every image and cannot vote again. Very strange.

ranmajen
06-18-2008, 06:37 AM
I think I have found a clue, here is the rating url of an image:

image url: http://gallery.ranmajen.net/index.php?showimage=37&category=3
rating url: gallery.ranmajen.net/addons/_ajaxratings/ajax_ratings/db.php?j=2&q=&t=xxx.xxx.xxx.xx&c=5&r=1&i=30&l=en&n=

there is no number for q, according to your db.php file, it should be id_sent

You can compare the rating url of the image in another pixelpost: http://graphics.ucsd.edu/~wjarosz/photoblog/index.php?showimage=91

So every time when I vote, the vote goes to no specific id, then the vote only has been added to the record of img_id=0 in the database. This explanation seems to make sense?

P.S. I have added "&category=x" to every image url, the rating problem may be the result of this modification?
But this modification only made for the template, no core files have been modified.

ranmajen
06-18-2008, 06:44 PM
One more information: the id in pixelpost table starts from 5, ie, the first photo does not start from 1. Don't know if this is related or not.

Besides, ajaxrating table seems created correctly with img_id starts from 5.

And I sent you a PM several days ago, did you receive it?

Dkozikowski
06-18-2008, 08:37 PM
Sorry, i've been extremely busy! I'll look into this as soon as possible. Good debug work.

Dkozikowski
06-19-2008, 12:43 AM
You're all set. One of your addons must be interfering with the $image_id variable or something has changed in your pixelpost version where the $image_id variable is not available to addons.

Luckily Pixelpost offers another way to access this var by using $imageid (underscore removed).

I rated a few of your photos randomly. You can use the supplied tools to reset the ratings.

ranmajen
06-19-2008, 04:01 AM
Yeah! Really thanks for your help!
You are so helpful :)

Then I can keep working on my pixelpost.

rathmannm
06-19-2008, 09:19 PM
Hi,

I've successfully installed your addon and everything is working fine - there's just one thing I could not work out - how do you actually change the colour of the "Rating: 0.0/5 (0 votes cast)" text below the actual stars? I've played around with the css file but no luck...

Thanks,
Manuel

Dkozikowski
06-20-2008, 02:57 AM
Send me a link to your site and I'll let you know what needs to be done.

rathmannm
06-20-2008, 06:52 AM
Hi,

thanks for your quick reply. I've included my photoblog url in my signature now :)

Thanks,
Manuel

Dkozikowski
06-20-2008, 07:19 AM
try adding your css to the .ratingblock class

rathmannm
06-20-2008, 11:33 AM
Thanks - that did the trick!

ranmajen
06-23-2008, 03:39 PM
I would like to know if I can show the following order for the top rated statistics:

1st: rating
2nd: number of votes

That means if the photos got the same rating, they will be ordered by number of votes. Could this be done?

Since the existing ordering only can be done by 1st condition.

Dkozikowski
06-24-2008, 03:43 PM
Try this code.

http://www.pixelpost.org/forum/showpost.php?p=53127&postcount=78

There was an issue similar to this before but I'm not 100% positive if I fixed it. That code above does contain other bug fixes though.
Let me know if the problem still exists. If it does I'll have a closer look at it.

TheMarco
06-28-2008, 03:52 PM
I have installed and customised the CSS for this plugin to play nice with my Dark Matter theme. However, it throws a JS error in Firefox after submitting a rating.

Here it is:

http://www.i-marco.nl/stuff/dmerr.jpg

Is this a bug or did I do something wrong?

Dkozikowski
06-28-2008, 06:32 PM
Does it still rate the image? I don't remember seeing that before.

Dkozikowski
06-28-2008, 06:34 PM
I just saw your post about editing the addon for your template. that error is a result of editing the addon to remove the extra info.

TheMarco
06-28-2008, 06:38 PM
I didn't edit the add-on in any way. All I did was change CSS.

TheMarco
06-28-2008, 06:39 PM
And, yes it does rate the image. It seems to work fine actually except for spitting out that error.

Dkozikowski
06-28-2008, 08:06 PM
i'll try to reproduce the error later and get back to you with my findings.

TheMarco
06-28-2008, 08:13 PM
Found the problem. It looks like the two optional tags:

<TOTAL_VOTES_AJAX_RATE> and <TOTAL_VOTES_CAST_AJAX_RATE>

are not as optional as the documentation says they are. When omitted, the Javascript breaks. I put them in and now things are working fine.

ranmajen
06-30-2008, 10:09 AM
Try this code.

http://www.pixelpost.org/forum/showpost.php?p=53127&postcount=78

There was an issue similar to this before but I'm not 100% positive if I fixed it. That code above does contain other bug fixes though.
Let me know if the problem still exists. If it does I'll have a closer look at it.


The result is the same, ie, with the same ranking as before. Cannot solve the problem.

1st: 5.0/5 (1 vote cast)

2nd: 5.0/5 (2 votes cast)

3rd: 5.0/5 (2 votes cast)


I want the ranking like this:

1st: 5.0/5 (2 votes cast)

2nd: 5.0/5 (2 votes cast)

3rd: 5.0/5 (1 vote cast)

Dkozikowski
06-30-2008, 03:04 PM
Try this.

Replace the old file with the one attached.

ranmajen
06-30-2008, 03:44 PM
Downloaded and replaced the original file but not ok.

You can see the right column of this page:
http://gallery.ranmajen.net/index.php?x=stat

3.0/5 has higher rank than 4.0 and 5.0

Dkozikowski
06-30-2008, 07:11 PM
Alright, I guess I'll have to actually fiddle around with the addon. I did not test the last update personally.

ranmajen
07-01-2008, 01:34 PM
Thanks a lot, wait for your update then :)

ranmajen
07-03-2008, 03:01 AM
Ok, I have got it:

ORDER BY `".$pixelpost_db_prefix."ajaxRatings`.`$order_by` $order, total_votes DESC LIMIT 0,$max");

Dkozikowski
07-03-2008, 03:50 AM
I have not had the time to look at the code yet. Way to many things going on right now. I'll confirm your solution a bit later.

Thanks for your detective work. It really helps ease up my heavy work-load.

ranmajen
07-03-2008, 04:46 AM
Actually, one of my friends suggests this solution to me.

Btw, I am still looking forward to your auto resize (to different window sizes) addon. This is the one I am eager to meet now :p

And really thanks for your help.

Dr.Ozdi
07-12-2008, 08:03 AM
I use for many months (few years?) customized "Image Rating v1.2" addon and "Ajax photo ratings" is seems to be more useful stronger tool.
Do anybody know if "Ajax photo ratings" can use vote datas from it?

Dkozikowski
07-12-2008, 08:07 AM
Yes, the ajax ratings addon comes with a utility to transfer over the ratings from this old addon by Robert: http://www.pixelpost.org/extend/addons/image-rating/

Take a look at the documentation and the db sync utility.

Dr.Ozdi
07-12-2008, 08:28 AM
Yes, thats it, I must install it right now :-)
Thanks

agmorpheus
08-04-2008, 07:46 PM
Hi,

first of all, great Plugin.

Now my problem which isn't really a problem :)
When someone hover over the area of the rating system that is showing best rating there is just the hint with the hand as mousecurser that the area is clickable. It would be better when each of the stars/boxes would change to semi transparent. How can I get this? Is it just CSS or also php work to do?

Sorry, for the bad english ;)

Dkozikowski
08-04-2008, 07:56 PM
CSS should do it

agmorpheus
08-04-2008, 08:00 PM
do you know how? Tried it allready but without success :(

Prahli
09-05-2008, 06:55 PM
Hi dwilkinsjr

Iīve got a problem and I donīt no how to fix it. Iīve tried so much. But with no result. But first, my Blog: http://www.prahli.de/photoblog
For now, itīs in the "building-phase". So thereīs not much.

The Problem: If I try to rate, the working-gif appears and nothing more happen. If I reload the page, there is no rating for the picture.

Here the things Iīve tried:
- changed the rights of the php-files up to 777
- checked the link of the rating (compared with an friendīs blog)
- installed it new (a few times)
- checked the db over phpmyadmin (table is ok)
- entered a value over phpmyadmin (appears as rating on the page)
- changed the template

Means, if I understand it right, the addon can read but not write.

Hope you can help me.

Greets Markus

Dkozikowski
09-06-2008, 03:47 PM
Try moving the ajax rating script / css inclusions to the end of the html header.

Open your image_template.html template file and find

<!-- AJAX RATINGS -->
<link rel="stylesheet" type="text/css" href="addons/_ajaxratings/ajax_ratings/css/rating-stars-30px.css" />
<script type="text/javascript" src="addons/_ajaxratings/ajax_ratings/js/behavior.js"></script>
<script type="text/javascript" src="addons/_ajaxratings/ajax_ratings/js/rating.js"></script>

and move it to just above the closing </head> tag.

Prahli
09-06-2008, 04:02 PM
There it is allready.

Tried also to disable all the other addons. But didnīt work.

Thank you for answering.

Greets

TunaFish
09-12-2008, 05:38 AM
Hi, I suspect that someone is constantly pulling my averages down by giving 1 star ratings. Can I find his IP address? Thanks

steff
09-12-2008, 10:30 AM
hi :)
I just installed this great addon, and successfully updated my database containing Prouse's ratings datas.
anyway I ask a little question: I use the Simple Template, and when I switch to Dark css, the star background remains white.
how can I do to get the same background color?
my photoblog: http://steff.altervista.org
cheers :)

siddr20
09-26-2008, 12:08 PM
Just installed this and works 100%

Just tricky trying to find the right place for the ajax tag.

Thanks once again!!!

Epimetheus
10-09-2008, 09:46 AM
I would also like to know how to modify this for a black background. Even if I modify the gif to black the mouse roll over makes it white.

JLDohm
10-30-2008, 04:49 PM
To Epimetheus:

The solution is to create an image with a transparent background. I am using 30px stars, but you should be able to modify this technique to work with something else.

Also note that this uses GIMP and not photoshop.

First open up rating-stars-30px.css and change all instances of star-30px.gif to star-30px.png.

then open up star-30px.gif with GIMP.

select image>>mode>>rgb

select Layer>>Transparency>>add alpha Channel

select Layer>>Transparency>>Color to Alpha
make sure white is the selected color and press ok

save your file as star-30px.png (the conversion to png can probably be avoided, but I kept loosing the empty star in the conversion)

upload all the new files.

enjoy

also note that working.gif already has a transparent background, so you should be OK there.

Epimetheus
11-05-2008, 05:32 PM
Thank you very much for the instructions! I have it now on my site: http://markuspuustinen.com/

hismuse
11-19-2008, 04:07 PM
I finally figured out how to make the stars small, now I need to make them so they have a black background. Help :D

Dennis
11-23-2008, 03:51 PM
read a view posts up (posting by JLDohm).

retrolaser
11-27-2008, 01:38 AM
First, congratulations for this beautiful addon! The documentation is ultra-complete, its easily customisable, has load of handy functions and it works great!
It is installed on this photoblog (http://butcrack.be). I'm simply using 1 star, i.e. "you like it or not". It's perfect.
One feature which would be cool is to be able to navigate directly the photos that made it on the rating_stats page. For example, i have a page which displays the 50 most rated photos. However, if i click on a thumbnail, and then want to see the next rated photo i have to go back to the rating_stats page and click on another one. It would be more user-friendly to be able to see the other rated photos by clicking previous/next on the detail page.
I know the same problem exists for categories though..
Anyways, keep up the good work!

Epimetheus
12-04-2008, 01:32 PM
I don’t understand how the statistics work. My top rated photos contains only photos which have only one vote. One picture for example has gotten five votes with maximum five stars but this picture is not included in the top rated. In my opinion picture with five votes is more top rated then picture with one vote if they have the same amount of stars.

Here's the statistics: http://markuspuustinen.com/index.php?x=rating_stats

maxomat
12-10-2008, 02:39 PM
I would like rate NOT photos, but albums, generated by Album View v1.2 (http://www.pixelpost.org/extend/addons/album-view/). Is it possible?

Please, help!

Thanks for any hacks and tips!

retrolaser
12-18-2008, 10:23 PM
It would be nice to have a "most recently rated" tag in the statistics module.

Finner
12-20-2008, 02:29 AM
Works nicely with multiple style sheets! - http://oculus.farfromreal.com

Question - is it supposed to update the number of votes when you submit your vote, or only on page refresh? If find the vote result updates, but not the number of votes submitted...

benlwong
12-21-2008, 10:48 PM
I am having the same problem as TunaFish reported earlier - my pics are getting rated 1 star all the time. I don't think it is a particular person doing this - but as another thread reported - it is most likely Yahoo! webcrawler crawling the links. See thread below for a more detailed explanation:

http://www.pixelpost.org/forum/showthread.php?t=792

Are other people having this problem? and does anyone have a solution?

Thanks,
Ben

Lafayette
01-16-2009, 07:04 PM
Hi,
I'm sorry i'm a new user of this addon and a new user of pixelpost in general. I' trying to use ajaxrating, i followed the instructions but it doesn't work. I don't know where i can put the code : <AJAX_RATE> is it the image_template file or in another one ?
Thank you.

EDIT : Finally I found the place for the tag : http://www.horizons.ovh.org/ (in construction) but it's not very nice...