Skip to content

Commit 7708e3c

Browse files
authored
[5.4] Fix issues in language installer (joomla#46403)
* Hide autoupdate box when installing languages * Fix loader when installing the language * Fix auto update disabled
1 parent ba3613c commit 7708e3c

File tree

5 files changed

+44
-8
lines changed

5 files changed

+44
-8
lines changed

installation/src/Model/ChecksModel.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Joomla\CMS\Installation\Model;
1212

13+
use Joomla\CMS\Component\ComponentHelper;
1314
use Joomla\CMS\Factory;
1415
use Joomla\CMS\Form\Form;
1516
use Joomla\CMS\Language\Text;
@@ -253,4 +254,18 @@ public function getForm($view = null)
253254

254255
return $form;
255256
}
257+
258+
/**
259+
* Check if auto updates are disabled
260+
*
261+
* @return boolean
262+
*
263+
* @since __DEPLOY_VERSION__
264+
*/
265+
public function getAutoUpdatesDisabled(): bool
266+
{
267+
$updates = ComponentHelper::getParams('com_joomlaupdate');
268+
269+
return !$updates->get('autoupdate', 0) && !$updates->get('autoupdate_status', 0);
270+
}
256271
}

installation/src/View/Remove/HtmlView.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ class HtmlView extends BaseHtmlView
6666
*/
6767
protected $installed_languages;
6868

69+
/**
70+
* If updates are disabled, we hide the box
71+
*
72+
* @var boolean
73+
* @since __DEPLOY_VERSION__
74+
*/
75+
protected $autoUpdatesDisabled = false;
76+
6977
/**
7078
* Execute and display a template script.
7179
*
@@ -92,6 +100,8 @@ public function display($tpl = null)
92100
$this->phpoptions = $checksModel->getPhpOptions();
93101
$this->phpsettings = $checksModel->getPhpSettings();
94102

103+
$this->autoUpdatesDisabled = $checksModel->getAutoUpdatesDisabled();
104+
95105
parent::display($tpl);
96106
}
97107
}

installation/template/js/remove.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ if (document.getElementById('installAddFeatures')) {
1010
document.getElementById('installAddFeatures').addEventListener('click', function(e) {
1111
e.preventDefault();
1212
document.getElementById('installLanguages').classList.add('active');
13+
document.getElementById('automatedUpdates')?.classList?.remove('active');
1314
document.getElementById('installCongrat').classList.remove('active');
1415
document.getElementById('installFinal').classList.remove('active');
1516
document.getElementById('installRecommended').classList.remove('active');
@@ -19,6 +20,7 @@ if (document.getElementById('installAddFeatures')) {
1920
if (document.getElementById('skipLanguages')) {
2021
document.getElementById('skipLanguages').addEventListener('click', function(e) {
2122
e.preventDefault();
23+
document.getElementById('automatedUpdates')?.classList?.add('active');
2224
document.getElementById('installCongrat').classList.add('active');
2325
document.getElementById('installFinal').classList.add('active');
2426
document.getElementById('installRecommended').classList.add('active');
@@ -165,12 +167,19 @@ if (document.getElementById('installLanguagesButton')) {
165167
document.getElementById('installLanguagesButton').addEventListener('click', function(e) {
166168
e.preventDefault();
167169
var form = document.getElementById('languagesForm');
168-
if (form) {
170+
if (form) {
171+
Joomla.removeMessages();
172+
document.body.appendChild(document.createElement('joomla-core-loader'));
173+
169174
// Install the extra languages
170-
if (Joomla.install(['languages'], form)) {
171-
document.getElementById('installLanguages').classList.remove('active');
172-
document.getElementById('installFinal').classList.add('active');
173-
}
175+
try {
176+
Joomla.install(['languages'], form, true);
177+
} catch (err) {
178+
const loader = document.querySelector('joomla-core-loader');
179+
if (loader) {
180+
loader.remove();
181+
}
182+
}
174183
}
175184
})
176185
}

installation/template/js/template.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
*
154154
* @param tasks An array of install tasks to execute
155155
*/
156-
Joomla.install = function(tasks, form) {
156+
Joomla.install = function(tasks, form, fromSubmit) {
157157
const progress = document.getElementById('progressbar');
158158
const progress_text = document.getElementById('progress-text');
159159
if (!form) {
@@ -163,7 +163,7 @@
163163
if (progress_text) {
164164
progress_text.innerText = Joomla.Text._('INSTL_FINISHED');
165165
}
166-
setTimeout(Joomla.goToPage, 2000, 'remove');
166+
setTimeout(Joomla.goToPage, 2000, 'remove', fromSubmit);
167167
return;
168168
}
169169

@@ -226,7 +226,7 @@
226226
progress.setAttribute('value', parseInt(progress.getAttribute('value')) + 1);
227227
progress_text.innerText = Joomla.Text._('INSTL_IN_PROGRESS');
228228
}
229-
Joomla.install(tasks, form);
229+
Joomla.install(tasks, form, fromSubmit);
230230
},
231231
onError: function(xhr){
232232
if (progress_text) {

installation/tmpl/remove/default.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class="form-check-input"
139139
</div>
140140
</fieldset>
141141

142+
<?php if (empty($this->autoUpdatesDisabled)) : ?>
142143
<fieldset id="automatedUpdates" class="j-install-step active">
143144
<legend class="j-install-step-header">
144145
<?php echo Text::_('INSTL_AUTOMATED_UPDATES'); ?>
@@ -151,6 +152,7 @@ class="form-check-input"
151152
</button>
152153
</div>
153154
</fieldset>
155+
<?php endif; ?>
154156

155157
<div id="installRecommended" class="j-install-step active">
156158
<div class="j-install-step-form">

0 commit comments

Comments
 (0)