diff --git a/administrator/components/com_installer/tmpl/install/default.php b/administrator/components/com_installer/tmpl/install/default.php index c265c2f553c64..cf480503879e2 100644 --- a/administrator/components/com_installer/tmpl/install/default.php +++ b/administrator/components/com_installer/tmpl/install/default.php @@ -20,9 +20,6 @@ Text::script('NOTICE'); Text::script('MESSAGE'); -Text::script('PLG_INSTALLER_PACKAGEINSTALLER_NO_PACKAGE'); -Text::script('PLG_INSTALLER_FOLDERINSTALLER_NO_INSTALL_PATH'); -Text::script('PLG_INSTALLER_URLINSTALLER_NO_URL'); Text::script('COM_INSTALLER_MSG_INSTALL_ENTER_A_URL'); /** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ @@ -31,9 +28,10 @@ ->usePreset('com_installer.installer') ->useScript('webcomponent.core-loader'); -$app = Factory::getApplication(); -?> +$app = Factory::getApplication(); +$tabs = $app->triggerEvent('onInstallerAddInstallationTab', []); +?>
@@ -44,31 +42,36 @@ showMessage) : ?> loadTemplate('message'); ?> - triggerEvent('onInstallerAddInstallationTab', []); ?> - $tabs[0]['name'] ?? '']); ?> - - - -
- -
- - + - enqueueMessage(Text::_('COM_INSTALLER_NO_INSTALLATION_PLUGINS_FOUND'), 'warning'); ?> +
+ + +
- ftp) : ?> - - loadTemplate('ftp'); ?> - + ftp) : ?> + $tabs[0]['name'] ?? '']); ?> + + + +
+ +
+ + + + ftp) : ?> + + loadTemplate('ftp'); ?> + + + - -
diff --git a/administrator/language/en-GB/com_installer.ini b/administrator/language/en-GB/com_installer.ini index 2633ea4af1f28..a4b236e30785e 100644 --- a/administrator/language/en-GB/com_installer.ini +++ b/administrator/language/en-GB/com_installer.ini @@ -83,9 +83,6 @@ COM_INSTALLER_INSTALL_BUTTON="Install" COM_INSTALLER_INSTALL_CHECKSUM_WRONG="The checksum verification failed. Please make sure you are using the correct update server!" COM_INSTALLER_INSTALL_DIRECTORY="Install Folder" COM_INSTALLER_INSTALL_ERROR="Error installing %s" -COM_INSTALLER_INSTALL_FROM_DIRECTORY="Install from Folder" -COM_INSTALLER_INSTALL_FROM_URL="Install from URL" -COM_INSTALLER_INSTALL_FROM_WEB="Install from Web" COM_INSTALLER_INSTALL_LANGUAGE_SUCCESS="Installation of the %s language was successful." COM_INSTALLER_INSTALL_SUCCESS="Installation of the %s was successful." COM_INSTALLER_INSTALL_URL="Install URL" @@ -282,14 +279,6 @@ COM_INSTALLER_VALUE_SUPPORTED_MISSING="Download Key invalid" COM_INSTALLER_VALUE_SUPPORTED_SELECT="- Select Download Key -" COM_INSTALLER_VALUE_SUPPORTED_SUPPORTED="Download Key supported" COM_INSTALLER_VALUE_TYPE_SELECT="- Select Type -" -COM_INSTALLER_WEBINSTALLER_INSTALL_OBSOLETE="The Install from Web plugin 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_WEBINSTALLER_INSTALL_WEB_CONFIRM="Please confirm the installation by selecting 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="Can't connect to the Joomla! server. Please try again later." -COM_INSTALLER_WEBINSTALLER_LOAD_APPS="Select to load extensions browser" COM_INSTALLER_XML_DESCRIPTION="Installer component for adding, removing and upgrading extensions" ; Alternate language strings for the rules form field diff --git a/administrator/language/en-GB/plg_installer_webinstaller.ini b/administrator/language/en-GB/plg_installer_webinstaller.ini index dc9ea88c4d930..6c4b9ba7d0dee 100644 --- a/administrator/language/en-GB/plg_installer_webinstaller.ini +++ b/administrator/language/en-GB/plg_installer_webinstaller.ini @@ -5,6 +5,12 @@ PLG_INSTALLER_WEBINSTALLER="Installer - Install from Web" PLG_INSTALLER_WEBINSTALLER_CANNOT_INSTALL_EXTENSION_IN_PLUGIN="This extension cannot be installed via the install from web system. Please visit the developer's website to purchase/download." +PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_CONFIRM="Please confirm the installation by selecting the Install button" +PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_CONFIRM_NAME="Extension Name" +PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_CONFIRM_URL="Install from" +PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_LOADING="Loading ..." +PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_LOADING_ERROR="Can't connect to the Joomla! server. Please try again later." ; The [SITEURL] placeholder should not be translated as it is used in the JavaScript API to insert the correct URL PLG_INSTALLER_WEBINSTALLER_REDIRECT_TO_EXTERNAL_SITE_TO_INSTALL="You will be redirected to the following link to complete the registration/purchase: [SITEURL]" +PLG_INSTALLER_WEBINSTALLER_TAB_LABEL="Install from Web" PLG_INSTALLER_WEBINSTALLER_XML_DESCRIPTION="This plugin allows you to install directly from the Joomla! Extension Directory." diff --git a/build/media_source/com_installer/js/installer.es6.js b/build/media_source/com_installer/js/installer.es6.js index dd1b4718b517d..8ca5d517becf6 100644 --- a/build/media_source/com_installer/js/installer.es6.js +++ b/build/media_source/com_installer/js/installer.es6.js @@ -3,109 +3,10 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -Joomla = window.Joomla || {}; - -((Joomla) => { +(() => { 'use strict'; - const installPackageButtonId = 'installbutton_package'; - document.addEventListener('DOMContentLoaded', () => { - Joomla.submitbuttonpackage = () => { - const form = document.getElementById('adminForm'); - - // do field validation - if (form.install_package.value === '') { - Joomla.renderMessages({ warning: [Joomla.JText._('PLG_INSTALLER_PACKAGEINSTALLER_NO_PACKAGE')] }); - } else if (form.install_package.files[0].size > form.max_upload_size.value) { - Joomla.renderMessages({ warning: [Joomla.JText._('COM_INSTALLER_MSG_WARNINGS_UPLOADFILETOOBIG')] }); - } else { - Joomla.displayLoader(); - - form.installtype.value = 'upload'; - form.submit(); - } - }; - - Joomla.submitbuttonfolder = () => { - const form = document.getElementById('adminForm'); - - // do field validation - if (form.install_directory.value === '') { - Joomla.renderMessages({ warning: [Joomla.JText._('PLG_INSTALLER_FOLDERINSTALLER_NO_INSTALL_PATH')] }); - } else { - Joomla.displayLoader(); - - form.installtype.value = 'folder'; - form.submit(); - } - }; - - Joomla.submitbuttonurl = () => { - const form = document.getElementById('adminForm'); - - // do field validation - if (form.install_url.value === '' || form.install_url.value === 'http://' || form.install_url.value === 'https://') { - Joomla.renderMessages({ warning: [Joomla.JText._('PLG_INSTALLER_URLINSTALLER_NO_URL')] }); - } else { - Joomla.displayLoader(); - - form.installtype.value = 'url'; - form.submit(); - } - }; - - Joomla.submitbutton4 = () => { - const form = document.getElementById('adminForm'); - - // do field validation - if (form.install_url.value === '' || form.install_url.value === 'http://' || form.install_url.value === 'https://') { - Joomla.renderMessages({ warning: [Joomla.JText._('COM_INSTALLER_MSG_INSTALL_ENTER_A_URL')] }); - } else { - Joomla.displayLoader(); - - form.installtype.value = 'url'; - form.submit(); - } - }; - - Joomla.submitbutton5 = () => { - const form = document.getElementById('adminForm'); - - // do field validation - if (form.install_url.value !== '' || form.install_url.value !== 'http://' || form.install_url.value !== 'https://') { - Joomla.submitbutton4(); - } else if (form.install_url.value === '') { - Joomla.renderMessages({ warning: [Joomla.apps.options.btntxt] }); - } else { - document.querySelector('#appsloading').classList.remove('hidden'); - form.installtype.value = 'web'; - form.submit(); - } - }; - - Joomla.submitbuttonUpload = () => { - const form = document.getElementById('uploadForm'); - - // do field validation - if (form.install_package.value === '') { - Joomla.renderMessages({ warning: [Joomla.JText._('COM_INSTALLER_MSG_INSTALL_PLEASE_SELECT_A_PACKAGE')] }); - } else if (form.install_package.files[0].size > form.max_upload_size.value) { - Joomla.renderMessages({ warning: [Joomla.JText._('COM_INSTALLER_MSG_WARNINGS_UPLOADFILETOOBIG')] }); - } else { - Joomla.displayLoader(); - - form.submit(); - } - }; - - Joomla.displayLoader = () => { - const loading = document.getElementById('loading'); - if (loading) { - loading.classList.remove('hidden'); - } - }; - const loading = document.getElementById('loading'); const installer = document.getElementById('installer-install'); @@ -117,180 +18,5 @@ Joomla = window.Joomla || {}; loading.classList.add('hidden'); loading.style.marginTop = '-10px'; } - - document.getElementById(installPackageButtonId).addEventListener('click', (event) => { - event.preventDefault(); - Joomla.submitbuttonpackage(); - }); - }); -})(Joomla); - -document.addEventListener('DOMContentLoaded', () => { - if (typeof FormData === 'undefined') { - document.querySelector('#legacy-uploader').classList.remove('hidden'); - document.querySelector('#uploader-wrapper').classList.add('hidden'); - return; - } - - let uploading = false; - const dragZone = document.querySelector('#dragarea'); - const fileInput = document.querySelector('#install_package'); - const fileSizeMax = document.querySelector('#max_upload_size').value; - const button = document.querySelector('#select-file-button'); - const returnUrl = document.querySelector('#installer-return').value; - const progress = document.getElementById('upload-progress'); - const progressBar = progress.querySelectorAll('.bar')[0]; - const percentage = progress.querySelectorAll('.uploading-number')[0]; - let uploadUrl = 'index.php?option=com_installer&task=install.ajax_upload'; - - function showError(res) { - dragZone.setAttribute('data-state', 'pending'); - let message = Joomla.JText._('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_ERROR_UNKNOWN'); - if (res == null) { - message = Joomla.JText._('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_ERROR_EMPTY'); - } else if (typeof res === 'string') { - // Let's remove unnecessary HTML - message = res.replace(/(<([^>]+)>|\s+)/g, ' '); - } else if (res.message) { - ({ message } = res); - } - Joomla.renderMessages({ error: [message] }); - } - - if (returnUrl) { - uploadUrl += `&return=${returnUrl}`; - } - - button.addEventListener('click', () => { - fileInput.click(); - }); - - fileInput.addEventListener('change', () => { - if (uploading) { - return; - } - Joomla.submitbuttonpackage(); - }); - - dragZone.addEventListener('dragenter', (event) => { - event.preventDefault(); - event.stopPropagation(); - - dragZone.classList.add('hover'); - - return false; - }); - - // Notify user when file is over the drop area - dragZone.addEventListener('dragover', (event) => { - event.preventDefault(); - event.stopPropagation(); - - dragZone.classList.add('hover'); - - return false; - }); - - dragZone.addEventListener('dragleave', (event) => { - event.preventDefault(); - event.stopPropagation(); - dragZone.classList.remove('hover'); - - return false; - }); - - dragZone.addEventListener('drop', (event) => { - event.preventDefault(); - event.stopPropagation(); - - if (uploading) { - return; - } - - dragZone.classList.remove('hover'); - - const files = event.target.files || event.dataTransfer.files; - - if (!files.length) { - return; - } - - const file = files[0]; - const data = new FormData(); - - if (file.size > fileSizeMax) { - Joomla.renderMessages({ warning: [Joomla.JText._('COM_INSTALLER_MSG_WARNINGS_UPLOADFILETOOBIG')] }); - return; - } - - data.append('install_package', file); - data.append('installtype', 'upload'); - dragZone.setAttribute('data-state', 'uploading'); - progressBar.setAttribute('aria-valuenow', 0); - - uploading = true; - progressBar.style.width = 0; - percentage.textContent = '0'; - - // Upload progress - const progressCallback = (evt) => { - if (evt.lengthComputable) { - const percentComplete = evt.loaded / evt.total; - const number = Math.round(percentComplete * 100); - progressBar.css('width', `${number}%`); - progressBar.setAttribute('aria-valuenow', number); - percentage.textContent = `${number}`; - if (number === 100) { - dragZone.setAttribute('data-state', 'installing'); - } - } - }; - - Joomla.request({ - url: uploadUrl, - method: 'POST', - perform: true, - data, - headers: { 'Content-Type': 'false' }, - uploadProgressCallback: progressCallback, - onSuccess: (response) => { - if (!response) { - showError(response); - return; - } - - let res; - - try { - res = JSON.parse(response); - } catch (e) { - showError(e); - - return; - } - - if (!res.success && !res.data) { - showError(res); - - return; - } - - // Always redirect that can show message queue from session - if (res.data.redirect) { - window.location.href = res.data.redirect; - } else { - window.location.href = 'index.php?option=com_installer&view=install'; - } - }, - onError: (error) => { - uploading = false; - if (error.status === 200) { - const res = error.responseText || error.responseJSON; - showError(res); - } else { - showError(error.statusText); - } - }, - }); }); -}); +})(); diff --git a/build/media_source/plg_installer_folderinstaller/js/folderinstaller.es6.js b/build/media_source/plg_installer_folderinstaller/js/folderinstaller.es6.js new file mode 100644 index 0000000000000..da9f4e3341ea0 --- /dev/null +++ b/build/media_source/plg_installer_folderinstaller/js/folderinstaller.es6.js @@ -0,0 +1,29 @@ +/** + * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +Joomla = window.Joomla || {}; + +((Joomla) => { + 'use strict'; + + document.addEventListener('DOMContentLoaded', () => { + Joomla.submitbuttonfolder = () => { + const form = document.getElementById('adminForm'); + + // do field validation + if (form.install_directory.value === '') { + Joomla.renderMessages({ warning: [Joomla.Text._('PLG_INSTALLER_FOLDERINSTALLER_NO_INSTALL_PATH')] }); + } else { + const loading = document.getElementById('loading'); + if (loading) { + loading.classList.remove('hidden'); + } + + form.installtype.value = 'folder'; + form.submit(); + } + }; + }); +})(Joomla); diff --git a/build/media_source/plg_installer_packageinstaller/js/packageinstaller.es6.js b/build/media_source/plg_installer_packageinstaller/js/packageinstaller.es6.js new file mode 100644 index 0000000000000..2d0226ec75889 --- /dev/null +++ b/build/media_source/plg_installer_packageinstaller/js/packageinstaller.es6.js @@ -0,0 +1,204 @@ +/** + * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +Joomla = window.Joomla || {}; + +((Joomla) => { + 'use strict'; + + document.addEventListener('DOMContentLoaded', () => { + Joomla.submitbuttonpackage = () => { + const form = document.getElementById('adminForm'); + + // do field validation + if (form.install_package.value === '') { + Joomla.renderMessages({ warning: [Joomla.Text._('PLG_INSTALLER_PACKAGEINSTALLER_NO_PACKAGE')] }); + } else if (form.install_package.files[0].size > form.max_upload_size.value) { + Joomla.renderMessages({ warning: [Joomla.Text._('COM_INSTALLER_MSG_WARNINGS_UPLOADFILETOOBIG')] }); + } else { + const loading = document.getElementById('loading'); + if (loading) { + loading.classList.remove('hidden'); + } + + form.installtype.value = 'upload'; + form.submit(); + } + }; + + if (typeof FormData === 'undefined') { + document.querySelector('#legacy-uploader').classList.remove('hidden'); + document.querySelector('#uploader-wrapper').classList.add('hidden'); + return; + } + + let uploading = false; + const dragZone = document.querySelector('#dragarea'); + const fileInput = document.querySelector('#install_package'); + const fileSizeMax = document.querySelector('#max_upload_size').value; + const button = document.querySelector('#select-file-button'); + const returnUrl = document.querySelector('#installer-return').value; + const progress = document.getElementById('upload-progress'); + const progressBar = progress.querySelectorAll('.bar')[0]; + const percentage = progress.querySelectorAll('.uploading-number')[0]; + let uploadUrl = 'index.php?option=com_installer&task=install.ajax_upload'; + + function showError(res) { + dragZone.setAttribute('data-state', 'pending'); + let message = Joomla.Text._('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_ERROR_UNKNOWN'); + if (res == null) { + message = Joomla.Text._('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_ERROR_EMPTY'); + } else if (typeof res === 'string') { + // Let's remove unnecessary HTML + message = res.replace(/(<([^>]+)>|\s+)/g, ' '); + } else if (res.message) { + ({ message } = res); + } + Joomla.renderMessages({ error: [message] }); + } + + if (returnUrl) { + uploadUrl += `&return=${returnUrl}`; + } + + button.addEventListener('click', () => { + fileInput.click(); + }); + + fileInput.addEventListener('change', () => { + if (uploading) { + return; + } + Joomla.submitbuttonpackage(); + }); + + dragZone.addEventListener('dragenter', (event) => { + event.preventDefault(); + event.stopPropagation(); + + dragZone.classList.add('hover'); + + return false; + }); + + // Notify user when file is over the drop area + dragZone.addEventListener('dragover', (event) => { + event.preventDefault(); + event.stopPropagation(); + + dragZone.classList.add('hover'); + + return false; + }); + + dragZone.addEventListener('dragleave', (event) => { + event.preventDefault(); + event.stopPropagation(); + dragZone.classList.remove('hover'); + + return false; + }); + + dragZone.addEventListener('drop', (event) => { + event.preventDefault(); + event.stopPropagation(); + + if (uploading) { + return; + } + + dragZone.classList.remove('hover'); + + const files = event.target.files || event.dataTransfer.files; + + if (!files.length) { + return; + } + + const file = files[0]; + const data = new FormData(); + + if (file.size > fileSizeMax) { + Joomla.renderMessages({ warning: [Joomla.Text._('COM_INSTALLER_MSG_WARNINGS_UPLOADFILETOOBIG')] }); + return; + } + + data.append('install_package', file); + data.append('installtype', 'upload'); + dragZone.setAttribute('data-state', 'uploading'); + progressBar.setAttribute('aria-valuenow', 0); + + uploading = true; + progressBar.style.width = 0; + percentage.textContent = '0'; + + // Upload progress + const progressCallback = (evt) => { + if (evt.lengthComputable) { + const percentComplete = evt.loaded / evt.total; + const number = Math.round(percentComplete * 100); + progressBar.css('width', `${number}%`); + progressBar.setAttribute('aria-valuenow', number); + percentage.textContent = `${number}`; + if (number === 100) { + dragZone.setAttribute('data-state', 'installing'); + } + } + }; + + Joomla.request({ + url: uploadUrl, + method: 'POST', + perform: true, + data, + headers: { 'Content-Type': 'false' }, + uploadProgressCallback: progressCallback, + onSuccess: (response) => { + if (!response) { + showError(response); + return; + } + + let res; + + try { + res = JSON.parse(response); + } catch (e) { + showError(e); + + return; + } + + if (!res.success && !res.data) { + showError(res); + + return; + } + + // Always redirect that can show message queue from session + if (res.data.redirect) { + window.location.href = res.data.redirect; + } else { + window.location.href = 'index.php?option=com_installer&view=install'; + } + }, + onError: (error) => { + uploading = false; + if (error.status === 200) { + const res = error.responseText || error.responseJSON; + showError(res); + } else { + showError(error.statusText); + } + }, + }); + }); + + document.getElementById('installbutton_package').addEventListener('click', (event) => { + event.preventDefault(); + Joomla.submitbuttonpackage(); + }); + }); +})(Joomla); diff --git a/build/media_source/plg_installer_urlinstaller/js/urlinstaller.es6.js b/build/media_source/plg_installer_urlinstaller/js/urlinstaller.es6.js new file mode 100644 index 0000000000000..0ee602dc49195 --- /dev/null +++ b/build/media_source/plg_installer_urlinstaller/js/urlinstaller.es6.js @@ -0,0 +1,29 @@ +/** + * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +Joomla = window.Joomla || {}; + +((Joomla) => { + 'use strict'; + + document.addEventListener('DOMContentLoaded', () => { + Joomla.submitbuttonurl = () => { + const form = document.getElementById('adminForm'); + + // do field validation + if (form.install_url.value === '' || form.install_url.value === 'http://' || form.install_url.value === 'https://') { + Joomla.renderMessages({ warning: [Joomla.Text._('PLG_INSTALLER_URLINSTALLER_NO_URL')] }); + } else { + const loading = document.getElementById('loading'); + if (loading) { + loading.classList.remove('hidden'); + } + + form.installtype.value = 'url'; + form.submit(); + } + }; + }); +})(Joomla); diff --git a/build/media_source/plg_installer_webinstaller/js/client.es6.js b/build/media_source/plg_installer_webinstaller/js/client.es6.js index 502072e8e303b..cf1798acf7f28 100644 --- a/build/media_source/plg_installer_webinstaller/js/client.es6.js +++ b/build/media_source/plg_installer_webinstaller/js/client.es6.js @@ -37,9 +37,9 @@ if (!Joomla) { const installButton = document.getElementById('uploadform-web-install'); installButton.addEventListener('click', () => { if (webInstallerOptions.options.installFrom === 4) { - Joomla.submitbutton4(); + this.submitButtonUrl(); } else { - Joomla.submitbutton5(); + this.submitButtonWeb(); } }); @@ -195,7 +195,7 @@ if (!Joomla) { if (installExtensionFromExternalButton) { installExtensionFromExternalButton.addEventListener('click', () => { const redirectUrl = installExtensionFromExternalButton.getAttribute('data-downloadurl'); - const redirectConfirm = window.confirm(Joomla.JText._('PLG_INSTALLER_WEBINSTALLER_REDIRECT_TO_EXTERNAL_SITE_TO_INSTALL').replace('[SITEURL]', redirectUrl)); + const redirectConfirm = window.confirm(Joomla.Text._('PLG_INSTALLER_WEBINSTALLER_REDIRECT_TO_EXTERNAL_SITE_TO_INSTALL').replace('[SITEURL]', redirectUrl)); if (redirectConfirm !== true) { return; @@ -332,7 +332,7 @@ if (!Joomla) { */ static installfromweb(installUrl, name = null) { if (!installUrl) { - Joomla.renderMessages({ warning: [Joomla.JText._('PLG_INSTALLER_WEBINSTALLER_CANNOT_INSTALL_EXTENSION_IN_PLUGIN')] }); + Joomla.renderMessages({ warning: [Joomla.Text._('PLG_INSTALLER_WEBINSTALLER_CANNOT_INSTALL_EXTENSION_IN_PLUGIN')] }); return false; } @@ -351,6 +351,39 @@ if (!Joomla) { return true; } + + // eslint-disable-next-line class-methods-use-this + submitButtonUrl() { + const form = document.getElementById('adminForm'); + + // do field validation + if (form.install_url.value === '' || form.install_url.value === 'http://' || form.install_url.value === 'https://') { + Joomla.renderMessages({ warning: [Joomla.Text._('COM_INSTALLER_MSG_INSTALL_ENTER_A_URL')] }); + } else { + const loading = document.getElementById('loading'); + if (loading) { + loading.classList.remove('hidden'); + } + + form.installtype.value = 'url'; + form.submit(); + } + } + + submitButtonWeb() { + const form = document.getElementById('adminForm'); + + // do field validation + if (form.install_url.value !== '' || form.install_url.value !== 'http://' || form.install_url.value !== 'https://') { + this.submitButtonUrl(); + } else if (form.install_url.value === '') { + Joomla.renderMessages({ warning: [Joomla.apps.options.btntxt] }); + } else { + document.querySelector('#appsloading').classList.remove('hidden'); + form.installtype.value = 'web'; + form.submit(); + } + } } document.addEventListener('DOMContentLoaded', () => { diff --git a/plugins/installer/folderinstaller/folderinstaller.php b/plugins/installer/folderinstaller/folderinstaller.php index 3bbb19c2d2a9b..33f5921543e14 100644 --- a/plugins/installer/folderinstaller/folderinstaller.php +++ b/plugins/installer/folderinstaller/folderinstaller.php @@ -20,12 +20,12 @@ class PlgInstallerFolderInstaller extends CMSPlugin { /** - * Load the language file on instantiation. + * Application object. * - * @var boolean - * @since 3.6.0 + * @var \Joomla\CMS\Application\CMSApplication + * @since __DEPLOY_VERSION__ */ - protected $autoloadLanguage = true; + protected $app; /** * Textfield or Form of the Plugin. @@ -36,6 +36,9 @@ class PlgInstallerFolderInstaller extends CMSPlugin */ public function onInstallerAddInstallationTab() { + // Load language files + $this->loadLanguage(); + $tab = array(); $tab['name'] = 'folder'; $tab['label'] = Text::_('PLG_INSTALLER_FOLDERINSTALLER_TEXT'); diff --git a/plugins/installer/folderinstaller/tmpl/default.php b/plugins/installer/folderinstaller/tmpl/default.php index 594657020aef7..fb0efe5f1090e 100644 --- a/plugins/installer/folderinstaller/tmpl/default.php +++ b/plugins/installer/folderinstaller/tmpl/default.php @@ -9,12 +9,22 @@ defined('_JEXEC') or die; -use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; -$app = Factory::getApplication(); -?> +/** @var PlgInstallerFolderInstaller $this */ + +Text::script('PLG_INSTALLER_FOLDERINSTALLER_NO_INSTALL_PATH'); +$this->app->getDocument()->getWebAssetManager() + ->registerAndUseScript( + 'plg_installer_folderinstaller.folderinstaller', + 'plg_installer_folderinstaller/folderinstaller.js', + [], + ['defer' => true], + ['core'] + ); + +?>
@@ -23,7 +33,7 @@
+ value="app->input->get('install_directory', $this->app->get('tmp_path')); ?>">

diff --git a/plugins/installer/packageinstaller/packageinstaller.php b/plugins/installer/packageinstaller/packageinstaller.php index 90ab9de684e44..c5a8c479ce17a 100644 --- a/plugins/installer/packageinstaller/packageinstaller.php +++ b/plugins/installer/packageinstaller/packageinstaller.php @@ -21,12 +21,12 @@ class PlgInstallerPackageInstaller extends CMSPlugin { /** - * Load the language file on instantiation. + * Application object * - * @var boolean - * @since 3.6.0 + * @var \Joomla\CMS\Application\CMSApplication + * @since __DEPLOY_VERSION__ */ - protected $autoloadLanguage = true; + protected $app; /** * Textfield or Form of the Plugin. @@ -37,6 +37,9 @@ class PlgInstallerPackageInstaller extends CMSPlugin */ public function onInstallerAddInstallationTab() { + // Load language files + $this->loadLanguage(); + $tab = array(); $tab['name'] = 'package'; $tab['label'] = Text::_('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_PACKAGE_FILE'); diff --git a/plugins/installer/packageinstaller/tmpl/default.php b/plugins/installer/packageinstaller/tmpl/default.php index 4d06754313f4c..6721472871ebe 100644 --- a/plugins/installer/packageinstaller/tmpl/default.php +++ b/plugins/installer/packageinstaller/tmpl/default.php @@ -9,22 +9,32 @@ defined('_JEXEC') or die; -use Joomla\CMS\Factory; use Joomla\CMS\Filesystem\FilesystemHelper; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; +/** @var PlgInstallerPackageInstaller $this */ + HTMLHelper::_('form.csrf'); +Text::script('PLG_INSTALLER_PACKAGEINSTALLER_NO_PACKAGE'); Text::script('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_ERROR_UNKNOWN'); Text::script('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_ERROR_EMPTY'); Text::script('COM_INSTALLER_MSG_WARNINGS_UPLOADFILETOOBIG'); -$return = Factory::getApplication()->input->getBase64('return'); +$this->app->getDocument()->getWebAssetManager() + ->registerAndUseScript( + 'plg_installer_packageinstaller.packageinstaller', + 'plg_installer_packageinstaller/packageinstaller.js', + [], + ['defer' => true], + ['core'] + ); + +$return = $this->app->input->getBase64('return'); $maxSizeBytes = FilesystemHelper::fileUploadMaxSize(false); $maxSize = HTMLHelper::_('number.bytes', $maxSizeBytes); ?> -
diff --git a/plugins/installer/urlinstaller/tmpl/default.php b/plugins/installer/urlinstaller/tmpl/default.php index 78fa227bdbdac..38072ecd5ced6 100644 --- a/plugins/installer/urlinstaller/tmpl/default.php +++ b/plugins/installer/urlinstaller/tmpl/default.php @@ -11,8 +11,14 @@ use Joomla\CMS\Language\Text; -?> +/** @var PlgInstallerUrlInstaller $this */ + +Text::script('PLG_INSTALLER_URLINSTALLER_NO_URL'); +$this->app->getDocument()->getWebAssetManager() + ->registerAndUseScript('plg_installer_urlinstaller.urlinstaller', 'plg_installer_urlinstaller/urlinstaller.js', [], ['defer' => true], ['core']); + +?>
diff --git a/plugins/installer/urlinstaller/urlinstaller.php b/plugins/installer/urlinstaller/urlinstaller.php index 80d1f9234875d..665111170c3a3 100644 --- a/plugins/installer/urlinstaller/urlinstaller.php +++ b/plugins/installer/urlinstaller/urlinstaller.php @@ -20,12 +20,12 @@ class PlgInstallerUrlInstaller extends CMSPlugin { /** - * Load the language file on instantiation. + * Application object. * - * @var boolean - * @since 3.6.0 + * @var \Joomla\CMS\Application\CMSApplication + * @since __DEPLOY_VERSION__ */ - protected $autoloadLanguage = true; + protected $app; /** * Textfield or Form of the Plugin. @@ -36,6 +36,9 @@ class PlgInstallerUrlInstaller extends CMSPlugin */ public function onInstallerAddInstallationTab() { + // Load language files + $this->loadLanguage(); + $tab = array(); $tab['name'] = 'url'; $tab['label'] = Text::_('PLG_INSTALLER_URLINSTALLER_TEXT'); diff --git a/plugins/installer/webinstaller/tmpl/default.php b/plugins/installer/webinstaller/tmpl/default.php index d3bf09680aede..092cbf5ec2d60 100644 --- a/plugins/installer/webinstaller/tmpl/default.php +++ b/plugins/installer/webinstaller/tmpl/default.php @@ -16,24 +16,23 @@ $dir = $this->isRTL() ? ' dir="ltr"' : ''; ?> -
-

+