-<?php\r
-\r
-/**\r
-* XHtmlSimpleElement \r
-* \r
-* Used to generate Xhtml-Code for simple xhtml elements \r
-* (i.e. elements, that can't contain child elements)\r
-* \r
-* \r
-* @author Felix Meinhold\r
-* \r
-*/\r
-class XHtmlSimpleElement {\r
- var $_element;\r
- var $_siblings = array();\r
- var $_htmlcode; \r
- var $_attributes = array();\r
-\r
- \r
- /**\r
- * Constructor\r
- * \r
- * @param string The element's name. Defaults to name of the \r
- * derived class\r
- * \r
- */\r
- function XHtmlSimpleElement($element = null) {\r
-\r
- $this->_element = $this->is_element();\r
- \r
- }\r
-\r
- function set_style($style) {\r
- $this->set_attribute("style", $style);\r
- }\r
- \r
- function set_class($class) {\r
- $this->set_attribute("class", $class);\r
- }\r
-\r
- \r
- function is_element() {\r
- return \r
- str_replace("xhtml_", "", get_class($this));\r
- }\r
-\r
- /**\r
- * Private function generates xhtml\r
- * @access private \r
- */\r
- function _html() {\r
- $this->_htmlcode = "<";\r
- foreach ($this->_attributeCollection as $attribute => $value) {\r
- if (!empty($value)) $this->_htmlcode .= " {$attribute}=\"{$value}\"";\r
- }\r
- $this->_htmlcode .= "/>";\r
- \r
- return $this->_htmlcode;\r
- }\r
- \r
- /**\r
- * Returns xhtml code\r
- * \r
- */\r
- function fetch() {\r
- return $this->_html();\r
- }\r
- /**\r
- * Echoes xhtml\r
- * \r
- */ \r
- function show() {\r
- echo $this->fetch();\r
- }\r
-\r
- function set_attribute($attr, $value) {\r
- $this->_attributes[$attr] = $value;\r
- }\r
-\r
-\r
-}\r
-\r
-/**\r
-* XHtmlElement \r
-* \r
-* Used to generate Xhtml-Code for xhtml elements \r
-* that can contain child elements\r
-* \r
-* \r
-*/\r
-class XHtmlElement extends XHtmlSimpleElement {\r
- var $_text = null; \r
- var $_htmlcode = "";\r
- var $_siblings = array();\r
-\r
- function XHtmlElement($text = null) {\r
- XHtmlSimpleElement::XHtmlSimpleElement();\r
- \r
- if ($text) $this->set_text($text);\r
- }\r
-\r
- /*\r
- * Adds an xhtml child to element\r
- * \r
- * @param XHtmlElement The element to become a child of element\r
- */\r
- function add(&$object) {\r
- array_push($this->_siblings,& $object);\r
- }\r
-\r
-\r
- /*\r
- * The CDATA section of Element\r
- * \r
- * @param string Text\r
- */\r
- function set_text($text) {\r
- if ($text) $this->_text = htmlspecialchars($text); \r
- }\r
-\r
- function fetch() {\r
- return $this->_html();\r
- }\r
-\r
-\r
- function _html() {\r
-\r
- $this->_htmlcode = "<{$this->_element}";\r
- foreach ($this->_attributes as $attribute =>$value) {\r
- if (!empty($value)) $this->_htmlcode .= " {$attribute} =\"{$value}\"";\r
- }\r
- $this->_htmlcode .= ">";\r
-\r
- \r
- if ($this->_text) { \r
- $this->_htmlcode .= $this->_text;\r
- }\r
- \r
- foreach ($this->_siblings as $obj) {\r
- $this->_htmlcode .= $obj->fetch();\r
- } \r
-\r
- $this->_htmlcode .= "</{$this->_element}>";\r
- \r
- return $this->_htmlcode;\r
- }\r
-\r
- /*\r
- * Returns siblings of Element\r
- * \r
- */\r
- function get_siblings() {\r
- return $this->_siblings;\r
- }\r
- \r
- function has_siblings() {\r
- return (count($this->_siblings) != 0);\r
- }\r
-}\r
-\r
-class XHTML_Button extends XHtmlElement {\r
- function XHTML_Button ($name, $text = null) {\r
- parent::XHtmlElement();\r
- \r
- $this->set_attribute("name", $name);\r
- \r
- if ($text) $this->set_text($text);\r
- }\r
-}\r
-\r
-\r
-class XHTML_Option extends XHtmlElement {\r
- function XHTML_Option($text, $value = null) {\r
- XHtmlElement::XHtmlElement(null); \r
- $this->set_text($text);\r
- }\r
-}\r
-\r
-\r
-class XHTML_Select extends XHTMLElement {\r
- var $_data;\r
-\r
- function XHTML_Select ($name, $multiple = false, $size = null) {\r
- XHtmlElement::XHtmlElement(); \r
-\r
- $this->set_attribute("name", $name);\r
- if ($multiple) $this->set_attribute("multiple","multiple");\r
- if ($size) $this->set_attribute("size",$size);\r
- \r
- \r
- }\r
- \r
- function set_data(&$data, $delim = ",") {\r
- switch (gettype($data)) {\r
- case "string":\r
- $this->_data = explode($delim, $data);\r
- break;\r
- case "array":\r
- $this->_data = $data;\r
- break;\r
- \r
- default:\r
- break;\r
- }\r
- }\r
- \r
- function fetch() {\r
- if (isset($this->_data) && $this->_data) {\r
- foreach ($this->_data as $value) { $this->add(new XHTML_Option($value)); }\r
- }\r
- return parent::fetch();\r
- }\r
- \r
-}\r
-\r
-\r
-?>
\ No newline at end of file
+<?php
+
+/**
+* XHtmlSimpleElement
+*
+* Used to generate Xhtml-Code for simple xhtml elements
+* (i.e. elements, that can't contain child elements)
+*
+*
+* @author Felix Meinhold
+*
+*/
+class XHtmlSimpleElement {
+ var $_element;
+ var $_siblings = array();
+ var $_htmlcode;
+ var $_attributes = array();
+
+
+ /**
+ * Constructor
+ *
+ * @param string The element's name. Defaults to name of the
+ * derived class
+ *
+ */
+ function XHtmlSimpleElement($element = null) {
+
+ $this->_element = $this->is_element();
+
+ }
+
+ function set_style($style) {
+ $this->set_attribute("style", $style);
+ }
+
+ function set_class($class) {
+ $this->set_attribute("class", $class);
+ }
+
+
+ function is_element() {
+ return
+ str_replace("xhtml_", "", get_class($this));
+ }
+
+ /**
+ * Private function generates xhtml
+ * @access private
+ */
+ function _html() {
+ $this->_htmlcode = "<";
+ foreach ($this->_attributeCollection as $attribute => $value) {
+ if (!empty($value)) $this->_htmlcode .= " {$attribute}=\"{$value}\"";
+ }
+ $this->_htmlcode .= "/>";
+
+ return $this->_htmlcode;
+ }
+
+ /**
+ * Returns xhtml code
+ *
+ */
+ function fetch() {
+ return $this->_html();
+ }
+ /**
+ * Echoes xhtml
+ *
+ */
+ function show() {
+ echo $this->fetch();
+ }
+
+ function set_attribute($attr, $value) {
+ $this->_attributes[$attr] = $value;
+ }
+
+
+}
+
+/**
+* XHtmlElement
+*
+* Used to generate Xhtml-Code for xhtml elements
+* that can contain child elements
+*
+*
+*/
+class XHtmlElement extends XHtmlSimpleElement {
+ var $_text = null;
+ var $_htmlcode = "";
+ var $_siblings = array();
+
+ function XHtmlElement($text = null) {
+ XHtmlSimpleElement::XHtmlSimpleElement();
+
+ if ($text) $this->set_text($text);
+ }
+
+ /*
+ * Adds an xhtml child to element
+ *
+ * @param XHtmlElement The element to become a child of element
+ */
+ function add(&$object) {
+ array_push($this->_siblings, $object);
+ }
+
+
+ /*
+ * The CDATA section of Element
+ *
+ * @param string Text
+ */
+ function set_text($text) {
+ if ($text) $this->_text = htmlspecialchars($text);
+ }
+
+ function fetch() {
+ return $this->_html();
+ }
+
+
+ function _html() {
+
+ $this->_htmlcode = "<{$this->_element}";
+ foreach ($this->_attributes as $attribute =>$value) {
+ if (!empty($value)) $this->_htmlcode .= " {$attribute} =\"{$value}\"";
+ }
+ $this->_htmlcode .= ">";
+
+
+ if ($this->_text) {
+ $this->_htmlcode .= $this->_text;
+ }
+
+ foreach ($this->_siblings as $obj) {
+ $this->_htmlcode .= $obj->fetch();
+ }
+
+ $this->_htmlcode .= "</{$this->_element}>";
+
+ return $this->_htmlcode;
+ }
+
+ /*
+ * Returns siblings of Element
+ *
+ */
+ function get_siblings() {
+ return $this->_siblings;
+ }
+
+ function has_siblings() {
+ return (count($this->_siblings) != 0);
+ }
+}
+
+class XHTML_Button extends XHtmlElement {
+ function XHTML_Button ($name, $text = null) {
+ parent::XHtmlElement();
+
+ $this->set_attribute("name", $name);
+
+ if ($text) $this->set_text($text);
+ }
+}
+
+
+class XHTML_Option extends XHtmlElement {
+ function XHTML_Option($text, $value = null) {
+ XHtmlElement::XHtmlElement(null);
+ $this->set_text($text);
+ }
+}
+
+
+class XHTML_Select extends XHTMLElement {
+ var $_data;
+
+ function XHTML_Select ($name, $multiple = false, $size = null) {
+ XHtmlElement::XHtmlElement();
+
+ $this->set_attribute("name", $name);
+ if ($multiple) $this->set_attribute("multiple","multiple");
+ if ($size) $this->set_attribute("size",$size);
+
+
+ }
+
+ function set_data(&$data, $delim = ",") {
+ switch (gettype($data)) {
+ case "string":
+ $this->_data = explode($delim, $data);
+ break;
+ case "array":
+ $this->_data = $data;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ function fetch() {
+ if (isset($this->_data) && $this->_data) {
+ foreach ($this->_data as $value) { $this->add(new XHTML_Option($value)); }
+ }
+ return parent::fetch();
+ }
+
+}
+
+
+?>