<?php
/*
phpRealGallery - A class for displaying images sorted in galleries
Version 0.1 - 14/07/2001
Thomas Uttenthaler (tom@uttenthaler.at || IRCnet->#webmasters.at->z3non)
Requirements:
HTTP-Server (tested with Apache)
PHP (tested with PHP 4)
SQL-Server (tested with Postgre 7.0)
a browser with graphic-capalities :-)
Credits:
PHPLib by Boris Erdmann, boris@erdmann.com, Kristian Köhntopp, kk@netuse.de and Sascha Schumann, sascha@schumann.cx
PHP_Thumbnail by Ryan Flynn (ryan@ryanflynn)
Form class (forms.php) by Manuel Lemos (mlemos@acm.org)
Download:
You can get the latest version from
http://www.uttenthaler.at
http://phpclasses.upperdesign.com
ChangeLog:
Version 0.1 - 14/07/2001 + Initial release
License:
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 2 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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Installation:
1) Unpack the package and create a database
2) Create a Database-User (e.g. phpRealGallery)
3) Create the tables "galleries" and "images". I have included a dump-file for Postgre (pg.sql).
galleries(gid(pkey), title, text)
images(iid(pkey), gid, file, title, text, tech, size, date, price)
4) Grant the select-right for these tables to the DB-User (the pg-dump-file does it for phpRealGallery)
5) Put data into the tables and upload the images
6) Set the appropriate values for the DB-Connection in prepend.php3 (I have included db_pgsql.inc, db_mysql.inc and db_odbc.inc,
if you have nstallled the PHP Base Library on your Server, you also can use this one. Therefore copy the prepend.php3 and
local inc into your directory, set the right include-path and db_* file in prepend.php3 and configure your database-connection
in local.inc.
6) Read the Documentation
Documentation:
Description:
phpRealGallery is a gallery-tool with a Database-Backend wich can display several galleries,
thumbnails of each gallery and the images in real-size with several information-fields (title, text, size, tech, date, price).
The class should be embedded in the body-tag of an HTML-File. It produces valid XHTML 1.0 code.
Methods:
main
Synopsis
$error=$gallery-object->main()
Purpose
Show overview of galleries
show_gallery
Synopsis
$error=$gallery-object->show_gallery($gid)
Purpose
Show thumbnails of specified gallery
Arguments
$gid
The ID of the selected gallery
show_image
Synopsis
$error=$gallery-object->show_image($iid)
Purpose
Show specified image in real-size with additional information
Arguments
$iid
The ID of the selected image
Properties:
img_path
Synopsis
$gallery_object->img_path=string
Purpose
Specifies the directory where the images are stored
thumbnails_per_row
Synopsis
$gallery_object->thumbnails_per_row=int
Purpose
Specifies the number of thumbnails per row
file_name
Synopsis
$gallery_object->file_name=basename($PHP_SELF);
Purpose
Specifies the Name of the gallery file
thumbnail_size
Synopsis
$gallery_object->thumbnail_size=int
Purpose
Specifies the Thumbnail-Size in percent of the original size
Example Usage:
require("./class.gallery.php");
$g=new Gallery;
$g->img_path="./img/gallery/"; (can also be an absolute path, or a ftp- or http-server)
$g->thumbnails_per_row=3;
$g->file_name=basename($PHP_SELF);
$g->thumbnail_size=25;
IF($show_gallery) $g->show_gallery($show_gallery);
ELSEIF($show_image) $g->show_image($show_image);
ELSE $g->main();
The Design can be changed by CSS with the following classes:
a.thumbnail
a.nav_button
table.thumbnail
tr.thumbnail
td.thumbnail
img.nav_button
img.thumbnail
img.gallery
Graphic-Navigation-Buttons:
Put the following files in the image-directory:
left.gif // for link-arrows
left2.gif // for non-link-arrows
right.gif
right2.gif
up.gif
Todo:
+ Storage of Images in Database ?
+ Admin-Interface with File-Upload
+ Real Thumbnail-Generation for jpg, gif and png (Either gif or png, depends on GD-Version)
+ Multi-Language Support
*/
require('./include/prepend.php3');
require("./include/class.thumbnail.php");
class Gallery extends DB_gallery{
var $img_path;
var $thumbnails_per_row;
var $thumbnail_size; //in percent of the original size
var $file_name;
function gallery() { //Konstruktor
$db=new DB_Gallery;
if($db->Error!="") {
echo "<p style='color:red;'>Keine Verbindung zur Datenbank!<br />
FEHLER!<br />".$error."</p>";
exit;
}
}
function show_gallery($show_gallery){ //Shows thumbnails of a gallery
$db=new DB_Gallery;
$db2=new DB_Gallery;
$t=new PHP_Thumbnail($this->thumbnail_size, $this->thumbnail_size, '%'); //set to 25% of default size
$query="SELECT * from galleries WHERE gid='".$show_gallery."'";
$result=$db->query($query);
$db->next_record();
$title=$db->f("title");
$text=$db->f("text");
if(file_exists($this->img_path."up.gif")):
$size_up=GetImageSize($this->img_path."up.gif");
$up="<img class='nav_button' src='".$this->img_path."up.gif' ".$size_up[3]." alt='Up' border='0' />";
else:
$up="Up";
endif;
echo "<a class='nav_button' href='./".$this->file_name."'>".$up."</a><br /><br />\n";
echo "<h2>".$title."</h2>\n";
IF($text) echo $text."<br />\n";
echo "<table class='thumbnail'><tr class='thumbnail'>\n";
$query="SELECT * FROM images WHERE gid='".$show_gallery."' ORDER BY iid";
$result=$db->query($query);
$i=0;
WHILE($db->next_record()):
#$dir=opendir($img_path);
$iid=$db->f("iid");
$file=$db->f("file");
$img=$this->img_path.$file;
$title=$db->f("title");
if(file_exists($this->img_path.$file)):
$size=GetImageSize($this->img_path.$file);
$file_size=filesize($this->img_path.$file);
$file_size=round($file_size/1024);
endif;
if($title) $alt_string=$title;
$alt_string=$alt_sting.$title.", ".$size[0]." x ".$size[1].", ".$file_size." kb";
echo "<td class='thumbnail'><a class='thumbnail' href='./".$this->file_name."?show_image=".$iid."' title='".$alt_string."'>";
$t->show($img, "class='thumbnail' alt='".$alt_string."'");
echo "</a></td>\n";
$i++;
if($i==$this->thumbnails_per_row):
echo "</tr>\n<tr>\n";
$i=0;
endif;
ENDWHILE;
echo "</tr></table>\n";
} //end of function show_gallery
function show_image($show_image){ //Shows a picture in real-size and data
$db=new DB_Gallery;
$db2=new DB_Gallery;
$query="SELECT * FROM images WHERE iid='".$show_image."'";
$result=$db->query($query);
$db->next_record();
$file=$db->f("file");
$title=$db->f("title");
$text=$db->f("text");
$gid=$db->f("gid");
$tech=$db->f("tech");
$size=$db->f("size");
$price=$db->f("price");
$date=$db->f("date");
$img=$this->img_path.$file;
$query="SELECT iid FROM images WHERE gid='".$gid."' ORDER BY iid";
$result=$db->query($query);
WHILE($db->next_record()):
$prev_iid_tmp=$iid;
$iid=$db->f("iid");
IF($next_id==1) BREAK;
IF($iid==$show_image):
$next_id=1;
$prev_iid=$prev_iid_tmp;
ENDIF;
IF(!$prev_iid AND $iid==$show_image) $first=1;
ENDWHILE;
IF($iid!=$show_image) $next_iid=$iid; //IF $show_image is not the last in the gallery ..
if(file_exists($this->img_path."left.gif")):
$size_left=GetImageSize($this->img_path."left.gif");
$left="<img class='nav_button' src='".$this->img_path."left.gif' ".$size_left[3]." alt='<<' border='0' />";
else:
$left="<<";
endif;
if(file_exists($this->img_path."left2.gif")):
$size_left2=GetImageSize($this->img_path."left2.gif");
$left2="<img class='nav_button' src='".$this->img_path."left2.gif' ".$size_left2[3]." alt='' border='0' />";
else:
$left2=" ";
endif;
if(file_exists($this->img_path."right.gif")):
$size_right=GetImageSize($this->img_path."right.gif");
$right="<img class='nav_button' src='".$this->img_path."right.gif' ".$size_right[3]." alt='>>' border='0' />";
else:
$right=">>";
endif;
if(file_exists($this->img_path."right2.gif")):
$size_right2=GetImageSize($this->img_path."right2.gif");
$right2="<img class='nav_button' src='".$this->img_path."right2.gif' ".$size_right2[3]." alt='' border='0' />";
else:
$right2=" ";
endif;
if(file_exists($this->img_path."up.gif")):
$size_up=GetImageSize($this->img_path."up.gif");
$up="<img src='".$this->img_path."up.gif' ".$size_up[3]." alt='Up' border='0' />";
else:
$up="Up";
endif;
IF(!$first) $nav_code="<a class='nav_button' href='./".$this->file_name."?show_image=".$prev_iid."'>".$left."</a> \n";
ELSE $nav_code=$left2." \n";
IF($next_iid) $nav_code=$nav_code."<a class='nav_button' href='./".$this->file_name."?show_image=".$next_iid."'>".$right."</a> \n";
ELSE $nav_code=$nav_code.$right2." \n";
$nav_code=$nav_code."<a class='nav_button' href='./".$this->file_name."?show_gallery=".$gid."'>".$up."</a>\n";
echo $nav_code;
echo "<br /><br /><h2>".$title."</h2>\n";
echo "<img src='".$img."' class='gallery' alt='".$title."'><br />\n";
if($tech) echo "<p><i>Technik:</i><br />".$tech."</p>\n";
if($size) echo "<p><i>Größe:</i><br />".$size."</p>\n"
;
if($text) echo "<p>".$text."</p>\n";
if($date) echo "<p><i>Datum:</i><br />".$date."</p>\n";
if($price) echo "<p><i>Preis:</i><br />".$price."</p>\n";
echo "<br />";
echo $nav_code;
echo "<br />";
} //end of function show_image
function main() { //shows gallery-overview
$db=new DB_Gallery;
$db2=new DB_Gallery;
echo "<h2>Bildergalerien</h2>";
$query="SELECT * from galleries";
$result=$db->query($query);
WHILE($db->next_record()):
$gid=$db->f("gid");
$title=$db->f("title");
$query="SELECT count(iid) as count FROM images WHERE gid='".$gid."'";
$result=$db2->query($query);
$db2->next_record();
$pcount=$db2->f("count");
echo "<h3><a href='./".$this->file_name."?show_gallery=".$gid."'>".$title."</a></h3>\n
<p>".$pcount." Bilder</p>\n<hr />\n";
ENDWHILE;
} //end of function main
} //end of class gallery
?> |