Source for file maps.php
Documentation is available at maps.php
* @package Joomla.Administrator
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Maps model for the Finder package.
* @package Joomla.Administrator
* @param array $config An associative array of configuration settings. [optional]
if (empty($config['filter_fields']))
$config['filter_fields'] =
array(
* Method to test whether a record can be deleted.
* @param object $record A record object.
* @return boolean True if allowed to delete the record. Defaults to the permission for the component.
return $user->authorise('core.delete', $this->option);
* Method to test whether a record can be deleted.
* @param object $record A record object.
* @return boolean True if allowed to change the state of the record. Defaults to the permission for the component.
return $user->authorise('core.edit.state', $this->option);
* Method to delete one or more records.
* @param array &$pks An array of record primary keys.
* @return boolean True if successful, false if an error occurs.
// Include the content plugins for the on delete events.
// Iterate the items to delete each one.
foreach ($pks as $i =>
$pk)
// Trigger the onContentBeforeDelete event.
$result =
$dispatcher->trigger('onContentBeforeDelete', array($context, $table));
if (!$table->delete($pk))
// Trigger the onContentAfterDelete event.
$dispatcher->trigger('onContentAfterDelete', array($context, $table));
// Prune items that you can't change.
$this->setError(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'));
// Clear the component's cache
* Build an SQL query to load the list data.
* @return JDatabaseQuery A JDatabaseQuery object
$query =
$db->getQuery(true);
// Select all fields from the table.
->from($db->quoteName('#__finder_taxonomy') .
' AS a');
// Self-join to get children.
$query->select('COUNT(b.id) AS num_children')
->join('LEFT', $db->quoteName('#__finder_taxonomy') .
' AS b ON b.parent_id=a.id');
// Join to get the map links
$query->select('COUNT(c.node_id) AS num_nodes')
->join('LEFT', $db->quoteName('#__finder_taxonomy_map') .
' AS c ON c.node_id=a.id')
->group('a.id, a.parent_id, a.title, a.state, a.access, a.ordering');
// If the model is set to check item state, add to the query.
$query->where('a.state = ' . (int)
$this->getState('filter.state'));
// Filter the maps over the branch if set.
$branch_id =
$this->getState('filter.branch');
$query->where('a.parent_id = ' . (int)
$branch_id);
// Filter the maps over the search string if set.
$search =
$this->getState('filter.search');
$query->where('a.title LIKE ' .
$db->quote('%' .
$search .
'%'));
// Handle the list ordering.
$ordering =
$this->getState('list.ordering');
$direction =
$this->getState('list.direction');
$query->order($db->escape($ordering) .
' ' .
$db->escape($direction));
* Method to get a store id based on 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
* @param string $id A prefix for the store id. [optional]
* @return string A store id.
$id .=
':' .
$this->getState('filter.state');
$id .=
':' .
$this->getState('filter.search');
$id .=
':' .
$this->getState('filter.branch');
* Returns a JTable object, always creating it.
* @param string $type The table type to instantiate. [optional]
* @param string $prefix A prefix for the table class name. [optional]
* @param array $config Configuration array for model. [optional]
* @return JTable A database object
public function getTable($type =
'Map', $prefix =
'FinderTable', $config =
array())
* Method to auto-populate the model state. Calling getState in this method will result in recursion.
* @param string $ordering An optional ordering field. [optional]
* @param string $direction An optional direction. [optional]
protected function populateState($ordering =
null, $direction =
null)
// Load the filter state.
$this->setState('filter.search', $search);
$this->setState('filter.state', $state);
$this->setState('filter.branch', $branch);
// List state information.
* Method to change the published state of one or more records.
* @param array &$pks A list of the primary keys to change.
* @param integer $value The value of the published state. [optional]
* @return boolean True on success.
public function publish(&$pks, $value =
1)
// Include the content plugins for the change of state event.
foreach ($pks as $i =>
$pk)
// Prune items that you can't change.
$this->setError(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
// Attempt to change the state of the records.
if (!$table->publish($pks, $value, $user->get('id')))
// Trigger the onContentChangeState event.
$result =
$dispatcher->trigger('onContentChangeState', array($context, $pks, $value));
// Clear the component's cache
* Method to purge all maps from the taxonomy.
* @return boolean Returns true on success, false on failure.
$query =
$db->getQuery(true)
->delete($db->quoteName('#__finder_taxonomy'))
->where($db->quoteName('parent_id') .
' > 1');
->delete($db->quoteName('#__finder_taxonomy_map'))
Documentation generated on Tue, 19 Nov 2013 15:07:39 +0100 by phpDocumentor 1.4.3