EOD;
$module = array('name'=>'form_filepicker', 'fullpath'=>'/lib/form/filepicker.js', 'requires'=>array('core_filepicker'));
$PAGE->requires->js_init_call('M.form_filepicker.init', array($options), true, $module);
return $str;
}
function exportValue(&$submitValues, $assoc = false) {
global $USER;
// make sure max one file is present and it is not too big
if ($draftitemid = $submitValues[$this->_attributes['name']]) {
$fs = get_file_storage();
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
if ($files = $fs->get_area_files($usercontext->id, 'user_draft', $draftitemid, 'id DESC', false)) {
$file = array_shift($files);
if ($this->_options['maxbytes'] and $file->get_filesize() > $this->_options['maxbytes']) {
// bad luck, somebody tries to sneak in oversized file
$file->delete();
}
foreach ($files as $file) {
// only one file expected
$file->delete();
}
}
}
return array($this->_attributes['name'] => $submitValues[$this->_attributes['name']]);
}
}