forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: ToTo123 on August 22, 2010, 10:55:36 pm

Title: Next Image instead of Popup
Post by: ToTo123 on August 22, 2010, 10:55:36 pm
Hey everyone,

I dont need the Pop-Up with the fullsize image. Instead I'd prefere to see the next picture when klicking on the image.
I looked up the displayimage.php but didnt find anything (Coppermine files where my first contact with php).

The Link to my Gallery: http://www.dpsg-rt-mitte.de/coppermine/

If there allready exists a topic with the same issue, please tell me how you found it. Tried several keywords, but didnt find anythink

Thanks in advance
ToTo123
Title: Re: Next Image instead of Popup
Post by: Stramm on August 23, 2010, 12:13:15 pm
I remember a few threads dealing with that. One I've found for 1.4
http://forum.coppermine-gallery.net/index.php/topic,59784.0.html

For 1.5 it might be slightly different. However do not mess with themes.inc.php but copy the function you want to modify from themes/sample/theme.php to the theme you want to use eg. themes/curve/theme.php
Title: Re: Next Image instead of Popup
Post by: ToTo123 on August 23, 2010, 12:43:42 pm
I added this to my theme.php

Code: [Select]
/******************************************************************************
** Section <<<theme_html_picture>>> - START
******************************************************************************/
// Displays a picture
function theme_html_picture()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER, $LINEBREAK;
    global $album, $lang_date, $template_display_media;
    global $lang_display_image_php, $lang_picinfo, $lang_common, $lang_errors;

    $superCage = Inspekt::makeSuperCage();

    $pid = $CURRENT_PIC_DATA['pid'];
    $pic_title = '';

    if (!isset($USER['liv']) || !is_array($USER['liv'])) {
        $USER['liv'] = array();
    }
    // Add 1 to hit counter
    if ((!USER_IS_ADMIN && $CONFIG['count_admin_hits'] == 0 || $CONFIG['count_admin_hits'] == 1) && !in_array($pid, $USER['liv']) && $superCage->cookie->keyExists($CONFIG['cookie_name'] . '_data')) {
        add_hit($pid);
        if (count($USER['liv']) > 4) array_shift($USER['liv']);
        array_push($USER['liv'], $pid);
    }

    // The weird comparision is because only picture_width is stored
    if ($CONFIG['thumb_use']=='ht' && $CURRENT_PIC_DATA['pheight'] > $CONFIG['picture_width'] ) {
        $condition = true;
    } elseif ($CONFIG['thumb_use']=='wd' && $CURRENT_PIC_DATA['pwidth'] > $CONFIG['picture_width']) {
        $condition = true;
    } elseif ($CONFIG['thumb_use']=='any' && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']) {
        $condition = true;
        //thumb cropping
    } elseif ($CONFIG['thumb_use']=='ex' && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']) {
        $condition = true;
    } else {
        $condition = false;
    }

    if ($CURRENT_PIC_DATA['title'] != '') {
        $pic_title .= $CURRENT_PIC_DATA['title'] . $LINEBREAK;
    }
    if ($CURRENT_PIC_DATA['caption'] != '') {
        $pic_title .= $CURRENT_PIC_DATA['caption'] . $LINEBREAK;
    }
    if ($CURRENT_PIC_DATA['keywords'] != '') {
        $pic_title .= $lang_common['keywords'] . ": " . $CURRENT_PIC_DATA['keywords'];
    }

    if (!$CURRENT_PIC_DATA['title'] && !$CURRENT_PIC_DATA['caption']) {
        template_extract_block($template_display_media, 'img_desc');
    } else {
        if (!$CURRENT_PIC_DATA['title']) {
            template_extract_block($template_display_media, 'title');
        }
        if (!$CURRENT_PIC_DATA['caption']) {
            template_extract_block($template_display_media, 'caption');
        }
    }

    $CURRENT_PIC_DATA['menu'] = html_picture_menu(); //((USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID) || ($CONFIG['users_can_edit_pics'] && $CURRENT_PIC_DATA['owner_id'] == USER_ID && USER_ID != 0) || GALLERY_ADMIN_MODE) ? html_picture_menu($pid) : '';

    $image_size = array();

    if ($CONFIG['make_intermediate'] && $condition ) {
        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal');
    } else {
        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize');
    }

    list($image_size['width'], $image_size['height'], , $image_size['geom']) = cpg_getimagesize(urldecode($picture_url));

    $pic_title = '';
    $mime_content = cpg_get_type($CURRENT_PIC_DATA['filename']);

    if ($mime_content['content']=='movie' || $mime_content['content']=='audio') {

        if ($CURRENT_PIC_DATA['pwidth']==0 || $CURRENT_PIC_DATA['pheight']==0) {
            $resize_method = $CONFIG['picture_use'] == "thumb" ? ($CONFIG['thumb_use'] == "ex" ? "any" : $CONFIG['thumb_use']) : $CONFIG['picture_use'];
            if ($resize_method == 'ht') {
                $pwidth = $CONFIG['picture_width']*4/3;
                $pheight = $CONFIG['picture_width'];
            } else {
                $pwidth = $CONFIG['picture_width'];
                $pheight = $CONFIG['picture_width']*3/4;
            }

            $CURRENT_PIC_DATA['pwidth']  = $pwidth; // Default width

            // Set default height; if file is a movie
            if ($mime_content['content']=='movie') {
                $CURRENT_PIC_DATA['pheight'] = $pheight; // Default height
            }
        }

        $ctrl_offset['mov']=15;
        $ctrl_offset['wmv']=45;
        $ctrl_offset['swf']=0;
        $ctrl_offset['rm']=0;
        $ctrl_offset_default=45;
        $ctrl_height = (isset($ctrl_offset[$mime_content['extension']]))?($ctrl_offset[$mime_content['extension']]):$ctrl_offset_default;
        $image_size['whole']='width="'.$CURRENT_PIC_DATA['pwidth'].'" height="'.($CURRENT_PIC_DATA['pheight']+$ctrl_height).'"';
    }

    if ($mime_content['content']=='image') {
        if ($CURRENT_PIC_DATA['mode'] != 'fullsize') {
            $winsizeX = $CURRENT_PIC_DATA['pwidth'] + $CONFIG['fullsize_padding_x'];  //the +'s are the mysterious FF and IE paddings
            $winsizeY = $CURRENT_PIC_DATA['pheight'] + $CONFIG['fullsize_padding_y']; //the +'s are the mysterious FF and IE paddings
            if ($CONFIG['transparent_overlay'] == 1) {
                $pic_html = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td background=\"" . $picture_url . "\" width=\"{$image_size['width']}\" height=\"{$image_size['height']}\" class=\"image\">";
                $pic_html_href_close = '</a>' . $LINEBREAK;
                if (!USER_ID && $CONFIG['allow_unlogged_access'] <= 2) {
                    if ($CONFIG['allow_user_registration'] == 0) {
                        $pic_html_href_close = '';
                    } else {
                        $pic_html .= '<a href="javascript:;" onclick="alert(\''.sprintf($lang_errors['login_needed'],'','','','').'\');">';
                    }
                } elseif (USER_ID && USER_ACCESS_LEVEL <= 2) {
                    $pic_html .= '<a href="javascript:;" onclick="alert(\''.sprintf($lang_errors['access_intermediate_only'],'','','','').'\');">';
                } else {
                    $pic_html .= "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid=$pid&amp;fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=no,status=no,resizable=yes,width=$winsizeX,height=$winsizeY')\">";
                }
                $pic_title = $lang_display_image_php['view_fs'] . $LINEBREAK . '==============' . $LINEBREAK . $pic_title;
                $pic_html .= "<img src=\"images/image.gif?id=".floor(rand()*1000+rand())."\" width=\"{$image_size['width']}\" height=\"{$image_size['height']}\"  border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />";
                $pic_html .= $pic_html_href_close . '</td></tr></table>';
                //PLUGIN FILTER
                $pic_html = CPGPluginAPI::filter('html_image_reduced_overlay', $pic_html);
            } else {
                $pic_html_href_close = '</a>' . $LINEBREAK;
                if (!USER_ID && $CONFIG['allow_unlogged_access'] <= 2) {
                    if ($CONFIG['allow_user_registration'] == 0) {
                        $pic_html = $pic_html_href_close = '';
                    } else {
                        $pic_html = '<a href="javascript:;" onclick="alert(\''.sprintf($lang_errors['login_needed'],'','','','').'\');">';
                    }
                } elseif (USER_ID && USER_ACCESS_LEVEL <= 2) {
                    $pic_html = '<a href="javascript:;" onclick="alert(\''.sprintf($lang_errors['access_intermediate_only'],'','','','').'\');">';
                } else {
                    $pic_html = "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid=$pid&amp;fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=no,status=no,resizable=yes,width=$winsizeX,height=$winsizeY')\">";
                }
                $pic_title = $lang_display_image_php['view_fs'] . $LINEBREAK . '==============' . $LINEBREAK . $pic_title;
                $pic_html .= "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />";
                $pic_html .= $pic_html_href_close;
                //PLUGIN FILTER
                $pic_html = CPGPluginAPI::filter('html_image_reduced', $pic_html);
            }
        } else {
            if ($CONFIG['transparent_overlay'] == 1) {
                $pic_html = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td background=\"" . $picture_url . "\" width=\"{$CURRENT_PIC_DATA['pwidth']}\" height=\"{$CURRENT_PIC_DATA['pheight']}\" class=\"image\">";
                $pic_html .= "<img src=\"images/image.gif?id=".floor(rand()*1000+rand())."\" width={$CURRENT_PIC_DATA['pwidth']} height={$CURRENT_PIC_DATA['pheight']} border=\"0\" alt=\"\" /><br />" . $LINEBREAK;
                $pic_html .= "</td></tr></table>";
                //PLUGIN FILTER
                $pic_html = CPGPluginAPI::filter('html_image_overlay', $pic_html);
            } else {
                $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />" . $LINEBREAK;
                //PLUGIN FILTER
                $pic_html = CPGPluginAPI::filter('html_image', $pic_html);
            }
        }
    } elseif ($mime_content['content']=='document') {
        $pic_thumb_url = get_pic_url($CURRENT_PIC_DATA,'thumb');
        $pic_html = "<a href=\"{$picture_url}\" target=\"_blank\" class=\"document_link\"><img src=\"".$pic_thumb_url."\" border=\"0\" class=\"image\" /></a><br />" . $LINEBREAK;
        //PLUGIN FILTER
        $pic_html = CPGPluginAPI::filter('html_document', $pic_html);
    } else {
        $autostart = ($CONFIG['media_autostart']) ? ('true'):('false');

        if ($mime_content['player'] == 'HTMLA') {
            $pic_html  = '<audio controls="true" src="' . $picture_url . '" autostart="' . $autostart . '"></audio>';
        } elseif ($mime_content['player'] == 'HTMLV') {
            $pic_html  = '<video controls="true" src="' . $picture_url . '" autostart="' . $autostart . '"' . $image_size['whole'] . '></video>';
        } else {

            $players['WMP'] = array('id' => 'MediaPlayer',
                                    'clsid' => 'classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" ',
                                    'codebase' => 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ',
                                    'mime' => 'type="application/x-mplayer2" ',
                                   );
            $players['DIVX'] = array('id' => 'DivX',
                                    'clsid' => 'classid="clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616"',
                                    'codebase' => 'codebase="http://go.divx.com/plugin/DivXBrowserPlugin.cab"',
                                    'mime' => 'type="video/divx"'
                                   );
            $players['RMP'] = array('id' => 'RealPlayer',
                                    'clsid' => 'classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" ',
                                    'codebase' => '',
                                    'mime' => 'type="audio/x-pn-realaudio-plugin" '
                                   );
            $players['QT']  = array('id' => 'QuickTime',
                                    'clsid' => 'classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ',
                                    'codebase' => 'codebase="http://www.apple.com/qtactivex/qtplugin.cab" ',
                                    'mime' => 'type="video/x-quicktime" '
                                   );
            $players['SWF'] = array('id' => 'SWFlash',
                                    'clsid' => ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ',
                                    'codebase' => '',
                                    'mime' => 'type="application/x-shockwave-flash" ',
                                    'data' => 'data="'.$picture_url.'" '
                                   );
            $players['UNK'] = array('id' => 'DefaultPlayer',
                                    'clsid' => '',
                                    'codebase' => '',
                                    'mime' => ''
                                   );

            $player = $players[$mime_content['player']];

            if (!$player) {
                $player = 'UNK';
            }

            $pic_html  = '<object id="'.$player['id'].'" '.$player['data'].$player['classid'].$player['codebase'].$player['mime'].$image_size['whole'].'>';
            $pic_html .= "<param name=\"autostart\" value=\"$autostart\" /><param name=\"src\" value=\"". $picture_url . "\" />";
            $pic_html .= '</object><br />' . $LINEBREAK;
        }

        //PLUGIN FILTER
        $pic_html = CPGPluginAPI::filter('html_other_media', $pic_html);
    }

    $CURRENT_PIC_DATA['html'] = $pic_html;
    $CURRENT_PIC_DATA['header'] = '';
    $CURRENT_PIC_DATA['footer'] = '';

    $CURRENT_PIC_DATA = CPGPluginAPI::filter('file_data',$CURRENT_PIC_DATA);

    $params = array('{CELL_HEIGHT}' => '100',
        '{IMAGE}' => $CURRENT_PIC_DATA['header'].$CURRENT_PIC_DATA['html'].$CURRENT_PIC_DATA['footer'],
        '{ADMIN_MENU}' => $CURRENT_PIC_DATA['menu'],
        '{TITLE}' => bb_decode($CURRENT_PIC_DATA['title']),
        '{CAPTION}' => bb_decode($CURRENT_PIC_DATA['caption']),
        );

    return template_eval($template_display_media, $params);
}
/******************************************************************************
** Section <<<theme_html_picture>>> - END
******************************************************************************/

