Preference
class Preference
Holds Tuskfish site configuration (preference) data.
Traits
Methods
URL-encode and escape a query string for use in a URL.
Check that a string is comprised solely of alphanumeric characters.
Check that a string is comprised solely of alphanumeric characters and underscores.
Check that a string is comprised solely of alphabetical characters.
Cast to string, check UTF-8 encoding and strip trailing whitespace and control characters.
Converts the preference object to an array suitable for insert/update calls to the database.
Update the preference object from an external data source (eg. form submission).
Read out the site preferences into an array.
No description
Set the number of objects to display in a single admin page view.
Return site author
Set the name of the site author. Used to population page meta author tag.
Return cache life.
Set life of items in cache (seconds).
Return the value of the site closed preference.
Open our close the site.
Return date format.
Set the date format, used to convert timestamps to human readable form.
Return default language.
Set the default language for this Tuskfish installation.
Return site description.
Set the site description. Used in meta description tag.
Return site email.
Set the admin email address for the site.
Return enableCache.
Enable or disable the cache.
Return gallery pagination.
Set number of objects to display on the gallery page.
No description
No description
Return minimum search length.
Set the minimum length of search terms (characters).
Return number of elements in a pagination control.
Set the default number of page slots to display in pagination elements.
Return the number of items to include in a RSS feed.
Set number of items to display in RSS feeds.
Number of items to include in a search page view.
Set number of results to display on a search page view.
Return server timezone.
Set the server timezone.
Return session life (minutes).
Set the life of an idle session.
Return session name.
Set the name (prefix) used to identify Tuskfish sessions.
Return site copyright.
Set the site meta copyright.
Return site name.
Set the title of the page.
Return site timezone.
Set the site timezone.
Number of items to display on a single user-side page.
Set the number of objects to display in a single page view on the public facing side of the site.
Details
in Language at line 42
array
listLanguages()
Returns a list of languages in use by the system.
In the interests of brevity and sanity a full list is not provided. Add entries that you want to use to the array using ISO 639-1 two-letter language codes, which you can find at: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes. Be aware that deleting entries that are in use by your content objects will cause errors.
in Timezones at line 36
array
listTimezones()
Provide a list of timezone offsets.
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.
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.
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.
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.
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.
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).
at line 90
__construct(Database $database)
Constructor.
at line 104
array
getPreferencesAsArray()
Converts the preference object to an array suitable for insert/update calls to the database.
Note that the output is not XSS escaped and should not be sent to display.
at line 124
load(array $input)
Update the preference object from an external data source (eg. form submission).
The preference object will conduct its own internal data type validation and range checks.
at line 155
array
readPreferences()
Read out the site preferences into an array.
at line 167
int
adminPagination()
at line 177
setAdminPagination(int $value)
Set the number of objects to display in a single admin page view.
at line 189
string
siteAuthor()
Return site author
at line 199
setSiteAuthor(string $value)
Set the name of the site author. Used to population page meta author tag.
at line 209
int
cacheLife()
Return cache life.
at line 222
setCacheLife(int $value)
Set life of items in cache (seconds).
Items that expire will be rebuilt and re-written to the cache the next time the page is requested.
at line 234
int
closeSite()
Return the value of the site closed preference.
at line 244
setCloseSite(int $value)
Open our close the site.
at line 258
string
dateFormat()
Return date format.
at line 270
setDateFormat(string $value)
Set the date format, used to convert timestamps to human readable form.
See the PHP manual for date formatting templates: http://php.net/manual/en/function.date.php
at line 280
string
defaultLanguage()
Return default language.
at line 290
setDefaultLanguage(string $value)
Set the default language for this Tuskfish installation.
at line 312
string
siteDescription()
Return site description.
at line 322
setSiteDescription(string $value)
Set the site description. Used in meta description tag.
at line 332
string
siteEmail()
Return site email.
at line 344
setSiteEmail(string $value)
Set the admin email address for the site.
Used in RSS feeds to populate the managingEditor and webmaster tags.
at line 374
int
enableCache()
Return enableCache.
at line 384
setEnableCache(int $value)
Enable or disable the cache.
at line 398
int
galleryPagination()
Return gallery pagination.
at line 408
setGalleryPagination(int $value)
Set number of objects to display on the gallery page.
at line 417
string
mapsApiKey()
at line 422
setMapsApiKey(string $value)
at line 434
int
minSearchLength()
Return minimum search length.
at line 448
setMinSearchLength(int $value)
Set the minimum length of search terms (characters).
Search terms less than this number of characters will be discarded. It is usually best to allow a minimum length of 3 characters; this allows searching for common acronyms without returning massive numbers of hits.
at line 462
int
paginationElements()
Return number of elements in a pagination control.
at line 474
setPaginationElements(int $value)
Set the default number of page slots to display in pagination elements.
Can be overridden manually in PaginationControl.
at line 488
int
rssPosts()
Return the number of items to include in a RSS feed.
at line 498
setRssPosts(int $value)
Set number of items to display in RSS feeds.
at line 512
int
searchPagination()
Number of items to include in a search page view.
at line 522
setSearchPagination(int $value)
Set number of results to display on a search page view.
at line 536
int
serverTimezone()
Return server timezone.
at line 546
setServerTimezone(int $value)
Set the server timezone.
at line 556
int
sessionLife()
Return session life (minutes).
at line 568
setSessionLife(int $value)
Set the life of an idle session.
User will be logged out after being idle for this many minutes.
at line 582
string
sessionName()
Return session name.
at line 594
setSessionName(string $value)
Set the name (prefix) used to identify Tuskfish sessions.
If you change it, use something unpredictable.
at line 610
string
siteCopyright()
Return site copyright.
at line 623
setSiteCopyright(string $value)
Set the site meta copyright.
Used to populate the dcterms.rights meta tag in the theme. Can be overridden in the theme.html file.
at line 633
string
siteName()
Return site name.
at line 648
setSiteName(string $value)
Set the title of the page.
Used to populate the meta title tag. Usually each page / object will specify a title, but if none is set this value will be used as the default. The title can be manually overriden on each page using the Metadata object (see comments at the bottom of controller scripts).
at line 658
int
siteTimezone()
Return site timezone.
at line 670
setSiteTimezone(int $value)
Set the site timezone.
This is normally the timezone for your principal target audience.
at line 680
int
userPagination()
Number of items to display on a single user-side page.
at line 691
setUserPagination(int $value)
Set the number of objects to display in a single page view on the public facing side of the site.