Click for Full Size
// Create a Gallery from the database
function PhotoThumbs($NumCols,$PageKey)
{
$myKey = $PageKey;
if($myKey == null)
{
$myKey = 0;
}
$myCols = $NumCols;
if($myCols == null)
{
$myCols = 3;
}
elseif($myCols < 1)
{
$myCols = 1;
}
require("../theFireRing/phputility/util.php");
$sql = new MySQL_class;
$sql->Create("");
$myQuery = "SELECT T.PhotoKey, T.ThumbFolder, T.ThumbName, T.WallpaperFolder, T.WallpaperName1024x768, T.WallpaperName800x600 FROM Photos T WHERE T.PageKey = $myKey ORDER BY T.DisplayOrder ";
$sql->Query($myQuery);
if($sql->rows < 1)
{
echo("
photos coming soon ");
}
else
{
echo("
");
$Count=0;
for ($i = 0; $i < $sql->rows; $i++)
{
$sql->Fetch($i);
$row = $sql->data;
$Count = $Count+1;
if($Count==1)
{
echo("");
}
echo("");
echo("
");
if($row[WallpaperName1024x768] != null)
{
echo("Wallpaper 1024x768 ");
}
if($row[WallpaperName800x600] != null)
{
echo("Wallpaper 800x600 ");
}
echo(" | ");
// have we filled all the columns? if so close the row and reset the counter.
if($Count==$myCols)
{
echo("
");
$Count=0;
}
}
// Did we end with a finished Row? If not then finish it.
if($Count!=0)
{
for ($x = 1; $x < $myCols-$Count; $x++)
{
echo(" | ");
}
echo("");
}
echo("
");
}
}
// Create a Gallery from the database using Thickbox
function CreateDatabaseGallery($NumCols,$PageKey, $galleryName, $galleryTitle, $useThickBox )
{
$myKey = $PageKey;
if($myKey == null)
{
$myKey = 0;
}
$myCols = $NumCols;
if($myCols == null)
{
$myCols = 3;
}
elseif($myCols < 1)
{
$myCols = 1;
}
require("../theFireRing/phputility/util.php");
$sql = new MySQL_class;
$sql->Create("");
$myQuery = "SELECT T.PhotoKey, T.FileName, T.ThumbFolder, T.ThumbName, T.WallpaperFolder, T.WallpaperName1024x768, T.WallpaperName800x600 FROM Photos T WHERE T.PageKey = $myKey ORDER BY T.DisplayOrder ";
$sql->Query($myQuery);
if($sql->rows < 1)
{
echo("
photos coming soon ");
}
else
{
// Start the gallery
$output .= "
";
$output .= ""; // ensure that we always have at least one row for proper HTML
$counter = 0;
$firstPass = true;
// loop through the data rows
for ($i = 0; $i < $sql->rows; $i++)
{
$sql->Fetch($i);
$row = $sql->data;
$Counter = $Counter+1;
if($Counter==1 && $firstPass==false) //if this is the first pass skip the row start because we already have it.
{
$output .= "
";
}
$output .= "";
if($useThickBox==true)
{
$output .= " ";
}
else
{
$output .= " ";
}
$output .= "";
$output .= " ";
if($row[WallpaperName1024x768] != null)
{
$output .= "Wallpaper 1024x768 ";
}
if($row[WallpaperName800x600] != null)
{
$output .= "Wallpaper 800x600 ";
}
$output .= " | ";
// have we filled all the columns? if so close the row and reset the counter.
if($Counter==$myCols)
{
$output .= "
";
$Counter=0;
}
if($firstPass == true) //firstPass will be set to false after the first iteration of this loop
{
$firstPass = false;
}
}
}
// Did we end with a finished Row? If not then finish it.
if($Counter!=0)
{
for ($x = 1; $x < $myCols-$Counter; $x++)
{
$output .= " | ";
}
$output .= "";
}
$output .= "
";
// display the gallery
echo $output;
}
// Create a gallery from a file structure
function createGallery( $pathToImages, $pathToThumbs, $numCols, $galleryName, $galleryTitle, $useThickBox )
{
//check and prefill parameters if needed
$myCols = $numCols;
if($myCols == null)
{
$myCols = 3;
}
elseif($myCols < 1)
{
$myCols = 1;
}
if($useThickBox == null)
{
$useThickBox = false;
}
// Start the gallery
$output .= "
";
$output .= ""; // ensure that we always have at least one row for proper HTML
// open the directory containing the photo thumbs
$dir = opendir( $pathToThumbs );
$counter = 0;
$firstPass = true;
// loop through the directory
while (false !== ($fname = readdir($dir)))
{
// strip the . and .. entries out
if ($fname != '.' && $fname != '..')
{
$Counter = $Counter+1;
if($Counter==1 && $firstPass==false) //if this is the first pass skip the row start because we already have it.
{
$output .= "
";
}
$output .= "";
if($useThickBox==true)
{
$output .= "";
}
else
{
$output .= "";
}
$output .= "";
$output .= "";
$output .= " | ";
// have we filled all the columns? if so close the row and reset the counter.
if($Counter==$myCols)
{
$output .= "
";
$Counter=0;
}
if($firstPass == true) //firstPass will be set to false after the first iteration of this loop
{
$firstPass = false;
}
}
}
// Did we end with a finished Row? If not then finish it.
if($Counter!=0)
{
for ($x = 1; $x < $myCols-$Counter; $x++)
{
$output .= " | ";
}
$output .= "";
}
$output .= "
";
// close the directory
closedir( $dir );
// display the gallery
echo $output;
}
// Resize Pictures
function createThumbs( $pathToImages, $pathToThumbs, $thumbMaxSide)//, $showMessages
{
// open the directory
$dir = opendir( $pathToImages );
// loop through it, looking for any/all JPG files:
while (false !== ($fname = readdir( $dir ))) {
// parse path for the extension
$info = pathinfo($pathToImages . $fname);
// continue only if this is a JPEG image
if ( strtolower($info['extension']) == 'jpg' )
{
//if($showMessages)
//{
echo "Creating thumbnail for {$fname}
";
//}
// load image and get image size
$img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
$width = imagesx( $img );
$height = imagesy( $img );
// calculate thumbnail size
if($width > $height)
{
$new_width = $thumbMaxSide ;
$new_height = floor( $height * ( $thumbMaxSide / $width ) );
}
else
{
$new_width = floor( $width* ( $thumbMaxSide / $height) );
$new_height = $thumbMaxSide ;
}
// create a new temporary image
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
// copy and resize old image into new image
//imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
imagecopyresampled( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
// save thumbnail into a file
imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
}
}
// close the directory
closedir( $dir );
}
//function createThumbs( $pathToImages, $pathToThumbs, $thumbMaxSide )
//{
// createThumbs( $pathToImages, $pathToThumbs, $thumbMaxSide, true );
//}
?>