<?php
/**
* @Copyright Copyright (C) 2007- 2010 Jeff Arthur
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
// no direct access
defined('_JEXEC') or die( 'Restricted access' );
/** load useful things*/
JApplicationHelper::getPath('front_html');
JApplicationHelper::getPath('com_jsmugplus');
JApplicationHelper::getPath('mosFactory');
//require_once("components\com_jsmugplus\jsmug.html.php");
include_once (JPATH_ROOT.DS.'components'.DS."com_jsmugplus".DS."jsmug.html.php");
$mainframe =& JFactory::getApplication();
// Where are we?
define( 'JSMUGBASEPATH', dirname(__FILE__) );
// globals
global $mosConfig_cachepath, $imagepath, $Smugmug, $Debug ,$thumbSize, $zoomedSize, $useLightBox,$SmugmugSelling;
// Get params from DB
#$menu = new JTableMenu( $database );
#$menu = new mosMenu( $database );
#$menu->load( $Itemid );
#$Itemid = mosGetParam( $_REQUEST, 'Itemid');
#$Itemid = mosGetParam( $_REQUEST, 'Itemid');
$Itemid = JRequest::getVar('Itemid');
//global $mainframe;
// Get the page/component configuration
//$params = &$mainframe->getParams();
$app = &JFactory::getApplication();
$params = $app->getParams();
$AlbumID=htmlspecialchars($params->get( 'smug_AlbumID', '682488' ));
$Debug=htmlspecialchars($params->get( 'smug_Debug', '0' ));
$UseSecureSocket=htmlspecialchars($params->get( 'smug_Secure', '0' ));
$SmugmugSelling=htmlspecialchars($params->get( 'smug_Selling', '1' ));
$useLightBox=htmlspecialchars($params->get( 'smug_useLightBox', '1' ));
$SessionCacheLifetime=htmlspecialchars($params->get( 'smug_SessionCacheLifetime', '10800' ));
$GalleryCacheLifetime=htmlspecialchars($params->get( 'smug_GalleryCacheLifetime', '900' ));
$GalleryImagesPerPage=htmlspecialchars($params->get( 'smug_GalleryImagesPerPage', '10' ));
$thumbSize=htmlspecialchars($params->get( 'smug_thumbnailSize', 'TinyURL' ));
$zoomedSize=htmlspecialchars($params->get( 'smug_zoomedSize', 'MediumURL' ));
#$GalleryImageOffset=mosGetParam( $_REQUEST, 'imageoffset', '1' );
$GalleryImageOffset=JRequest::getVar('imageoffset', '1' );
$Debug=htmlspecialchars($params->get( 'smug_Debug', '0' ));
$useProtect=htmlspecialchars($params->get( 'smug_useProtect' , '0' ));
$useTopNav=htmlspecialchars($params->get( 'smug_useTopNav' , '1' ));
$useBottomNav=htmlspecialchars($params->get( 'smug_useBottomNav' , '1' ));
// include required Stuff
require_once(JSMUGBASEPATH .DS."SmugmugAPI.php");
require_once(JSMUGBASEPATH .DS."phppaginator-1.0".DS."Paginator.php");
// Use Cache
#require_once( $mosConfig_absolute_path . '/includes/Cache/Lite/Function.php' );
// Setup Session Cache
$lifetime=$SessionCacheLifetime;
#$SessionCache = new Cache_Lite( array("cacheDir" => $mosConfig_cachepath."/", "lifeTime" => $lifetime) );
// Setup Galley Cache
$lifetime=$GalleryCacheLifetime;
#$GalleryCache = new Cache_Lite( array("cacheDir" => $mosConfig_cachepath."/", "lifeTime" => $lifetime) );
// Wake up the SmugMug API
$Smugmug= new SmugmugAPI();
// Get Our Call URL
$mosConfig_live_site = JUri::base();
$callURL = htmlspecialchars($mosConfig_live_site . "/index.php?option=com_jsmugplus&Itemid=" . $Itemid . "&imageoffset=");
// Dump Config Values in Debug
if ( $Debug ) smug_HTML::printDebug("SmugmugSelling: " . $SmugmugSelling );
// Get A Session ID for Smugmug cached or otherwise
// $cachedsession = $SessionCache->get("jsmug_SmugmugAPISession");
// if ( $Debug ) smug_HTML::printDebug("Cached Session : " . $cachedsession) ;
// if ($cachedsession) {
// if ( $Debug ) smug_HTML::printDebug("Using Cached Session ID") ;
// $SessionID = $cachedsession;
//} else {
// if ( $Debug ) smug_HTML::printDebug("No Cached Session ID Available Query SmugMug ") ;
$SessionID = $Smugmug->SmugmugLoginAnonymously($UseSecureSocket);
if ( $Debug ) smug_HTML::printDebug($SessionID) ;
// $SessionCache->save($SessionID,"jsmug_SmugmugAPISession");
// $cachedsession = $SessionCache->get("jsmug_SmugmugAPISession");
// $SessionID = $cachedsession;
//}
if ($SessionID) {
smug_HTML::printJsmugCSS($mosConfig_live_site);
if ( $Debug ) smug_HTML::printDebug("Session ID: " . $SessionID );
if ( $Debug ) smug_HTML::printDebug("Album ID: " . $AlbumID );
if ( $Debug ) smug_HTML::printDebug("Image Path: " . $imagepath );
if ( $useLightBox) smug_HTML::printLightBoxSetup($mosConfig_live_site);
if ( $useProtect) smug_HTML::printImgProtect($mosConfig_live_site);
smug_HTML::printPaginatorCSS($mosConfig_live_site);
// if ($cachedgallery = $GalleryCache->get("jsmug_GalleryData" . $AlbumID) ) {
// if ( $Debug ) smug_HTML::printDebug("Using Cached Gallery Data") ;
// $GalleryData = unserialize($cachedgallery);
// } else {
// if ( $Debug ) smug_HTML::printDebug("No Cached Cached Gallery Data is Available Query SmugMug ") ;
$GalleryData = $Smugmug->SmugmugImagesGet($SessionID,$AlbumID,$UseSecureSocket);
// $GalleryCache->save(serialize($GalleryData),"jsmug_GalleryData" . $AlbumID);
// }
// if ( $Debug ) smug_HTML::printDebug(print_r($GalleryData)) ;
if ($GalleryData) {
$lastImage = $GalleryImageOffset + $GalleryImagesPerPage;
if ( $Debug ) smug_HTML::printDebug("lastImage: " . $lastImage);
if ( $Debug ) smug_HTML::printDebug("GalleryImageOffset: " . $GalleryImageOffset);
if ( $useTopNav ) Paginator::paginate($GalleryImageOffset,sizeof($GalleryData),$GalleryImagesPerPage,$callURL);
smug_HTML::startDIV("jsmugcontainer");
smug_HTML::startDIV("jsmugspacerdiv");
smug_HTML::nbsp();
smug_HTML::endDIV();
for ( $counter = $GalleryImageOffset; $counter < $lastImage; $counter += 1) {
// if ( $Debug ) smug_HTML::printDebug(print_r($GalleryData[$counter-1])) ;
if ( $counter > sizeof($GalleryData)) break;
smug_HTML::startDIV("jsmugframediv");
smug_HTML::startDIV(getPhotoDivName($thumbSize));
outputImage($GalleryData[$counter-1]);
smug_HTML::endDIV();
smug_HTML::endDIV();
}
smug_HTML::startDIV("jsmugspacerdiv");
smug_HTML::nbsp();
smug_HTML::endDIV();
smug_HTML::endDIV();
if ( $useBottomNav ) Paginator::paginate($GalleryImageOffset,sizeof($GalleryData),$GalleryImagesPerPage,$callURL);
} else {
smug_HTML::printError("Non Existant or empty Gallery");
}
} else {
if ( $Debug ) smug_HTML::printDebug("No Valid Session\n");
smug_HTML::printError("Unable to Connect to Smugmug, This probably means that you do not have libcurl support in you php installation AND you have remote file access disabled in php config. The best way round this is to get libcurl support for your version of php. If you know what this means you probably have access to do this yourself, if not ask your hosting provider. As a last resort you could even set allow_url_fopen = On in you php config, but i woulnt't advise it. This is probably an environmental issue on your server. Consider disabling SSL in the JSmug parameters. It is also possible, though very unlikely, that Smugmug is down");
}
smug_HTML::startDIV("jsmugComponentFooter");
smug_HTML::printComponentFooter();
smug_HTML::endDIV();
function getPhotoDivName($thumbSize) {
switch ( $thumbSize ) {
case "TinyURL":
$photDivName='jsmugfloattiny';
break;
case "ThumbURL":
$photDivName='jsmugfloatthumb';
break;
case "SmallURL":
$photDivName='jsmugfloatsmall';
break;
case "MediumURL":
$photDivName='jsmugfloatmedium';
break;
case "LargeURL":
$photDivName='jsmugfloatlarge';
break;
case "OriginalURL":
$photDivName='jsmugfloatoriginal';
break;
default:
$photDivName='jsmugfloattiny';
break;
}
return $photDivName;
}
{JFBCComments}
function outputImage($Image) {
global $Debug,$Smugmug,$useLightBox,$SmugmugSelling, $thumbSize,$zoomedSize;
if ( $Debug ) smug_HTML::printDebug("Image ID: " . $Image["id"]) ;
if ( $Debug ) smug_HTML::printDebug("Thumb Size: " . $thumbSize) ;
if ( $Debug ) smug_HTML::printDebug("Zoomed Size: " . $zoomedSize) ;
smug_HTML::printStartLink($Image[$zoomedSize],$Image["AlbumURL"],$SmugmugSelling,$useLightBox);
smug_HTML::printImageSource( $Image[$thumbSize] );
smug_HTML::printEndLink();
if ($SmugmugSelling) smug_HTML::printBuyLink( $Image["AlbumURL"] );
smug_HTML::printPhotoSeparator();
}
?>
</body></html>Join our newsletter to get alerts for Joomla releases, tips and tricks and extension updates.
