September 02, 2010, 03:19:55 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: The wait is over - Coppermine 1.5.8 [stable] is here
It is with great pride that the Coppermine community announces to the world the immediate availability of Coppermine 1.5.8 stable. As a community of contributors, we have been through celebrations and tribulations. We have had fun, and we have worked hard. We have learned from and helped one another. What started two and a half years ago has grown into what we believe to be the finest PHP photo gallery yet.
[more]
   Home   Help Search Board rules Login Register  
Pages: [1] 2   Go Down
  Print  
Author Topic: Nicer voting in cpg 1.x [Updated]  (Read 27176 times)
0 Members and 1 Guest are viewing this topic.
SaWey Topic starter
Dev Team member
****
Gender: Male
Belgium Belgium

Posts: 1119



WWW
« on: January 31, 2007, 09: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:
<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:
//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:
// 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.

* vote.zip (1.71 KB - downloaded 233 times.)
« Last Edit: March 20, 2007, 11:42:38 pm by Nibbler » Logged
alanuk
Coppermine newbie

Posts: 9


« Reply #1 on: February 20, 2007, 10: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 Topic starter
Dev Team member
****
Gender: Male
Belgium Belgium

Posts: 1119



WWW
« Reply #2 on: February 20, 2007, 10:15:34 pm »

I'm glad it's usefull!

Nice site BTW
Logged
SaWey Topic starter
Dev Team member
****
Gender: Male
Belgium Belgium

Posts: 1119



WWW
« Reply #3 on: March 20, 2007, 11:27:41 pm »

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
****
Gender: Male
Germany Germany

Posts: 47735


aka "GauGau"


WWW
« Reply #4 on: March 21, 2007, 08: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
***
Posts: 117


« Reply #5 on: May 26, 2007, 05:11:21 pm »

hey there..

ah what does this actually do?
Logged
SaWey Topic starter
Dev Team member
****
Gender: Male
Belgium Belgium

Posts: 1119



WWW
« Reply #6 on: May 26, 2007, 09: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
***
Posts: 117


« Reply #7 on: May 27, 2007, 08: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
***
Posts: 153



« Reply #8 on: July 16, 2007, 09: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
*
Gender: Female
Turkey Turkey

Posts: 42

MyWedding


WWW
« Reply #9 on: July 16, 2007, 09: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:

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
****
Gender: Male
Germany Germany

Posts: 47735


aka "GauGau"


WWW
« Reply #10 on: July 17, 2007, 08: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:
//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:
?>
Logged
SaWey Topic starter
Dev Team member
****
Gender: Male
Belgium Belgium

Posts: 1119



WWW
« Reply #11 on: July 22, 2007, 10: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
***
Posts: 153



« Reply #12 on: July 23, 2007, 07: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 Topic starter
Dev Team member
****
Gender: Male
Belgium Belgium

Posts: 1119



WWW
« Reply #13 on: July 23, 2007, 10:16:32 am »

not at all, please post it
Logged
zac
Contributor
***
Posts: 153



« Reply #14 on: July 23, 2007, 05:47:47 pm »

Cool thanks

* theme.zip (8.15 KB - downloaded 32 times.)
Logged
SaWey Topic starter
Dev Team member
****
Gender: Male
Belgium Belgium

Posts: 1119



WWW
« Reply #15 on: July 23, 2007, 10: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
***
Posts: 153



« Reply #16 on: July 23, 2007, 11:12:00 pm »

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
**
Posts: 77


WWW
« Reply #17 on: August 23, 2007, 04: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
****
Gender: Male
Germany Germany

Posts: 47735


aka "GauGau"


WWW
« Reply #18 on: August 23, 2007, 06: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
**
Posts: 77


WWW
« Reply #19 on: August 24, 2007, 06: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
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
Page created in 0.142 seconds with 17 queries.