forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Voting/Rating => Topic started by: SaWey on January 31, 2007, 10:00:28 am

Title: Nicer voting in cpg 1.x [Updated]
Post by: SaWey on January 31, 2007, 10:00:28 am
I've been working on the voting of cpg,
I thought it could use some new voting pic.

Edit:
Before you read any further, this has still a giant bug in it.
In Firefox everything works fine, but IE won't let you vote for the moment.
This is caused by the referer in the code in "ratepic.php" at line 39.
If you comment this out, it will work in both IE and Firefox, but be carefull:
If the referer isn't checked, it is possible to vote from another website!

Solution to this ex-problem can be found at the bottom

To intall this, follow these steps:

First of all, copy the attached files in there corresponding folders:
rating.js -> scripts/rating
new.gif -> images
full.gif -> images
empty.gif -> images

Then in your "template.html" add the following above the </head> tag:

Code: [Select]
<script type="text/javascript" src="scripts/rating/rating.js"></script>


And as a last change, in your "theme.php" file add the following code before "?>"

Code: [Select]
//Rating change
$template_image_rating = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
        <tr>
                <td colspan="6" class="tableh2_compact"><b>{TITLE}</b> {VOTES}</td>
        </tr>
        <tr>
                <td class="tableb_compact">{RATESCRIPT}</td>
        </tr>
</table>
EOT;
function theme_html_rating_box()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
    global $template_image_rating, $lang_rate_pic;

    if (!(USER_CAN_RATE_PICTURES && $CURRENT_ALBUM_DATA['votes'] == 'YES')) return '';

    $votes = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_rate_pic['rating'], round($CURRENT_PIC_DATA['pic_rating'] / 2000, 1), $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
    $pid = $CURRENT_PIC_DATA['pid'];

    if (defined('THEME_HAS_RATING_GRAPHICS')) {
        $location= $THEME_DIR;
    } else {
        $location= '';
    }

    $params = array('{TITLE}' => $lang_rate_pic['rate_this_pic'],

'{RATESCRIPT}' => '<script type="text/javascript" language="JavaScript">displayStars(' . round($CURRENT_PIC_DATA['pic_rating'] / 2000, 0) . ', ' . $pid . ', "");</script>',
        '{VOTES}' => $votes,
        '{WIDTH}' => $CONFIG['picture_table_width'],
        '{LOCATION}' => $location,        //theme dir or default images directory
        );

    return template_eval($template_image_rating, $params);
}

To escape the ex-problem in IE, just
Change the code in "ratepic.php" at line 39 to
Code: [Select]
// If referer is not displayimage.php we don't accept the vote
$referer = $_SERVER["HTTP_REFERER"];
if (!eregi("displayimage", $referer) & !($referer == "")){
    header('Location: displayimage.php?pos=' . (- $pic));
    exit;
}


Now it works.

Have fun.
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: alanuk on February 20, 2007, 11:04:33 pm
Hi

Thanks for this. It's really useful.

I've changed it for my site to allow me to use a 1 - 10 scale which was very easy to do.

Thanks again for making this available.

Alan
http://www.digital-imaging-associates.com (http://www.digital-imaging-associates.com)   
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: SaWey on February 20, 2007, 11:15:34 pm
I'm glad it's usefull!

Nice site BTW
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: SaWey on March 21, 2007, 12:27:41 am
I don't know if any moderator will see this, but if you do,
can't you place this topic in the mods-section (visuals or something)

Thanks
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: Joachim Müller on March 21, 2007, 09:26:33 am
It is (coppermine-gallery.net > No Support > Modifications/Add-Ons/Hacks > Mods: Voting/Rating). Nibbler moved it here. Shouldn't have gone into the bugs board in the first place imo.
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: bitcloud on May 26, 2007, 06:11:21 pm
hey there..

ah what does this actually do?
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: SaWey on May 26, 2007, 10:37:21 pm
This replaces the standard voting pictures with only one picture and adds some rollover effects.

You should try it,
It's realy nice.
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: bitcloud on May 27, 2007, 09:04:10 am
nice 1...

