Source for file index.php
Documentation is available at index.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
* Index model class for Finder.
* @package Joomla.Administrator
* The event to trigger after deleting the data.
* The event to trigger before deleting the data.
* @param array $config An associative array of configuration settings. [optional]
if (empty($config['filter_fields']))
$config['filter_fields'] =
array(
'published', 'l.published',
'indexdate', 'l.indexdate'
* 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.
if (!$table->delete($pk))
// Trigger the onContentAfterDelete event.
// 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('t.title AS t_title')
->from($db->quoteName('#__finder_links') .
' AS l')
->join('INNER', $db->quoteName('#__finder_types') .
' AS t ON t.id = l.type_id');
// Check the type filter.
$query->where('l.type_id = ' . (int)
$this->getState('filter.type'));
// Check for state filter.
$query->where('l.published = ' . (int)
$this->getState('filter.state'));
// Check the search phrase.
if ($this->getState('filter.search') !=
'')
$search =
$db->escape($this->getState('filter.search'));
'l.title LIKE ' .
$db->quote('%' .
$db->escape($search) .
'%') .
' OR l.url LIKE ' .
$db->quote('%' .
$db->escape($search) .
'%')
.
' OR l.indexdate LIKE ' .
$db->quote('%' .
$db->escape($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 the state of the Smart Search plug-ins.
* @return array Array of relevant plug-ins and whether they are enabled or not.
$query =
$db->getQuery(true)
->select('name, enabled')
->from($db->quoteName('#__extensions'))
->where($db->quoteName('type') .
' = ' .
$db->quote('plugin'))
->where($db->quoteName('folder') .
' IN(' .
$db->quote('system') .
',' .
$db->quote('content') .
')')
->where($db->quoteName('element') .
' = ' .
$db->quote('finder'));
$plugins =
$db->loadObjectList('name');
* 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.search');
$id .=
':' .
$this->getState('filter.state');
$id .=
':' .
$this->getState('filter.type');
* 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 =
'Link', $prefix =
'FinderTable', $config =
array())
* Method to purge the index, deleting all links.
* @return boolean True on success, false on failure.
* @throws Exception on database error
// Truncate the links table.
$db->truncateTable('#__finder_links');
// Truncate the links terms tables.
for ($i =
0; $i <=
15; $i++
)
// Get the mapping table suffix.
$db->truncateTable('#__finder_links_terms' .
$suffix);
// Truncate the terms table.
$db->truncateTable('#__finder_terms');
// Truncate the taxonomy map table.
$db->truncateTable('#__finder_taxonomy_map');
// Delete all the taxonomy nodes except the root.
$query =
$db->getQuery(true)
->delete($db->quoteName('#__finder_taxonomy'))
->where($db->quoteName('id') .
' > 1');
// Truncate the tokens tables.
$db->truncateTable('#__finder_tokens');
// Truncate the tokens aggregate table.
$db->truncateTable('#__finder_tokens_aggregate');
* 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);
// 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
Documentation generated on Tue, 19 Nov 2013 15:05:22 +0100 by phpDocumentor 1.4.3