2004-09-30 22:49:26 +00:00
|
|
|
<?php
|
2004-10-01 03:10:10 +00:00
|
|
|
/** */
|
2004-09-30 22:49:26 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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-10-01 03:10:10 +00:00
|
|
|
/**
|
|
|
|
|
* @access private
|
|
|
|
|
* @param string $name Name of the fieldset.
|
|
|
|
|
* @param string $content HTML content to put in.
|
|
|
|
|
* @return string HTML fieldset
|
|
|
|
|
*/
|
|
|
|
|
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";
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-01 03:10:10 +00:00
|
|
|
/*
|
|
|
|
|
* @access private
|
|
|
|
|
* @param string $varname Name of the checkbox.
|
|
|
|
|
* @param boolean $checked Set true to check the box (default False).
|
|
|
|
|
*/
|
|
|
|
|
function checkbox( $varname, $checked=false ) {
|
2004-09-30 22:49:26 +00:00
|
|
|
$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";
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-01 03:10:10 +00:00
|
|
|
/*
|
|
|
|
|
* @access private
|
|
|
|
|
* @param string $varname Name of the textbox.
|
|
|
|
|
* @param string $value Optional value (default empty)
|
|
|
|
|
* @param integer $size Optional size of the textbox (default 20)
|
|
|
|
|
*/
|
|
|
|
|
function textbox( $varname, $value='', $size=20 ) {
|
2004-10-01 03:01:22 +00:00
|
|
|
$value = isset( $GLOBALS[$varname] ) ? $GLOBALS[$varname] : $value;
|
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";
|
|
|
|
|
}
|
2004-10-01 03:10:10 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @access private
|
|
|
|
|
* @param string $varname Name of the radiobox.
|
|
|
|
|
* @param array $fields Various fields.
|
|
|
|
|
*/
|
|
|
|
|
function radiobox( $varname, $fields ) {
|
2004-09-30 22:49:26 +00:00
|
|
|
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:48:22 +00:00
|
|
|
return $this->fieldset( $this->mName.'-'.$varname, $s );
|
2004-09-30 22:49:26 +00:00
|
|
|
}
|
2004-10-01 03:01:22 +00:00
|
|
|
|
2004-10-01 03:10:10 +00:00
|
|
|
/*
|
|
|
|
|
* @access private
|
|
|
|
|
* @param string $varname Name of the textareabox.
|
|
|
|
|
* @param string $value Optional value (default empty)
|
|
|
|
|
* @param integer $size Optional size of the textarea (default 20)
|
|
|
|
|
*/
|
|
|
|
|
function textareabox ( $varname, $value='', $size=20 ) {
|
2004-10-01 03:01:22 +00:00
|
|
|
$value = isset( $GLOBALS[$varname] ) ? $GLOBALS[$varname] : $value;
|
|
|
|
|
return '<div><label>'.wfMsg( $this->mName.'-'.$varname ).
|
|
|
|
|
"<textarea name=\"wpOp{$varname}\" rows=\"5\" cols=\"{$size}\">$value</textarea>\n";
|
|
|
|
|
}
|
2004-09-30 22:49:26 +00:00
|
|
|
|
2004-10-01 03:10:10 +00:00
|
|
|
/*
|
|
|
|
|
* @access private
|
|
|
|
|
* @param string $varname Name of the arraybox.
|
|
|
|
|
* @param integer $size Optional size of the textarea (default 20)
|
|
|
|
|
*/
|
|
|
|
|
function arraybox( $varname , $size=20 ) {
|
2004-09-30 22:49:26 +00:00
|
|
|
$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";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|