now we just need some kind of ajaxified voting and we're set! (so the page doesn't reload when you submit your vote)
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: zac on July 16, 2007, 10:01:34 am
Hiya SaWey... another great mod... I had it working fine on my site and then with my endless theme tweaking I managed to screw it up... now it returns the dreaded "selected album/file does not exist" message whenever a vote is cast.  I noticed that it changes from mysite/displayimage.php?album=#&pos=-# to mysite/displayimage.php?pos=-# (no album is identified).  Is the fix in the ratepic.php ? 

Thanks for any help with this.
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: mywedding on July 16, 2007, 10:57:45 am
And as a last change, in your "theme.php" file add the following code before "?>"


hi dears,

i did not change , rating , well, i have not "theme.php" like you , could you fix problem , many thx,

note: my "theme.php" is below

Code: [Select]

define('THEME_IS_XHTML10_TRANSITIONAL',1); // Remove this if you edit this template until
                                           // you have validated it. See docs/theme.htm.

// HTML template for template sys_menu spacer
$template_sys_menu_spacer ='<img src="themes/water_drop/images/orange_carret.gif" width="8" height="8" border="0" alt="" />';

?>
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: Joachim Müller on July 17, 2007, 09:19:25 am
If a function or var definition doesn't exist in your cutom theme, copy the corresponding section from the sample theme. In your case, paste
Code: [Select]
//Rating change
$template_image_rating = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
        <tr>
                <td colspan="6" class="tableh2_compact"><b>{TITLE}</b> {VOTES}</td>
        </tr>
        <tr>
                <td class="tableb_compact">{RATESCRIPT}</td>
        </tr>
</table>
EOT;
function theme_html_rating_box()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
    global $template_image_rating, $lang_rate_pic;

    if (!(USER_CAN_RATE_PICTURES && $CURRENT_ALBUM_DATA['votes'] == 'YES')) return '';

    $votes = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_rate_pic['rating'], round($CURRENT_PIC_DATA['pic_rating'] / 2000, 1), $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
    $pid = $CURRENT_PIC_DATA['pid'];

    if (defined('THEME_HAS_RATING_GRAPHICS')) {
        $location= $THEME_DIR;
    } else {
        $location= '';
    }

    $params = array('{TITLE}' => $lang_rate_pic['rate_this_pic'],

'{RATESCRIPT}' => '<script type="text/javascript" language="JavaScript">displayStars(' . round($CURRENT_PIC_DATA['pic_rating'] / 2000, 0) . ', ' . $pid . ', "");</script>',
        '{VOTES}' => $votes,
        '{WIDTH}' => $CONFIG['picture_table_width'],
        '{LOCATION}' => $location,        //theme dir or default images directory
        );

    return template_eval($template_image_rating, $params);
}
into a new line before
Code: [Select]
?>
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: SaWey on July 22, 2007, 11:21:48 am
Hiya SaWey... another great mod... I had it working fine on my site and then with my endless theme tweaking I managed to screw it up... now it returns the dreaded "selected album/file does not exist" message whenever a vote is cast.  I noticed that it changes from mysite/displayimage.php?album=#&pos=-# to mysite/displayimage.php?pos=-# (no album is identified).  Is the fix in the ratepic.php ? 

Thanks for any help with this.

You should check some things:
Open a voting page and look into the source, find "<SCRIPT language=JavaScript type=text/javascript>displayStars",
It should end with something like this: "displayStars(0, 217, "");</SCRIPT>" Where the 217 is the number of the picture.

If that isn't in there, no pic will be defined and the problem lies within your theme.php file.
If so, please post your theme.php source in this thread.
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: zac on July 23, 2007, 08:02:04 am
Yea.. must be the theme... here it is, long one...  with your cool lightbox mod as well. 
i am having problems posting it because of the length, would you  mind looking at a zip?

Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: SaWey on July 23, 2007, 11:16:32 am
not at all, please post it
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: zac on July 23, 2007, 06:47:47 pm
Cool thanks
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: SaWey on July 23, 2007, 11:33:50 pm
Is this the correct theme.php file?
Cause I can't seem to find anything related to the voting mod?
have you added the code as suggested at the top of this thread?
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: zac on July 24, 2007, 12:12:00 am
ah. yea forgot to mention that.  i took out the mod when i was trying to troubleshoot.  It was just a unmodified copy of what you have in this thread.

anyways...  I guess the problem is totally unrelated to your mod and is rather some other problem in my voting system.  I should probably make a diff thread for this i guess.. sorry bout that.
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: Singular on August 23, 2007, 05:45:51 pm
Nice mod. It works great. I have a request if you are willing. Could you guide me in the process of how to change the rating system to 10 stars instead of 5?

