class MoodleQuickForm_filemanager extends HTML_QuickForm_element {
protected $_helpbutton = '';
- protected $_options = array('subdirs'=>0, 'maxbytes'=>0, 'maxfiles'=>-1);
+ protected $_options = array('subdirs'=>0, 'maxbytes'=>0, 'maxfiles'=>-1, 'filetypes'=>'*', 'returnvalue'=>'*');
- function MoodleQuickForm_filemanager($elementName=null, $elementLabel=null, $options=null, $attributes=null) {
+ function MoodleQuickForm_filemanager($elementName=null, $elementLabel=null, $attributes=null, $options=null) {
global $CFG;
$options = (array)$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']);
}
* @access public
*/
class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
- var $_helpbutton='';
+ protected $_helpbutton = '';
+ protected $_options = array('maxbytes'=>0, 'filetypes'=>'*', 'returnvalue'=>'*');
+
+ function MoodleQuickForm_filepicker($elementName=null, $elementLabel=null, $attributes=null, $options=null) {
+ global $CFG;
- function MoodleQuickForm_filepicker($elementName=null, $elementLabel=null, $attributes=null, $filetypes = '*', $returnvalue = '*') {
- $this->filetypes = $filetypes;
- $this->returnvalue = $returnvalue;
+ $options = (array)$options;
+ foreach ($options as $name=>$value) {
+ if (array_key_exists($name, $this->_options)) {
+ $this->_options[$name] = $value;
+ }
+ }
+ if (!empty($options['maxbytes'])) {
+ $this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']);
+ }
parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
}
$context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
}
$client_id = uniqid();
- $repository_info = repository_get_client($context, $client_id, $this->filetypes, $this->returnvalue);
+ $repository_info = repository_get_client($context, $client_id, $this->_options['filetypes'], $this->_options['returnvalue']);
$id = $this->_attributes['id'];
$elname = $this->_attributes['name'];
}
if (!empty($forum->maxattachments) && $forum->maxbytes != 1 && has_capability('mod/forum:createattachment', $modcontext)) { // 1 = No attachments at all
- $mform->addElement('filemanager', 'attachments', get_string('attachment', 'forum'),
+ $mform->addElement('filemanager', 'attachments', get_string('attachment', 'forum'), null,
array('subdirs'=>0,
'maxbytes'=>$forum->maxbytes,
'maxfiles'=>$forum->maxattachments,
$mform->setType('aliases', PARAM_TEXT);
$mform->setHelpButton('aliases', array('aliases2', strip_tags(get_string('aliases', 'glossary')), 'glossary'));
- $mform->addElement('filemanager', 'attachment_filemanager', get_string('attachment', 'glossary'), $attachmentoptions);
+ $mform->addElement('filemanager', 'attachment_filemanager', get_string('attachment', 'glossary'), null, $attachmentoptions);
$mform->setHelpButton('attachment_filemanager', array('attachment2', get_string('attachment', 'glossary'), 'glossary'));
if (!$glossary->usedynalink) {