Klutz Driver implementation for comics as files with SUM info stored
in SQL database.
Required parameters:
'directory' The main directory the comics are stored in
Methods summary
public
|
#
Klutz_Driver_sql( array $params = array() )
Constructs a new SQL storage object.
Constructs a new SQL storage object.
Parameters
- $params
- A hash containing connection parameters.
|
public
|
#
loadSums( )
We do nothing in this function for the SQL driver since we grab
the info on demand from the database. We keep the function here,
however to honor our 'interface' since we call this function from
various places in the client code.
We do nothing in this function for the SQL driver since we grab
the info on demand from the database. We keep the function here,
however to honor our 'interface' since we call this function from
various places in the client code.
|
public
|
#
rebuildSums( )
Rebuild the table of unique identifiers.
Rebuild the table of unique identifiers.
|
public
boolean|PEAR_Error
|
#
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
Returns
boolean|PEAR_Error True on success, PEAR_Error on failure.
|
public
integer|PEAR_Error
|
#
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.
Returns
integer|PEAR_Error number of affected Comics on success, PEAR_Error on failure.
|
public
boolean
|
#
isUnique( Klutz_Image $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
- Raw (binary) image data.
Returns
boolean True if unique, false otherwise.
|
public
mixed
|
#
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
mixed An array of dates in $subdir format between $oldest and
$newest that we have comics for | PEAR_Error
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
|