class Listing

Model for listing content objects.

Traits

Provides definition of permitted content object types.
Provides methods for validating UTF-8 character encoding and string composition.

Methods

array
listTemplates()

Returns a list of template names used by specific content types.

array
listTypes()

Returns a whitelist of permitted content object types.

string
encodeEscapeUrl(string $url)

URL-encode and escape a query string for use in a URL.

bool
isAlnum(string $alnum)

Check that a string is comprised solely of alphanumeric characters.

bool
isAlnumUnderscore(string $alnumUnderscore)

Check that a string is comprised solely of alphanumeric characters and underscores.

bool
isAlpha(string $alpha)

Check that a string is comprised solely of alphabetical characters.

bool
isUtf8(string $text)

Check if the character encoding of text is UTF-8.

string
trimString(mixed $text)

Cast to string, check UTF-8 encoding and strip trailing whitespace and control characters.

__construct(Database $database, CriteriaFactory $criteriaFactory, Preference $preference, Session $session)

Constructor.

Mixed
getObject(int $id)

Get a single content object.

array
getObjects(array $params)

Get content objects matching filtering criteria.

array
activeTagOptions()

Return IDs and titles of tags that are actually in use with content objects.

int
adminlimit()

Return the admin-side pagination limit.

array
collectionTagOptions(int $id)

Return a collection of tags.

string
dateFormat()

Returns the template for formatting the date from preferences.

int
gallerylimit()

Return the gallery pagination limit.

int
getCount(array $params)

No description

string
mapsApiKey()

Returns the Google Maps API key (if set) from preferences.

array
getTagsForObject(int $id)

Get the tags associated with a content object.

int
userlimit()

Return the user-side pagination limit.

Details

in ContentTypes at line 36
array listTemplates()

Returns a list of template names used by specific content types.

Return Value

array Array of type-template key values.

in ContentTypes at line 62
array listTypes()

Returns a whitelist of permitted content object types.

Use this whitelist when dynamically instantiating content objects. If you create additional types of content object (which must be descendants of the TfContentObject class) you must add them to the whitelist below. Otherwise their use will be denied in many parts of the Tuskfish system.

Return Value

array Array of whitelisted (permitted) content object types.

in ValidateString at line 41
string encodeEscapeUrl(string $url)

URL-encode and escape a query string for use in a URL.

Trims, checks for UTF-8 compliance, rawurlencodes and then escapes with htmlspecialchars(). If you wish to use the data on a landing page you must decode it with htmlspecialchars_decode() followed by rawurldecode() in that order. But really, if you are using any characters that need to be encoded in the first place you should probably just stop.

Parameters

string $url Unescaped input URL.

Return Value

string Encoded and escaped URL.

in ValidateString at line 59
bool isAlnum(string $alnum)

Check that a string is comprised solely of alphanumeric characters.

Accented regional characters are rejected. This method is designed to be used to check database identifiers or object property names.

Parameters

string $alnum Input to be tested.

Return Value

bool True if valid alphanumerical string, false otherwise.

in ValidateString at line 77
bool isAlnumUnderscore(string $alnumUnderscore)

Check that a string is comprised solely of alphanumeric characters and underscores.

Accented regional characters are rejected. This method is designed to be used to check database identifiers or object property names.

Parameters

string $alnumUnderscore Input to be tested.

Return Value

bool True if valid alphanumerical or underscore string, false otherwise.

in ValidateString at line 95
bool isAlpha(string $alpha)

Check that a string is comprised solely of alphabetical characters.

Tolerates vanilla ASCII only. Accented regional characters are rejected. This method is designed to be used to check database identifiers or object property names.

Parameters

string $alpha Input to be tested.

Return Value

bool True if valid alphabetical string, false otherwise.

in ValidateString at line 113
bool isUtf8(string $text)

Check if the character encoding of text is UTF-8.

All strings received from external sources must be passed through this function, particularly prior to storage in the database.

Parameters

string $text Input string to check.

Return Value

bool True if string is UTF-8 encoded otherwise false.

in ValidateString at line 131
string trimString(mixed $text)

Cast to string, check UTF-8 encoding and strip trailing whitespace and control characters.

Removes trailing whitespace and control characters (ASCII <= 32 / UTF-8 points 0-32 inclusive), checks for UTF-8 character set and casts input to a string. Note that the data returned by this function still requires escaping at the point of use; it is not database or XSS safe.

As the input is cast to a string do NOT apply this function to non-string types (int, float, bool, object, resource, null, array, etc).

Parameters

mixed $text Input to be trimmed.

Return Value

string Trimmed and UTF-8 validated string.

at line 52
__construct(Database $database, CriteriaFactory $criteriaFactory, Preference $preference, Session $session)

Constructor.

Parameters

Database $database Instance of the Tuskfish database class.
CriteriaFactory $criteriaFactory Instance of the criteria factory class.
Preference $preference Instance of the Tuskfish site preferences class.
Session $session Instance of the Tuskfish session manager class.

at line 73
Mixed getObject(int $id)

Get a single content object.

Parameters

int $id ID of the content object to retrieve.

Return Value

Mixed \Tfish\Content\Entity\Content on success, false on failure.

at line 106
array getObjects(array $params)

Get content objects matching filtering criteria.

Parameters

array $params Filtering criteria.

Return Value

array Array of content objects.

at line 121
array activeTagOptions()

Return IDs and titles of tags that are actually in use with content objects.

Return Value

array IDs and titles as key-value pairs.

at line 160
int adminlimit()

Return the admin-side pagination limit.

Return Value

int Number of content items to display in one page view.

at line 173
array collectionTagOptions(int $id)

Return a collection of tags.

Retrieves tags that have been grouped into a collection as ID-title key-value pairs.

Parameters

int $id ID of the collection content object.

Return Value

array Tag IDs and titles as associative array.

at line 192
string dateFormat()

Returns the template for formatting the date from preferences.

Return Value

string

at line 202
int gallerylimit()

Return the gallery pagination limit.

Return Value

int Number of content items to display in one page view.

at line 207
int getCount(array $params)

Parameters

array $params

Return Value

int

at line 229
string mapsApiKey()

Returns the Google Maps API key (if set) from preferences.

Return Value

string Google Maps API key.

at line 251
array getTagsForObject(int $id)

Get the tags associated with a content object.

Parameters

int $id ID of the content object.

Return Value

array Array of tags as id/title key-value pairs.

at line 370
int userlimit()

Return the user-side pagination limit.

Return Value

int Number of content items to display in one page view.