MDL-10496:
[moodle-linuxchix.git] / lib / form / textarea.php
blob06d3ed1a4be51e678c1660cd75dc799eb2cb2e1d
1 <?php
2 require_once('HTML/QuickForm/textarea.php');
4 /**
5 * HTML class for a textarea type element
7 * @author Jamie Pratt
8 * @access public
9 */
10 class MoodleQuickForm_textarea extends HTML_QuickForm_textarea{
11 /**
12 * Need to store id of form as we may need it for helpbutton
14 * @var string
16 var $_formid = '';
17 /**
18 * html for help button, if empty then no help
20 * @var string
22 var $_helpbutton='';
23 /**
24 * set html for help button
26 * @access public
27 * @param array $help array of arguments to make a help button
28 * @param string $function function name to call to get html
30 function setHelpButton($helpbuttonargs, $function='helpbutton'){
31 global $SESSION;
32 if (!is_array($helpbuttonargs)){
33 $helpbuttonargs=array($helpbuttonargs);
34 }else{
35 $helpbuttonargs=$helpbuttonargs;
37 //we do this to to return html instead of printing it
38 //without having to specify it in every call to make a button.
39 if ('helpbutton' == $function){
40 $defaultargs=array('', '', 'moodle', true, false, '', true);
41 $helpbuttonargs=$helpbuttonargs + $defaultargs ;
42 } elseif ('editorhelpbutton' == $function){
43 if (in_array('emoticons', $helpbuttonargs)){
44 $SESSION->inserttextform = $this->_formid;
45 $SESSION->inserttextfield = $this->getAttribute('name');
48 $this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
50 /**
51 * get html for help button
53 * @access public
54 * @return string html for help button
56 function getHelpButton(){
57 return $this->_helpbutton;
59 /**
60 * Called by HTML_QuickForm whenever form event is made on this element
62 * @param string $event Name of event
63 * @param mixed $arg event arguments
64 * @param object $caller calling object
65 * @since 1.0
66 * @access public
67 * @return void
69 function onQuickFormEvent($event, $arg, &$caller)
71 switch ($event) {
72 case 'createElement':
73 $this->_formid = $caller->getAttribute('id');
74 break;
76 return parent::onQuickFormEvent($event, $arg, $caller);
77 } // end func onQuickFormEvent
78 /**
79 * Slightly different container template when frozen.
81 * @return string
83 function getElementTemplateType(){
84 if ($this->_flagFrozen){
85 return 'static';
86 } else {
87 return 'default';