2 require_once('HTML/QuickForm/file.php');
5 * HTML class for a form element to upload a file
10 class MoodleQuickForm_file
extends HTML_QuickForm_file
{
12 * html for help button, if empty then no help
17 function MoodleQuickForm_file($elementName=null, $elementLabel=null, $attributes=null) {
18 parent
::HTML_QuickForm_file($elementName, $elementLabel, $attributes);
21 * set html for help button
24 * @param array $help array of arguments to make a help button
25 * @param string $function function name to call to get html
27 function setHelpButton($helpbuttonargs, $function='helpbutton'){
28 if (!is_array($helpbuttonargs)){
29 $helpbuttonargs=array($helpbuttonargs);
31 $helpbuttonargs=$helpbuttonargs;
33 //we do this to to return html instead of printing it
34 //without having to specify it in every call to make a button.
35 if ('helpbutton' == $function){
36 $defaultargs=array('', '', 'moodle', true, false, '', true);
37 $helpbuttonargs=$helpbuttonargs +
$defaultargs ;
39 $this->_helpbutton
=call_user_func_array($function, $helpbuttonargs);
42 * set html for help button
45 * @param array $help array of arguments to make a help button
46 * @param string $function function name to call to get html
48 function getHelpButton(){
49 return $this->_helpbutton
;
53 * Override createElement event to add max files
55 function onQuickFormEvent($event, $arg, &$caller)
57 if ($event == 'createElement') {
58 $className = get_class($this);
59 $this->$className($arg[0], $arg[1].' ('.get_string('maxsize', '', display_size($caller->getMaxFileSize())).')', $arg[2]);
62 return parent
::onQuickFormEvent($event, $arg, $caller);
63 } // end func onQuickFormEvent
65 * Slightly different container template when frozen.
69 function getElementTemplateType(){
70 if ($this->_flagFrozen
){