2004-09-30 22:49:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class to build various forms
|
|
|
|
|
*/
|
|
|
|
|
class HTMLForm {
|
2004-09-30 23:44:54 +00:00
|
|
|
/** name of our form. Used as prefix for labels */
|
|
|
|
|
var $mName;
|
|
|
|
|
|
2004-09-30 22:49:26 +00:00
|
|
|
/* private */ function fieldset( $name, $content ) {
|
2004-09-30 23:44:54 +00:00
|
|
|
return "<fieldset><legend>".wfMsg($this->mName.'-'.$name)."</legend>\n" .
|
2004-09-30 22:49:26 +00:00
|
|
|
$content . "\n</fieldset>\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* private */ function checkbox( $varname, $checked=false ) {
|
|
|
|
|
$checked = isset( $GLOBALS[$varname] ) && $GLOBALS[$varname] ;
|
|
|
|
|
return "<div><input type='checkbox' value=\"1\" id=\"{$varname}\" name=\"wpOp{$varname}\"" .
|
|
|
|
|
( $checked ? ' checked="checked"' : '' ) .
|
2004-09-30 23:44:54 +00:00
|
|
|
" /><label for=\"{$varname}\">". wfMsg( $this->mName.'-'.$varname ) .
|
2004-09-30 22:49:26 +00:00
|
|
|
"</label></div>\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* private */ function textbox( $varname, $value='', $size=20 ) {
|
|
|
|
|
$value = isset( $GLOBALS[$varname] ) ? $GLOBALS[$varname] : '';
|
2004-09-30 23:44:54 +00:00
|
|
|
return "<div><label>". wfMsg( $this->mName.'-'.$varname ) .
|
2004-09-30 22:49:26 +00:00
|
|
|
"<input type='text' name=\"wpOp{$varname}\" value=\"{$value}\" size=\"{$size}\" /></label></div>\n";
|
|
|
|
|
}
|
|
|
|
|
/* private */ function radiobox( $varname, $fields ) {
|
|
|
|
|
foreach ( $fields as $value => $checked ) {
|
|
|
|
|
$s .= "<div><label><input type='radio' name=\"wpOp{$varname}\" value=\"{$value}\"" .
|
2004-09-30 23:44:54 +00:00
|
|
|
( $checked ? ' checked="checked"' : '' ) . " />" . wfMsg( $this->mName.'-'.$varname.'-'.$value ) .
|
2004-09-30 22:49:26 +00:00
|
|
|
"</label></div>\n";
|
|
|
|
|
}
|
2004-09-30 23:44:54 +00:00
|
|
|
return $this->fieldset( $this->mName'-'.$varname, $s );
|
2004-09-30 22:49:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* private */ function arraybox( $varname , $size=20 ) {
|
|
|
|
|
$s = '';
|
|
|
|
|
if ( isset( $GLOBALS[$varname] ) && is_array( $GLOBALS[$varname] ) ) {
|
|
|
|
|
foreach ( $GLOBALS[$varname] as $index=>$element ) {
|
|
|
|
|
$s .= $element."\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-09-30 23:44:54 +00:00
|
|
|
return "<div><label>".wfMsg( $this->mName.'-'.$varname ).
|
2004-09-30 22:49:26 +00:00
|
|
|
"<textarea name=\"wpOp{$varname}\" rows=\"5\" cols=\"{$size}\">{$s}</textarea>\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|