<?PHP
ob_start();
session_start();
include("includes/globals.php.inc");
include("includes/functions.php");
include("lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("lang/".$sxSetup['Language'].".php");
include("themes/$THEME_FOLDER/config.php.inc");
protectComponentPage(2);
if(userAdmin()){
if($upid) moveAlbumUp($upid);
if($downid) moveAlbumDown($downid);
if($topid) moveAlbumTop($topid);
if($bottomid) moveAlbumBottom($bottomid);
if($delete){ deleteAlbum($delete, $allpics); $message = $sxLang['MessagePhotoAlbumMiniDeleted']; }
}
$totalPics = 0;
$query = "SELECT id FROM $DB_Photos";
$result = mysql_query($query, $Link) or queryError("16", mysql_error());
while($ROW = mysql_fetch_object($result))
{
if(sxPhotoUserAccess($ROW->id, $THIS_USER) == TRUE)
$totalPics = $totalPics + 1;
}
$myAlbums = array();
$query = "SELECT id FROM $DB_Photos_Albums ORDER BY position";
$result = mysql_query($query, $Link) or queryError("16", mysql_error());
while($ROW = mysql_fetch_object($result))
{
if(sxAlbumUserAccess($ROW->id, $THIS_USER) == TRUE)
array_push($myAlbums, $ROW->id);
}
$totalAlbums = count($myAlbums);
if($totalAlbums < $sxSetup['GalleryNumColumns'])
$sxRealNumColumns = $totalAlbums;
else
$sxRealNumColumns = $sxSetup['GalleryNumColumns'];
$query = "SELECT * FROM $DB_Photos ORDER BY timestamp DESC";
$result = mysql_query($query, $Link) or queryError("16", mysql_error());
$ROW = mysql_fetch_object($result);
if($ROW->timestamp != 0)
$lastUpdated = fetchDate($ROW->timestamp, 3, 1);
else
$lastUpdated = "__-__-____";
if(!$page) $page = 1;
$start = ($page - 1)*$sxSetup['AlbumsPerPage'];
$sxTitleAddendum = getComponentName("2");
include("themes/$THEME_FOLDER/header.php");
?>
<?PHP if((userEditor())OR(userAdmin())) { ?>
<script language="JavaScript" type="text/JavaScript">
<!--
function confirmDelete(theID,theName){
if(confirm("<?PHP echo $sxLang['PhotoAlbumJSDeleteAlbum1']; ?> '"+theName+"' <?PHP echo $sxLang['GeneralJSDeleteEntry2']; ?>")){
if(confirm("<?PHP echo $sxLang['PhotoAlbumJSDeletePhotos']; ?>")){
window.location='<?PHP print $PHP_SELF."?allpics=1&delete="; ?>'+theID;
}else{
window.location='<?PHP print $PHP_SELF."?allpics=0&delete="; ?>'+theID;
}
}
}
//-->
</script>
<?PHP } ?>
<div class="bodyWrapper">
<h1><?PHP echo getComponentName("2"); ?></h1>
<?PHP echoMessage($message); ?>
<?php
if ($sxThemeConfig['GalleryHideData'] == 1)
echo '';
else {
echo '<div class="galleryData">'. $sxLang['PhotoTotal'] .': <strong>'. $totalPics .'</strong>';
echo ' '. $sxLang['PhotoTotalAlbums'] .': <strong>'. $totalAlbums .'</strong>';
echo ' '. $sxLang['PhotoLastUpdated'] .': <strong>'. $lastUpdated .'</strong></div>';
}
?>
<div class="pageTurns">
<?PHP pageTurns($PHP_SELF."?", $totalAlbums, $page, $sxSetup['AlbumsPerPage']); ?></div>
<div class="sxGalleryLayout">
<?PHP
echo '<table border="0" cellpadding="0" cellspacing="0" width="' . ($sxThemeConfig['ContentWidth']-10) . '" align="center">'."\n";
$count = 0;
$display = false;
$limit_end = ($page)*$sxSetup['AlbumsPerPage'];
if($limit_end > count($myAlbums))
$limit_end = count($myAlbums);
$limit_start = ($page-1)*$sxSetup['AlbumsPerPage'];
for($i = $limit_start; $i < $limit_end; $i++)
{
$display = true;
$query = "SELECT * FROM $DB_Photos_Albums WHERE id='$myAlbums[$i]'";
$result = mysql_query($query, $Link) or queryError("16", mysql_error());
$ROW = mysql_fetch_object($result);
if($count == 0) echo '<tr>';
$found = false;
if(sxAlbumUserAccess($ROW->id, $userid) == TRUE)
{
echo '<td valign="top"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr valign="top">'."\n";
echo '<td valign="top" align="'. $sxThemeConfig['GalleryThumbAlign'] .'" width="' . (($sxThemeConfig['ContentWidth']-10)/$sxRealNumColumns) . '">'."\n";
// An image has been assigned as the album cover
if ($ROW->picture)
{
// Compute dimensions
list($width_original, $height_original) = getimagesize($sxContentDir['PhotoThumb'] . $ROW->picture);
$dimensions = resizeDimensions($width_original, $height_original, $sxSetup['GalleryMaxDimensionThumb']);
$thumbW = $dimensions[0]+1;
$thumbH = $dimensions[1]+1;
echo '<table style="float: '. $sxThemeConfig['GalleryThumbPos'] .';" cellpadding="0" cellspacing="0" class="sxGalleryThumbnailContainer"><tr><td width="' . $sxSetup['GalleryMaxDimensionThumb'] . '" height="' . $sxSetup['GalleryMaxDimensionThumb'] . '" valign="'. $sxThemeConfig['GalleryThumbAlignVert'] .'" style="text-align: '. $sxThemeConfig['GalleryThumbPos'] .'" class="sxGalleryThumb" ><a href="album.php?albumid=' . $ROW->id . '"><img src="' . $sxContentDir['PhotoThumb'] . $ROW->picture . '" height="' . $thumbH . '" width="' . $thumbW . '" alt="' . $ROW->name . '"/></a></td></tr></table>';
}
// No image has been assigned, pull the first image
else
{
$query4 = "SELECT * FROM $DB_Photos, $DB_Photos_Assoc
WHERE $DB_Photos_Assoc.photoid=$DB_Photos.id AND
$DB_Photos_Assoc.albumid='$ROW->id'
ORDER BY position LIMIT 0,1";
$result4 = mysql_query($query4, $Link) or queryError("16", mysql_error());
if(mysql_num_rows($result4))
{
$ROW4 = mysql_fetch_object($result4);
// Compute dimensions
list($width_original, $height_original) = getimagesize($sxContentDir['PhotoThumb'] . $ROW4->filename);
$dimensions = resizeDimensions($width_original, $height_original, $sxSetup['GalleryMaxDimensionThumb']);
$thumbW = $dimensions[0]+1;
$thumbH = $dimensions[1]+1;
//list($thumbW, $thumbH) = getimagesize($sxContentDir['PhotoThumb'] . $ROW4->filename);
echo '<table style="float: '. $sxThemeConfig['GalleryThumbPos'] .';" cellpadding="0" cellspacing="0" class="sxGalleryThumbnailContainer"><tr><td width="' . $sxSetup['GalleryMaxDimensionThumb'] . '" height="' . $sxSetup['GalleryMaxDimensionThumb'] . '" valign="'. $sxThemeConfig['GalleryThumbAlignVert'] .'" style="text-align: '. $sxThemeConfig['GalleryThumbPos'] .'" class="sxGalleryThumb" ><a href="album.php?albumid=' . $ROW->id . '"><img src="' . $sxContentDir['PhotoThumb'] . $ROW4->filename . '" height="' . $thumbH . '" width="' . $thumbW . '" alt="' . $ROW->name . '"/></a></td></tr></table>'."\n";
}
// Album is empty, get the default image
else
{
// Compute dimensions
list($width_original, $height_original) = getimagesize('images/default_picture.jpg');
$dimensions = resizeDimensions($width_original, $height_original, $sxSetup['GalleryMaxDimensionThumb']);
$thumbW = $dimensions[0]+1;
$thumbH = $dimensions[1]+1;
//list($thumbW, $thumbH) = getimagesize('images/default_picture.jpg');
echo '<table style="float: '. $sxThemeConfig['GalleryThumbPos'] .';" cellpadding="0" cellspacing="0" class="sxGalleryThumbnailContainer"><tr><td width="' . $sxSetup['GalleryMaxDimensionThumb'] . '" height="' . $sxSetup['GalleryMaxDimensionThumb'] . '" valign="'. $sxThemeConfig['GalleryThumbAlignVert'] .'" style="text-align: '. $sxThemeConfig['GalleryThumbPos'] .'" class="sxGalleryThumb" ><a href="album.php?albumid=' . $ROW->id . '"><img src="' . $sxSetup['Url'] . '/images/default_picture.jpg" height="' . $thumbH . '" width="' . $thumbW . '" alt="' . $ROW->name . '"/></a></td></tr></table>';
}
}
echo '<div style="text-align: '. $sxThemeConfig['GalleryThumbPos'] .'" class="sxAlbumDescription" >'."\n";
echo '<a href="album.php?albumid=' . $ROW->id . '"><strong>' . $ROW->name . '</strong></a><br />'."\n";
echo '<span class="sxSmallText">'."\n";
// Admin album editing
if((userAdmin())OR((userEditor())AND($sxSetup['EditorRightsAlbumsManage'])))
{
echo '<a href="admin/photo_album_edit.php?editid=' . $ROW->id . '&sxPrevURL='.urlencode("http://{$HTTP_HOST}{$REQUEST_URI}").'"><img src="images/edit.gif" style="border: 0;" alt="' . $sxLang['ButtonEdit'] . '" /></a> '."\n";
echo '<a href="#" onclick="confirmDelete(' . $ROW->id . ',\'' . addslashes($ROW->name) . '\')"><img src="images/delete.gif" style="border: 0;" alt="' . $sxLang['ButtonDelete'] . '" /></a> '."\n";
echo '<a href="' . $PHP_SELF . '?upid=' . $ROW->id . '&page=' . $page . '"><img src="images/up.gif" style="border: 0;" alt="' . $sxLang['ButtonUp'] . '" /></a> '."\n";
echo '<a href="' . $PHP_SELF . '?downid=' . $ROW->id . '&page=' . $page . '"><img src="images/down.gif" style="border: 0;" alt="' . $sxLang['ButtonDown'] . '" /></a> '."\n";
echo '<a href="' . $PHP_SELF . '?topid=' . $ROW->id . '&page=' . $page . '"><img src="images/top.gif" style="border: 0;" alt="' . $sxLang['ButtonTop'] . '" /></a> '."\n";
echo '<a href="' . $PHP_SELF . '?bottomid=' . $ROW->id . '&page=' . $page . '"><img src="images/bottom.gif" style="border: 0;" alt="' . $sxLang['ButtonBottom'] . '" /></a><br /> '."\n";
}
if($sxSetup['GalleryShowDescription'] == 1 && $ROW->description)
{
if($sxSetup['GalleryDescriptionTrunc'] > 0)
echo nl2br(limitString($ROW->description, $sxSetup['GalleryDescriptionTrunc']))."\n";
else echo nl2br($ROW->description)."\n";
}
if($sxSetup['GalleryShowCreated'] == 1)
echo '<br /><span class="shadowText">' . $sxLang['GeneralItemDate'] . ': ' . fetchDate($ROW->timestamp, 2, 1) . '</span>';
if($sxSetup['AlbumShowNumPhotos'] == 1)
{
$query2 = "SELECT * FROM $DB_Photos_Assoc WHERE albumid='$ROW->id'";
$result2 = mysql_query($query2, $Link) or queryError("17", mysql_error());
echo '<br /><span class="shadowText">' . $sxLang['PhotoItemPhotos'] . ': ' . mysql_num_rows($result2) . '</span>'."\n";
}
echo '</span></div></td>'."\n";
echo '</tr></table></td>'."\n";
}
if($count == ($sxRealNumColumns - 1))
{
echo '</tr>'."\n";
$count = 0;
}
else $count = $count + 1;
}
if(!$display) echo '<tr align="center"><td><em>' . $sxLang['NoAlbums'] . '</em></td></tr>';
echo '</table>'."\n";
?>
<div class="pageTurns"><?PHP pageTurns($PHP_SELF."?", $totalAlbums, $page, $sxSetup['AlbumsPerPage']); ?></div>
</div>
</div>
<?PHP
include("themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>