Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dndupload_handler Class Reference

Stores all the information about the available dndupload handlers. More...

Public Member Functions

 __construct ($course, $modnames=null)
 Gather a list of dndupload handlers from the different mods. More...
 
 get_handled_file_types ($module)
 Gets a list of the file types that are handled by a particular module. More...
 
 get_js_data ()
 Returns an object to pass onto the javascript code with data about all the registered file / type handlers. More...
 
 has_file_handler ($module, $extension)
 Check to see if the module in question has registered to handle files with the given extension (or to handle all file types) More...
 
 has_type_handler ($module, $type)
 Check to see if the module in question has registered to handle the type given. More...
 
 is_known_type ($type)
 Check to see if the type has been registered. More...
 

Protected Member Functions

 register_file_handler ($extension, $module, $message)
 Used to declare that a particular module will handle a particular type of dropped file. More...
 
 register_type ($identifier, $datatransfertypes, $addmessage, $namemessage, $handlermessage, $priority=100)
 Used to add a new mime type that can be drag and dropped onto a course displayed in a browser window. More...
 
 register_type_handler ($type, $module, $message, $noname)
 Used to declare that a particular module will handle a particular type of dropped data. More...
 
 type_compare ($type1, $type2)
 Comparison function used when sorting types by priority. More...
 

Protected Attributes

context_course null $context = null
 
array $filehandlers = array()
 A list of the different file types (extensions) that different modules will handle.
 
array $types = array()
 A list of all registered mime types that can be dropped onto a course along with the modules that will handle them.
 

Detailed Description

Stores all the information about the available dndupload handlers.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

dndupload_handler::__construct (   $course,
  $modnames = null 
)

Gather a list of dndupload handlers from the different mods.

Parameters
object$courseThe course this is being added to (to check course_allowed_module() )

Member Function Documentation

◆ get_handled_file_types()

dndupload_handler::get_handled_file_types (   $module)

Gets a list of the file types that are handled by a particular module.

Parameters
string$moduleThe name of the module to check
Return values
arrayof file extensions or string '*'

◆ get_js_data()

dndupload_handler::get_js_data ( )

Returns an object to pass onto the javascript code with data about all the registered file / type handlers.

Return values
objectData to pass on to Javascript code

◆ has_file_handler()

dndupload_handler::has_file_handler (   $module,
  $extension 
)

Check to see if the module in question has registered to handle files with the given extension (or to handle all file types)

Parameters
string$moduleThe name of the module
string$extensionThe extension of the uploaded file
Return values
boolTrue if the module has registered to handle files with that extension (or to handle all file types)

◆ has_type_handler()

dndupload_handler::has_type_handler (   $module,
  $type 
)

Check to see if the module in question has registered to handle the type given.

Parameters
string$moduleThe name of the module
string$typeThe identifier of the type
Return values
boolTrue if the module has registered to handle that type

◆ is_known_type()

dndupload_handler::is_known_type (   $type)

Check to see if the type has been registered.

Parameters
string$typeThe identifier of the type you are interested in
Return values
boolTrue if the type is registered

◆ register_file_handler()

dndupload_handler::register_file_handler (   $extension,
  $module,
  $message 
)
protected

Used to declare that a particular module will handle a particular type of dropped file.

Parameters
string$extensionThe file extension to handle ('*' for all types)
string$moduleThe name of the module to handle this type
string$messageThe message to show the user if more than one handler is registered for a type and the user needs to make a choice between them

◆ register_type()

dndupload_handler::register_type (   $identifier,
  $datatransfertypes,
  $addmessage,
  $namemessage,
  $handlermessage,
  $priority = 100 
)
protected

Used to add a new mime type that can be drag and dropped onto a course displayed in a browser window.

Parameters
string$identifierThe name that this type will be known as
array$datatransfertypesAn array of the different types in the browser 'dataTransfer.types' object that will map to this type
string$addmessageThe message to display in the browser when this type is being dragged onto the page
string$namemessageThe message to pop up when asking for the name to give the course module instance when it is created
string$handlermessageThe message to pop up when asking which module should handle this type
int$priorityControls the order in which types are checked by the browser (mainly needed to check for 'text' last as that is usually given as fallback)

◆ register_type_handler()

dndupload_handler::register_type_handler (   $type,
  $module,
  $message,
  $noname 
)
protected

Used to declare that a particular module will handle a particular type of dropped data.

Parameters
string$typeThe name of the type (as declared in register_type)
string$moduleThe name of the module to handle this type
string$messageThe message to show the user if more than one handler is registered for a type and the user needs to make a choice between them
bool$nonameIf true, the 'name' dialog should be disabled in the pop-up.
Exceptions
coding_exception

◆ type_compare()

dndupload_handler::type_compare (   $type1,
  $type2 
)
protected

Comparison function used when sorting types by priority.

Parameters
object$type1first type to compare
object$type2second type to compare
Return values
integer-1 for $type1 < $type2; 1 for $type1 > $type2; 0 for equal

The documentation for this class was generated from the following file: