Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403]
Library to handle drag and drop course uploads
Copyright: | 2012 Davo smith |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 672 lines (26 kb) |
Included or required: | 0 times |
Referenced: | 3 times |
Includes or requires: | 0 files |
dndupload_handler:: (10 methods):
__construct()
register_type()
register_type_handler()
register_file_handler()
is_known_type()
has_type_handler()
has_file_handler()
get_handled_file_types()
get_js_data()
type_compare()
dndupload_ajax_processor:: (10 methods):
__construct()
is_file_upload()
process()
handle_file_upload()
handle_other_upload()
display_name_from_file()
create_course_module()
prepare_module_data()
finish_setup_course_module()
send_response()
Class: dndupload_handler - X-Ref
Stores all the information about the available dndupload handlers__construct($course, $modnames = null) X-Ref |
Gather a list of dndupload handlers from the different mods param: object $course The course this is being added to (to check course_allowed_module() ) |
register_type($identifier, $datatransfertypes, $addmessage, $namemessage, $handlermessage, $priority=100) X-Ref |
Used to add a new mime type that can be drag and dropped onto a course displayed in a browser window param: string $identifier The name that this type will be known as param: array $datatransfertypes An array of the different types in the browser param: string $addmessage The message to display in the browser when this type is being param: string $namemessage The message to pop up when asking for the name to give the param: string $handlermessage The message to pop up when asking which module should handle this type param: int $priority Controls the order in which types are checked by the browser (mainly |
register_type_handler($type, $module, $message, $noname) X-Ref |
Used to declare that a particular module will handle a particular type of dropped data param: string $type The name of the type (as declared in register_type) param: string $module The name of the module to handle this type param: string $message The message to show the user if more than one handler is registered param: bool $noname If true, the 'name' dialog should be disabled in the pop-up. |
register_file_handler($extension, $module, $message) X-Ref |
Used to declare that a particular module will handle a particular type of dropped file param: string $extension The file extension to handle ('*' for all types) param: string $module The name of the module to handle this type param: string $message The message to show the user if more than one handler is registered |
is_known_type($type) X-Ref |
Check to see if the type has been registered param: string $type The identifier of the type you are interested in return: bool True if the type is registered |
has_type_handler($module, $type) X-Ref |
Check to see if the module in question has registered to handle the type given param: string $module The name of the module param: string $type The identifier of the type return: bool True if the module has registered to handle that type |
has_file_handler($module, $extension) X-Ref |
Check to see if the module in question has registered to handle files with the given extension (or to handle all file types) param: string $module The name of the module param: string $extension The extension of the uploaded file return: bool True if the module has registered to handle files with |
get_handled_file_types($module) X-Ref |
Gets a list of the file types that are handled by a particular module param: string $module The name of the module to check return: array of file extensions or string '*' |
get_js_data() X-Ref |
Returns an object to pass onto the javascript code with data about all the registered file / type handlers return: object Data to pass on to Javascript code |
type_compare($type1, $type2) X-Ref |
Comparison function used when sorting types by priority param: object $type1 first type to compare param: object $type2 second type to compare return: integer -1 for $type1 < $type2; 1 for $type1 > $type2; 0 for equal |
Class: dndupload_ajax_processor - X-Ref
Processes the upload, creating the course module and returning the result__construct($courseid, $section, $type, $modulename) X-Ref |
Set up some basic information needed to handle the upload param: int $courseid The ID of the course we are uploading to param: int $section The section number we are uploading to param: string $type The type of upload (as reported by the browser) param: string $modulename The name of the module requested to handle this upload |
is_file_upload() X-Ref |
Check if this upload is a 'file' upload return: bool true if it is a 'file' upload, false otherwise |
process($displayname = null, $content = null) X-Ref |
Process the upload - creating the module in the course and returning the result to the browser param: string $displayname optional the name (from the browser) to give the course module instance param: string $content optional the content of the upload (for non-file uploads) |
handle_file_upload() X-Ref |
Handle uploads containing files - create the course module, ask the upload repository to process the file, ask the mod to set itself up, then return the result to the browser |
handle_other_upload($content) X-Ref |
Handle uploads not containing file - create the course module, ask the mod to set itself up, then return the result to the browser param: string $content the content uploaded to the browser |
display_name_from_file($filename) X-Ref |
Generate the name of the mod instance from the name of the file (remove the extension and convert underscore => space param: string $filename the filename of the uploaded file return: string the display name to use |
create_course_module() X-Ref |
Create the coursemodule to hold the file/content that has been uploaded |
prepare_module_data($draftitemid = null, $content = null) X-Ref |
Gather together all the details to pass on to the mod, so that it can initialise it's own database tables param: int $draftitemid optional the id of the draft area containing the file (for file uploads) param: string $content optional the content dropped onto the course (for non-file uploads) return: object data to pass on to the mod, containing: |
finish_setup_course_module($instanceid) X-Ref |
Called after the mod has set itself up, to finish off any course module settings (set instance id, add to correct section, set visibility, etc.) and send the response param: int $instanceid id returned by the mod when it was created |
send_response($mod) X-Ref |
Send the details of the newly created activity back to the client browser param: cm_info $mod details of the mod just created |
dndupload_add_to_course($course, $modnames) X-Ref |
Add the Javascript to enable drag and drop upload to a course page param: object $course The currently displayed course param: array $modnames The list of enabled (visible) modules on this site return: void |