form.class.php 1.27 KB
<?php

class renderForm {
    var $html = TRUE;
    var $tableid = '';
    
    function __construct() {
        $a = 1;
    }

    function start($action, $method) {
        $this->ret .= "<form action='$action' method='$method'>\n";
        if($this->html) {            
            $this->ret .= "<table id='" . $this->tableid . "' class='" . $this->tableclass . "'>\n";
        }
    }
    
    function br() {
        if($this->html) {
            $this->ret .= "<tr><td colspan='2'>&nbsp;</td></tr>";
        } else {
            $this->ret .= "<br>";
        }
    }    

    function inp($description, $name, $type='text', $value='', $checked=FALSE) {
        $check = $checked == TRUE ? "checked='checked'" : "";
        if ($this->html) {
            $this->ret .= "<tr>\n
                            \t<td>".$description."</td>\n
                            \t<td><input type='".$type."' name='".$name."' value='".$value."' ". $check ."/></td>\n
                          </tr>";
        } else {
            $this->ret .= "$description <input type='".$type."' name='".$name."' value='".$value."' />";
        }
    }

    function end() {
        if($this->html) {
            $this->ret .= "</table>\n";
        }
        $this->ret .= "</form>\n";
        return $this->ret;
    }

}

?>