- <?
- /**
- * @package form
- * @filesource
- * @see HTML_FORM_COMPONENT_PATH.'/Textarea.php'
- * @copyright (c) http://Finn-Rasmussen.com
- * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
- * @author http://Finn-Rasmussen.com
- * @version 1.9
- * @since 21-oct-2005
- */
-
- /**
- * The required files
- */
- require_once(HTML_PATH.'/Html.php');
-
- /**
- * Generates a html form elements, TEXTAREA
- * <code>
- * Usage:
- * $textarea = new Textarea($name,$text,$rows,$cols,$class,$title,$tabindex);
- * print $textarea->getHtml();
- * Or
- * $textarea = new Textarea($name,$text,$rows,$cols,$class,$title,$tabindex);
- * print $textarea->getStart();
- * print "Display some text";
- * print $textarea->getEnd();
- * Or
- * Textarea::display($name,$text,$rows,$cols,$class,$title,$tabindex);
- * Or
- * Textarea::start($name,$text,$rows,$cols,$class,$title,$tabindex);
- * Raw::display('Display some text');
- * Textarea::end($name,$text,$rows,$cols,$class,$title,$tabindex);
- * </code>
- * @package form
- */
-
- class Textarea extends Html {
- var $name = ''; // The name of the element
-
- var $id = ''; // The ID of the element
-
- var $text = ''; // The text to show
-
- var $rows = ''; // The number of rows
-
- var $cols = ''; // The number of columns
-
- var $class = ''; // The css class
-
- var $title = ''; // Tooltip
-
- var $tabindex = ''; // Tabindex
-
-
-
- /**
- * Constructor
- * @param String $name The name of the control
- * @param String $text The text value, if any
- * @param String $rows The number of rows
- * @param String $cols The number of columns
- * @param String $class The class name
- * @param String $tabindex The tabindex
- */
- function Textarea($name,$text='',$rows='',$cols='',$class='',$title='',$tabindex='') {
- $this->Html();
- $this->name = $name;
- $this->id = $name;
- $this->title = $title;
- $this->tabindex = $tabindex;
- $this->text = $text!=''?$text:'';
- $this->rows = $rows!=''?$rows:TEXTAREA_ROWS;
- $this->cols = $cols!=''?$cols:TEXTAREA_COLS;
- $this->class = $class!=''?$class:CSS_TEXTAREA_CLASS;
- }
-
- /**
- * Returns the complete html for the start of a textarea control
- * @return String the complete html
- */
- function getStart() {
- $html = $this->html;
- $html .= '<textarea';
- $html .= $this->getAttribute('name');
- $html .= $this->getAttribute('id');
- $html .= $this->getAttribute('rows');
- $html .= $this->getAttribute('cols');
- $html .= $this->getAttribute('class');
- $html .= $this->getAttribute('title');
- $html .= $this->getAttribute('tabindex');
- $html .= ">";
- return $html;
- }
-
- /**
- * Returns the complete html for the end of a textarea control
- * @return String the complete html
- */
- function getEnd() {
- $html = '';
- $html .= "</textarea><br />\r\n";
- return $html;
- }
-
- /**
- * Returns the complete html for a textarea control
- * @return String the complete html
- */
- function getHtml() {
- $html = '';
- $html .= $this->getStart();
- $html .= htmlspecialchars(stripslashes($this->text)); // Translate html special chars
- $html .= $this->getEnd();
- return $html;
- }
-
- /**
- * Display start html
- * <code>
- * Usage:
- * Textarea::start($name,$text,$rows,$cols,$class,$title,$tabindex);
- * </code>
- * @static
- * @param String $name The name of the control
- * @param String $text The text value, if any
- * @param String $rows The number of rows
- * @param String $cols The number of columns
- * @param String $class The class name
- * @param String $tabindex The tabindex
- */
- function start($name,$text='',$rows='',$cols='',$class='',$title='',$tabindex='') {
- $html = new Textarea($name,$text,$rows,$cols,$class,$title,$tabindex);
- $html->addHtml($html->getStart());
- }
-
- /**
- * Display end html
- * <code>
- * Usage:
- * Textarea::end();
- * </code>
- * @static
- */
- function end() {
- $html = new Html();
- $html->addHtml(Textarea::getEnd());
- }
-
- /**
- * Display html
- * <code>
- * Usage:
- * Textarea::display($name,$text,$rows,$cols,$class,$title,$tabindex);
- * </code>
- * @static
- * @param String $name The name of the control
- * @param String $text The text value, if any
- * @param String $rows The number of rows
- * @param String $cols The number of columns
- * @param String $class The class name
- * @param String $tabindex The tabindex
- */
- function display($name,$text='',$rows='',$cols='',$class='',$title='',$tabindex='') {
- $html = new Textarea($name,$text,$rows,$cols,$class,$title,$tabindex);
- $html->addHtml();
- }
- }
- ?>