all the best,
Joe
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: Joachim Müller on August 23, 2007, 07:26:08 pm
Could you guide me in the process of how to change the rating system to 10 stars instead of 5?
Not related to this mod. Ask that question in a new thread on the support board after having searched for instructions how to accomplish what you're up to - I'm pretty sure that this has already been explained. Please do not clutter mod announcement threads with unrelated stuff in the future.



I created a demo theme based on the classic theme that comes with coppermine and bundled it with this mod. The bundle contains everything you need but the changes in ratepic.php.
To make this an actual theme, I changed the location of the extra files and modified the js file a bit (should be self-explanatory).

To see what the mod does, take a look at http://coppermine-gallery.net/demo/cpg14x/index.php?theme=classic_rating and try voting for any file.
Download my modified version of the classic theme (named "classic_rating") that contains all needed files originally created by SaWey here: http://downloads.sourceforge.net/coppermine/cpg1.4.x_theme_classic_rating.zip
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: Singular on August 24, 2007, 07:49:06 pm
Thanks for your reply. i tried the link you provided and I was not able to rate an image. There was no option and no stars visible. I was logged in.

all the best,
Joe
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: SaWey on August 24, 2007, 11:32:31 pm
Make sure you are not using internet explorer as the title mentioned
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: Joachim Müller on August 25, 2007, 09:44:31 am
Try http://coppermine-gallery.net/demo/cpg14x/thumbnails.php?album=20&theme=classic_rating and browse the files there.
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: DaBe on February 09, 2008, 05:49:02 pm
Hello
this is a very nice plugin..but I have a question, when I vote, and than vote encore..than I become a error, that I have voted! Can I remove the error, but the vote dont add!?

sry for my english


Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: clyde4210 on June 03, 2008, 05:12:05 am
am i missing a folder because 1.4.18 doesn't have a scripts folder
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: SaWey on June 04, 2008, 02:02:04 pm
You can just create that folder if it doesn't exist
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: comicdom on July 21, 2008, 07:24:40 am
beautiful voting solution!  Thanks so much for putting this together. =]
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: the-evil on September 06, 2008, 06:02:56 pm
Scipt is great....but i don't understand how i could change the numer of stars
for voting.... ???

Rich
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: Crazymodder on November 20, 2008, 07:36:10 pm
Very great Mod.
I have a question did anyone have an idea how I can include an noscript tag for the standart rating?
So if you have activate javascript you see the nicer voting. And if javascript is deactivated the orginal voting system is shown?
If somebody have an idea it would be very nice if he can help me.
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: werool on May 27, 2010, 12:15:20 am
Is it possible to put Your system under image? (not under filmstrip?)


werol.

I've been working on the voting of cpg,
I thought it could use some new voting pic.

Edit:
Before you read any further, this has still a giant bug in it.
In Firefox everything works fine, but IE won't let you vote for the moment.
This is caused by the referer in the code in "ratepic.php" at line 39.
If you comment this out, it will work in both IE and Firefox, but be carefull:
If the referer isn't checked, it is possible to vote from another website!

Solution to this ex-problem can be found at the bottom

To intall this, follow these steps:

First of all, copy the attached files in there corresponding folders:
rating.js -> scripts/rating
new.gif -> images
full.gif -> images
empty.gif -> images

Then in your "template.html" add the following above the </head> tag:

Code: [Select]
<script type="text/javascript" src="scripts/rating/rating.js"></script>


And as a last change, in your "theme.php" file add the following code before "?>"

Code: [Select]
//Rating change
$template_image_rating = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
        <tr>
                <td colspan="6" class="tableh2_compact"><b>{TITLE}</b> {VOTES}</td>
        </tr>
        <tr>
                <td class="tableb_compact">{RATESCRIPT}</td>
        </tr>
