6 * Template for constructing a select input tag.
8 * The following variables are available in this template:
9 * string $name The name of the select input
10 * array $aValues An associative array corresponding to each
11 * select option where keys must be used as
12 * the option value and the values must be used
14 * boolean $bUsekeys When FALSE, the value of each option should
15 * be the same as the option text instead of
16 * using the array key for the option value
17 * boolean $multiple When TRUE, a multiple select list should be
19 * array $default An array of option values that should be
20 * selected by default (only will contain one
21 * array element unless this is a multiple select
23 * array $aAttribs Any extra attributes: an associative array, where
24 * keys are attribute names, and values (which are
25 * optional and might be null) should be placed
26 * in double quotes as attribute values (optional;
29 * @copyright © 1999-2008 The SquirrelMail Project Team
30 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
32 * @package squirrelmail
33 * @subpackage templates
37 // retrieve the template vars
42 if (isset($aAttribs['id'])) {
43 $label_open = '<label for="' . $aAttribs['id'] . '">';
44 $label_close = '</label>';
51 echo '<select name="' . $name . ($multiple ? '[]" multiple="multiple" size="3"' : '"');
52 foreach ($aAttribs as $key => $value) {
53 echo ' ' . $key . (is_null($value) ? '' : '="' . $value . '"');
58 foreach ($aValues as $key => $value) {
59 if (!$bUsekeys) $key = $value;
60 echo '<option value="' . $key . '"';
62 // multiple select lists have possibly more than one default selection
65 foreach ($default as $def) {
66 if ((string)$def == (string)$key) {
67 echo ' selected="selected"';
73 // single select widget only needs to check for one default value
74 // (we could use the same code above, but we do this here to increase
75 // efficency and performance)
77 else if ((string)$default[0] == (string)$key)
78 echo ' selected="selected"';
80 echo '>' . $label_open . $value . $label_close . "</option>\n";