Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JModelList
+ Graphe d'héritage de JModelList:
+ Graphe de collaboration de JModelList:

Liste de tous les membres

Fonctions membres publiques

 __construct ($config=array())
 getActiveFilters ()
 getItems ()
 getPagination ()
 getTotal ()
 getStart ()
 getFilterForm ($data=array(), $loadData=true)
 getUserStateFromRequest ($key, $request, $default=null, $type= 'none', $resetPage=true)
- Fonctions membres publiques inherited from JModelLegacy
 getDbo ()
 getName ()
 getState ($property=null, $default=null)
 getTable ($name= '', $prefix= 'Table', $options=array())
 loadHistory ($version_id, JTable &$table)
 setDbo ($db)
 setState ($property, $value=null)
- Fonctions membres publiques inherited from JObject
 __toString ()
 def ($property, $default=null)
 get ($property, $default=null)
 getProperties ($public=true)
 getError ($i=null, $toString=true)
 getErrors ()
 set ($property, $value=null)
 setProperties ($properties)
 setError ($error)

Fonctions membres protégées

 _getListQuery ()
 getListQuery ()
 getStoreId ($id= '')
 loadForm ($name, $source=null, $options=array(), $clear=false, $xpath=false)
 loadFormData ()
 populateState ($ordering=null, $direction=null)
 preprocessForm (JForm $form, $data, $group= 'content')
- Fonctions membres protégées inherited from JModelLegacy
 _getList ($query, $limitstart=0, $limit=0)
 _getListCount ($query)
 _createTable ($name, $prefix= 'Table', $config=array())
 populateState ()
 cleanCache ($group=null, $client_id=0)

Attributs protégés

 $cache = array()
 $context = null
 $filter_fields = array()
 $query = array()
 $filterFormName = null
 $htmlFormName = 'adminForm'
- Attributs protégés inherited from JModelLegacy
 $__state_set = null
 $_db
 $name
 $option = null
 $state
 $event_clean_cache = null
- Attributs protégés inherited from JObject
 $_errors = array()

Additional Inherited Members

- Fonctions membres publiques statiques inherited from JModelLegacy
static addIncludePath ($path= '', $prefix= '')
static addTablePath ($path)
static getInstance ($type, $prefix= '', $config=array())
- Fonctions membres protégées statiques inherited from JModelLegacy
static _createFileName ($type, $parts=array())

Description détaillée

Définition à la ligne 19 du fichier list.php.


Documentation des constructeurs et destructeur

JModelList::__construct (   $config = array())

Constructor.

Paramètres:
array$configAn optional associative array of configuration settings.
Voir également:
JModelLegacy
Depuis:
12.2

Réimplémentée à partir de JModelLegacy.

Définition à la ligne 77 du fichier list.php.

{
// Add the ordering filtering fields white list.
if (isset($config['filter_fields']))
{
$this->filter_fields = $config['filter_fields'];
}
// Guess the context as Option.ModelName.
if (empty($this->context))
{
$this->context = strtolower($this->option . '.' . $this->getName());
}
}

Documentation des fonctions membres

JModelList::_getListQuery ( )
protected

Method to cache the last query constructed.

This method ensures that the query is constructed only once for a given state of the model.

Renvoie:
JDatabaseQuery A JDatabaseQuery object
Depuis:
12.2

Définition à la ligne 103 du fichier list.php.

{
// Capture the last store id used.
static $lastStoreId;
// Compute the current store id.
$currentStoreId = $this->getStoreId();
// If the last store id is different from the current, refresh the query.
if ($lastStoreId != $currentStoreId || empty($this->query))
{
$lastStoreId = $currentStoreId;
$this->query = $this->getListQuery();
}
return $this->query;
}
JModelList::getActiveFilters ( )

Function to get the active filters

Renvoie:
array Associative array in the format: array('filter_published' => 0)
Depuis:
3.2

Définition à la ligne 128 du fichier list.php.

{
$activeFilters = array();
if (!empty($this->filter_fields))
{
foreach ($this->filter_fields as $filter)
{
$filterName = 'filter.' . $filter;
if (property_exists($this->state, $filterName) && (!empty($this->state->{$filterName}) || is_numeric($this->state->{$filterName})))
{
$activeFilters[$filter] = $this->state->get($filterName);
}
}
}
return $activeFilters;
}
JModelList::getFilterForm (   $data = array(),
  $loadData = true 
)

