Content
class Content
Represents a single content object.
Content objects are the base data class for Tuskfish CMS. The 'type' property determines the template that will be used to display the object, and some aspects of its behaviour.
Traits
Methods
Returns a list of template names used by specific content types.
Return a list of permitted audio mimetypes and extensions.
Return a list of permitted image mimetypes and extensions.
Return a list of permitted video mimetypes and extensions.
Returns an array of mimetypes that are permitted for upload to the media directory.
Resizes and caches an associated image and returns a URL to the cached copy.
Returns a list of intellectual property rights licenses for the content submission form.
Check if a file path contains traversals (including encoded traversals) or null bytes.
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.
Magic get access is to support the Tree class - better to refactor it.
Load properties.
Converts bytes to a human readable units (KB, MB, GB etc).
Convert the site base URL to the TFISH_LINK constant and vice versa.
Return a URL (permalink) to a content object.
Return ID.
Set ID
Return title.
Set title
Return type of content object.
Set type.
Return teaser.
Return teaser with TFISH_LINK constant converted to URL.
Set teaser.
Return description.
Return description with TFISH_LINK constant converted to URL.
Set description.
Return creator.
Set creator.
Return media file name.
Set media file name.
Return file extension.
Return format (mimetype).
Set format.
Return file size of media attachment.
Set file size of media attachment.
Return image name.
Set image.
Return caption of image.
Set caption.
Set date.
Return meta information about content object.
Return submission time.
Set submission time.
Return last modification time.
Set last updated time.
Return expiry date.
Set expiry time.
Return view/download counter.
Set view/download counter.
Return online status.
Set online status.
Return parent ID.
Set parent.
Return language.
Set language.
Return rights.
Set rights.
Return publisher.
Set publisher.
Return module.
Set module.
Details
in ContentTypes at line 36
array
listTemplates()
Returns a list of template names used by specific content types.
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.
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 Metadata at line 45
string
metaTitle()
Return meta title.
Used to set the
in Metadata at line 55
setMetaTitle(string $metaTitle)
Set meta title.
in Metadata at line 67
string
metaDescription()
Return meta description.
Used to set the tag.
in Metadata at line 77
setMetaDescription(string $metaDescription)
Set meta description.
in Metadata at line 90
string
metaSeo()
Return SEO-friendly string.
This is an SEO-friendly text fragment that can be appended to URLs. It does not affct URL function in any way, since Tuskfish never uses it as a parameter.
in Metadata at line 100
setMetaSeo(string $metaSeo)
Set SEO-friendly string
in Mimetypes at line 36
array
listAudioMimetypes()
Return a list of permitted audio mimetypes and extensions.
in Mimetypes at line 51
array
listImageMimetypes()
Return a list of permitted image mimetypes and extensions.
in Mimetypes at line 65
array
listVideoMimetypes()
Return a list of permitted video mimetypes and extensions.
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.
in ResizeImage at line 48
string
cachedImage(int $width = 0, int $height = 0)
Resizes and caches an associated image and returns a URL to the cached copy.
Allows arbitrary sized thumbnails to be produced from the object's image property. These are saved in the cache for future lookups. Image proportions are always preserved, so if both width and height are specified, the larger dimension will take precedence for resizing and the other will be ignored.
Usually, you want to produce an image of a specific width or (less commonly) height to meet a template/presentation requirement.
Requires GD library.
in Rights at line 41
array
listRights()
Returns a list of intellectual property rights licenses for the content submission form.
In the interests of brevity and sanity, a comprehensive list is not provided. Add entries that you want to use to the array below. Be aware that deleting entries that are in use by your content objects will cause errors.
in Tag at line 39
array
tags()
Return tags.
in Tag at line 49
setTags(array $tags)
Set tags.
in TraversalCheck at line 46
bool
hasTraversalorNullByte(string $path)
Check if a file path contains traversals (including encoded traversals) or null bytes.
Directory traversals are not permitted in Tuskfish method parameters. If a path is found to contain a traversal it is presumed to be an attack. Encoded traversals are a clear sign of attempted abuse.
In general untrusted data should never be used to construct a file path. This method exists as a second line safety measure.
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 99
__get($property)
Magic get access is to support the Tree class - better to refactor it.
at line 113
load(array $row, bool $convertUrlToConstant = true)
Load properties.
Parameters are validated by the respective setters.
at line 161
string
bytesToHumanReadable(int $bytes)
Converts bytes to a human readable units (KB, MB, GB etc).
at line 194
protected
convertBaseUrlToConstant(string $html, bool $convertToConstant = false)
Convert the site base URL to the TFISH_LINK constant and vice versa.
This aids site portability. The URL is stored as a constant in the database, but is converted to actual URL on display. If the domain changes at some point all the references to TFISH_LINK will update automatically.
at line 228
string
url(string $customRoute = '')
Return a URL (permalink) to a content object.
at line 264
int
id()
Return ID.
at line 274
setId(int $id)
Set ID
at line 288
string
title()
Return title.
at line 298
setTitle(string $title)
Set title
at line 308
string
type()
Return type of content object.
at line 318
setType(string $type)
Set type.
at line 336
string
teaser()
Return teaser.
This is a HTML field. It has been input-validated but should not be output escaped.
at line 348
string
teaserForDisplay()
Return teaser with TFISH_LINK constant converted to URL.
This is a HTML field. It has been input-validated but should not be output escaped.
at line 359
setTeaser(string $teaser)
Set teaser.
at line 371
string
description()
Return description.
This is a HTML field. It has been input-validated but should not be output escaped.
at line 383
string
descriptionForDisplay()
Return description with TFISH_LINK constant converted to URL.
This is a HTML field. It has been input-validated but should not be output escaped.
at line 394
setDescription(string $description)
Set description.
at line 404
string
creator()
Return creator.
at line 414
setCreator(string $creator)
Set creator.
at line 424
string
media()
Return media file name.
at line 434
setMedia(string $filename)
Set media file name.
at line 460
string
extension()
Return file extension.
at line 470
string
format()
Return format (mimetype).
at line 480
setFormat(string $format)
Set format.
at line 497
string
fileSize()
Return file size of media attachment.
at line 507
setFileSize(int $fileSize)
Set file size of media attachment.
at line 521
string
image()
Return image name.
at line 531
setImage(string $filename)
Set image.
at line 556
string
caption()
Return caption of image.
at line 566
setCaption(string $caption)
Set caption.
at line 576
DateTime
date()
Return date as a DateTime object that can be manipulated.
at line 586
setDate(string $date)
Set date.
at line 604
string
info()
Return meta information about content object.
at line 630
int
submissionTime()
Return submission time.
at line 640
setSubmissionTime(int $timestamp)
Set submission time.
at line 654
int
lastUpdated()
Return last modification time.
at line 664
setLastUpdated(int $timestamp)
Set last updated time.
at line 680
int
expiresOn()
Return expiry date.
Expiry date is not yet implemented.
at line 690
setExpiresOn(int $timestamp)
Set expiry time.
at line 706
int
counter()
Return view/download counter.
The counter tracks downloads for download content types, and views for everything else.
at line 716
setCounter(int $counter)
Set view/download counter.
at line 730
int
onlineStatus()
Return online status.
at line 740
setOnlineStatus(int $status)
Set online status.
at line 754
int
parent()
Return parent ID.
at line 764
setParent(int $parent)
Set parent.
at line 782
string
language()
Return language.
at line 792
setLanguage(string $language)
Set language.
at line 808
int
rights()
Return rights.
Rights is an index to a license found in listRights();
at line 820
setRights(int $rights)
Set rights.
Index to license stored in listRights().
at line 834
string
publisher()
Return publisher.
at line 844
setPublisher(string $publisher)
Set publisher.
at line 856
string
module()
Return module.
Deprecated.
at line 868
setModule(string $module)
Set module.
Deprecated, will be removed.