forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Voting/Rating => Topic started by: Master of Orion on March 06, 2006, 10:59:28 am

Title: When vote for file... New feature.
Post by: Master of Orion on March 06, 2006, 10:59:28 am
Possible do? When vote for file, visitor goes to the next one in album?

Look at this for example - http://china.kulichki.com/english/girls/

Title: Re: When vote for file... New feature.
Post by: twistah on March 16, 2006, 12:46:40 pm
Hello !

I have a dead simpe hack for this as I needed to speed up the voting process on my site as well.

Anyone interested to see the small modifications ?
Title: Re: When vote for file... New feature.
Post by: Joachim Müller on March 16, 2006, 03:45:35 pm
please post it.
Title: Re: When vote for file... New feature.
Post by: twistah on March 17, 2006, 10:21:22 am
Right.

Remember; this is a quick-and-dirty hack made to the Coppermine code on my site to speed up the voting process from a users standpoint.
The problem is that after voting on an image in an album, the resulting page is the same image. The user then have to click the "next" button
to move on to the next image in the album.

Im a bit suprised this isnt an optional feature in Coppermine (afaik).

So to the hack:

Open the include/theme.inc.php file, locate the heme_html_rating_box function.
Replace the theme_html_rating_box function to:

Code: [Select]
if (!function_exists('theme_html_rating_box')) {  //{THEMES}
function theme_html_rating_box()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
    global $template_image_rating, $lang_rate_pic, $pos, $album;

    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= '';
    }

    if (isset($_GET['autonext'])){     
        $params = array('{TITLE}' => $lang_rate_pic['rate_this_pic'],
                '{VOTES}' => $votes,
                '{RATE0}' => "ratepic.php?pic=$pid&rate=0&nextpos=".($pos+1)."&album=$album",
                '{RATE1}' => "ratepic.php?pic=$pid&rate=1&nextpos=".($pos+1)."&album=$album",
                '{RATE2}' => "ratepic.php?pic=$pid&rate=2&nextpos=".($pos+1)."&album=$album",
                '{RATE3}' => "ratepic.php?pic=$pid&rate=3&nextpos=".($pos+1)."&album=$album",
                '{RATE4}' => "ratepic.php?pic=$pid&rate=4&nextpos=".($pos+1)."&album=$album",
                '{RATE5}' => "ratepic.php?pic=$pid&rate=5&nextpos=".($pos+1)."&album=$album",
                '{RUBBISH}' => $lang_rate_pic['rubbish'],
                '{POOR}' => $lang_rate_pic['poor'],
                '{FAIR}' => $lang_rate_pic['fair'],
                '{GOOD}' => $lang_rate_pic['good'],
                '{EXCELLENT}' => $lang_rate_pic['excellent'],
                '{GREAT}' => $lang_rate_pic['great'],
                '{WIDTH}' => $CONFIG['picture_table_width'],
                '{LOCATION}' => $location,        //theme dir or default images directory
                );
    }else{     
        $params = array('{TITLE}' => $lang_rate_pic['rate_this_pic'],
                '{VOTES}' => $votes,
                '{RATE0}' => "ratepic.php?pic=$pid&rate=0",
                '{RATE1}' => "ratepic.php?pic=$pid&rate=1",
                '{RATE2}' => "ratepic.php?pic=$pid&rate=2",
                '{RATE3}' => "ratepic.php?pic=$pid&rate=3",
                '{RATE4}' => "ratepic.php?pic=$pid&rate=4",
                '{RATE5}' => "ratepic.php?pic=$pid&rate=5",
                '{RUBBISH}' => $lang_rate_pic['rubbish'],
                '{POOR}' => $lang_rate_pic['poor'],
                '{FAIR}' => $lang_rate_pic['fair'],
                '{GOOD}' => $lang_rate_pic['good'],
                '{EXCELLENT}' => $lang_rate_pic['excellent'],
                '{GREAT}' => $lang_rate_pic['great'],
                '{WIDTH}' => $CONFIG['picture_table_width'],
                '{LOCATION}' => $location,        //theme dir or default images directory
                );

    }
    return template_eval($template_image_rating, $params);
}
}  //{THEMES}



