Permalink
Browse files

MDL-38367 course dndupload - deprecate public 'add_type' function, re…

…move non-YUI3 API call to _node
  • Loading branch information...
1 parent 413bca9 commit 09fd07fe0007ed629c2066ab8f81acd33d7d98d6 @davosmith davosmith committed Mar 18, 2013
Showing with 21 additions and 6 deletions.
  1. +1 −1 course/dndupload.js
  2. +20 −5 course/dnduploadlib.php
View
2 course/dndupload.js
@@ -505,7 +505,7 @@ M.course_dndupload = {
section.addClass('dndupload-over');
// Horrible work-around to allow the 'Add X here' text to be a drop target in Firefox.
- var node = preview.one('span')._node;
+ var node = preview.one('span').getDOMNode();
node.firstChild.nodeValue = type.addmessage;
},
View
25 course/dnduploadlib.php
@@ -112,11 +112,11 @@ public function __construct($course, $modnames = null) {
// 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', 'text/x-moz-url'), get_string('addlinkhere', 'moodle'),
+ $this->add_type_internal('url', array('url', 'text/uri-list', 'text/x-moz-url'), get_string('addlinkhere', 'moodle'),
get_string('nameforlink', 'moodle'), get_string('whatforlink', 'moodle'), 10);
- $this->add_type('text/html', array('text/html'), get_string('addpagehere', 'moodle'),
+ $this->add_type_internal('text/html', array('text/html'), get_string('addpagehere', 'moodle'),
get_string('nameforpage', 'moodle'), get_string('whatforpage', 'moodle'), 20);
- $this->add_type('text', array('text', 'text/plain'), get_string('addpagehere', 'moodle'),
+ $this->add_type_internal('text', array('text', 'text/plain'), get_string('addpagehere', 'moodle'),
get_string('nameforpage', 'moodle'), get_string('whatforpage', 'moodle'), 30);
// Loop through all modules to find handlers.
@@ -148,7 +148,7 @@ public function __construct($course, $modnames = null) {
if (!isset($type['handlermessage'])) {
$type['handlermessage'] = '';
}
- $this->add_type($type['identifier'], $type['datatransfertypes'],
+ $this->add_type_internal($type['identifier'], $type['datatransfertypes'],
$type['addmessage'], $type['namemessage'], $type['handlermessage'], $priority);
}
}
@@ -162,6 +162,21 @@ public function __construct($course, $modnames = null) {
}
/**
+ * No external code should be directly adding new types - they should be added via a 'addtypes' array, returned
+ * by MODNAME_dndupload_register.
+ *
+ * @deprecated deprecated since Moodle 2.5
+ * @param string $identifier
+ * @param array $datatransfertypes
+ * @param string $addmessage
+ * @param string $namemessage
+ * @param int $priority
+ */
+ public function add_type($identifier, $datatransfertypes, $addmessage, $namemessage, $priority=100) {
+ $this->add_type_internal($identifier, $datatransfertypes, $addmessage, $namemessage, '', $priority);
+ }
+
+ /**
* Used to add a new mime type that can be drag and dropped onto a
* course displayed in a browser window
*
@@ -176,7 +191,7 @@ public function __construct($course, $modnames = null) {
* @param int $priority Controls the order in which types are checked by the browser (mainly
* needed to check for 'text' last as that is usually given as fallback)
*/
- public function add_type($identifier, $datatransfertypes, $addmessage, $namemessage, $handlermessage, $priority=100) {
+ protected function add_type_internal($identifier, $datatransfertypes, $addmessage, $namemessage, $handlermessage, $priority=100) {
if ($this->is_known_type($identifier)) {
throw new coding_exception("Type $identifier is already registered");
}

0 comments on commit 09fd07f

Please sign in to comment.