Klutz Driver implementation for comics as files.
Required parameters:
'directory' The main directory the comics are stored in
'sumsfile' The filename to hold md5sums for images
Methods summary
public
|
#
Klutz_Driver_file( array $params = array() )
Constructs a new file storage object.
Constructs a new file storage object.
Parameters
- $params
- A hash containing connection parameters.
|
public
|
#
loadSums( )
Load a list of unique identifiers for comics from the sumsfile.
Load a list of unique identifiers for comics from the sumsfile.
|
public
|
#
saveSums( )
Save the list of unique identifiers for comics to the sumsfile.
Save the list of unique identifiers for comics to the sumsfile.
|
public
|
#
rebuildSums( )
Rebuild the table of unique identifiers.
Rebuild the table of unique identifiers.
|
public
|
#
addSum( string $index, timestamp $date, string $data )
Add a unique identifier for a given image.
Add a unique identifier for a given image.
Parameters
- $index
- The index for the comic
- $date
- The date of the comic
- $data
- The md5 of the raw (binary) image data
|
public
|
#
removeSum( string $index = null, timestamp $date = null )
Remove the unique identifier for the given comic and/or
date. If both are passed, removes the uid for that comic and
date. If only a comic is passed, removes all uids for that
comic. If only a date is passed removes uids for all comics on
that date. If neither is passed, all uids are wiped out.
Remove the unique identifier for the given comic and/or
date. If both are passed, removes the uid for that comic and
date. If only a comic is passed, removes all uids for that
comic. If only a date is passed removes uids for all comics on
that date. If neither is passed, all uids are wiped out.
Parameters
- $index
- <p>Index for the comic to delete. If left out all
comics will be assumed.</p>
- $date
- Date to remove. If left out, assumes all dates.
|
public
boolean
|
#
isUnique( object $image )
Determine if the image passed is a unique image (one we don't already
have).
Determine if the image passed is a unique image (one we don't already
have).
This allows for $days = random, etc., but keeps us from getting the same
comic day after day.
Parameters
- $image
- $image Raw (binary) image data
Returns
boolean True if unique, false otherwise.
|
public
array
|
#
listDates( timestamp $date = null, timestamp $oldest = null, timestamp $newest = null )
Get a list of the dates for which we have comics between
$oldest and $newest. Only returns dates we have at least one
comic for.
Get a list of the dates for which we have comics between
$oldest and $newest. Only returns dates we have at least one
comic for.
Parameters
- $date
- The reference date (default today)
- $oldest
- <p>The earliest possible date to return (default
first of the month)</p>
- $newest
- <p>The latest possible date to return (default
last date of the month)</p>
Returns
array timestamps Any dates between $oldest and $newest that we
have comics for.
Overrides
|
public
string
|
#
imageSize( string $index, timestamp $date = null )
Get the image dimensions for the requested image.
Get the image dimensions for the requested image.
Parameters
- $index
- The index of the comic to check
- $date
- The date of the comic to check (default today)
Returns
string Attributes for an tag giving height and width
Overrides
|
public
boolean
|
#
imageExists( string $index, timestamp $date = null )
Find out if we already have a local copy of this image.
Find out if we already have a local copy of this image.
Parameters
- $index
- The index of the comic to check
- $date
- The date of the comic to check (default today)
Returns
boolean False in this driver
Overrides
|
public
mixed
|
#
retrieveImage( string $index, timestamp $date = null )
Retrieve an image from storage. Make sure the image exists
first with imageExists().
Retrieve an image from storage. Make sure the image exists
first with imageExists().
Parameters
- $index
- The index of the comic to retrieve
- $date
- The date for which we want $comic
Returns
mixed If the image exists locally, return a Klutz_Image object.
If it doesn't, return a string with the URL pointing to
the comic.
Overrides
|
public
boolean
|
#
storeImage( string $index, string $image, timestamp $date = null )
Store an image for later retrieval.
Store an image for later retrieval.
Parameters
- $index
- The index of the comic to retrieve
- $image
- Raw (binary) image data to store
- $date
- $data Date to store it under (default today)
Returns
boolean True on success, false otherwise
Overrides
|
public
boolean
|
#
removeImage( string $index, timestamp $date = null )
Remove an image from the storage system (including its unique
ID).
Remove an image from the storage system (including its unique
ID).
Parameters
- $index
- The index of the comic to remove
- $date
- The date of the comic to remove (default today)
Returns
boolean True on success, else false
|
public
boolean
|
#
removeDate( timestamp $date = null )
Remove all images from the storage system (including unique
IDs) for a given date.
Remove all images from the storage system (including unique
IDs) for a given date.
Parameters
- $date
- The date to remove comics for (default today)
Returns
boolean True on success, else false
|