--- nfo/php/libs/com.newsblob.phphtmllib/XMLTagClass.inc 2003/02/22 20:55:24 1.2
+++ nfo/php/libs/com.newsblob.phphtmllib/XMLTagClass.inc 2004/05/06 16:23:38 1.4
@@ -3,7 +3,7 @@
/**
* Holds the XMLTagClass
*
- * $Id: XMLTagClass.inc,v 1.2 2003/02/22 20:55:24 jonen Exp $
+ * $Id: XMLTagClass.inc,v 1.4 2004/05/06 16:23:38 jonen Exp $
*
* @author Walter A. Boring IV
* @package phpHtmlLib
@@ -56,13 +56,16 @@
/**
* The constructor
+ *
+ * {@source }
+ *
+ * @tutorial XMLTagClass.cls#example
*
* @param string - the tag name
* @param array - the attributes array
* can be in name => value
* or just value
- * @param mixed - n items of content to
- * add
+ * @param mixed - n items of content to add
*
*/
function XMLTagClass($name, $attributes=array() ) {
@@ -82,6 +85,8 @@
* This function is responsible
* for rendering the tag and
* its contents
+ *
+ * {@source }
*
* @param int - the current indentation
* level for the tag
@@ -109,6 +114,8 @@
* This method is used to set the bitmask
* flags for this tag. It tells the
* class how to render the tag.
+ *
+ * @access private
*
* NOTE: the child class can override this
* to set the options
@@ -121,6 +128,8 @@
/**
* This method sets the name of the tag
+ *
+ * {@source }
*
* @param string - the tag name
*/
@@ -130,6 +139,8 @@
/**
* This method gets the name of the tag
+ *
+ * {@source }
*
* @return string - the tag name
*/
@@ -141,6 +152,8 @@
* This returns the tag declared for this class.
* This should be used in favor of
* accessing the $this->_tag directly.
+ *
+ * {@source }
*
* @return string - the _tag var for this class.
*/
@@ -151,9 +164,12 @@
/**
* add a single attribute (name="value")
+ *
+ * {@source }
+ *
* @param string $name attribute name
* @param mixed $value the value.
- * @access public
+ * @return none
*/
function set_tag_attribute( $name, $value=NULL ) {
$this->_attributes[$name] = $value;
@@ -161,10 +177,13 @@
/**
* add multiple attributes (name="value")
+ *
+ * {@source }
+ *
* @param array $attributes Associative array of name="value" pairs of
* tag atributes.
* ie array("border"=>"0", "class"=>"hover");
- * @access public
+ * @return none
*/
function set_tag_attributes( $attributes=array() ) {
$this->_attributes = array_merge($this->_attributes, $attributes);
@@ -172,10 +191,13 @@
/**
* clear all attributes and start with new attributes
- * @param array $attributes Associative array of name="value" pairs of
- * tag atributes.
- * ie array("border"=>"0", "class"=>"hover");
- * @access public
+ *
+ * {@source }
+ *
+ * @param array Associative array of name="value" pairs of
+ * tag atributes.
+ * ie array("border"=>"0", "class"=>"hover");
+ * @return none
*/
function reset_attributes( $attributes=array() ) {
$this->_attributes = array();
@@ -184,11 +206,18 @@
/**
* get the nth element from content array
+ *
+ * NOTE:
+ * This has been made public in the Container
+ *
+ * {@source }
+ * @access private
+ *
* @param int $cell the cell to get
* @return mixed
*/
- function _get_element( $cell ) {
- return $this->_content[$cell];
+ function &_get_element( $cell ) {
+ return $this->get_element($cell);
}
@@ -199,7 +228,11 @@
/**
* set the newline_after_opentag flag
- * @param boolean $flag TRUE or FALSE
+ *
+ * {@source }
+ *
+ * @param boolean TRUE or FALSE
+ * @return none
*/
function set_newline_after_opentag( $flag ) {
if ($flag) {
@@ -211,7 +244,11 @@
/**
* set the newline_after_content flag
- * @param boolean $flag TRUE or FALSE
+ *
+ * {@source }
+ *
+ * @param boolean TRUE or FALSE
+ * @return none
*/
function set_newline_after_closetag( $flag ) {
if ($flag) {
@@ -221,12 +258,33 @@
}
}
+ /**
+ * This method turns on the automatic wrapping
+ * of the tag's content inside the CDATA wrapper
+ * for XML
+ *
+ * {@source }
+ * @param boolean $flag TRUE or FALSE
+ * @return none
+ */
+ function set_cdata_flag($flag) {
+ if ($flag) {
+ $this->_flags |= _CDATACONTENTWRAP;
+ $this->set_collapse(TRUE);
+ } else{
+ $this->_flags &= ~_CDATACONTENTWRAP;
+ }
+ }
+
/**
* This function turns on the collapse flag
+ *
+ * {@source }
*
* @param boolean - the collapse flag
* @param boolean - the indent flag
* DEFAULT: TRUE;
+ * @return none
*/
function set_collapse($collapse=TRUE, $indent=TRUE) {
if ($collapse) {
@@ -249,7 +307,10 @@
* there is only 1 content data, and
* its not an object, then it auto
* sets some of the indentation flags
- *
+ *
+ * {@source }
+ * @access private
+ * @return none
*/
function _prepare_flags() {
if ($this->_flags & _CONTENTREQUIRED) {
@@ -261,7 +322,9 @@
$this->_flags &= ~_NEWLINEAFTEROPENTAG;
}
}
- }
+ } else if ($this->count_content() == 0) {
+ $this->_flags &= ~(_CONTENTREQUIRED | _CLOSETAGREQUIRED);
+ }
}
}
@@ -274,10 +337,14 @@
/**
* this function is responsible for
* rendering the open tag.
+ *
+ * {@source }
+ * @access private
*
* @param int - the indent level
* @param boolean - do we add the finish / if we have no
* close tag and no content?
+ * @return string
*/
function _render_open_tag( $indent_level, $finish_slash=TRUE ) {
//get the indent level
@@ -290,7 +357,7 @@
$this->_tag = strtoupper($this->_tag);
}
//save on mem
- $xml = $indent . ($this->_tag_prefix ? $this->_tag_prefix : _TAG_PREFIX) . $this->_tag;
+ $xml = $indent . ((isset($this->_tag_prefix) && $this->_tag_prefix) ? $this->_tag_prefix : _TAG_PREFIX) . $this->_tag;
foreach( $this->_attributes as $name => $value) {
$xml .= $this->_build_attribute_string($name, $value);
@@ -298,9 +365,9 @@
if ( !($this->_flags & _CLOSETAGREQUIRED) && !($this->_flags & _NOFINISHSLASHXHTML)
&& $finish_slash ) {
- $xml .= " /".($this->_tag_postfix ? $this->_tag_postfix : _TAG_SUFFIX);
+ $xml .= " /".(@$this->_tag_postfix ? $this->_tag_postfix : _TAG_SUFFIX);
} else {
- $xml .= ($this->_tag_postfix ? $this->_tag_postfix : _TAG_SUFFIX);
+ $xml .= (@$this->_tag_postfix ? $this->_tag_postfix : _TAG_SUFFIX);
}
if ($this->_flags & _NEWLINEAFTEROPENTAG) {
@@ -316,7 +383,11 @@
* rendering the pcdata, or content
* of the tag (if any)
*
+ * {@source }
+ * @access private
+ *
* @param int - the indent level
+ * @return string
*/
function _render_content( $indent_level, $output_debug=0 ) {
@@ -343,7 +414,7 @@
} else {
$indent = $indent_level + 1;
}
- $indent = $this->_render_indent($indent + 1);
+ $indent = $this->_render_indent($indent);
if ($this->_flags & _NEWLINEAFTEROPENTAG) {
$item = str_replace("\n", "\n" . $indent, $item);
$xml .= $indent . $item . "\n";
@@ -373,7 +444,11 @@
* this function is reposnsible for
* rendering the closing tag (if any)
*
+ * {@source }
+ * @access private
+ *
* @param int - the indent level
+ * @return string
*/
function _render_close_tag( $indent_level ) {
if (!($this->_flags & _CLOSETAGREQUIRED)) {
@@ -397,6 +472,9 @@
* this builds an attribute for an XML tag.
* XML attributes MUST have a name AND a
* value.
+ *
+ * {@source }
+ * @access private
*
* @param string - $name attribute name
* @param mixed - $value attribute value
@@ -404,14 +482,7 @@
* to be added to the tag.
*/
function _build_attribute_string($name, $value) {
- if ( ((int)$name - 0) === $name) {
- $returnval = " ".$value;
- } else if ( $value === NULL ) {
- $returnval = " ".$name;
- } else {
- $returnval= " ".$name."=\"".$value."\"";
- }
- return $returnval;
+ return " ".$name."=\"".$value."\"";
}
}
?>