Source for file install.php
Documentation is available at install.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
* Extension Manager Install Model
* @package Joomla.Administrator
* @subpackage com_installer
* @var object JTable object
* @var object JTable object
protected $_context =
'com_installer.install';
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
$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', '');
// Recall the 'Install from Directory' path.
$path =
$app->getUserStateFromRequest($this->_context .
'.install_directory', 'install_directory', $app->getCfg('tmp_path'));
$this->setState('install.directory', $path);
* Install an extension from either folder, url or upload.
* @return boolean result of install
// Set FTP credentials, if given.
// Load installer plugins for assistance if required:
// This event allows an input pre-treatment, a custom pre-packing or custom installation (e.g. from a JSON description)
$results =
$dispatcher->trigger('onInstallerBeforeInstallation', array($this, &$package));
elseif (in_array(false, $results, true))
$installType =
$app->input->getWord('installtype');
// Remember the 'Install from Directory' path.
$app->getUserStateFromRequest($this->_context .
'.install_directory', 'install_directory');
$app->setUserState('com_installer.message', JText::_('COM_INSTALLER_NO_INSTALL_TYPE_FOUND'));
// This event allows a custom installation of the package or a customization of the package:
$results =
$dispatcher->trigger('onInstallerBeforeInstaller', array($this, &$package));
elseif (in_array(false, $results, true))
if (in_array($installType, array('upload', 'url')))
// Was the package unpacked?
if (!$package ||
!$package['type'])
if (in_array($installType, array('upload', 'url')))
$app->setUserState('com_installer.message', JText::_('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE'));
// Get an installer instance
if (!$installer->install($package['dir']))
// There was an error installing the package
// Package installed sucessfully
// This event allows a custom a post-flight:
$dispatcher->trigger('onInstallerAfterInstaller', array($this, &$package, $installer, &$result, &$msg));
// Set some model state values
$app->enqueueMessage($msg);
$this->setState('name', $installer->get('name'));
$app->setUserState('com_installer.message', $installer->message);
$app->setUserState('com_installer.extension_message', $installer->get('extension_message'));
$app->setUserState('com_installer.redirect_url', $installer->get('redirect_url'));
// Cleanup the install files
if (!is_file($package['packagefile']))
$package['packagefile'] =
$config->get('tmp_path') .
'/' .
$package['packagefile'];
* Works out an installation package from a HTTP upload
* @return package definition or false on failure
// Get the uploaded file information
$userfile =
JRequest::getVar('install_package', null, 'files', 'array');
// Make sure that file uploads are enabled in php
if (!(bool)
ini_get('file_uploads'))
// Make sure that zlib is loaded so that the package can be unpacked
// If there is no uploaded file, we have a problem...
// Check if there was a problem uploading the file.
if ($userfile['error'] ||
$userfile['size'] <
1)
// Build the appropriate paths
$tmp_dest =
$config->get('tmp_path') .
'/' .
$userfile['name'];
$tmp_src =
$userfile['tmp_name'];
// Unpack the downloaded package file
* Install an extension from a directory
* @return array Package details or false on failure
// Get the path to the package to install
$p_dir =
$input->getString('install_directory');
// Did you give us a valid directory?
// Detect the package type
// Did you give us a valid package?
$package['packagefile'] =
null;
$package['extractdir'] =
null;
$package['dir'] =
$p_dir;
$package['type'] =
$type;
* Install an extension from a URL
* @return Package details or false on failure
// Get the URL of the package to install
$url =
$input->getString('install_url');
// Did you give us a URL?
// Handle updater XML file case:
$update->loadFromXML($url);
$package_url =
trim($update->get('downloadurl', false)->_data);
// Download the package at the URL given
// Was the package downloaded?
$tmp_dest =
$config->get('tmp_path');
// Unpack the downloaded package file
Documentation generated on Tue, 19 Nov 2013 15:05:38 +0100 by phpDocumentor 1.4.3