/[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.2 by jonen, Sat Feb 22 20:55:24 2003 UTC revision 1.4 by jonen, Thu May 6 16:23:38 2004 UTC
# Line 46  class HTMLTagClass extends XMLTagClass { Line 46  class HTMLTagClass extends XMLTagClass {
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 $GLOBALS["HTML_RENDER_TYPE"] is "XHTML STRICT"
50           *           *
51       * We comment this declaration out       * We comment this declaration out
52       * to save memory, since only a small       * to save memory, since only a small
# Line 74  class HTMLTagClass extends XMLTagClass { Line 74  class HTMLTagClass extends XMLTagClass {
74    
75          /**          /**
76           * Class Constructor           * Class Constructor
77         *
78         * {@source }
79         *
80           * @param   array - Associative array of           * @param   array - Associative array of
81           *                  name="value" pairs of           *                  name="value" pairs of
82           *                  tag atributes.           *                  tag atributes.
# Line 83  class HTMLTagClass extends XMLTagClass { Line 86  class HTMLTagClass extends XMLTagClass {
86           *                  of parameters that will           *                  of parameters that will
87           *                  be added to the content           *                  be added to the content
88           *                  of the tag automatically.           *                  of the tag automatically.
          *  
          * @access   public  
89           */           */
90          function HTMLTagClass( $attributes=NULL ) {          function HTMLTagClass( $attributes=NULL ) {
91                  if ( $attributes ) {                  if ( $attributes ) {
# Line 105  class HTMLTagClass extends XMLTagClass { Line 106  class HTMLTagClass extends XMLTagClass {
106                  //this is a magic test.  It assumes that                  //this is a magic test.  It assumes that
107                  //someone has created the define for                  //someone has created the define for
108                  //HTML_RENDER_TYPE                  //HTML_RENDER_TYPE
109                  if ( HTML_RENDER_TYPE == XHTML ||                  if ( $GLOBALS["HTML_RENDER_TYPE"] == XHTML ||
110                           HTML_RENDER_TYPE == XHTML_STRICT ) {                           $GLOBALS["HTML_RENDER_TYPE"] == XHTML_STRICT ) {
111                          $this->_flags |= _XHTMLCOMPLIANT;                          $this->_flags |= _XHTMLCOMPLIANT;
112    
113                  }                  }
# Line 121  class HTMLTagClass extends XMLTagClass { Line 122  class HTMLTagClass extends XMLTagClass {
122    
123          /**          /**
124           * Renders the tag, attributes, content and close tag.           * Renders the tag, attributes, content and close tag.
125         *
126         * {@source }
127         *
128           * @param   int    $indent_level    the indentation level for this tag.           * @param   int    $indent_level    the indentation level for this tag.
129         * @param  boolean output in html viewable mode
130           * @return  string           * @return  string
          * @access  public  
131           */           */
132          function render($indent_level=NULL, $output_debug=0) {          function render($indent_level=NULL, $output_debug=0) {
133    
# Line 155  class HTMLTagClass extends XMLTagClass { Line 159  class HTMLTagClass extends XMLTagClass {
159       * This function is a shorthand helper       * This function is a shorthand helper
160       * to setting the style attribute on a       * to setting the style attribute on a
161       * tag.       * tag.
162         *
163         * {@source }
164       *       *
165       * @param string - the style value.       * @param string - the style value.
166         * @return none
167       */       */
168      function set_style( $value ) {      function set_style( $value ) {
169          $this->set_tag_attribute("style", $value);          $this->set_tag_attribute("style", $value);
# Line 166  class HTMLTagClass extends XMLTagClass { Line 173  class HTMLTagClass extends XMLTagClass {
173       * This function is a shorthand helper       * This function is a shorthand helper
174       * to setting the class attribute on a       * to setting the class attribute on a
175       * tag.       * tag.
176         *
177         * {@source }
178       *       *
179       * @param string - the class value.       * @param string - the class value.
180         * @return none
181       */       */
182      function set_class( $value ) {      function set_class( $value ) {
183          $this->set_tag_attribute("class", $value);          $this->set_tag_attribute("class", $value);
# Line 177  class HTMLTagClass extends XMLTagClass { Line 187  class HTMLTagClass extends XMLTagClass {
187       * This function is a shorthand helper       * This function is a shorthand helper
188       * to setting the id attribute on a       * to setting the id attribute on a
189       * tag.       * tag.
190         *
191         * {@source }
192       *       *
193       * @param string - the class value.       * @param string - the class value.
194         * @return none
195       */       */
196      function set_id( $value ) {      function set_id( $value ) {
197          $this->set_tag_attribute("id", $value);          $this->set_tag_attribute("id", $value);
# Line 191  class HTMLTagClass extends XMLTagClass { Line 204  class HTMLTagClass extends XMLTagClass {
204    
205          /**          /**
206           * renders the open tag. is <TABLE>           * renders the open tag. is <TABLE>
207           * @param   int    $indent_level    the indentation level for this tag.       *
208           * @return  string       * {@source }
209           * @access  private       * @access  private
210         *
211             * @param int the indentation level for this tag.
212             * @return string
213           */           */
214          function _render_tag($indent_level, $output_debug=0) {          function _render_tag($indent_level, $output_debug=0) {
215                  if ( $output_debug ) {                  if ( $output_debug ) {
# Line 207  class HTMLTagClass extends XMLTagClass { Line 223  class HTMLTagClass extends XMLTagClass {
223          /**          /**
224           * Renders all of the content.           * Renders all of the content.
225           * Content can be raw strings, or tag objects.           * Content can be raw strings, or tag objects.
226           * @param   int    $indent_level    the indentation level for this tag.       *
227         * {@source }
228         * @access private
229         *
230             * @param int the indentation level for this tag.
231           * @return  string           * @return  string
          * @access  private  
232           */           */
233          function _render_content($indent_level, $output_debug=0) {          function _render_content($indent_level, $output_debug=0) {
234                  if ( $output_debug ) {                  if ( $output_debug ) {
# Line 221  class HTMLTagClass extends XMLTagClass { Line 240  class HTMLTagClass extends XMLTagClass {
240    
241          /**          /**
242           * Renders the close tag (if needed)           * Renders the close tag (if needed)
243           * @param   int    $indent_level    the indentation level for this tag.       *
244           * @return  string       * {@source }
245           * @access  private       * @access private
246         *
247             * @param int the indentation level for this tag.
248             * @return string
249           */           */
250          function _render_close_tag($indent_level, $output_debug=0) {          function _render_close_tag($indent_level, $output_debug=0) {
251                  if ( $output_debug ) {                  if ( $output_debug ) {
# Line 240  class HTMLTagClass extends XMLTagClass { Line 262  class HTMLTagClass extends XMLTagClass {
262           * so we can override this by the child           * so we can override this by the child
263           * tag, so it can add a link on content or           * tag, so it can add a link on content or
264           * one of the attributes.             * one of the attributes.  
265         *
266         * {@source }
267         * @access private
268         *
269         * @param int the indentation level
270         * @return string
271           */           */
272          function _render_tag_debug($indent_level) {          function _render_tag_debug($indent_level) {
273    
274                  $indent = $this->_render_indent($indent_level, TRUE);                  $indent = $this->_render_indent($indent_level, TRUE);
275    
276                  $tag_prefix = htmlspecialchars( ($this->_tag_prefix ? $this->_tag_prefix : _TAG_PREFIX));                  $tag_prefix = htmlspecialchars( (@$this->_tag_prefix ? $this->_tag_prefix : _TAG_PREFIX));
277                  $tab_postfix = htmlspecialchars( ($this->_tag_postfix ? $this->_tag_postfix : _TAG_SUFFIX));                  $tab_postfix = htmlspecialchars( (@$this->_tag_postfix ? $this->_tag_postfix : _TAG_SUFFIX));
278                  $str = $indent . $tag_prefix. "<span class=\"purple\" style=\"white-space:nowrap;\">";                  $str = $indent . $tag_prefix. "<span class=\"purple\" style=\"white-space:nowrap;\">";
279                  $str .= $this->_tag . "</span>";                  $str .= $this->_tag . "</span>";
280    
# Line 286  class HTMLTagClass extends XMLTagClass { Line 314  class HTMLTagClass extends XMLTagClass {
314           * so it acts like view source.           * so it acts like view source.
315           *           *
316           * Content can be raw strings, or tag objects.           * Content can be raw strings, or tag objects.
317           * @param   int    $indent_level    the indentation level for this tag.       *
318           * @return  string       * {@source }
319           * @access  private       * @access private
320         *
321             * @param int the indentation level for this tag.
322             * @return string
323           */           */
324          function _render_content_debug($indent_level) {          function _render_content_debug($indent_level) {
325    
# Line 334  class HTMLTagClass extends XMLTagClass { Line 365  class HTMLTagClass extends XMLTagClass {
365    
366          /**          /**
367           * this renders the close tag in debugging mode.           * this renders the close tag in debugging mode.
368           * @param   int    $indent_level    the indentation level for this tag.       *
369           * @return  string       * {@source }
370           * @access  private       * @access private
371         *
372             * @param int the indentation level for this tag.
373             * @return string
374           */           */
375          function _render_close_tag_debug( $indent_level ) {          function _render_close_tag_debug( $indent_level ) {
376    
# Line 370  class HTMLTagClass extends XMLTagClass { Line 404  class HTMLTagClass extends XMLTagClass {
404           * that shouldn't be rendered if they           * that shouldn't be rendered if they
405           * are in the $this->_xhtml_strict_attributes           * are in the $this->_xhtml_strict_attributes
406           * array and HTML_RENDER_TYPE = XHTML STRICT           * array and HTML_RENDER_TYPE = XHTML STRICT
407         *
408         * {@source }
409         * @access private
410           *           *
411           * @param   string - $name attribute name           * @param   string - $name attribute name
412           * @param   mixed - $value attribute value           * @param   mixed - $value attribute value
# Line 396  class HTMLTagClass extends XMLTagClass { Line 433  class HTMLTagClass extends XMLTagClass {
433                                  }                                  }
434                          }                          }
435    
436                          if ( HTML_RENDER_TYPE == XHTML_STRICT &&                          if ( $GLOBALS["HTML_RENDER_TYPE"] == XHTML_STRICT &&
437                                   @in_array($name, $this->_xhtml_strict_attributes) ) {                                   @in_array($name, $this->_xhtml_strict_attributes) ) {
438                                  $returnval = NULL;                                  $returnval = NULL;
439                          }                          }
440                  } else {                  } else {
441                          //hack to make non name-value pair work.                          //hack to make non name-value pair work.
442                          //ie <option name=foo value=bar CHECKED>                          //ie <option name=foo value=bar CHECKED>
443                          if ( HTML_RENDER_TYPE == XHTML_STRICT && !is_int($name) ) {                          if ( $GLOBALS["HTML_RENDER_TYPE"] == XHTML_STRICT && !is_int($name) ) {
444                                  //We do this because XHTML STRICT complains about                                  //We do this because XHTML STRICT complains about
445                                  //html characters such as &.  So we mask them.                                  //html characters such as &.  So we mask them.
446                                  $value = htmlentities($value);                                  $value = htmlspecialchars($value);
447                          }                          }
448    
449                          if ( HTML_RENDER_TYPE == XHTML_STRICT &&                          if ( $GLOBALS["HTML_RENDER_TYPE"] == XHTML_STRICT &&
450                                   @in_array($name, $this->_xhtml_strict_attributes) ) {                                   @in_array($name, $this->_xhtml_strict_attributes) ) {
451                                  $returnval = NULL;                                  $returnval = NULL;
452                          } else {                          } else {
453                                  $returnval = XMLTagClass::_build_attribute_string($name, $value);                  if ( ((int)$name - 0) === $name) {
454                        $returnval = " ".$value;
455                    } else if ( $value === NULL ) {
456                        $returnval = " ".$name;
457                    } else {
458                        $returnval= " ".$name."=\"".$value."\"";
459                    }
460                          }                          }
461                  }                  }
462                  return $returnval;                  return $returnval;
# Line 423  class HTMLTagClass extends XMLTagClass { Line 466  class HTMLTagClass extends XMLTagClass {
466          // Misc functions          // Misc functions
467          //****************************************************************          //****************************************************************
468    
469    
470        /**
471         * This function checks to see if
472         * there is only 1 content data, and
473         * its not an object, then it auto
474         * sets some of the indentation flags
475         *
476         * {@source }
477         * @access private
478         * @return none
479         */
480        function _prepare_flags() {
481                    if ($this->_flags & _CONTENTREQUIRED) {
482                            if ($this->count_content() == 1) {
483                                    if (!is_object($this->_content[0])) {
484                                            //ok looks like this object has only
485                                            //1 data for content and its a string.          
486                                            if ( !strstr($this->_content[0], "\n") ) {
487                                                    $this->_flags &= ~_NEWLINEAFTEROPENTAG;
488                                            }
489                                    }
490                            } else if ($this->count_content() == 0) {
491                    $this->_flags &= ~_NEWLINEAFTEROPENTAG;
492                }
493                    }
494        }
495    
496  }  }
497  ?>  ?>

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

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