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 JModelAdmin
+ Graphe d'héritage de JModelAdmin:
+ Graphe de collaboration de JModelAdmin:

Liste de tous les membres

Fonctions membres publiques

 __construct ($config=array())
 batch ($commands, $pks, $contexts)
 checkin ($pks=array())
 checkout ($pk=null)
 delete (&$pks)
 getItem ($pk=null)
 publish (&$pks, $value=1)
 reorder ($pks, $delta=0)
 save ($data)
 saveorder ($pks=null, $order=null)
 createTagsHelper ($tagsObserver, $type, $pk, $typeAlias, $table)
 generateTitle ($categoryId, $table)
- Fonctions membres publiques inherited from JModelForm
 getForm ($data=array(), $loadData=true)
 validate ($form, $data, $group=null)
- 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

 batchAccess ($value, $pks, $contexts)
 batchCopy ($value, $pks, $contexts)
 batchLanguage ($value, $pks, $contexts)
 batchMove ($value, $pks, $contexts)
 canDelete ($record)
 canEditState ($record)
 generateNewTitle ($category_id, $alias, $title)
 getReorderConditions ($table)
 populateState ()
 prepareTable ($table)
 checkCategoryId ($categoryId)
- Fonctions membres protégées inherited from JModelForm
 loadForm ($name, $source=null, $options=array(), $clear=false, $xpath=false)
 loadFormData ()
 preprocessData ($context, &$data)
 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())
 cleanCache ($group=null, $client_id=0)

Attributs protégés

 $text_prefix = null
 $event_after_delete = null
 $event_after_save = null
 $event_before_delete = null
 $event_before_save = null
 $event_change_state = null
- Attributs protégés inherited from JModelForm
 $_forms = array()
- 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()

Description détaillée

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


Documentation des constructeurs et destructeur

JModelAdmin::__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 admin.php.

{
if (isset($config['event_after_delete']))
{
$this->event_after_delete = $config['event_after_delete'];
}
elseif (empty($this->event_after_delete))
{
$this->event_after_delete = 'onContentAfterDelete';
}
if (isset($config['event_after_save']))
{
$this->event_after_save = $config['event_after_save'];
}
elseif (empty($this->event_after_save))
{
$this->event_after_save = 'onContentAfterSave';
}
if (isset($config['event_before_delete']))
{
$this->event_before_delete = $config['event_before_delete'];
}
elseif (empty($this->event_before_delete))
{
$this->event_before_delete = 'onContentBeforeDelete';
}
if (isset($config['event_before_save']))
{
$this->event_before_save = $config['event_before_save'];
}
elseif (empty($this->event_before_save))
{
$this->event_before_save = 'onContentBeforeSave';
}
if (isset($config['event_change_state']))
{
$this->event_change_state = $config['event_change_state'];
}
elseif (empty($this->event_change_state))
{
$this->event_change_state = 'onContentChangeState';
}
// Guess the JText message prefix. Defaults to the option.
if (isset($config['text_prefix']))
{
$this->text_prefix = strtoupper($config['text_prefix']);
}
elseif (empty($this->text_prefix))
{
$this->text_prefix = strtoupper($this->option);
}
}

Documentation des fonctions membres

JModelAdmin::batch (   $commands,
  $pks,
  $contexts 
)

Method to perform batch operations on an item or a set of items.

Paramètres:
array$commandsAn array of commands to perform.
array$pksAn array of item ids.
array$contextsAn array of item contexts.
Renvoie:
boolean Returns true on success, false on failure.
Depuis:
12.2

Définition à la ligne 148 du fichier admin.php.

Références JText\_(), JFactory\getUser(), JArrayHelper\getValue(), et JArrayHelper\toInteger().

