4 * edit_list_associative_widget_list_style.tpl
6 * Template for constructing an associative edit list using a list-format layout.
8 * The following variables are available in this template:
10 * string $name The name of the edit list
11 * mixed $current_value The currently selected value(s)
12 * array $possible_values The original list of options in the edit list
13 * array $poss_value_folders When not empty, contains a list of names
14 * to be used to populate a drop-down selection
15 * list for the value input (instead of the
16 * $input_value_widget textual input). If any
17 * of the values is an array, it is assumed to
18 * be an IMAP folder list in the format given
19 * by sqimap_mailbox_list()
20 * string $folder_filter Controls the folders listed by
21 * $poss_value_folders. See $flag argument in
22 * the sqimap_mailbox_option_list() function
23 * boolean $use_input_widget Whether or not to present the key/value inputs
24 * boolean $use_delete_widget Whether or not to present the $checkbox_widget
25 * string $checkbox_widget A preconstructed checkbox used for deleting
26 * elements from the edit list
27 * string $input_key_widget A preconstructed input text box used
28 * for adding new element keys to the edit list
29 * string $input_value_widget A preconstructed input text box used
30 * for adding new element values to the edit list
31 * int $select_height The size of the edit list select widget
32 FIXME: which inputs to use $aAttribs for? currently only the <select> tag
33 * array $aAttribs Any extra attributes: an associative array,
34 * where keys are attribute names, and values
35 * (which are optional and might be null)
36 * should be placed in double quotes as attribute
37 * values (optional; may not be present)
38 * string $trailing_text Any text given by the caller to be displayed
39 * after the edit list input
41 * @copyright 1999-2017 The SquirrelMail Project Team
42 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
44 * @package squirrelmail
45 * @subpackage templates
49 // retrieve the template vars
54 // Construct the add key/value inputs
56 echo '<table class="table2" cellspacing="0"><tr><td>';
57 if ($use_input_widget) {
58 //FIXME implement poss_key_folders here? probably not worth the trouble, is there a use case?
59 echo _("Add") . ' ' . $input_key_widget . ' ';
61 // FIXME: shall we allow these "poss value folders" (folder list selection for edit list values) for NON-Associative EDIT_LIST widgets?
62 if ($poss_value_folders) {
63 echo '<select name="add_' . $name . '_value">';
65 // Add each possible value to the select list
66 foreach ($poss_value_folders as $real_value => $disp_value) {
68 if ( is_array($disp_value) ) {
69 // For folder list, we passed in the array of boxes
70 $new_option = sqimap_mailbox_option_list(0, 0, 0, $disp_value, $folder_filter);
73 // Start the next new option string
74 $new_option = '<option value="' . sm_encode_html_special_chars($real_value) . '"';
76 // Add the display value to our option string
77 $new_option .= '>' . sm_encode_html_special_chars($disp_value) . "</option>\n";
79 // And add the new option string to our select tag
82 // Close the select tag and return our happy result
86 echo $input_value_widget . '<br />';
88 if (!empty($trailing_text))
89 echo ($trailing_text_small ? '<small>' : '') . ($trailing_text_is_html ? $trailing_text : sm_encode_html_special_chars($trailing_text)) . ($trailing_text_small ? '</small>' : '') . '<br />';
92 // Construct the select input showing all current values in the list
94 echo '<table class="table_messageList" cellspacing="0">';
99 if (is_array($current_value))
100 $selected = $current_value;
102 $selected = array($current_value);
104 foreach ($possible_values as $key => $value) {
106 if ($class == 'even') $class = 'odd';
107 else $class = 'even';
109 echo '<tr class="' . $class . '">'
110 . '<td class="col_check" style="width:1%"><input type="checkbox" name="new_' . $name . '[' . urlencode($key) . ']" id="' . $name . '_list_item_' . urlencode($key) . '" value="' . sm_encode_html_special_chars($value);
112 // having a selected item in the edit list doesn't have
113 // any meaning, but maybe someone will think of a way to
114 // use it, so we might as well put the code in
116 foreach ($selected as $default) {
117 if ((string)$default == (string)$key) {
118 echo '" checked="checked';
124 . '<td><label for="' . $name . '_list_item_' . urlencode($key) . '">' . sm_encode_html_special_chars($key) . ' = ';
126 if ($poss_value_folders) {
127 foreach ($poss_value_folders as $real_value => $disp_value) {
128 if ( is_array($disp_value) ) {
129 foreach ($disp_value as $folder_info) {
130 if ($value == $folder_info['unformatted']) {
131 echo sm_encode_html_special_chars(str_replace(' ', '', $folder_info['formatted']));
137 if ($value == $disp_value) {
138 echo sm_encode_html_special_chars($disp_value);
144 echo sm_encode_html_special_chars($value);
154 // Construct the delete input
156 if (!empty($possible_values) && $use_delete_widget)
157 echo $checkbox_widget . ' <label for="delete_' . $name . '">'
158 . _("Delete Selected") . '</label>';
161 echo '</td></tr></table>';