Merge branch 'MDL-32657-master-1' of git://git.luns.net.uk/moodle
[moodle.git] / lib / form / file.php
blob259881b50424ca0a4465f396ee38b6afdce83e94
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * File type form element
21 * Contains HTML class for a file type form element
23 * @package core_form
24 * @copyright 2007 Jamie Pratt <me@jamiep.org>
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 require_once('HTML/QuickForm/file.php');
30 /**
31 * file element
33 * HTML class for a form element to upload a file
35 * @package core_form
36 * @deprecated since Moodle 2.0 Please do not use this form element.
37 * @todo MDL-31294 remove this element
38 * @see MoodleQuickForm_filepicker
39 * @see MoodleQuickForm_filemanager
40 * @copyright 2007 Jamie Pratt <me@jamiep.org>
41 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
43 class MoodleQuickForm_file extends HTML_QuickForm_file{
44 /** @var string html for help button, if empty then no help */
45 var $_helpbutton='';
47 /**
48 * Constructor
50 * @param string $elementName (optional) name of the editor
51 * @param string $elementLabel (optional) editor label
52 * @param array $attributes (optional) Either a typical HTML attribute string
53 * or an associative array
55 function MoodleQuickForm_file($elementName=null, $elementLabel=null, $attributes=null) {
56 debugging('file forms element is deprecated, please use new filepicker instead');
57 parent::HTML_QuickForm_file($elementName, $elementLabel, $attributes);
59 /**
60 * set html for help button
62 * @param array $helpbuttonargs array of arguments to make a help button
63 * @param string $function function name to call to get html
64 * @deprecated since Moodle 2.0. Please do not call this function any more.
65 * @todo MDL-31047 this api will be removed.
66 * @see MoodleQuickForm::setHelpButton()
68 function setHelpButton($helpbuttonargs, $function='helpbutton'){
69 debugging('component setHelpButton() is not used any more, please use $mform->setHelpButton() instead');
71 /**
72 * set html for help button
74 function getHelpButton(){
75 return $this->_helpbutton;
78 /**
79 * Override createElement event to add max files
81 * @param string $event Name of event
82 * @param mixed $arg event arguments
83 * @param object $caller calling object
84 * @return bool
86 function onQuickFormEvent($event, $arg, &$caller)
88 if ($event == 'createElement') {
89 $className = get_class($this);
90 $this->$className($arg[0], $arg[1].' ('.get_string('maxsize', '', display_size($caller->getMaxFileSize())).')', $arg[2]);
91 return true;
93 return parent::onQuickFormEvent($event, $arg, $caller);
96 /**
97 * Slightly different container template when frozen.
99 * @return string
101 function getElementTemplateType(){
102 if ($this->_flagFrozen){
103 return 'static';
104 } else {
105 return 'default';