{
// Sanitize ids.
$pks = array_unique($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
$this->batchSet = true;
if ($this->type == false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
}
if ($this->type === false)
{
$type = new JUcmType;
$this->type = $type->getTypeByAlias($this->typeAlias);
$typeAlias = $this->type->type_alias;
}
else
{
$typeAlias = $this->type->type_alias;
}
$this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags');
if (!empty($commands['category_id']))
{
$cmd = JArrayHelper::getValue($commands, 'move_copy', 'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands['category_id'], $pks, $contexts);
if (is_array($result))
{
$pks = $result;
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands['category_id'], $pks, $contexts))
{
return false;
}
$done = true;
}
if (!empty($commands['assetgroup_id']))
{
if (!$this->batchAccess($commands['assetgroup_id'], $pks, $contexts))
{
return false;
}
$done = true;
}
if (!empty($commands['language_id']))
{
if (!$this->batchLanguage($commands['language_id'], $pks, $contexts))
{
return false;
}
$done = true;
}
if (!empty($commands['tag']))
{
if (!$this->batchTag($commands['tag'], $pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::batchAccess (   $value,
  $pks,
  $contexts 
)
protected

Batch access level changes for a group of rows.

Paramètres:
integer$valueThe new value matching an Asset Group ID.
array$pksAn array of row IDs.
array$contextsAn array of item contexts.
Renvoie:
boolean True if successful, false otherwise and internal error is set.
Depuis:
12.2

Définition à la ligne 273 du fichier admin.php.

Références JText\_(), et JFactory\getUser().

{
if (!$this->batchSet)
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
}
foreach ($pks as $pk)
{
if ($this->user->authorise('core.edit', $contexts[$pk]))
{
$this->table->reset();
$this->table->load($pk);
$this->table->access = (int) $value;
static::createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
if (!$this->table->store())
{
$this->setError($table->getError());
return false;
}
}
else
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::batchCopy (   $value,
  $pks,
  $contexts 
)
protected

Batch copy items to a new category or current.

Paramètres:
integer$valueThe new category.
array$pksAn array of row IDs.
array$contextsAn array of item contexts.
Renvoie:
mixed An array of new IDs on success, boolean false on failure.
Depuis:
12.2

Définition à la ligne 327 du fichier admin.php.

Références JFactory\getUser(), et JText\sprintf().

{
if (!$this->batchSet)
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
}
$i = 0;
$categoryId = $value;
if (!static::checkCategoryId($categoryId))
{
return false;
}
// Parent exists so let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$this->table->reset();
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}
static::generateTitle($categoryId, $this->table);
// Reset the ID because we are making a copy
$this->table->id = 0;
// New category ID
$this->table->catid = $categoryId;
// TODO: Deal with ordering?
// $this->table->ordering = 1;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
static::createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
// Store the row.
if (!$this->table->store())
{
$this->setError($table->getError());
return false;
}
// Get the new item ID
$newId = $this->table->get('id');
// Add the new ID to the array
$newIds[$i] = $newId;
$i++;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::batchLanguage (   $value,
  $pks,
  $contexts 
)
protected

Batch language changes for a group of rows.

Paramètres:
string$valueThe new value matching a language.
array$pksAn array of row IDs.
array$contextsAn array of item contexts.
Renvoie:
boolean True if successful, false otherwise and internal error is set.
Depuis:
11.3

Définition à la ligne 428 du fichier admin.php.

Références JText\_(), et JFactory\getUser().

{
if (!$this->batchSet)
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
}
foreach ($pks as $pk)
{
if ($this->user->authorise('core.edit', $contexts[$pk]))
{
$this->table->reset();
$this->table->load($pk);
$this->table->language = $value;
static::createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
else
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::batchMove (   $value,
  $pks,
  $contexts 
)
protected

Batch move items to a new category

Paramètres:
integer$valueThe new category ID.
array$pksAn array of row IDs.
array$contextsAn array of item contexts.
Renvoie:
boolean True if successful, false otherwise and internal error is set.
Depuis:
12.2

Définition à la ligne 482 du fichier admin.php.

Références JText\_(), JFactory\getUser(), et JText\sprintf().

{
if (!$this->batchSet)
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
}
$categoryId = (int) $value;
if (!static::checkCategoryId($categoryId))
{
return false;
}
// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit', $contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}
// Set the new category ID
$this->table->catid = $categoryId;
// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());
return false;
}
static::createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::canDelete (   $record)
protected

Method to test whether a record can be deleted.

Paramètres:
object$recordA record object.
Renvoie:
boolean True if allowed to delete the record. Defaults to the permission for the component.
Depuis:
12.2

Définition à la ligne 618 du fichier admin.php.

Références JFactory\getUser().

{
$user = JFactory::getUser();
return $user->authorise('core.delete', $this->option);
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::canEditState (   $record)
protected

Method to test whether a record can be deleted.

Paramètres:
object$recordA record object.
Renvoie:
boolean True if allowed to change the state of the record. Defaults to the permission for the component.
Depuis:
12.2

Définition à la ligne 634 du fichier admin.php.

Références JFactory\getUser().

{
$user = JFactory::getUser();
return $user->authorise('core.edit.state', $this->option);
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::checkCategoryId (   $categoryId)
protected

Method to check the validity of the category ID for batch copy and move

Paramètres:
integer$categoryIdThe category ID to check
Renvoie:
boolean
Depuis:
3.2

Définition à la ligne 1242 du fichier admin.php.

Références JText\_(), JFactory\getApplication(), et JTable\getInstance().

{
// Check that the category exists
if ($categoryId)
{
$categoryTable = JTable::getInstance('Category');
if (!$categoryTable->load($categoryId))
{
if ($error = $categoryTable->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'));
return false;
}
}
}
if (empty($categoryId))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'));
return false;
}
// Check that the user has create permission for the component
$extension = JFactory::getApplication()->input->get('option', '');
if (!$this->user->authorise('core.create', $extension . '.category.' . $categoryId))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE'));
return false;
}
return true;
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::checkin (   $pks = array())

Method override to check-in a record or an array of record

Paramètres:
mixed$pksThe ID of the primary key or an array of IDs
Renvoie:
mixed Boolean false if there is an error, otherwise the count of records checked in.
Depuis:
12.2

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

Définition à la ligne 650 du fichier admin.php.

{
$pks = (array) $pks;
$table = $this->getTable();
$count = 0;
if (empty($pks))
{
$pks = array((int) $this->getState($this->getName() . '.id'));
}
// Check in all items.
foreach ($pks as $pk)
{
if ($table->load($pk))
{
if ($table->checked_out > 0)
{
if (!parent::checkin($pk))
{
return false;
}
$count++;
}
}
else
{
$this->setError($table->getError());
return false;
}
}
return $count;
}
JModelAdmin::checkout (   $pk = null)

Method override to check-out a record.

Paramètres:
integer$pkThe ID of the primary key.
Renvoie:
boolean True if successful, false if an error occurs.
Depuis:
12.2

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

Définition à la ligne 696 du fichier admin.php.

{
$pk = (!empty($pk)) ? $pk : (int) $this->getState($this->getName() . '.id');
return parent::checkout($pk);
}
JModelAdmin::createTagsHelper (   $tagsObserver,
  $type,
  $pk,
  $typeAlias,
  $table 
)

Method to creat a tags helper to ensure proper management of tags

Paramètres:
JTableObserverTags$tagsObserverThe tags observer for this table
JUcmType$typeThe type for the table being processed
integer$pkPrimary key of the item bing processed
string$typeAliasThe type alias for this table
JTable$tableThe JTable object
Renvoie:
void
Depuis:
3.2

Définition à la ligne 1223 du fichier admin.php.

{
if (!empty($tagsObserver) && !empty($type))
{
$table->tagsHelper = new JHelperTags();
$table->tagsHelper->typeAlias = $typeAlias;
$table->tagsHelper->tags = explode(',', $table->tagsHelper->getTagIds($pk, $typeAlias));
}
}
JModelAdmin::delete ( $pks)

Method to delete one or more records.

Paramètres:
array&$pksAn array of record primary keys.
Renvoie:
boolean True if successful, false if an error occurs.
Depuis:
12.2

Définition à la ligne 712 du fichier admin.php.

Références JText\_(), JLog\add(), JEventDispatcher\getInstance(), et JLog\WARNING.

{
$pks = (array) $pks;
$table = $this->getTable();
// Include the content plugins for the on delete events.
JPluginHelper::importPlugin('content');
// Iterate the items to delete each one.
foreach ($pks as $i => $pk)
{
if ($table->load($pk))
{
if ($this->canDelete($table))
{
$context = $this->option . '.' . $this->name;
// Trigger the onContentBeforeDelete event.
$result = $dispatcher->trigger($this->event_before_delete, array($context, $table));
if (in_array(false, $result, true))
{
$this->setError($table->getError());
return false;
}
if (!$table->delete($pk))
{
$this->setError($table->getError());
return false;
}
// Trigger the onContentAfterDelete event.
$dispatcher->trigger($this->event_after_delete, array($context, $table));
}
else
{
// Prune items that you can't change.
unset($pks[$i]);
$error = $this->getError();
if ($error)
{
JLog::add($error, JLog::WARNING, 'jerror');
return false;
}
else
{
JLog::add(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), JLog::WARNING, 'jerror');
return false;
}
}
}
else
{
$this->setError($table->getError());
return false;
}
}
// Clear the component's cache
$this->cleanCache();
return true;
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::generateNewTitle (   $category_id,
  $alias,
  $title 
)
protected

Method to change the title & alias.

Paramètres:
integer$category_idThe id of the category.
string$aliasThe alias.
string$titleThe title.
Renvoie:
array Contains the modified title and alias.
Depuis:
12.2

Définition à la ligne 795 du fichier admin.php.

Références JString\increment().

{
// Alter the title & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias, 'catid' => $category_id)))
{
$title = JString::increment($title);
$alias = JString::increment($alias, 'dash');
}
return array($title, $alias);
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::generateTitle (   $categoryId,
  $table 
)

A method to preprocess generating a new title in order to allow tables with alternative names for alias and title to use the batch move and copy methods

Paramètres:
integer$categoryIdThe target category id
JTable$tableThe JTable within which move or copy is taking place
Renvoie:
void
Depuis:
3.2

Définition à la ligne 1296 du fichier admin.php.

{
// Alter the title & alias
$data = $this->generateNewTitle($categoryId, $table->alias, $table->title);
$table->title = $data['0'];
$table->alias = $data['1'];
}
JModelAdmin::getItem (   $pk = null)

Method to get a single record.

Paramètres:
integer$pkThe id of the primary key.
Renvoie:
mixed Object on success, false on failure.
Depuis:
12.2

Définition à la ligne 817 du fichier admin.php.

Références JRegistry\loadString(), et JArrayHelper\toObject().

{
$pk = (!empty($pk)) ? $pk : (int) $this->getState($this->getName() . '.id');
$table = $this->getTable();
if ($pk > 0)
{
// Attempt to load the row.
$return = $table->load($pk);
// Check for a table object error.
if ($return === false && $table->getError())
{
$this->setError($table->getError());
return false;
}
}
// Convert to the JObject before adding other data.
$properties = $table->getProperties(1);
$item = JArrayHelper::toObject($properties, 'JObject');
if (property_exists($item, 'params'))
{
$registry = new JRegistry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
return $item;
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::getReorderConditions (   $table)
protected

A protected method to get a set of ordering conditions.

Paramètres:
JTable$tableA JTable object.
Renvoie:
array An array of conditions to add to ordering queries.
Depuis:
12.2

Définition à la ligne 858 du fichier admin.php.

{
return array();
}
JModelAdmin::populateState ( )
protected

Stock method to auto-populate the model state.

Renvoie:
void
Depuis:
12.2

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

Définition à la ligne 870 du fichier admin.php.

Références JFactory\getApplication().

{
$table = $this->getTable();
$key = $table->getKeyName();
// Get the pk of the record from the request.
$pk = JFactory::getApplication()->input->getInt($key);
$this->setState($this->getName() . '.id', $pk);
// Load the parameters.
$value = JComponentHelper::getParams($this->option);
$this->setState('params', $value);
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::prepareTable (   $table)
protected

Prepare and sanitise the table data prior to saving.

Paramètres:
JTable$tableA reference to a JTable object.
Renvoie:
void
Depuis:
12.2

Définition à la ligne 893 du fichier admin.php.

{
// Derived class will provide its own implementation if required.
}
JModelAdmin::publish ( $pks,
  $value = 1 
)

Method to change the published state of one or more records.

Paramètres:
array&$pksA list of the primary keys to change.
integer$valueThe value of the published state.
Renvoie:
boolean True on success.
Depuis:
12.2

Définition à la ligne 908 du fichier admin.php.

Références JText\_(), JLog\add(), JEventDispatcher\getInstance(), JFactory\getUser(), et JLog\WARNING.

{
$user = JFactory::getUser();
$table = $this->getTable();
$pks = (array) $pks;
// Include the content plugins for the change of state event.
JPluginHelper::importPlugin('content');
// Access checks.
foreach ($pks as $i => $pk)
{
$table->reset();
if ($table->load($pk))
{
if (!$this->canEditState($table))
{
// Prune items that you can't change.
unset($pks[$i]);
JLog::add(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), JLog::WARNING, 'jerror');
return false;
}
}
}
// Attempt to change the state of the records.
if (!$table->publish($pks, $value, $user->get('id')))
{
$this->setError($table->getError());
return false;
}
$context = $this->option . '.' . $this->name;
// Trigger the onContentChangeState event.
$result = $dispatcher->trigger($this->event_change_state, array($context, $pks, $value));
if (in_array(false, $result, true))
{
$this->setError($table->getError());
return false;
}
// Clear the component's cache
$this->cleanCache();
return true;
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::reorder (   $pks,
  $delta = 0 
)

Method to adjust the ordering of a row.

Returns NULL if the user did not have edit privileges for any of the selected primary keys.

Paramètres:
integer$pksThe ID of the primary key to move.
integer$deltaIncrement, usually +1 or -1
Renvoie:
mixed False on failure or error, true on success, null if the $pk is empty (no items selected).
Depuis:
12.2

Définition à la ligne 975 du fichier admin.php.

Références JText\_(), JLog\add(), et JLog\WARNING.

{
$table = $this->getTable();
$pks = (array) $pks;
$result = true;
$allowed = true;
foreach ($pks as $i => $pk)
{
$table->reset();
if ($table->load($pk) && $this->checkout($pk))
{
// Access checks.
if (!$this->canEditState($table))
{
// Prune items that you can't change.
unset($pks[$i]);
$this->checkin($pk);
JLog::add(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), JLog::WARNING, 'jerror');
$allowed = false;
continue;
}
$where = $this->getReorderConditions($table);
if (!$table->move($delta, $where))
{
$this->setError($table->getError());
unset($pks[$i]);
$result = false;
}
$this->checkin($pk);
}
else
{
$this->setError($table->getError());
unset($pks[$i]);
$result = false;
}
}
if ($allowed === false && empty($pks))
{
$result = null;
}
// Clear the component's cache
if ($result == true)
{
$this->cleanCache();
}
return $result;
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::save (   $data)

Method to save the form data.

Paramètres:
array$dataThe form data.
Renvoie:
boolean True on success, False on error.
Depuis:
12.2

Définition à la ligne 1042 du fichier admin.php.

Références JEventDispatcher\getInstance().

{
$table = $this->getTable();
if ((!empty($data['tags']) && $data['tags'][0] != ''))
{
$table->newTags = $data['tags'];
}
$key = $table->getKeyName();
$pk = (!empty($data[$key])) ? $data[$key] : (int) $this->getState($this->getName() . '.id');
$isNew = true;
// Include the content plugins for the on save events.
JPluginHelper::importPlugin('content');
// Allow an exception to be thrown.
try
{
// Load the row if saving an existing record.
if ($pk > 0)
{
$table->load($pk);
$isNew = false;
}
// Bind the data.
if (!$table->bind($data))
{
$this->setError($table->getError());
return false;
}
// Prepare the row for saving
$this->prepareTable($table);
// Check the data.
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Trigger the onContentBeforeSave event.
$result = $dispatcher->trigger($this->event_before_save, array($this->option . '.' . $this->name, $table, $isNew));
if (in_array(false, $result, true))
{
$this->setError($table->getError());
return false;
}
// Store the data.
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
// Clean the cache.
$this->cleanCache();
// Trigger the onContentAfterSave event.
$dispatcher->trigger($this->event_after_save, array($this->option . '.' . $this->name, $table, $isNew));
}
catch (Exception $e)
{
$this->setError($e->getMessage());
return false;
}
$pkName = $table->getKeyName();
if (isset($table->$pkName))
{
$this->setState($this->getName() . '.id', $table->$pkName);
}
$this->setState($this->getName() . '.new', $isNew);
return true;
}

+ Voici le graphe d'appel pour cette fonction :

JModelAdmin::saveorder (   $pks = null,
  $order = null 
)

Saves the manually set order of records.

Paramètres:
array$pksAn array of primary key ids.
integer$order+1 or -1
Renvoie:
mixed
Depuis:
12.2

Définition à la ligne 1137 du fichier admin.php.

Références JText\_(), JLog\add(), JError\raiseWarning(), et JLog\WARNING.

{
$table = $this->getTable();
$tableClassName = get_class($table);
$contentType = new JUcmType;
$type = $contentType->getTypeByTable($tableClassName);
$typeAlias = $type->type_alias;
$tagsObserver = $table->getObserverOfClass('JTableObserverTags');
$conditions = array();
if (empty($pks))
{
return JError::raiseWarning(500, JText::_($this->text_prefix . '_ERROR_NO_ITEMS_SELECTED'));
}
// Update ordering values
foreach ($pks as $i => $pk)
{
$table->load((int) $pk);
// Access checks.
if (!$this->canEditState($table))
{
// Prune items that you can't change.
unset($pks[$i]);
JLog::add(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), JLog::WARNING, 'jerror');
}
elseif ($table->ordering != $order[$i])
{
$table->ordering = $order[$i];
$this->createTagsHelper($tagsObserver, $type, $pk, $typeAlias, $table);
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
// Remember to reorder within position and client_id
$condition = $this->getReorderConditions($table);
$found = false;
foreach ($conditions as $cond)
{
if ($cond[1] == $condition)
{
$found = true;
break;
}
}
if (!$found)
{
$key = $table->getKeyName();
$conditions[] = array($table->$key, $condition);
}
}
}
// Execute reorder for each category.
foreach ($conditions as $cond)
{
$table->load($cond[0]);
$table->reorder($cond[1]);
}
// Clear the component's cache
$this->cleanCache();
return true;
}

+ Voici le graphe d'appel pour cette fonction :


Documentation des données membres

JModelAdmin::$event_after_delete = null
protected

Définition à la ligne 35 du fichier admin.php.

JModelAdmin::$event_after_save = null
protected

Définition à la ligne 43 du fichier admin.php.

JModelAdmin::$event_before_delete = null
protected

Définition à la ligne 51 du fichier admin.php.

JModelAdmin::$event_before_save = null
protected

Définition à la ligne 59 du fichier admin.php.

JModelAdmin::$event_change_state = null
protected

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

JModelAdmin::$text_prefix = null
protected

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


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