Source for file class_b_element.php

Documentation is available at class_b_element.php

  1. <?php
  2. class b_document extends b_element {
  3. var $docType;
  4. function b_document( $type = 'transitional' ) {
  5. /*
  6. * NOTE: i've removed the namespace declarations, they are:
  7. * transitional: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
  8. * strict: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  9. * frameset: "http://www.w3.org/TR/html4/frameset.dtd"
  10. */
  11. if( $type == 'transitional' ) {
  12. $this->docType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
  13. } else if( $type == 'strict' ) {
  14. $this->docType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">';
  15. } else if( $type == 'frameset' ) {
  16. $this->docType = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">';
  17. }
  18. parent::HTMLElement();
  19. }
  20. function to_html() {
  21. $return = "\n<?xml version='1.0' encoding='utf-8'?>\n";
  22. $return .= $this->docType;
  23. foreach( $this->childNodes as $node ) {
  24. $return .= $node->to_html();
  25. }
  26. return $return;
  27. }
  28. }
  29.  
  30. class b_element extends HTMLElement {
  31.  
  32. /*
  33. * b_element is an extension of the standard DOM interface which
  34. * allows DOM objects to be instantiated with 4 parameters:
  35. * $tag - same as standard DOM: specifies the type of node to create
  36. * $id - sets the node's id attribute
  37. * $init_val - can be either text or a child node. in the case of text it
  38. * appends a text node with the given value, in the case of
  39. * a child node it appends the child node
  40. * $attrs - an array of name:value attributes
  41. *
  42. * example: to create a new div with a title containing text 'hello world' and inline style declaration:
  43. * $layer = new b_elment( 'div', 'layer1', new b_element( 'h1', 'title1', 'hello world' ), array( 'style'=>'position:absolute;left:10px;top:10px' ) );
  44. */
  45. function b_element( $tag, $id = NULL, $init_val = NULL, $attrs = array() ) {
  46. //construct the parent DOM object
  47.  
  48. parent::HTMLElement($tag);
  49. if( $id ) { $this->setAttribute( 'id', $id ); }
  50. if( $init_val ) { $this->appendChild( $init_val ); }
  51. $this->setAttributes( $attrs );
  52. }
  53. }
  54.  
  55. ?>

Documentation generated on Tue, 24 May 2005 03:57:21 -0400 by phpDocumentor 1.3.0RC3