| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * edit_list_widget_list_style.tpl |
| 5 | * |
| 6 | * Template for constructing an edit list using a list-format layout. |
| 7 | * |
| 8 | * The following variables are available in this template: |
| 9 | * |
| 10 | * string $name The name of the edit list |
| 11 | * string $input_widget A preconstructed input text box used |
| 12 | * for adding new elements to the edit list |
| 13 | * boolean $use_input_widget Whether or not to present the $input_widget |
| 14 | * boolean $use_delete_widget Whether or not to present the $checkbox_widget |
| 15 | * string $select_widget A preconstructed select widget containing |
| 16 | * all the elements in the list |
| 17 | * string $checkbox_widget A preconstructed checkbox used for deleting |
| 18 | * elements from the edit list |
| 19 | * string $trailing_text Any text given by the caller to be displayed |
| 20 | * after the edit list input |
| 21 | * array $possible_values The original list of options in the edit list, |
| 22 | * for use constructing layouts alternative to |
| 23 | * the select widget |
| 24 | * mixed $current_value The currently selected value(s) |
| 25 | * |
| 26 | * @copyright 1999-2024 The SquirrelMail Project Team |
| 27 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 28 | * @version $Id$ |
| 29 | * @package squirrelmail |
| 30 | * @subpackage templates |
| 31 | */ |
| 32 | |
| 33 | |
| 34 | // retrieve the template vars |
| 35 | // |
| 36 | extract($t); |
| 37 | |
| 38 | |
| 39 | echo '<table class="table2" cellspacing="0"><tr><td>'; |
| 40 | |
| 41 | if ($use_input_widget) |
| 42 | echo _("Add") . ' ' . $input_widget . '<br />'; |
| 43 | if (!empty($trailing_text)) |
| 44 | echo ($trailing_text_small ? '<small>' : '') . ($trailing_text_is_html ? $trailing_text : sm_encode_html_special_chars($trailing_text)) . ($trailing_text_small ? '</small>' : '') . '<br />'; |
| 45 | |
| 46 | echo '<table class="table_messageList" cellspacing="0">'; |
| 47 | |
| 48 | $class = 'even'; |
| 49 | $index = 0; |
| 50 | |
| 51 | if (is_array($current_value)) |
| 52 | $selected = $current_value; |
| 53 | else |
| 54 | $selected = array($current_value); |
| 55 | |
| 56 | foreach ($possible_values as $key => $value) { |
| 57 | |
| 58 | if ($class == 'even') $class = 'odd'; |
| 59 | else $class = 'even'; |
| 60 | |
| 61 | echo '<tr class="' . $class . '">' |
| 62 | . '<td class="col_check" style="width:1%"><input type="checkbox" name="new_' . $name . '[' . ($index++) . ']" id="' . $name . '_list_item_' . $key . '" value="' . $value; |
| 63 | |
| 64 | // having a selected item in the edit list doesn't have |
| 65 | // any meaning, but maybe someone will think of a way to |
| 66 | // use it, so we might as well put the code in |
| 67 | // |
| 68 | foreach ($selected as $default) { |
| 69 | if ((string)$default == (string)$value) { |
| 70 | echo '" checked="checked'; |
| 71 | break; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | echo '"></td>' |
| 76 | . '<td><label for="' . $name . '_list_item_' . $key . '">' . $value . '</label></td>' |
| 77 | . "</tr>\n"; |
| 78 | |
| 79 | } |
| 80 | |
| 81 | echo '</table>'; |
| 82 | |
| 83 | if (!empty($possible_values) && $use_delete_widget) |
| 84 | echo $checkbox_widget . ' <label for="delete_' . $name . '">' |
| 85 | . _("Delete Selected") . '</label>'; |
| 86 | |
| 87 | echo '</td></tr></table>'; |