And modify the last part of the ratepic.php

Code: [Select]
...

$nextposlink = $_GET['nextpos']."&album=".$_GET['album'];
$location = "displayimage.php?pos=";
$location .= isset($_GET['nextpos']) ? $nextposlink : (- $pic);

$header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
header($header_location . $location);
pageheader($lang_info, "<META http-equiv=\"refresh\" content=\"1;url=$location\">");
msg_box($lang_info, $lang_rate_pic_php['rate_ok'], $lang_continue, $location);
pagefooter();
ob_end_flush();

?>

Now, for making this work (Coppermine will behave as usual), you must add a query parameter to your link for the album you want your users to vote on.

This is the old type link: http://www.yoursite.com/album/displayimage.php?album=388&pos=0
This, with the extra parameter: http://www.yoursite.com/album/displayimage.php?album=388&pos=0&autonext=true

Again, this isnt a study of php code exellence, but a simple walkthrough of a 10 minutes hack to make voting easier for our users.

If wanted, I could sure make this more proper Coppermine style and quality.

(If I've forgotten somthing above, let me know)

/twistah
Title: Re: When vote for file... New feature.
Post by: crxman on April 14, 2006, 04:35:20 pm
Very usefull mod thanks ! will wait for the final code to ad it :)
Title: Re: When vote for file... New feature.
Post by: adiboy on May 09, 2006, 11:15:56 pm
is this code done yet coz i tryed it and it dosen't work.
Title: Re: When vote for file... New feature.
Post by: complexity on May 15, 2006, 01:37:02 pm
this is exactly what i need, i think i added it correctly but no luck..

IF you could set it up like


find


replace

find

replace


It would be greatly appreciated. And am I understanding it correctly, this mod will move you on to the next image, after you vote?
Title: Re: When vote for file... New feature.
Post by: war59312 on May 17, 2006, 01:21:43 am
Yeah it's broke, sadly. :(

Parse error: syntax error, unexpected T_STRING in /gallery/include/themes.inc.php on line 2303
Title: Re: When vote for file... New feature.
Post by: Joachim Müller on May 17, 2006, 01:24:15 am
make sure you copied everything correctly.

Let me add a note that editing themes.inc.php is not recommended at all. Instead: edit themes/yourtheme/theme.php
Title: Re: When vote for file... New feature.
Post by: complexity on May 18, 2006, 09:33:00 am
hmmm no luck anyone got this working that can help ?
Title: Re: When vote for file... New feature.
Post by: younk on May 31, 2006, 12:25:30 pm
I can't get it to work. I really really want it to, and i have tried in an hour, but it just show the same error:
Parse error: syntax error, unexpected T_STRING in /gallery/include/themes.inc.php on line 2303
Sadly

I hope someone get this to work, because it would really rock!
Title: Re: When vote for file... New feature.
Post by: Joachim Müller on June 01, 2006, 07:36:24 am
Did you paste in the dots at the very start of the code box? You mustn't, they are just meant to show you that there's code in front of it. The instructions for this mod are not newbie-safe, you can't just copy and paste. As suggested: editing themes.inc.php is silly in the first place, that's why I won't look into this. If the original contributor doesn't reply, there will probably little you can do.
Title: Re: When vote for file... New feature.
Post by: younk on June 01, 2006, 12:02:11 pm
I thought they where typeos (type errors) I try again.
Title: Re: When vote for file... New feature.
Post by: younk on June 01, 2006, 12:47:35 pm
I still can't get it to work. And you are right, but if this is the only way to make voting jump to next image i really need it.

