Reference Manuals

Photo

Photo — A Photo object that contains a single photo.

Photo is part of the Gallery package.

Synopsis

class Photo {
        public         Album               $album
        private        array               $attrs
        private        bool                $attrs_dirty

        private        Photo               __construct               ( Album &$album,
                                                                       array $photo );
        private        bool                apply_transforms          ( string $file,
                                                                       array $transforms,
                                                                        &$transforms );
        public         mixed               from_id                   ( Gallery &$gallery,
                                                                       int $photo_id );
        private        mixed               get_attr_name             ( string $attr_name );
        public         string              get_path                  ( int $type );
        private        bool                make_writable             ( string $path );
        private        void                move                      ( int $offset );
        public         void                move_down                 ( void );
        public         void                move_up                   ( void );
        public         void                save                      ( void );
        public         bool                update_images             ( string $file );
        public         mixed               __get                     (  $attr_name );
        public         bool                __isset                   (  $attr_name );
        public         void                __set                     (  $attr_name,
                                                                        $attr_value );
        public         void                __unset                   (  $attr_name );
}

Object Hierarchy

Photo

Description

A Photo object that contains a single photo.

The photo metadata is stored in an SQL database. The minimal definition for the photos table is:

 CREATE TABLE photos (
   photo_id INTEGER PRIMARY KEY AUTOINCREMENT,
   album_id INTEGER,
   photo_filename VARCHAR(256),
   photo_rank INTEGER,
   photo_created INTEGER,
   photo_updates INTEGER
 )
These columns are available as attributes of the Photo 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. The album_id is not exposed as an attibute. The Photo object already has a reference to the Album object.

Attribute Details

$album

public         Album          $album

A reference to the Album object that contains this Photo

Default value: empty string


$attrs

private        array          $attrs

This holds the photo's metadata attributes

Default value: empty string


$attrs_dirty

private        bool           $attrs_dirty

TRUE if the attributes have been changed

Default value: empty string

Method Details

__construct()

private        Photo          __construct               ( Album &$album,
                                                          array $photo );

Create a new Photo object.

The constructor is private since you should use the from_id() factory method.

&$album
A reference to the parent Album object
$photo
An array containing the photo's metadata attributes

apply_transforms()

private        bool           apply_transforms          ( string $file,
                                                          array $transforms,
                                                           &$transforms );

Apply the stack of transforms to the image.

$file
Path to the image
$transforms
A stack of Transform objects
&$transforms

from_id()

public         mixed          from_id                   ( Gallery &$gallery,
                                                          int $photo_id );

Static factory method to create a Photo object for the photo with the given ID

&$gallery
A reference to the Gallery object
$photo_id
The ID of the photo

get_attr_name()

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.

$attr_name
The attribute name

get_path()

public         string         get_path                  ( int $type );

Get the path of the photo relative to the gallery root

$type
The type of path. Can be one of WG_ORIGINAL, WG_THUMBNAIL or WG_FULL

make_writable()

private        bool           make_writable             ( string $path );

Ensure that $path can be written to.

Any missing directories will be created.

$path

move()

private        void           move                      ( int $offset );

Switch the Photo's rank with the Photo on $offset positions away in the same album

$offset
The offset of the Photo to swap rank with

move_down()

public         void           move_down                 ( void );

Move this Photo down in the rank order.


move_up()

public         void           move_up                   ( void );

Move this Photo up in the rank order.


save()

public         void           save                      ( void );

Save the Photo


update_images()

public         bool           update_images             ( string $file );

Regenerate the full size and thumbnail images.

If $file is set then this image will be used as a new original image. If $file is not set then the images will be regenerated from the existing original image in the gallery.

$file
A new original image to use

__get()

public         mixed          __get                     (  $attr_name );

Magic method for using the Photo's metadata attributes.Because Photos 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

$attr_name

__isset()

public         bool           __isset                   (  $attr_name );

Magic method for using the Photo's metadata attributes.Because Photos 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

$attr_name

__set()

public         void           __set                     (  $attr_name,
                                                           $attr_value );

Magic method for using the Photo's metadata attributes.Because Photos 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

$attr_name
$attr_value

__unset()

public         void           __unset                   (  $attr_name );

Magic method for using the Photo's metadata attributes.Because Photos 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

$attr_name