Class Klutz_Driver_file

Description

Klutz Driver implementation for comics as files.

$Horde: klutz/lib/Driver/file.php,v 1.39 2008/09/08 21:28:18 mrubinsk Exp $

Required parameters:

   'directory'  The main directory the comics are stored in
   'sumsfile'   The filename to hold md5sums for images

Located in /lib/Driver/file.php (line 15)

Klutz_Driver
   |
   --Klutz_Driver_file
Variable Summary
 string $basedir
 array $diffs
 string $subdir
 string $sumsfile
Method Summary
 Klutz_Driver_file Klutz_Driver_file ([array $params = array()])
 void addSum (string $index, timestamp $date, string $data)
 boolean imageExists (string $index, [timestamp $date = null])
 string imageSize (string $index, [timestamp $date = null])
 boolean isUnique (object Klutz_Image $image)
 array listDates ([timestamp $date = null], [timestamp $oldest = null], [timestamp $newest = null])
 void loadSums ()
 void rebuildSums ()
 boolean removeDate ([timestamp $date = null])
 boolean removeImage (string $index, [timestamp $date = null])
 void removeSum ([string $index = null], [timestamp $date = null])
 mixed retrieveImage (string $index, [timestamp $date = null])
 void saveSums ()
 boolean storeImage (string $index, string $image, [ $date = null], timestamp $data)
Variables
string $basedir = null (line 22)

The base directory we store comics in.

array $diffs = array() (line 46)

The actual array of unique image identifiers (md5 sums right now).

Key is the full path of the comic, value is md5

string $subdir = 'Ymd' (line 30)

The format for the various subdirectories.

WARNING: DO NOT CHANGE THIS!

string $sumsfile = 'sums' (line 37)

The file we store unique image identifiers in.

Methods
Constructor Klutz_Driver_file (line 53)

Constructs a new file storage object.

Klutz_Driver_file Klutz_Driver_file ([array $params = array()])
  • array $params: A hash containing connection parameters.
addSum (line 154)

Add a unique identifier for a given image.

void addSum (string $index, timestamp $date, string $data)
  • string $index: The index for the comic
  • timestamp $date: The date of the comic
  • string $data: The md5 of the raw (binary) image data
imageExists (line 293)

Find out if we already have a local copy of this image.

  • return: False in this driver
boolean imageExists (string $index, [timestamp $date = null])
  • string $index: The index of the comic to check
  • timestamp $date: The date of the comic to check (default today)

Redefinition of:
Klutz_Driver::imageExists()
Find out if we already have a local copy of this image.
imageSize (line 275)

Get the image dimensions for the requested image.

  • return: Attributes for an <img> tag giving height and width
string imageSize (string $index, [timestamp $date = null])
  • string $index: The index of the comic to check
  • timestamp $date: The date of the comic to check (default today)

Redefinition of:
Klutz_Driver::imageSize()
Get the image dimensions for the requested image.
isUnique (line 203)

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.

  • return: True if unique, false otherwise.
boolean isUnique (object Klutz_Image $image)
listDates (line 226)

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.

  • return: timestamps Any dates between $oldest and $newest that we have comics for.
array listDates ([timestamp $date = null], [timestamp $oldest = null], [timestamp $newest = null])
  • timestamp $date: The reference date (default today)
  • timestamp $oldest: The earliest possible date to return (default first of the month)
  • timestamp $newest: The latest possible date to return (default last date of the month)

Redefinition of:
Klutz_Driver::listDates()
Gets a list of the dates for which we have comics between $oldest and $newest. In the default driver (no backend) this is just a list of all dates between $oldest and $newest.
loadSums (line 79)

Load a list of unique identifiers for comics from the sumsfile.

void loadSums ()
rebuildSums (line 120)

Rebuild the table of unique identifiers.

void rebuildSums ()
removeDate (line 404)

Remove all images from the storage system (including unique IDs) for a given date.

  • return: True on success, else false
boolean removeDate ([timestamp $date = null])
  • timestamp $date: The date to remove comics for (default today)
removeImage (line 380)

Remove an image from the storage system (including its unique ID).

  • return: True on success, else false
boolean removeImage (string $index, [timestamp $date = null])
  • string $index: The index of the comic to remove
  • timestamp $date: The date of the comic to remove (default today)
removeSum (line 173)

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.

void removeSum ([string $index = null], [timestamp $date = null])
  • string $index: Index for the comic to delete. If left out all comics will be assumed.
  • timestamp $date: Date to remove. If left out, assumes all dates.
retrieveImage (line 314)

Retrieve an image from storage. Make sure the image exists first with imageExists().

  • return: If the image exists locally, return a Klutz_Image object. If it doesn't, return a string with the URL pointing to the comic.
mixed retrieveImage (string $index, [timestamp $date = null])
  • string $index: The index of the comic to retrieve
  • timestamp $date: The date for which we want $comic

Redefinition of:
Klutz_Driver::retrieveImage()
Retrieve an image from storage. Since there is no local storage this will actually call for the fetching.
saveSums (line 100)

Save the list of unique identifiers for comics to the sumsfile.

void saveSums ()
storeImage (line 333)

Store an image for later retrieval.

  • return: True on success, false otherwise
boolean storeImage (string $index, string $image, [ $date = null], timestamp $data)
  • string $index: The index of the comic to retrieve
  • string $image: Raw (binary) image data to store
  • timestamp $data: Date to store it under (default today)
  • $date

Redefinition of:
Klutz_Driver::storeImage()
Store an image for later retrieval

Inherited Methods

Inherited From Klutz_Driver

 Klutz_Driver::Klutz_Driver()
 Klutz_Driver::factory()
 Klutz_Driver::imageExists()
 Klutz_Driver::imageSize()
 Klutz_Driver::listDates()
 Klutz_Driver::retrieveImage()
 Klutz_Driver::singleton()
 Klutz_Driver::storeImage()

Documentation generated on Sun, 30 Jan 2011 05:30:35 +0000 by phpDocumentor 1.4.3