Tuskfish API V1.1.3
  • Package
  • Class

Packages

  • content
  • core
  • database
  • installation
  • security
  • user
  • utilities

Classes

  • TfCache
  • TfDataObject
  • TfFileHandler
  • TfLogger
  • TfMetadata
  • TfPaginationControl
  • TfPreference
  • TfPreferenceHandler
  • TfTemplate
  • TfTree

Traits

  • TfLanguage
  • TfMagicMethods
  • TfMimetypes
  • TfRights

Functions

  • checkPasswordStrength
  • hashPassword
  • tf_autoload
  • tfContentModuleAutoload

Class TfPreference

Holds Tuskfish site configuration (preference) data.

A preference object is automatically instantiated on every page via tfHeader.php.

TfPreference uses TfMagicMethods, TfLanguage
Package: core
Copyright: Simon Wilkinson 2013+ (https://tuskfish.biz)
License: GNU General Public License (GPL) V2
Author: Simon Wilkinson simon@isengard.biz
Version: Release: 1.0
Since: 1.0
Uses: trait TfMagicMethods Prevents direct setting of properties / unlisted properties.
Uses: trait TfLanguage to obtain a list of available translations.
Located at trust_path/libraries/tuskfish/class/TfPreference.php

Methods summary

public
# __construct( TfValidator $validator, array $preferences )

Constructor.

Constructor.

Parameters

$validator
An instance of the Tuskfish data validator class.
$preferences

An associative array holding Tuskfish preference settings, may be read from the database or passed in via the preference form.

public string
# escapeForXss( string $property )

Escape a property for on-screen display to prevent XSS.

Escape a property for on-screen display to prevent XSS.

Applies htmlspecialchars() to a property destined for display to mitigate XSS attacks. Note that preference values should not be directly assigned to meta tags; they should be assigned to $tfMetadata instead, which will handle any escaping necessary.

Parameters

$property
Name of property.

Returns

string
Value of property escaped for display.
public array
# getPreferencesAsArray( )

Converts the preference object to an array suitable for insert/update calls to the database.

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.

Returns

array
Array of object property/values.
public
# loadPropertiesFromArray( array $dirtyInput )

Update the preference object from an external data source (eg. form submission).

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.

Parameters

$dirtyInput
Usually $_REQUEST data.
public
# setAdminPagination( integer $value )

Set the number of objects to display in a single admin page view.

Set the number of objects to display in a single admin page view.

Parameters

$value
Number of objects to view on a single page.
public integer
# getAdminPagination( )

Returns the number of objects to display in a single admin page view, XSS safe.

Returns the number of objects to display in a single admin page view, XSS safe.

Returns

integer
Admin pagination.
public
# setSiteAuthor( string $value )

Set the name of the site author. Used to population page meta author tag.

Set the name of the site author. Used to population page meta author tag.

Parameters

$value
Name of the site author.
public string
# getSiteAuthor( )

Returns the site author XSS escaped for display.

Returns the site author XSS escaped for display.

Returns

string
Site author.
public
# setCacheLife( integer $value )

Set life of items in cache (seconds).

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.

Parameters

$value
Expiry timer on cached items (seconds).
public in
# getCacheLife( )

Returns the cache life in seconds, XSS safe.

Returns the cache life in seconds, XSS safe.

Returns

in
Cache life in seconds.
public
# setCloseSite( integer $value )

Open our close the site.

Open our close the site.

Parameters

$value
Site open (0) or closed (1).
public string
# getCloseSite( )

Return the human readable value of the site closed preference, XSS safe.

Return the human readable value of the site closed preference, XSS safe.

Returns

string
Yes if site open, no if site closed.
public
# setDateFormat( string $value )

Set the date format, used to convert timestamps to human readable form.

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

Parameters

$value
Template for formatting dates.
public string
# getDateFormat( )

Returns the data format used to convert timestamps to human readable form, XSS safe.

Returns the data format used to convert timestamps to human readable form, XSS safe.

Returns

string
Date format.
public
# setDefaultLanguage( string $value )

Set the default language for this Tuskfish installation.

Set the default language for this Tuskfish installation.

Parameters

$value
ISO 639-1 two-letter language codes.
public string
# getDefaultLanguage( )

Returns the default site language as a two-letter code XSS escaped for display.

Returns the default site language as a two-letter code XSS escaped for display.

Returns

string
Two letter ISO 639-1 language code.
public
# setSiteDescription( string $value )

Set the site description. Used in meta description tag.

Set the site description. Used in meta description tag.

Parameters

$value
Site description.
public string
# getSiteDescription( )

Returns the site meta tag description, XSS safe.

Returns the site meta tag description, XSS safe.

Returns

string
Site description.
public
# setSiteEmail( string $value )

Set the admin email address for the site.

Set the admin email address for the site.

Used in RSS feeds to populate the managingEditor and webmaster tags.

Parameters

$value
Email address.
public string
# getSiteEmail( )

Returns the site administration email address, XSS safe.

Returns the site administration email address, XSS safe.

Returns

string
Site email address.
public
# setEnableCache( integer $value )

Enable or disable the cache.

Enable or disable the cache.

Parameters

$value
Enabled (1) or disabled (0).
public string
# getEnableCache( )

Returns the human readable value of the enable cache preference, XSS safe.

Returns the human readable value of the enable cache preference, XSS safe.

Returns

string
Yes if enabled, no if not.
public
# setGalleryPagination( integer $value )

Set number of objects to display on the gallery page.

Set number of objects to display on the gallery page.

Parameters

$value
Number of objects to display on a single page view.
public integer
# getGalleryPagination( )

Return the number of objects to display on the gallery page, XSS safe.

Return the number of objects to display on the gallery page, XSS safe.

Returns

integer
Gallery pagination.
public
# setMinSearchLength( integer $value )

Set the minimum length of search terms (characters).

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.

Parameters

$value
Minimum number of characters.
public integer
# getMinSearchLength( )

Returns the minimum allowed length of search terms, XSS safe.

Returns the minimum allowed length of search terms, XSS safe.

Returns

integer
Minimum search length.
public
# setPaginationElements( integer $value )

Set the default number of page slots to display in pagination elements.

Set the default number of page slots to display in pagination elements.

Can be overridden manually in TfishPaginationControl.

Parameters

$value
Number of page slots to display in pagination control.
public integer
# getPaginationElements( )

Returns the number of slots to display in user-side pagination control, XSS safe.

Returns the number of slots to display in user-side pagination control, XSS safe.

Returns

integer
Number of pagination elements.
public
# setRssPosts( integer $value )

Set number of items to display in RSS feeds.

Set number of items to display in RSS feeds.

Parameters

$value
Number of items to include in feed.
public integer
# getRssPosts( )

Returns the number of content items to include in RSS feed, XSS safe.

Returns the number of content items to include in RSS feed, XSS safe.

Returns

integer
Number of posts in RSS.
public
# setSearchPagination( integer $value )

Set number of results to display on a search page view.

Set number of results to display on a search page view.

Parameters

$value
Number of objects to display in a single page view.
public Search
# getSearchPagination( )

Returns the number of items to display in one page of search results, XSS safe.

Returns the number of items to display in one page of search results, XSS safe.

Returns

Search
pagination.
public
# setServerTimezone( string $value )

Set the server timezone.

Set the server timezone.

Parameters

$value
Timezone.
public string
# getServerTimezone( )

Returns the server timezone, XSS safe.

Returns the server timezone, XSS safe.

Returns

string
Server timezone.
public
# setSessionLife( integer $value )

Set the life of an idle session.

Set the life of an idle session.

User will be logged out after being idle for this many minutes.

Parameters

$value
Session life (minutes).
public integer
# getSessionLife( )

Returns session lifetime in seconds, XSS safe.

Returns session lifetime in seconds, XSS safe.

Returns

integer
Session life.
public
# setSessionName( string $value )

Set the name (prefix) used to identify Tuskfish sessions.

Set the name (prefix) used to identify Tuskfish sessions.

If you change it, use something unpredictable.

Parameters

$value
Session name.
public string
# getSessionName( )

Returns the session name, XSS safe but should never be publicly displayed.

Returns the session name, XSS safe but should never be publicly displayed.

This method should only be used in the edit preferences form.

Returns

string
Session name.
public
# setSiteCopyright( string $value )

Set the site meta copyright.

Set the site meta copyright.

Used to populate the dcterms.rights meta tag in the theme. Can be overridden in the theme.html file.

Parameters

$value
Copyright statement.
public string
# getSiteCopyright( )

Returns the site copyright notice, XSS escaped for display.

Returns the site copyright notice, XSS escaped for display.

Returns

string
Site copyright notice.
public
# setSiteName( string $value )

Set the title of the page.

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 TfishMetadata object (see comments at the bottom of controller scripts).

Parameters

$value
public string
# getSiteName( )

Returns the site name XSS escaped for display.

Returns the site name XSS escaped for display.

Returns

string
Site name.
public
# setSiteTimezone( string $value )

Set the site timezone.

Set the site timezone.

This is normally the timezone for your principal target audience.

Parameters

$value
Timezone.
public string
# getSiteTimezone( )

Returns the site timezone, XSS escaped for display.

Returns the site timezone, XSS escaped for display.

Returns

string
Site timezone.
public
# setUserPagination( integer $value )

Set the number of objects to display in a single page view on the public facing side of the site.

Set the number of objects to display in a single page view on the public facing side of the site.

Parameters

$value
Number of objects to display.
public User
# getUserPagination( )

Returns the number of objects to display in a single page view on the public side of the site, XSS escaped for display.

Returns the number of objects to display in a single page view on the public side of the site, XSS escaped for display.

Returns

User
pagination.

Methods used from TfMagicMethods

__get(), __isset(), __set(), __unset()

Methods used from TfLanguage

getListOfLanguages()

Properties summary

protected $validator
#
protected $siteName
#
protected $siteDescription
#
protected $siteAuthor
#
protected $siteEmail
#
protected $siteCopyright
#
protected $closeSite
#
protected $serverTimezone
#
protected $siteTimezone
#
protected $minSearchLength
#
protected $searchPagination
#
protected $userPagination
#
protected $adminPagination
#
protected $galleryPagination
#
protected $rssPosts
#
protected $paginationElements
#
protected $sessionName
#
protected $sessionLife
#
protected $defaultLanguage
#
protected $dateFormat
#
protected $enableCache
#
protected $cacheLife
#

Magic properties

public TfValidator $validator

Instance of the Tuskfish data validator class.

public string $siteName

Name of website.

public string $siteDescription

Meta description of website.

public string $siteAuthor

Author of website.

public string $siteEmail

Administrative contact email for website.

public string $siteCopyright

Copyright notice.

public integer $closeSite

Toggle to close this site.

public string $serverTimezone

Timezone of server location.

public string $siteTimezone

Timezone for main audience location.

public integer $minSearchLength

Minimum length of search terms.

Tuskfish API V1.1.3 API documentation generated by ApiGen