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

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)