timeline: if a section is set to hidden and the user is not capable of editing a...
[moodle-blog-course-format.git] / lib / form / textarea.php
blob21095f59d6637ef35ae5e04fc88eaadc58da3d0b
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 function MoodleQuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null) {
24 parent::HTML_QuickForm_textarea($elementName, $elementLabel, $attributes);
27 /**
28 * set html for help button
30 * @access public
31 * @param array $help array of arguments to make a help button
32 * @param string $function function name to call to get html
34 function setHelpButton($helpbuttonargs, $function='helpbutton'){
35 global $SESSION;
36 if (!is_array($helpbuttonargs)){
37 $helpbuttonargs=array($helpbuttonargs);
38 }else{
39 $helpbuttonargs=$helpbuttonargs;
41 //we do this to to return html instead of printing it
42 //without having to specify it in every call to make a button.
43 if ('helpbutton' == $function){
44 $defaultargs=array('', '', 'moodle', true, false, '', true);
45 $helpbuttonargs=$helpbuttonargs + $defaultargs ;
46 } elseif ('editorhelpbutton' == $function){
47 if (in_array('emoticons', $helpbuttonargs)){
48 $SESSION->inserttextform = $this->_formid;
49 $SESSION->inserttextfield = $this->getAttribute('name');
52 $this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
54 /**
55 * get html for help button
57 * @access public
58 * @return string html for help button
60 function getHelpButton(){
61 return $this->_helpbutton;
63 /**
64 * Called by HTML_QuickForm whenever form event is made on this element
66 * @param string $event Name of event
67 * @param mixed $arg event arguments
68 * @param object $caller calling object
69 * @since 1.0
70 * @access public
71 * @return void
73 function onQuickFormEvent($event, $arg, &$caller)
75 switch ($event) {
76 case 'createElement':
77 $this->_formid = $caller->getAttribute('id');
78 break;
80 return parent::onQuickFormEvent($event, $arg, $caller);
81 } // end func onQuickFormEvent
82 /**
83 * Slightly different container template when frozen.
85 * @return string
87 function getElementTemplateType(){
88 if ($this->_flagFrozen){
89 return 'static';
90 } else {
91 return 'default';