Documentation is available at xhtml_forms.php
- <?
- /* Form selection menu*/
- class selection_menu extends xml_element
- {
- function selection_menu($name,$initial_data=array(),$is_multiple="no")
- {
- $this->xml_element("select",array("name" => $name));
- if ($is_multiple=="yes") $this->set_attrib("multiple","yes");
- $this->build($initial_data);
- }
- function build($data)
- {
- foreach ($data as $name => $item)
- {
- if (is_array($item))
- {
- $submenu=&$this->add_submenu($name);
- $subment->build($item);
- }
- else
- {
- $this->add_option($name,$item);
- }
- }
- }
- function &add_submenu($title)
- {
- $temp=&$this->add_child(new sub_menu($title),$title);
- return $temp;
- }
- function add_option($label,$value="",$selected="no")
- {
- $temp=&$this->add_child(new selection_item($label,
- $value,
- $selected),
- $label);
- return $temp;
- }
- }
- /* Form submenu */
- class sub_menu extends selection_menu
- {
- function sub_menu($title)
- {
- $this->xml_element("optgroup",array("title" => $title));
- }
- }
- /* Form menu item */
- class selection_item extends xml_element
- {
- function selection_item($label,$value="",$selected="no")
- {
- $this->xml_element("option");
- $this->add_child($label);
- if ($value!="") $this->set_attrib("value",$value);
- if ($selected=="yes") $this->set_attrib("selected","yes");
- }
- }
- class input_control extends xml_element
- {
- function input_control($type,$name,$value="",$label="")
- {
- $this->xml_element("label");
- $temp = new xml_element("input",array("name" => $name,
- "value" => $value,
- "type" => $type));
- $this->add_child($label);
- $this->add_child($temp,"control");
- }
- }
- class text_input extends input_control
- {
- function text_input($name,$value="",$label="",$size=15)
- {
- $this->input_control("text",$name,$value,$label);
- $t=&$this->get_child("control");
- $t->set_attrib("size",$size);
- }
- }
- class file_input extends input_control
- {
- function file_input($name,$value="",$label="")
- {
- $this->input_control("file",$name,$value,$label);
- }
- }
- class hidden_input extends input_control
- {
- function hidden_input($name,$value="")
- {
- $this->input_control("hidden",$name,$value);
- }
- }
- class submit_input extends input_control
- {
- function submit_input($value="Submit")
- {
- $this->input_control("submit",$name,$value);
- }
- }
- class textarea extends xml_element
- {
- function textarea($name,$value,$label="",$rows="10",$cols="50")
- {
- $this->xml_element("label");
- $temp= new xml_element("textarea",array("rows" => $rows,
- "cols" => $cols,
- "name" => $name));
- $temp->add_child($value);
- $this->add_child($label);
- $this->add_child($temp);
- }
- }
- class form extends xml_element
- {
- function form($action,$method="post",$enctype="application/x-www-form-encoded")
- {
- $this->xml_element("form",array("action" => $action,
- "method" => $method,
- "enctype" => $enctype));
- }
- }
Documentation generated on Tue, 24 May 2005 03:59:20 -0400 by phpDocumentor 1.3.0RC3