Allow options to use HTML in trailing text
[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 *
22387c8d 41 * @copyright 1999-2017 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}
88
89
90// Construct the select input showing all current values in the list
91//
92echo '<table class="table_messageList" cellspacing="0">';
93
94$class = 'even';
95$index = 0;
96
97if (is_array($current_value))
98 $selected = $current_value;
99else
100 $selected = array($current_value);
101
102foreach ($possible_values as $key => $value) {
103
104 if ($class == 'even') $class = 'odd';
105 else $class = 'even';
106
107 echo '<tr class="' . $class . '">'
108 . '<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);
109
110 // having a selected item in the edit list doesn't have
111 // any meaning, but maybe someone will think of a way to
112 // use it, so we might as well put the code in
113 //
114 foreach ($selected as $default) {
115 if ((string)$default == (string)$key) {
116 echo '" checked="checked';
117 break;
118 }
119 }
120
121 echo '"></td>'
122 . '<td><label for="' . $name . '_list_item_' . urlencode($key) . '">' . sm_encode_html_special_chars($key) . ' = ';
123
124 if ($poss_value_folders) {
125 foreach ($poss_value_folders as $real_value => $disp_value) {
126 if ( is_array($disp_value) ) {
127 foreach ($disp_value as $folder_info) {
128 if ($value == $folder_info['unformatted']) {
129 echo sm_encode_html_special_chars(str_replace('&nbsp;', '', $folder_info['formatted']));
130 break 2;
131 }
132 }
133 }
134 else
135 if ($value == $disp_value) {
136 echo sm_encode_html_special_chars($disp_value);
137 break;
138 }
139 }
140 }
141 else
142 echo sm_encode_html_special_chars($value);
143
144 echo '</label></td>'
145 . "</tr>\n";
146
147}
148
149echo '</table>';
150
151
152// Construct the delete input
153//
154if (!empty($possible_values) && $use_delete_widget)
155 echo $checkbox_widget . '&nbsp;<label for="delete_' . $name . '">'
156 . _("Delete Selected") . '</label>';
157
158
159echo '</td></tr></table>';