diff --git a/administrator/components/com_installer/config.xml b/administrator/components/com_installer/config.xml index c741282ab4970..cc363da9f06db 100644 --- a/administrator/components/com_installer/config.xml +++ b/administrator/components/com_installer/config.xml @@ -5,6 +5,22 @@ label="COM_INSTALLER_PREFERENCES_LABEL" description="COM_INSTALLER_PREFERENCES_DESCRIPTION" > + + + + 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; + // Load installer plugins for assistance if required: + JPluginHelper::importPlugin('installer'); + $dispatcher = JDispatcher::getInstance(); + + $package = null; + + // 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)); + + if (in_array(true, $results, true)) + { + return true; } - + elseif (in_array(false, $results, true)) + { + return false; + } + + $installType = JRequest::getWord('installtype'); + if ($package === null) + { + switch ($installType) + { + case 'folder': + // Remember the 'Install from Directory' path. + $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; + } + } + + // This event allows a custom installation of the package or a customization of the package: + $results = $dispatcher->trigger('onInstallerBeforeInstaller', array($this, &$package)); + + if (in_array(true, $results, true)) + { + return true; + } + elseif (in_array(false, $results, true)) + { + if (in_array($installType, array('upload', 'url'))) + { + JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); + } + return false; + } + // Was the package unpacked? - if (!$package) { + if (!$package || !$package['type']) { + if (in_array($installType, array('upload', 'url'))) + { + JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); + } $app->setUserState('com_installer.message', JText::_('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE')); return false; } @@ -112,6 +155,8 @@ function install() $result = true; } + $dispatcher->trigger('onInstallerAfterInstaller', array($this, &$package, $installer, &$result, &$msg)); + // Set some model state values $app = JFactory::getApplication(); $app->enqueueMessage($msg); @@ -177,7 +222,7 @@ protected function _getPackageFromUpload() $uploaded = JFile::upload($tmp_src, $tmp_dest); // Unpack the downloaded package file - $package = JInstallerHelper::unpack($tmp_dest); + $package = JInstallerHelper::unpack($tmp_dest, true); return $package; } @@ -206,7 +251,6 @@ protected function _getPackageFromFolder() // Did you give us a valid package? if (!$type) { JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE')); - return false; } $package['packagefile'] = null; @@ -237,6 +281,20 @@ protected function _getPackageFromUrl() return false; } + // Handle updater XML file case: + if (preg_match('/\.xml\s*$/', $url)) + { + jimport('joomla.updater.update'); + $update = new JUpdate; + $update->loadFromXML($url); + $package_url = trim($update->get('downloadurl', false)->_data); + if ($package_url) + { + $url = $package_url; + } + unset($update); + } + // Download the package at the URL given $p_file = JInstallerHelper::downloadPackage($url); @@ -250,7 +308,7 @@ protected function _getPackageFromUrl() $tmp_dest = $config->get('tmp_path'); // Unpack the downloaded package file - $package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file); + $package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file, true); return $package; } diff --git a/administrator/components/com_installer/views/install/tmpl/default_form.php b/administrator/components/com_installer/views/install/tmpl/default_form.php index 041da65de141d..7a2d5311d18cf 100644 --- a/administrator/components/com_installer/views/install/tmpl/default_form.php +++ b/administrator/components/com_installer/views/install/tmpl/default_form.php @@ -9,9 +9,25 @@ // no direct access defined('_JEXEC') or die; + +if ($this->showJedAndWebInstaller && !$this->showMessage) { + $info = '
×
' + . preg_replace( + '#([^<]*)([^<]*)([^<]*)([^<]*)([^<]*)([^<]*)#', + '\1' + . '' . '\2' . '' + . '\3' + . '' . '\4' . '' + . '\5' + . '' + . '\7', + str_replace('"', '"', JText::_('COM_INSTALLER_INSTALL_FROM_WEB_INFORMATION')) + ); + JFactory::getApplication()->enqueueMessage($info, 'info'); +} ?>
- ftp) : ?> loadTemplate('ftp'); ?>
+ + trigger('onInstallerViewBeforeFirstTab', array()); ?> +
@@ -73,6 +97,9 @@
+ + trigger('onInstallerViewAfterLastTab', array()); ?> + diff --git a/administrator/components/com_installer/views/install/view.html.php b/administrator/components/com_installer/views/install/view.html.php index ddd58a8802295..6b12116a9434b 100644 --- a/administrator/components/com_installer/views/install/view.html.php +++ b/administrator/components/com_installer/views/install/view.html.php @@ -30,6 +30,12 @@ function display($tpl=null) $this->assignRef('paths', $paths); $this->assignRef('state', $state); + $this->showJedAndWebInstaller = JComponentHelper::getParams('com_installer')->get('show_jed_info', 1); + + JPluginHelper::importPlugin('installer'); + + JDispatcher::getInstance()->trigger('onInstallerBeforeDisplay', array(&$this->showJedAndWebInstaller, $this)); + parent::display($tpl); } diff --git a/administrator/language/en-GB/en-GB.com_installer.ini b/administrator/language/en-GB/en-GB.com_installer.ini index 9634beb375130..fe30d569f4bd0 100644 --- a/administrator/language/en-GB/en-GB.com_installer.ini +++ b/administrator/language/en-GB/en-GB.com_installer.ini @@ -123,6 +123,11 @@ COM_INSTALLER_NO_INSTALL_TYPE_FOUND="No Install Type Found" COM_INSTALLER_PACKAGE_DOWNLOAD_FAILED="Package download failed: %s" COM_INSTALLER_PACKAGE_FILE="Package File" COM_INSTALLER_PURGED_UPDATES="Purged updates" +COM_INSTALLER_SHOW_JED_INFORMATION_DESC="Show or hide the information at the top of the installer page about the Joomla! Extensions Directory." +COM_INSTALLER_SHOW_JED_INFORMATION_HIDE_MESSAGE="Hide message" +COM_INSTALLER_SHOW_JED_INFORMATION_LABEL="Joomla! Extensions Directory" +COM_INSTALLER_SHOW_JED_INFORMATION_SHOW_MESSAGE="Show message" +COM_INSTALLER_SHOW_JED_INFORMATION_TOOLTIP="Opens Installer Options for setting to hide this Joomla! Extensions Directory message." COM_INSTALLER_SUBMENU_DATABASE="Database" COM_INSTALLER_SUBMENU_DISCOVER="Discover" COM_INSTALLER_SUBMENU_INSTALL="Install" @@ -168,6 +173,14 @@ COM_INSTALLER_VALUE_FOLDER_NONAPPLICABLE="N/A" COM_INSTALLER_VALUE_FOLDER_SELECT="- Select Folder -" COM_INSTALLER_VALUE_STATE_SELECT="- Select Status -" COM_INSTALLER_VALUE_TYPE_SELECT="- Select Type -" +COM_INSTALLER_WEBINSTALLER_INSTALL_WEB_CONFIRM="Please confirm the installation by clicking on the Install button" +COM_INSTALLER_WEBINSTALLER_INSTALL_WEB_CONFIRM_NAME="Extension Name" +COM_INSTALLER_WEBINSTALLER_INSTALL_WEB_CONFIRM_URL="Install from" +COM_INSTALLER_WEBINSTALLER_INSTALL_WEB_LOADING="Loading..." +COM_INSTALLER_WEBINSTALLER_INSTALL_WEB_LOADING_ERROR="Cannot connect to the Joomla! server. Please try again later." +COM_INSTALLER_WEBINSTALLER_LOAD_APPS="Click here to load extensions browser" +COM_INSTALLER_WEBINSTALLER_INSTALL_OBSOLETE="The Install from Web plugin has become obsolete and needs to be updated." +COM_INSTALLER_WEBINSTALLER_INSTALL_UPDATE_AVAILABLE="There is a new update available for the Install from Web plugin. It is advisable that you update as soon as possible." COM_INSTALLER_XML_DESCRIPTION="Installer component for adding, removing and upgrading extensions" JLIB_RULES_SETTING_NOTES="1. If you change the setting, it will apply to this component. Note that:
Inherited means that the permissions from global configuration and parent group will be used.
Denied means that no matter what the global configuration or parent group settings are, the group being edited cannot take this action on this component.
Allowed means that the group being edited will be able to take this action for this component (but if this is in conflict with the global configuration or parent group it will have no impact; a conflict will be indicated by Not Allowed (Locked) under Calculated Settings).
2. If you select a new setting, click Save to refresh the calculated settings." COM_INSTALLER_PREFERENCES_LABEL="Preferences" @@ -182,3 +195,8 @@ COM_INSTALLER_HEADER_LANGUAGES="Install Accredited Language Translations" COM_INSTALLER_HEADING_DETAILS_URL="Details URL" COM_INSTALLER_MSG_LANGUAGES_NOLANGUAGES="There are no available languages to install at the moment. Please click on the "Purge Cache" and "Find languages" buttons to check for updates on the Joomla Languages server. You will need an internet connection for this to work." COM_INSTALLER_LANGUAGES_FILTER_SEARCH_DESC="Search by language name." +COM_INSTALLER_INSTALL_FROM_WEB="Install from Web" +COM_INSTALLER_INSTALL_FROM_WEB_INFORMATION="Joomla! Extensions Directory now available with Install from Web on this page: " +COM_INSTALLER_INSTALL_FROM_WEB_ADD_TAB="Add "Install from Web" option" +COM_INSTALLER_INSTALL_FROM_WEB_INFO="Joomla! Extensions Directory (JED) now available with Install from Web on this page." +COM_INSTALLER_INSTALL_FROM_WEB_TOS="By clicking "_QQ_"Add Install from Web option"_QQ_" below, you agree to the JED Terms of Service and all applicable third party license terms." diff --git a/administrator/language/en-GB/en-GB.plg_installer_webinstaller.ini b/administrator/language/en-GB/en-GB.plg_installer_webinstaller.ini new file mode 100644 index 0000000000000..2022446c8f600 --- /dev/null +++ b/administrator/language/en-GB/en-GB.plg_installer_webinstaller.ini @@ -0,0 +1,11 @@ +; Joomla! Project +; Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved. +; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php +; Note : All ini files need to be saved as UTF-8 + +PLG_INSTALLER_WEBINSTALLER="Installer - Install from Web" +PLG_INSTALLER_WEBINSTALLER_TAB_POSITION_DESC="Indicate whether to place the Install from Web tab first or last" +PLG_INSTALLER_WEBINSTALLER_TAB_POSITION_LABEL="Tab Position" +PLG_INSTALLER_WEBINSTALLER_TAB_POSITION_FIRST="First" +PLG_INSTALLER_WEBINSTALLER_TAB_POSITION_LAST="Last" +PLG_INSTALLER_WEBINSTALLER_XML_DESCRIPTION="This plugin offers functionality for the 'Install from Web' tab." diff --git a/administrator/language/en-GB/en-GB.plg_installer_webinstaller.sys.ini b/administrator/language/en-GB/en-GB.plg_installer_webinstaller.sys.ini new file mode 100644 index 0000000000000..7d9476fd80351 --- /dev/null +++ b/administrator/language/en-GB/en-GB.plg_installer_webinstaller.sys.ini @@ -0,0 +1,7 @@ +; Joomla! Project +; Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved. +; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php +; Note : All ini files need to be saved as UTF-8 + +PLG_INSTALLER_WEBINSTALLER="Installer - Install from Web" +PLG_INSTALLER_WEBINSTALLER_XML_DESCRIPTION="This plugin offers functionality for the 'Install from Web' tab." diff --git a/libraries/joomla/installer/helper.php b/libraries/joomla/installer/helper.php index c1c11a493a8a2..7942f14202582 100644 --- a/libraries/joomla/installer/helper.php +++ b/libraries/joomla/installer/helper.php @@ -75,6 +75,7 @@ public static function downloadPackage($url, $target = false) $response->body = $php_errormsg; } + JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_DOWNLOAD_SERVER_CONNECT', $response->code), JLog::WARNING, 'jerror'); JError::raiseWarning(42, JText::sprintf('JLIB_INSTALLER_ERROR_DOWNLOAD_SERVER_CONNECT', $response->body)); return false; @@ -113,13 +114,14 @@ public static function downloadPackage($url, $target = false) * Unpacks a file and verifies it as a Joomla element package * Supports .gz .tar .tar.gz and .zip * - * @param string $p_filename The uploaded package filename or install directory + * @param string $p_filename The uploaded package filename or install directory + * @param boolean $alwaysReturnArray If should return false (and leave garbage behind) or return $retval['type']=false * * @return array Two elements: extractdir and packagefile * * @since 11.1 */ - public static function unpack($p_filename) + public static function unpack($p_filename, $alwaysReturnArray = false) { // Path to the archive $archivename = $p_filename; @@ -136,6 +138,13 @@ public static function unpack($p_filename) if ($result === false) { + if ($alwaysReturnArray) + { + $retval['extractdir'] = null; + $retval['packagefile'] = $archivename; + $retval['type'] = false; + return $retval; + } return false; } @@ -173,7 +182,7 @@ public static function unpack($p_filename) * Get the extension type and return the directory/type array on success or * false on fail. */ - if ($retval['type'] = self::detectType($extractdir)) + if (($retval['type'] = self::detectType($extractdir)) || $alwaysReturnArray) { return $retval; } @@ -262,7 +271,7 @@ public static function cleanupInstall($package, $resultdir) $config = JFactory::getConfig(); // Does the unpacked extension directory exist? - if (is_dir($resultdir)) + if ($resultdir && is_dir($resultdir)) { JFolder::delete($resultdir); } diff --git a/plugins/installer/index.html b/plugins/installer/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/plugins/installer/index.html @@ -0,0 +1 @@ +