Then i replaced this
Code: [Select]
$pic_html = "<a href=\"javascript:;\" onclick=\"MM_openBrWindow('displayimage.php?pid=$pid&amp;fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=no,status=no,resizable=yes,width=$winsizeX,height=$winsizeY')\">";
                }

with
Code: [Select]
$pic_html = "<a href='?album=$album$cat_link&amp;pos=$nextimg'>";
                }

and this
Code: [Select]
$pic_html = "<a href="{NEXT_TGT}" class="navmenu_pic" title="{NEXT_TITLE}">";
                }

both replacements gave me a white screen.
The first one i took from the link you gave me.
The second one should be the line which creates the url for the "Next Picture"-Button.

But evene if there wasnt the white screen. Would it work? Because as i understand it only replaces the popup for the fullsize image, but in my gallery there appears no pop-up when klicking the image.
Title: Re: Next Image instead of Popup
Post by: Stramm on August 23, 2010, 01:42:52 pm
that won't work... you'll need to calc the next image pos and for that you'll need additional data

as said copy the entire function theme_html_picture from themes/sample/theme.php to the theme you're using right before ?>
then find in that function near the top
Code: [Select]
$pic_title = '';
below add
Code: [Select]
global $pic_data, $pos, $CPG_PHP_SELF, $cat_link, $date_link, $pic_count;
$cat_link = is_numeric($album) ? '' : '&amp;cat=' . $cat;
//$date_link = $_GET['date']=='' ? '' : '&date=' . cpgValidateDate($_GET['date']);

