english/administrator/components/com_installer/models/install.php
/**
	 * Install an extension from either folder, url or upload.
	 *
	 * @return	boolean result of install
	 * @since	1.5
	 */
Install an extension from either folder, url or upload.
@return      boolean result of install
@since       1.5
Install an extension from either folder url or upload . @return boolean result of install @since 1 . 5
function install()
	{
		jimport('joomla.client.helper');
		$this->setState('action', 'install');
		JClientHelper::setCredentialsFromRequest('ftp');
		$app = JFactory::getApplication();
		switch(JRequest::getWord('installtype')) {
			case 'folder':
				$app->getUserStateFromRequest($this->_context.'.install_directory', 'install_directory');
				$package = $this->_getPackageFromFolder();
				break;
			case 'upload':
				$package = $this->_getPackageFromUpload();
				break;
			case 'url':
				$package = $this->_getPackageFromUrl();
				break;
			default:
				$app->setUserState('com_installer.message', JText::_('COM_INSTALLER_NO_INSTALL_TYPE_FOUND'));
				return false;
				break;
		}
				if (!$package) {
			$app->setUserState('com_installer.message', JText::_('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE'));
			return false;
		}
		$installer = JInstaller::getInstance();
		if (!$installer->install($package['dir'])) {
			$msg = JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_'.strtoupper($package['type'])));
			$result = false;
		} else {
			$msg = JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', JText::_('COM_INSTALLER_TYPE_TYPE_'.strtoupper($package['type'])));
			$result = true;
		}
		$app	= JFactory::getApplication();
		$app->enqueueMessage($msg);
		$this->setState('name', $installer->get('name'));
		$this->setState('result', $result);
		$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'));
		if (!is_file($package['packagefile'])) {
			$config = JFactory::getConfig();
			$package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
		}
		JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
		return $result;
	}
function install ( ) { jimport ( 'joomla.client.helper' ) ; $ this -> setState ( 'action' , 'install' ) ; JClientHelper :: setCredentialsFromRequest ( 'ftp' ) ; $ app = JFactory :: getApplication ( ) ; switch ( JRequest :: getWord ( 'installtype' ) ) { case 'folder' : $ app -> getUserStateFromRequest ( $ this -> _context . '.install_directory' , 'install_directory' ) ; $ package = $ this -> _getPackageFromFolder ( ) ; break ; case 'upload' : $ package = $ this -> _getPackageFromUpload ( ) ; break ; case 'url' : $ package = $ this -> _getPackageFromUrl ( ) ; break ; default : $ app -> setUserState ( 'com_installer.message' , JText :: _ ( 'COM_INSTALLER_NO_INSTALL_TYPE_FOUND' ) ) ; return false ; break ; } if ( ! $ package ) { $ app -> setUserState ( 'com_installer.message' , JText :: _ ( 'COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE' ) ) ; return false ; } $ installer = JInstaller :: getInstance ( ) ; if ( ! $ installer -> install ( $ package [ 'dir' ] ) ) { $ msg = JText :: sprintf ( 'COM_INSTALLER_INSTALL_ERROR' , JText :: _ ( 'COM_INSTALLER_TYPE_TYPE_' . strtoupper ( $ package [ 'type' ] ) ) ) ; $ result = false ; } else { $ msg = JText :: sprintf ( 'COM_INSTALLER_INSTALL_SUCCESS' , JText :: _ ( 'COM_INSTALLER_TYPE_TYPE_' . strtoupper ( $ package [ 'type' ] ) ) ) ; $ result = true ; } $ app = JFactory :: getApplication ( ) ; $ app -> enqueueMessage ( $ msg ) ; $ this -> setState ( 'name' , $ installer -> get ( 'name' ) ) ; $ this -> setState ( 'result' , $ result ) ; $ 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' ) ) ; if ( ! is_file ( $ package [ 'packagefile' ] ) ) { $ config = JFactory :: getConfig ( ) ; $ package [ 'packagefile' ] = $ config -> get ( 'tmp_path' ) . '/' . $ package [ 'packagefile' ] ; } JInstallerHelper :: cleanupInstall ( $ package [ 'packagefile' ] , $ package [ 'extractdir' ] ) ; return $ result ; }
Install an extension from either folder, url or upload.
Install an extension from either folder url or upload .
// Set FTP credentials, if given. // Remember the 'Install from Directory' path. // Was the package unpacked?
 // Get an installer instance // Install the package // There was an error installing the package // Package installed sucessfully // Set some model state values // Cleanup the install files