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;
28 * int $size The desired height of multiple select boxes (not
29 * applicable when $multiple is FALSE)
31 * @copyright 1999-2020 The SquirrelMail Project Team
32 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
34 * @package squirrelmail
35 * @subpackage templates
39 // retrieve the template vars
44 if (isset($aAttribs['id'])) {
45 $label_open = '<label for="' . $aAttribs['id'] . '">';
46 $label_close = '</label>';
53 echo '<select name="' . $name . ($multiple ? '[]" multiple="multiple" size="' . $size . '"' : '"');
54 foreach ($aAttribs as $key => $value) {
55 echo ' ' . $key . (is_null($value) ? '' : '="' . $value . '"');
60 foreach ($aValues as $key => $value) {
61 if (!$bUsekeys) $key = $value;
62 echo '<option value="' . $key . '"';
64 // multiple select lists have possibly more than one default selection
67 foreach ($default as $def) {
68 if ((string)$def == (string)$key) {
69 echo ' selected="selected"';
75 // single select widget only needs to check for one default value
76 // (we could use the same code above, but we do this here to increase
77 // efficency and performance)
79 else if ((string)$default[0] == (string)$key)
80 echo ' selected="selected"';
82 echo '>' . $label_open . $value . $label_close . "</option>\n";