Add a directory where FOFModel should search for models. You may either pass a string or an array of directories.
static array
addIncludePath
([mixed $path = ''], [string $prefix = ''])
-
mixed
$path: A path or array[sting] of paths to search.
-
string
$prefix: A prefix for models.
Adds to the stack of model table paths in LIFO order.
static void
addTablePath
(mixed $path)
-
mixed
$path: The directory as a string or directories as an array to add.
Returns a new model object. Unless overriden by the $config array, it will try to automatically populate its state from the request variables.
static
FOFModel
&getAnInstance
(
string $type, [
string $prefix =
''], [
array $config =
array()])
-
string
$type: Model type, e.g. 'Items'
-
string
$prefix: Model prefix, e.g. 'FoobarModel'
-
array
$config: Model configuration variables
Returns a new instance of a model, with the state reset to defaults
static
FOFModel
&getTmpInstance
(
string $type, [
string $prefix =
''], [
array $config =
array()])
-
string
$type: Model type, e.g. 'Items'
-
string
$prefix: Model prefix, e.g. 'FoobarModel'
-
array
$config: Model configuration variables
Create the filename for a resource
static string
_createFileName
(string $type, [array $parts = array()])
-
string
$type: The resource type to create the filename for.
-
array
$parts: An associative array of filename information.
Public class constructor
FOFModel
__construct
([type $config = array()])
-
type
$config: The configuration array
Redefinition of:
- JObject::__construct()
- Class constructor, overridden in descendant classes.
Adds a behavior to the model
boolean
addBehavior
(string $name, [array $config = array()])
-
string
$name: The name of the behavior
-
array
$config: Optional Behavior configuration
Applies view access level filtering for the specified user. Useful to filter a front-end items listing.
FOFModel
applyAccessFiltering
([
integer $userID =
null])
-
integer
$userID: The user ID to use. Skip it to use the currently logged in user.
Builds the count query used in getTotal()
boolean
buildCountQuery
()
Builds the SELECT query
-
boolean
$overrideLimits: Are we requested to override the set limits?
Redefined in descendants as:
Checks in the current item
boolean
checkin
()
Checks out the current item
boolean
checkout
()
Clean the cache
void
cleanCache
([string $group = null], [integer $client_id = 0])
-
string
$group: The cache group
-
integer
$client_id: The ID of the client
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().
Copy one or more records
boolean
copy
()
Deletes one or several items
boolean
delete
()
Guesses the best candidate for the path to use for a particular form.
mixed
findFormFilename
(string $source, [array $paths = array()])
-
string
$source: The name of the form file to load, without the .xml extension.
-
array
$paths: The paths to look into. You can declare this to override the default FOF paths.
Clones the model object and returns the clone
Method to get the database driver object
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.
FOFTable
&getFirstItem
([
boolean $overrideLimits =
false])
-
boolean
$overrideLimits: Should I override set limits?
A method for getting the form from the model.
mixed
getForm
([array $data = array()], [boolean $loadData = true], [boolean $source = null])
-
array
$data: Data for the form.
-
boolean
$loadData: True if the form is to load its own data (default case), false if not.
-
boolean
$source: The name of the form. If not set we'll try the form_name state variable or fall back to default.
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.
string
getHash
()
Returns the currently set ID
integer
getId
()
Returns the list of IDs for batch operations
array
getIds
()
Returns a single item. It uses the id set with setId, or the first ID in the list of IDs for batch operations
FOFTable
&getItem
([
integer $id =
null])
-
integer
$id: Force a primary key ID to the model. Use null to use the id from the state.
Returns a list of items
array
&getItemList
([boolean $overrideLimits = false], [string $group = ''])
-
boolean
$overrideLimits: Should I override set limits?
-
string
$group: The group by clause
Alias for getItemList
array
&getList
([boolean $overrideLimits = false], [string $group = ''])
-
boolean
$overrideLimits: Should I override set limits?
-
string
$group: The group by clause
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
string
getName
()
Creates the WHERE part of the reorder query
string
getReorderWhere
()
Returns the table object after the last save() operation
Get a filtered state variable
mixed
getState
([string $key = null], [mixed $default = null], [string $filter_type = 'raw'])
-
string
$key: The name of the state variable
-
mixed
$default: The default value to use
-
string
$filter_type: Filter type
Method to get a table object, load it if necessary.
FOFTable
getTable
([
string $name =
''], [
string $prefix =
null], [
array $options =
array()])
-
string
$name: The table name. Optional.
-
string
$prefix: The class prefix. Optional.
-
array
$options: Configuration array for model. Optional.
Get the alias set for this model's table
string
getTableAlias
()
Returns a list of the fields of the table associated with this model
array
getTableFields
()
Get the number of all items
integer
getTotal
()
Gets the value of a user state variable.
The
getUserStateFromRequest
(string $key, string $request, [string $default = null], [string $type = 'none'], [boolean $setUserState = true])
-
string
$key: The key of the user state variable.
-
string
$request: The name of the variable passed in a request.
-
string
$default: The default value for the variable if not found. Optional.
-
string
$type: Filter for the variable, for valid values see JFilterInput::clean(). Optional.
-
boolean
$setUserState: Should I save the variable in the user state? Default: true. Optional.
Increments the hit counter
boolean
hit
()
Tells you if the current item is checked out or not
boolean
isCheckedOut
()
Method to get a form object.
mixed
loadForm
(string $name, [string $source = null], [array $options = array()], [boolean $clear = false], [string $xpath = false])
-
string
$name: The name of the form.
-
string
$source: The form source. Can be XML string if file flag is set to false.
-
array
$options: Optional array of options for the form creation.
-
boolean
$clear: Optional argument to force load a new form.
-
string
$xpath: An optional xpath to search for the fields.
Method to get the data that should be injected in the form.
array
loadFormData
()
Moves the current item up or down in the ordering list
boolean
move
(string $dirn)
-
string
$dirn: The direction and magnitude to use (2 means move up by 2 positions, -3 means move down three positions)
This method runs after a record has been copied
-
FOFTable
&$table: The table instance of the record which was copied
This method runs after a record with key value $id is deleted
boolean
onAfterDelete
(integer $id)
-
integer
$id: The id of the record which was deleted
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.
-
FOFTable
&$record: The table instance we fetched
This method runs after a record has been hit
-
FOFTable
&$table: The table instance of the record which was hit
Allows the manipulation after the form is loaded
viod
onAfterLoadForm
(
FOFForm $form,
string &$name,
string &$source,
array &$options)
-
FOFForm
$form: A FOFForm object.
-
string
&$name: The name of the form.
-
string
&$source: The form source. Can be XML string if file flag is set to false.
-
array
&$options: Optional array of options for the form creation.
This method runs after a record has been moved
-
FOFTable
&$table: The table instance of the record which was moved
Allows data and form manipulation after preprocessing the form
viod
onAfterPreprocessForm
(
FOFForm $form,
array &$data)
-
FOFForm
$form: A FOFForm object.
-
array
&$data: The data expected for the form.
This method runs after a record has been published
boolean
onAfterPublish
(
FOFTable &$table)
-
FOFTable
&$table: The table instance of the record which was published
This method runs after a table is reordered
boolean
onAfterReorder
(
FOFTable &$table)
-
FOFTable
&$table: The table instance which was reordered
This method runs after the data is saved to the $table.
-
FOFTable
&$table: The table which was saved
This method runs before a record is copied
-
FOFTable
&$table: The table instance of the record being copied
This method runs before the record with key value of $id is deleted from $table
boolean
onBeforeDelete
(
integer &$id,
FOFTable &$table)
-
integer
&$id: The ID of the record being deleted
-
FOFTable
&$table: The table instance used to delete the record
This method runs before a record is hit
-
FOFTable
&$table: The table instance of the record being hit
Allows the manipulation before the form is loaded
viod
onBeforeLoadForm
(string &$name, string &$source, array &$options)
-
string
&$name: The name of the form.
-
string
&$source: The form source. Can be XML string if file flag is set to false.
-
array
&$options: Optional array of options for the form creation.
This method runs before a record is moved
-
FOFTable
&$table: The table instance of the record being moved
Allows data and form manipulation before preprocessing the form
viod
onBeforePreprocessForm
(
FOFForm $form,
array &$data)
-
FOFForm
$form: A FOFForm object.
-
array
&$data: The data expected for the form.
This method runs before a record is published
boolean
onBeforePublish
(
FOFTable &$table)
-
FOFTable
&$table: The table instance of the record being published
This method runs before a table is reordered
boolean
onBeforeReorder
(
FOFTable &$table)
-
FOFTable
&$table: The table instance being reordered
This method runs before the $data is saved to the $table. Return false to stop saving.
boolean
onBeforeSave
(
array &$data,
FOFTable &$table)
-
array
&$data: The data to save
-
FOFTable
&$table: The table to save the data to
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!
void
onProcessList
(array &$resultArray)
-
array
&$resultArray: An array of objects, each row representing a record
Redefined in descendants as:
Initialises the _savestate variable
void
populateSavestate
([integer $defaultSaveState = -999])
-
integer
$defaultSaveState: The default value for the savestate
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.
void
populateState
()
Method to allow derived classes to preprocess the form.
void
preprocessForm
(
FOFForm $form,
mixed &$data, [
string $group =
'content'])
-
FOFForm
$form: A FOFForm object.
-
mixed
&$data: The data expected for the form.
-
string
$group: The name of the plugin group to import (defaults to "content").
Toggles the published state of one or several items
boolean
publish
([integer $publish = 1], [integer $user = null])
-
integer
$publish: The publishing state to set (e.g. 0 is unpublished)
-
integer
$user: The user ID performing this action
Reorders all items in the table
boolean
reorder
()
Resets the model, like it was freshly loaded
Resets the saved state for this view
Binds the data to the model and tries to save it
boolean
save
(array|object $data)
-
array|object
$data: The source data array or object
Sets the model state auto-save status. By default the model is set up to save its state to the session.
-
boolean
$newState: True to save the state, false to not save it.
Method to set the database driver object
Sets the ID and resets internal data
-
integer
$id: The ID to use
Sets a list of IDs for batch operations from an array and resets the model
-
array
$idlist: An array of item IDs to be set to the model's state
Sets the list of IDs from the request data
Set the internal input field
Method to set model state variables
mixed
setState
(string $property, [mixed $value = null])
-
string
$property: The name of the property.
-
mixed
$value: The value of the property to set or null.
Method to validate the form data.
mixed
validateForm
(
FOFForm $form,
array $data, [
string $group =
null])
-
FOFForm
$form: The form to validate against.
-
array
$data: The data to validate.
-
string
$group: The name of the field group to validate.
Method to load and return a model object.
FOFTable
&_createTable
(
string $name, [
string $prefix =
'Table'], [
array $config =
array()])
-
string
$name: The name of the view
-
string
$prefix: The class prefix. Optional.
-
array
$config: The configuration array to pass to the table
Returns an object list
array
&_getList
(string $query, [integer $limitstart = 0], [integer $limit = 0], [string $group = ''])
-
string
$query: The query
-
integer
$limitstart: Offset from start
-
integer
$limit: The number of records
-
string
$group: The group by clause
Returns a record count for the query
integer
_getListCount
(string $query)
-
string
$query: The query.
Method to get model state variables
object The
_real_getState
([string $property = null], [mixed $default = null])
-
string
$property: Optional parameter name
-
mixed
$default: Optional default value
Magic caller; allows to use the name of model state keys as methods to set their values.
FOFModel
__call
(
string $name,
mixed $arguments)
-
string
$name: The name of the state variable to set
-
mixed
$arguments: The value to set the state variable to
Magic getter; allows to use the name of model state keys as properties
mixed
__get
(string $name)
-
string
$name: The name of the variable to get
Magic setter; allows to use the name of model state keys as properties
void
__set
(string $name, mixed $value)
-
string
$name: The name of the variable
-
mixed
$value: The value to set the variable to
Inherited Methods
Inherited From JObject
JObject::__construct()
JObject::def()
JObject::get()
JObject::getError()
JObject::getErrors()
JObject::getProperties()
JObject::set()
JObject::setError()
JObject::setProperties()
JObject::__toString()