forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 plugins => Topic started by: robertokl on September 28, 2010, 06:39:02 pm

Title: Better Slideshow: Coppermine + Cooliris
Post by: robertokl on September 28, 2010, 06:39:02 pm
Hi all.
I'm new to coppermine, and I really liked the application.
The first think I did not liked was the poor slideshow for the albums, so I decided to integrate coppermine with cooliris (http://www.cooliris.com/).
I'm not really in the mod of doing a one-click-installable-plugin, but I decided to contribute what I've learned with others, and maybe some good soul will do this as a plugin, if there are enough requests.
Enough talk, to the patch.

Step 1. Install the xFeed 1.8 plugin from Aditya Mooley: http://forum.coppermine-gallery.net/index.php/topic,61197.0.html

Step 2. Overwrite the {application_root}/plugins/xfeed/xfeed.php with
Code: [Select]
<?php
/**************************************************
  Coppermine 1.5.x Plugin - XFeeds $VERSION$=1.3
  *************************************************
  Copyright (c) 2008 lee (www.mininoteuser.com)
  Plugin for CPG 1.4 created by Lee
  Ported to CPG 1.5.x by Aditya Mooley <adityamooley@sanisoft.com>
  *************************************************
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 3 of the License, or
  (at your option) any later version.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  **************************************************/

// WARNING : No user servicable parts below here
define('IN_COPPERMINE'true);

require_once(
'./plugins/xfeed/include/init.inc.php');

// This should work as it is, but hardcode if necessary.
define('CPG15'version_compare(COPPERMINE_VERSION"1.5.0"">="));
define('PHP5'version_compare(phpversion(), "5"">="));
$base rtrim($CONFIG['ecards_more_pic_target'], '/');
$gallery_name $CONFIG['gallery_name'];

function 
lmdate($timestamp)
{
    if (
PHP5) {
        return 
date('r'$timestamp);
    } else {
        return 
date('D, d M Y H:i:s +0800'$timestamp date('Z'));
    }
}

function 
rfc3339date ($timestamp)
{
    
//2002-10-02T15:00:00Z
    
return(date("Y-m-d"$timestamp date('Z')) . "T" date("H:i:s"$timestamp date('Z') ) . "Z");
}


if (
$superCage->get->keyExists('album')) {
    
// For any kind of album, get its pictures using built-in get_pic_data(). Respect the album privacy settings
    
$album $superCage->get->getEscaped('album');

    if (
$superCage->get->keyExists('cat')) {
        
$cat $superCage->get->getRaw('cat');
        
$cat = (int)$cat;

        if (
$cat 0) {
            
// In case of metaalbums, the category id gets negative value which is actually the album id. So, first get the correct category id
            
$aid = -($cat);
            
$query "SELECT category FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '$aid'";
            
$result cpg_db_query($query);

            
$row cpg_db_fetch_rowset($result);
            
$cat $row[0]['category'];
        }

        
$CURRENT_CAT_NAME populate_category_name($cat);

        
get_meta_album_set($cat);
    } else {
        
get_meta_album_set(0);
    }

    
$pic_data get_pic_data($album$count$album_name02000false);
} elseif (
$superCage->get->testInt('cat')) {
    
// If on category page, show the last uploaded photos for all the albums in that category in feed
    
$cat $superCage->get->getInt('cat');
    
$album 'lastup';

    
$CURRENT_CAT_NAME populate_category_name($cat);

    
get_meta_album_set($cat);
    
$pic_data get_pic_data($album$count$album_name0$XFDSET['xfd_feed_items'], false);

} else {
    
get_meta_album_set(0);
    
$query "SELECT pid,ctime,title,keywords,filepath,filename,caption,u.user_name FROM {$CONFIG['TABLE_PICTURES']} r, {$CONFIG['TABLE_USERS']} u
            
$RESTRICTEDWHERE AND r.owner_id = u.user_id AND approved = 'YES' ORDER BY pid DESC LIMIT 0, {$XFDSET['xfd_feed_items']}";
    
$result cpg_db_query($query);
    
$pic_data cpg_db_fetch_rowset($result);
}

/**
 * MAIN CODE
 */
$feedtype $superCage->get->keyExists('type') ? $superCage->get->getEscaped('type') : '';
header("Content-type: text/xml; charset={$CONFIG['charset']}");
if (
$feedtype == "atom"){
    
atom10();
} elseif (
$feedtype == "cooliris") {
    
cooliris();
} else {
    
rss20();
}

function 
cooliris() {
    global 
$CONFIG$result$base$gallery_name$pic_data$album$album_name$CURRENT_CAT_NAME;

    
$superCage Inspekt::makeSuperCage();

    
// Decide what kind of title to be shown
    
if ((int)$album) {
        
$title " | Album: $album_name";
    } elseif (
$superCage->get->testInt('cat')) {
        if (
strip_tags($album_name)) {
            
$title ' | ' strip_tags($album_name);
        }
        if (
$superCage->get->getInt('cat') < 0) {
            
$albumDetails get_album_name(-($superCage->get->getInt('cat')));
            
$title .= " | Album: {$albumDetails['title']}";
        }
    } elseif (
$album) {
        
$title ' | 'strip_tags($album_name);
    }
  print 
"<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss/\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n";
  print 
"  <channel>\n";
  print 
"    <title>{$gallery_name}{$title}</title>\n";
  print 
"    <description>{$CONFIG['gallery_description']}</description>\n";
  print 
"    <link>$base</link>\n";
  foreach (
$pic_data as $row) {
    
$title $row['title'] ? $row['title'] : $row['filename'];
    print 
"    <item>\n";
    print 
"      <title>".htmlentities($title)."</title>\n";
    print 
"      <link>$base/displayimage.php?pid={$row['pid']}</link>\n";
    print 
"      <media:thumbnail url=\"$base/albums/{$row["filepath"]}thumb_{$row["filename"]}\"/>\n";
    print 
"      <media:content url=\"$base/albums/{$row["filepath"]}{$row["filename"]}\"/>\n";
    print 
"    </item>\n";
  }
  print 
"  </channel>\n";
  print 
"</rss>";
}
// Create RSS

function rss20() {
    global 
$CONFIG$result$base$gallery_name$pic_data$album$album_name$CURRENT_CAT_NAME;

    
$superCage Inspekt::makeSuperCage();

    
// Decide what kind of title to be shown
    
if ((int)$album) {
        
$title " | Album: $album_name";
    } elseif (
$superCage->get->testInt('cat')) {
        if (
strip_tags($album_name)) {
            
$title ' | ' strip_tags($album_name);
        }
        if (
$superCage->get->getInt('cat') < 0) {
            
$albumDetails get_album_name(-($superCage->get->getInt('cat')));
            
$title .= " | Album: {$albumDetails['title']}";
        }
    } elseif (
$album) {
        
$title ' | 'strip_tags($album_name);
    }

    print 
"<?xml version=\"1.0\" encoding=\"{$CONFIG['charset']}\"?>
\n";
    print "<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">";
    print "<channel>\n";
    print "<title>{$gallery_name}{$title}</title>\n";
    print "<link>$base</link>\n";
    print "<description>".$CONFIG['gallery_description']."</description>\n";
    print "<language>en-US</language>\n";
    print "<lastBuildDate>"  . lmdate(time()) . "</lastBuildDate>\n";
    print "<generator>Coppermine RSS Aggregator</generator>\n\n";

    foreach ($pic_data as $row) {
        $title = $row['title'] ? $row['title'] : $row['filename'];
        print "\t<item>\n";
        print "\t\t<title>".htmlentities($title)."</title>\n";
        print "\t\t<link>$base/displayimage.php?pid={$row['pid']}</link>\n";
        print "\t\t<dc:creator>{$row['owner_name']}</dc:creator>\n";
        print "\t\t<pubDate>" . lmdate($row['ctime']) . "</pubDate>\n";
        print "\t\t<description>";
        echo  htmlentities("<p><img src=\"$base/".get_pic_url($row, 'thumb')."\" alt=\"{$row['filename']}\" /></p>");
        echo  htmlentities("<p>{$row['caption']}&nbsp;</p>");
        echo  htmlentities("<p>{$row['keywords']}</p>");

        if (isset($row['msg_body']) && !empty($row['msg_body'])) {
            // We have comment for the photo. Must be lastcom metaalbum feed. Display the comment
            echo  htmlentities("<p><b>Comment:</b> (<i>".date('Y-m-d H:m:s', $row['msg_date'])."</i>) - {$row['msg_author']}</p>");
            if ($CONFIG['enable_smilies']) {
                include_once("include/smilies.inc.php");
                $row['msg_body'] = process_smilies($row['msg_body']);
            }
            echo  htmlentities("<p>".bb_decode($row['msg_body'])."&nbsp;</p>");
        }

        print "</description>\n";
        print "\t\t<guid>$base/displayimage.php?pid={$row['pid']}</guid>\n";
        print "\t</item>\n";
        print "\n";
    }
    print "</channel>";
    print "</rss>";
}

function atom10() {
    global $CONFIG, $result, $base, $gallery_name, $CURRENT_CAT_NAME, $album, $album_name, $pic_data;

    $superCage = Inspekt::makeSuperCage();

    // Decide what kind of title to be shown
    if ((int)$album) {
        $title = " | Album: $album_name";
    } elseif ($superCage->get->testInt('cat')) {
        $title = " | Category: $CURRENT_CAT_NAME";
    } elseif ($album) {
        $title = ' | '. strip_tags($album_name);
    }

    print "<?xml version=\"1.0\" encoding=\"{$CONFIG['charset']}\"?>\n";
    print "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n";
    print "<title>$gallery_name{$title}</title>\n";
    print "<link href=\"$base\" />\n";
    print "<updated>" . rfc3339date(time()) . "</updated>\n";
    print "<author><name>Admin</name></author>\n";
    print "<id>$base/</id>\n";
    print "<generator uri=\"http://coppermine-gallery.net/\" version=\"1.0\">Coppermine Atom Aggregator</generator>\n";
    print "<link rel=\"self\" type=\"application/atom+xml\" href=\"$base" . $_SERVER["PHP_SELF"] . "?type=atom\" />\n\n";


    foreach ($pic_data as $row) {
        print "\t<entry>\n";
        print "\t\t<title> {$row['title']} </title>\n";
        print "\t\t<link href=\"$base/displayimage.php?pid={$row['pid']}\" />\n";
        print "\t\t<id>$base/displayimage.php?pid={$row['pid']}</id>\n";
        print "\t\t<updated>" . rfc3339date($row['ctime']) . "</updated>\n";
        print "\t\t<content type=\"html\">\n";
        echo  htmlentities("<p><img src=\"$base/".get_pic_url($row, 'thumb')."\" alt=\"{$row['filename']}\" /></p>");
        echo  htmlentities("<p>{$row['caption']}&nbsp;</p>");
        echo  htmlentities("<p>{$row['keywords']}</p>");

        if (isset($row['msg_body']) && !empty($row['msg_body'])) {
            // We have comment for the photo. Must be lastcom metaalbum feed. Display the comment
            echo  htmlentities("<p><b>Comment:</b> (<i>".date('Y-m-d H:m:s', $row['msg_date'])."</i>) - {$row['msg_author']}</p>");
            if ($CONFIG['enable_smilies']) {
                include_once("include/smilies.inc.php");
                $row['msg_body'] = process_smilies($row['msg_body']);
            }
            echo  htmlentities("<p>".bb_decode($row['msg_body'])."&nbsp;</p>");
        }

        print "\n\t\t</content>\n";
        print "\t</entry>\n";
        print "\n";
    }

    print "</feed>";
}

Step 3. Add the line bellow to the end of the file {application_root}/displayimages.php
Code: [Select]
<script src="http://apps.cooliris.com/slideshow/go.js" type="text/javascript"></script>

Step 4. Within {application_root}/include/themes.inc.php
  4.1. Locate the $slideshow_tgt variable and add bellow it:
Code: [Select]
$slideshow_cooliris=$CONFIG['ecards_more_pic_target']."index.php?file=xfeed/xfeed&album=$album&type=cooliris";
  4.2 Locate the $js_buttons variable and add the variable to array, becoming something like:
Code: [Select]
$js_buttons = array(
        'pic_info_title'  => $lang_img_nav_bar['pic_info_title'],
        'pic_info_btn'    => $pic_info_btn,
        'slideshow_tgt'   => $slideshow_tgt,
        'slideshow_title' => $lang_img_nav_bar['slideshow_title'],
        'slideshow_btn'   => $slideshow_btn,
        'loc' => $location,
        'slideshow_cooliris' => $slideshow_cooliris,
    )

  4.3 Locate END slideshow_button and add bellow it:
Code: [Select]
<!-- BEGIN cooliris_slideshow_button -->
                <!-- button will be added by displayimage.js -->
                <td id="cooliris_slideshow_button" align="center" valign="middle" class="navmenu" width="48"></td>
<!-- END slideshow_button -->

Step 5. Within {application_root}/js/displayimages.js, locate the function printSlideshowButton and add:
Code: [Select]
var btn2 = '<a href="javascript:cooliris.embed.show({maxScale:0,feed:encodeURIComponent(\'' + js_vars.buttons.slideshow_cooliris + '\')})" class="navmenu_pic" title="' + js_vars.buttons.slideshow_title + '" rel="nofollow"><img src="' + js_vars.buttons.loc + 'images/navbar/slideshow.png" border="0" align="middle" alt="' + js_vars.buttons.slideshow_title + '" /></a>';
    $('#cooliris_slideshow_button').append(btn2);
becoming something like this (entire function):
Code: [Select]
function printSlideshowButton() {
    // insert slideshow button as defined in theme or create default button
    var btn = js_vars.buttons.slideshow_btn ? js_vars.buttons.slideshow_btn
        : '<a href="' + js_vars.buttons.slideshow_tgt + '" class="navmenu_pic" title="' + js_vars.buttons.slideshow_title + '" rel="nofollow"><img src="' + js_vars.buttons.loc + 'images/navbar/slideshow.png" border="0" align="middle" alt="' + js_vars.buttons.slideshow_title + '" /></a>';
    $('#slideshow_button').append(btn);

    var btn2 = '<a href="javascript:cooliris.embed.show({maxScale:0,feed:encodeURIComponent(\'' + js_vars.buttons.slideshow_cooliris + '\')})" class="navmenu_pic" title="' + js_vars.buttons.slideshow_title + '" rel="nofollow"><img src="' + js_vars.buttons.loc + 'images/navbar/slideshow.png" border="0" align="middle" alt="' + js_vars.buttons.slideshow_title + '" /></a>';
    $('#cooliris_slideshow_button').append(btn2);
}

Now just go to a photo in an album and there should be 2 "play" buttons. The second one will open the cooliris slideshow. It requires the flash plugin, so be sure you have it installed.

That's it. Hope you can understand all steps. Fell free to make questions.
Title: Re: Better Slideshow: Coppermine + Cooliris
Post by: Jeff Bailey on September 28, 2010, 06:48:43 pm
Does this work the same as => http://forum.coppermine-gallery.net/index.php/topic,67091.0.html
Title: Re: Better Slideshow: Coppermine + Cooliris
Post by: robertokl on September 28, 2010, 07:05:49 pm
Well, it should be, but I wasn't able to install the plugin (dunno what I could be doing wrong) and the Demo doesn't work either.
Title: Re: Better Slideshow: Coppermine + Cooliris
Post by: julakali on November 24, 2010, 10:14:54 pm
This is really awesome, especially since theres NO fullscreen plugin available for CPG 1.5 right now!
Works quite good (only with XFeed 1.8 though).
Title: Re: Better Slideshow: Coppermine + Cooliris
Post by: dgi on April 06, 2011, 02:50:32 am
Hey - I've followed every step, have two buttons - but no Colliris.. any ideas. My page works.. the back and forward play buttons work.