Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 33b24bdd9998239fedf0b156ec7bb7312e8df5da 1 parent 5103b5e
Davo Smith davosmith authored
17 lib/ajax/dndupload.js → course/dndupload.js
@@ -25,7 +25,7 @@ M.course_dndupload = {
25 25 // YUI object.
26 26 Y: null,
27 27 // URL for upload requests
28   - url: M.cfg.wwwroot + '/lib/ajax/dndupload.php',
  28 + url: M.cfg.wwwroot + '/course/dndupload.php',
29 29 // maximum size of files allowed in this form
30 30 maxbytes: 0,
31 31 // ID of the course we are on
@@ -93,7 +93,7 @@ M.course_dndupload = {
93 93 }, this);
94 94
95 95 var div = this.add_status_div();
96   - div.setContent(M.util.get_string('dndworking', 'core_dndupload'));
  96 + div.setContent(M.util.get_string('dndworking', 'moodle'));
97 97 },
98 98
99 99 /**
@@ -116,7 +116,6 @@ M.course_dndupload = {
116 116 * @return true if browser supports drag/drop upload
117 117 */
118 118 browser_supported: function() {
119   -
120 119 if (typeof FileReader == 'undefined') {
121 120 return false;
122 121 }
@@ -207,7 +206,7 @@ M.course_dndupload = {
207 206 }
208 207 return {
209 208 realtype: 'Files',
210   - addmessage: M.util.get_string('addfilehere', 'core_dndupload'),
  209 + addmessage: M.util.get_string('addfilehere', 'moodle'),
211 210 namemessage: null, // Should not be asked for anyway
212 211 type: 'Files'
213 212 };
@@ -464,7 +463,7 @@ M.course_dndupload = {
464 463 preview.div.appendChild(document.createTextNode(' '));
465 464
466 465 preview.namespan.className = 'instancename';
467   - preview.namespan.innerHTML = M.util.get_string('addfilehere', 'core_dndupload');
  466 + preview.namespan.innerHTML = M.util.get_string('addfilehere', 'moodle');
468 467 preview.div.appendChild(preview.namespan);
469 468
470 469 modsel.appendChild(preview.li);
@@ -536,7 +535,7 @@ M.course_dndupload = {
536 535 } else {
537 536 sel = handlers[0].module;
538 537 }
539   - content += '<p>'+M.util.get_string('actionchoice', 'core_dndupload', file.name)+'</p>';
  538 + content += '<p>'+M.util.get_string('actionchoice', 'moodle', file.name)+'</p>';
540 539 content += '<div id="dndupload_handlers'+uploadid+'">';
541 540 for (var i=0; i<handlers.length; i++) {
542 541 var id = 'dndupload_handler'+uploadid+handlers[i].module;
@@ -636,7 +635,7 @@ M.course_dndupload = {
636 635 var self = this;
637 636
638 637 if (file.size > this.maxbytes) {
639   - alert("'"+file.name+"' "+M.util.get_string('filetoolarge', 'core_dndupload'));
  638 + alert("'"+file.name+"' "+M.util.get_string('filetoolarge', 'moodle'));
640 639 return;
641 640 }
642 641
@@ -677,7 +676,7 @@ M.course_dndupload = {
677 676 }
678 677 }
679 678 } else {
680   - alert(M.util.get_string('servererror', 'core_dndupload'));
  679 + alert(M.util.get_string('servererror', 'moodle'));
681 680 }
682 681 }
683 682 };
@@ -851,7 +850,7 @@ M.course_dndupload = {
851 850 }
852 851 }
853 852 } else {
854   - alert(M.util.get_string('servererror', 'core_dndupload'));
  853 + alert(M.util.get_string('servererror', 'moodle'));
855 854 }
856 855 }
857 856 };
2  lib/ajax/dndupload.php → course/dndupload.php
@@ -26,7 +26,7 @@
26 26 define('AJAX_SCRIPT', true);
27 27
28 28 require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
29   -require_once($CFG->libdir.'/dnduploadlib.php');
  29 +require_once($CFG->dirroot.'/course/dnduploadlib.php');
