MDL-22504 Course drag and drop upload - moved file locations

This commit is contained in:
Davo Smith
2012-05-16 08:25:22 +01:00
parent 5103b5e667
commit 33b24bdd99
6 changed files with 44 additions and 74 deletions
@@ -25,7 +25,7 @@ M.course_dndupload = {
// YUI object.
Y: null,
// URL for upload requests
url: M.cfg.wwwroot + '/lib/ajax/dndupload.php',
url: M.cfg.wwwroot + '/course/dndupload.php',
// maximum size of files allowed in this form
maxbytes: 0,
// ID of the course we are on
@@ -93,7 +93,7 @@ M.course_dndupload = {
}, this);
var div = this.add_status_div();
div.setContent(M.util.get_string('dndworking', 'core_dndupload'));
div.setContent(M.util.get_string('dndworking', 'moodle'));
},
/**
@@ -116,7 +116,6 @@ M.course_dndupload = {
* @return true if browser supports drag/drop upload
*/
browser_supported: function() {
if (typeof FileReader == 'undefined') {
return false;
}
@@ -207,7 +206,7 @@ M.course_dndupload = {
}
return {
realtype: 'Files',
addmessage: M.util.get_string('addfilehere', 'core_dndupload'),
addmessage: M.util.get_string('addfilehere', 'moodle'),
namemessage: null, // Should not be asked for anyway
type: 'Files'
};
@@ -464,7 +463,7 @@ M.course_dndupload = {
preview.div.appendChild(document.createTextNode(' '));
preview.namespan.className = 'instancename';
preview.namespan.innerHTML = M.util.get_string('addfilehere', 'core_dndupload');
preview.namespan.innerHTML = M.util.get_string('addfilehere', 'moodle');
preview.div.appendChild(preview.namespan);
modsel.appendChild(preview.li);
@@ -536,7 +535,7 @@ M.course_dndupload = {
} else {
sel = handlers[0].module;
}
content += '<p>'+M.util.get_string('actionchoice', 'core_dndupload', file.name)+'</p>';
content += '<p>'+M.util.get_string('actionchoice', 'moodle', file.name)+'</p>';
content += '<div id="dndupload_handlers'+uploadid+'">';
for (var i=0; i<handlers.length; i++) {
var id = 'dndupload_handler'+uploadid+handlers[i].module;
@@ -636,7 +635,7 @@ M.course_dndupload = {
var self = this;
if (file.size > this.maxbytes) {
alert("'"+file.name+"' "+M.util.get_string('filetoolarge', 'core_dndupload'));
alert("'"+file.name+"' "+M.util.get_string('filetoolarge', 'moodle'));
return;
}
@@ -677,7 +676,7 @@ M.course_dndupload = {
}
}
} else {
alert(M.util.get_string('servererror', 'core_dndupload'));
alert(M.util.get_string('servererror', 'moodle'));
}
}
};
@@ -851,7 +850,7 @@ M.course_dndupload = {
}
}
} else {
alert(M.util.get_string('servererror', 'core_dndupload'));
alert(M.util.get_string('servererror', 'moodle'));
}
}
};
@@ -26,7 +26,7 @@
define('AJAX_SCRIPT', true);
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once($CFG->libdir.'/dnduploadlib.php');
require_once($CFG->dirroot.'/course/dnduploadlib.php');
$courseid = required_param('course', PARAM_INT);
$section = required_param('section', PARAM_INT);
@@ -48,18 +48,16 @@ function dndupload_add_to_course($course, $modnames) {
// Add the javascript to the page.
$jsmodule = array(
'name' => 'dndupload',
'fullpath' => new moodle_url('/lib/ajax/dndupload.js'),
'name' => 'coursedndupload',
'fullpath' => new moodle_url('/course/dndupload.js'),
'strings' => array(
array('addfilehere', 'core_dndupload'),
array('dndworking', 'core_dndupload'),
array('filetoolarge', 'core_dndupload'),
array('nofilereader', 'core_dndupload'),
array('noajax', 'core_dndupload'),
array('actionchoice', 'core_dndupload'),
array('servererror', 'core_dndupload'),
array('upload', 'core'),
array('cancel', 'core')
array('addfilehere', 'moodle'),
array('dndworking', 'moodle'),
array('filetoolarge', 'moodle'),
array('actionchoice', 'moodle'),
array('servererror', 'moodle'),
array('upload', 'moodle'),
array('cancel', 'moodle')
),
'requires' => array('node', 'event', 'panel', 'json')
);
@@ -105,12 +103,12 @@ class dndupload_handler {
// Add some default types to handle.
// Note: 'Files' type is hard-coded into the Javascript as this needs to be ...
// ... treated a little differently.
$this->add_type('url', array('url', 'text/uri-list'), get_string('addlinkhere', 'core_dndupload'),
get_string('nameforlink', 'core_dndupload'), 10);
$this->add_type('text/html', array('text/html'), get_string('addpagehere', 'core_dndupload'),
get_string('nameforpage', 'core_dndupload'), 20);
$this->add_type('text', array('text', 'text/plain'), get_string('addpagehere', 'core_dndupload'),
get_string('nameforpage', 'core_dndupload'), 30);
$this->add_type('url', array('url', 'text/uri-list'), get_string('addlinkhere', 'moodle'),
get_string('nameforlink', 'moodle'), 10);
$this->add_type('text/html', array('text/html'), get_string('addpagehere', 'moodle'),
get_string('nameforpage', 'moodle'), 20);
$this->add_type('text', array('text', 'text/plain'), get_string('addpagehere', 'moodle'),
get_string('nameforpage', 'moodle'), 30);
// Loop through all modules to find handlers.
$mods = get_plugin_list_with_function('mod', 'dndupload_register');
@@ -430,7 +428,7 @@ class dndupload_ajax_processor {
if ($this->is_file_upload()) {
require_capability('moodle/course:managefiles', $this->context);
if ($content != null) {
throw new moodle_exception('fileuploadwithcontent', 'core_dndupload');
throw new moodle_exception('fileuploadwithcontent', 'moodle');
}
}
@@ -458,7 +456,7 @@ class dndupload_ajax_processor {
$types = $this->dnduploadhandler->get_handled_file_types($this->module->name);
$repo = repository::get_instances(array('type' => 'upload'));
if (empty($repo)) {
throw new moodle_exception('errornouploadrepo', 'core_dndupload');
throw new moodle_exception('errornouploadrepo', 'moodle');
}
$repo = reset($repo); // Get the first (and only) upload repo.
$details = $repo->process_upload(null, $maxbytes, $types, '/', $draftitemid);
@@ -490,7 +488,7 @@ class dndupload_ajax_processor {
// Check this plugin is registered to handle this type of upload
if (!$this->dnduploadhandler->has_type_handler($this->module->name, $this->type)) {
$info = (object)array('modname' => $this->module->name, 'type' => $this->type);
throw new moodle_exception('moddoesnotsupporttype', 'core_dndupload', $info);
throw new moodle_exception('moddoesnotsupporttype', 'moodle', $info);
}
// Create a course module to hold the new instance.
@@ -587,7 +585,7 @@ class dndupload_ajax_processor {
if (!$instanceid) {
// Something has gone wrong - undo everything we can.
delete_course_module($this->cm->id);
throw new moodle_exception('errorcreatingactivity', 'core_dndupload', '', $this->module->name);
throw new moodle_exception('errorcreatingactivity', 'moodle', '', $this->module->name);
}
$DB->set_field('course_modules', 'instance', $instanceid, array('id' => $this->cm->id));
@@ -604,7 +602,7 @@ class dndupload_ajax_processor {
if (!isset($info->cms[$this->cm->id])) {
// The course module has not been properly created in the course - undo everything.
delete_course_module($this->cm->id);
throw new moodle_exception('errorcreatingactivity', 'core_dndupload', '', $this->module->name);
throw new moodle_exception('errorcreatingactivity', 'moodle', '', $this->module->name);
}
$mod = $info->cms[$this->cm->id];
+1 -1
View File
@@ -28,7 +28,7 @@ defined('MOODLE_INTERNAL') || die;
require_once($CFG->libdir.'/completionlib.php');
require_once($CFG->libdir.'/filelib.php');
require_once($CFG->libdir.'/dnduploadlib.php');
require_once($CFG->dirroot.'/course/dnduploadlib.php');
define('COURSE_MAX_LOGS_PER_PAGE', 1000); // records
define('COURSE_MAX_RECENT_PERIOD', 172800); // Two days, in seconds
-41
View File
@@ -1,41 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'dndupload', language 'en', branch 'master'
*
* @package core
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['actionchoice'] = 'What do you want to do with the file \'{$a}\'?';
$string['addfilehere'] = 'Add file(s) here';
$string['addlinkhere'] = 'Add link here';
$string['addpagehere'] = 'Add page here';
$string['dndworking'] = 'Drag and drop files, text or links onto course sections to upload them';
$string['errorcreatingactivity'] = 'Unable to create an instance of activity \'{$a}\'';
$string['errorfiletoobig'] = 'The file was bigger than the limit of {$a} bytes';
$string['errornouploadrepo'] = 'There is no upload repository enabled for this site';
$string['filetoolarge'] = 'is too large to upload';
$string['fileuploadwithcontent'] = 'File uploads should not include the content parameter';
$string['moddoesnotsupporttype'] = 'Module {$a->modname} does not support uploads of type {$a->type}';
$string['nameforlink'] = 'What do you want to call this link?';
$string['nameforpage'] = 'What do you want to call this page?';
$string['noajax'] = 'AJAX course editing must be enabled for drag and drop upload to work';
$string['nofilereader'] = 'Your browser does not support drag and drop upload of files';
$string['noscript'] = 'Javascript must be enabled for drag and drop upload to work';
$string['servererror'] = 'An error occurred whilst communicating with the server';
+14
View File
@@ -25,6 +25,7 @@
$string['abouttobeinstalled'] = 'about to be installed';
$string['action'] = 'Action';
$string['actionchoice'] = 'What do you want to do with the file \'{$a}\'?';
$string['actions'] = 'Actions';
$string['active'] = 'Active';
$string['activeusers'] = 'Active users';
@@ -54,13 +55,16 @@ $string['addedrecips'] = 'Added {$a} new recipients';
$string['addedtogroup'] = 'Added to group "{$a}"';
$string['addedtogroupnot'] = 'Not added to group "{$a}"';
$string['addedtogroupnotenrolled'] = 'Not added to group "{$a}", because not enrolled in course';
$string['addfilehere'] = 'Add file(s) here';
$string['addinganew'] = 'Adding a new {$a}';
$string['addinganewto'] = 'Adding a new {$a->what} to {$a->to}';
$string['addingdatatoexisting'] = 'Adding data to existing';
$string['addlinkhere'] = 'Add link here';
$string['addnewcategory'] = 'Add new category';
$string['addnewcourse'] = 'Add a new course';
$string['addnewuser'] = 'Add a new user';
$string['addnousersrecip'] = 'Add users who haven\'t accessed this {$a} to recipient list';
$string['addpagehere'] = 'Add page here';
$string['addresource'] = 'Add a resource...';
$string['address'] = 'Address';
$string['addstudent'] = 'Add student';
@@ -458,6 +462,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['dndworking'] = 'Drag and drop files, text or links onto course sections to upload them';
$string['documentation'] = 'Moodle documentation';
$string['down'] = 'Down';
$string['download'] = 'Download';
@@ -622,6 +627,9 @@ $string['enteremailaddress'] = 'Enter in your email address to reset your
$string['enterusername'] = 'Enter your username';
$string['entries'] = 'Entries';
$string['error'] = 'Error';
$string['errorcreatingactivity'] = 'Unable to create an instance of activity \'{$a}\'';
$string['errorfiletoobig'] = 'The file was bigger than the limit of {$a} bytes';
$string['errornouploadrepo'] = 'There is no upload repository enabled for this site';
$string['errortoomanylogins'] = 'Sorry, you have exceeded the allowed number of login attempts. Restart your browser.';
$string['errorwhenconfirming'] = 'You are not confirmed yet because an error occurred. If you clicked on a link in an email to get here, make sure that the line in your email wasn\'t broken or wrapped. You may have to use cut and paste to reconstruct the link properly.';
$string['everybody'] = 'Everybody';
@@ -663,8 +671,10 @@ $string['failedloginattemptsall'] = '{$a->attempts} failed logins for {$a->accou
$string['feedback'] = 'Feedback';
$string['file'] = 'File';
$string['filemissing'] = '{$a} is missing';
$string['filetoolarge'] = 'is too large to upload';
$string['files'] = 'Files';
$string['filesfolders'] = 'Files/folders';
$string['fileuploadwithcontent'] = 'File uploads should not include the content parameter';
$string['filloutallfields'] = 'Please fill out all fields in this form';
$string['filter'] = 'Filter';
$string['findmorecourses'] = 'Find more courses...';
@@ -1030,6 +1040,7 @@ $string['missingsummary'] = 'Missing summary';
$string['missingteacher'] = 'Must choose something';
$string['missingurl'] = 'Missing URL';
$string['missingusername'] = 'Missing username';
$string['moddoesnotsupporttype'] = 'Module {$a->modname} does not support uploads of type {$a->type}';
$string['modified'] = 'Modified';
$string['moduledeleteconfirm'] = 'You are about to completely delete the module \'{$a}\'. This will completely delete everything in the database associated with this activity module. Are you SURE you want to continue?';
$string['moduledeletefiles'] = 'All data associated with the module \'{$a->module}\' has been deleted from the database. To complete the deletion (and prevent the module re-installing itself), you should now delete this directory from your server: {$a->directory}';
@@ -1070,6 +1081,8 @@ $string['myhome'] = 'My home';
$string['mymoodledashboard'] = 'My Moodle dashboard';
$string['myprofile'] = 'My profile';
$string['name'] = 'Name';
$string['nameforlink'] = 'What do you want to call this link?';
$string['nameforpage'] = 'What do you want to call this page?';
$string['navigation'] = 'Navigation';
$string['needed'] = 'Needed';
$string['never'] = 'Never';
@@ -1469,6 +1482,7 @@ $string['senddetails'] = 'Send my details via email';
$string['separate'] = 'Separate';
$string['separateandconnected'] = 'Separate and Connected ways of knowing';
$string['separateandconnectedinfo'] = 'The scale based on the theory of separate and connected knowing. This theory describes two different ways that we can evaluate and learn about the things we see and hear.<ul><li><strong>Separate knowers</strong> remain as objective as possible without including feelings and emotions. In a discussion with other people, they like to defend their own ideas, using logic to find holes in opponent\'s ideas.</li><li><strong>Connected knowers</strong> are more sensitive to other people. They are skilled at empathy and tends to listen and ask questions until they feel they can connect and "understand things from their point of view". They learn by trying to share the experiences that led to the knowledge they find in other people.</li></ul>';
$string['servererror'] = 'An error occurred whilst communicating with the server';
$string['serverlocaltime'] = 'Server\'s local time';
$string['setcategorytheme'] = 'Set category theme';
$string['settings'] = 'Settings';