| 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 | * + $name - The name of the select input |
| 10 | * + $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 | * + $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 | * + $default - The option value that should be selected by default |
| 18 | * + $aAttribs - Any extra attributes: an associative array, where |
| 19 | * keys are attribute names, and values (which are |
| 20 | * optional and might be null) should be placed |
| 21 | * in double quotes as attribute values (optional; |
| 22 | * may not be present) |
| 23 | * |
| 24 | * @copyright © 1999-2006 The SquirrelMail Project Team |
| 25 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 26 | * @version $Id$ |
| 27 | * @package squirrelmail |
| 28 | * @subpackage templates |
| 29 | */ |
| 30 | |
| 31 | |
| 32 | // retrieve the template vars |
| 33 | // |
| 34 | extract($t); |
| 35 | |
| 36 | |
| 37 | if (isset($aAttribs['id'])) { |
| 38 | $label_open = '<label for="' . $aAttribs['id'] . '">'; |
| 39 | $label_close = '</label>'; |
| 40 | } else { |
| 41 | $label_open = ''; |
| 42 | $label_close = ''; |
| 43 | } |
| 44 | |
| 45 | |
| 46 | echo '<select name="' . $name . '"'; |
| 47 | foreach ($aAttribs as $key => $value) { |
| 48 | echo ' ' . $key . (is_null($value) ? '' : '="' . $value . '"'); |
| 49 | } |
| 50 | echo ">\n"; |
| 51 | |
| 52 | |
| 53 | foreach ($aValues as $key => $value) { |
| 54 | if (!$bUsekeys) $key = $value; |
| 55 | echo '<option value="' . $key . '"' |
| 56 | . (($default == $key) ? ' selected="selected"' : '') |
| 57 | . '>' . $label_open . $value . $label_close . "</option>\n"; |
| 58 | } |
| 59 | echo "</select>\n"; |
| 60 | |
| 61 | |