<?
require_once("PTagParser.inc");
require_once("PTagSupport.inc");
require_once("HTML_Form.inc");
/**
*
* HTML_Form tag lib
* @author Masahiro.Kobayashi < masa918@nifty.com >
*
*/
class HTML_FormTag extends PTagSupport
{
var $form = null;
function HTML_FormTag()
{
$this->form =& HTML_Form::instance();
}
function doStartTag()
{
foreach($this->attrs as $key => $value){
print " $key=\"$value\"";
}
}
}
/**
*
* HTML_FormText
* <input type="text" .... >
*
* <form:text name="..." default=""/>
*/
class HTML_FormText extends HTML_FormTag
{
function doStartTag(){
print "<input ";
$this->form->text($this->attrs["name"],
$this->attrs["default"]);
unset($this->attrs["name"]);
unset($this->attrs["default"]);
parent::doStartTag();
print ">";
}
}
/**
* HTML_FormPassword
*
*/
class HTML_FormPassword extends HTML_FormTag
{
function doStartTag(){
print "<input ";
$this->form->password($this->attrs["name"],
$this->attrs["default"]);
unset($this->attrs["name"]);
unset($this->attrs["default"]);
parent::doStartTag();
print ">";
}
}
/**
* HTML_FormTextarea
*
*/
class HTML_FormTextarea extends HTML_FormTag
{
var $default = "";
function doStartTag(){
$this->default = $this->attrs["default"];
print "<textarea ";
unset($this->attrs["default"]);
parent::doStartTag();
print ">";
}
function doBody($body)
{
$this->form->htmlValue($this->attrs["name"],
$this->default);
}
function doEndTag()
{
print "</textarea>";
}
}
/**
* HTML_FormRadio
*
*/
class HTML_FormRadio extends HTML_FormTag
{
function doStartTag(){
print "<input ";
print $this->form->radio($this->attrs["name"],
$this->attrs["value"],
$this->attrs["default"]);
unset($this->attrs["name"]);
unset($this->attrs["default"]);
unset($this->attrs["value"]);
parent::doStartTag();
print ">";
}
}
class HTML_FormCheckBox extends HTML_FormTag
{
function doStartTag(){
print "<input ";
print $this->form->checkbox($this->attrs["name"],
$this->attrs["value"],
$this->attrs["default"]);
unset($this->attrs["name"]);
unset($this->attrs["default"]);
unset($this->attrs["value"]);
parent::doStartTag();
print ">";
}
}
/**
* HTML_FormSelect
*/
class HTML_FormSelect extends HTML_FormTag
{
/**
* select object
*/
var $select;
function doStartTag(){
$this->select =& $this->form->getSelect($this->attrs["name"]);
print "<select";
parent::doStartTag();
print ">";
}
function doEndTag()
{
print "</select>";
}
}
/**
*
*/
class HTML_FormOption extends HTML_FormTag
{
function doStartTag(){
$select =& $this->parent->select;
print "<option ";
$select->option($this->attrs["value"],$this->parent->attrs["default"]);
print ">";
}
function doEndTag()
{
print "</option>";
}
}
//
// set ptaglib
//
setPTaglib("form","text","HTML_FormText");
setPTaglib("form","password","HTML_FormPassword");
setPTaglib("form","textarea","HTML_FormTextarea");
setPTaglib("form","radio","HTML_FormRadio");
setPTaglib("form","checkbox","HTML_FormCheckBox");
setPTaglib("form","select","HTML_FormSelect");
setPTaglib("form","option","HTML_FormOption");
?>
|