You dont know another funktion to do this?
Title: Re: When vote for file... New feature.
Post by: Nibbler on June 01, 2006, 02:43:57 pm
Post your changed file.
Title: Re: When vote for file... New feature.
Post by: Dr Preacox on June 01, 2006, 02:49:28 pm
In a way I find this mod weird because it turns coppermine into a well advanced Hot or Not website, but I can see the benifits too ...
Title: Re: When vote for file... New feature.
Post by: younk on June 05, 2006, 08:28:22 pm
www.younk.dk/test/files.rar (http://www.younk.dk/test/files.rar)
Title: Re: When vote for file... New feature.
Post by: Nibbler on June 05, 2006, 08:49:26 pm
You've got that line split over 2 lines. Put them on the same line.
Title: Re: When vote for file... New feature.
Post by: younk on June 06, 2006, 10:36:54 am
Now i have corrected that file, but is still get this error:
Fatal error: Call to undefined function: theme_main_menu() in /mounted-storage/home11b/sub002/sc16206-UEQL/babez.dk/galleri/include/themes.inc.php on line 1213

I have uploadet the new files: www.younk.dk/test/files2.rar (http://www.younk.dk/test/files2.rar)

I hope you can help me again.

BTW Thanks for the first part of help  ;)
Title: Re: When vote for file... New feature.
Post by: complexity on June 08, 2006, 06:27:39 pm
anyone get this working yet..
Title: Re: When vote for file... New feature.
Post by: trippinsweet on June 26, 2006, 07:42:13 pm
I couldn't get it to work either, but I took the basic concept and made my own version of this hack.

In this version, you don't have to add the extra parameter '&autonext=true', which should make integration into coppermine much easier.
It worked on my system, which is slightly modified to display in Joomla, but I believe the code changes needed for this mod are independent of my other modifications.



In themes.inc.php, find
Code: [Select]
function theme_html_rating_box()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
    global $template_image_rating, $lang_rate_pic;

And replace with
Code: [Select]
function theme_html_rating_box()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
    global $template_image_rating, $lang_rate_pic, $pos, $album;

Same file, find
Code: [Select]
                '{RATE0}' => "ratepic.php?pic=$pid&amp;rate=0",
                '{RATE1}' => "ratepic.php?pic=$pid&amp;rate=1",
                '{RATE2}' => "ratepic.php?pic=$pid&amp;rate=2",
                '{RATE3}' => "ratepic.php?pic=$pid&amp;rate=3",
                '{RATE4}' => "ratepic.php?pic=$pid&amp;rate=4",
                '{RATE5}' => "ratepic.php?pic=$pid&amp;rate=5",

and replace with:
Code: [Select]
        '{RATE0}' => "ratepic.php?pic=$pid&amp;rate=0&pos=$pos&album=$album&cat=".$_GET['cat'],
        '{RATE1}' => "ratepic.php?pic=$pid&amp;rate=1&pos=$pos&album=$album&cat=".$_GET['cat'],
        '{RATE2}' => "ratepic.php?pic=$pid&amp&rate=2&pos=$pos&album=$album&cat=".$_GET['cat'],
        '{RATE3}' => "ratepic.php?pic=$pid&amp;rate=3&pos=$pos&album=$album&cat=".$_GET['cat'],
        '{RATE4}' => "ratepic.php?pic=$pid&amp;rate=4&pos=$pos&album=$album&cat=".$_GET['cat'],
        '{RATE5}' => "ratepic.php?pic=$pid&amp;rate=5&pos=$pos&album=$album&cat=".$_GET['cat'],

In file ratepic.php, find
Code: [Select]
    $location = "displayimage.php?pos=" . (- $pic);

And add directly after it:
Code: [Select]
    if (isset($_GET['album'])) $location = "displayimage.php?album=".$_GET['album']."&pos=".($_GET['pos'] + 1)."&cat=".$_GET['cat'];
Title: Re: When vote for file... New feature.
Post by: absolutmalmo on September 07, 2006, 09:42:55 pm
Why don't you make this to a real Plugin for coppermine? like you upload it with pluginmgr.php and then easily can get this too work!
Title: Re: When vote for file... New feature.
Post by: Joachim Müller on September 08, 2006, 07:48:33 am
Why don't you make this to a real Plugin for coppermine? like you upload it with pluginmgr.php and then easily can get this too work!
Why don't you turn it into a plugin if you're so clever?
Remember; this is a quick-and-dirty hack made to the Coppermine code on my site to speed up the voting process from a users standpoint.


Side-note to all: twistah's instructions say to edit include/themes.inc.php. Although this will probably work, we're not particularly fond of this method. This file should stay unmodified no matter what. Apply the suggested changes to themes/yourtheme/theme.php instead. If you can't find the stuff you're suppossed to edit there, copy it first from themes/sample/theme.php first into your theme.
The reason why we constantly tell users not to modify include/themes.inc.php is simple: it will make updating or upgrading very hard, as you have to re-apply mods every time you upgrade. Subsequently, users who have mods applied shy away from mandatory upgrades (because they are afraid to break things that already work or they don't want to go through the steps to apply their mod again), leaving their galleries outdated and vulnerable.

Joachim

Title: Re: When vote for file... New feature.
Post by: mywedding on December 23, 2008, 02:42:06 am
many thx trippinsweet,

it works, :)
Title: Re: When vote for file... New feature.
Post by: Joerg-Andre on October 22, 2010, 04:47:20 pm
please post it.
Hallo, kannst du mir vielleicht weiter helfen?
suche aus soetwas wie ein bild voten und dann wird automatisch das nächste angezeigt.
versuche das grad mit der coppermine gallerie v1.58.
irgendwie scheint man hier nicht um forum zu finden auser eion code der aber auch nicht geht..
Title: Re: When vote for file... New feature.
Post by: Joachim Müller on October 25, 2010, 09:31:39 am
This is an international sub-board where only English postings are allowed. Respect board rules! This thread is for cpg1.4.x galleries anyway, so your reply doesn't fit in. Don't clutter unrelated threads with your issues!
Title: Re: When vote for file... New feature.
Post by: Joerg-Andre on October 26, 2010, 10:08:32 am
I couldn't get it to work either, but I took the basic concept and made my own version of this hack.

In this version, you don't have to add the extra parameter '&autonext=true', which should make integration into coppermine much easier.
It worked on my system, which is slightly modified to display in Joomla, but I believe the code changes needed for this mod are independent of my other modifications.



In themes.inc.php, find
Code: [Select]
function theme_html_rating_box()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
    global $template_image_rating, $lang_rate_pic;

And replace with
Code: [Select]
function theme_html_rating_box()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR;
    global $template_image_rating, $lang_rate_pic, $pos, $album;

Same file, find
Code: [Select]
                '{RATE0}' => "ratepic.php?pic=$pid&amp;rate=0",
                '{RATE1}' => "ratepic.php?pic=$pid&amp;rate=1",
                '{RATE2}' => "ratepic.php?pic=$pid&amp;rate=2",
                '{RATE3}' => "ratepic.php?pic=$pid&amp;rate=3",
                '{RATE4}' => "ratepic.php?pic=$pid&amp;rate=4",
                '{RATE5}' => "ratepic.php?pic=$pid&amp;rate=5",

and replace with:
Code: [Select]
        '{RATE0}' => "ratepic.php?pic=$pid&amp;rate=0&pos=$pos&album=$album&cat=".$_GET['cat'],
        '{RATE1}' => "ratepic.php?pic=$pid&amp;rate=1&pos=$pos&album=$album&cat=".$_GET['cat'],
        '{RATE2}' => "ratepic.php?pic=$pid&amp&rate=2&pos=$pos&album=$album&cat=".$_GET['cat'],
        '{RATE3}' => "ratepic.php?pic=$pid&amp;rate=3&pos=$pos&album=$album&cat=".$_GET['cat'],
        '{RATE4}' => "ratepic.php?pic=$pid&amp;rate=4&pos=$pos&album=$album&cat=".$_GET['cat'],
        '{RATE5}' => "ratepic.php?pic=$pid&amp;rate=5&pos=$pos&album=$album&cat=".$_GET['cat'],

In file ratepic.php, find
Code: [Select]
    $location = "displayimage.php?pos=" . (- $pic);

And add directly after it:
Code: [Select]
    if (isset($_GET['album'])) $location = "displayimage.php?album=".$_GET['album']."&pos=".($_GET['pos'] + 1)."&cat=".$_GET['cat'];


HALLO
it works good when i use coppermine allone.
but i have integratet it in pragma mx an there doesent it works.
why?
can anyone helps me?
PLEASE
Title: Re: When vote for file... New feature.
Post by: Joachim Müller on October 27, 2010, 08:21:03 am
We don't support PragmaMx. Ask the nice people over at the Pragma support board. Locking.