--- nfo/php/libs/com.newsblob.phphtmllib/HTMLTagClass.inc 2003/01/30 03:29:08 1.1
+++ nfo/php/libs/com.newsblob.phphtmllib/HTMLTagClass.inc 2004/05/06 12:58:02 1.3
@@ -3,7 +3,7 @@
/**
* Holds the HTMLTagClass
*
- * $Id: HTMLTagClass.inc,v 1.1 2003/01/30 03:29:08 jonen Exp $
+ * $Id: HTMLTagClass.inc,v 1.3 2004/05/06 12:58:02 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,10 +61,15 @@
* 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();
/**
@@ -100,6 +91,9 @@
$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 +105,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);
}
}
@@ -138,15 +132,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);
}
@@ -206,7 +200,7 @@
//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);
}
}
@@ -251,12 +245,12 @@
$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 +261,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 +274,7 @@
$html = $str.">";
}
- if ( $this->newline_after_opentag ) {
+ if ( $this->_flags & _NEWLINEAFTEROPENTAG ) {
$html .= "
\n";
}
return $html;
@@ -300,9 +294,10 @@
$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 +307,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 +316,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";
@@ -346,17 +341,17 @@
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";
}
@@ -391,7 +386,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 +396,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