1<?php
2	/**
3	 * Class to handle basic HTML GUI functions
4	 *
5	 * $Id: Gui.php,v 1.2 2004/06/07 20:03:22 soranzo Exp $
6	 */
7	 class GUI {
8
9		/**
10		 *Constructor
11		 */
12		function __construct() {}
13
14		/**
15		 * Prints a combox box
16		 * @param $arrOptions associative array storing options and values of combo should be Option => Value
17		 * @param $szName string to specify the name of the form element
18		 * @param (optional) $bBlankEntry bool to specify whether or not we want a blank selection
19		 * @param (optional) $szDefault string to specify the default VALUE selected
20		 * @param (optional) $bMultiple bool to specify whether or not we want a multi select combo box
21		 * @param (optional) $iSize int to specify the size IF a multi select combo
22		 * @return string with the generated HTML select box
23		 */
24		static function printCombo(&$arrOptions, $szName, $bBlankEntry = true, $szDefault = '', $bMultiple = false, $iSize = 10) {
25			$htmlOut = '';
26			if ($bMultiple) // If multiple select combo
27				$htmlOut .= "<select name=\"$szName\" id=\"$szName\" multiple=\"multiple\" size=\"$iSize\">\n";
28			else
29				$htmlOut .= "<select name=\"$szName\" id=\"$szName\">\n";
30			if ($bBlankEntry)
31				$htmlOut .= "<option value=\"\"></option>\n";
32
33			foreach ($arrOptions as $curKey => $curVal) {
34				$curVal = htmlspecialchars($curVal);
35				$curKey = htmlspecialchars($curKey);
36				if ($curVal == $szDefault) {
37					$htmlOut .= "<option value=\"$curVal\" selected=\"selected\">$curKey</option>\n";
38				}
39				else {
40					$htmlOut .= "<option value=\"$curVal\">$curKey</option>\n";
41				}
42			}
43			$htmlOut .= "</select>\n";
44
45			return $htmlOut;
46		}
47	 }
48?>
49