if ($superCage->get->keyExists('date')) {
//date will be validated
$date_link = '&date=' . cpgValidateDate($superCage->get->getRaw('date'));
} else {
$date_link = '';
}

//$uid_link = is_numeric($_GET['uid']) ? '&amp;uid=' . $_GET['uid'] : '';
if ($superCage->get->getInt('uid')) {
$uid_link = '&amp;uid=' . $superCage->get->getInt('uid');
} else {
$uid_link = '';
}

$page = ceil(($pos + 1) / ($CONFIG['thumbrows'] * $CONFIG['thumbcols']));
$pid = $CURRENT_PIC_DATA['pid'];
$msg_id = ($album == 'lastcom' || $album == 'lastcomby') ? "&amp;msg_id={$pic_data[$pos]['msg_id']}&amp;page=$page" : '';


if ($pos < ($pic_count -1)) {
$next = $pos + 1;
//$next_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$next$uid_link";// Abbas - added pid in URL instead of pos
if ($album == 'lastcom' || $album == 'lastcomby') {
$page = cpg_get_comment_page_number($pic_data[$next]['msg_id']);
$page = (is_numeric($page)) ? "&amp;page=$page" : '';
$next_tgt = "$CPG_PHP_SELF?album=$album$cat_link$date_link&amp;pid={$pic_data[$next]['pid']}$uid_link&amp;msg_id={$pic_data[$next]['msg_id']}$page#comment{$pic_data[$next]['msg_id']}";
} else {
$next_tgt = "$CPG_PHP_SELF?album=$album$cat_link$date_link&amp;pid={$pic_data[$next]['pid']}$uid_link#top_display_media";
}
} else {
// on last image, so no next button/link
$next_tgt = "javascript:;";
}



