/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/HTMLTagClass.inc
ViewVC logotype

Diff of /nfo/php/libs/com.newsblob.phphtmllib/HTMLTagClass.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by jonen, Thu Jan 30 03:29:08 2003 UTC revision 1.2 by jonen, Sat Feb 22 20:55:24 2003 UTC
# Line 26  require_once( $phphtmllib."/XMLTagClass. Line 26  require_once( $phphtmllib."/XMLTagClass.
26   *   *
27   * @author      Walter A. Boring IV <waboring@buildabetterweb.com>   * @author      Walter A. Boring IV <waboring@buildabetterweb.com>
28   * @link http://phphtmllib.sourceforge.net   * @link http://phphtmllib.sourceforge.net
29     * @package phpHtmlLib
30   */   */
31  class HTMLTagClass extends XMLTagClass {  class HTMLTagClass extends XMLTagClass {
32    
   
         /**  
          * 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;  
   
33          /**          /**
34           * the list of tag attributes that we           * the list of tag attributes that we
35           * should create a clickable link for           * should create a clickable link for
36           * when in debug mode.           * when in debug mode.
37         *
38         * We comment this declaration out
39         * to save memory, since only a small
40         * number of tags use it
41         *
42           * @var  array           * @var  array
43           * @access private           * @access private
44           */           */
45          var $_debug_link_attributes = array("background");          //var $_debug_link_attributes = array("background");
46    
47          /**          /**
48           * The list of attributes not to render           * The list of attributes not to render
49           * if HTML_RENDER_TYPE is "XHTML STRICT"           * if HTML_RENDER_TYPE is "XHTML STRICT"
50           *           *
51         * We comment this declaration out
52         * to save memory, since only a small
53         * number of tags use it
54         *
55           */           */
56          var $_xhtml_strict_attributes = array();          //var $_xhtml_strict_attributes = array();
57    
58    
59          /**          /**
# Line 75  class HTMLTagClass extends XMLTagClass { Line 61  class HTMLTagClass extends XMLTagClass {
61           * htmlentities() on if we are in XHTML_STRICT           * htmlentities() on if we are in XHTML_STRICT
62           * mode.  Otherwise the validator complains about           * mode.  Otherwise the validator complains about
63           * html characters such as &.           * html characters such as &.
64         *
65         * We comment this declaration out
66         * to save memory, since only a small
67         * number of tags use it
68         *
69           * @var array.           * @var array.
70           * @access private           * @access private
71           */           */
72          var $_htmlentities_attributes = array();          //var $_htmlentities_attributes = array();
73    
74    
75          /**          /**
# Line 100  class HTMLTagClass extends XMLTagClass { Line 91  class HTMLTagClass extends XMLTagClass {
91                          $this->set_tag_attributes( $attributes );                          $this->set_tag_attributes( $attributes );
92                  }                  }
93    
94            //set the default tag options
95            $this->_set_flags();
96    
97                  //add the content if any.                  //add the content if any.
98                  $num_args = func_num_args();                  $num_args = func_num_args();
99                  for ($i = 1; $i < $num_args; $i++) {                  for ($i = 1; $i < $num_args; $i++) {
# Line 113  class HTMLTagClass extends XMLTagClass { Line 107  class HTMLTagClass extends XMLTagClass {
107                  //HTML_RENDER_TYPE                  //HTML_RENDER_TYPE
108                  if ( HTML_RENDER_TYPE == XHTML ||                  if ( HTML_RENDER_TYPE == XHTML ||
109                           HTML_RENDER_TYPE == XHTML_STRICT ) {                           HTML_RENDER_TYPE == XHTML_STRICT ) {
110                          $this->_xhtml_compliant = TRUE;                          $this->_flags |= _XHTMLCOMPLIANT;
111    
112                  }                  }
113    
114                  //if the tag is depricated                  //if the tag is depricated
115                  //we raise an alert.                  //we raise an alert.
116                  if ( $this->_depricated ) {                  if ( $this->_flags & _DEPRICATED ) {
117                          trigger_error(htmlspecialchars($this->_tag) . " has been depricated in HTML 4.0", E_USER_NOTICE);                          trigger_error(htmlspecialchars($this->_tag) . " has been depricated in HTML 4.0", E_USER_NOTICE);
118                  }                  }
119          }          }
# Line 138  class HTMLTagClass extends XMLTagClass { Line 132  class HTMLTagClass extends XMLTagClass {
132                  $this->_prepare_flags();                  $this->_prepare_flags();
133    
134                  if ( $indent_level==NULL ) {                  if ( $indent_level==NULL ) {
135                          $indent_level = $this->_indent_level;                          $indent_level = 0;
136                  }                  }
137    
138                  $html  = $this->_render_tag($indent_level, $output_debug);                  $html = $this->_render_tag($indent_level, $output_debug);
139    
140                  if ( $this->_content_required ) {                  if ( $this->_flags & _CONTENTREQUIRED) {
141                          $html .= $this->_render_content($indent_level, $output_debug);                          $html .= $this->_render_content($indent_level, $output_debug);
142                  }                  }
143                  if ( $this->_close_tag_required ) {                  if ( $this->_flags & _CLOSETAGREQUIRED ) {
144                          $html .= $this->_render_close_tag($indent_level, $output_debug);                          $html .= $this->_render_close_tag($indent_level, $output_debug);
145                  }                  }
146    
# Line 206  class HTMLTagClass extends XMLTagClass { Line 200  class HTMLTagClass extends XMLTagClass {
200                          //lets call the special render tag debug function                          //lets call the special render tag debug function
201                          return $this->_render_tag_debug( $indent_level );                                      return $this->_render_tag_debug( $indent_level );            
202                  } else {                  } else {
203              return XMLTag::_render_open_tag($indent_level, $this->_xhtml_compliant);              return XMLTag::_render_open_tag($indent_level, $this->_flags & _XHTMLCOMPLIANT);
204                  }                  }
205          }          }
206    
# Line 251  class HTMLTagClass extends XMLTagClass { Line 245  class HTMLTagClass extends XMLTagClass {
245    
246                  $indent = $this->_render_indent($indent_level, TRUE);                  $indent = $this->_render_indent($indent_level, TRUE);
247    
248                  $tag_prefix = htmlspecialchars( $this->_tag_prefix );                  $tag_prefix = htmlspecialchars( ($this->_tag_prefix ? $this->_tag_prefix : _TAG_PREFIX));
249                  $tab_postfix = htmlspecialchars( $this->_tag_postfix );                  $tab_postfix = htmlspecialchars( ($this->_tag_postfix ? $this->_tag_postfix : _TAG_SUFFIX));
250                  $str = $indent . $tag_prefix. "<span class=\"purple\" style=\"white-space:nowrap;\">";                  $str = $indent . $tag_prefix. "<span class=\"purple\" style=\"white-space:nowrap;\">";
251                  $str .= $this->_tag . "</span>";                  $str .= $this->_tag . "</span>";
252    
253                  if ( $this->_xhtml_compliant && !$this->_always_upper_case ) {                  if ( ($this->_flags & _XHTMLCOMPLIANT) && !($this->_flags & _ALWAYS_UPPERCASE) ) {
254                          //we have to have the tag name be lower case.                          //we have to have the tag name be lower case.
255                          $str = strtolower( $str );                          $str = strtolower( $str );
256                  }                  }
# Line 267  class HTMLTagClass extends XMLTagClass { Line 261  class HTMLTagClass extends XMLTagClass {
261    
262                  //if we want to output xhtml compliant code, we have to                  //if we want to output xhtml compliant code, we have to
263                  //render a special tag closing.                  //render a special tag closing.
264                  if ( $this->_xhtml_compliant ) {                  if ( $this->_flags & _XHTMLCOMPLIANT ) {
265                          //we have to render a special close for the                          //we have to render a special close for the
266                          //open tag, if the tag doesn't require a close                          //open tag, if the tag doesn't require a close
267                          //tag or content.                          //tag or content.
268                          if ( !$this->_close_tag_required && !$this->_no_finish_slash_xhtml ) {                          if ( !($this->_flags & _CLOSETAGREQUIRED) && !($this->_flags & _NOFINISHSLASHXHTML) ) {
269                                  $html = $str . "&nbsp;/&gt;";                                  $html = $str . "&nbsp;/&gt;";
270                          } else {                          } else {
271                                  $html = $str."&gt;";                                  $html = $str."&gt;";
# Line 280  class HTMLTagClass extends XMLTagClass { Line 274  class HTMLTagClass extends XMLTagClass {
274                          $html = $str."&gt;";                          $html = $str."&gt;";
275                  }                  }
276    
277                  if ( $this->newline_after_opentag ) {                  if ( $this->_flags & _NEWLINEAFTEROPENTAG ) {
278                          $html .= "<br>\n";                          $html .= "<br>\n";
279                  }                  }
280                  return $html;                  return $html;
# Line 300  class HTMLTagClass extends XMLTagClass { Line 294  class HTMLTagClass extends XMLTagClass {
294    
295                  $html = '';                  $html = '';
296                  //walk through the content                  //walk through the content
297                  foreach ($this->_content as $item) {                  for ($x=0; $x<=$this->_data_count; $x++) {
298                $item = &$this->_content[$x];
299                          if (method_exists($item, "render")) {                          if (method_exists($item, "render")) {
300                                  if ($this->_collapse_flag && method_exists($item, "set_collapse")) {                                  if (($this->_flags & _COLLAPSE) && method_exists($item, "set_collapse")) {
301                                                  $item->set_collapse(TRUE, FALSE);                                                  $item->set_collapse(TRUE, FALSE);
302                                  }                                  }
303                                  if ($indent_level == INDENT_LEFT_JUSTIFY) {                                  if ($indent_level == INDENT_LEFT_JUSTIFY) {
# Line 312  class HTMLTagClass extends XMLTagClass { Line 307  class HTMLTagClass extends XMLTagClass {
307                                  }                                  }
308                                  $html .= $item->render($indent, TRUE);                                  $html .= $item->render($indent, TRUE);
309                          } else {                          } else {
310                                  if ($this->_collapse_flag) {                                  if ($this->_flags & _COLLAPSE) {
311                      $html .= htmlspecialchars($item);                      $html .= htmlspecialchars($item);
312                                  } else {                                  } else {
313                                          if ($indent_level == INDENT_LEFT_JUSTIFY) {                                          if ($indent_level == INDENT_LEFT_JUSTIFY) {
# Line 321  class HTMLTagClass extends XMLTagClass { Line 316  class HTMLTagClass extends XMLTagClass {
316                                                  $indent = $indent_level + 1;                                                  $indent = $indent_level + 1;
317                                          }                                          }
318                                          $indent = $this->_render_indent($indent, TRUE);                                          $indent = $this->_render_indent($indent, TRUE);
319                                          if ( $this->newline_after_opentag ) {                                          if ( $this->_flags & _NEWLINEAFTEROPENTAG ) {
320                                                  $item = htmlspecialchars($item);                                                  $item = htmlspecialchars($item);
321                                                  $item = str_replace("\n", "<br>\n" . $indent, $item);                                                  $item = str_replace("\n", "<br>\n" . $indent, $item);
322                                                  $html .= $indent . "<span style=\"white-space:nowrap\">" .$item . "</span><br>\n";                                                  $html .= $indent . "<span style=\"white-space:nowrap\">" .$item . "</span><br>\n";
# Line 346  class HTMLTagClass extends XMLTagClass { Line 341  class HTMLTagClass extends XMLTagClass {
341          function _render_close_tag_debug( $indent_level ) {          function _render_close_tag_debug( $indent_level ) {
342    
343                  $indent ="";                  $indent ="";
344                  if ( $this->indent_flag && $this->newline_after_opentag ) {                  if ( ($this->_flags & _INDENT) && ($this->_flags & _NEWLINEAFTEROPENTAG) ) {
345                          $indent = $this->_render_indent($indent_level, TRUE);                          $indent = $this->_render_indent($indent_level, TRUE);
346                  }                  }
347                  $str = $indent . "&lt;/" . "<span class=\"purple\">";                  $str = $indent . "&lt;/" . "<span class=\"purple\">";
348                  $str .= $this->_tag . "</span>&gt;";                  $str .= $this->_tag . "</span>&gt;";
349    
350                  if ( $this->_xhtml_compliant ) {                  if ( $this->_flags & _XHTMLCOMPLIANT ) {
351                          $str = strtolower( $str );                          $str = strtolower( $str );
352                  }                  }
353    
354                  if ( $this->newline_after_closetag ) {                  if ( $this->_flags & _NEWLINEAFTERCLOSETAG ) {
355                          $str .= "<br>\n";                          $str .= "<br>\n";
356                  }                  }
357    
# Line 391  class HTMLTagClass extends XMLTagClass { Line 386  class HTMLTagClass extends XMLTagClass {
386                          } else if ( $value === NULL ) {                          } else if ( $value === NULL ) {
387                                  $returnval = " <span class=\"black\">$name</span>";                                  $returnval = " <span class=\"black\">$name</span>";
388                          } else {                          } else {
389                                  if ( in_array($name, $this->_debug_link_attributes) ) {                                  if ( @in_array($name, $this->_debug_link_attributes) ) {
390                                          //lets create a clickable link for the value                                          //lets create a clickable link for the value
391                                          //of this attribute                                          //of this attribute
392                                          $value = "<a href=\"$value\">$value</a>";                                          $value = "<a href=\"$value\">$value</a>";
# Line 402  class HTMLTagClass extends XMLTagClass { Line 397  class HTMLTagClass extends XMLTagClass {
397                          }                          }
398    
399                          if ( HTML_RENDER_TYPE == XHTML_STRICT &&                          if ( HTML_RENDER_TYPE == XHTML_STRICT &&
400                                   in_array($name, $this->_xhtml_strict_attributes) ) {                                   @in_array($name, $this->_xhtml_strict_attributes) ) {
401                                  $returnval = NULL;                                  $returnval = NULL;
402                          }                          }
403                  } else {                  } else {
# Line 415  class HTMLTagClass extends XMLTagClass { Line 410  class HTMLTagClass extends XMLTagClass {
410                          }                          }
411    
412                          if ( HTML_RENDER_TYPE == XHTML_STRICT &&                          if ( HTML_RENDER_TYPE == XHTML_STRICT &&
413                                   in_array($name, $this->_xhtml_strict_attributes) ) {                                   @in_array($name, $this->_xhtml_strict_attributes) ) {
414                                  $returnval = NULL;                                  $returnval = NULL;
415                          } else {                          } else {
416                                  $returnval = XMLTagClass::_build_attribute_string($name, $value);                                  $returnval = XMLTagClass::_build_attribute_string($name, $value);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed