Gallery — A simple gallery backend
Gallery is part of the Gallery package.
class Gallery implements Iterator (internal interface) { private array $albums private array $album_ids private array $album_slice private int $album_slice_length private int $album_slice_offset public DBAPI $db public string $db_albums public string $db_photos public string $gallery_path public array $output_func private array $photo_transforms private array $thumb_transforms public Gallery __construct ( DBAPI &$db, string $gallery_path, string $db_albums, string $db_photos ); public Album add_album ( title $title ); public bool add_transform ( mixed $type, mixed $transform, &$transform ); public mixed album ( int $album_id ); public mixed album_by_title ( string $album_title ); public mixed current ( void ); public void delete_album ( int $album_id ); public array get_transforms ( int $type ); public mixed key ( void ); public int length ( void ); public mixed next ( void ); public void rewind ( void ); public void save ( void ); public void slice ( int $offset, int $length ); private void slice_update ( void ); public bool valid ( void ); }
Gallery
A simple gallery backend
This is the base class for a simple gallery system. The metadata for albums and photos are stored in a database while the photos and thumbnails themselves are stored on disk. This gallery needs a DBAPI-compatible databse connection. See the documentation for Album and Photo for the exact definition of the database tables.The Gallery (and the Album object) implements the Iterable interface, so you can loop over it using foreach and other PHP methods. For example:
$gallery = new Gallery(...); foreach ($gallery as &$album) { foreach ($album as &$photo) echo $photo->title }
private array $albums
An array containing all loaded album objects
Default value: empty string
private array $album_ids
An array containing all the album IDs
Default value: empty string
private array $album_slice
An array containing all album IDs in the current slice
Default value: empty string
private int $album_slice_length
Length of the album slice. Zero means to the end of the array
Default value: empty string
private int $album_slice_offset
Offset of the album slice
Default value: empty string
public DBAPI $db
A DBAPI object for the database to store sessions in
public string $db_albums
The name of the album metadata table in the database
Default value: empty string
public string $db_photos
The name of the photo metadata table in the database
Default value: empty string
public string $gallery_path
The path to the root of the gallery. It should end in a slash (/)
Default value: empty string
public array $output_func
Map file extensions to GD output functions. This will be dynamically filled when creating a new Gallery object
Default value: empty string
private array $photo_transforms
The stack of Transforms to apply to photos
Default value: empty string
private array $thumb_transforms
The stack of Transforms to apply to thumbnails
Default value: empty string
public Gallery __construct ( DBAPI &$db, string $gallery_path, string $db_albums, string $db_photos );
Create a new Gallery object
public Album add_album ( title $title );
Add a new Ablum to the gallery
public bool add_transform ( mixed $type, mixed $transform, &$transform );
Add an image transformation to the transformation stack
public mixed album ( int $album_id );
Get the Album identified by the album ID.
public mixed album_by_title ( string $album_title );
Get the Album identified by the album title.
public mixed current ( void );
Part of the Iterator interfaceSee the PHP manual on object iteration: http://www.php.net/manual/en/language.oop5.iterations.php
public void delete_album ( int $album_id );
Delete an album
public array get_transforms ( int $type );
Return the transform stack for WG_FULL or WG_THUMB
public mixed key ( void );
Part of the Iterator interfaceSee the PHP manual on object iteration: http://www.php.net/manual/en/language.oop5.iterations.php
public int length ( void );
Return the number of albums
public mixed next ( void );
Part of the Iterator interfaceSee the PHP manual on object iteration: http://www.php.net/manual/en/language.oop5.iterations.php
public void rewind ( void );
Part of the Iterator interface
See the PHP manual on object iteration: http://www.php.net/manual/en/language.oop5.iterations.php
public void save ( void );
Recursively save all Albums in the Gallery and all Photos in those galleries
public void slice ( int $offset, int $length );
Set the slice of albums that the Iterator interface will iterate over.
private void slice_update ( void );
Update the slice of albums that the interface will iterate over, based on $album_slice_offset and $album_slice_length.
public bool valid ( void );
Part of the Iterator interfaceSee the PHP manual on object iteration: http://www.php.net/manual/en/language.oop5.iterations.php