MDL-13766
[moodle.git] / lib / form / filepicker.php
CommitLineData
c5704ec6 1<?php
2// $Id$
3
4require_once("HTML/QuickForm/button.php");
5require_once(dirname(dirname(dirname(__FILE__))) . '/repository/lib.php');
6
7/**
8 * HTML class for a button type element
9 *
10 * @author Dongsheng Cai <dongsheng@cvs.moodle.org>
11 * @version 1.0
12 * @since Moodle 2.0
13 * @access public
14 */
15class MoodleQuickForm_filepicker extends HTML_QuickForm_button
16{
17 var $_helpbutton='';
18 function setHelpButton($helpbuttonargs, $function='helpbutton'){
19 if (!is_array($helpbuttonargs)){
20 $helpbuttonargs=array($helpbuttonargs);
21 }else{
22 $helpbuttonargs=$helpbuttonargs;
23 }
24 //we do this to to return html instead of printing it
25 //without having to specify it in every call to make a button.
26 if ('helpbutton' == $function){
27 $defaultargs=array('', '', 'moodle', true, false, '', true);
28 $helpbuttonargs=$helpbuttonargs + $defaultargs ;
29 }
30 $this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
31 }
32 function getHelpButton(){
33 return $this->_helpbutton;
34 }
35 function getElementTemplateType(){
36 if ($this->_flagFrozen){
37 return 'nodisplay';
38 } else {
39 return 'default';
40 }
41 }
42 function toHtml() {
43 global $CFG;
44 if ($this->_flagFrozen) {
45 return $this->getFrozenHtml();
46 } else {
47 $ret = get_repository_client();
48 return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' onclick=\'openpicker()\' />'.$ret['html'].$ret['js'];
49 }
50 }
51}