timeline: if a section is set to hidden and the user is not capable of editing a...
[moodle-blog-course-format.git] / lib / form / file.php
blob6d7726f11b66c0346cbe936c20d461ee15f500bb
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 parent::HTML_QuickForm_file($elementName, $elementLabel, $attributes);
20 /**
21 * set html for help button
23 * @access public
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);
30 }else{
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);
41 /**
42 * set html for help button
44 * @access public
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;
52 /**
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]);
60 return true;
62 return parent::onQuickFormEvent($event, $arg, $caller);
63 } // end func onQuickFormEvent
64 /**
65 * Slightly different container template when frozen.
67 * @return string
69 function getElementTemplateType(){
70 if ($this->_flagFrozen){
71 return 'static';
72 } else {
73 return 'default';