phpDocumentor page
[ class tree: page ] [ index: page ] [ all elements ]

Source for file Span.php

Documentation is available at Span.php

  1. <?
  2. /**
  3. * @package page
  4. * @filesource
  5. * @see HTML_PAGE_UTIL_PATH.'/Span.php'
  6. * @copyright (c) http://Finn-Rasmussen.com
  7. * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
  8. * @author http://Finn-Rasmussen.com
  9. * @version 1.9
  10. * @since 21-oct-2005
  11. */
  12.  
  13. /**
  14. * The required files
  15. */
  16. require_once(HTML_PATH.'/Html.php');
  17.  
  18. /**
  19. * Generates an <span>...</span>
  20. * <code>
  21. * Usage:
  22. * $html = new Span($text, $class, $align);
  23. * print $html->getHtml();
  24. * Or
  25. * Span::display($text,$class,$align);
  26. * Or
  27. * Span::start($class, $align);
  28. * Link::display();
  29. * Span::end();
  30. * </code>
  31. * @package page
  32. */
  33.  
  34. class Span extends Html {
  35. var $text = ''; // Text or an object
  36. var $class = '';
  37. var $align = '';
  38.  
  39. /**
  40. * Constructor
  41. * @param String $text, The text for the Span tag or an object
  42. * @param String $class The css class name
  43. * @param String $align The align attribute
  44. */
  45. function Span($text='',$class='',$align='') {
  46. $this->Html();
  47. $this->text = $text;
  48. $this->class = $class;
  49. $this->align = $align;
  50. }
  51.  
  52. /**
  53. * Returns the start for the span html element
  54. * @return String the complete html
  55. */
  56. function getStart() {
  57. $html = '';
  58. $html .= '<span';
  59. $html .= $this->getAttribute('class');
  60. $html .= $this->getAttribute('align');
  61. $html .= '>';
  62. return $html;
  63. }
  64.  
  65. /**
  66. * Returns the end for the span html element
  67. * @return String the complete html
  68. */
  69. function getEnd() {
  70. return "</span>\r\n";
  71. }
  72.  
  73. /**
  74. * Returns the html for the span html element
  75. * @return String the complete html
  76. */
  77. function getHtml() {
  78. $html = '';
  79. $html .= $this->getStart();
  80. if (is_object($this->text)) {
  81. $html .= $this->text->getHtml();
  82. } else {
  83. $html .= $this->text;
  84. }
  85. $html .= $this->getElements();
  86. $html .= $this->getEnd();
  87. return $html;
  88. }
  89.  
  90. /**
  91. * Display start
  92. * <code>
  93. * Usage:
  94. * Span::start($class,$align);
  95. * </code>
  96. * @static
  97. * @param String $class The css class of the span
  98. * @param String $align The align attribute
  99. */
  100. function start($class='',$align='') {
  101. $html = new Span('',$class,$align);
  102. $html->addHtml($html->getStart());
  103. }
  104.  
  105. /**
  106. * Display end
  107. * <code>
  108. * Usage:
  109. * Span::end();
  110. * </code>
  111. * @static
  112. */
  113. function end() {
  114. $html = new Html();
  115. $html->addHtml(Span::getEnd());
  116. }
  117.  
  118. /**
  119. * Display html
  120. * <code>
  121. * Usage:
  122. * Span::display($text,$class,$align);
  123. * </code>
  124. * @static
  125. * @param String $text, The text for the span or an object
  126. * @param String $class The css class of the span
  127. * @param String $align The align attribute
  128. */
  129. function display($text='',$class='',$align='') {
  130. $html = new Span($text,$class,$align);
  131. $html->addHtml();
  132. }
  133. }
  134. ?>

Documentation generated on Thu, 22 Dec 2005 17:18:57 +0100 by phpDocumentor 1.3.0RC3