public static
boolean
|
#
delete( integer $id )
Delete a single object from the content table.
Delete a single object from the content table.
Parameters
- $id
- ID of content object to delete.
Returns
boolean True on success, false on failure.
|
public static
boolean
|
#
deleteParentalReferences( integer $id )
Removes references to a collection when it is deleted or changed to another type.
Removes references to a collection when it is deleted or changed to another type.
Parameters
- $id
- ID of the parent collection.
Returns
boolean True on success, false on failure.
|
public static
boolean
|
#
insert( TfishContentObject $obj )
Inserts a content object into the database.
Inserts a content object into the database.
Note that content child content classes that have unset unused properties from the parent
should reset them to null before insertion or update. This is to guard against the case
where the admin reassigns the type of a content object - it makes sure that unused properties
are zeroed in the database.
Parameters
- $obj
- TfishContentObject subclass.
Returns
boolean True on success, false on failure.
|
public static
boolean
|
#
isSanctionedType( string $type )
Checks if a class name is a sanctioned subclass of TfishContentObject.
Checks if a class name is a sanctioned subclass of TfishContentObject.
Basically this just checks if the class name is whitelisted.
Parameters
- $type
- Type of content object.
Returns
boolean True if sanctioned type otherwise false.
|
public static
array|boolean
|
#
getActiveTagList( string $type = null, boolean $online_only = true )
Get a list of tags actually in use by other content objects, optionally filtered by type.
Get a list of tags actually in use by other content objects, optionally filtered by type.
Used primarily to build select box controls. Use $online_only to select only those tags that
are marked as online (true), or all tags (false).
Parameters
- $type
- Type of content object.
- $online_only
- True if marked as online, false if marked as offline.
Returns
array|boolean List of tags if available, false if empty.
|
public static
integer
|
#
getCount( TfishCriteria $criteria = null )
Count content objects optionally matching conditions specified with a TfishCriteria object.
Count content objects optionally matching conditions specified with a TfishCriteria object.
Parameters
- $criteria
- TfishCriteria object used to build conditional database query.
Returns
integer $count Number of objects matching conditions.
|
public static
array
|
#
getLanguages( )
Returns a list of languages for the content object submission form.
Returns a list of languages for the content object submission form.
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.
Returns
array Array of languages in ISO 639-1 code => name format.
|
public static
array
|
#
getList( TfishCriteria $criteria = null )
Returns a list of content object titles with ID as key.
Returns a list of content object titles with ID as key.
Parameters
- $criteria
- TfishCriteria object used to build conditional database query.
Returns
array Array as id => title of content objects.
|
public static
object|boolean
|
#
getObject( integer $id )
Retrieves a single content object based on its ID.
Retrieves a single content object based on its ID.
Parameters
- $id
- ID of content object.
Returns
object|boolean $object Object on success, false on failure.
|
public static
array
|
#
getObjects( TfishCriteria $criteria = null )
Get content objects, optionally matching conditions specified with a TfishCriteria object.
Get content objects, optionally matching conditions specified with a TfishCriteria object.
Parameters
- $criteria
- TfishCriteria object used to build conditional database query.
Returns
array Array of content objects.
|
public static
string
|
#
getOnlineSelectBox( integer $selected = null, string $zero_option = TFISH_ONLINE_STATUS )
Generates an online/offline select box.
Generates an online/offline select box.
Parameters
- $selected
- The currently option.
- $zero_option
- The text to display in the zero option of the select box.
Returns
string HTML select box.
|
public static
array
|
#
getRights( )
Returns a list of intellectual property rights licenses for the content submission form.
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.
Returns
array Array of copyright licenses.
|
public static
array
|
#
getTagList( boolean $online_only = true )
Get an array of all tag objects in $id => $title format.
Get an array of all tag objects in $id => $title format.
Parameters
- $online_only
- tags marked online only.
Returns
array Array of tag IDs and titles.
|
public static
array
|
#
getTags( )
Get an array of all tag objects.
Get an array of all tag objects.
Use this function when you need to build a buffer of tags to reduce database queries, for
example when looping through a result set.
Returns
array Array of TfishTag objects.
|
protected static
integer|null
|
#
getTypeIndex( array $criteria_items )
Search the filtering criteria ($criteria->items) to see if object type has been set and
return the key.
Search the filtering criteria ($criteria->items) to see if object type has been set and
return the key.
Parameters
- $criteria_items
- Array of TfishCriteriaItem objects.
Returns
integer|null Key of relevant TfishCriteriaItem or null.
|
public static
array
|
#
getTypes( )
Returns a whitelist of permitted content object types, ie. descendants of TfishContentObject.
Returns a whitelist of permitted content object types, ie. descendants of TfishContentObject.
Use this whitelist when dynamically instantiating content objects. If you create additional
types of content object (which must be descendants of the TfishContentObject class) you
must add them to the whitelist below. Otherwise their use will be denied in many parts of
the Tuskfish system.
Returns
array Array of whitelisted (permitted) content object types.
|
public static
string
|
#
getTypeSelectBox( string $selected = '', string $zero_option = null )
Get a content type select box.
Get a content type select box.
Parameters
- $selected
- Currently selected option.
- $zero_option
- The default text to show at top of select box.
Returns
string HTML select box.
|
public static
array
|
#
makeTagLinks( array $tags, string $target_filename = '' )
Converts an array of tag_ids into an array of tag links with an arbitrary local target file.
Converts an array of tag_ids into an array of tag links with an arbitrary local target file.
Note that the filename may only consist of alphanumeric characters and underscores. Do not
include the file extension (eg. use 'article' instead of 'article.php'. The base URL of the
site will be prepended and .php plus the tag_id will be appended.
Parameters
- $tags
- Array of tag IDs.
- $target_filename
- Name of file for tag links to point at.
Returns
array Array of HTML tag links.
|
public static
array|boolean
|
#
searchContent( TfishPreference $tfish_preference, string $search_terms, string $andor, integer $limit = 0, integer $offset = 0 )
Provides global search functionality for content objects.
Provides global search functionality for content objects.
Escaping of search terms is handled through use of a PDO prepared statement with named
placeholders; search terms are inserted indirectly by binding them to the placeholders.
Search terms must NEVER be inserted into a query directly (creates an SQL injection
vulnerability), otherwise do us all a favour and go shoot yourself now.
Search terms have entity encoding (htmlspecialchars) applied on the teaser and description
fields (only) to ensure consistency with the entity encoding treatment that these HTML fields
have been subjected to, otherwise searches involving entities will not return results.
Parameters
- $tfish_preference
- TfishPreference object, to make site preferences available.
- $search_terms
- Search terms.
- $andor
- Operator to chain search terms (AND or OR).
- $limit
- Maximum number of results to retrieve (pagination constraint).
- $offset
- Starting point for retrieving results (pagination constraint).
Returns
array|boolean Array of content objects on success, false failure.
|
public static
boolean
|
#
toggleOnlineStatus( integer $id )
Toggle the online status of a content object.
Toggle the online status of a content object.
Parameters
- $id
- ID of content object.
Returns
boolean True on success, false on failure.
|
public static
object|boolean
|
#
toObject( array $row )
Convert a database content row to a corresponding content object.
Convert a database content row to a corresponding content object.
Only use this function to convert single objects, as it does a separate query to look up
the associated taglinks. Running it through a loop will therefore consume a lot of resources.
To convert multiple objects, load them directly into the relevant class files using
PDO::FETCH_CLASS, prepare a buffer of tags using getTags() and loop through the objects
referring to the buffer rather than hitting the database every time.
Parameters
- $row
- Array of result set from database.
Returns
object|boolean Content object on success, false on failure.
|
public static
boolean
|
#
update( TfishContentObject $obj )
Updates a content object in the database.
Updates a content object in the database.
Parameters
- $obj
- TfishContentObject subclass.
Returns
boolean True on success, false on failure.
|
public static
|
#
updateCounter( integer $id )
Increment a given content object counter field by one.
Increment a given content object counter field by one.
Parameters
- $id
- ID of content object.
|