diff --git a/files/renderer.php b/files/renderer.php index 8b6a15e14d8..62e15b64b82 100644 --- a/files/renderer.php +++ b/files/renderer.php @@ -114,8 +114,10 @@ class core_files_renderer extends plugin_renderer_base { array('unknownoriginal', 'repository'), array('confirmdeletefolder', 'repository'), array('confirmdeletefilewithhref', 'repository'), array('confirmrenamefolder', 'repository'), array('confirmrenamefile', 'repository'), array('newfolder', 'repository'), array('edit', 'moodle'), - ['nofilesselected', 'repository'], ['confirmdeleteselectedfile', 'repository'], - ['selectall', 'moodle'], ['deselectall', 'moodle'], ['selectallornone', 'form'], + array('originalextensionchange', 'repository'), array('originalextensionremove', 'repository'), + array('aliaseschange', 'repository'), ['nofilesselected', 'repository'], + ['confirmdeleteselectedfile', 'repository'], ['selectall', 'moodle'], ['deselectall', 'moodle'], + ['selectallornone', 'form'], ) ); if ($this->page->requires->should_create_one_time_item_now('core_file_managertemplate')) { diff --git a/lang/en/repository.php b/lang/en/repository.php index 3485ec61ddc..bc6d094a3d4 100644 --- a/lang/en/repository.php +++ b/lang/en/repository.php @@ -29,6 +29,7 @@ $string['add'] = 'Add'; $string['addfile'] = 'Add...'; $string['addfiletext'] = 'Add file'; $string['addplugin'] = 'Add a repository plugin'; +$string['aliaseschange'] = 'There are {$a} alias/shortcut files that use this file as their source. If you proceed then those aliases will be converted to true copies.'; $string['allowexternallinks'] = 'Allow external links'; $string['areamainfile'] = 'Main file'; $string['coursebackup'] = 'Course backups'; @@ -68,7 +69,7 @@ $string['configsyncimagetimeout'] = 'Timeout in seconds for downloading an image $string['confirmdelete'] = 'Are you sure you want to delete the repository {$a}? If you choose "Continue and download", file references to external contents will be downloaded to Moodle. This could take a long time to process.'; $string['confirmdeletefile'] = 'Are you sure you want to delete this file?'; $string['confirmdeleteselectedfile'] = 'Are you sure you want to delete the selected {$a} file(s)?'; -$string['confirmrenamefile'] = 'Are you sure you want to rename/move this file? There are {$a} alias/shortcut files that use this file as their source. If you proceed then those aliases will be converted to true copies.'; +$string['confirmrenamefile'] = 'Are you sure you want to rename/move this file?'; $string['confirmdeletefilewithhref'] = 'Are you sure you want to delete this file? There are {$a} alias/shortcut files that use this file as their source. If you proceed then those aliases will be converted to true copies.'; $string['confirmdeletefolder'] = 'Are you sure you want to delete this folder? All files and subfolders will be deleted.'; $string['confirmremove'] = 'Are you sure you want to remove this repository plugin, its options and all of its instances - {$a}? If you choose "Continue and download", file references to external contents will be downloaded to Moodle. This could take a long time to process.'; @@ -187,6 +188,8 @@ $string['norepositoriesexternalavailable'] = 'Sorry, none of your current reposi $string['notyourinstances'] = 'You can not view/edit repository instances of another user'; $string['off'] = 'Enabled but hidden'; $string['original'] = 'Original'; +$string['originalextensionchange'] = 'The original file extension has been modified as a part of the file name change. Changing the extension from ".{$a->originalextension}" to ".{$a->newextension}" could potentially cause some side effects.'; +$string['originalextensionremove'] = 'The original file extension has been removed as a part of the file name change. Removing the extension ".{$a}" could potentially cause some side effects.'; $string['openpicker'] = 'Choose a file...'; $string['operation'] = 'Operation'; $string['on'] = 'Enabled and visible'; diff --git a/lib/form/filemanager.js b/lib/form/filemanager.js index d09406959b3..950a0026c3c 100644 --- a/lib/form/filemanager.js +++ b/lib/form/filemanager.js @@ -773,10 +773,38 @@ M.form_filemanager.init = function(Y, options) { this.print_msg(M.util.get_string('enternewname', 'repository'), 'error'); return; } - if ((filenamechanged || filepathchanged) && !confirmed && fileinfo.refcount) { - dialog_options.message = M.util.get_string('confirmrenamefile', 'repository', fileinfo.refcount); - this.show_confirm_dialog(dialog_options); - return; + + if ((filenamechanged || filepathchanged) && !confirmed) { + var warnings = ''; + var originalfilenamearr = fileinfo.fullname.split('.'); + var originalextension = (originalfilenamearr.length > 1) ? originalfilenamearr.pop() : ""; + var newfilenamearr = newfilename.split('.'); + var newextension = (newfilenamearr.length > 1) ? newfilenamearr.pop() : ""; + + if (newextension !== originalextension) { + if (newextension === "") { + var string = M.util.get_string('originalextensionremove', 'repository', originalextension); + } else { + var stringvars = { + originalextension: originalextension, + newextension: newextension + } + string = M.util.get_string('originalextensionchange', 'repository', stringvars); + } + warnings = warnings.concat('
', confirmmsg, '
', + '