class FORM {
var $FORM_NAME = '';
var $ACTION = '';
var $O_NAME = '';
var $O_LABEL = array();
var $O_VALUE = array();
var $O_TYPE = '';
var $O_ALIGN = "HORIZONTAL";
var $O_SELECTED_LABEL = '';
var $O_IS_CHECKED = 0;
var $EVENT_NAME = '';
var $EVENT_HANDLER = '';
var $ONSUBMIT = '';
var $ROWS = 5;
var $COLS = 40;
var $WRAP = 'SOFT';
var $SIZE = 20;
var $MAXLENGTH = 20;
function start($f_name) {
$this->FORM_NAME = strtoupper($f_name);
$f_str = "nn<!---------- NEO FORM BEGINS: $f_name ------------>nn";
$f_str .= "<FORM NAME="" . $this->FORM_NAME . "" METHOD="POST" ENCTYPE="multipart/form-data" ACTION="" . $this->ACTION . "" OnSubmit="" . $this->ONSUBMIT . "">n";
$this->ONSUBMIT = '';
return $f_str;
}
function set($var, $value) {
$this->$var = $value;
}
function input() {
$f_str = '';
if($this->EVENT_NAME =='' || $this->EVENT_HANDLER =='') {
$e_str = '';
}
else {
$e_str = " " . $this->EVENT_NAME . "="" . $this->EVENT_HANDLER .""";
}
if($this->O_TYPE == 'RADIO') {
if($this->O_ALIGN == 'VERTICAL') $ALIGN = "<BR>";
for($i = 0; $i < count($this->O_VALUE); $i++) {
if(!$i) {
$check_str = ' CHECKED';
}
else {
$check_str = '';
}
$f_str .= "<INPUT TYPE="" . $this->O_TYPE . "" NAME="" . $this->O_NAME . "" VALUE="" . $this->O_VALUE[$i] . """. $check_str . $e_str . ">" . $this->O_LABEL[$i] . $ALIGN . "n";
}
}
else if($this->O_TYPE == 'CHECKBOX') {
if($this->O_IS_CHECKED) $checked_str = ' CHECKED';
$f_str .= "<INPUT TYPE="" . $this->O_TYPE . "" NAME="" . $this->O_NAME . "" VALUE="" . $this->O_VALUE[0] . """. $check_str . $e_str . ">" . $this->O_LABEL[0] . "n";
}
else if($this->O_TYPE == 'SELECT') {
$f_str .= "<SELECT NAME="" . $this->O_NAME . "" SIZE="1"" . $e_str . ">n";
for($i = 0; $i < count($this->O_VALUE); $i++) {
if(!$i && $this->O_SELECTED_LABEL =='') {
$selected_str = ' SELECTED';
}
else if(isset($this->O_SELECTED_LABEL) && $this->O_SELECTED_LABEL == $this->O_VALUE[$i]){
$selected_str = ' SELECTED';
}
else {
$selected_str = '';
}
$f_str .= "<OPTION VALUE="" . $this->O_VALUE[$i] . """ . $selected_str . ">" . $this->O_LABEL[$i] . "</OPTION>n";
}
$f_str .= "</SELECT>n";
}
else if($this->O_TYPE == 'BUTTON') {
$f_str .= "<INPUT TYPE="" . $this->O_TYPE . "" NAME="" . $this->O_NAME . "" VALUE="" . $this->O_VALUE[0] . """ . $e_str . ">" . $this->O_LABEL[0] . "n";
}
else if($this->O_TYPE == 'TEXT') {
$f_str .= "<INPUT TYPE="" . $this->O_TYPE . "" NAME="" . $this->O_NAME . "" VALUE="" . $this->O_VALUE[0] . "" SIZE="" . $this->SIZE . "" MAXLENGTH="" . $this->MAXLENGTH . """ . $e_str . ">" . $this->O_LABEL[0] . "n";
}
else if($this->O_TYPE == 'PASSWORD') {
$f_str .= "<INPUT TYPE="" . $this->O_TYPE . "" NAME="" . $this->O_NAME . "" VALUE="" . $this->O_VALUE[0] . "" SIZE="" . $this->SIZE . "" MAXLENGTH="" . $this->MAXLENGTH . """. $e_str . ">" . $this->O_LABEL[0] . "n";
}
else if($this->O_TYPE == 'TEXTAREA') {
$f_str .= "<TEXTAREA ROWS="" . $this->ROWS . "" COLS="" . $this->COLS. "" NAME="" . $this->O_NAME . "" WRAP="" . $this->WRAP . "">n";
$f_str .= $this->O_VALUE[0];
$f_str .= "</TEXTAREA>n";
}
else {
$f_str .= "<INPUT TYPE="" . $this->O_TYPE . "" NAME="" . $this->O_NAME . "" VALUE="" . $this->O_VALUE[0] . "">n";
}
$this->O_NAME = '';
$this->O_LABEL = array();
$this->O_VALUE = array();
$this->O_TYPE = '';
$this->O_ALIGN = "HORIZONTAL";
$this->O_SELECTED_LABEL = '';
$this->EVENT_NAME = '';
$this->EVENT_HANDLER = '';
return $f_str;
}
function button($name, $value='', $label='') {
$this->O_NAME = $name;
$this->O_VALUE[0] = $value;
$this->O_TYPE = 'BUTTON';
$this->O_LABEL[0] = $label;
return $this->input();
}
function radio($name, $value='', $labels='') {
$this->O_NAME = $name;
$this->O_VALUE = $value;
$this->O_LABEL = $labels;
$this->O_TYPE = 'RADIO';
return $this->input();
}
function checkbox($name, $value='', $is_checked=0, $labels='') {
$this->O_NAME = $name;
$this->O_VALUE[0] = $value;
$this->O_IS_CHECKED = $is_checked;
$this->O_LABEL = $labels;
$this->O_TYPE = 'CHECKBOX';
return $this->input();
}
function select($name, $value='', $labels='', $selected_label='') {
$this->O_NAME = $name;
$this->O_VALUE = $value;
$this->O_TYPE = 'SELECT';
$this->O_LABEL = $labels;
$this->O_SELECTED_LABEL = $selected_label;
return $this->input();
}
function text($name, $value='', $size=0, $maxlength=0, $label='') {
$this->O_NAME = $name;
$this->O_VALUE[0] = $value;
$this->O_LABEL[0] = $label;
if($size != 0) $this->SIZE = $size;
if($maxlength != 0) $this->MAXLENGTH = $maxlength;
$this->O_TYPE = 'TEXT';
return $this->input();
}
function password($name, $value='', $label='') {
$this->O_NAME = $name;
$this->O_VALUE[0] = $value;
$this->O_LABEL[0] = $label;
$this->O_TYPE = 'PASSWORD';
return $this->input();
}
function textarea($name, $value='', $rows=0, $cols=0, $wrap='soft') {
$this->O_NAME = $name;
$this->O_VALUE[0] = $value;
if($rows != 0) $this->ROWS = $rows;
if($cols != 0) $this->COLS = $cols;
$this->WRAP = strtoupper($wrap);
$this->O_TYPE = 'TEXTAREA';
return $this->input();
}
function hidden($name, $value='') {
$this->O_NAME = $name;
$this->O_VALUE[0] = $value;
$this->O_TYPE = 'HIDDEN';
return $this->input();
}
function filetext($name, $value='') {
$this->O_NAME = $name;
$this->O_VALUE[0] = $value;
$this->O_TYPE = 'FILE';
return $this->input();
}
function submit($value='') {
$this->O_NAME = 'SUBMIT';
if($value == '') $value = 'Submit';
$this->O_VALUE[0] = $value;
$this->O_TYPE = 'SUBMIT';
return $this->input();
}
function reset($value='') {
$this->O_NAME = 'RESET';
if($value == '') $value = 'Reset';
$this->O_VALUE[0] = $value;;
$this->O_TYPE = 'RESET';
return $this->input();
}
function end() {
$f_str = '';
$f_str .= "</FORM>n";
$f_str .= "nn<!---------- NEO FORM ENDS: " . $this->FORM_NAME . " -------------->nn";
$this->FORM_NAME = '';
return $f_str;
}
}
|