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

Source for file Textarea.php

Documentation is available at Textarea.php

  1. <?
  2. /**
  3. * @package form
  4. * @filesource
  5. * @see HTML_FORM_COMPONENT_PATH.'/Textarea.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 html form elements, TEXTAREA
  20. * <code>
  21. * Usage:
  22. * $textarea = new Textarea($name,$text,$rows,$cols,$class,$title,$tabindex);
  23. * print $textarea->getHtml();
  24. * Or
  25. * $textarea = new Textarea($name,$text,$rows,$cols,$class,$title,$tabindex);
  26. * print $textarea->getStart();
  27. * print "Display some text";
  28. * print $textarea->getEnd();
  29. * Or
  30. * Textarea::display($name,$text,$rows,$cols,$class,$title,$tabindex);
  31. * Or
  32. * Textarea::start($name,$text,$rows,$cols,$class,$title,$tabindex);
  33. * Raw::display('Display some text');
  34. * Textarea::end($name,$text,$rows,$cols,$class,$title,$tabindex);
  35. * </code>
  36. * @package form
  37. */
  38.  
  39. class Textarea extends Html {
  40. var $name = ''; // The name of the element
  41. var $id = ''; // The ID of the element
  42. var $text = ''; // The text to show
  43. var $rows = ''; // The number of rows
  44. var $cols = ''; // The number of columns
  45. var $class = ''; // The css class
  46. var $title = ''; // Tooltip
  47. var $tabindex = ''; // Tabindex
  48.  
  49.  
  50. /**
  51. * Constructor
  52. * @param String $name The name of the control
  53. * @param String $text The text value, if any
  54. * @param String $rows The number of rows
  55. * @param String $cols The number of columns
  56. * @param String $class The class name
  57. * @param String $tabindex The tabindex
  58. */
  59. function Textarea($name,$text='',$rows='',$cols='',$class='',$title='',$tabindex='') {
  60. $this->Html();
  61. $this->name = $name;
  62. $this->id = $name;
  63. $this->title = $title;
  64. $this->tabindex = $tabindex;
  65. $this->text = $text!=''?$text:'';
  66. $this->rows = $rows!=''?$rows:TEXTAREA_ROWS;
  67. $this->cols = $cols!=''?$cols:TEXTAREA_COLS;
  68. $this->class = $class!=''?$class:CSS_TEXTAREA_CLASS;
  69. }
  70.  
  71. /**
  72. * Returns the complete html for the start of a textarea control
  73. * @return String the complete html
  74. */
  75. function getStart() {
  76. $html = $this->html;
  77. $html .= '<textarea';
  78. $html .= $this->getAttribute('name');
  79. $html .= $this->getAttribute('id');
  80. $html .= $this->getAttribute('rows');
  81. $html .= $this->getAttribute('cols');
  82. $html .= $this->getAttribute('class');
  83. $html .= $this->getAttribute('title');
  84. $html .= $this->getAttribute('tabindex');
  85. $html .= ">";
  86. return $html;
  87. }
  88.  
  89. /**
  90. * Returns the complete html for the end of a textarea control
  91. * @return String the complete html
  92. */
  93. function getEnd() {
  94. $html = '';
  95. $html .= "</textarea><br />\r\n";
  96. return $html;
  97. }
  98.  
  99. /**
  100. * Returns the complete html for a textarea control
  101. * @return String the complete html
  102. */
  103. function getHtml() {
  104. $html = '';
  105. $html .= $this->getStart();
  106. $html .= htmlspecialchars(stripslashes($this->text)); // Translate html special chars
  107. $html .= $this->getEnd();
  108. return $html;
  109. }
  110.  
  111. /**
  112. * Display start html
  113. * <code>
  114. * Usage:
  115. * Textarea::start($name,$text,$rows,$cols,$class,$title,$tabindex);
  116. * </code>
  117. * @static
  118. * @param String $name The name of the control
  119. * @param String $text The text value, if any
  120. * @param String $rows The number of rows
  121. * @param String $cols The number of columns
  122. * @param String $class The class name
  123. * @param String $tabindex The tabindex
  124. */
  125. function start($name,$text='',$rows='',$cols='',$class='',$title='',$tabindex='') {
  126. $html = new Textarea($name,$text,$rows,$cols,$class,$title,$tabindex);
  127. $html->addHtml($html->getStart());
  128. }
  129.  
  130. /**
  131. * Display end html
  132. * <code>
  133. * Usage:
  134. * Textarea::end();
  135. * </code>
  136. * @static
  137. */
  138. function end() {
  139. $html = new Html();
  140. $html->addHtml(Textarea::getEnd());
  141. }
  142.  
  143. /**
  144. * Display html
  145. * <code>
  146. * Usage:
  147. * Textarea::display($name,$text,$rows,$cols,$class,$title,$tabindex);
  148. * </code>
  149. * @static
  150. * @param String $name The name of the control
  151. * @param String $text The text value, if any
  152. * @param String $rows The number of rows
  153. * @param String $cols The number of columns
  154. * @param String $class The class name
  155. * @param String $tabindex The tabindex
  156. */
  157. function display($name,$text='',$rows='',$cols='',$class='',$title='',$tabindex='') {
  158. $html = new Textarea($name,$text,$rows,$cols,$class,$title,$tabindex);
  159. $html->addHtml();
  160. }
  161. }
  162. ?>

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