public
|
#
__construct( TfValidator $validator )
Constructor.
Parameters
- $validator
- An instance of the Tuskfish data validator class.
|
public
array
|
#
convertObjectToArray( )
Converts a content object to an array suitable for insert/update calls to the database.
Converts a content object to an array suitable for insert/update calls to the database.
Note that the returned array observes the PARENT object's getPropertyWhitelist() as a
restriction on the setting of keys. This whitelist explicitly excludes the handler,
template and module properties as these are part of the class definition and are not stored
in the database. Calling the parent's property whitelist ensures that properties that are
unset by child classes are zeroed (this is important when an object is changed to a
different subclass, as the properties used may differ).
Returns
array Array of object property/values.
|
public
string
|
#
getCachedImage( integer $width = 0, integer $height = 0 )
Resizes and caches an associated image and returns a URL to the cached copy.
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.
Parameters
- $width
- Width of the cached image output.
- $height
- Height of the cached image output.
Returns
string $url URL to the cached image.
|
public
array
|
#
getListOfAllowedAudioMimetypes( )
Returns an array of audio mimetypes that are permitted for content objects.
Returns an array of audio mimetypes that are permitted for content objects.
Note that ogg audio files should use the .oga extension, although the legacy .ogg extension
is still acceptable, although it must no longer be used for video files.
Returns
array Array of permitted audio mimetypes in file extension => mimetype format.
|
public
array
|
#
getListOfAllowedImageMimetypes( )
Returns an array of image mimetypes that are permitted for content objects.
Returns an array of image mimetypes that are permitted for content objects.
Returns
array Array of permitted image mimetypes in file extension => mimetype format.
|
public
array
|
#
getListOfAllowedVideoMimetypes( )
Returns an array of video mimetypes that are permitted for upload.
Returns an array of video mimetypes that are permitted for upload.
Note that ogg video files must use the .ogv file extension. Please do not use .ogg for
video files as this practice has been deprecated in favour of .ogv. While .ogg is still in
wide use it is now presumed to refer to audio files only.
Returns
array Array of permitted video mimetypes in file extension => mimetype format.
|
public
array
|
#
getListOfZeroedProperties( )
Returns an array of base object properties that are not used by this subclass.
Returns an array of base object properties that are not used by this subclass.
This list is also used in update calls to the database to ensure that unused columns are
cleared and reset with default values.
Returns
array
|
public
array
|
#
getPropertyWhitelist( )
Returns a whitelist of object properties whose values are allowed be set.
Returns a whitelist of object properties whose values are allowed be set.
This function is used to build a list of $allowedVars for a content object. Child classes
use this list to unset properties they do not use. Properties that are not resident in the
database are also unset here (handler, template, module and icon).
Returns
array Array of object properties as keys.
|
public
boolean
|
#
isValidMedia( )
Determine if the media file (mime) type is valid for this content type.
Determine if the media file (mime) type is valid for this content type.
Used in templates to determine whether a media file should be displayed or not.
For example, if you attach a video file to an audio content object, the
inline player will not be displayed (because it will not work).
Returns
boolean True if media mimetype is valid for this content type, otherwise false.
|
public
|
#
loadPropertiesFromArray( array $dirtyInput, boolean $convertUrlToConstant = true )
Populates the properties of the object from external (untrusted) data source.
Populates the properties of the object from external (untrusted) data source.
Note that the supplied data is internally validated by __set().
Parameters
- $dirtyInput
- Usually raw form $_REQUEST data.
- $convertUrlToConstant
- Convert base url to TFISH_LINK (true) or TFISH_LINK to base url (false).
|
public
|
#
loadImage( array $propertyWhitelist )
Sets the image property from untrusted form data.
Sets the image property from untrusted form data.
This method should be called after loadPropertiesFromArray(), but only when form data is
being sent (submit or update operations). Do not use it when retrieving an object from the
database.
Parameters
- $propertyWhitelist
- List of permitted object properties.
|
public
|
#
loadMedia( array $propertyWhitelist )
Sets the media property from untrusted form data reading from $_FILES.
Sets the media property from untrusted form data reading from $_FILES.
This method should be called after loadPropertiesFromArray(), but only when form data is
being sent (submit or update operations). Do not use it when retrieving an object from the
database.
Parameters
- $propertyWhitelist
- List of permitted object properties.
|
public
string
|
#
convertBytesToHumanReadable( integer $bytes )
Converts bytes to a human readable units (KB, MB, GB etc).
Converts bytes to a human readable units (KB, MB, GB etc).
Parameters
- $bytes
- File size in bytes.
Returns
string Bytes expressed as convenient human readable units.
|
public
|
#
setCaption( string $caption )
Set the caption that will accompany the image property.
Set the caption that will accompany the image property.
Parameters
- $caption
- Caption describing image.
|
public
string
|
#
getCaption( )
Return the caption XSS escaped for display.
Return the caption XSS escaped for display.
Returns
string
|
public
|
#
setCounter( integer $counter )
Set the view/download counter for this object.
Set the view/download counter for this object.
Parameters
Overrides
|
public
integer
|
#
getCounter( )
Return the counter value, XSS safe.
Return the counter value, XSS safe.
Returns
integer Counter.
Overrides
|
public
|
#
setCreator( string $creator )
Set the creator of this object.
Set the creator of this object.
Parameters
- $creator
- Name of the creator.
|
public
string
|
#
getCreator( )
Return the creator XSS escaped for display.
Return the creator XSS escaped for display.
Returns
string Creator.
|
public
|
#
setDate( string $date )
Set the publication date of this object expressed as a string.
Set the publication date of this object expressed as a string.
Parameters
|
public
string
|
#
getDate( )
Return the date XSS escaped for display.
Return the date XSS escaped for display.
Returns
string Date.
|
public
|
#
setDescription( string $description )
Set the description of this object (HTML field).
Set the description of this object (HTML field).
Parameters
- $description
- Description in HTML.
|
public
string
|
#
getDescription( boolean $escapeHtml = false )
Return the description of this object (prevalidated HTML).
Return the description of this object (prevalidated HTML).
Do not escape HTML for front end display, as HTML properties are input validated with
HTMLPurifier. However, you must escape HTML properties when editing content; this is
because TinyMCE requires entities to be double escaped for storage (this is a specification
requirement) or they will not display property.
Parameters
- $escapeHtml
- True to escape HTML, false to return unescaped HTML.
Returns
string Description of this machine as HTML.
|
public
|
#
setFileSize( integer $fileSize )
Set the file size for the media attachment to this object.
Set the file size for the media attachment to this object.
Parameters
- $fileSize
- Filesize in bytes.
|
public
string
|
#
getFileSize( )
Returns the file size in human readable format, XSS escaped for display.
Returns the file size in human readable format, XSS escaped for display.
Returns
string File size.
|
public
|
#
setFormat( string $format )
Set the format (mimetype) for the media attachment to this object.
Set the format (mimetype) for the media attachment to this object.
Mimetypes must be official/correct as they are used in headers to initiate streaming of
media files.
Parameters
|
public
string
|
#
getFormat( )
Returns the file extension associated with the media mimetype, XSS escaped for display.
Returns the file extension associated with the media mimetype, XSS escaped for display.
Returns
string File extension.
|
public
|
#
setImage( string $image )
Set the image for this content object.
Set the image for this content object.
Parameters
- $image
- Filename of the image.
|
public
string
|
#
getImage( )
Return the image file name XSS escaped for display.
Return the image file name XSS escaped for display.
Returns
string Image file name.
|
public
|
#
setLanguage( string $language )
Set the language of this content object.
Set the language of this content object.
Parameters
- $language
- ISO_639-1 two-letter language code.
|
public
string
|
#
getLanguage( )
Returns the language of this object XSS escaped for display.
Returns the language of this object XSS escaped for display.
Returns
string Language.
|
public
|
#
setMedia( string $media )
Set the media attachment for this content object.
Set the media attachment for this content object.
Parameters
- $media
- Filename of the media attachment.
|
public
string
|
#
getMedia( )
Return the media file name XSS escaped for display.
Return the media file name XSS escaped for display.
Returns
string Media file name.
|
public
|
#
setParent( integer $parent )
Set the ID of the parent for this object (must be a collection).
Set the ID of the parent for this object (must be a collection).
Parent ID must be different to content ID (cannot declare self as parent).
Parameters
- $parent
- ID of parent object.
|
public
integer
|
#
getParent( )
Returns the ID of the parent object, XSS safe.
Returns the ID of the parent object, XSS safe.
Returns
integer ID of parent.
|
public
|
#
setPublisher( string $publisher )
Set the publisher of this content object.
Set the publisher of this content object.
Parameters
- $publisher
- Name of the publisher.
|
public
string
|
#
getPublisher( )
Returns the publisher, XSS escaped for display.
Returns the publisher, XSS escaped for display.
Returns
string Publisher.
|
public
|
#
setRights( integer $rights )
Set the intellectual property rights for this content object.
Set the intellectual property rights for this content object.
See getListOfRights() for the available licenses, which you can customise to suit yourself.
Parameters
- $rights
- ID of a copyright license.
|
public
string
|
#
getRights( )
Returns the intellectual property rights license for this content object XSS escaped for display.
Returns the intellectual property rights license for this content object XSS escaped for display.
Returns
string Name of intellectual property rights license for this content object.
|
public
|
#
setTags( array $tags )
Set the tags associated with this content object.
Set the tags associated with this content object.
Parameters
- $tags
- IDs of associated tags.
|
public
|
#
setTeaser( string $teaser )
Set the teaser (short form description) for this content object.(HTML).
Set the teaser (short form description) for this content object.(HTML).
Parameters
- $teaser
- Teaser (in HTML).
|
public
string
|
#
getTeaser( boolean $escapeHtml = false )
Return the teaser of this content (prevalidated HTML).
Return the teaser of this content (prevalidated HTML).
Do not escape HTML for front end display, as HTML properties are input validated with
HTMLPurifier. However, you must escape HTML properties when editing content; this is
because TinyMCE requires entities to be double escaped for storage (this is a specification
requirement) or they will not display property.
Parameters
- $escapeHtml
- True to escape HTML, false to return unescaped HTML.
Returns
string Teaser (short form description) of this machine as HTML.
|
public
|
#
setTitle( string $title )
Set the title of this content object.
Set the title of this content object.
Parameters
- $title
- Title of this object.
|
public
string
|
#
getTitle( )
Returns the title of this content XSS escaped for display.
Returns the title of this content XSS escaped for display.
Returns
string Title.
|
public
|
#
setType( string $type )
Set the content type for this object.
Set the content type for this object.
Type must be the name of a content subclass.
Parameters
- $type
- Class name for this content object.
|
public
string
|
#
getType( )
Returns the type (class name) of this content XSS escaped for display.
Returns the type (class name) of this content XSS escaped for display.
Returns
string Type (class name).
|