<?php

// Formular class
// Date: 2012-06-19

class Form
{
	
  protected $action = '';
  protected $method = 'post';
  protected $inputs = array();
  protected $title = '';

  function __construct($inputs,$title,$action = '?',$method = 'post')
  {
	$this->action = $action;
	$this->title = $title;
	$this->method = $method;
	$this->inputs = $inputs;
  }
  
  function GetText() {
	 $return = '';
	if ($this->title != '') $return .= '<strong>'.$this->title.'</strong>';
     $return .= '
		<form action="'.$this->action.'" method="'.$this->method.'">
		<table>';
	  
    foreach($this->inputs as $input)
    {
		$return .= '<tr>';
		
		if (isset($input['description'])) $return .= '<td>'.$input['description'].'</td>'; 
		else $return .= '<td></td>';
		
		$return .= '<td><input ';
		
		if (isset($input['type'])) $return .= 'type="'.$input['type'].'" ';
		if (isset($input['name'])) $return .= 'name="'.$input['name'].'" ';
		if (isset($input['value'])) $return .= 'value="'.$input['value'].'" ';
		
		$return .= '/></td></tr>';
    }
	  
    $return .= '</table>
         </form>';
  	return $return;
  }
  
  function Show()
  {
	  
	  echo $this->GetText();
  }
  
}
?>
