Browse files

MDL-31642 added 'max attachments' to filemanager and 'drag and drop' …

…message inside the box
  • Loading branch information...
1 parent 5bbf3cb commit adce023069ddb110e1fb971f5151de665b6ed764 @davosmith davosmith committed Feb 23, 2012
Showing with 30 additions and 4 deletions.
  1. +2 −0 lang/en/moodle.php
  2. +9 −0 lib/form/dndupload.js
  3. +10 −1 lib/form/filemanager.js
  4. +7 −1 lib/form/filemanager.php
  5. +1 −1 lib/outputrenderers.php
  6. +1 −1 lib/outputrequirementslib.php
View
2 lang/en/moodle.php
@@ -455,6 +455,7 @@
$string['dndenabled'] = 'Drag and drop available';
$string['dndenabled_help'] = 'You can drag one or more files from your desktop and drop them onto the box below to upload them.<br />Note: this may not work with other web browsers';
$string['dndenabled_insentence'] = 'drag and drop available';
+$string['dndenabled_inbox'] = 'drag and drop files here to upload them';
$string['documentation'] = 'Moodle documentation';
$string['down'] = 'Down';
$string['download'] = 'Download';
@@ -970,6 +971,7 @@
$string['markedthistopic'] = 'This topic is highlighted as the current topic';
$string['markthistopic'] = 'Highlight this topic as the current topic';
$string['matchingsearchandrole'] = 'Matching \'{$a->search}\' and {$a->role}';
+$string['maxsizeandattachments'] = 'Maximum size for new files: {$a->size}, maximum attachments: {$a->attachments}';
$string['maxfilesreached'] = 'You are allowed to attach a maximum of {$a} file(s) to this item';
$string['maximumgrade'] = 'Maximum grade';
$string['maximumgradex'] = 'Maximum grade: {$a}';
View
9 lib/form/dndupload.js
@@ -95,6 +95,15 @@ M.form_dndupload.init = function(Y, options) {
// Needed to tell the filemanager to redraw when files uploaded
// and to check how many files are already uploaded
this.filemanager = options.filemanager;
+ // Add a callback to show the 'drag and drop enabled' message
+ // within the filemanager box once it has finished loading,
+ // if there are no files yet uploaded
+ this.filemanager.emptycallback = function(clientid) {
+ var el = Y.one('#dndenabled2-'+clientid);
+ if (el) {
+ el.setStyle('display', 'inline');
+ }
+ }
} else if (options.formcallback) {
// Needed to tell the filepicker to update when a new
View
11 lib/form/filemanager.js
@@ -61,6 +61,7 @@ M.form_filemanager.init = function(Y, options) {
this.currentpath = '/';
this.maxfiles = options.maxfiles;
this.maxbytes = options.maxbytes;
+ this.emptycallback = null; // Used by drag and drop upload
this.filepicker_options = options.filepicker?options.filepicker:{};
this.filepicker_options.client_id = this.client_id;
@@ -264,7 +265,15 @@ M.form_filemanager.init = function(Y, options) {
}, this);
},
empty_filelist: function(container) {
- container.set('innerHTML', '<div class="mdl-align">'+M.str.repository.nofilesattached+'</div>'+this.upload_message());
+ var content = '<div class="mdl-align">'+M.str.repository.nofilesattached;
+ content += '<span id="dndenabled2-'+this.client_id+'" style="display: none">';
+ content += ' - '+M.util.get_string('dndenabled_inbox', 'moodle')+'</span>';
+ content += '</div>';
+ content += this.upload_message();
+ container.set('innerHTML', content);
+ if (this.emptycallback) {
+ this.emptycallback(this.client_id);
+ }
},
upload_message: function() {
var div = '<div id="filemanager-uploadmessage'+this.client_id+'" style="display:none" class="dndupload-target">';
View
8 lib/form/filemanager.php
@@ -376,7 +376,13 @@ function form_filemanager_render($options) {
$extra = '';
}
- $maxsize = get_string('maxfilesize', 'moodle', display_size(get_max_upload_file_size($CFG->maxbytes, $course_maxbytes, $options->maxbytes)));
+ $maxbytes = display_size(get_max_upload_file_size($CFG->maxbytes, $course_maxbytes, $options->maxbytes));
+ if (empty($options->maxfiles) || $options->maxfiles == -1) {
+ $maxsize = get_string('maxfilesize', 'moodle', $maxbytes);
+ } else {
+ $strparam = (object)array('size' => $maxbytes, 'attachments' => $options->maxfiles);
+ $maxsize = get_string('maxsizeandattachments', 'moodle', $strparam);
+ }
$strdndenabled = get_string('dndenabled_insentence', 'moodle').$OUTPUT->help_icon('dndenabled');
$loading = get_string('loading', 'repository');
$html .= <<<FMHTML
View
2 lib/outputrenderers.php
@@ -2018,7 +2018,7 @@ public function render_file_picker(file_picker $fp) {
$strsaved = get_string('filesaved', 'repository');
$straddfile = get_string('openpicker', 'repository');
$strloading = get_string('loading', 'repository');
- $strdndenabled = get_string('dndenabled_insentence', 'moodle');
+ $strdndenabled = get_string('dndenabled_inbox', 'moodle');
$icon_progress = $OUTPUT->pix_icon('i/loading_small', $strloading).'';
$currentfile = $options->currentfile;
View
2 lib/outputrequirementslib.php
@@ -501,7 +501,7 @@ protected function find_module($component) {
$module = array('name' => 'core_dndupload',
'fullpath' => '/lib/form/dndupload.js',
'requires' => array('node', 'event', 'json'),
- 'strings' => array(array('uploadformlimit', 'moodle'), array('droptoupload', 'moodle'), array('maxfilesreached', 'moodle')));
+ 'strings' => array(array('uploadformlimit', 'moodle'), array('droptoupload', 'moodle'), array('maxfilesreached', 'moodle'), array('dndenabled_inbox', 'moodle')));
break;
}

0 comments on commit adce023

Please sign in to comment.