Merge branch 'MDL-86616_501' of https://github.com/timhunt/moodle into MOODLE_501_STABLE
This commit is contained in:
@@ -290,7 +290,13 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element implements temp
|
||||
$html .= html_writer::empty_tag('input', array('value' => $draftitemid, 'name' => $elname, 'type' => 'hidden', 'id' => $id));
|
||||
|
||||
if (!empty($options->accepted_types) && $options->accepted_types != '*') {
|
||||
$html .= html_writer::tag('div', get_string('filesofthesetypes', 'form'), ['class' => 'mt-1']);
|
||||
$html .= html_writer::tag(
|
||||
'div',
|
||||
get_string('filesofthesetypes', 'form'),
|
||||
[
|
||||
'class' => 'filetypes-descriptions-intro mt-1',
|
||||
],
|
||||
);
|
||||
$util = new \core_form\filetypes_util();
|
||||
$filetypes = $options->accepted_types;
|
||||
$filetypedescriptions = $util->describe_file_types($filetypes);
|
||||
|
||||
@@ -185,7 +185,13 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input implements templat
|
||||
$html .= '</noscript>';
|
||||
|
||||
if (!empty($args->accepted_types) && $args->accepted_types != '*') {
|
||||
$html .= html_writer::tag('div', get_string('filesofthesetypes', 'form'), ['class' => 'mt-1']);
|
||||
$html .= html_writer::tag(
|
||||
'div',
|
||||
get_string('filesofthesetypes', 'form'),
|
||||
[
|
||||
'class' => 'filetypes-descriptions-intro mt-1',
|
||||
],
|
||||
);
|
||||
$util = new \core_form\filetypes_util();
|
||||
$filetypedescriptions = $util->describe_file_types($args->accepted_types);
|
||||
$html .= $OUTPUT->render_from_template('core_form/filetypes-descriptions', $filetypedescriptions);
|
||||
|
||||
@@ -175,7 +175,11 @@ class qtype_essay_renderer extends qtype_renderer {
|
||||
|
||||
$text = '';
|
||||
if (!empty($qa->get_question()->filetypeslist)) {
|
||||
$text = html_writer::tag('p', get_string('acceptedfiletypes', 'qtype_essay'));
|
||||
$text = html_writer::tag(
|
||||
'div',
|
||||
get_string('acceptedfiletypes', 'qtype_essay'),
|
||||
['class' => 'filetypes-descriptions-intro mt-1'],
|
||||
);
|
||||
$filetypesutil = new \core_form\filetypes_util();
|
||||
$filetypes = $qa->get_question()->filetypeslist;
|
||||
$filetypedescriptions = $filetypesutil->describe_file_types($filetypes);
|
||||
|
||||
@@ -1892,7 +1892,75 @@ M.core_filepicker.init = function(Y, options) {
|
||||
node.all('label').set('for', node.one('input,select').generateID());
|
||||
});
|
||||
content.one('form').set('id', id);
|
||||
content.one('.fp-file input').set('name', 'repo_upload_file');
|
||||
// Define element IDs.
|
||||
const ids = {
|
||||
restrictionsSpan: 'fp-restrictions-span-' + client_id,
|
||||
filetypesDescriptions: 'form-filetypes-descriptions-' + client_id,
|
||||
filetypesDescriptionsIntro: 'filetypes-descriptions-intro-' + client_id,
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets unique IDs for file type restriction and description elements within the file picker or file manager wrapper.
|
||||
*
|
||||
* @param {Y.Node} wrapper - The YUI Node wrapper element to search within (e.g., filepicker or filemanager wrapper).
|
||||
* @param {Object} ids - An object containing the IDs to assign to relevant elements.
|
||||
* - restrictionsSpan: ID for the restrictions span element.
|
||||
* - filetypesDescriptions: ID for the file types descriptions element.
|
||||
* - filetypesDescriptionsIntro: ID for the file types descriptions intro element.
|
||||
*/
|
||||
function setFileTypeIds(wrapper, ids) {
|
||||
if (!wrapper) {
|
||||
return {
|
||||
hasRestrictionSpan: false,
|
||||
hasFiletypesDescriptions: false,
|
||||
hasFiletypesDescriptionsIntro: false,
|
||||
};
|
||||
}
|
||||
const parent = wrapper.get('parentNode');
|
||||
const restrictionSpan = wrapper.one('.fp-restrictions span');
|
||||
if (restrictionSpan) {
|
||||
restrictionSpan.set('id', ids.restrictionsSpan);
|
||||
}
|
||||
const filetypesDescriptions = parent.one('.form-filetypes-descriptions');
|
||||
if (filetypesDescriptions) {
|
||||
filetypesDescriptions.set('id', ids.filetypesDescriptions);
|
||||
}
|
||||
const filetypesDescriptionsIntro = parent.one('.filetypes-descriptions-intro');
|
||||
if (filetypesDescriptionsIntro) {
|
||||
filetypesDescriptionsIntro.set('id', ids.filetypesDescriptionsIntro);
|
||||
}
|
||||
return {
|
||||
hasRestrictionSpan: !!restrictionSpan,
|
||||
hasFiletypesDescriptions: !!filetypesDescriptions,
|
||||
hasFiletypesDescriptionsIntro: !!filetypesDescriptionsIntro,
|
||||
};
|
||||
}
|
||||
|
||||
const filepickerIdsSet = setFileTypeIds(Y.one('#filepicker-wrapper-' + client_id), ids);
|
||||
const filemanagerIdsSet = setFileTypeIds(Y.one('#filemanager-' + client_id), ids);
|
||||
|
||||
let idsToDescribe = '';
|
||||
// Set value of aria-describedby.
|
||||
if (filepickerIdsSet.hasRestrictionSpan || filemanagerIdsSet.hasRestrictionSpan) {
|
||||
idsToDescribe += ids.restrictionsSpan;
|
||||
}
|
||||
if (filepickerIdsSet.hasFiletypesDescriptionsIntro || filemanagerIdsSet.hasFiletypesDescriptionsIntro) {
|
||||
if (idsToDescribe.length > 0) {
|
||||
idsToDescribe += ' ';
|
||||
}
|
||||
idsToDescribe += ids.filetypesDescriptionsIntro;
|
||||
}
|
||||
if (filepickerIdsSet.hasFiletypesDescriptions || filemanagerIdsSet.hasFiletypesDescriptions) {
|
||||
if (idsToDescribe.length > 0) {
|
||||
idsToDescribe += ' ';
|
||||
}
|
||||
idsToDescribe += ids.filetypesDescriptions;
|
||||
}
|
||||
|
||||
content
|
||||
.one('.fp-file input')
|
||||
.set('name', 'repo_upload_file')
|
||||
.set('aria-describedby', idsToDescribe);
|
||||
if (data.upload.label && content.one('.fp-file label')) {
|
||||
content.one('.fp-file label').setContent(data.upload.label);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user