class Rss implements Viewable

ViewModel for displaying RSS feeds from content objects.

Traits

Provides a list of common (permitted) mimetypes for file uploads.
Provides methods for validating UTF-8 character encoding and string composition.
Provides standard implementation for the Viewable interface.

Methods

array
listAudioMimetypes()

Return a list of permitted audio mimetypes and extensions.

from Mimetypes
array
listImageMimetypes()

Return a list of permitted image mimetypes and extensions.

from Mimetypes
array
listVideoMimetypes()

Return a list of permitted video mimetypes and extensions.

from Mimetypes
array
listMimetypes()

Returns an array of mimetypes that are permitted for upload to the media directory.

from Mimetypes
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.

string
pageTitle()

Return title of this page.

from Viewable
setPageTitle(string $pageTitle)

Set the title of this page.

from Viewable
template()

Return the template object required by this page.

from Viewable
setTemplate(string $template)

Set the template used by this page.

from Viewable
string
theme()

Return the theme used by this page.

from Viewable
setTheme(string $theme)

Set (change) the theme.

from Viewable
array
metadata()

Return page-specific metadata overrides.

from Viewable
setMetadata(array $metadata)

Set page-specific overrides of the site metadata.

from Viewable
__construct(object $model)

Constructor.

array
listContent()

Return content objects for the feed.

array
listContentForTag()

Return content objects for a given tag.

string
copyright()

Return site (feed) copyright.

string
description()

Return site (feed) description.

array
items()

Return items for the feed.

string
link()

Return link to RSS feed.

setCollection(int $id)

Set collection ID.

setTag(int $tag)

Set tag ID.

string
siteEmail()

Return site administrative email address.

string
title()

Return site (feed) title.

string
webMaster()

Return site webmaster's email address.

Details

in Mimetypes at line 36
array listAudioMimetypes()

Return a list of permitted audio mimetypes and extensions.

Return Value

array

in Mimetypes at line 51
array listImageMimetypes()

Return a list of permitted image mimetypes and extensions.

Return Value

array

in Mimetypes at line 65
array listVideoMimetypes()

Return a list of permitted video mimetypes and extensions.

Return Value

array

in Mimetypes at line 85
array listMimetypes()

Returns an array of mimetypes that are permitted for upload to the media directory.

NOTE: Adding HTML or any other scripting language or executable to this list would be a BAD IDEA, as such files can include PHP code, although uploaded files have execution permissions removed and are stored outside of the web root in order to prevent direct access by browser.

Return Value

array Array of permitted mimetypes and extensions.

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.

in Viewable at line 39
string pageTitle()

Return title of this page.

Return Value

string

in Viewable at line 49
setPageTitle(string $pageTitle)

Set the title of this page.

Parameters

string $pageTitle Title of this page.

in Viewable at line 59
Template template()

Return the template object required by this page.

Return Value

Template

in Viewable at line 69
setTemplate(string $template)

Set the template used by this page.

Parameters

string $template Name of template (alphanumeric and underscore characters only).

in Viewable at line 86
string theme()

Return the theme used by this page.

Return Value

string

in Viewable at line 98
setTheme(string $theme)

Set (change) the theme.

You must ensure that the new theme directory contains the HTML template files that you need.

Parameters

string $theme Name of theme directory (alphanumeric and underscores only).

in Viewable at line 115
array metadata()

Return page-specific metadata overrides.

Return Value

array

in Viewable at line 125
setMetadata(array $metadata)

Set page-specific overrides of the site metadata.

Parameters

array $metadata Array of metadata as key => value pairs.

at line 52
__construct(object $model)

Constructor.

Parameters

object $model Instance of a model class.

at line 67
array listContent()

Return content objects for the feed.

Return Value

array Array of content objects.

at line 77
array listContentForTag()

Return content objects for a given tag.

Return Value

array Array of content objects.

Return site (feed) copyright.

Return Value

string

at line 111
string description()

Return site (feed) description.

Return Value

string

at line 125
array items()

Return items for the feed.

Return Value

array Array of content objects.

Return link to RSS feed.

Return Value

string URL.

at line 153
setCollection(int $id)

Set collection ID.

Parameters

int $id ID of collection.

at line 164
setTag(int $tag)

Set tag ID.

Parameters

int $tag ID of tag.

at line 175
string siteEmail()

Return site administrative email address.

Return Value

string Email address.

at line 185
string title()

Return site (feed) title.

Return Value

string Title, as set in site preferences.

at line 199
string webMaster()

Return site webmaster's email address.

Return Value

string Email address.