now find the two lines containing MM_openBrWindow and replace the entire line with
Code: [Select]
$pic_html .= "<a href=\"javascript:;\" onclick=\"window.location.href='{$next_tgt}'\">";

I've just tested the basics and it works for me even for most meta albums (not random). It should work with date search, too (untested)
Title: Re: Next Image instead of Popup
Post by: ToTo123 on August 23, 2010, 01:59:39 pm
Did exactly what you told me.
At least there is no white screen anymore :D
But it didnt change anything.


I remember that i removed the popup function long time ago. But dont know how.
Title: Re: Next Image instead of Popup
Post by: Stramm on August 23, 2010, 02:21:05 pm
This is a replacement of the popup function. So if there wouldn't be a popup, then there won't be a next link neither.

As far as I can see there are no 'bigger' images than the ones that get displayed -> no popup. If the fullsized image is getting displayed in your intermediate view you'll have to do more coding

find
Code: [Select]
$pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />" . $LINEBREAK;
and replace with
Code: [Select]
$pic_html = "<a href=\"javascript:;\" onclick=\"window.location.href='{$next_tgt}'\">";
$pic_html .= "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" alt=\"\" /><br />" . $LINEBREAK;
$pic_html .= "</a>";

untested...
Title: Re: Next Image instead of Popup
Post by: ToTo123 on August 23, 2010, 02:33:03 pm
Works!
Thank you :)

