Add "alreadyFocused" functionality to login page
[squirrelmail.git] / templates / default / select.tpl
1 <?php
2
3 /**
4 * select.tpl
5 *
6 * Template for constructing a select input tag.
7 *
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
13 * as the option text
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
18 * shown.
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
22 * list)
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;
27 * may not be present)
28 *
29 * @copyright &copy; 1999-2008 The SquirrelMail Project Team
30 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
31 * @version $Id$
32 * @package squirrelmail
33 * @subpackage templates
34 */
35
36
37 // retrieve the template vars
38 //
39 extract($t);
40
41
42 if (isset($aAttribs['id'])) {
43 $label_open = '<label for="' . $aAttribs['id'] . '">';
44 $label_close = '</label>';
45 } else {
46 $label_open = '';
47 $label_close = '';
48 }
49
50
51 echo '<select name="' . $name . ($multiple ? '[]" multiple="multiple" size="3"' : '"');
52 foreach ($aAttribs as $key => $value) {
53 echo ' ' . $key . (is_null($value) ? '' : '="' . $value . '"');
54 }
55 echo ">\n";
56
57
58 foreach ($aValues as $key => $value) {
59 if (!$bUsekeys) $key = $value;
60 echo '<option value="' . $key . '"';
61
62 // multiple select lists have possibly more than one default selection
63 //
64 if ($multiple) {
65 foreach ($default as $def) {
66 if ((string)$def == (string)$key) {
67 echo ' selected="selected"';
68 break;
69 }
70 }
71 }
72
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)
76 //
77 else if ((string)$default[0] == (string)$key)
78 echo ' selected="selected"';
79
80 echo '>' . $label_open . $value . $label_close . "</option>\n";
81 }
82 echo "</select>\n";
83
84