removing occurences of sitesettings. Replaced by an internal name.
[lhc/web/wiklou.git] / includes / HTMLForm.php
1 <?php
2
3 /**
4 * Class to build various forms
5 */
6 class HTMLForm {
7 /** name of our form. Used as prefix for labels */
8 var $mName;
9
10 /* private */ function fieldset( $name, $content ) {
11 return "<fieldset><legend>".wfMsg($this->mName.'-'.$name)."</legend>\n" .
12 $content . "\n</fieldset>\n";
13 }
14
15 /* private */ function checkbox( $varname, $checked=false ) {
16 $checked = isset( $GLOBALS[$varname] ) && $GLOBALS[$varname] ;
17 return "<div><input type='checkbox' value=\"1\" id=\"{$varname}\" name=\"wpOp{$varname}\"" .
18 ( $checked ? ' checked="checked"' : '' ) .
19 " /><label for=\"{$varname}\">". wfMsg( $this->mName.'-'.$varname ) .
20 "</label></div>\n";
21 }
22
23 /* private */ function textbox( $varname, $value='', $size=20 ) {
24 $value = isset( $GLOBALS[$varname] ) ? $GLOBALS[$varname] : '';
25 return "<div><label>". wfMsg( $this->mName.'-'.$varname ) .
26 "<input type='text' name=\"wpOp{$varname}\" value=\"{$value}\" size=\"{$size}\" /></label></div>\n";
27 }
28 /* private */ function radiobox( $varname, $fields ) {
29 foreach ( $fields as $value => $checked ) {
30 $s .= "<div><label><input type='radio' name=\"wpOp{$varname}\" value=\"{$value}\"" .
31 ( $checked ? ' checked="checked"' : '' ) . " />" . wfMsg( $this->mName.'-'.$varname.'-'.$value ) .
32 "</label></div>\n";
33 }
34 return $this->fieldset( $this->mName'-'.$varname, $s );
35 }
36
37 /* private */ function arraybox( $varname , $size=20 ) {
38 $s = '';
39 if ( isset( $GLOBALS[$varname] ) && is_array( $GLOBALS[$varname] ) ) {
40 foreach ( $GLOBALS[$varname] as $index=>$element ) {
41 $s .= $element."\n";
42 }
43 }
44 return "<div><label>".wfMsg( $this->mName.'-'.$varname ).
45 "<textarea name=\"wpOp{$varname}\" rows=\"5\" cols=\"{$size}\">{$s}</textarea>\n";
46 }
47 }
48 ?>