Fix to show current language rather than always Default
[squirrelmail.git] / src / options_display.php
1 <?php
2
3 /**
4 * options_display.php
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Displays all optinos about display preferences
10 *
11 * $Id$
12 */
13
14 /* Define the group constants for the display options page. */
15 define('SMOPT_GRP_GENERAL', 0);
16 define('SMOPT_GRP_MAILBOX', 1);
17 define('SMOPT_GRP_MESSAGE', 2);
18
19 /* Define the optpage load function for the display options page. */
20 function load_optpage_data_display() {
21 global $theme, $language, $languages, $js_autodetect_results,
22 $default_use_mdn, $squirrelmail_language;
23
24 /* Build a simple array into which we will build options. */
25 $optgrps = array();
26 $optvals = array();
27
28 /******************************************************/
29 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
30 /******************************************************/
31
32 /*** Load the General Options into the array ***/
33 $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options");
34 $optvals[SMOPT_GRP_GENERAL] = array();
35
36 /* Load the theme option. */
37 $theme_values = array();
38 foreach ($theme as $theme_key => $theme_attributes) {
39 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
40 }
41 ksort($theme_values);
42 $theme_values = array_flip($theme_values);
43 $optvals[SMOPT_GRP_GENERAL][] = array(
44 'name' => 'chosen_theme',
45 'caption' => _("Theme"),
46 'type' => SMOPT_TYPE_STRLIST,
47 'refresh' => SMOPT_REFRESH_ALL,
48 'posvals' => $theme_values,
49 'save' => 'save_option_theme'
50 );
51
52 $css_values = array( 'none' => _("Default" ) );
53 $handle=opendir('../themes/css/');
54 while ($file = readdir($handle) ) {
55 if ( substr( $file, -4 ) == '.css' ) {
56 $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
57 }
58 }
59 closedir($handle);
60
61 if ( count( $css_values > 1 ) ) {
62
63 $optvals[SMOPT_GRP_GENERAL][] = array(
64 'name' => 'custom_css',
65 'caption' => _("Custom Stylesheet"),
66 'type' => SMOPT_TYPE_STRLIST,
67 'refresh' => SMOPT_REFRESH_ALL,
68 'posvals' => $css_values
69 );
70
71 }
72
73 $language_values = array();
74 foreach ($languages as $lang_key => $lang_attributes) {
75 if (isset($lang_attributes['NAME'])) {
76 $language_values[$lang_key] = $lang_attributes['NAME'];
77 }
78 }
79 asort($language_values);
80 $language_values =
81 array_merge(array('' => _("Default")), $language_values);
82 $language = $squirrelmail_language;
83 $optvals[SMOPT_GRP_GENERAL][] = array(
84 'name' => 'language',
85 'caption' => _("Language"),
86 'type' => SMOPT_TYPE_STRLIST,
87 'refresh' => SMOPT_REFRESH_ALL,
88 'posvals' => $language_values
89 );
90
91 /* Set values for the "use javascript" option. */
92 $optvals[SMOPT_GRP_GENERAL][] = array(
93 'name' => 'javascript_setting',
94 'caption' => _("Use Javascript"),
95 'type' => SMOPT_TYPE_STRLIST,
96 'refresh' => SMOPT_REFRESH_ALL,
97 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
98 SMPREF_JS_ON => _("Always"),
99 SMPREF_JS_OFF => _("Never"))
100 );
101
102 $js_autodetect_script =
103 "<SCRIPT LANGUAGE=\"JavaScript\"><!--\n".
104 "document.forms[0].new_js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
105 "// --></SCRIPT>\n";
106 $js_autodetect_results = SMPREF_JS_OFF;
107 $optvals[SMOPT_GRP_GENERAL][] = array(
108 'name' => 'js_autodetect_results',
109 'caption' => '',
110 'type' => SMOPT_TYPE_HIDDEN,
111 'refresh' => SMOPT_REFRESH_NONE,
112 'script' => $js_autodetect_script,
113 'save' => 'save_option_javascript_autodetect'
114 );
115
116 /*** Load the General Options into the array ***/
117 $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
118 $optvals[SMOPT_GRP_MAILBOX] = array();
119
120 $optvals[SMOPT_GRP_MAILBOX][] = array(
121 'name' => 'show_num',
122 'caption' => _("Number of Messages to Index"),
123 'type' => SMOPT_TYPE_INTEGER,
124 'refresh' => SMOPT_REFRESH_NONE,
125 'size' => SMOPT_SIZE_TINY
126 );
127
128 $optvals[SMOPT_GRP_MAILBOX][] = array(
129 'name' => 'alt_index_colors',
130 'caption' => _("Enable Alternating Row Colors"),
131 'type' => SMOPT_TYPE_BOOLEAN,
132 'refresh' => SMOPT_REFRESH_NONE
133 );
134
135 $optvals[SMOPT_GRP_MAILBOX][] = array(
136 'name' => 'page_selector',
137 'caption' => _("Enable Page Selector"),
138 'type' => SMOPT_TYPE_BOOLEAN,
139 'refresh' => SMOPT_REFRESH_NONE
140 );
141
142 $optvals[SMOPT_GRP_MAILBOX][] = array(
143 'name' => 'page_selector_max',
144 'caption' => _("Maximum Number of Pages to Show"),
145 'type' => SMOPT_TYPE_INTEGER,
146 'refresh' => SMOPT_REFRESH_NONE,
147 'size' => SMOPT_SIZE_TINY
148 );
149
150 /*** Load the General Options into the array ***/
151 $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display and Composition");
152 $optvals[SMOPT_GRP_MESSAGE] = array();
153
154 $optvals[SMOPT_GRP_MESSAGE][] = array(
155 'name' => 'wrap_at',
156 'caption' => _("Wrap Incoming Text At"),
157 'type' => SMOPT_TYPE_INTEGER,
158 'refresh' => SMOPT_REFRESH_NONE,
159 'size' => SMOPT_SIZE_TINY
160 );
161
162 $optvals[SMOPT_GRP_MESSAGE][] = array(
163 'name' => 'editor_size',
164 'caption' => _("Size of Editor Window"),
165 'type' => SMOPT_TYPE_INTEGER,
166 'refresh' => SMOPT_REFRESH_NONE,
167 'size' => SMOPT_SIZE_TINY
168 );
169
170 $optvals[SMOPT_GRP_MESSAGE][] = array(
171 'name' => 'location_of_buttons',
172 'caption' => _("Location of Buttons when Composing"),
173 'type' => SMOPT_TYPE_STRLIST,
174 'refresh' => SMOPT_REFRESH_NONE,
175 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
176 SMPREF_LOC_BETWEEN => _("Between headers and message body"),
177 SMPREF_LOC_BOTTOM => _("After message body"))
178 );
179
180 $optvals[SMOPT_GRP_MESSAGE][] = array(
181 'name' => 'use_javascript_addr_book',
182 'caption' => _("Addressbook Display Format"),
183 'type' => SMOPT_TYPE_STRLIST,
184 'refresh' => SMOPT_REFRESH_NONE,
185 'posvals' => array('1' => _("Javascript"),
186 '0' => _("HTML"))
187 );
188
189 $optvals[SMOPT_GRP_MESSAGE][] = array(
190 'name' => 'show_html_default',
191 'caption' => _("Show HTML Version by Default"),
192 'type' => SMOPT_TYPE_BOOLEAN,
193 'refresh' => SMOPT_REFRESH_NONE
194 );
195
196 $optvals[SMOPT_GRP_MESSAGE][] = array(
197 'name' => 'include_self_reply_all',
198 'caption' => _("Include Me in CC when I Reply All"),
199 'type' => SMOPT_TYPE_BOOLEAN,
200 'refresh' => SMOPT_REFRESH_NONE
201 );
202
203 $optvals[SMOPT_GRP_MESSAGE][] = array(
204 'name' => 'show_xmailer_default',
205 'caption' => _("Enable Mailer Display"),
206 'type' => SMOPT_TYPE_BOOLEAN,
207 'refresh' => SMOPT_REFRESH_NONE
208 );
209
210 $optvals[SMOPT_GRP_MESSAGE][] = array(
211 'name' => 'attachment_common_show_images',
212 'caption' => _("Display Attached Images with Message"),
213 'type' => SMOPT_TYPE_BOOLEAN,
214 'refresh' => SMOPT_REFRESH_NONE
215 );
216
217 $optvals[SMOPT_GRP_MESSAGE][] = array(
218 'name' => 'pf_subtle_link',
219 'caption' => _("Enable Subtle Printer Friendly Link"),
220 'type' => SMOPT_TYPE_BOOLEAN,
221 'refresh' => SMOPT_REFRESH_NONE
222 );
223
224 $optvals[SMOPT_GRP_MESSAGE][] = array(
225 'name' => 'pf_cleandisplay',
226 'caption' => _("Enable Printer Friendly Clean Display"),
227 'type' => SMOPT_TYPE_BOOLEAN,
228 'refresh' => SMOPT_REFRESH_NONE
229 );
230 if ($default_use_mdn) {
231 $optvals[SMOPT_GRP_MESSAGE][] = array(
232 'name' => 'mdn_user_support',
233 'caption' => _("Enable request/confirm reading"),
234 'type' => SMOPT_TYPE_BOOLEAN,
235 'refresh' => SMOPT_REFRESH_NONE
236 );
237 }
238 $optvals[SMOPT_GRP_MESSAGE][] = array(
239 'name' => 'compose_new_win',
240 'caption' => _("Always compose in a new window"),
241 'type' => SMOPT_TYPE_BOOLEAN,
242 'refresh' => SMOPT_REFRESH_ALL
243 );
244 $optvals[SMOPT_GRP_MESSAGE][] = array(
245 'name' => 'sig_first',
246 'caption' => _("Append signature before reply/forward text"),
247 'type' => SMOPT_TYPE_BOOLEAN,
248 'refresh' => SMOPT_REFRESH_NONE
249 );
250 $optvals[SMOPT_GRP_MESSAGE][] = array(
251 'name' => 'internal_date_sort',
252 'caption' => _("Use receive date for sort"),
253 'type' => SMOPT_TYPE_BOOLEAN,
254 'refresh' => SMOPT_REFRESH_ALL
255 );
256 /* Assemble all this together and return it as our result. */
257 $result = array(
258 'grps' => $optgrps,
259 'vals' => $optvals
260 );
261 return ($result);
262 }
263
264 /******************************************************************/
265 /** Define any specialized save functions for this option page. ***/
266 /******************************************************************/
267
268 function save_option_theme($option) {
269 global $theme;
270
271 /* Do checking to make sure $new_theme is in the array. */
272 $theme_in_array = false;
273 for ($i = 0; $i < count($theme); ++$i) {
274 if ($theme[$i]['PATH'] == $option->new_value) {
275 $theme_in_array = true;
276 break;
277 }
278 }
279
280 if (!$theme_in_array) {
281 $option->new_value = '';
282 }
283
284 /* Save the option like normal. */
285 save_option($option);
286 }
287
288 function save_option_javascript_autodetect($option) {
289 global $data_dir, $username, $new_javascript_setting;
290
291 /* Set javascript either on or off. */
292 if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
293 if ($option->new_value == SMPREF_JS_ON) {
294 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON);
295 } else {
296 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
297 }
298 } else {
299 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
300 }
301 }
302
303 ?>