init
[garradin.git] / include / libs / template_lite / plugins / function.html_textbox.php
1 <?php
2 /**
3 * Template_Lite {html_textbox} function plugin
4 *
5 * Type: function
6 * Name: html_textbox
7 * Purpose: Creates a textbox
8 * Input:
9 * - name = the name of the textbox
10 * - rows = optional number of rows in the textbox
11 * - cols = optional number of columns in the textbox
12 * - value = optional preset value to put in the textbox
13 * Author: Paul Lockaby <paul@paullockaby.com>
14 */
15 function tpl_function_html_textbox($params, &$tpl)
16 {
17 require_once("shared.escape_chars.php");
18 $name = null;
19 $value = '';
20 $extra = '';
21
22 foreach($params as $_key => $_value)
23 {
24 switch($_key)
25 {
26 case 'name':
27 case 'value':
28 $$_key = $_value;
29 break;
30 default:
31 if(!is_array($_key))
32 {
33 $extra .= ' ' . $_key . '="' . tpl_escape_chars($_value) . '"';
34 }
35 else
36 {
37 throw new Template_Exception("html_textbox: attribute '$_key' cannot be an array", $tpl);
38 }
39 }
40 }
41
42 if (!isset($name) || empty($name))
43 {
44 throw new Template_Exception("html_textbox: missing 'name' parameter", $tpl);
45 return;
46 }
47
48 $toReturn = '<textarea name="' . tpl_escape_chars($name) . '" ' . $extra . '>' . tpl_escape_chars($value) . '</textarea>';
49 return $toReturn;
50 }
51 ?>