\Klutz_Comic_Bysize

Klutz_Comic_Bysize Class.

This class uses follows the search methodology until it hits the final page in the list. On this page it gets a list of all images and tries to figure out which image is most likely to be the comic based on image sizes. This is the LEAST efficient driver and you're discouraged from using it when not absolutely necessary.

Summary

Methods
Properties
Constants
Klutz_Comic()
_initHTTP()
_prepareSearch()
getOverride()
substitute()
getInstance()
getInstance_monthly()
getInstance_weekly()
getInstance_yearly()
getInstance_ref()
Klutz_Comic_bysize()
fetchURL()
fetchImage()
_stripimages()
_expandurls()
_ignore()
_getsizes()
$name
$author
$homepage
$days
$comment
$offset
$nohistory
$http
$url
$referer
$agent
$user
$pass
$cookies
$headers
$subs
$itype
$iformat
$icount
$idate
$isow
$override
$search
$ignore
$minheight
$minwidth
$maxheight
$maxwidth
$choose
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$name

$name : string

The title of the comics (Dilbert, The 5th Wave, etc.)

Type

string

$author

$author : string

The author or authors of the comic (the byline)

Type

string

$homepage

$homepage : string

The URL for the official homepage (not necessarily where we get the comic from.

Type

string

$days

$days : array

Days (lowercase, three-letter english abbreviation) that this comic is is available.

Type

array

$comment

$comment : string

Some comment to display for this comic

Type

string

$offset

$offset : string

Days behind the current date this comic is published

Type

string

$nohistory

$nohistory : boolean

Are past episodes available? Some comics are difficult or impossible to retrieve other than the day it's published.

Type

boolean

$http

$http : \HTTP_Request

Web browser object used to fetch pages

Type

\HTTP_Request

$url

$url : string

The first url we need to hit to get the comic we want.

Type

string

$referer

$referer : string

The referral URL to use when fetching the comic.

Type

string

$agent

$agent : string

The user-agent to use when fetching the comic.

Type

string

$user

$user : string

The username to use when fetching the comic.

Type

string

$pass

$pass : string

The password to use when fetching the comic.

Type

string

$cookies

$cookies : array

Cookies to set when fetching the comic.

Type

array

$headers

$headers : array

Headers to set when fetching the comic.

Type

array

$subs

$subs : array

An array of the fields we need to do substitution on.

Type

array

$itype

$itype : string

Method for counting instances (when using the 'i' construct in substitutions.

Type

string

$iformat

$iformat : string

Format string for the instance construct (printf string)

Type

string

$icount

$icount : integer

The number of the "first" instance of the comic (the reference number) when using the reference-based instance type

Type

integer

$idate

$idate : \date

The date for which the reference is icount.

Type

\date

$isow

$isow : string

The day the "week" starts for instance type weekly.

Abbreviated day name in english, lowercase.

Type

string

$override

$override : array

The array of overrides by weekday. If sun_url exists, then when trying to fetch the sunday edition of this comic, it will fetch it from the specified url instead of $url.

Type

array

$search

$search : array

Once set, an array of preg searches to perform to find the comic image

Type

array

$ignore

$ignore : array

A list of images to ignore (preg matches)

Type

array

$minheight

$minheight : integer

What is the smallest height to consider

Type

integer

$minwidth

$minwidth : integer

What are the smallest width to consider

Type

integer

$maxheight

$maxheight : integer

What is the largest height to consider

Type

integer

$maxwidth

$maxwidth : integer

What is the largest width to consider

Type

integer

$choose

$choose : 

How should we decide which image to take? Options are "first", "biggest", and "smallest".

Type

Methods

Klutz_Comic()

Klutz_Comic(string  $comic) 

Loads the $comics[$comic] array into this object

Parameters

string $comic

The comic to create this object from

_initHTTP()

_initHTTP(\timestamp  $date,   $url) 

Create an HTTP_Request object and set all parameters necessary to perform fetches for this comic.

Parameters

\timestamp $date

Date of the comic to retrieve (default today)

$url

_prepareSearch()

_prepareSearch(  $search) : array

Turn the search strings from the configuration file into preg_match-formatted strings

Parameters

$search

Returns

array —

Search strings properly formatted to be used with preg_match

getOverride()

getOverride(string  $setting, \timestamp  $date = null, string  $array_map = null) : mixed

Check for "override" settings - settings that override other settings depending on the day on which the comic appears

Parameters

string $setting

The name of the setting to override

\timestamp $date

The date to check for overrides

string $array_map

Filter to be used with array_map

Returns

mixed —

If the setting is an array, returns the setting passed through array_map if array_map was passed. Otherwise, returns the value of the setting, overridden if an override is present

substitute()

substitute(string  $string, \timestamp  $date = null) : string

Process known substitutions in a string. Currently known options:<br /> o {dow(int day, string format)} day is numeric day of the week, format format is an strftime string (e.g. '%Y%m%d'), replaced with the formatted date for the requested day of the week o {i} replaced with the instance of this comic as determined by the various instance configuration options<br /> o {format} format is an strftime string, replaced with todays date formatted according to the format string<br /> o {lc(string)} replaces string with string lowercased<br /> o {uc(string)} replaces string with string uppercased<br /> o {t(string)} removes extra space surrounding string<br /> o {tl0(string)} removes leading zeroes from string

Parameters

string $string

String to process

\timestamp $date

Date to use when processing subs

Returns

string —

A string with all substitutions made

getInstance()

getInstance(\timestamp  $date) : string

Get the instance requested based on the date. The instance is determined by itype, iformat, idate, isow

Parameters

\timestamp $date

The date the instance occurs on

Returns

string —

An strftime-formatted string based on the iformat parameter

getInstance_monthly()

getInstance_monthly(\timestamp  $date) : integer

Get an instance number for a comic that appears monthly

Parameters

\timestamp $date

The date the comic appears

Returns

integer —

The instance number (unformatted)

getInstance_weekly()

getInstance_weekly(\timestamp  $date) : integer

Get an instance number for a comic that appears weekly

Parameters

\timestamp $date

The date the comic appears

Returns

integer —

The instance number (unformatted)

getInstance_yearly()

getInstance_yearly(\timestamp  $date) : integer

Get an instance number for a comic that appears yearly (NOT IMPLEMENTED!)

Parameters

\timestamp $date

The date the comic appears

Returns

integer —

The instance number (unformatted)

getInstance_ref()

getInstance_ref(\timestamp  $date) : integer

Get an instance number for a comic based on a date reference.

This takes the idate option as a reference date, then uses the 'days' setting to determine how often it appears. Using this information it extrapolates which instance will occur on the date requested.

Parameters

\timestamp $date

The date the comic appears

Returns

integer —

The instance number (unformatted)

Klutz_Comic_bysize()

Klutz_Comic_bysize(string  $comic) 

Constructor - Create an object that can be used to retrieve a comic by looking at all images on a page, a list of images to ignore, and a range of dimensions, then choose which image is most likely the comic.

Parameters

string $comic

Index for the comic

fetchURL()

fetchURL(\timestamp  $date = null) : string

Do all that is necessary to get the final URL from which the comic will be fetched. Instead of returning the comic, return the URL pointing to that comic.

Parameters

\timestamp $date

Date of the comic to retrieve (default today)

Returns

string —

URL of the comic image

fetchImage()

fetchImage(\timestamp  $date = null) : mixed

Fetch the actual image

Parameters

\timestamp $date

The date to retrieve the comic for (default today).

Returns

mixed —

Klutz_Image on success, false otherwise.

_stripimages()

_stripimages(string  $document) : array

Strip the list of images from the contents of a web page.

Derived from Snoopy's striplinks function.

Parameters

string $document

The HTML document to parse.

Returns

array —

List of images in the page.

_expandurls()

_expandurls(array  $urls, string  $base) : array

Expand paths to fully-qualified URLs

Parameters

array $urls

Paths to expand

string $base

The base URL used for relative links

Returns

array —

Fully-qualified URLs

_ignore()

_ignore(string  $string) : boolean

Determine if the passed image name is on the list of images to ignore.

Parameters

string $string

The name to check

Returns

boolean —

True if we should ignore it

_getsizes()

_getsizes(array  $images, boolean  $filter = true, \timestamp  $date = null) : array

Get the dimensions from the list of images passed in.

Parameters

array $images

The list of images to check.

boolean $filter

Filter by size, etc? (true).

\timestamp $date

Date to use for filter prefs.

Returns

array —

Dimensions for all desired images.