188 lines
6.3 KiB
PHP
188 lines
6.3 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = getLanguageText('TEXT-PHOTO-GALLERIES');
|
|
|
|
|
|
// Get gallery number
|
|
unset($gallery_num);
|
|
if (array_key_exists('gallery_num',$_GET)) $gallery_num = intval($_GET['gallery_num']);
|
|
if (array_key_exists('gallery_num',$_POST)) $gallery_num = intval($_POST['gallery_num']);
|
|
|
|
// Validate the gallery number
|
|
if (isset($gallery_num)) {
|
|
$results = db_query("SELECT * FROM photo_galleries WHERE school_num = $school_num AND record_num = $gallery_num");
|
|
if (db_num_rows($results) != 1) {
|
|
$error_message = getLanguageText('ERRORMSG-NOT-FOUND');
|
|
$naction = 'list';
|
|
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$row = db_fetch_array($results);
|
|
extract($row);
|
|
$templatePageTitle = $gallery_title;
|
|
}
|
|
|
|
|
|
// Display selected gallery
|
|
if (isset($gallery_num)) {
|
|
|
|
$perRow = 5;
|
|
$perPage = $perRow * 3;
|
|
$limit = "limit 0,$perPage";
|
|
|
|
if (array_key_exists('pg',$_GET)) {
|
|
$pg = intval($_GET['pg']);
|
|
|
|
if ($pg > 0) {
|
|
$n = ($pg - 1) * $perPage;
|
|
$limit = "limit $n,$perPage ";
|
|
}
|
|
}
|
|
|
|
// Determine number of images in gallery
|
|
$total = db_getVal("SELECT count(*) FROM photo_gallery_images WHERE school_num = $school_num AND gallery_num = $gallery_num");
|
|
|
|
// Get the images for this gallery
|
|
$images = db_query("SELECT * FROM photo_gallery_images WHERE school_num = $school_num AND gallery_num = $gallery_num ORDER BY sequence $limit");
|
|
if (db_num_rows($images)) {
|
|
|
|
if ($total > $perPage) {
|
|
if (!isset($pg)) $pg = 1;
|
|
|
|
$link = "action=photo-gallery&gallery_num=$gallery_num";
|
|
|
|
$last = 1;
|
|
for ($i = 1; (($i - 1) * $perPage) <= $total; $i++) {
|
|
if ($i == $pg) $pages .= "[$i] ";
|
|
else $pages .= "[<a href='?$link&pg=$i'>$i</a>] ";
|
|
$last = $i;
|
|
}
|
|
|
|
$prev = $pg - 1;
|
|
if ($prev > 0) $pages = "<a href='?$link&pg=$prev'><<<</a> $pages";
|
|
|
|
$next = $pg + 1;
|
|
if ($next <= $last) $pages .= " <a href='?$link&pg=$next'>>>></a>";
|
|
|
|
$pages = "$pages<br><br>";
|
|
}
|
|
|
|
if (!isset($pages)) $pages = '';
|
|
?>
|
|
<table width='90%' cellpadding='5' cellspacing='3' border='0'>
|
|
<tr>
|
|
<td colspan='<?php echo($perRow) ?>' align='center'><?php echo($pages) ?>Click on any Image to View a Larger Version</td>
|
|
</tr>
|
|
<?php
|
|
|
|
$count = 0;
|
|
$cellWidth = intval(100 / $perRow);
|
|
|
|
while ($row = db_fetch_array($images)) {
|
|
extract($row);
|
|
if (($count % $perRow) == 0) {
|
|
if ($count > 0) echo(" </tr>\n");
|
|
echo(" <tr>\n");
|
|
}
|
|
$count++;
|
|
|
|
//$image_size = GetImageSize("$gallerydir/$photo");
|
|
//$image_width = $image_size[0];
|
|
//$image_height = $image_size[1];
|
|
|
|
//$span_id = "img_span$record_num";
|
|
//$otipSpans .= "<span id='$span_id'>" . sprintf($otipIMG,"$galleryurl/$photo",$image_height,$image_width,$product_name) . "</span>\n";
|
|
// $image = "<a href=\"javascript:TagToTip('$span_id')\" onmouseover=\"TagToTip('$span_id')\" onmouseout=\"UnTip()\"><img src='$galleryurl/$thumbnail' border='2'></a>";
|
|
|
|
$image = "<a href='$galleryurl/$photo' rel='lightbox[property]'><img src='$galleryurl/$thumbnail' border='2'></a>";
|
|
echo(" <td width='$cellWidth%' align='center'>$image</td>\n");
|
|
}
|
|
unset($otipSpans);
|
|
?>
|
|
</tr>
|
|
<?php
|
|
if (isset($pages) && strlen($pages) > 0) {
|
|
?>
|
|
<tr>
|
|
<td colspan='<?php echo($perRow) ?>' align='center'><br><?php echo($pages) ?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
</table>
|
|
<?php
|
|
}
|
|
}
|
|
else {
|
|
$query = "SELECT gallery_title,description,category_num,category_title,added_date,active,sequence,pg.record_num " .
|
|
"FROM photo_galleries AS pg, photo_gallery_categories AS pgc " .
|
|
"WHERE pg.school_num = $school_num " .
|
|
"AND active = 'Y' " .
|
|
"AND pg.category_num = pgc.record_num " .
|
|
"ORDER BY sequence,added_date";
|
|
$galleries = db_query($query);
|
|
|
|
if (db_num_rows($galleries)) {
|
|
$prevCategory = 0;
|
|
while ($row = db_fetch_array($galleries)) {
|
|
extract($row);
|
|
if ($category_num != $prevCategory) {
|
|
if ($prevCategory != 0) {
|
|
echo(" </ul>\n");
|
|
echo(" </td>\n");
|
|
echo(" </tr>\n");
|
|
echo(" </table>\n");
|
|
}
|
|
$prevCategory = $category_num;
|
|
|
|
echo(" <br >\n");
|
|
echo(" <table width='70%' cellpadding='1' cellspacing='1' border='0' class='content-table'>\n");
|
|
echo(" <tr>\n");
|
|
echo(" <td align='center' class='heading'>$category_title</td>\n");
|
|
echo(" </tr>\n");
|
|
echo(" <tr>\n");
|
|
echo(" <td align='left'>\n");
|
|
echo(" <ul>\n");
|
|
}
|
|
|
|
echo(" <li><b><a href='/?action=photo-gallery&gallery_num=$record_num'>$gallery_title</a></b>");
|
|
if (strlen($description)) {
|
|
echo(" <br><a href=''>$description</a>\n");
|
|
}
|
|
echo(" </li>\n");
|
|
}
|
|
|
|
echo(" </ul>\n");
|
|
echo(" </tr>\n");
|
|
echo(" </table>\n");
|
|
}
|
|
}
|
|
|
|
|
|
// Ensure that only valid user types can see the buttons
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Communications Administrator');
|
|
if (isset($gallery_num) && checkPermission($AllowedUserTypes) == 1) {
|
|
?>
|
|
<br>
|
|
<table cellpadding='10'>
|
|
<tr>
|
|
<td align='center'><a href='?action=photo-gallery-images&naction=list&gallery_num=<?php echo($gallery_num) ?>' class='btn btn--primary>'> Manage Gallery </a></td>
|
|
<td align='center'><a href='?action=photo-gallery-images&gallery_num=<?php echo($gallery_num) ?>&naction=upload' class='btn btn--primary>'> Upload Images </a></td>
|
|
</tr>
|
|
</table>
|
|
<?php
|
|
}
|
|
|
|
endTemplate();
|
|
?>
|