<?
class IDForm {
const _VER= '1.1'; //class version
protected $_html;
public function Header($name,$action,$method='POST',$target=null,$enctype=null) {
$this->_html= '<form';
$this->_html.= ' name="'.$name.'"';
$this->_html.= ' action="'.$action.'"';
$this->_html.= ' method="'.$method.'"';
$this->_html.= ($target<>null ? ' target="'.$target.'"' : '');
$this->_html.= ($enctype<>null ? ' enctype="'.$enctype.'"' : '');
$this->_html.= '>';
}
public function AddHtml($html) {
$this->_html.= $html;
}
public function Input($name,$type,$args=array()) {
$this->_html.= '<input';
$this->_html.= ' name="'.$name.'"';
$this->_html.= ' type="'.$type.'"';
$this->_html.= (isset($args['align']) ? ' align="'.$args['align'].'"' : '');
$this->_html.= (isset($args['alt']) ? ' value="'.$args['alt'].'"' : '');
$this->_html.= (isset($args['border']) ? ' value="'.$args['border'].'"' : '');
$this->_html.= (isset($args['checked']) ? ' checked' : '');
$this->_html.= (isset($args['disabled']) ? ' disabled' : '');
$this->_html.= (isset($args['maxlength']) ? ' maxlength="'.$args['maxlength'].'"' : '');
$this->_html.= (isset($args['readonly']) ? ' readonly' : '');
$this->_html.= (isset($args['size']) ? ' size="'.$args['size'].'"' : '');
$this->_html.= (isset($args['value']) ? ' value="'.$args['value'].'"' : '');
$this->_html.= (isset($args['id']) ? ' id="'.$args['id'].'"' : '');
$this->_html.= (isset($args['style']) ? ' style="'.$args['style'].'"' : '');
$this->_html.= ' />';
}
public function Select($name,$elements=array(),$args=array()) {
$this->_html.= '<select';
$this->_html.= ' name="'.$name.'"';
$this->_html.= (isset($args['size']) ? ' size="'.$args['size'].'"' : '');
$this->_html.= (isset($args['multiple']) ? ' multiple' : '');
$this->_html.= (isset($args['disabled']) ? ' disabled' : '');
$this->_html.= (isset($args['id']) ? ' id="'.$args['id'].'"' : '');
$this->_html.= (isset($args['style']) ? ' style="'.$args['style'].'"' : '');
$this->_html.= '>';
if (!empty($elements)) {
foreach($elements as $elem) {
$this->_html.= '<option';
$this->_html.= (isset($elem['value']) ? ' value="'.$elem['value'].'"' : '');
$this->_html.= (isset($elem['selected']) ? ' selected' : '');
$this->_html.= (isset($elem['disabled']) ? ' disabled' : '');
$this->_html.= '>'.@$elem['text'].'</option>';
}
}
$this->_html.= '</select>';
}
public function TextArea($name,$text='',$args=array()) {
$this->_html.= '<textarea ';
$this->_html.= ' name="'.$name.'"';
$this->_html.= (isset($args['cols']) ? ' cols="'.$args['cols'].'"' : '');
$this->_html.= (isset($args['disabled']) ? ' disabled' : '');
$this->_html.= (isset($args['readonly']) ? ' readonly' : '');
$this->_html.= (isset($args['rows']) ? ' rows="'.$args['rows'].'"' : '');
$this->_html.= (isset($args['wrap']) ? ' wrap="'.$args['wrap'].'"' : '');
$this->_html.= (isset($args['id']) ? ' id="'.$args['id'].'"' : '');
$this->_html.= (isset($args['style']) ? ' style="'.$args['style'].'"' : '');
$this->_html.= '>';
$this->_html.= $text.'</textarea>';
}
public function Finish() {
$this->_html.= '</form>';
}
public function Reset() {
$this->_html= '';
}
public function GetHtml() {
return $this->_html;
}
}
?>