示例#1
0
/**
 * 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
 */
function dndupload_add_to_course($course, $modnames)
{
    global $CFG, $PAGE;
    // Get all handlers.
    $handler = new dndupload_handler($course, $modnames);
    $jsdata = $handler->get_js_data();
    if (empty($jsdata->types) && empty($jsdata->filehandlers)) {
        return;
        // No valid handlers - don't enable drag and drop.
    }
    // Add the javascript to the page.
    $jsmodule = array('name' => 'coursedndupload', 'fullpath' => new moodle_url('/course/dndupload.js'), 'strings' => array(array('addfilehere', 'moodle'), array('dndworkingfiletextlink', 'moodle'), array('dndworkingfilelink', 'moodle'), array('dndworkingfiletext', 'moodle'), array('dndworkingfile', 'moodle'), array('dndworkingtextlink', 'moodle'), array('dndworkingtext', 'moodle'), array('dndworkinglink', 'moodle'), array('filetoolarge', 'moodle'), array('actionchoice', 'moodle'), array('servererror', 'moodle'), array('upload', 'moodle'), array('cancel', 'moodle')), 'requires' => array('node', 'event', 'panel', 'json'));
    $vars = array(array('courseid' => $course->id, 'maxbytes' => get_max_upload_file_size($CFG->maxbytes, $course->maxbytes), 'handlers' => $handler->get_js_data()));
    $PAGE->requires->js_init_call('M.course_dndupload.init', $vars, true, $jsmodule);
}
示例#2
0
 /**
  * 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
  */
 protected static function dndupload_add_to_course($course, $modnames)
 {
     global $CFG, $PAGE;
     $showstatus = optional_param('notifyeditingon', false, PARAM_BOOL);
     // Get all handlers.
     $handler = new \dndupload_handler($course, $modnames);
     $jsdata = $handler->get_js_data();
     if (empty($jsdata->types) && empty($jsdata->filehandlers)) {
         return;
         // No valid handlers - don't enable drag and drop.
     }
     // Add the javascript to the page.
     $jsmodule = array('name' => 'coursedndupload', 'fullpath' => '/theme/snap/javascript/dndupload.js', 'strings' => array(array('addfilehere', 'moodle'), array('dndworkingfiletextlink', 'moodle'), array('dndworkingfilelink', 'moodle'), array('dndworkingfiletext', 'moodle'), array('dndworkingfile', 'moodle'), array('dndworkingtextlink', 'moodle'), array('dndworkingtext', 'moodle'), array('dndworkinglink', 'moodle'), array('namedfiletoolarge', 'moodle'), array('actionchoice', 'moodle'), array('servererror', 'moodle'), array('upload', 'moodle'), array('cancel', 'moodle'), array('modulename', 'mod_label')), 'requires' => array('node', 'event', 'json', 'anim'));
     $vars = array(array('courseid' => $course->id, 'maxbytes' => get_max_upload_file_size($CFG->maxbytes, $course->maxbytes), 'handlers' => $handler->get_js_data(), 'showstatus' => $showstatus));
     $PAGE->requires->js('/course/dndupload.js');
     $PAGE->requires->js_init_call('M.theme_snap.dndupload.init', $vars, true, $jsmodule);
 }