</table>
EOT;
function theme_html_rating_box()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
    global $template_image_rating, $lang_rate_pic;

    if (!(USER_CAN_RATE_PICTURES && $CURRENT_ALBUM_DATA['votes'] == 'YES')) return '';

    $votes = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_rate_pic['rating'], round($CURRENT_PIC_DATA['pic_rating'] / 2000, 1), $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
    $pid = $CURRENT_PIC_DATA['pid'];

    if (defined('THEME_HAS_RATING_GRAPHICS')) {
        $location= $THEME_DIR;
    } else {
        $location= '';
    }

    $params = array('{TITLE}' => $lang_rate_pic['rate_this_pic'],

'{RATESCRIPT}' => '<script type="text/javascript" language="JavaScript">displayStars(' . round($CURRENT_PIC_DATA['pic_rating'] / 2000, 0) . ', ' . $pid . ', "");</script>',
        '{VOTES}' => $votes,
        '{WIDTH}' => $CONFIG['picture_table_width'],
        '{LOCATION}' => $location,        //theme dir or default images directory
        );

    return template_eval($template_image_rating, $params);
}

To escape the ex-problem in IE, just
Change the code in "ratepic.php" at line 39 to
Code: [Select]
// If referer is not displayimage.php we don't accept the vote
$referer = $_SERVER["HTTP_REFERER"];
if (!eregi("displayimage", $referer) & !($referer == "")){
    header('Location: displayimage.php?pos=' . (- $pic));
    exit;
}


Now it works.

Have fun.

Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: Joachim Müller on May 27, 2010, 10:20:29 am
You will not be supported, as the gallery from your profile URL http://art-club.pl/ is deliberately hiding the "Powered by Coppermine" footer, which is a license breach. Restore the footer permanently. Respect board rules in the future after having restored the footer. If you don't, then go away and stay away.
Title: Re: Nicer voting in cpg 1.x [Updated]
Post by: Joerg-Andre on October 22, 2010, 04:49:34 pm
I've been working on the voting of cpg,
I thought it could use some new voting pic.

Edit:
Before you read any further, this has still a giant bug in it.
In Firefox everything works fine, but IE won't let you vote for the moment.
This is caused by the referer in the code in "ratepic.php" at line 39.
If you comment this out, it will work in both IE and Firefox, but be carefull:
If the referer isn't checked, it is possible to vote from another website!

Solution to this ex-problem can be found at the bottom

To intall this, follow these steps:

First of all, copy the attached files in there corresponding folders:
rating.js -> scripts/rating
new.gif -> images
full.gif -> images
empty.gif -> images

Then in your "template.html" add the following above the </head> tag:

Code: [Select]
<script type="text/javascript" src="scripts/rating/rating.js"></script>


And as a last change, in your "theme.php" file add the following code before "?>"

Code: [Select]
//Rating change
$template_image_rating = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
        <tr>
                <td colspan="6" class="tableh2_compact"><b>{TITLE}</b> {VOTES}</td>
        </tr>
        <tr>
                <td class="tableb_compact">{RATESCRIPT}</td>
        </tr>
</table>
EOT;
function theme_html_rating_box()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
    global $template_image_rating, $lang_rate_pic;

    if (!(USER_CAN_RATE_PICTURES && $CURRENT_ALBUM_DATA['votes'] == 'YES')) return '';

    $votes = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_rate_pic['rating'], round($CURRENT_PIC_DATA['pic_rating'] / 2000, 1), $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
    $pid = $CURRENT_PIC_DATA['pid'];

    if (defined('THEME_HAS_RATING_GRAPHICS')) {
        $location= $THEME_DIR;
    } else {
        $location= '';
    }

    $params = array('{TITLE}' => $lang_rate_pic['rate_this_pic'],

'{RATESCRIPT}' => '<script type="text/javascript" language="JavaScript">displayStars(' . round($CURRENT_PIC_DATA['pic_rating'] / 2000, 0) . ', ' . $pid . ', "");</script>',
        '{VOTES}' => $votes,
        '{WIDTH}' => $CONFIG['picture_table_width'],
        '{LOCATION}' => $location,        //theme dir or default images directory
        );

    return template_eval($template_image_rating, $params);
}

To escape the ex-problem in IE, just
Change the code in "ratepic.php" at line 39 to
Code: [Select]
// If referer is not displayimage.php we don't accept the vote
$referer = $_SERVER["HTTP_REFERER"];
if (!eregi("displayimage", $referer) & !($referer == "")){
    header('Location: displayimage.php?pos=' . (- $pic));
    exit;
}


Now it works.

Have fun.


hello,
can this code jump after vote to the next picture to vote?
this is something what i´m loking for.