From 52992d993caee44289e2f36a6b9fccd2d34f032f Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Wed, 12 Jan 2022 09:17:49 +0000 Subject: [PATCH] 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 --- files/renderer.php | 2 +- lang/en/admin.php | 4 ++-- lib/adminlib.php | 15 ++++----------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/files/renderer.php b/files/renderer.php index 90eca4b294c..14c8b358752 100644 --- a/files/renderer.php +++ b/files/renderer.php @@ -303,7 +303,7 @@ class core_files_renderer extends plugin_renderer_base { } else { $maxsize = get_string('maxfilesize', 'moodle', $maxbytes); } - // TODO MDL-32020 also should say about 'File types accepted' + return ''. $maxsize . ''; } diff --git a/lang/en/admin.php b/lang/en/admin.php index e3a56980622..008e6049d4b 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -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['loglifetime'] = 'Keep logs for'; $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_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['logstorenotrequired'] = 'Log store not required'; $string['logstoressupported'] = 'Log stores that support this report'; diff --git a/lib/adminlib.php b/lib/adminlib.php index 65c04420d3d..91bc7b489e2 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -10764,7 +10764,7 @@ class admin_setting_configstoredfile extends admin_setting { } public function output_html($data, $query = '') { - global $PAGE, $CFG; + global $CFG; $options = $this->get_options(); $id = $this->get_id(); @@ -10780,24 +10780,17 @@ class admin_setting_configstoredfile extends admin_setting { $fmoptions->mainfile = $options['mainfile']; $fmoptions->maxbytes = $options['maxbytes']; $fmoptions->maxfiles = $options['maxfiles']; - $fmoptions->client_id = uniqid(); - $fmoptions->itemid = $draftitemid; $fmoptions->subdirs = $options['subdirs']; - $fmoptions->target = $id; $fmoptions->accepted_types = $options['accepted_types']; $fmoptions->return_types = $options['return_types']; $fmoptions->context = $options['context']; $fmoptions->areamaxbytes = $options['areamaxbytes']; - $fm = new form_filemanager($fmoptions); - $output = $PAGE->get_renderer('core', 'files'); - $html = $output->render($fm); - - $html .= ''; - $html .= ''; + $fm = new MoodleQuickForm_filemanager($elname, $this->visiblename, ['id' => $id], $fmoptions); + $fm->setValue($draftitemid); return format_admin_setting($this, $this->visiblename, - '
'.$html.'
', + '
' . $fm->toHtml() . '
', $this->description, true, '', '', $query); } }