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

Source for file Div.php

Documentation is available at Div.php

  1. <?
  2. /**
  3. * @package page
  4. * @filesource
  5. * @see HTML_PAGE_UTIL_PATH.'/Div.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 a <div class="$class" align="$align">$text</div>
  20. * <code>
  21. * Usage:
  22. * $html = new Div($text, $class,$align);
  23. * print $html->getHtml();
  24. * Or
  25. * Div::display($text,$class,$align);
  26. * Or
  27. * Div::start($class, $align);
  28. * Link::display();
  29. * Div::end();
  30. * </code>
  31. * @package page
  32. */
  33.  
  34. class Div extends Html {
  35. /**
  36. * @var String $text The Text or an object
  37. */
  38. var $text = '';
  39.  
  40. /**
  41. * @var String $class The CSS class name for an object
  42. */
  43. var $class = '';
  44.  
  45. /**
  46. * @var String $align The align attribute
  47. */
  48. var $align = '';
  49.  
  50. /**
  51. * Constructor
  52. * @param String $text, The text for the Div tag or an object
  53. * @param String $class The css class name
  54. * @param String $align The align attribute
  55. */
  56. function Div($text='',$class='',$align='') {
  57. $this->Html();
  58. $this->text = $text;
  59. $this->class = $class;
  60. $this->align = $align;
  61. }
  62.  
  63. /**
  64. * Returns the start for the div html element
  65. * @return String the complete html
  66. */
  67. function getStart() {
  68. $html = '';
  69. $html .= '<div';
  70. $html .= $this->getAttribute('class');
  71. $html .= $this->getAttribute('align');
  72. $html .= '>';
  73. return $html;
  74. }
  75.  
  76. /**
  77. * Returns the end for the div html element
  78. * @return String the complete html
  79. */
  80. function getEnd() {
  81. return "</div>\r\n";
  82. }
  83.  
  84. /**
  85. * Returns the html for the div html element
  86. * @return String the complete html
  87. */
  88. function getHtml() {
  89. $html = '';
  90. $html .= $this->getStart();
  91. if (is_object($this->text)) {
  92. $html .= $this->text->getHtml();
  93. } else {
  94. $html .= $this->text;
  95. }
  96. $html .= $this->getElements();
  97. $html .= $this->getEnd();
  98. return $html;
  99. }
  100.  
  101. /**
  102. * Display start
  103. * <code>
  104. * Usage:
  105. * Div::start($class,$align);
  106. * </code>
  107. * @static
  108. * @param $class, The css class of the div
  109. * @param $align The align attribute
  110. */
  111. function start($class='',$align='') {
  112. $html = new Div('',$class,$align);
  113. $html->addHtml($html->getStart());
  114. }
  115.  
  116. /**
  117. * Display end
  118. * <code>
  119. * Usage:
  120. * Div::end();
  121. * </code>
  122. * @static
  123. */
  124. function end() {
  125. $html = new Html();
  126. $html->addHtml(Div::getEnd());
  127. }
  128.  
  129. /**
  130. * Display html
  131. * <code>
  132. * Usage:
  133. * Div::display($text,$class,$align);
  134. * </code>
  135. * @static
  136. * @param String $text The text for the div or an object
  137. * @param String $class The css class of the div
  138. * @param String $align The align attribute
  139. */
  140. function display($text='',$class='',$align='') {
  141. $html = new Div($text,$class,$align);
  142. $html->addHtml();
  143. }
  144. }
  145. ?>

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