Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2   Go Down

Author Topic: Nicer voting in cpg 1.x [Updated]  (Read 42182 times)

0 Members and 1 Guest are viewing this topic.

SaWey

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1119
    • SaWey.be
Nicer voting in cpg 1.x [Updated]
« 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.
« Last Edit: March 21, 2007, 12:42:38 am by Nibbler »
Logged

alanuk

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Nicer voting in cpg 1.x [Updated]
« Reply #1 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   
Logged

SaWey

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1119
    • SaWey.be
Re: Nicer voting in cpg 1.x [Updated]
« Reply #2 on: February 20, 2007, 11:15:34 pm »

I'm glad it's usefull!

Nice site BTW
Logged

SaWey

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1119
    • SaWey.be
Re: Nicer voting in cpg 1.x [Updated]
« Reply #3 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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Nicer voting in cpg 1.x [Updated]
« Reply #4 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.
Logged

bitcloud

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 117
Re: Nicer voting in cpg 1.x [Updated]
« Reply #5 on: May 26, 2007, 06:11:21 pm »

hey there..

ah what does this actually do?
Logged

SaWey

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1119
    • SaWey.be
Re: Nicer voting in cpg 1.x [Updated]
« Reply #6 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.
Logged

bitcloud

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 117
Re: Nicer voting in cpg 1.x [Updated]
« Reply #7 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)
Logged

zac

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 153
Re: Nicer voting in cpg 1.x [Updated]
« Reply #8 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.
Logged

mywedding

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Female
  • Posts: 42
  • MyWedding
    • Wedding
Re: Nicer voting in cpg 1.x [Updated]
« Reply #9 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="" />';

?>
Logged
Dreams are free, so free your dreams, "Astrid Alauda"

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Nicer voting in cpg 1.x [Updated]
« Reply #10 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]
?>
Logged

SaWey

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1119
    • SaWey.be
Re: Nicer voting in cpg 1.x [Updated]
« Reply #11 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.
Logged

zac

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 153
Re: Nicer voting in cpg 1.x [Updated]
« Reply #12 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?

Logged

SaWey

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1119
    • SaWey.be
Re: Nicer voting in cpg 1.x [Updated]
« Reply #13 on: July 23, 2007, 11:16:32 am »

not at all, please post it
Logged

zac

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 153
Re: Nicer voting in cpg 1.x [Updated]
« Reply #14 on: July 23, 2007, 06:47:47 pm »

Cool thanks
Logged

SaWey

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1119
    • SaWey.be
Re: Nicer voting in cpg 1.x [Updated]
« Reply #15 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?
Logged

zac

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 153
Re: Nicer voting in cpg 1.x [Updated]
« Reply #16 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.
Logged

Singular

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 95
    • A Singular Creation
Re: Nicer voting in cpg 1.x [Updated]
« Reply #17 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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Nicer voting in cpg 1.x [Updated]
« Reply #18 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
Logged

Singular

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 95
    • A Singular Creation
Re: Nicer voting in cpg 1.x [Updated]
« Reply #19 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
Logged
Pages: [1] 2   Go Up
 

Page created in 0.078 seconds with 20 queries.