Happy New Year
[squirrelmail.git] / templates / default / edit_list_associative_widget_list_style.tpl
CommitLineData
282f8e7c 1<?php
2
3/**
4 * edit_list_associative_widget_list_style.tpl
5 *
6 * Template for constructing an associative 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 * 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
32FIXME: 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
40 *
353d074a 41 * @copyright 1999-2018 The SquirrelMail Project Team
282f8e7c 42 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
43 * @version $Id$
44 * @package squirrelmail
45 * @subpackage templates
46 */
47
48
49// retrieve the template vars
50//
51extract($t);
52
53
54// Construct the add key/value inputs
55//
56echo '<table class="table2" cellspacing="0"><tr><td>';
57if ($use_input_widget) {
58//FIXME implement poss_key_folders here? probably not worth the trouble, is there a use case?
59 echo _("Add") . '&nbsp;' . $input_key_widget . ' ';
60
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">';
64
65 // Add each possible value to the select list
66 foreach ($poss_value_folders as $real_value => $disp_value) {
67
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);
71
72 } else {
73 // Start the next new option string
74 $new_option = '<option value="' . sm_encode_html_special_chars($real_value) . '"';
75
76 // Add the display value to our option string
77 $new_option .= '>' . sm_encode_html_special_chars($disp_value) . "</option>\n";
78 }
79 // And add the new option string to our select tag
80 echo $new_option;
81 }
82 // Close the select tag and return our happy result
83 echo '</select>';
84 }
85 else
86 echo $input_value_widget . '<br />';
87}
5e441742 88if (!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 />';
282f8e7c 90
91
92// Construct the select input showing all current values in the list
93//
94echo '<table class="table_messageList" cellspacing="0">';
95
96$class = 'even';
97$index = 0;
98
99if (is_array($current_value))
100 $selected = $current_value;
101else
102 $selected = array($current_value);
103
104foreach ($possible_values as $key => $value) {
105
106 if ($class == 'even') $class = 'odd';
107 else $class = 'even';
108
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);
111
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
115 //
116 foreach ($selected as $default) {
117 if ((string)$default == (string)$key) {
118 echo '" checked="checked';
119 break;
120 }
121 }
122
123 echo '"></td>'
124 . '<td><label for="' . $name . '_list_item_' . urlencode($key) . '">' . sm_encode_html_special_chars($key) . ' = ';
125
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('&nbsp;', '', $folder_info['formatted']));
132 break 2;
133 }
134 }
135 }
136 else
137 if ($value == $disp_value) {
138 echo sm_encode_html_special_chars($disp_value);
139 break;
140 }
141 }
142 }
143 else
144 echo sm_encode_html_special_chars($value);
145
146 echo '</label></td>'
147 . "</tr>\n";
148
149}
150
151echo '</table>';
152
153
154// Construct the delete input
155//
156if (!empty($possible_values) && $use_delete_widget)
157 echo $checkbox_widget . '&nbsp;<label for="delete_' . $name . '">'
158 . _("Delete Selected") . '</label>';
159
160
161echo '</td></tr></table>';