From a67f718157febd5617904433e924238fbc246a35 Mon Sep 17 00:00:00 2001
From: Robert Sesek <rsesek@bluestatic.org>
Date: Mon, 25 Dec 2006 22:55:50 +0000
Subject: [PATCH] - Added BSPrinterTableElement::RowTextarea() - Added textarea
 support to BSPrinterBaseElement

---
 PrinterBaseElement.php  | 17 ++++++++++++++++-
 PrinterTableElement.php | 20 ++++++++++++++++++++
 printer.php             | 18 +-----------------
 3 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/PrinterBaseElement.php b/PrinterBaseElement.php
index ce68dc9..8586540 100644
--- a/PrinterBaseElement.php
+++ b/PrinterBaseElement.php
@@ -81,6 +81,11 @@ class BSPrinterBaseElement extends BSPrinterElement
 		$this->name = $name;
 		$this->value = $value;
 		$this->setCssClass('input');
+		
+		if ($type == 'textarea')
+		{
+			$this->setStyle(array('width' => '100%', 'height' => '50px'));
+		}
 	}
 	
 	// ###################################################################
@@ -94,7 +99,7 @@ class BSPrinterBaseElement extends BSPrinterElement
 	{
 		if (!in_array($this->type, array('checkbox', 'radio', 'option')))
 		{
-			trigger_error('PrinterBaseElement::setActive() can only be used on elements of type checkbox, radio, or option');
+			trigger_error('BSPrinterBaseElement::setActive() can only be used on elements of type checkbox, radio, or option');
 		}
 		$this->active = $active;
 	}
@@ -186,6 +191,16 @@ class BSPrinterBaseElement extends BSPrinterElement
 			
 			case 'select':
 				return '<select' . $name . $this->_prepareStyle() . '>' . $this->value . '</select>';
+			break;
+			
+			case 'textarea':
+				if (!isset($this->style['height']) OR !isset($this->style['width']))
+				{
+					trigger_error('BSPrinterBaseElement of type "textarea" require a "height" and "width" style attribute');
+				}
+				
+				return '<textarea' . $name . ' cols="50" rows="2"' . $this->_prepareStyle() . '>' . $this->value . '</textarea>';
+			break;
 			
 			default:
 				trigger_error('Invalid PrinterBaseElement type "' . $this->type . '"');
diff --git a/PrinterTableElement.php b/PrinterTableElement.php
index f3e7d9c..2e5d33e 100644
--- a/PrinterTableElement.php
+++ b/PrinterTableElement.php
@@ -270,6 +270,26 @@ class BSPrinterTableElement extends BSPrinterElement
 		return $tr;
 	}
 	
+	// ###################################################################
+	/**
+	* Prints a row with a textarea
+	*
+	* @param	string	Label
+	* @param	string	Textarea name
+	* @param	string	Value to fill with
+	*
+	* @return	BSPrinterTableElement	Table row
+	*/
+	public static function RowTextarea($label, $name, $value = null)
+	{
+		$tr = new BSPrinterTableElement();
+		
+		$tr->addChild(new BSPrinterLabelElement($label));
+		$tr->addChild(new BSPrinterBaseElement('textarea', $name, $value));
+		
+		return $tr;
+	}
+	
 	// ###################################################################
 	/**
 	* Returns the number of columns in this element
diff --git a/printer.php b/printer.php
index b0be961..e969329 100644
--- a/printer.php
+++ b/printer.php
@@ -56,23 +56,7 @@ require_once('ISSO/PrinterTableElement.php');
 */
 class Printer
 {	
-	// ###################################################################
-	/**
-	* Creates a table row with a <textarea> as the value column
-	*
-	* @param	string	Label text
-	* @param	string	Name of the <textarea>
-	* @param	string	Value of the <textarea>
-	* @param	integer	Colspan attribute
-	* @param	integer	Number of rows in the <textarea>
-	* @param	integer Number of colums in the <textarea>
-	* @param	bool	Whether or not to use monospacing font
-	* @param	string	Extra style attributes to apply to the <textarea>
-	*/
-	public function row_textarea($label, $name, $value = '', $colspan = 2, $rows = 7, $cols = 50, $code = false, $style = '')
-	{
-		$this->row_text($label, "<textarea name=\"$name\" class=\"" . ($code ? 'code' : 'input') . "\" rows=\"$rows\" cols=\"$cols\"" . ($style ? ' style="' . $style . '"' : '') . ">$value</textarea>", 'top', $colspan);
-	}
+
 }
 
 /*=====================================================================*\
-- 
2.43.5