Location: PHPKode > scripts > Simple Gallery > simple-gallery/readme.txt
   Class written by: Mike Rosas ©2007                                 
   -----------------------------------------------------------------     
   This class can manage a gallery with out using MySQL.               
   It reads the images directly from the directories                     
   All you have to do is to initialize the class and point to         
   the directory containing the images subdirectory and the              
   thumbs subdirectory.                                               
                                                                           
   More info on readme.txt                                            
   -----------------------------------------------------------------     


-------------------------[ R E A D M E ]----------------------------------

1. Introduction
2. Setting it up
3. Functions and parameters
4. Error messages
5. Final notes

-------------------------[ I N T R O D U C T I O N ] ---------------------

This is actually a very simple gallery that does not use mysql, it only requires 
PHP for executing the code.

[*] It includes an index thumb gallery and a image view page. 
[*] It supports multiple paging for the index thumb page and for the image view page.
[*] In the thumb index, you can set the number of images per row and columns.
[*] No previous style is given so your CSS will afect it.
[*] You have a style function to modify some extra stuff.
[*] Error display.
[*] It contains a test function.

Setting it up is really simple, you dont have to modify any actual code, 

-------------------------[ S E T T I N G  I T  U P ] ---------------------

1. Create a directory in your server. (example: gallery01)

2. create two subdirectories in gallery01 (images and thumbs by default)

3. copy your images and thumbs to the right folders 
(images should be already processed)

4. Include require_once("sgallery.class.php"); some where on your PHP document.

5. Initialize a variable with the constructor.

	$gallery = new sGallery();

6. Optinally modify the style with the style function:

	$gallery->style();

7. Where ever you want to print the index gallery or the image page, just call the function:

	$gallery->show();

I recomend you put the code in a table where you can set the width, otherwise it will go 100%

This is pretty much it, but lets review the function to know what are the parameters and
how to use them in the best way.

-------------------------[ F U N C T I N S   A N D ] ---------------------
-------------------------[ P A R A M E T E R S     ] ---------------------

[*] Constructor

$gallery = new sGallery($title, $dir);

The constructor uses two parameters, the first one is the Gallery name and its
displayed in the index page. The second one is the rute to the gallery where ever you have 
your images and thumbs forlder (gallery01 in the setting it up example).

if no values for parameters are indicated, this are the default values:

	$gallery = new sGallery("", ".");

[*] Style

$gallery->style($hcolor, $bcolor, $fcolor, $border, $nav);

The parameter $hcolor sets a color as the background for the TD where the title is displayed
on the index thumb page. The $bcolor is the background color in the TD where the images are 
displayed on the thumb index page. The $fcolor is the background color for the lower TD where
the page anchors are displayed. All collor already includes the # so you dont need to use it
again, just set the number for the RGB. Also the $fcolor is the background color for the 
navigation links on the image view page.

$border is a number representing the px for the border on the thumb index and the image page
view. $nav supports "auto", "up", "down" or "none", it tells where to display the navigational
links on the image view page. Auto displays them in the upper and lower place of the table while
upper only display it in the upper place, same goes for down. its not recomended to use none
becouse no navigational links will apear.

[*] Show

$gallery->show($p, $nc, $nr, $k);

first of all, leave $p and $k just like they are, they are used to build the paging system.
$nc indicates the number of thumbs displayed for all columns, while $nr indicates the number 
of thumbs displayed in all rows, this is handy so that you can display as many images per page
as you want, for example:

	$gallery->show($p, 4, 5, $k);

Displays a gallery showing colums of 4 images and rows of 5 images making a total of 20 images
per page. The default values for $nc and $nr are 5 and 5.

This same function is used to display the image, the $p shows the actual page for the thumb index 
but the $k shows the image to be displayed.

[*] Test Function

If no error ocures in the executing of the constructor, then you can test the script, just run 

$gallery->test();

and some data will be printed:
-> Name: Actual name you have given to the gallery.
-> nimg: Number of Images
-> nthu: Number of Thumbnails
-> dirs: Actual Directory
-> images: List of the images in the images dir
-> thumbs: List of the thumbs in the thumbs dir

-------------------------[ E R R O R   M E S S A G E S ]------------------

When executing the contructor you could recieve some error messages instead of runing succesfully
the class. This are the posible messages and the solution.

[*] ERROR: Can't open image dir
This happends becouse the selected dir does not exist. Maybe you have a typo on the name.

[*] ERROR: No files found in image dir
The dir exists, but there are no images on it.

[*] ERROR: Can't open thumb dir
This happends becouse the selected dir does not exist. Maybe you have a typo on the name.

[*] ERROR: No files found in thumb dir
The dir exists, but there are no images on it.

[*] ERROR: images != thumbs
This is more like a warning, saying that the number of thumbs are not the same as the number of images.

-------------------------[ F I N A L   N O T E S  ]-----------------------

1st. dont be to hard on me, its my first class.
2nd. please give me credit if you ever use this code.
3rd. email me for anything regarding my code mikzael AT hotmail.com
4th. excuse my broken english.
Return current item: Simple Gallery