Let Database do the quoting of the 'group' table, so that prefixed tables will work.
[lhc/web/wiklou.git] / includes / HTMLForm.php
1 <?php
2 /**
3 * Class to build various forms
4 *
5 * @package MediaWiki
6 * @author jeluf, hashar
7 */
8 class HTMLForm {
9 /** name of our form. Used as prefix for labels */
10 var $mName;
11
12 /**
13 * @access private
14 * @param string $name Name of the fieldset.
15 * @param string $content HTML content to put in.
16 * @return string HTML fieldset
17 */
18 function fieldset( $name, $content ) {
19 return "<fieldset><legend>".wfMsg($this->mName.'-'.$name)."</legend>\n" .
20 $content . "\n</fieldset>\n";
21 }
22
23 /*
24 * @access private
25 * @param string $varname Name of the checkbox.
26 * @param boolean $checked Set true to check the box (default False).
27 */
28 function checkbox( $varname, $checked=false ) {
29 $checked = isset( $_POST[$varname] ) && $_POST[$varname] ;
30 return "<div><input type='checkbox' value=\"1\" id=\"{$varname}\" name=\"wpOp{$varname}\"" .
31 ( $checked ? ' checked="checked"' : '' ) .
32 " /><label for=\"{$varname}\">". wfMsg( $this->mName.'-'.$varname ) .
33 "</label></div>\n";
34 }
35
36 /*
37 * @access private
38 * @param string $varname Name of the textbox.
39 * @param string $value Optional value (default empty)
40 * @param integer $size Optional size of the textbox (default 20)
41 */
42 function textbox( $varname, $value='', $size=20 ) {
43 $value = isset( $_POST[$varname] ) ? $_POST[$varname] : $value;
44 return "<div><label>". wfMsg( $this->mName.'-'.$varname ) .
45 "<input type='text' name=\"{$varname}\" value=\"{$value}\" size=\"{$size}\" /></label></div>\n";
46 }
47
48 /*
49 * @access private
50 * @param string $varname Name of the radiobox.
51 * @param array $fields Various fields.
52 */
53 function radiobox( $varname, $fields ) {
54 foreach ( $fields as $value => $checked ) {
55 $s .= "<div><label><input type='radio' name=\"{$varname}\" value=\"{$value}\"" .
56 ( $checked ? ' checked="checked"' : '' ) . " />" . wfMsg( $this->mName.'-'.$varname.'-'.$value ) .
57 "</label></div>\n";
58 }
59 return $this->fieldset( $this->mName.'-'.$varname, $s );
60 }
61
62 /*
63 * @access private
64 * @param string $varname Name of the textareabox.
65 * @param string $value Optional value (default empty)
66 * @param integer $size Optional size of the textarea (default 20)
67 */
68 function textareabox ( $varname, $value='', $size=20 ) {
69 $value = isset( $_POST[$varname] ) ? $_POST[$varname] : $value;
70 return '<div><label>'.wfMsg( $this->mName.'-'.$varname ).
71 "<textarea name=\"{$varname}\" rows=\"5\" cols=\"{$size}\">$value</textarea></label></div>\n";
72 }
73
74 /*
75 * @access private
76 * @param string $varname Name of the arraybox.
77 * @param integer $size Optional size of the textarea (default 20)
78 */
79 function arraybox( $varname , $size=20 ) {
80 $s = '';
81 if ( isset( $_POST[$varname] ) && is_array( $_POST[$varname] ) ) {
82 foreach ( $_POST[$varname] as $index=>$element ) {
83 $s .= $element."\n";
84 }
85 }
86 return "<div><label>".wfMsg( $this->mName.'-'.$varname ).
87 "<textarea name=\"{$varname}\" rows=\"5\" cols=\"{$size}\">{$s}</textarea>\n";
88 }
89 }
90 ?>