public static
FOFModel
&
|
#
getAnInstance( string $type, string $prefix = '', array $config = array() )
Returns a new model object. Unless overriden by the $config array, it will
try to automatically populate its state from the request variables.
Returns a new model object. Unless overriden by the $config array, it will
try to automatically populate its state from the request variables.
Parameters
- $type
string - $type Model type, e.g. 'Items'
- $prefix
string - $prefix Model prefix, e.g. 'FoobarModel'
- $config
array - $config Model configuration variables
Returns
|
public
boolean
|
#
addBehavior( string $name, array $config = array() )
Adds a behavior to the model
Adds a behavior to the model
Parameters
- $name
string - $name The name of the behavior
- $config
array - $config Optional Behavior configuration
Returns
boolean - True if the behavior is found and added
|
public static
FOFModel
&
|
#
getTmpInstance( string $type, string $prefix = '', array $config = array() )
Returns a new instance of a model, with the state reset to defaults
Returns a new instance of a model, with the state reset to defaults
Parameters
- $type
string - $type Model type, e.g. 'Items'
- $prefix
string - $prefix Model prefix, e.g. 'FoobarModel'
- $config
array - $config Model configuration variables
Returns
|
public static
array
|
#
addIncludePath( mixed $path = '', string $prefix = '' )
Add a directory where FOFModel should search for models. You may either pass
a string or an array of directories.
Add a directory where FOFModel should search for models. You may either pass
a string or an array of directories.
Parameters
- $path
mixed - $path A path or array[sting] of paths to search.
- $prefix
string - $prefix A prefix for models.
Returns
array - An array with directory elements. If prefix is equal to '', all directories are
returned.
Since
12.2
|
public static
|
#
addTablePath( mixed $path )
Adds to the stack of model table paths in LIFO order.
Adds to the stack of model table paths in LIFO order.
Parameters
- $path
mixed - $path The directory as a string or directories as an array to add.
Since
12.2
|
protected static
string
|
#
_createFileName( string $type, array $parts = array() )
Create the filename for a resource
Create the filename for a resource
Parameters
- $type
string - $type The resource type to create the filename for.
- $parts
array - $parts An associative array of filename information.
Returns
string - The filename
Since
12.2
|
public
|
#
__construct( array $config = array() )
Public class constructor
Parameters
- $config
array - $config The configuration array
Overrides
|
public
FOFModel
|
#
setIDsFromRequest( )
Sets the list of IDs from the request data
Sets the list of IDs from the request data
Returns
|
public
FOFModel
|
#
setId( integer $id = 0 )
Sets the ID and resets internal data
Sets the ID and resets internal data
Parameters
- $id
integer - $id The ID to use
Returns
Throws
|
public
integer
|
#
getId( )
Returns the currently set ID
Returns the currently set ID
Returns
integer
|
public
FOFModel
|
#
setIds( array $idlist )
Sets a list of IDs for batch operations from an array and resets the
model
Sets a list of IDs for batch operations from an array and resets the
model
Parameters
- $idlist
array - $idlist An array of item IDs to be set to the model's state
Returns
|
public
array
|
#
getIds( )
Returns the list of IDs for batch operations
Returns the list of IDs for batch operations
Returns
array - An array of integers
|
public
FOFModel
|
#
reset( )
Resets the model, like it was freshly loaded
Resets the model, like it was freshly loaded
Returns
|
public
FOFModel
|
#
clearState( )
Clears the model state, but doesn't touch the internal lists of records,
record tables or record id variables. To clear these values, please use
reset().
Clears the model state, but doesn't touch the internal lists of records,
record tables or record id variables. To clear these values, please use
reset().
Returns
|
public
FOFModel
|
|
public
FOFModel
|
#
setInput( mixed $input )
Set the internal input field
Set the internal input field
Parameters
Returns
|
public
FOFModel
|
#
resetSavedState( )
Resets the saved state for this view
Resets the saved state for this view
Returns
|
public
boolean
|
#
loadhistory( integer $version_id, FOFTable & $table, string $alias )
Method to load a row for editing from the version history table.
Method to load a row for editing from the version history table.
Parameters
- $version_id
integer - $version_id Key to the version history table.
- $table
FOFTable - &$table Content table object being loaded.
- $alias
string - $alias The type_alias in #__content_types
Returns
boolean - False on failure or error, true otherwise.
Since
2.3
|
public
FOFTable
&
|
#
getItem( integer $id = null )
Returns a single item. It uses the id set with setId, or the first ID in the
list of IDs for batch operations
Returns a single item. It uses the id set with setId, or the first ID in the
list of IDs for batch operations
Parameters
- $id
integer - $id Force a primary key ID to the model. Use null to use the id from the state.
Returns
FOFTable
- A copy of the item's FOFTable array
|
public
array
&
|
#
getList( boolean $overrideLimits = false, string $group = '' )
Alias for getItemList
Parameters
- $overrideLimits
boolean - $overrideLimits Should I override set limits?
- $group
string - $group The group by clause
Returns
array
CodeCoverageIgnore
|
public
array
&
|
#
getItemList( boolean $overrideLimits = false, string $group = '' )
Returns a list of items
Parameters
- $overrideLimits
boolean - $overrideLimits Should I override set limits?
- $group
string - $group The group by clause
Returns
array
|
public
FOFDatabaseIterator
&
|
#
getIterator( boolean $overrideLimits = false, string $tableClass = null )
Returns a FOFDatabaseIterator over a list of items.
Returns a FOFDatabaseIterator over a list of items.
THERE BE DRAGONS. Unlike the getItemList() you have a few restrictions:
- The onProcessList event does not run when you get an iterator
- The Iterator returns FOFTable instances. By default, $this->table is
used. If you have JOINs, GROUPs or a complex query in general you will need to
create a custom FOFTable subclass and pass its type in $tableType.
The getIterator() method is a great way to sift through a large amount of
records which would otherwise not fit in memory since it only keeps one record
in PHP memory at a time. It works best with simple models, returning all the
contents of a single database table.
Parameters
- $overrideLimits
boolean - $overrideLimits Should I ignore set limits?
- $tableClass
string - $tableClass The table class for the iterator, e.g. FoobarTableBar. Leave empty
to use the default Table class for this Model.
Returns
|
public
FOFTable
&
|
#
getFirstItem( boolean $overrideLimits = false )
A cross-breed between getItem and getItemList. It runs the complete query,
like getItemList does. However, instead of returning an array of ad-hoc objects,
it binds the data from the first item fetched on the list to an instance of the
table object and returns that table object instead.
A cross-breed between getItem and getItemList. It runs the complete query,
like getItemList does. However, instead of returning an array of ad-hoc objects,
it binds the data from the first item fetched on the list to an instance of the
table object and returns that table object instead.
Parameters
- $overrideLimits
boolean - $overrideLimits Should I override set limits?
Returns
|
public
boolean
|
#
save( array|object $data )
Binds the data to the model and tries to save it
Binds the data to the model and tries to save it
Parameters
- $data
array|object - $data The source data array or object
Returns
boolean - True on success
|
public
boolean
|
#
copy( )
Copy one or more records
Returns
boolean - True on success
|
public
FOFTable
|
#
getSavedTable( )
Returns the table object after the last save() operation
Returns the table object after the last save() operation
Returns
|
public
boolean
|
#
delete( )
Deletes one or several items
Deletes one or several items
Returns
boolean - True on success
|
public
boolean
|
#
publish( integer $publish = 1, integer $user = null )
Toggles the published state of one or several items
Toggles the published state of one or several items
Parameters
- $publish
integer - $publish The publishing state to set (e.g. 0 is unpublished)
- $user
integer - $user The user ID performing this action
Returns
boolean - True on success
|
public
boolean
|
#
checkout( )
Checks out the current item
Checks out the current item
Returns
boolean
|
public
boolean
|
#
checkin( )
Checks in the current item
Checks in the current item
Returns
boolean
|
public
boolean
|
#
isCheckedOut( )
Tells you if the current item is checked out or not
Tells you if the current item is checked out or not
Returns
boolean
|
public
boolean
|
#
hit( )
Increments the hit counter
Increments the hit counter
Returns
boolean
|
public
boolean
|
#
move( string $dirn )
Moves the current item up or down in the ordering list
Moves the current item up or down in the ordering list
Parameters
- $dirn
string - $dirn The direction and magnitude to use (2 means move up by 2 positions, -3
means move down three positions)
Returns
boolean - True on success
|
public
boolean
|
#
reorder( )
Reorders all items in the table
Reorders all items in the table
Returns
boolean
|
public
integer
|
#
getTotal( )
Get the number of all items
Get the number of all items
Returns
integer
|
protected
integer
|
#
_getListCount( string $query )
Returns a record count for the query
Returns a record count for the query
Parameters
- $query
string - $query The query.
Returns
integer - Number of rows for query
Since
12.2
|
public
mixed
|
#
getState( string $key = null, mixed $default = null, string $filter_type = 'raw' )
Get a filtered state variable
Get a filtered state variable
Parameters
- $key
string - $key The name of the state variable
- $default
mixed - $default The default value to use
- $filter_type
string - $filter_type Filter type
Returns
mixed - The variable's value
|
protected
object
|
#
_real_getState( string $property = null, mixed $default = null )
Method to get model state variables
Method to get model state variables
Parameters
- $property
string - $property Optional parameter name
- $default
mixed - $default Optional default value
Returns
object - The property where specified, the state object where omitted
Since
12.2
|
public
string
|
#
getHash( )
Returns a hash for this component and view, e.g. "foobar.items.", used for
determining the keys of the variables which will be placed in the session
storage.
Returns a hash for this component and view, e.g. "foobar.items.", used for
determining the keys of the variables which will be placed in the session
storage.
Returns
string - The hash
|
protected
string
|
#
getUserStateFromRequest( string $key, string $request, string $default = null, string $type = 'none', boolean $setUserState = true )
Gets the value of a user state variable.
Gets the value of a user state variable.
Parameters
- $key
string - $key The key of the user state variable.
- $request
string - $request The name of the variable passed in a request.
- $default
string - $default The default value for the variable if not found. Optional.
- $type
string - $type Filter for the variable, for valid values see JFilterInput::clean() . Optional.
- $setUserState
boolean - $setUserState Should I save the variable in the user state? Default: true.
Optional.
Returns
string - The request user state.
|
protected
array
&
|
#
_getList( string $query, integer $limitstart = 0, integer $limit = 0, string $group = '' )
Returns an object list
Parameters
- $query
string - $query The query
- $limitstart
integer - $limitstart Offset from start
- $limit
integer - $limit The number of records
- $group
string - $group The group by clause
Returns
array - Array of objects
|
public
FOFTable
|
#
getTable( string $name = '', string $prefix = null, array $options = array() )
Method to get a table object, load it if necessary.
Method to get a table object, load it if necessary.
Parameters
- $name
string - $name The table name. Optional.
- $prefix
string - $prefix The class prefix. Optional.
- $options
array - $options Configuration array for model. Optional.
Returns
Throws
|
protected
FOFTable
&
|
#
_createTable( string $name, string $prefix = 'Table', array $config = array() )
Method to load and return a model object.
Method to load and return a model object.
Parameters
- $name
string - $name The name of the view
- $prefix
string - $prefix The class prefix. Optional.
- $config
array - $config The configuration array to pass to the table
Returns
FOFTable
- Table object or boolean false if failed
|
public
string
|
#
getReorderWhere( )
Creates the WHERE part of the reorder query
Creates the WHERE part of the reorder query
Returns
string
|
public
FOFDatabaseQuery
|
#
buildQuery( boolean $overrideLimits = false )
Builds the SELECT query
Parameters
- $overrideLimits
boolean - $overrideLimits Are we requested to override the set limits?
Returns
|
public
array
|
#
getTableFields( )
Returns a list of the fields of the table associated with this model
Returns a list of the fields of the table associated with this model
Returns
array
|
public
string
|
#
getTableAlias( )
Get the alias set for this model's table
Get the alias set for this model's table
Returns
string - The table alias
|
public
boolean
|
#
buildCountQuery( )
Builds the count query used in getTotal()
Builds the count query used in getTotal()
Returns
boolean
|
public
FOFModel
&
|
#
getClone( )
Clones the model object and returns the clone
Clones the model object and returns the clone
Returns
|
public
mixed
|
#
__get( string $name )
Magic getter; allows to use the name of model state keys as properties
Magic getter; allows to use the name of model state keys as properties
Parameters
- $name
string - $name The name of the variable to get
Returns
mixed - The value of the variable
|
public
|
#
__set( string $name, mixed $value )
Magic setter; allows to use the name of model state keys as properties
Magic setter; allows to use the name of model state keys as properties
Parameters
- $name
string - $name The name of the variable
- $value
mixed - $value The value to set the variable to
|
public
FOFModel
|
#
__call( string $name, mixed $arguments )
Magic caller; allows to use the name of model state keys as methods to set
their values.
Magic caller; allows to use the name of model state keys as methods to set
their values.
Parameters
- $name
string - $name The name of the state variable to set
- $arguments
mixed - $arguments The value to set the state variable to
Returns
|
public
FOFModel
&
|
#
savestate( boolean $newState )
Sets the model state auto-save status. By default the model is set up to save
its state to the session.
Sets the model state auto-save status. By default the model is set up to save
its state to the session.
Parameters
- $newState
boolean - $newState True to save the state, false to not save it.
Returns
|
public
|
#
populateSavestate( integer $defaultSaveState = -999 )
Initialises the _savestate variable
Initialises the _savestate variable
Parameters
- $defaultSaveState
integer - $defaultSaveState The default value for the savestate
|
protected
|
#
populateState( )
Method to auto-populate the model state.
Method to auto-populate the model state.
This method should only be called once per instantiation and is designed to
be called on the first call to the getState() method unless the model
configuration flag to ignore the request is set.
Since
12.2
Note
Calling getState in this method will result in recursion.
|
public
FOFModel
|
#
applyAccessFiltering( integer $userID = null )
Applies view access level filtering for the specified user. Useful to filter
a front-end items listing.
Applies view access level filtering for the specified user. Useful to filter
a front-end items listing.
Parameters
- $userID
integer - $userID The user ID to use. Skip it to use the currently logged in user.
Returns
|
public
mixed
|
#
getForm( array $data = array(), boolean $loadData = true, boolean $source = null )
A method for getting the form from the model.
A method for getting the form from the model.
Parameters
- $data
array - $data Data for the form.
- $loadData
boolean - $loadData True if the form is to load its own data (default case), false if not.
- $source
boolean - $source The name of the form. If not set we'll try the form_name state variable
or fall back to default.
Returns
mixed - A FOFForm object on success, false on failure
Since
2.0
|
protected
mixed
|
#
loadForm( string $name, string $source, array $options = array(), boolean $clear = false, boolean|string $xpath = false )
Method to get a form object.
Method to get a form object.
Parameters
- $name
string - $name The name of the form.
- $source
string - $source The form filename (e.g. form.browse)
- $options
array - $options Optional array of options for the form creation.
- $clear
boolean - $clear Optional argument to force load a new form.
- $xpath
boolean|string - $xpath An optional xpath to search for the fields.
Returns
mixed - FOFForm object on success, False on error.
Throws
Since
2.0
See
|
public
mixed
|
#
findFormFilename( string $source, array $paths = array() )
Guesses the best candidate for the path to use for a particular form.
Guesses the best candidate for the path to use for a particular form.
Parameters
- $source
string - $source The name of the form file to load, without the .xml extension.
- $paths
array - $paths The paths to look into. You can declare this to override the default FOF
paths.
Returns
mixed - A string if the path and filename of the form to load is found, false otherwise.
Since
2.0
|
protected
array
|
#
loadFormData( )
Method to get the data that should be injected in the form.
Method to get the data that should be injected in the form.
Returns
array - The default data is an empty array.
Since
2.0
|
protected
|
#
preprocessForm( FOFForm & $form, mixed & $data, string $group = 'content' )
Method to allow derived classes to preprocess the form.
Method to allow derived classes to preprocess the form.
Parameters
- $form
FOFForm - $form A FOFForm object.
- $data
mixed - &$data The data expected for the form.
- $group
string - $group The name of the plugin group to import (defaults to "content").
Throws
Exception
- if there is an error in the form event.
Since
2.0
See
|
public
mixed
|
#
validateForm( FOFForm $form, array $data, string $group = null )
Method to validate the form data.
Method to validate the form data.
Parameters
- $form
FOFForm - $form The form to validate against.
- $data
array - $data The data to validate.
- $group
string - $group The name of the field group to validate.
Returns
mixed - Array of filtered data if valid, false otherwise.
Since
2.0
See
|
public
|
#
onBeforeLoadForm( string & $name, string & $source, array & $options )
Allows the manipulation before the form is loaded
Allows the manipulation before the form is loaded
Parameters
- $name
string - &$name The name of the form.
- $source
string - &$source The form source. Can be XML string if file flag is set to false.
- $options
array - &$options Optional array of options for the form creation.
CodeCoverageIgnore
|
public
|
#
onAfterLoadForm( FOFForm & $form, string & $name, string & $source, array & $options )
Allows the manipulation after the form is loaded
Allows the manipulation after the form is loaded
Parameters
- $form
FOFForm - $form A FOFForm object.
- $name
string - &$name The name of the form.
- $source
string - &$source The form source. Can be XML string if file flag is set to false.
- $options
array - &$options Optional array of options for the form creation.
CodeCoverageIgnore
|
public
|
#
onBeforePreprocessForm( FOFForm & $form, array & $data )
Allows data and form manipulation before preprocessing the form
Allows data and form manipulation before preprocessing the form
Parameters
- $form
FOFForm - $form A FOFForm object.
- $data
array - &$data The data expected for the form.
CodeCoverageIgnore
|
public
|
#
onAfterPreprocessForm( FOFForm & $form, array & $data )
Allows data and form manipulation after preprocessing the form
Allows data and form manipulation after preprocessing the form
Parameters
- $form
FOFForm - $form A FOFForm object.
- $data
array - &$data The data expected for the form.
CodeCoverageIgnore
|
protected
|
#
onProcessList( array & $resultArray )
This method can be overriden to automatically do something with the list
results array. You are supposed to modify the list which was passed in the
parameters; DO NOT return a new array!
This method can be overriden to automatically do something with the list
results array. You are supposed to modify the list which was passed in the
parameters; DO NOT return a new array!
Parameters
- $resultArray
array - &$resultArray An array of objects, each row representing a record
|
protected
|
#
onAfterGetItem( FOFTable & $record )
This method runs after an item has been gotten from the database in a read
operation. You can modify it before it's returned to the MVC triad for further
processing.
This method runs after an item has been gotten from the database in a read
operation. You can modify it before it's returned to the MVC triad for further
processing.
Parameters
- $record
FOFTable - &$record The table instance we fetched
|
protected
boolean
|
#
onBeforeSave( array & $data, FOFTable & $table )
This method runs before the $data is saved to the $table. Return false to
stop saving.
This method runs before the $data is saved to the $table. Return false to
stop saving.
Parameters
- $data
array - &$data The data to save
- $table
FOFTable - &$table The table to save the data to
Returns
boolean - Return false to prevent saving, true to allow it
|
protected
boolean
|
#
onAfterSave( FOFTable & $table )
This method runs after the data is saved to the $table.
This method runs after the data is saved to the $table.
Parameters
- $table
FOFTable - &$table The table which was saved
Returns
boolean
|
protected
boolean
|
#
onBeforeDelete( integer & $id, FOFTable & $table )
This method runs before the record with key value of $id is deleted from
$table
This method runs before the record with key value of $id is deleted from
$table
Parameters
- $id
integer - &$id The ID of the record being deleted
- $table
FOFTable - &$table The table instance used to delete the record
Returns
boolean
|
protected
boolean
|
#
onAfterDelete( integer $id )
This method runs after a record with key value $id is deleted
This method runs after a record with key value $id is deleted
Parameters
- $id
integer - $id The id of the record which was deleted
Returns
boolean - Return false to raise an error, true otherwise
|
protected
boolean
|
#
onBeforeCopy( FOFTable & $table )
This method runs before a record is copied
This method runs before a record is copied
Parameters
- $table
FOFTable - &$table The table instance of the record being copied
Returns
boolean - True to allow the copy
|
protected
boolean
|
#
onAfterCopy( FOFTable & $table )
This method runs after a record has been copied
This method runs after a record has been copied
Parameters
- $table
FOFTable - &$table The table instance of the record which was copied
Returns
boolean - True to allow the copy
|
protected
boolean
|
#
onBeforePublish( FOFTable & $table )
This method runs before a record is published
This method runs before a record is published
Parameters
- $table
FOFTable - &$table The table instance of the record being published
Returns
boolean - True to allow the operation
|
protected
boolean
|
#
onAfterPublish( FOFTable & $table )
This method runs after a record has been published
This method runs after a record has been published
Parameters
- $table
FOFTable - &$table The table instance of the record which was published
Returns
boolean - True to allow the operation
|
protected
boolean
|
#
onBeforeHit( FOFTable & $table )
This method runs before a record is hit
This method runs before a record is hit
Parameters
- $table
FOFTable - &$table The table instance of the record being hit
Returns
boolean - True to allow the operation
|
protected
boolean
|
#
onAfterHit( FOFTable & $table )
This method runs after a record has been hit
This method runs after a record has been hit
Parameters
- $table
FOFTable - &$table The table instance of the record which was hit
Returns
boolean - True to allow the operation
|
protected
boolean
|
#
onBeforeMove( FOFTable & $table )
This method runs before a record is moved
This method runs before a record is moved
Parameters
- $table
FOFTable - &$table The table instance of the record being moved
Returns
boolean - True to allow the operation
|
protected
boolean
|
#
onAfterMove( FOFTable & $table )
This method runs after a record has been moved
This method runs after a record has been moved
Parameters
- $table
FOFTable - &$table The table instance of the record which was moved
Returns
boolean - True to allow the operation
|
protected
boolean
|
#
onBeforeReorder( FOFTable & $table )
This method runs before a table is reordered
This method runs before a table is reordered
Parameters
- $table
FOFTable - &$table The table instance being reordered
Returns
boolean - True to allow the operation
|
protected
boolean
|
#
onAfterReorder( FOFTable & $table )
This method runs after a table is reordered
This method runs after a table is reordered
Parameters
- $table
FOFTable - &$table The table instance which was reordered
Returns
boolean - True to allow the operation
|
public
FOFDatabaseDriver
|
#
getDbo( )
Method to get the database driver object
Method to get the database driver object
Returns
|
public
string
|
#
getName( )
Method to get the model name
Method to get the model name
The model name. By default parsed using the classname or it can be set by
passing a $config['name'] in the class constructor
Returns
string - The name of the model
Throws
|
public
|
#
setDbo( FOFDatabaseDriver $db )
Method to set the database driver object
Method to set the database driver object
Parameters
|
public
mixed
|
#
setState( string $property, mixed $value = null )
Method to set model state variables
Method to set model state variables
Parameters
- $property
string - $property The name of the property.
- $value
mixed - $value The value of the property to set or null.
Returns
mixed - The previous value of the property or null if not set.
|
protected
|
#
cleanCache( string $group = null, integer $client_id = 0 )
Clean the cache
Parameters
- $group
string - $group The cache group
- $client_id
integer - $client_id The ID of the client
|
public
FOFModel
|
#
setBehaviorParam( string $name, mixed $value )
Set a behavior param
Parameters
- $name
string - $name The name of the param
- $value
mixed - $value The param value to set
Returns
|
public
mixed
|
#
getBehaviorParam( string $name, mixed $default = null )
Get a behavior param
Parameters
- $name
string - $name The name of the param
- $default
mixed - $default The default value returned if not set
Returns
mixed
|
public
|array
|
#
blacklistFilters( mixed $list = null, boolean $reset = false )
Set or get the backlisted filters
Set or get the backlisted filters
Parameters
- $list
mixed - $list A filter or list of filters to backlist. If null return the list of
backlisted filter
- $reset
boolean - $reset Reset the blacklist if true
Returns
|array - Return an array of value if $list is null
|