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

Class: GALBlob

Source Location: /libgallue/blobs.inc.php

Class Overview


Representation of data inside the image database.


Constants

Methods



Class Details

[line 49]
Representation of data inside the image database.

This class tries to hide the fact that image data stored inside the database are fragmented into pieces of (default) 512 kB. It handles inserting, fetching, caching and deleting of the data. This class doesn't handle information specific to images, like resolution. It is therefor suitable for other data like audio or video. A note to referenceCount: It is introduced to delete blobs which aren't referenced anymore. Maybe this should be resolved somehow with foreign keys - can anyone tell me how? A safe solution would be to count the referencing items every time the blob might become orphaned by deleting a referencing item, but this is an impact on performance. In this solution, you can use reference() and dereference() to automatically delete a blob that isn't referenced anymore.




[ Top ]


Class Methods


static method cleanExtension [line 171]

static string cleanExtension( string $extension)

Remove unwanted characters and convert to lowercase.

This method removes all characters which aren't alphanumeric, '-' or '_' from the given string. Then it's made lowercase. It is used in GALBlob::createFromFile().




Parameters:

string   $extension  

[ Top ]

static method createFromFile [line 114]

static GALBlob createFromFile( string $path, string $mime, string $extension, GALGallery $glb, [int $readmode = 0])

Insert a new blob and read data from the specified file.

To speed up things, this method provides a way to adjust how the data get into the local disk cache to make it possible to move the data within a filesystem to their new location if the source file isn't needed anymore.




Tags:

return:  The newly created blob.


Parameters:

string   $path   Source path of data.
string   $mime   MIME type of the data.
string   $extension   The file extension of the blob. It is not determined from the source file's name.
GALGallery   $glb  
int   $readmode   One of GALBlob::NOCACHE, GALBlob::COPY, GALBlob::RENAME, GALBlob::MOVE_UPLOADED or GALBlob::STREAM.

[ Top ]

constructor __construct [line 255]

GALBlob __construct( GALGallery $glb, int $blobID)



Parameters:

GALGallery   $glb   Global settings
int   $blobID   The numerical ID of this blob.

[ Top ]

method delete [line 362]

void delete( )

Deletes this blob.

This method deletes all data associated with this blob. Note that the cached data are only deleted if they are stored on the cluster node where this function is called, so from time to time one needs to scan the cache on every node for orphan cache entries. No reason to worry - they do nothing harmful except of using disk space. Because blobID is increased strictly monotonally for new blobs, a new blob will never interfere with old data. But take care: After creating (2^32) - 1 blobs, a wrap-around could happen... ;)




[ Top ]

method dereference [line 481]

void dereference( )

Decrease the reference count of this blob and delete it if necessary.

Use this method if you delete a referencing item. If the reference count reaches 0, the blob is deleted. This method is called automatically in GALJob::delete() and GALInstance::delete()

  • no need for you to do this unless you know exactly what you're doing!




[ Top ]

method isLocal [line 302]

bool isLocal( )

Returns TRUE if cached locally.

Returns TRUE if the content of this GALBlob is in the correct place in the disk cache.




Tags:

return:  True if the blob is local.


[ Top ]

method loadNodes [line 278]

GALNodeIterator loadNodes( $expr, [GALOrder $order = ""], [string $limit = ""], [string $additional = ""], [bool $super = false])

Loads nodes which cache this blob.

It adds a specially crafted join, a comparison expression and ordering by RAND() to the arguments and passes them to GALTable::extendedLoad().




Tags:



Parameters:

GALExpression   $expr  
GALOrder   $order   Can also be an empty string or a string containing sth. like "`title` DESC".
string   $limit  
string   $additional  
bool   $super   If set to TRUE, access control is overridden.

[ Top ]

method path [line 323]

string path( )

Path to the data of this blob in the local disk cache.

If this blob isn't cached locally, the data are downloaded from the database to the cache. Note that changing the cached data leads to undefined behavior. If you want to change image data, please create a new blob and change all references so they point to the new blob.




[ Top ]

method reference [line 458]

void reference( )

Increase the reference count of this blob.

Use this method if you insert an item that references this blob. This method is called automatically in GALJobs::add() and GALInstances::add()

  • no need for you to do this!




[ Top ]

method __get [line 311]

mixed __get( string $field)

Magic method to read properties.



Tags:

return:  The propertie's value.


Parameters:

string   $field   The requested propertie's name.

[ Top ]


Class Constants

COPY =  0

[line 77]

Copy source file.

When creating a new GALBlob from a file, the source file is copied to the local disk cache.



[ Top ]

MOVE_UPLOADED =  2

[line 91]

Source file is an uploaded file.

When creating a new GALBlob from an uploaded file, move_uploaded_file() is used to move it to the local disk cache.



[ Top ]

NOCACHE =  -1

[line 70]

Don't put the data into the local disk cache.

When creating a new GALBlob from a file, don't try to copy it to the local disk cache. This might be useful if one tries to insert data from another user account than the disk cache owner.



[ Top ]

RENAME =  1

[line 84]

Rename source file.

When creating a new GALBlob from a file, the source file gets renamed and this way moved to the local disk cache.



[ Top ]

STREAM =  3

[line 100]

Read source file with stream functions.

When creating a new GALBlob from a file, the source file is read with stream functions and copied to the local disk cache. This is useful if the source file is not in the local filesystem, but this isn't supported yet.



[ Top ]



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