Get the filter form

Paramètres:
array$datadata
boolean$loadDataload current data
Renvoie:
JForm/false the JForm object or false
Depuis:
3.2

Définition à la ligne 333 du fichier list.php.

{
$form = null;
// Try to locate the filter form automatically. Example: ContentModelArticles => "filter_articles"
if (empty($this->filterFormName))
{
$classNameParts = explode('Model', get_called_class());
if (count($classNameParts) == 2)
{
$this->filterFormName = 'filter_' . strtolower($classNameParts[1]);
}
}
if (!empty($this->filterFormName))
{
// Get the form.
$form = $this->loadForm($this->context . '.filter', $this->filterFormName, array('control' => '', 'load_data' => $loadData));
}
return $form;
}
JModelList::getItems ( )

Method to get an array of data items.

Renvoie:
mixed An array of data items on success, false on failure.
Depuis:
12.2

Définition à la ligne 155 du fichier list.php.

{
// Get a storage key.
$store = $this->getStoreId();
// Try to load the data from internal storage.
if (isset($this->cache[$store]))
{
return $this->cache[$store];
}
// Load the list items.
$query = $this->_getListQuery();
try
{
$items = $this->_getList($query, $this->getStart(), $this->getState('list.limit'));
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Add the items to the internal cache.
$this->cache[$store] = $items;
return $this->cache[$store];
}
JModelList::getListQuery ( )
protected

Method to get a JDatabaseQuery object for retrieving the data set from a database.

Renvoie:
JDatabaseQuery A JDatabaseQuery object to retrieve the data set.
Depuis:
12.2

Définition à la ligne 193 du fichier list.php.

{
$db = $this->getDbo();
$query = $db->getQuery(true);
return $query;
}
JModelList::getPagination ( )

Method to get a JPagination object for the data set.

Renvoie:
JPagination A JPagination object for the data set.
Depuis:
12.2

Définition à la ligne 208 du fichier list.php.

{
// Get a storage key.
$store = $this->getStoreId('getPagination');
// Try to load the data from internal storage.
if (isset($this->cache[$store]))
{
return $this->cache[$store];
}
// Create the pagination object.
$limit = (int) $this->getState('list.limit') - (int) $this->getState('list.links');
$page = new JPagination($this->getTotal(), $this->getStart(), $limit);
// Add the object to the internal cache.
$this->cache[$store] = $page;
return $this->cache[$store];
}
JModelList::getStart ( )

Method to get the starting number of items for the data set.

Renvoie:
integer The starting number of items available in the data set.
Depuis:
12.2

Définition à la ligne 298 du fichier list.php.

{
$store = $this->getStoreId('getstart');
// Try to load the data from internal storage.
if (isset($this->cache[$store]))
{
return $this->cache[$store];
}
$start = $this->getState('list.start');
$limit = $this->getState('list.limit');
$total = $this->getTotal();
if ($start > $total - $limit)
{
$start = max(0, (int) (ceil($total / $limit) - 1) * $limit);
}
// Add the total to the internal cache.
$this->cache[$store] = $start;
return $this->cache[$store];
}
JModelList::getStoreId (   $id = '')
protected

Method to get a store id based on the model configuration state.

This is necessary because the model is used by the component and different modules that might need different sets of data or different ordering requirements.

Paramètres:
string$idAn identifier string to generate the store id.
Renvoie:
string A store id.
Depuis:
12.2

Définition à la ligne 242 du fichier list.php.

{
// Add the list state to the store id.
$id .= ':' . $this->getState('list.start');
$id .= ':' . $this->getState('list.limit');
$id .= ':' . $this->getState('list.ordering');
$id .= ':' . $this->getState('list.direction');
return md5($this->context . ':' . $id);
}
JModelList::getTotal ( )

Method to get the total number of items for the data set.

Renvoie:
integer The total number of items available in the data set.
Depuis:
12.2

Définition à la ligne 260 du fichier list.php.

{
// Get a storage key.
$store = $this->getStoreId('getTotal');
// Try to load the data from internal storage.
if (isset($this->cache[$store]))
{
return $this->cache[$store];
}
// Load the total.
$query = $this->_getListQuery();
try
{
$total = (int) $this->_getListCount($query);
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Add the total to the internal cache.
$this->cache[$store] = $total;
return $this->cache[$store];
}
JModelList::getUserStateFromRequest (   $key,
  $request,
  $default = null,
  $type = 'none',
  $resetPage = true 
)

Gets the value of a user state variable and sets it in the session

This is the same as the method in JApplication except that this also can optionally force you back to the first page when a filter has changed

Paramètres:
string$keyThe key of the user state variable.
string$requestThe name of the variable passed in a request.
string$defaultThe default value for the variable if not found. Optional.
string$typeFilter for the variable, for valid values see JFilterInput::clean(). Optional.
boolean$resetPageIf true, the limitstart in request is set to zero
Renvoie:
The request user state.
Depuis:
12.2

Définition à la ligne 641 du fichier list.php.

Références JFactory\getApplication().

{
$input = $app->input;
$old_state = $app->getUserState($key);
$cur_state = (!is_null($old_state)) ? $old_state : $default;
$new_state = $input->get($request, null, $type);
if (($cur_state != $new_state) && ($resetPage))
{
$input->set('limitstart', 0);
}
// Save the new value only if it is set in this request.
if ($new_state !== null)
{
$app->setUserState($key, $new_state);
}
else
{
$new_state = $cur_state;
}
return $new_state;
}

+ Voici le graphe d'appel pour cette fonction :

JModelList::loadForm (   $name,
  $source = null,
  $options = array(),
  $clear = false,
  $xpath = false 
)
protected

Method to get a form object.

Paramètres:
string$nameThe name of the form.
string$sourceThe form source. Can be XML string if file flag is set to false.
array$optionsOptional array of options for the form creation.
boolean$clearOptional argument to force load a new form.
string$xpathAn optional xpath to search for the fields.
Renvoie:
mixed JForm object on success, False on error.
Voir également:
JForm
Depuis:
3.2

Définition à la ligne 371 du fichier list.php.

Références JForm\addFieldPath(), JForm\addFormPath(), JForm\getInstance(), et JArrayHelper\getValue().

{
// Handle the optional arguments.
$options['control'] = JArrayHelper::getValue($options, 'control', false);
// Create a signature hash.
$hash = md5($source . serialize($options));
// Check if we can use a previously loaded form.
if (isset($this->_forms[$hash]) && !$clear)
{
return $this->_forms[$hash];
}
// Get the form.
JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
try
{
$form = JForm::getInstance($name, $source, $options, false, $xpath);
if (isset($options['load_data']) && $options['load_data'])
{
// Get the data for the form.
$data = $this->loadFormData();
}
else
{
$data = array();
}
// Allow for additional modification of the form, and events to be triggered.
// We pass the data because plugins may require it.
$this->preprocessForm($form, $data);
// Load the data into the form after the plugins have operated.
$form->bind($data);
}
catch (Exception $e)
{
$this->setError($e->getMessage());
return false;
}
// Store the form for later.
$this->_forms[$hash] = $form;
return $form;
}

+ Voici le graphe d'appel pour cette fonction :

JModelList::loadFormData ( )
protected

Method to get the data that should be injected in the form.

Renvoie:
mixed The data for the form.
Depuis:
3.2

Définition à la ligne 430 du fichier list.php.

Références JFactory\getApplication().

{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState($this->context, new stdClass);
// Pre-fill the list options
if (!property_exists($data, 'list'))
{
$data->list = array(
'direction' => $this->state->{'list.direction'},
'limit' => $this->state->{'list.limit'},
'ordering' => $this->state->{'list.ordering'},
'start' => $this->state->{'list.start'}
);
}
return $data;
}

+ Voici le graphe d'appel pour cette fonction :

JModelList::populateState (   $ordering = null,
  $direction = null 
)
protected

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.

Note. Calling getState in this method will result in recursion.

Paramètres:
string$orderingAn optional ordering field.
string$directionAn optional direction (asc|desc).
Renvoie:
void
Depuis:
12.2

Définition à la ligne 465 du fichier list.php.

Références JFactory\getApplication().

{
// If the context is set, assume that stateful lists are used.
if ($this->context)
{
// Receive & set filters
if ($filters = $app->getUserStateFromRequest($this->context . '.filter', 'filter', array(), 'array'))
{
foreach ($filters as $name => $value)
{
$this->setState('filter.' . $name, $value);
}
}
$limit = 0;
// Receive & set list options
if ($list = $app->getUserStateFromRequest($this->context . '.list', 'list', array(), 'array'))
{
foreach ($list as $name => $value)
{
// Extra validations
switch ($name)
{
case 'fullordering':
$orderingParts = explode(' ', $value);
if (count($orderingParts) >= 2)
{
// Latest part will be considered the direction
$fullDirection = end($orderingParts);
if (in_array(strtoupper($fullDirection), array('ASC', 'DESC', '')))
{
$this->setState('list.direction', $fullDirection);
}
unset($orderingParts[count($orderingParts) - 1]);
// The rest will be the ordering
$fullOrdering = implode(' ', $orderingParts);
if (in_array($fullOrdering, $this->filter_fields))
{
$this->setState('list.ordering', $fullOrdering);
}
}
else
{
$this->setState('list.ordering', $ordering);
$this->setState('list.direction', $direction);
}
break;
case 'ordering':
if (!in_array($value, $this->filter_fields))
{
$value = $ordering;
}
break;
case 'direction':
if (!in_array(strtoupper($value), array('ASC', 'DESC', '')))
{
$value = $direction;
}
break;
case 'limit':
$limit = $value;
break;
// Just to keep the default case
default:
$value = $value;
break;
}
$this->setState('list.' . $name, $value);
}
}
else
// Keep B/C for components previous to jform forms for filters
{
// Pre-fill the limits
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'uint');
$this->setState('list.limit', $limit);
// Check if the ordering field is in the white list, otherwise use the incoming value.
$value = $app->getUserStateFromRequest($this->context . '.ordercol', 'filter_order', $ordering);
if (!in_array($value, $this->filter_fields))
{
$value = $ordering;
$app->setUserState($this->context . '.ordercol', $value);
}
$this->setState('list.ordering', $value);
// Check if the ordering direction is valid, otherwise use the incoming value.
$value = $app->getUserStateFromRequest($this->context . '.orderdirn', 'filter_order_Dir', $direction);
if (!in_array(strtoupper($value), array('ASC', 'DESC', '')))
{
$value = $direction;
$app->setUserState($this->context . '.orderdirn', $value);
}
$this->setState('list.direction', $value);
}
$value = $app->getUserStateFromRequest($this->context . '.limitstart', 'limitstart', 0);
$limitstart = ($limit != 0 ? (floor($value / $limit) * $limit) : 0);
$this->setState('list.start', $limitstart);
}
else
{
$this->setState('list.start', 0);
$this->setState('list.limit', 0);
}
}

+ Voici le graphe d'appel pour cette fonction :

JModelList::preprocessForm ( JForm  $form,
  $data,
  $group = 'content' 
)
protected

Method to allow derived classes to preprocess the form.

Paramètres:
JForm$formA JForm object.
mixed$dataThe data expected for the form.
string$groupThe name of the plugin group to import (defaults to "content").
Renvoie:
void
Depuis:
3.2
Exceptions:
Exceptionif there is an error in the form event.

Définition à la ligne 601 du fichier list.php.

Références JEventDispatcher\getInstance().

{
// Import the appropriate plugin group.
JPluginHelper::importPlugin($group);
// Get the dispatcher.
$dispatcher = JDispatcher::getInstance();
// Trigger the form preparation event.
$results = $dispatcher->trigger('onContentPrepareForm', array($form, $data));
// Check for errors encountered while preparing the form.
if (count($results) && in_array(false, $results, true))
{
// Get the last error.
$error = $dispatcher->getError();
if (!($error instanceof Exception))
{
throw new Exception($error);
}
}
}

+ Voici le graphe d'appel pour cette fonction :


Documentation des données membres

JModelList::$cache = array()
protected

Définition à la ligne 27 du fichier list.php.

JModelList::$context = null
protected

Définition à la ligne 36 du fichier list.php.

JModelList::$filter_fields = array()
protected

Définition à la ligne 44 du fichier list.php.

JModelList::$filterFormName = null
protected

Définition à la ligne 60 du fichier list.php.

JModelList::$htmlFormName = 'adminForm'
protected

Définition à la ligne 67 du fichier list.php.

JModelList::$query = array()
protected

Définition à la ligne 52 du fichier list.php.


La documentation de cette classe a été générée à partir du fichier suivant :