Moodle 2.0.3 release
[moodle.git] / lib / form / file.php
blob2f69f60b60c11a1f2340136173935db495129031
1 <?php
2 require_once('HTML/QuickForm/file.php');
4 /**
5 * HTML class for a form element to upload a file
7 * @author Jamie Pratt
8 * @access public
9 */
10 class MoodleQuickForm_file extends HTML_QuickForm_file{
11 /**
12 * html for help button, if empty then no help
14 * @var string
16 var $_helpbutton='';
17 function MoodleQuickForm_file($elementName=null, $elementLabel=null, $attributes=null) {
18 debugging('file forms element is deprecated, please use new filepicker instead');
19 parent::HTML_QuickForm_file($elementName, $elementLabel, $attributes);
21 /**
22 * set html for help button
24 * @access public
25 * @param array $help array of arguments to make a help button
26 * @param string $function function name to call to get html
28 function setHelpButton($helpbuttonargs, $function='helpbutton'){
29 debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
31 /**
32 * set html for help button
34 * @access public
35 * @param array $help array of arguments to make a help button
36 * @param string $function function name to call to get html
38 function getHelpButton(){
39 return $this->_helpbutton;
42 /**
43 * Override createElement event to add max files
45 function onQuickFormEvent($event, $arg, &$caller)
47 if ($event == 'createElement') {
48 $className = get_class($this);
49 $this->$className($arg[0], $arg[1].' ('.get_string('maxsize', '', display_size($caller->getMaxFileSize())).')', $arg[2]);
50 return true;
52 return parent::onQuickFormEvent($event, $arg, $caller);
53 } // end func onQuickFormEvent
54 /**
55 * Slightly different container template when frozen.
57 * @return string
59 function getElementTemplateType(){
60 if ($this->_flagFrozen){
61 return 'static';
62 } else {
63 return 'default';