Source for file ElementsByTagName.class.php

Documentation is available at ElementsByTagName.class.php

  1. <?php
  2. /**
  3. * NAJAX HTML DOM Elements By Tag Name file.
  4. *
  5. * <p>This file defines the {@link NAJAX_HTML_DOM_ElementsByTagName} Class.</p>
  6. *
  7. * @author Stanimir Angeloff
  8. *
  9. * @package NAJAX
  10. *
  11. * @subpackage NAJAX_HTML
  12. *
  13. * @version 0.4.1.0
  14. *
  15. */
  16.  
  17. /**
  18. * Loads the file that defines the base class for {@link NAJAX_HTML_DOM_ElementsByTagName}.
  19. */
  20. require_once(NAJAX_HTML_BASE . '/classes/DOM/BaseElement.class.php');
  21.  
  22. /**
  23. * NAJAX HTML DOM Elements By Tag Name Class.
  24. *
  25. * @author Stanimir Angeloff
  26. *
  27. * @package NAJAX
  28. *
  29. * @subpackage NAJAX_HTML
  30. *
  31. * @version 0.4.1.0
  32. *
  33. */
  34. class NAJAX_HTML_DOM_ElementsByTagName extends NAJAX_HTML_DOM_BaseElement
  35. {
  36. /**
  37. * Creates a new instance of the {@link NAJAX_HTML_DOM_ElementsByTagName} class.
  38. *
  39. * @param string $tagName String that holds the tag name of the elements.
  40. *
  41. * @access public
  42. *
  43. */
  44. function NAJAX_HTML_DOM_ElementsByTagName($tagName)
  45. {
  46. parent::NAJAX_HTML_DOM_BaseElement();
  47.  
  48. $this->tagName = $tagName;
  49.  
  50. $this->skipKeys[] = 'tagName';
  51. }
  52.  
  53. /**
  54. * Returns the JavaScript name of the elements.
  55. *
  56. * @access public
  57. *
  58. * @return string The JavaScript name of the elements.
  59. *
  60. */
  61. function getElement()
  62. {
  63. return '__' . ereg_replace('[^a-zA-Z0-9]', '_', $this->tagName);
  64. }
  65.  
  66. /**
  67. * Returns the JavaScript code of the DOM elements.
  68. *
  69. * <p>You should not call this method directly.</p>
  70. *
  71. * @access public
  72. *
  73. * @return string JavaScript source code for the DOM elements.
  74. *
  75. * @static
  76. *
  77. */
  78. function process()
  79. {
  80. $element = $this->getElement();
  81.  
  82. $returnValue = $element . 's=document.getElementsByTagName("' . $this->tagName . '");';
  83.  
  84. $returnValue .= 'for(' . $element . 'sIterator=0;';
  85. $returnValue .= $element . 'sIterator<' . $element . 's.length;';
  86. $returnValue .= $element . 'sIterator++){';
  87. $returnValue .= $element . '=' . $element . 's[' . $element . 'sIterator];';
  88.  
  89. $returnValue .= parent::process($element);
  90.  
  91. $returnValue .= '}';
  92.  
  93. return $returnValue;
  94. }
  95. }
  96. ?>

Documentation generated on Tue, 20 Sep 2005 21:40:01 +0300 by phpDocumentor 1.3.0RC3