MDL-73568 admin: show accepted types for stored file config settings.

Re-factor existing code to make use of file manager class that renders
these details for us by default.

Co-authored-by: Simey Lameze <simey@moodle.com>
This commit is contained in:
Paul Holden 2022-01-12 09:17:49 +00:00
parent ceb41588d2
commit 52992d993c
3 changed files with 7 additions and 14 deletions

View file

@ -303,7 +303,7 @@ class core_files_renderer extends plugin_renderer_base {
} else { } else {
$maxsize = get_string('maxfilesize', 'moodle', $maxbytes); $maxsize = get_string('maxfilesize', 'moodle', $maxbytes);
} }
// TODO MDL-32020 also should say about 'File types accepted'
return '<span>'. $maxsize . '</span>'; return '<span>'. $maxsize . '</span>';
} }

View file

@ -784,9 +784,9 @@ $string['loginpageautofocus'] = 'Autofocus login page form';
$string['loginpageautofocus_help'] = 'Enabling this option improves usability of the login page, but automatically focusing fields may be considered an accessibility issue.'; $string['loginpageautofocus_help'] = 'Enabling this option improves usability of the login page, but automatically focusing fields may be considered an accessibility issue.';
$string['loglifetime'] = 'Keep logs for'; $string['loglifetime'] = 'Keep logs for';
$string['logo'] = 'Logo'; $string['logo'] = 'Logo';
$string['logo_desc'] = 'A full logo to be used as decoration by some themes (such as core themes). This image can be quite high resolution because it will be scaled down for use (and cached for performance). Logos that are wider than they are high usually give better results. Formats accepted: PNG and JPG.'; $string['logo_desc'] = 'A full logo to be used as decoration by some themes (such as core themes). This image can be quite high resolution because it will be scaled down for use (and cached for performance). Logos that are wider than they are high usually give better results.';
$string['logocompact'] = 'Compact logo'; $string['logocompact'] = 'Compact logo';
$string['logocompact_desc'] = 'A compact version of the same logo as above, such as an emblem, shield or icon. The image should be clear even at small sizes. Formats accepted: PNG and JPG.'; $string['logocompact_desc'] = 'A compact version of the same logo as above, such as an emblem, shield or icon. The image should be clear even at small sizes.';
$string['logossettings'] = 'Logos'; $string['logossettings'] = 'Logos';
$string['logstorenotrequired'] = 'Log store not required'; $string['logstorenotrequired'] = 'Log store not required';
$string['logstoressupported'] = 'Log stores that support this report'; $string['logstoressupported'] = 'Log stores that support this report';

View file

@ -10764,7 +10764,7 @@ class admin_setting_configstoredfile extends admin_setting {
} }
public function output_html($data, $query = '') { public function output_html($data, $query = '') {
global $PAGE, $CFG; global $CFG;
$options = $this->get_options(); $options = $this->get_options();
$id = $this->get_id(); $id = $this->get_id();
@ -10780,24 +10780,17 @@ class admin_setting_configstoredfile extends admin_setting {
$fmoptions->mainfile = $options['mainfile']; $fmoptions->mainfile = $options['mainfile'];
$fmoptions->maxbytes = $options['maxbytes']; $fmoptions->maxbytes = $options['maxbytes'];
$fmoptions->maxfiles = $options['maxfiles']; $fmoptions->maxfiles = $options['maxfiles'];
$fmoptions->client_id = uniqid();
$fmoptions->itemid = $draftitemid;
$fmoptions->subdirs = $options['subdirs']; $fmoptions->subdirs = $options['subdirs'];
$fmoptions->target = $id;
$fmoptions->accepted_types = $options['accepted_types']; $fmoptions->accepted_types = $options['accepted_types'];
$fmoptions->return_types = $options['return_types']; $fmoptions->return_types = $options['return_types'];
$fmoptions->context = $options['context']; $fmoptions->context = $options['context'];
$fmoptions->areamaxbytes = $options['areamaxbytes']; $fmoptions->areamaxbytes = $options['areamaxbytes'];
$fm = new form_filemanager($fmoptions); $fm = new MoodleQuickForm_filemanager($elname, $this->visiblename, ['id' => $id], $fmoptions);
$output = $PAGE->get_renderer('core', 'files'); $fm->setValue($draftitemid);
$html = $output->render($fm);
$html .= '<input value="'.$draftitemid.'" name="'.$elname.'" type="hidden" />';
$html .= '<input value="" id="'.$id.'" type="hidden" />';
return format_admin_setting($this, $this->visiblename, return format_admin_setting($this, $this->visiblename,
'<div class="form-filemanager" data-fieldtype="filemanager">'.$html.'</div>', '<div class="form-filemanager" data-fieldtype="filemanager">' . $fm->toHtml() . '</div>',
$this->description, true, '', '', $query); $this->description, true, '', '', $query);
} }
} }