Skip to content

Commit

Permalink
MDL-38367 course dndupload - deprecate public 'add_type' function, re…
Browse files Browse the repository at this point in the history
…move non-YUI3 API call to _node
  • Loading branch information
davosmith committed Mar 18, 2013
1 parent 413bca9 commit 09fd07f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion course/dndupload.js
Expand Up @@ -505,7 +505,7 @@ M.course_dndupload = {
section.addClass('dndupload-over'); section.addClass('dndupload-over');


// Horrible work-around to allow the 'Add X here' text to be a drop target in Firefox. // 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; node.firstChild.nodeValue = type.addmessage;
}, },


Expand Down
25 changes: 20 additions & 5 deletions course/dnduploadlib.php
Expand Up @@ -112,11 +112,11 @@ public function __construct($course, $modnames = null) {
// Add some default types to handle. // Add some default types to handle.
// Note: 'Files' type is hard-coded into the Javascript as this needs to be ... // Note: 'Files' type is hard-coded into the Javascript as this needs to be ...
// ... treated a little differently. // ... 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); 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); 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); get_string('nameforpage', 'moodle'), get_string('whatforpage', 'moodle'), 30);


// Loop through all modules to find handlers. // Loop through all modules to find handlers.
Expand Down Expand Up @@ -148,7 +148,7 @@ public function __construct($course, $modnames = null) {
if (!isset($type['handlermessage'])) { if (!isset($type['handlermessage'])) {
$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); $type['addmessage'], $type['namemessage'], $type['handlermessage'], $priority);
} }
} }
Expand All @@ -161,6 +161,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 * Used to add a new mime type that can be drag and dropped onto a
* course displayed in a browser window * course displayed in a browser window
Expand All @@ -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 * @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) * 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)) { if ($this->is_known_type($identifier)) {
throw new coding_exception("Type $identifier is already registered"); throw new coding_exception("Type $identifier is already registered");
} }
Expand Down

0 comments on commit 09fd07f

Please sign in to comment.