30 30
31 31 $courseid = required_param('course', PARAM_INT);
32 32 $section = required_param('section', PARAM_INT);
42 lib/dnduploadlib.php → course/dnduploadlib.php
@@ -48,18 +48,16 @@ function dndupload_add_to_course($course, $modnames) {
48 48
49 49 // Add the javascript to the page.
50 50 $jsmodule = array(
51   - 'name' => 'dndupload',
52   - 'fullpath' => new moodle_url('/lib/ajax/dndupload.js'),
  51 + 'name' => 'coursedndupload',
  52 + 'fullpath' => new moodle_url('/course/dndupload.js'),
53 53 'strings' => array(
54   - array('addfilehere', 'core_dndupload'),
55   - array('dndworking', 'core_dndupload'),
56   - array('filetoolarge', 'core_dndupload'),
57   - array('nofilereader', 'core_dndupload'),
58   - array('noajax', 'core_dndupload'),
59   - array('actionchoice', 'core_dndupload'),
60   - array('servererror', 'core_dndupload'),
61   - array('upload', 'core'),
62   - array('cancel', 'core')
  54 + array('addfilehere', 'moodle'),
  55 + array('dndworking', 'moodle'),
  56 + array('filetoolarge', 'moodle'),
  57 + array('actionchoice', 'moodle'),
  58 + array('servererror', 'moodle'),
  59 + array('upload', 'moodle'),
  60 + array('cancel', 'moodle')
63 61 ),
64 62 'requires' => array('node', 'event', 'panel', 'json')
65 63 );
@@ -105,12 +103,12 @@ public function __construct($course, $modnames = null) {
105 103 // Add some default types to handle.
106 104 // Note: 'Files' type is hard-coded into the Javascript as this needs to be ...
107 105 // ... treated a little differently.
108   - $this->add_type('url', array('url', 'text/uri-list'), get_string('addlinkhere', 'core_dndupload'),
109   - get_string('nameforlink', 'core_dndupload'), 10);
110   - $this->add_type('text/html', array('text/html'), get_string('addpagehere', 'core_dndupload'),
111   - get_string('nameforpage', 'core_dndupload'), 20);
112   - $this->add_type('text', array('text', 'text/plain'), get_string('addpagehere', 'core_dndupload'),
113   - get_string('nameforpage', 'core_dndupload'), 30);
  106 + $this->add_type('url', array('url', 'text/uri-list'), get_string('addlinkhere', 'moodle'),
  107 + get_string('nameforlink', 'moodle'), 10);
  108 + $this->add_type('text/html', array('text/html'), get_string('addpagehere', 'moodle'),
  109 + get_string('nameforpage', 'moodle'), 20);
  110 + $this->add_type('text', array('text', 'text/plain'), get_string('addpagehere', 'moodle'),
  111 + get_string('nameforpage', 'moodle'), 30);
114 112
115 113 // Loop through all modules to find handlers.
116 114 $mods = get_plugin_list_with_function('mod', 'dndupload_register');
@@ -430,7 +428,7 @@ public function process($displayname = null, $content = null) {
430 428 if ($this->is_file_upload()) {
431 429 require_capability('moodle/course:managefiles', $this->context);
432 430 if ($content != null) {
433   - throw new moodle_exception('fileuploadwithcontent', 'core_dndupload');
  431 + throw new moodle_exception('fileuploadwithcontent', 'moodle');
434 432 }
435 433 }
436 434
@@ -458,7 +456,7 @@ protected function handle_file_upload() {
458 456 $types = $this->dnduploadhandler->get_handled_file_types($this->module->name);
459 457 $repo = repository::get_instances(array('type' => 'upload'));
460 458 if (empty($repo)) {
461   - throw new moodle_exception('errornouploadrepo', 'core_dndupload');
  459 + throw new moodle_exception('errornouploadrepo', 'moodle');
462 460 }
463 461 $repo = reset($repo); // Get the first (and only) upload repo.
464 462 $details = $repo->process_upload(null, $maxbytes, $types, '/', $draftitemid);
@@ -490,7 +488,7 @@ protected function handle_other_upload($content) {
490 488 // Check this plugin is registered to handle this type of upload
491 489 if (!$this->dnduploadhandler->has_type_handler($this->module->name, $this->type)) {
492 490 $info = (object)array('modname' => $this->module->name, 'type' => $this->type);
493   - throw new moodle_exception('moddoesnotsupporttype', 'core_dndupload', $info);
  491 + throw new moodle_exception('moddoesnotsupporttype', 'moodle', $info);
494 492 }
495 493
496 494 // Create a course module to hold the new instance.
@@ -587,7 +585,7 @@ protected function finish_setup_course_module($instanceid) {
587 585 if (!$instanceid) {
588 586 // Something has gone wrong - undo everything we can.
589 587 delete_course_module($this->cm->id);
590   - throw new moodle_exception('errorcreatingactivity', 'core_dndupload', '', $this->module->name);
  588 + throw new moodle_exception('errorcreatingactivity', 'moodle', '', $this->module->name);
591 589 }
592 590
593 591 $DB->set_field('course_modules', 'instance', $instanceid, array('id' => $this->cm->id));
@@ -604,7 +602,7 @@ protected function finish_setup_course_module($instanceid) {
604 602 if (!isset($info->cms[$this->cm->id])) {
605 603 // The course module has not been properly created in the course - undo everything.
606 604 delete_course_module($this->cm->id);
607   - throw new moodle_exception('errorcreatingactivity', 'core_dndupload', '', $this->module->name);
  605 + throw new moodle_exception('errorcreatingactivity', 'moodle', '', $this->module->name);
608 606 }
609 607 $mod = $info->cms[$this->cm->id];
610 608
2  course/lib.php
@@ -28,7 +28,7 @@
28 28
29 29 require_once($CFG->libdir.'/completionlib.php');
30 30 require_once($CFG->libdir.'/filelib.php');
31   -require_once($CFG->libdir.'/dnduploadlib.php');
  31 +require_once($CFG->dirroot.'/course/dnduploadlib.php');
32 32
33 33 define('COURSE_MAX_LOGS_PER_PAGE', 1000); // records
34 34 define('COURSE_MAX_RECENT_PERIOD', 172800); // Two days, in seconds
41 lang/en/dndupload.php
... ... @@ -1,41 +0,0 @@
1   -<?php
2   -// This file is part of Moodle - http://moodle.org/
3   -//
4   -// Moodle is free software: you can redistribute it and/or modify
5   -// it under the terms of the GNU General Public License as published by
6   -// the Free Software Foundation, either version 3 of the License, or
7   -// (at your option) any later version.
8   -//
9   -// Moodle is distributed in the hope that it will be useful,
10   -// but WITHOUT ANY WARRANTY; without even the implied warranty of
11   -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   -// GNU General Public License for more details.
13   -//
14   -// You should have received a copy of the GNU General Public License
15   -// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16   -
17   -/**
18   - * Strings for component 'dndupload', language 'en', branch 'master'
19   - *
20   - * @package core
21   - * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
22   - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23   - */
24   -
25   -$string['actionchoice'] = 'What do you want to do with the file \'{$a}\'?';
26   -$string['addfilehere'] = 'Add file(s) here';
27   -$string['addlinkhere'] = 'Add link here';
28   -$string['addpagehere'] = 'Add page here';
29   -$string['dndworking'] = 'Drag and drop files, text or links onto course sections to upload them';
30   -$string['errorcreatingactivity'] = 'Unable to create an instance of activity \'{$a}\'';
31   -$string['errorfiletoobig'] = 'The file was bigger than the limit of {$a} bytes';
32   -$string['errornouploadrepo'] = 'There is no upload repository enabled for this site';
33   -$string['filetoolarge'] = 'is too large to upload';
34   -$string['fileuploadwithcontent'] = 'File uploads should not include the content parameter';
35   -$string['moddoesnotsupporttype'] = 'Module {$a->modname} does not support uploads of type {$a->type}';
36   -$string['nameforlink'] = 'What do you want to call this link?';
37   -$string['nameforpage'] = 'What do you want to call this page?';
38   -$string['noajax'] = 'AJAX course editing must be enabled for drag and drop upload to work';
39   -$string['nofilereader'] = 'Your browser does not support drag and drop upload of files';
40   -$string['noscript'] = 'Javascript must be enabled for drag and drop upload to work';
41   -$string['servererror'] = 'An error occurred whilst communicating with the server';
14 lang/en/moodle.php
@@ -25,6 +25,7 @@
25 25
26 26 $string['abouttobeinstalled'] = 'about to be installed';
27 27 $string['action'] = 'Action';
  28 +$string['actionchoice'] = 'What do you want to do with the file \'{$a}\'?';
28 29 $string['actions'] = 'Actions';
29 30 $string['active'] = 'Active';
30 31 $string['activeusers'] = 'Active users';
@@ -54,13 +55,16 @@
54 55 $string['addedtogroup'] = 'Added to group "{$a}"';
55 56 $string['addedtogroupnot'] = 'Not added to group "{$a}"';
56 57 $string['addedtogroupnotenrolled'] = 'Not added to group "{$a}", because not enrolled in course';
  58 +$string['addfilehere'] = 'Add file(s) here';
57 59 $string['addinganew'] = 'Adding a new {$a}';
58 60 $string['addinganewto'] = 'Adding a new {$a->what} to {$a->to}';
59 61 $string['addingdatatoexisting'] = 'Adding data to existing';
  62 +$string['addlinkhere'] = 'Add link here';
60 63 $string['addnewcategory'] = 'Add new category';
61 64 $string['addnewcourse'] = 'Add a new course';
62 65 $string['addnewuser'] = 'Add a new user';
63 66 $string['addnousersrecip'] = 'Add users who haven\'t accessed this {$a} to recipient list';
  67 +$string['addpagehere'] = 'Add page here';
64 68 $string['addresource'] = 'Add a resource...';
65 69 $string['address'] = 'Address';
66 70 $string['addstudent'] = 'Add student';
@@ -458,6 +462,7 @@
458 462 $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';
459 463 $string['dndenabled_insentence'] = 'drag and drop available';
460 464 $string['dndenabled_inbox'] = 'drag and drop files here to upload them';
  465 +$string['dndworking'] = 'Drag and drop files, text or links onto course sections to upload them';
461 466 $string['documentation'] = 'Moodle documentation';
462 467 $string['down'] = 'Down';
463 468 $string['download'] = 'Download';
@@ -622,6 +627,9 @@
622 627 $string['enterusername'] = 'Enter your username';
623 628 $string['entries'] = 'Entries';
624 629 $string['error'] = 'Error';
  630 +$string['errorcreatingactivity'] = 'Unable to create an instance of activity \'{$a}\'';
  631 +$string['errorfiletoobig'] = 'The file was bigger than the limit of {$a} bytes';
  632 +$string['errornouploadrepo'] = 'There is no upload repository enabled for this site';
625 633 $string['errortoomanylogins'] = 'Sorry, you have exceeded the allowed number of login attempts. Restart your browser.';
626 634 $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.';
627 635 $string['everybody'] = 'Everybody';
@@ -663,8 +671,10 @@
663 671 $string['feedback'] = 'Feedback';
664 672 $string['file'] = 'File';
665 673 $string['filemissing'] = '{$a} is missing';
  674 +$string['filetoolarge'] = 'is too large to upload';
666 675 $string['files'] = 'Files';
667 676 $string['filesfolders'] = 'Files/folders';
  677 +$string['fileuploadwithcontent'] = 'File uploads should not include the content parameter';
668 678 $string['filloutallfields'] = 'Please fill out all fields in this form';
669 679 $string['filter'] = 'Filter';
670 680 $string['findmorecourses'] = 'Find more courses...';
@@ -1030,6 +1040,7 @@
1030 1040 $string['missingteacher'] = 'Must choose something';
1031 1041 $string['missingurl'] = 'Missing URL';
1032 1042 $string['missingusername'] = 'Missing username';
  1043 +$string['moddoesnotsupporttype'] = 'Module {$a->modname} does not support uploads of type {$a->type}';
1033 1044 $string['modified'] = 'Modified';
1034 1045 $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?';
1035 1046 $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 @@
1070 1081 $string['mymoodledashboard'] = 'My Moodle dashboard';
1071 1082 $string['myprofile'] = 'My profile';
1072 1083 $string['name'] = 'Name';
  1084 +$string['nameforlink'] = 'What do you want to call this link?';
  1085 +$string['nameforpage'] = 'What do you want to call this page?';
1073 1086 $string['navigation'] = 'Navigation';
1074 1087 $string['needed'] = 'Needed';
1075 1088 $string['never'] = 'Never';
@@ -1469,6 +1482,7 @@
1469 1482 $string['separate'] = 'Separate';
1470 1483 $string['separateandconnected'] = 'Separate and Connected ways of knowing';
1471 1484 $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>';
  1485 +$string['servererror'] = 'An error occurred whilst communicating with the server';
1472 1486 $string['serverlocaltime'] = 'Server\'s local time';
1473 1487 $string['setcategorytheme'] = 'Set category theme';
1474 1488 $string['settings'] = 'Settings';

0 comments on commit 33b24bd

Please sign in to comment.
Something went wrong with that request. Please try again.