Album — An album object that can contain one or more Photo objects.
Album is part of the Gallery package.
class Album implements Iterator (internal interface) { private array $attrs private bool $attrs_dirty public Gallery $gallery private array $photos private array $photo_ids private array $photo_slice private int $photo_slice_length private int $photo_slice_offset private Album __construct ( Gallery &$gallery, array $album ); public mixed add_photo ( string $file ); public mixed current ( void ); public void delete_all_photos ( void ); public void delete_photo ( int $photo_id ); public mixed from_id ( Gallery &$gallery, int $album_id ); public mixed from_title ( Gallery &$gallery, string $album_title ); private mixed get_attr_name ( string $attr_name ); public mixed key ( void ); public int length ( void ); private void move ( int $offset ); public void move_down ( void ); public void move_up ( void ); public mixed next ( void ); public mixed photo ( int $photo_id ); public void rewind ( void ); public void save ( mixed $recursive ); public void slice ( int $offset, int $length ); private void slice_update ( void ); public bool valid ( void ); public mixed __get ( $attr_name ); public bool __isset ( $attr_name ); public void __set ( $attr_name, $attr_value ); public void __unset ( $attr_name ); }
Album
An album object that can contain one or more Photo objects.
The album metadata is stored in an SQL database. The minimal definition for the albums table is:
CREATE TABLE albums ( album_id INTEGER PRIMARY KEY AUTOINCREMENT, album_title VARCHAR(256), album_rank INTEGER, album_created INTEGER, album_updated INTEGER )These columns are available as attributes of the Album object, without the album_ prefix. Any extra columns in the database table are also exposed as attributes of the Album object through their column names. If the column names start with the album_ prefix then they will have this prefix stripped.Like the Gallery base object, the Album object is iterable. For example, when you have an albums table with album_description as an extra column, you can do this:
$gallery = new Gallery(...); foreach ($gallery as &$album) { printf('%s - %s', $album->title, $album->description); foreach ($album as &$photo) echo $photo->title; }
private array $attrs
This holds the album's metadata attributes
Default value: empty string
private bool $attrs_dirty
TRUE if the attributes have been changed
Default value: empty string
public Gallery $gallery
A reference to the parent Gallery object
Default value: empty string
private array $photos
An array containing all loaded Photo objects
Default value: empty string
private array $photo_ids
An array containing all the IDs for the album's photos
Default value: empty string
private array $photo_slice
An array containing all photo IDs in the current slice
Default value: empty string
private int $photo_slice_length
Length of the photo slice. Zero means to the end of the array
Default value: empty string
private int $photo_slice_offset
Offset of the photo slice
Default value: empty string
private Album __construct ( Gallery &$gallery, array $album );
Create a new Album object.
The constructor is private since you should use the from_id() or from_title factory methods.
public mixed add_photo ( string $file );
Add the image $file as a new photo to this album.
The image file is compied to the gallery and the full size and thumbnail images will be generated by applying the transformation stacks. If everything was succesfull it will return the Photo object for the new photo, otherwise it returns NULL.
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_all_photos ( void );
Delete all photos in the album
public void delete_photo ( int $photo_id );
Delete a photo from the album
This also removes the actual image files.
public mixed from_id ( Gallery &$gallery, int $album_id );
Static factory method to create an Album object for the album with the given ID
The result should be assigned by reference. Example:
$album =& Album::from_id($gallery, $album_id);
public mixed from_title ( Gallery &$gallery, string $album_title );
Static factory method to create an Album object for the album with the given title
The result should be assigned by reference. Example:
$album =& Album::from_title($gallery, $album_title);
private mixed get_attr_name ( string $attr_name );
Check the attribute name and prefix it with "album_" if need be.
Returns FALSE if the attribute does not exist.
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 photos in the album
private void move ( int $offset );
Switch the Album's rank with the Album on $offset positions away
public void move_down ( void );
Move this Album down in the rank order.
public void move_up ( void );
Move this Album up in the rank order.
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 mixed photo ( int $photo_id );
Get the Photo object for the given photo ID
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 ( mixed $recursive );
Save the Album and all photos to the database
Set $recursive to FALSE if you only want to save the Album metadata and not the photos it contains
public void slice ( int $offset, int $length );
Set the slice of photos that the Iterator interface will iterate over.
private void slice_update ( void );
Update the slice of photos that the interface will iterate over, based on $photo_slice_offset and $photo_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
public mixed __get ( $attr_name );
Magic method for using the Album's metadata attributes.Because Albums are stored in the database, you cannot add or remove attributes.See the PHP manual on overloading: http://nl.php.net/manual/en/language.oop5.overloading.php
public bool __isset ( $attr_name );
Magic method for using the Album's metadata attributes.Because Albums are stored in the database, you cannot add or remove attributes.See the PHP manual on overloading: http://nl.php.net/manual/en/language.oop5.overloading.php
public void __set ( $attr_name, $attr_value );
Magic method for using the Album's metadata attributes.Because Albums are stored in the database, you cannot add or remove attributes.See the PHP manual on overloading: http://nl.php.net/manual/en/language.oop5.overloading.php
public void __unset ( $attr_name );
Magic method for using the Album's metadata attributes.Because Albums are stored in the database, you cannot add or remove attributes.See the PHP manual on overloading: http://nl.php.net/manual/en/language.oop5.overloading.php