Source for file discover.php
Documentation is available at discover.php
* @package Joomla.Administrator
* @subpackage com_installer
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
require_once __DIR__ .
'/extension.php';
* Installer Discover Model
* @package Joomla.Administrator
* @subpackage com_installer
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
protected function populateState($ordering =
null, $direction =
null)
// Load the filter state.
$this->setState('filter.search', $search);
$this->setState('filter.client_id', $clientId);
$this->setState('filter.type', $categoryId);
$this->setState('filter.group', $group);
$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message', '');
parent::populateState('name', 'asc');
* Method to get the database query.
* @return JDatabaseQuery the database query
$client =
$this->getState('filter.client_id');
$group =
$this->getState('filter.group');
$query->where('type=' .
$this->_db->quote($type));
$query->where('client_id=' . (int)
$client);
if ($group !=
'' &&
in_array($type, array('plugin', 'library', '')))
$query->where('folder=' .
$this->_db->quote($group ==
'*' ?
'' :
$group));
// Filter by search in id
$search =
$this->getState('filter.search');
if (!empty($search) &&
stripos($search, 'id:') ===
0)
$query->where('extension_id = ' . (int)
substr($search, 3));
* Finds uninstalled extensions
// Purge the list of discovered extensions
$results =
$installer->discover();
// Get all templates, including discovered ones
$query =
$db->getQuery(true)
->select('extension_id, element, folder, client_id, type')
$installedtmp =
$db->loadObjectList();
foreach ($installedtmp as $install)
$key =
implode(':', array($install->type, $install->element, $install->folder, $install->client_id));
$extensions[$key] =
$install;
foreach ($results as $result)
// Check if we have a match on the element
$key =
implode(':', array($result->type, $result->element, $result->folder, $result->client_id));
* Installs a discovered extension.
$result =
$installer->discover_install($id);
$app->enqueueMessage(JText::_('COM_INSTALLER_MSG_DISCOVER_INSTALLFAILED') .
': ' .
$id);
$this->setState('name', $installer->get('name'));
$app->setUserState('com_installer.message', $installer->message);
$app->setUserState('com_installer.extension_message', $installer->get('extension_message'));
$app->enqueueMessage(JText::_('COM_INSTALLER_MSG_DISCOVER_INSTALLSUCCESSFUL'));
$app->enqueueMessage(JText::_('COM_INSTALLER_MSG_DISCOVER_NOEXTENSIONSELECTED'));
* Cleans out the list of discovered extensions.
* @return bool True on success
$query =
$db->getQuery(true)
->delete('#__extensions')
$this->_message =
JText::_('COM_INSTALLER_MSG_DISCOVER_PURGEDDISCOVEREDEXTENSIONS');
$this->_message =
JText::_('COM_INSTALLER_MSG_DISCOVER_FAILEDTOPURGEEXTENSIONS');
Documentation generated on Tue, 19 Nov 2013 15:01:31 +0100 by phpDocumentor 1.4.3