Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / lib / form / text.php
blobb0eccb4f897c2c4c8d5c8ed9e0f343ef4a020bbc
1 <?php
2 require_once("HTML/QuickForm/text.php");
4 /**
5 * HTML class for a text type element
7 * @author Jamie Pratt
8 * @access public
9 */
10 class MoodleQuickForm_text extends HTML_QuickForm_text{
11 /**
12 * html for help button, if empty then no help
14 * @var string
16 var $_helpbutton='';
17 var $_hiddenLabel=false;
18 function setHiddenLabel($hiddenLabel){
19 $this->_hiddenLabel = $hiddenLabel;
21 function toHtml(){
22 if ($this->_hiddenLabel){
23 $this->_generateId();
24 return '<label class="accesshide" for="'.$this->getAttribute('id').'" >'.
25 $this->getLabel().'</label>'.parent::toHtml();
26 } else {
27 return parent::toHtml();
30 /**
31 * Automatically generates and assigns an 'id' attribute for the element.
33 * Currently used to ensure that labels work on radio buttons and
34 * checkboxes. Per idea of Alexander Radivanovich.
35 * Overriden in moodleforms to remove qf_ prefix.
37 * @access private
38 * @return void
40 function _generateId()
42 static $idx = 1;
44 if (!$this->getAttribute('id')) {
45 $this->updateAttributes(array('id' => 'id_'. substr(md5(microtime() . $idx++), 0, 6)));
47 } // end func _generateId
48 /**
49 * set html for help button
51 * @access public
52 * @param array $help array of arguments to make a help button
53 * @param string $function function name to call to get html
55 function setHelpButton($helpbuttonargs, $function='helpbutton'){
56 if (!is_array($helpbuttonargs)){
57 $helpbuttonargs=array($helpbuttonargs);
58 }else{
59 $helpbuttonargs=$helpbuttonargs;
61 //we do this to to return html instead of printing it
62 //without having to specify it in every call to make a button.
63 if ('helpbutton' == $function){
64 $defaultargs=array('', '', 'moodle', true, false, '', true);
65 $helpbuttonargs=$helpbuttonargs + $defaultargs ;
67 $this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
69 /**
70 * get html for help button
72 * @access public
73 * @return string html for help button
75 function getHelpButton(){
76 return $this->_helpbutton;
78 /**
79 * Slightly different container template when frozen. Don't want to use a label tag
80 * with a for attribute in that case for the element label but instead use a div.
81 * Templates are defined in renderer constructor.
83 * @return string
85 function getElementTemplateType(){
86 if ($this->_flagFrozen){
87 return 'static';
88 } else {
89 return 'default';