SourceForge.net LogoPHPGallue
[ class tree: libgallue ] [ index: libgallue ] [ all elements ]

Class: GALInstance

Source Location: /libgallue/instance.inc.php

Class Overview

GALRow
   |
   --GALTableRow
      |
      --GALInstance

Provide information specific to an image's instance.


Variables

Methods


Inherited Variables

Inherited Methods

Class: GALTableRow

GALTableRow::__construct()
Initializes this object.
GALTableRow::delete()
Deletes this row from the database.
GALTableRow::getParent()
Returns the top level parent of this row.
GALTableRow::set()
Sets the specified field of this row to the specified value.
GALTableRow::__set()
Magic method to set a field of this row almost like a native PHP property.

Class: GALRow

GALRow::__construct()
Initializes a row.
GALRow::countFields()
Returns the number of fields contained in a result.
GALRow::get()
Returns the value of a field.
GALRow::getData()
Provides access to the stored data.
GALRow::getFields()
Returns all fields contained in this result.
GALRow::getFlags()
Gets the flags of the given field.
GALRow::getLength()
Gets the length of the given field.
GALRow::getParent()
Returns the top level parent of an entity.
GALRow::getTable()
Gets the name of the table the given field is contained in.
GALRow::getType()
Gets the type of the given field.
GALRow::isField()
Checks if the given field is contained in a result.
GALRow::__destruct()
Deletes the stored data and sets $_dead to TRUE.
GALRow::__get()
Magic method to access this row's fields like native PHP properties.

Class Details

[line 240]
Provide information specific to an image's instance.

An instance corresponds to a @link GALBlob} containing the image data. Information like MIME-type, file extension and file size is kept inside the "blob" property, while width and height can be accessed through the "x" and "y" properties. A GALInstance always belongs to a certain GALImage. One can only change the "blob" and "permission properties. When changing the "blob" property, the image dimensions are adjusted automatically. Instances are created by GALImages::add() and (indirectly) by GALImage::addInstance(). If you want to mess up your image database (for example: thumbnail and full res image show sth. different), you can of course use GALInstances::add() instead ;).

This class provides various properties accessed via the magic methods GALInstance::__get() and GALInstance::__set(). Some of these properties correspond to database fields, some do not. The __get() and __set() methods internally use the GALInstance::get() and GALInstance::set() methods which provide access control - in contrast to the parent class's GALRow::get() and GALTableRow::set() methods. After performing the access control, these are used to read and write the properties corresponding to database fields. All properties corresponding to database fields are of type string, but instead database types are given here. (r indicates readable, w writable)

  1. Properties corresponding to database fields:
2. Properties generated using database fields
  • GALImage image (from imageID) r The image this instance belongs to.
  • GALUser owner (from image->ownerID) r The user of the image this instance belongs to.
  • GALBlob blob (from blobID) rw The GALBlob that keeps the image data.
  • string url An URL that points to the image data, at the moment it points to the img.php script passing imageID and instanceID as GET parameters.




[ Top ]


Class Variables

$_blob =  false

[line 245]



Tags:

access:  protected

Type:   mixed


[ Top ]

$_glb =  false

[line 244]

Link to GALGallery object



Tags:

access:  protected

Type:   mixed


[ Top ]



Class Methods


constructor __construct [line 256]

GALInstance __construct( GALGallery $glb, $result, &$data, $table, array $data)

Initialize

This constructor is not intended to be called by library users, it is called inside GALInstanceIterator::fetch().




Overrides GALTableRow::__construct() (Initializes this object.)

Parameters:

GALGallery   $glb   Used to initialize the GALInstance::$_glb object variable.
GALResult   $result   Used in parent constructor GALTableRow::__construct().
array   $data   Used in parent constructor GALTableRow::__construct().
GALTable   $table   Used in parent constructor GALTableRow::__construct().
   &$data  

[ Top ]

method canEdit [line 378]

bool canEdit( GALUser $user)

Check if the specified user has got the privilege to change the instance's properties.



Tags:

return:  True if the user can change the instance, false otherwise.


Parameters:

GALUser   $user   The user whose privileges are checked.

[ Top ]

method canView [line 363]

bool canView( GALUser $user)

Check if the specified user has got the privilege to read the instance's properties.



Tags:

return:  True if the user can see the instance, false otherwise.


Parameters:

GALUser   $user   The user whose privileges are checked.

[ Top ]

method delete [line 410]

void delete( [bool $super = false])

Delete this instance.

This method deletes the instance's GALBlob unless it is referenced by other instances or jobs, deletes the database row and then calls the refresh() method of the instance's image. If deleting fails, an GAL_EInstance is thrown.




Overrides GALTableRow::delete() (Deletes this row from the database.)

Parameters:

bool   $super   If set to TRUE, access control is overridden.

[ Top ]

method get [line 292]

void get( string $field, [bool $super = true])

Read a property via method call.

First of all access control is performed. If successful, properties not corresponding to database fields are handled by this method itself. Properties corresponding to database fields are delegated to the inherited GALRow::get() method. It might seem strange that overriding access control is the default. It is like it is because GALRow::__construct() called by GALInstance::__construct reads the row's primary key using the get() method. In our case the original get() method is overridden by the current one, so it has to work in this case without second parameter.




Overrides GALRow::get() (Returns the value of a field.)

Parameters:

string   $field   The propertie's name
bool   $super   TRUE indicates privileged access overriding access control.

[ Top ]

method set [line 329]

void set( string $field, mixed $value, [bool $super = false])

Set a property via method call.

One can only change the "blob" or the "permission" property.




Overrides GALTableRow::set() (Sets the specified field of this row to the specified value.)

Parameters:

string   $field   The propertie's name.
mixed   $value   The propertie's new value.
bool   $super   If set to TRUE, access control is overridden.

[ Top ]

method url [line 394]

string url( [bool $super = false])

Get URL pointing to the image data.

The base url is read from configuration, then imageID and instanceID of the current instance are added as GET parameters.




Tags:

return:  URL pointing to image data.


Parameters:

bool   $super   If set to TRUE, access control is overridden.

[ Top ]

method __get [line 273]

mixed __get( string $field)

Magic method to read properties.

It internally uses the GALInstance::get() method with enforced access control. Library users should not explicitly call the __get() method - it is good for nothing. If you want to read a property with a method call, use get() instead. This method also provides overriding access control if required.




Tags:

return:  The propertie's value.


Overrides GALRow::__get() (Magic method to access this row's fields like native PHP properties.)

Parameters:

string   $field   The requested propertie's name.

[ Top ]

method __set [line 319]

void __set( string $field, mixed $value)

Magic method to set properties It internally uses GALInstance::set() with enforced access control.



Overrides GALTableRow::__set() (Magic method to set a field of this row almost like a native PHP property.)

Parameters:

string   $field   The name of the property to set.
mixed   $value   The propertie's new value.

[ Top ]


Documentation generated on Wed, 16 Aug 2006 15:36:13 +0200 by phpDocumentor 1.3.0RC6