Reference Manuals

Gallery

Gallery — A simple gallery backend

Gallery is part of the Gallery package.

Synopsis

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 );
}

Object Hierarchy

Gallery

Implemented Interfaces

Gallery implements Iterator (internal interface)

Description

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
 }

Attribute Details

$albums

private        array          $albums

An array containing all loaded album objects

Default value: empty string


$album_ids

private        array          $album_ids

An array containing all the album IDs

Default value: empty string


$album_slice

private        array          $album_slice

An array containing all album IDs in the current slice

Default value: empty string


$album_slice_length

private        int            $album_slice_length

Length of the album slice. Zero means to the end of the array

Default value: empty string


$album_slice_offset

private        int            $album_slice_offset

Offset of the album slice

Default value: empty string


$db

public         DBAPI          $db

A DBAPI object for the database to store sessions in


$db_albums

public         string         $db_albums

The name of the album metadata table in the database

Default value: empty string


$db_photos

public         string         $db_photos

The name of the photo metadata table in the database

Default value: empty string


$gallery_path

public         string         $gallery_path

The path to the root of the gallery. It should end in a slash (/)

Default value: empty string


$output_func

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


$photo_transforms

private        array          $photo_transforms

The stack of Transforms to apply to photos

Default value: empty string


$thumb_transforms

private        array          $thumb_transforms

The stack of Transforms to apply to thumbnails

Default value: empty string

Method Details

__construct()

public         Gallery        __construct               ( DBAPI &$db,
                                                          string $gallery_path,
                                                          string $db_albums,
                                                          string $db_photos );

Create a new Gallery object

&$db
A reference to a DBAPI object connected to the database storing the metadata
$gallery_path
The path to the root directory of the gallery
$db_albums
The name of the album metadata table in the database
$db_photos
The name of the photo metadata table in the database

add_album()

public         Album          add_album                 ( title $title );

Add a new Ablum to the gallery

$title
The title of the new album

add_transform()

public         bool           add_transform             ( mixed $type,
                                                          mixed $transform,
                                                           &$transform );

Add an image transformation to the transformation stack

$type
The image type to apply the transform to. Should be WG_FULL or WG_THUMB
$transform
The Transform object
&$transform

album()

public         mixed          album                     ( int $album_id );

Get the Album identified by the album ID.

$album_id
The ID of the album

album_by_title()

public         mixed          album_by_title            ( string $album_title );

Get the Album identified by the album title.

$album_title
The title of the album

current()

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


delete_album()

public         void           delete_album              ( int $album_id );

Delete an album

$album_id
The ID of the album to delete

get_transforms()

public         array          get_transforms            ( int $type );

Return the transform stack for WG_FULL or WG_THUMB

$type
WG_FULL or WG_THUMB

key()

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


length()

public         int            length                    ( void );

Return the number of albums


next()

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


rewind()

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


save()

public         void           save                      ( void );

Recursively save all Albums in the Gallery and all Photos in those galleries


slice()

public         void           slice                     ( int $offset,
                                                          int $length );

Set the slice of albums that the Iterator interface will iterate over.

$offset
If offset is non-negative, the slice will start at that offset in the album list. If offset is negative, the slice will start that far from the end of the album list.
$length
length If length is given and is positive, then the slice will have that many elements in it. If length is given and is negative then the slice will stop that many elements from the end of the array. If it is omitted, then the slice will have everything from offset up until the end of the album list.

slice_update()

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.


valid()

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