Skip to content

Commit

Permalink
Merge branch '5.0-dev' into tours-alias-language
Browse files Browse the repository at this point in the history
  • Loading branch information
obuisard authored Sep 2, 2023
2 parents 263d0ef + 5dd26bd commit 9e9000b
Show file tree
Hide file tree
Showing 20 changed files with 248 additions and 51 deletions.
1 change: 1 addition & 0 deletions administrator/components/com_fields/forms/field.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
type="text"
label="COM_FIELDS_FIELD_SHOWON_LABEL"
description="COM_FIELDS_FIELD_SHOWON_DESC"
validate="ShowOn"
/>

</fieldset>
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_finder/src/Indexer/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,12 +836,12 @@ protected function tokenizeToDb($input, $context, $lang, $format, $count = 0)
*/
if (!feof($input)) {
// Find the last space character.
$ls = StringHelper::strrpos($buffer, ' ');
$ls = strrpos($buffer, ' ');

// Adjust string based on the last space character.
if ($ls) {
// Truncate the string to the last space character.
$string = StringHelper::substr($buffer, 0, $ls);
$string = substr($buffer, 0, $ls);

// Adjust the buffer based on the last space for the next iteration and trim.
$buffer = StringHelper::trim(substr($buffer, $ls));
Expand Down
11 changes: 5 additions & 6 deletions administrator/components/com_finder/src/Indexer/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

use Joomla\CMS\Filter\InputFilter;
use Joomla\CMS\Language\Text;
use Joomla\String\StringHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -81,26 +80,26 @@ public static function getInstance($format)
public function parse($input)
{
// If the input is less than 2KB we can parse it in one go.
if (StringHelper::strlen($input) <= 2048) {
if (strlen($input) <= 2048) {
return $this->process($input);
}

// Input is longer than 2Kb so parse it in chunks of 2Kb or less.
$start = 0;
$end = StringHelper::strlen($input);
$end = strlen($input);
$chunk = 2048;
$return = null;

while ($start < $end) {
// Setup the string.
$string = StringHelper::substr($input, $start, $chunk);
$string = substr($input, $start, $chunk);

// Find the last space character if we aren't at the end.
$ls = (($start + $chunk) < $end ? StringHelper::strrpos($string, ' ') : false);
$ls = (($start + $chunk) < $end ? strrpos($string, ' ') : false);

// Truncate to the last space character.
if ($ls !== false) {
$string = StringHelper::substr($string, 0, $ls);
$string = substr($string, 0, $ls);
}

// Adjust the start position for the next iteration.
Expand Down
15 changes: 7 additions & 8 deletions administrator/components/com_finder/src/Indexer/Parser/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace Joomla\Component\Finder\Administrator\Indexer\Parser;

use Joomla\Component\Finder\Administrator\Indexer\Parser;
use Joomla\String\StringHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -118,11 +117,11 @@ private function removeBlocks($input, $startTag, $endTag)
{
$return = '';
$offset = 0;
$startTagLength = StringHelper::strlen($startTag);
$endTagLength = StringHelper::strlen($endTag);
$startTagLength = strlen($startTag);
$endTagLength = strlen($endTag);

// Find the first start tag.
$start = StringHelper::stripos($input, $startTag);
$start = stripos($input, $startTag);

// If no start tags were found, return the string unchanged.
if ($start === false) {
Expand All @@ -132,10 +131,10 @@ private function removeBlocks($input, $startTag, $endTag)
// Look for all blocks defined by the start and end tags.
while ($start !== false) {
// Accumulate the substring up to the start tag.
$return .= StringHelper::substr($input, $offset, $start - $offset) . ' ';
$return .= substr($input, $offset, $start - $offset) . ' ';

// Look for an end tag corresponding to the start tag.
$end = StringHelper::stripos($input, $endTag, $start + $startTagLength);
$end = stripos($input, $endTag, $start + $startTagLength);

// If no corresponding end tag, leave the string alone.
if ($end === false) {
Expand All @@ -148,11 +147,11 @@ private function removeBlocks($input, $startTag, $endTag)
$offset = $end + $endTagLength;

// Look for the next start tag and loop.
$start = StringHelper::stripos($input, $startTag, $offset);
$start = stripos($input, $startTag, $offset);
}

// Add in the final substring after the last end tag.
$return .= StringHelper::substr($input, $offset);
$return .= substr($input, $offset);

return $return;
}
Expand Down
6 changes: 3 additions & 3 deletions administrator/components/com_media/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
type="textarea"
label="COM_MEDIA_FIELD_RESTRICT_UPLOADS_EXTENSIONS_LABEL"
description="COM_MEDIA_FIELD_RESTRICT_UPLOADS_EXTENSIONS_DESC"
default="bmp,gif,jpg,jpeg,png,webp,ico,mp3,mp4,odg,odp,ods,odt,pdf,png,ppt,txt,xcf,xls,csv"
default="bmp,gif,jpg,jpeg,png,webp,avif,ico,mp3,mp4,odg,odp,ods,odt,pdf,png,ppt,txt,xcf,xls,csv"
showon="restrict_uploads:1"
/>

Expand All @@ -77,7 +77,7 @@
type="textarea"
label="COM_MEDIA_FIELD_LEGAL_IMAGE_EXTENSIONS_LABEL"
description="COM_MEDIA_FIELD_LEGAL_IMAGE_EXTENSIONS_DESC"
default="bmp,gif,jpg,jpeg,png,webp"
default="bmp,gif,jpg,jpeg,png,webp,avif"
/>

<field
Expand Down Expand Up @@ -116,7 +116,7 @@
type="textarea"
label="COM_MEDIA_FIELD_LEGAL_MIME_TYPES_LABEL"
description="COM_MEDIA_FIELD_LEGAL_MIME_TYPES_DESC"
default="image/jpeg,image/gif,image/png,image/bmp,image/webp,audio/ogg,audio/mpeg,audio/mp4,video/mp4,video/mpeg,video/quicktime,video/webm,application/msword,application/excel,application/pdf,application/powerpoint,text/plain,application/x-zip"
default="image/jpeg,image/gif,image/png,image/bmp,image/webp,image/avif,audio/ogg,audio/mpeg,audio/mp4,video/mp4,video/mpeg,video/quicktime,video/webm,application/msword,application/excel,application/pdf,application/powerpoint,text/plain,application/x-zip"
showon="restrict_uploads:1"
/>
</fieldset>
Expand Down
21 changes: 21 additions & 0 deletions build/media_source/templates/site/cassiopeia/scss/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,24 @@ span[lang] {
content: attr(lang);
}
}

.float-start {
float: left;
}

.float-end {
float: right;
}

.float-none {
float: none;
}

.mx-auto {
margin-right: auto !important;
margin-left: auto !important;
}

.d-block {
display: block !important;
}
6 changes: 6 additions & 0 deletions installation/language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,9 @@ JLIB_FORM_CONTAINS_INVALID_FIELDS="The form cannot be submitted as it's missing
JLIB_FORM_FIELD_INVALID_VALUE="This value is not valid."
JLIB_FORM_FIELD_REQUIRED_CHECK="One of the options must be selected."
JLIB_FORM_FIELD_REQUIRED_VALUE="Please fill in this field."

; Installation progress screen
INSTL="Installation"
INSTL_FINISHED="Installation finished"
INSTL_IN_PROGRESS="Installation running"
INSTL_PROGRESS="Installation Progress"
2 changes: 1 addition & 1 deletion installation/sql/mysql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`,
(0, 'com_installer', 'component', 'com_installer', '', 1, 1, 1, 1, 1, '', '{"cachetimeout":"6","minimum_stability":"4"}', ''),
(0, 'com_languages', 'component', 'com_languages', '', 1, 1, 1, 1, 1, '', '{"administrator":"en-GB","site":"en-GB"}', ''),
(0, 'com_login', 'component', 'com_login', '', 1, 1, 1, 1, 1, '', '', ''),
(0, 'com_media', 'component', 'com_media', '', 1, 1, 0, 1, 1, '', '{"upload_maxsize":"10","file_path":"images","image_path":"images","restrict_uploads":"1","allowed_media_usergroup":"3","restrict_uploads_extensions":"bmp,gif,jpg,jpeg,png,webp,ico,mp3,m4a,mp4a,ogg,mp4,mp4v,mpeg,mov,odg,odp,ods,odt,pdf,png,ppt,txt,xcf,xls,csv","check_mime":"1","image_extensions":"bmp,gif,jpg,png,jpeg,webp","audio_extensions":"mp3,m4a,mp4a,ogg","video_extensions":"mp4,mp4v,mpeg,mov,webm","doc_extensions":"odg,odp,ods,odt,pdf,ppt,txt,xcf,xls,csv","ignore_extensions":"","upload_mime":"image\\/jpeg,image\\/gif,image\\/png,image\\/bmp,image\\/webp,audio\\/ogg,audio\\/mpeg,audio\\/mp4,video\\/mp4,video\\/webm,video\\/mpeg,video\\/quicktime,application\\/msword,application\\/excel,application\\/pdf,application\\/powerpoint,text\\/plain,application\\/x-zip"}', ''),
(0, 'com_media', 'component', 'com_media', '', 1, 1, 0, 1, 1, '', '{"upload_maxsize":"10","file_path":"images","image_path":"images","restrict_uploads":"1","allowed_media_usergroup":"3","restrict_uploads_extensions":"bmp,gif,jpg,jpeg,png,webp,avif,ico,mp3,m4a,mp4a,ogg,mp4,mp4v,mpeg,mov,odg,odp,ods,odt,pdf,png,ppt,txt,xcf,xls,csv","check_mime":"1","image_extensions":"bmp,gif,jpg,png,jpeg,webp,avif","audio_extensions":"mp3,m4a,mp4a,ogg","video_extensions":"mp4,mp4v,mpeg,mov,webm","doc_extensions":"odg,odp,ods,odt,pdf,ppt,txt,xcf,xls,csv","ignore_extensions":"","upload_mime":"image\\/jpeg,image\\/gif,image\\/png,image\\/bmp,image\\/webp,image\\/avif,audio\\/ogg,audio\\/mpeg,audio\\/mp4,video\\/mp4,video\\/webm,video\\/mpeg,video\\/quicktime,application\\/msword,application\\/excel,application\\/pdf,application\\/powerpoint,text\\/plain,application\\/x-zip"}', ''),
(0, 'com_menus', 'component', 'com_menus', '', 1, 1, 1, 1, 1, '', '{"page_title":"","show_page_heading":0,"page_heading":"","pageclass_sfx":""}', ''),
(0, 'com_messages', 'component', 'com_messages', '', 1, 1, 1, 1, 1, '', '', ''),
(0, 'com_modules', 'component', 'com_modules', '', 1, 1, 1, 1, 1, '', '', ''),
Expand Down
2 changes: 1 addition & 1 deletion installation/sql/postgresql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder",
(0, 'com_installer', 'component', 'com_installer', '', 1, 1, 1, 1, 1, '', '{"cachetimeout":"6","minimum_stability":"4"}', '', 0, 0),
(0, 'com_languages', 'component', 'com_languages', '', 1, 1, 1, 1, 1, '', '{"administrator":"en-GB","site":"en-GB"}', '', 0, 0),
(0, 'com_login', 'component', 'com_login', '', 1, 1, 1, 1, 1, '', '', '', 0, 0),
(0, 'com_media', 'component', 'com_media', '', 1, 1, 0, 1, 1, '', '{"upload_maxsize":"10","file_path":"images","image_path":"images","restrict_uploads":"1","allowed_media_usergroup":"3","restrict_uploads_extensions":"bmp,gif,jpg,jpeg,png,ico,webp,mp3,m4a,mp4a,ogg,mp4,mp4v,mpeg,mov,odg,odp,ods,odt,pdf,png,ppt,txt,xcf,xls,csv","check_mime":"1","image_extensions":"bmp,gif,jpg,png,jpeg,webp","audio_extensions":"mp3,m4a,mp4a,ogg","video_extensions":"mp4,mp4v,mpeg,mov,webm","doc_extensions":"odg,odp,ods,odt,pdf,ppt,txt,xcf,xls,csv","ignore_extensions":"","upload_mime":"image\\/jpeg,image\\/gif,image\\/png,image\\/bmp,image\\/webp,audio\\/ogg,audio\\/mpeg,audio\\/mp4,video\\/mp4,video\\/webm,video\\/mpeg,video\\/quicktime,application\\/msword,application\\/excel,application\\/pdf,application\\/powerpoint,text\\/plain,application\\/x-zip"}', '', 0, 0),
(0, 'com_media', 'component', 'com_media', '', 1, 1, 0, 1, 1, '', '{"upload_maxsize":"10","file_path":"images","image_path":"images","restrict_uploads":"1","allowed_media_usergroup":"3","restrict_uploads_extensions":"bmp,gif,jpg,jpeg,png,ico,webp,avif,mp3,m4a,mp4a,ogg,mp4,mp4v,mpeg,mov,odg,odp,ods,odt,pdf,png,ppt,txt,xcf,xls,csv","check_mime":"1","image_extensions":"bmp,gif,jpg,png,jpeg,webp,avif","audio_extensions":"mp3,m4a,mp4a,ogg","video_extensions":"mp4,mp4v,mpeg,mov,webm","doc_extensions":"odg,odp,ods,odt,pdf,ppt,txt,xcf,xls,csv","ignore_extensions":"","upload_mime":"image\\/jpeg,image\\/gif,image\\/png,image\\/bmp,image\\/webp,image\\/avif,audio\\/ogg,audio\\/mpeg,audio\\/mp4,video\\/mp4,video\\/webm,video\\/mpeg,video\\/quicktime,application\\/msword,application\\/excel,application\\/pdf,application\\/powerpoint,text\\/plain,application\\/x-zip"}', '', 0, 0),
(0, 'com_menus', 'component', 'com_menus', '', 1, 1, 1, 1, 1, '', '{"page_title":"","show_page_heading":0,"page_heading":"","pageclass_sfx":""}', '', 0, 0),
(0, 'com_messages', 'component', 'com_messages', '', 1, 1, 1, 1, 1, '', '', '', 0, 0),
(0, 'com_modules', 'component', 'com_modules', '', 1, 1, 1, 1, 1, '', '', '', 0, 0),
Expand Down
21 changes: 16 additions & 5 deletions installation/src/Controller/InstallationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,20 @@ public function dbcheck()
if ($data === false) {
$this->app->enqueueMessage(Text::_('INSTL_DATABASE_VALIDATION_ERROR'), 'error');
$r->validated = false;
$r->error = true;
$this->sendJsonResponse($r);

return;
}

$data = $model->storeOptions($data);

$r->validated = $model->validateDbConnection($data);
if (!$model->validateDbConnection($data)) {
$r->validated = false;
$r->error = true;
} else {
$r->validated = true;
}

$this->sendJsonResponse($r);
}
Expand Down Expand Up @@ -121,10 +127,12 @@ public function create()
}

if (!$dbCreated) {
$r->view = 'setup';
$r->view = 'setup';
$r->error = true;
} else {
if (!$databaseModel->handleOldDatabase($options)) {
$r->view = 'setup';
$r->view = 'setup';
$r->error = true;
}
}

Expand Down Expand Up @@ -168,12 +176,14 @@ public function populate()
if (!isset($files[$step])) {
$r->view = 'setup';
$this->app->enqueueMessage(Text::_('INSTL_SAMPLE_DATA_NOT_FOUND'), 'error');
$r->error = true;
$this->sendJsonResponse($r);
}

// Attempt to populate the database with the given file.
if (!$model->createTables($schema, $options)) {
$r->view = 'setup';
$r->view = 'setup';
$r->error = true;
}

$this->sendJsonResponse($r);
Expand Down Expand Up @@ -204,7 +214,8 @@ public function config()

// Attempt to setup the configuration.
if (!$configurationModel->setup($options)) {
$r->view = 'setup';
$r->view = 'setup';
$r->error = true;
}

$this->sendJsonResponse($r);
Expand Down
5 changes: 5 additions & 0 deletions installation/src/Response/JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ public function __construct($data)
} else {
// Prepare the response data.
$this->error = false;

if (isset($data->error) && $data->error) {
$this->error = true;
}

$this->data = $data;
}
}
Expand Down
5 changes: 5 additions & 0 deletions installation/template/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
Text::script('JLIB_JS_AJAX_ERROR_TIMEOUT');
Text::script('INSTL_DATABASE_RESPONSE_ERROR');

// Add strings for installation progress
Text::script('INSTL');
Text::script('INSTL_FINISHED');
Text::script('INSTL_IN_PROGRESS');

// Load the JavaScript translated messages
Text::script('INSTL_PROCESS_BUSY');

Expand Down
39 changes: 29 additions & 10 deletions installation/template/js/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,36 +58,50 @@ Joomla.checkInputs = function() {
inputs.forEach(function(item) {
if (!item.valid) state = false;
});
document.getElementById('progress-text').classList.remove('error');
document.getElementById('progress-text').setAttribute('role', 'status');
document.getElementById('progress-text').innerText = Joomla.Text._('INSTL_IN_PROGRESS');
document.getElementById('progressbar').setAttribute('value', 0);

// Reveal everything
document.getElementById('installStep1').classList.add('active');
document.getElementById('installStep2').classList.add('active');
document.getElementById('installStep3').classList.add('active');


if (Joomla.checkFormField(['#jform_site_name', '#jform_admin_user', '#jform_admin_email', '#jform_admin_password', '#jform_db_type', '#jform_db_host', '#jform_db_user', '#jform_db_name'])) {
Joomla.checkDbCredentials();
}
};


Joomla.checkDbCredentials = function() {
document.body.appendChild(document.createElement('joomla-core-loader'));
const progress = document.getElementById('progressbar');
const progress_text = document.getElementById('progress-text');
var form = document.getElementById('adminForm'),
data = Joomla.serialiseForm(form);

// Remove potential messages
Joomla.removeMessages();

// Hide form and show progress bar
document.getElementById('installStep1').classList.remove('active');
document.getElementById('installStep2').classList.remove('active');
document.getElementById('installStep3').classList.remove('active');
document.getElementById('installStep4').classList.add('active');
progress_text.innerText = Joomla.Text._('INSTL_IN_PROGRESS');

Joomla.request({
method: "POST",
url : Joomla.installationBaseUrl + '?task=installation.dbcheck&format=json',
data: data,
perform: true,
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
onSuccess: function(response, xhr){
var loaderElement = document.querySelector('joomla-core-loader');
try {
response = JSON.parse(response);
} catch (e) {
loaderElement.parentNode.removeChild(loaderElement);
progress_text.setAttribute('role', 'alert');
progress_text.classList.add('error');
progress_text.innerText = response;
console.error('Error in DB Check Endpoint');
console.error(response);
Joomla.renderMessages({'error': [Joomla.Text._('INSTL_DATABASE_RESPONSE_ERROR')]});
Expand All @@ -100,21 +114,27 @@ Joomla.checkDbCredentials = function() {
}

Joomla.replaceTokens(response.token);
loaderElement.parentNode.removeChild(loaderElement);

if (response.error) {
Joomla.renderMessages({'error': [response.message]});
document.getElementById('installStep1').classList.add('active');
document.getElementById('installStep2').classList.add('active');
document.getElementById('installStep3').classList.add('active');
document.getElementById('installStep4').classList.remove('active');
progress_text.innerText = Joomla.Text._('INSTL');
} else if (response.data && response.data.validated === true) {
// Run the installer - we let this handle the redirect for now
// @todo: Convert to promises
progress.setAttribute('value', parseInt(progress.getAttribute('value')) + 1);
progress_text.innerText = Joomla.Text._('INSTL_IN_PROGRESS');
Joomla.install(['create', 'populate1', 'populate2', 'populate3', 'custom1', 'custom2', 'config'], form);
}
},
onError: function(xhr){
Joomla.renderMessages([['', Joomla.Text._('JLIB_DATABASE_ERROR_DATABASE_CONNECT', 'A Database error occurred.')]]);
progress_text.setAttribute('role', 'alert');
progress_text.classList.add('error');
progress_text.innerText = response.message;
//Install.goToPage('summary');
var loaderElement = document.querySelector('joomla-core-loader');
loaderElement.parentNode.removeChild(loaderElement);

try {
var r = JSON.parse(xhr.responseText);
Expand Down Expand Up @@ -199,5 +219,4 @@ Joomla.checkDbCredentials = function() {
Joomla.checkInputs();
})
}

})();
Loading

0 comments on commit 9e9000b

Please sign in to comment.