/*
class.form.php
A collection of subroutines to create form elements
*/
class htmlForm {
/**
* A class to centralise the creation of forms and form elements,
* covers open and close form, text fields, hidden fields, radiobuttons
* checkboxes, selection boxes, textarea, password fields, submit &
* reset buttons
*/
/**
* Opens a form
*
* @param string $action - URL to send data to
* @param string $method - Should be either GET or POST (default is POST)
* @param string $jscript - any js that will go in the onSubmit
* @param string $formname - the form name
* @param string $enctype - used in situations where the mime type needs to be set
*
*/
function openForm($action, $method="POST",$jscript="", $formname="",$enctype="", $id="") {
$formString = "
";
}
/**
* Outputs a hidden form field
*
* @param string $name
* @param string $value
* @param string $id
* * @return
*/
function hiddenField($name, $value, $id="") {
return "";
}
/**
* Returns a text input field
*
* @param string $name
* @param string $id
* @param string $value
* @param int $size
* @param int $maxlen
* @param string $extraParams - allows for non-std params like "read-only" etc
* @return
*/
function textField($name, $id="", $value="", $size="", $maxlen="",$extraParams="") {
return "";
}
/**
* Returns a file input field
*
* @param string $name
* @param string $id
* @return
*/
function fileField($name, $id="") {
return "";
}
/**
* Returns a set of radio buttons
*
* @param string $name
* @param array $values
* @param string $checked
* @param string $id
* @return
*/
/**
* Produces an array of radio buttons
*
* @param string $name - the name of the control
* @param array $values - an array containing any/all button values
* @param string $checked - contains the name of the ($values) to start as checked
* @param string $id
* @return array $rbOptions - each line of the array is a complete rb entry
*/
function radioButton($name, $values, $displayText="",$checked="",$id="") {
// $values should be an array
$rbText = "
";
return $rbText;
}
/**
* Returns an input form checkbox
*
* @param string $name
* @param string $checked
* @param string $id
* @return
*/
function checkBox($name, $checked="", $id="", $value="") {
// 15 May - added value field to allow for cb arrays
$cbText = "";
return $cbText;
}
function checkBoxArray($name, $checked="", $displayText="", $value="",$id="") {
// if no "key" value is passed, use the display value
$displayText = ($displayText != "")? $displayText : $value;
$cbText = "".$displayText;
return $cbText;
}
/**
* Returns a string containing a full HTML Select statement
*
* @param string $name
* @param array $values
* @param int $size
* @param string $id
* @param string $selected - the VALUE that should be pre-selected
* @return
*/
function selectionBox($name,$values,$size,$id="",$selected="") {
$sbText = "";
return $sbText;
}
/**
* creates a dropdown based on a numeric range
*
* @param String $name
* @param int $low
* @param int $high
* @param int $size
* @param String $id
* @return String
*/
function selectionBoxNumericRange($name,$low,$high,$size=1,$default,$id="") {
$sbText = "";
return $sbText;
}
/**
* It seems it's not possible to overload methods in PHP, so I had to create a new method
* to deal with selection boxes where the display value and the passed value differ..
* //me -> hoping that this is wrong ....
*
* @param String $name
* @param Array $values
* @param Array $displayValues
* @param int $size
* @param String $id
* @param String $selected <-- holds the value of any default option
*/
function selectionBoxVariable($name,$values,$displayValues,$size,$id="",$selected="",$extraParams="") {
$sbText = "";
$sbText .= "";
return $sbText;
}
/**
* Creates an HTML textarea
*
* @param string $name
* @param string $value
* @param int $rowsunknown
* @param int $cols
* @param string $id
*/
function textArea($name,$value,$rows,$cols, $id="") {
return "";
}
/**
* Creates an HTML password input
*
* @param string $name
* @param string $id
*/
function password($name,$id="") {
return "";
}
/**
* Creates a form button
*
* @param string $url - url for the graphic to use
* @param string $id
*/
function submitGfx($url,$text="",$id="") {
return "";
}
/**
* Creates an HTML submit button
*
* @param string $text
* @param string $jScript
* @param string id
*/
function submit($text,$jScript="",$id="") {
return "";
}
/**
* Creates an HTML reset button
*
* @param string $text
* @param string $id
*/
function reset($text,$id="") {
return "";
}
/**
* creates three dropdowns to allow date selection
* userProvided name will be postpended by d, m or y
*
* @param String $name
* @param String $id
* @param int $startYear
* @param int $endYear
*/
function date($name, $id="", $startYear=1900, $endYear=2050,$defaultMonth=1, $defaultDay=1, $defaultYear=2007){
$day = $this->selectionBoxNumericRange($name."d",1,31,1,$defaultDay);
$mon = $this->selectionBoxNumericRange($name."m",1,12,1,$defaultMonth);
$yr = $this->selectionBoxNumericRange($name."y",$startYear,$endYear,1,$defaultYear);
return ($day."/".$mon."/".$yr);
}
} // end of class definition
?>