0, 'maxbytes'=>0, 'maxfiles'=>0); function MoodleQuickForm_filemanager($elementName=null, $elementLabel=null, $options=null, $attributes=null) { global $CFG; $options = (array)$options; foreach ($options as $name=>$value) { if (array_key_exists($name, $this->_options)) { $this->_options[$name] = $value; } } if (!empty($options['filetypes'])) { $this->filetypes = $options['filetypes']; } else { $this->filetypes = '*'; } if (!empty($options['returnvalue'])) { $this->returnvalue = $options['returnvalue']; } else { $this->returnvalue = '*'; } if (!empty($options['maxbytes'])) { $this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']); } parent::HTML_QuickForm_element($elementName, $elementLabel, $attributes); } function setName($name) { $this->updateAttributes(array('name'=>$name)); } function getName() { return $this->getAttribute('name'); } function setValue($value) { $this->updateAttributes(array('value'=>$value)); } function getValue() { return $this->getAttribute('value'); } function getMaxbytes() { return $this->_options['maxbytes']; } function setMaxbytes($maxbytes) { global $CFG; $this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $maxbytes); } function getSubdirs() { return $this->_options['subdirs']; } function setSubdirs($allow) { $this->_options['subdirs'] = $allow; } function getMaxfiles() { return $this->_options['maxfiles']; } function setMaxfiles($num) { $this->_options['maxfiles'] = $num; } function setHelpButton($helpbuttonargs, $function='helpbutton'){ if (!is_array($helpbuttonargs)){ $helpbuttonargs=array($helpbuttonargs); }else{ $helpbuttonargs=$helpbuttonargs; } //we do this to to return html instead of printing it //without having to specify it in every call to make a button. if ('helpbutton' == $function){ $defaultargs=array('', '', 'moodle', true, false, '', true); $helpbuttonargs=$helpbuttonargs + $defaultargs ; } $this->_helpbutton=call_user_func_array($function, $helpbuttonargs); } function getHelpButton() { return $this->_helpbutton; } function getElementTemplateType() { if ($this->_flagFrozen){ return 'nodisplay'; } else { return 'default'; } } function _get_draftfiles($draftid, $suffix) { global $USER, $CFG; $html = ''; if (!$context = get_context_instance(CONTEXT_USER, $USER->id)) { } $contextid = $context->id; $filearea = 'user_draft'; $browser = get_file_browser(); $fs = get_file_storage(); $filepath = '/'; if (!$directory = $fs->get_file($context->id, 'user_draft', $draftid, $filepath, '.')) { $directory = new virtual_root_file($context->id, 'user_draft', $draftid); $filepath = $directory->get_filepath(); } $files = $fs->get_directory_files($context->id, 'user_draft', $draftid, $directory->get_filepath()); $parent = $directory->get_parent_directory(); $html .= '
';;
html += '