--- nfo/php/libs/com.newsblob.phphtmllib/HTMLTagClass.inc 2003/01/30 03:29:08 1.1.1.1
+++ nfo/php/libs/com.newsblob.phphtmllib/HTMLTagClass.inc 2004/05/06 16:23:38 1.4
@@ -3,7 +3,7 @@
/**
* Holds the HTMLTagClass
*
- * $Id: HTMLTagClass.inc,v 1.1.1.1 2003/01/30 03:29:08 jonen Exp $
+ * $Id: HTMLTagClass.inc,v 1.4 2004/05/06 16:23:38 jonen Exp $
*
* @author Walter A. Boring IV
* @package phpHtmlLib
@@ -26,48 +26,34 @@
*
* @author Walter A. Boring IV
* @link http://phphtmllib.sourceforge.net
+ * @package phpHtmlLib
*/
class HTMLTagClass extends XMLTagClass {
-
- /**
- * Flag to tell the renderer not to
- * place the /> if we are in xhtml
- * compliant mode.
- */
- var $_no_finish_slash_xhtml = FALSE;
-
-
- /**
- * Flag to let us know to render XHTML 1.0
- * compliant output. defaulted to FALSE
- * @var boolean
- * @access private
- */
- var $_xhtml_compliant = FALSE;
-
- /**
- * Flag to denote that this tag is
- * depricated by the HTML standard.
- *
- */
- var $_depricated = FALSE;
-
/**
* the list of tag attributes that we
* should create a clickable link for
* when in debug mode.
+ *
+ * We comment this declaration out
+ * to save memory, since only a small
+ * number of tags use it
+ *
* @var array
* @access private
*/
- var $_debug_link_attributes = array("background");
+ //var $_debug_link_attributes = array("background");
/**
* The list of attributes not to render
- * if HTML_RENDER_TYPE is "XHTML STRICT"
+ * if $GLOBALS["HTML_RENDER_TYPE"] is "XHTML STRICT"
*
+ * We comment this declaration out
+ * to save memory, since only a small
+ * number of tags use it
+ *
*/
- var $_xhtml_strict_attributes = array();
+ //var $_xhtml_strict_attributes = array();
/**
@@ -75,14 +61,22 @@
* htmlentities() on if we are in XHTML_STRICT
* mode. Otherwise the validator complains about
* html characters such as &.
+ *
+ * We comment this declaration out
+ * to save memory, since only a small
+ * number of tags use it
+ *
* @var array.
* @access private
*/
- var $_htmlentities_attributes = array();
+ //var $_htmlentities_attributes = array();
/**
* Class Constructor
+ *
+ * {@source }
+ *
* @param array - Associative array of
* name="value" pairs of
* tag atributes.
@@ -92,14 +86,15 @@
* of parameters that will
* be added to the content
* of the tag automatically.
- *
- * @access public
*/
function HTMLTagClass( $attributes=NULL ) {
if ( $attributes ) {
$this->set_tag_attributes( $attributes );
}
+ //set the default tag options
+ $this->_set_flags();
+
//add the content if any.
$num_args = func_num_args();
for ($i = 1; $i < $num_args; $i++) {
@@ -111,15 +106,15 @@
//this is a magic test. It assumes that
//someone has created the define for
//HTML_RENDER_TYPE
- if ( HTML_RENDER_TYPE == XHTML ||
- HTML_RENDER_TYPE == XHTML_STRICT ) {
- $this->_xhtml_compliant = TRUE;
+ if ( $GLOBALS["HTML_RENDER_TYPE"] == XHTML ||
+ $GLOBALS["HTML_RENDER_TYPE"] == XHTML_STRICT ) {
+ $this->_flags |= _XHTMLCOMPLIANT;
}
//if the tag is depricated
//we raise an alert.
- if ( $this->_depricated ) {
+ if ( $this->_flags & _DEPRICATED ) {
trigger_error(htmlspecialchars($this->_tag) . " has been depricated in HTML 4.0", E_USER_NOTICE);
}
}
@@ -127,9 +122,12 @@
/**
* Renders the tag, attributes, content and close tag.
+ *
+ * {@source }
+ *
* @param int $indent_level the indentation level for this tag.
+ * @param boolean output in html viewable mode
* @return string
- * @access public
*/
function render($indent_level=NULL, $output_debug=0) {
@@ -138,15 +136,15 @@
$this->_prepare_flags();
if ( $indent_level==NULL ) {
- $indent_level = $this->_indent_level;
+ $indent_level = 0;
}
- $html = $this->_render_tag($indent_level, $output_debug);
+ $html = $this->_render_tag($indent_level, $output_debug);
- if ( $this->_content_required ) {
+ if ( $this->_flags & _CONTENTREQUIRED) {
$html .= $this->_render_content($indent_level, $output_debug);
}
- if ( $this->_close_tag_required ) {
+ if ( $this->_flags & _CLOSETAGREQUIRED ) {
$html .= $this->_render_close_tag($indent_level, $output_debug);
}
@@ -161,8 +159,11 @@
* This function is a shorthand helper
* to setting the style attribute on a
* tag.
+ *
+ * {@source }
*
* @param string - the style value.
+ * @return none
*/
function set_style( $value ) {
$this->set_tag_attribute("style", $value);
@@ -172,8 +173,11 @@
* This function is a shorthand helper
* to setting the class attribute on a
* tag.
+ *
+ * {@source }
*
* @param string - the class value.
+ * @return none
*/
function set_class( $value ) {
$this->set_tag_attribute("class", $value);
@@ -183,8 +187,11 @@
* This function is a shorthand helper
* to setting the id attribute on a
* tag.
+ *
+ * {@source }
*
* @param string - the class value.
+ * @return none
*/
function set_id( $value ) {
$this->set_tag_attribute("id", $value);
@@ -197,25 +204,31 @@
/**
* renders the open tag. is
- * @param int $indent_level the indentation level for this tag.
- * @return string
- * @access private
+ *
+ * {@source }
+ * @access private
+ *
+ * @param int the indentation level for this tag.
+ * @return string
*/
function _render_tag($indent_level, $output_debug=0) {
if ( $output_debug ) {
//lets call the special render tag debug function
return $this->_render_tag_debug( $indent_level );
} else {
- return XMLTag::_render_open_tag($indent_level, $this->_xhtml_compliant);
+ return XMLTag::_render_open_tag($indent_level, $this->_flags & _XHTMLCOMPLIANT);
}
}
/**
* Renders all of the content.
* Content can be raw strings, or tag objects.
- * @param int $indent_level the indentation level for this tag.
+ *
+ * {@source }
+ * @access private
+ *
+ * @param int the indentation level for this tag.
* @return string
- * @access private
*/
function _render_content($indent_level, $output_debug=0) {
if ( $output_debug ) {
@@ -227,9 +240,12 @@
/**
* Renders the close tag (if needed)
- * @param int $indent_level the indentation level for this tag.
- * @return string
- * @access private
+ *
+ * {@source }
+ * @access private
+ *
+ * @param int the indentation level for this tag.
+ * @return string
*/
function _render_close_tag($indent_level, $output_debug=0) {
if ( $output_debug ) {
@@ -246,17 +262,23 @@
* so we can override this by the child
* tag, so it can add a link on content or
* one of the attributes.
+ *
+ * {@source }
+ * @access private
+ *
+ * @param int the indentation level
+ * @return string
*/
function _render_tag_debug($indent_level) {
$indent = $this->_render_indent($indent_level, TRUE);
- $tag_prefix = htmlspecialchars( $this->_tag_prefix );
- $tab_postfix = htmlspecialchars( $this->_tag_postfix );
+ $tag_prefix = htmlspecialchars( (@$this->_tag_prefix ? $this->_tag_prefix : _TAG_PREFIX));
+ $tab_postfix = htmlspecialchars( (@$this->_tag_postfix ? $this->_tag_postfix : _TAG_SUFFIX));
$str = $indent . $tag_prefix. "";
$str .= $this->_tag . "";
- if ( $this->_xhtml_compliant && !$this->_always_upper_case ) {
+ if ( ($this->_flags & _XHTMLCOMPLIANT) && !($this->_flags & _ALWAYS_UPPERCASE) ) {
//we have to have the tag name be lower case.
$str = strtolower( $str );
}
@@ -267,11 +289,11 @@
//if we want to output xhtml compliant code, we have to
//render a special tag closing.
- if ( $this->_xhtml_compliant ) {
+ if ( $this->_flags & _XHTMLCOMPLIANT ) {
//we have to render a special close for the
//open tag, if the tag doesn't require a close
//tag or content.
- if ( !$this->_close_tag_required && !$this->_no_finish_slash_xhtml ) {
+ if ( !($this->_flags & _CLOSETAGREQUIRED) && !($this->_flags & _NOFINISHSLASHXHTML) ) {
$html = $str . " />";
} else {
$html = $str.">";
@@ -280,7 +302,7 @@
$html = $str.">";
}
- if ( $this->newline_after_opentag ) {
+ if ( $this->_flags & _NEWLINEAFTEROPENTAG ) {
$html .= " \n";
}
return $html;
@@ -292,17 +314,21 @@
* so it acts like view source.
*
* Content can be raw strings, or tag objects.
- * @param int $indent_level the indentation level for this tag.
- * @return string
- * @access private
+ *
+ * {@source }
+ * @access private
+ *
+ * @param int the indentation level for this tag.
+ * @return string
*/
function _render_content_debug($indent_level) {
$html = '';
//walk through the content
- foreach ($this->_content as $item) {
+ for ($x=0; $x<=$this->_data_count; $x++) {
+ $item = &$this->_content[$x];
if (method_exists($item, "render")) {
- if ($this->_collapse_flag && method_exists($item, "set_collapse")) {
+ if (($this->_flags & _COLLAPSE) && method_exists($item, "set_collapse")) {
$item->set_collapse(TRUE, FALSE);
}
if ($indent_level == INDENT_LEFT_JUSTIFY) {
@@ -312,7 +338,7 @@
}
$html .= $item->render($indent, TRUE);
} else {
- if ($this->_collapse_flag) {
+ if ($this->_flags & _COLLAPSE) {
$html .= htmlspecialchars($item);
} else {
if ($indent_level == INDENT_LEFT_JUSTIFY) {
@@ -321,7 +347,7 @@
$indent = $indent_level + 1;
}
$indent = $this->_render_indent($indent, TRUE);
- if ( $this->newline_after_opentag ) {
+ if ( $this->_flags & _NEWLINEAFTEROPENTAG ) {
$item = htmlspecialchars($item);
$item = str_replace("\n", " \n" . $indent, $item);
$html .= $indent . "" .$item . " \n";
@@ -339,24 +365,27 @@
/**
* this renders the close tag in debugging mode.
- * @param int $indent_level the indentation level for this tag.
- * @return string
- * @access private
+ *
+ * {@source }
+ * @access private
+ *
+ * @param int the indentation level for this tag.
+ * @return string
*/
function _render_close_tag_debug( $indent_level ) {
$indent ="";
- if ( $this->indent_flag && $this->newline_after_opentag ) {
+ if ( ($this->_flags & _INDENT) && ($this->_flags & _NEWLINEAFTEROPENTAG) ) {
$indent = $this->_render_indent($indent_level, TRUE);
}
$str = $indent . "</" . "";
$str .= $this->_tag . ">";
- if ( $this->_xhtml_compliant ) {
+ if ( $this->_flags & _XHTMLCOMPLIANT ) {
$str = strtolower( $str );
}
- if ( $this->newline_after_closetag ) {
+ if ( $this->_flags & _NEWLINEAFTERCLOSETAG ) {
$str .= " \n";
}
@@ -375,6 +404,9 @@
* that shouldn't be rendered if they
* are in the $this->_xhtml_strict_attributes
* array and HTML_RENDER_TYPE = XHTML STRICT
+ *
+ * {@source }
+ * @access private
*
* @param string - $name attribute name
* @param mixed - $value attribute value
@@ -391,7 +423,7 @@
} else if ( $value === NULL ) {
$returnval = " $name";
} else {
- if ( in_array($name, $this->_debug_link_attributes) ) {
+ if ( @in_array($name, $this->_debug_link_attributes) ) {
//lets create a clickable link for the value
//of this attribute
$value = "$value";
@@ -401,24 +433,30 @@
}
}
- if ( HTML_RENDER_TYPE == XHTML_STRICT &&
- in_array($name, $this->_xhtml_strict_attributes) ) {
+ if ( $GLOBALS["HTML_RENDER_TYPE"] == XHTML_STRICT &&
+ @in_array($name, $this->_xhtml_strict_attributes) ) {
$returnval = NULL;
}
} else {
//hack to make non name-value pair work.
//ie