Also works with newest uploads and most viewed
only newest comments gives a critical error

Can it be fixed? or is it the price i've to pay for it?
Title: Re: Next Image instead of Popup
Post by: Stramm on August 23, 2010, 04:41:52 pm
I've updated my above posting.
Title: Re: Next Image instead of Popup
Post by: ToTo123 on August 23, 2010, 05:37:30 pm
works perfekt now
THANK YOU
Title: Re: Next Image instead of Popup
Post by: Iced Coffee on October 19, 2010, 04:45:50 am
I love you Stramm, as always it works well for me :)

By the way, is there a way to make it navigate back to the previous picture if we click on the left side of the current picture? I know it now works pretty more than I can expect already, but this sounds better if we have this function also. If it makes thing messy or too complicated, please ignore this request. Thanks :)
Title: Re: Next Image instead of Popup
Post by: Αndré on October 20, 2010, 02:54:24 pm
That's basically possible. But you need to display some arrows, as it's not obvious for visitors why they sometimes go to the next and sometimes to the previous image.
Title: Re: Next Image instead of Popup
Post by: Iced Coffee on October 20, 2010, 06:04:55 pm
 :) It's great to hear that it is possible Andre. Yes, to make it less confusing but avoid putting an arrow on the picture, I guess we can navigate it like in this page http://hn.24h.com.vn/bong-da/anh-chelsea-vuot-ai-spartak-o-moscow-c48a332005.html

How do you think?
Title: Re: Next Image instead of Popup
Post by: Αndré on October 20, 2010, 06:38:32 pm
It's implemented exactly like the draft in my head 8) It just adds 2 divs, one on the left side, one on the right. Maybe I find some time tomorrow to create a mod or even a plugin which adds that functionality.
Title: Re: Next Image instead of Popup
Post by: Iced Coffee on October 21, 2010, 02:26:31 am
 :D Thanks a lot Andre. I look forward to have it up and running on my CPG.
Title: Re: Next Image instead of Popup
Post by: Iced Coffee on October 24, 2010, 05:31:46 pm
Hi Andre,

Have you got time to work on the modification? Thanks.
Title: Re: Next Image instead of Popup
Post by: Αndré on October 24, 2010, 05:52:02 pm
Not yet. But it's already on top of my to-do list :)
Title: Re: Next Image instead of Popup
Post by: Iced Coffee on November 02, 2010, 10:59:30 am
Hi Andre, did this mod come out yet? I hope you have not put this off the list :)
Title: Re: Next Image instead of Popup
Post by: Αndré on November 02, 2010, 11:51:29 am
No sorry. I'm currently very busy supporting cpg1.5.x, so I haven't found time yet to work on the plugin. But it's still on my list!
Title: Re: Next Image instead of Popup
Post by: Iced Coffee on November 02, 2010, 12:21:28 pm
Thanks. Will wait for that.
Title: Re: Next Image instead of Popup
Post by: Αndré on November 20, 2010, 06:54:40 pm
Have a look at that plugin (http://coppermine.svn.sourceforge.net/viewvc/coppermine/branches/cpg1.5.x/plugins/picture_navigation/?view=tar). I currently tested it only with my preferred settings (no intermediate pictures, no transparent overlay). Please report any odd behavior.
Title: Re: Next Image instead of Popup
Post by: Αndré on November 30, 2010, 06:15:24 pm
Plugin has been released here (http://forum.coppermine-gallery.net/index.php/topic,68456.0.html).
Title: Re: Next Image instead of Popup
Post by: Iced Coffee on December 01, 2010, 04:12:48 am
Thanks Andre. But will it be a problem if I have modified the files as guided in earlier posts in this topic? Do I need to revert all the files back before applying this plugin?
Title: Re: Next Image instead of Popup
Post by: Αndré on December 01, 2010, 07:19:29 am
I guess you have to undo the modifications.