Source for file joomla.php
Documentation is available at joomla.php
* @subpackage Extension.Joomla
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Joomla! master extension plugin.
* @subpackage Extension.Joomla
* @var integer Extension Identifier
* @var JInstaller Installer object
private $installer =
null;
* Load the language file on instantiation.
* Adds an update site to the table if it doesn't exist.
* @param string $name The friendly name of the site
* @param string $type The type of site (e.g. collection or extension)
* @param string $location The URI for the site
* @param boolean $enabled If this site is enabled
private function addUpdateSite($name, $type, $location, $enabled)
// Look if the location is used already; doesn't matter what type you can't have two types at the same address, doesn't make sense
$query =
$db->getQuery(true)
->select('update_site_id')
->from('#__update_sites')
->where('location = ' .
$db->quote($location));
$update_site_id = (int)
$db->loadResult();
// If it doesn't exist, add it!
->insert('#__update_sites')
->columns(array($db->quoteName('name'), $db->quoteName('type'), $db->quoteName('location'), $db->quoteName('enabled')))
->values($db->quote($name) .
', ' .
$db->quote($type) .
', ' .
$db->quote($location) .
', ' . (int)
$enabled);
// Link up this extension to the update site
$update_site_id =
$db->insertid();
// Check if it has an update site id (creation might have faileD)
// Look for an update site entry that exists
->select('update_site_id')
->from('#__update_sites_extensions')
->where('update_site_id = ' .
$update_site_id)
->where('extension_id = ' .
$this->eid);
$tmpid = (int)
$db->loadResult();
// Link this extension to the relevant update site
->insert('#__update_sites_extensions')
->columns(array($db->quoteName('update_site_id'), $db->quoteName('extension_id')))
->values($update_site_id .
', ' .
$this->eid);
* Handle post extension install update sites
* @param JInstaller $installer Installer object
* @param integer $eid Extension Identifier
$this->installer =
$installer;
// After an install we only need to do update sites
$this->processUpdateSites();
* Handle extension uninstall
* @param JInstaller $installer Installer instance
* @param integer $eid Extension id
* @param integer $result Installation result
// Wipe out any update_sites_extensions links
$query =
$db->getQuery(true)
->delete('#__update_sites_extensions')
->where('extension_id = ' .
$eid);
// Delete any unused update sites
->select('update_site_id')
->from('#__update_sites_extensions');
$results =
$db->loadColumn();
// So we need to delete the update sites and their associated updates
$updatesite_delete =
$db->getQuery(true);
$updatesite_delete->delete('#__update_sites');
$updatesite_query =
$db->getQuery(true);
$updatesite_query->select('update_site_id')
->from('#__update_sites');
// If we get results back then we can exclude them
$updatesite_query->where('update_site_id NOT IN (' .
implode(',', $results) .
')');
$updatesite_delete->where('update_site_id NOT IN (' .
implode(',', $results) .
')');
// So let's find what update sites we're about to nuke and remove their associated extensions
$db->setQuery($updatesite_query);
$update_sites_pending_delete =
$db->loadColumn();
if (is_array($update_sites_pending_delete) &&
count($update_sites_pending_delete))
// Nuke any pending updates with this site before we delete it
// TODO: investigate alternative of using a query after the delete below with a query and not in like above
->where('update_site_id IN (' .
implode(',', $update_sites_pending_delete) .
')');
// Note: this might wipe out the entire table if there are no extensions linked
$db->setQuery($updatesite_delete);
// Last but not least we wipe out any pending updates for the extension
->where('extension_id = '.
$eid);
* After update of an extension
* @param JInstaller $installer Installer object
* @param integer $eid Extension identifier
$this->installer =
$installer;
// handle any update sites
$this->processUpdateSites();
* Processes the list of update sites for an extension.
private function processUpdateSites()
$manifest =
$this->installer->getManifest();
$updateservers =
$manifest->updateservers;
$children =
$updateservers->children();
foreach ($children as $child)
$attrs =
$child->attributes();
$this->addUpdateSite($attrs['name'], $attrs['type'], trim($child), true);
$data =
trim((string)
$updateservers);
// We have a single entry in the update server line, let us presume this is an extension line
$this->addUpdateSite(JText::_('PLG_EXTENSION_JOOMLA_UNKNOWN_SITE'), 'extension', $data, true);
Documentation generated on Tue, 19 Nov 2013 15:06:05 +0100 by phpDocumentor 1.4.3