Tuskfish API
  • Package
  • Class

Packages

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

Classes

  • TfishArticle
  • TfishArticleHandler
  • TfishAudio
  • TfishAudioHandler
  • TfishBlock
  • TfishBlockHandler
  • TfishCollection
  • TfishCollectionHandler
  • TfishContentHandler
  • TfishContentObject
  • TfishDownload
  • TfishDownloadHandler
  • TfishImage
  • TfishImageHandler
  • TfishMetadata
  • TfishRss
  • TfishStatic
  • TfishStaticHandler
  • TfishTag
  • TfishTagHandler
  • TfishTaglink
  • TfishTaglinkHandler
  • TfishTemplate
  • TfishVideo
  • TfishVideoHandler

Class TfishContentObject

Parent content object class, represents a single content object.

There is only one 'archtype' of content object in Tuskfish; it uses standard Dublin Core metadata fields plus a few more that are common to most content objects. Why? If you look at most common content types - articles, photos, downloads etc. - you will see that for the most part they all use the same fields. For example, everything has a title, everything has a description, everything has an author, everything has a hit counter.

Traditionally, most CMS create a separate database table for every type of content with duplicate column names. And it works just fine until you want to publish a single content stream containing different kinds of content objects. Then, suddenly, your queries are full of complex joins and other rubbish and it becomes very painful to work with.

By using a single table for content objects with common field names our queries become very simple and much redundancy is avoided. Of course, some types of content might not require a few particular properties; and so subclassed content types simply unset() any properties that they don't need in their constructor.

TfishAncestralObject
Extended by TfishContentObject

Direct known subclasses

TfishArticle, TfishAudio, TfishBlock, TfishCollection, TfishDownload, TfishImage, TfishStatic, TfishTag, TfishVideo

Package: content
Copyright: Simon Wilkinson 2013-2017 (https://tuskfish.biz)
License: GNU General Public License (GPL) V2
Author: Simon Wilkinson simon@isengard.biz
Version: Release: 1.0
Since: 1.0
Properties: int $id Auto-increment, set by database.
Properties: string $type Content object type eg. TfishArticle etc. [ALPHA]
Properties: string $title The name of this content.
Properties: string $teaser A short (one paragraph) summary or abstract for this content. [HTML]
Properties: string $description The full article or description of the content. [HTML]
Properties: string $media An associated download/audio/video file. [FILEPATH OR URL]
Properties: string $format Mimetype
Properties: string $file_size Specify in bytes.
Properties: string $creator Author.
Properties: string image An associated image file, eg. a screenshot a good way to handle it. [FILEPATH OR URL]
Properties: string $caption Caption of the image file.
Properties: string $date Date of publication expressed as a string.
Properties: int $parent A source work or collection of which this content is part.
Properties: string $language Future proofing.
Properties: int $rights Intellectual property rights scheme or license under which the work is distributed.
Properties: string $publisher The entity responsible for distributing this work.
Properties: array $tags Tag IDs associated with this object; not persistent (stored as taglinks in taglinks table).
Properties: int $online Toggle object on or offline.
Properties: int $submission_time Timestamp representing submission time.
Properties: int $counter Number of times this content was viewed or downloaded.
Properties: string $meta_title Set a custom page title for this content.
Properties: string $meta_description Set a custom page meta description for this content.
Properties: string $seo SEO-friendly string; it will be appended to the URL for this content.
Properties: string $handler Handler for this object (not persistent).
Properties: string $template The template that should be used to display this object (not persistent).
Properties: string $module The module that handles this content type (not persistent).
Properties: string $icon The vector icon that represents this object type (not persistent).
Located at trust_path/libraries/tuskfish/class/TfishContentObject.php

Methods summary

public
# __construct( )

Initialise default content object properties and values.

Initialise default content object properties and values.

protected string
# makeHumanReadable( string $clean_property )

Converts properties to human readable form in preparation for output.

Converts properties to human readable form in preparation for output.

This method is overridden in child subclasses, to allow for the possibility of handling additional properties. The overrides refer back to this parent method for handling base (standard) properties of this parent class.

Parameters

$clean_property
$property Name of property.

Returns

string
Property formatted to human readable form for output.
public string
# escape( string $property, boolean $escape_html = false )

Escapes object properties for output to browser.

Escapes object properties for output to browser.

Use this method to retrieve object properties when you want to send them to the browser. They will be automatically escaped with htmlspecialchars() to mitigate cross-site scripting attacks.

Note that the method excludes the teaser and description fields by default, which are returned unescaped; these are dedicated HTML fields that have been input-validated with the HTMLPurifier library, and so should be safe. However, when editing these fields it is necessary to escape them in order to prevent TinyMCE deleting them, as the '&' part of entity encoding also needs to be escaped when in a textarea for some highly annoying reason.

Parameters

$property
Name of property.
$escape_html
Whether to escape HTML fields (teaser, description).

Returns

string
Human readable value escaped for display.
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.

Parameters

$width
Width of the cached image output.
$height
Height of the cached image output.

Returns

string
$url URL to the cached image.
public string
# getURL( string $custom_page = '' )

Generates a URL to access this object in single view mode.

Generates a URL to access this object in single view mode.

URL can point relative to either the home page (index.php, or other custom content stream page defined by modifying TFISH_PERMALINK_URL in config.php) or to an arbitrary page in the web root. For example, you could rename index.php to 'blog.php' to free up the index page for a landing page (this requires you to append the name of the new page to the TFISH_PERMALINK_URL constant).

You can set up an articles.php page to display only TfishArticle objects. The subclass-specific pages are found in the trust_path/extras folder. Just drop them into your site root to use them.

Parameters

$custom_page
Use an arbitrary target page or the home page (index.php).

Returns

string
URL to view this object.
public
# loadProperties( array $dirty_input, boolean $live_urls = 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

$dirty_input
Usually raw form $_REQUEST data.
$live_urls
Convert base url to TFISH_LINK (true) or TFISH_LINK to base url (false).
public
# __set( string $property, mixed $value )

Set the value of a whitelisted property.

Set the value of a whitelisted property.

Intercepts direct calls to set the value of an object property. This method is overridden by child classes to impose data type restrictions and range checks before allowing the property to be set. Tuskfish objects are designed not to trust other components; each conducts its own internal validation checks.

Parameters

$property
Name of property.
$value
Value of property.

Overrides

TfishAncestralObject::__set
public boolean
# validMedia( )

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 array
# zeroedProperties( )

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

Methods inherited from TfishAncestralObject

__get(), __isset(), __unset(), getPropertyWhitelist(), toArray()

Properties summary

Properties inherited from TfishAncestralObject

$__data, $__properties

Tuskfish API API documentation generated by ApiGen