Adds language options in config.
[squirrelmail.git] / include / options / display.php
1 <?php
2
3 /**
4 * options_display.php
5 *
6 * Copyright (c) 1999-2003 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 $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
23 $optmode, $show_alternative_names, $available_languages;
24
25 /* Build a simple array into which we will build options. */
26 $optgrps = array();
27 $optvals = array();
28
29 /******************************************************/
30 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
31 /******************************************************/
32
33 /*** Load the General Options into the array ***/
34 $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options");
35 $optvals[SMOPT_GRP_GENERAL] = array();
36
37 /* Load the theme option. */
38 $theme_values = array();
39 foreach ($theme as $theme_key => $theme_attributes) {
40 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
41 }
42 ksort($theme_values);
43 $theme_values = array_flip($theme_values);
44 $optvals[SMOPT_GRP_GENERAL][] = array(
45 'name' => 'chosen_theme',
46 'caption' => _("Theme"),
47 'type' => SMOPT_TYPE_STRLIST,
48 'refresh' => SMOPT_REFRESH_ALL,
49 'posvals' => $theme_values,
50 'save' => 'save_option_theme'
51 );
52
53 $css_values = array( 'none' => _("Default" ) );
54 $handle=opendir('../themes/css/');
55 while ($file = readdir($handle) ) {
56 if ( substr( $file, -4 ) == '.css' ) {
57 $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
58 }
59 }
60 closedir($handle);
61
62 if ( count( $css_values ) > 1 ) {
63
64 $optvals[SMOPT_GRP_GENERAL][] = array(
65 'name' => 'custom_css',
66 'caption' => _("Custom Stylesheet"),
67 'type' => SMOPT_TYPE_STRLIST,
68 'refresh' => SMOPT_REFRESH_ALL,
69 'posvals' => $css_values
70 );
71
72 }
73
74 // config.php can be unupdated.
75 if (! isset($available_languages) || $available_languages=="" ) {
76 $available_languages="ALL"; }
77
78 $language_values = array();
79 if ( strtoupper($available_languages)=='ALL') {
80 foreach ($languages as $lang_key => $lang_attributes) {
81 if (isset($lang_attributes['NAME'])) {
82 $language_values[$lang_key] = $lang_attributes['NAME'];
83 if ( isset($show_alternative_names) &&
84 $show_alternative_names &&
85 isset($lang_attributes['ALTNAME']) ) {
86 $language_values[$lang_key] .= " / " . $lang_attributes['ALTNAME'];
87 }
88 }
89 }
90 } else if (strtoupper($available_languages)!='NONE') {
91 // admin can set list of available languages in config
92 $available_languages_array=explode (" ",$available_languages);
93 foreach ($available_languages_array as $lang_key ) {
94 if (isset($languages[$lang_key]['NAME'])) {
95 $language_values[$lang_key] = $languages[$lang_key]['NAME'];
96 if ( isset($show_alternative_names) &&
97 $show_alternative_names &&
98 isset($languages[$lang_key]['ALTNAME']) ) {
99 $language_values[$lang_key] .= " / " . $languages[$lang_key]['ALTNAME'];
100 }
101 }
102 }
103 }
104 asort($language_values);
105 $language_values =
106 array_merge(array('' => _("Default")), $language_values);
107 $language = $squirrelmail_language;
108 if (strtoupper($available_languages)!='NONE') {
109 // if set to 'none', interface will use only default language
110 $optvals[SMOPT_GRP_GENERAL][] = array(
111 'name' => 'language',
112 'caption' => _("Language"),
113 'type' => SMOPT_TYPE_STRLIST,
114 'refresh' => SMOPT_REFRESH_ALL,
115 'posvals' => $language_values
116 );
117 }
118
119 /* Set values for the "use javascript" option. */
120 $optvals[SMOPT_GRP_GENERAL][] = array(
121 'name' => 'javascript_setting',
122 'caption' => _("Use Javascript"),
123 'type' => SMOPT_TYPE_STRLIST,
124 'refresh' => SMOPT_REFRESH_ALL,
125 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
126 SMPREF_JS_ON => _("Always"),
127 SMPREF_JS_OFF => _("Never"))
128 );
129
130
131 if ($optmode != 'submit')
132 $onLoadScript = 'document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\'';
133 else
134 $onLoadScript = '';
135
136 $optvals[SMOPT_GRP_GENERAL][] = array(
137 'name' => 'js_autodetect_results',
138 'caption' => '',
139 'type' => SMOPT_TYPE_HIDDEN,
140 'refresh' => SMOPT_REFRESH_NONE,
141 //'post_script' => $js_autodetect_script,
142 'save' => 'save_option_javascript_autodetect'
143 );
144
145 /*** Load the General Options into the array ***/
146 $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
147 $optvals[SMOPT_GRP_MAILBOX] = array();
148
149 $optvals[SMOPT_GRP_MAILBOX][] = array(
150 'name' => 'show_num',
151 'caption' => _("Number of Messages to Index"),
152 'type' => SMOPT_TYPE_INTEGER,
153 'refresh' => SMOPT_REFRESH_NONE,
154 'size' => SMOPT_SIZE_TINY
155 );
156
157 $optvals[SMOPT_GRP_MAILBOX][] = array(
158 'name' => 'alt_index_colors',
159 'caption' => _("Enable Alternating Row Colors"),
160 'type' => SMOPT_TYPE_BOOLEAN,
161 'refresh' => SMOPT_REFRESH_NONE
162 );
163
164 $optvals[SMOPT_GRP_MAILBOX][] = array(
165 'name' => 'page_selector',
166 'caption' => _("Enable Page Selector"),
167 'type' => SMOPT_TYPE_BOOLEAN,
168 'refresh' => SMOPT_REFRESH_NONE
169 );
170
171 $optvals[SMOPT_GRP_MAILBOX][] = array(
172 'name' => 'page_selector_max',
173 'caption' => _("Maximum Number of Pages to Show"),
174 'type' => SMOPT_TYPE_INTEGER,
175 'refresh' => SMOPT_REFRESH_NONE,
176 'size' => SMOPT_SIZE_TINY
177 );
178
179 $optvals[SMOPT_GRP_MAILBOX][] = array(
180 'name' => 'show_full_date',
181 'caption' => _("Always Show Full Date"),
182 'type' => SMOPT_TYPE_BOOLEAN,
183 'refresh' => SMOPT_REFRESH_NONE
184 );
185
186 $optvals[SMOPT_GRP_MAILBOX][] = array(
187 'name' => 'truncate_sender',
188 'caption' => _("Length of From/To Field (0 for full)"),
189 'type' => SMOPT_TYPE_INTEGER,
190 'refresh' => SMOPT_REFRESH_NONE,
191 'size' => SMOPT_SIZE_TINY
192 );
193
194 $optvals[SMOPT_GRP_MAILBOX][] = array(
195 'name' => 'truncate_subject',
196 'caption' => _("Length of Subject Field (0 for full)"),
197 'type' => SMOPT_TYPE_INTEGER,
198 'refresh' => SMOPT_REFRESH_NONE,
199 'size' => SMOPT_SIZE_TINY
200 );
201
202 $optvals[SMOPT_GRP_MAILBOX][] = array(
203 'name' => 'show_recipient_instead',
204 'caption' => _("Show recipient name if the message is from your default identity"),
205 'type' => SMOPT_TYPE_BOOLEAN,
206 'refresh' => SMOPT_REFRESH_NONE,
207 'size' => SMOPT_SIZE_TINY
208 );
209
210
211 /*** Load the General Options into the array ***/
212 $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display and Composition");
213 $optvals[SMOPT_GRP_MESSAGE] = array();
214
215 $optvals[SMOPT_GRP_MESSAGE][] = array(
216 'name' => 'wrap_at',
217 'caption' => _("Wrap Incoming Text At"),
218 'type' => SMOPT_TYPE_INTEGER,
219 'refresh' => SMOPT_REFRESH_NONE,
220 'size' => SMOPT_SIZE_TINY
221 );
222
223 $optvals[SMOPT_GRP_MESSAGE][] = array(
224 'name' => 'editor_size',
225 'caption' => _("Size of Editor Window"),
226 'type' => SMOPT_TYPE_INTEGER,
227 'refresh' => SMOPT_REFRESH_NONE,
228 'size' => SMOPT_SIZE_TINY
229 );
230
231 $optvals[SMOPT_GRP_MESSAGE][] = array(
232 'name' => 'location_of_buttons',
233 'caption' => _("Location of Buttons when Composing"),
234 'type' => SMOPT_TYPE_STRLIST,
235 'refresh' => SMOPT_REFRESH_NONE,
236 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
237 SMPREF_LOC_BETWEEN => _("Between headers and message body"),
238 SMPREF_LOC_BOTTOM => _("After message body"))
239 );
240
241
242 $optvals[SMOPT_GRP_MESSAGE][] = array(
243 'name' => 'use_javascript_addr_book',
244 'caption' => _("Addressbook Display Format"),
245 'type' => SMOPT_TYPE_STRLIST,
246 'refresh' => SMOPT_REFRESH_NONE,
247 'posvals' => array('1' => _("Javascript"),
248 '0' => _("HTML"))
249 );
250
251 $optvals[SMOPT_GRP_MESSAGE][] = array(
252 'name' => 'show_html_default',
253 'caption' => _("Show HTML Version by Default"),
254 'type' => SMOPT_TYPE_BOOLEAN,
255 'refresh' => SMOPT_REFRESH_NONE
256 );
257
258 $optvals[SMOPT_GRP_MESSAGE][] = array(
259 'name' => 'enable_forward_as_attachment',
260 'caption' => _("Enable Forward as Attachment"),
261 'type' => SMOPT_TYPE_BOOLEAN,
262 'refresh' => SMOPT_REFRESH_NONE
263 );
264
265 $optvals[SMOPT_GRP_MESSAGE][] = array(
266 'name' => 'forward_cc',
267 'caption' => _("Include CCs when Forwarding Messages"),
268 'type' => SMOPT_TYPE_BOOLEAN,
269 'refresh' => SMOPT_REFRESH_NONE
270 );
271
272 $optvals[SMOPT_GRP_MESSAGE][] = array(
273 'name' => 'include_self_reply_all',
274 'caption' => _("Include Me in CC when I Reply All"),
275 'type' => SMOPT_TYPE_BOOLEAN,
276 'refresh' => SMOPT_REFRESH_NONE
277 );
278
279 $optvals[SMOPT_GRP_MESSAGE][] = array(
280 'name' => 'show_xmailer_default',
281 'caption' => _("Enable Mailer Display"),
282 'type' => SMOPT_TYPE_BOOLEAN,
283 'refresh' => SMOPT_REFRESH_NONE
284 );
285
286 $optvals[SMOPT_GRP_MESSAGE][] = array(
287 'name' => 'attachment_common_show_images',
288 'caption' => _("Display Attached Images with Message"),
289 'type' => SMOPT_TYPE_BOOLEAN,
290 'refresh' => SMOPT_REFRESH_NONE
291 );
292
293 $optvals[SMOPT_GRP_MESSAGE][] = array(
294 'name' => 'pf_cleandisplay',
295 'caption' => _("Enable Printer Friendly Clean Display"),
296 'type' => SMOPT_TYPE_BOOLEAN,
297 'refresh' => SMOPT_REFRESH_NONE
298 );
299
300 if ($default_use_mdn) {
301 $optvals[SMOPT_GRP_MESSAGE][] = array(
302 'name' => 'mdn_user_support',
303 'caption' => _("Enable Mail Delivery Notification"),
304 'type' => SMOPT_TYPE_BOOLEAN,
305 'refresh' => SMOPT_REFRESH_NONE
306 );
307 }
308
309 $optvals[SMOPT_GRP_MESSAGE][] = array(
310 'name' => 'compose_new_win',
311 'caption' => _("Compose Messages in New Window"),
312 'type' => SMOPT_TYPE_BOOLEAN,
313 'refresh' => SMOPT_REFRESH_ALL
314 );
315
316 $optvals[SMOPT_GRP_MESSAGE][] = array(
317 'name' => 'compose_width',
318 'caption' => _("Width of Compose Window"),
319 'type' => SMOPT_TYPE_INTEGER,
320 'refresh' => SMOPT_REFRESH_ALL,
321 'size' => SMOPT_SIZE_TINY
322 );
323
324 $optvals[SMOPT_GRP_MESSAGE][] = array(
325 'name' => 'compose_height',
326 'caption' => _("Height of Compose Window"),
327 'type' => SMOPT_TYPE_INTEGER,
328 'refresh' => SMOPT_REFRESH_ALL,
329 'size' => SMOPT_SIZE_TINY
330 );
331
332 $optvals[SMOPT_GRP_MESSAGE][] = array(
333 'name' => 'sig_first',
334 'caption' => _("Append Signature before Reply/Forward Text"),
335 'type' => SMOPT_TYPE_BOOLEAN,
336 'refresh' => SMOPT_REFRESH_NONE
337 );
338
339 $optvals[SMOPT_GRP_MESSAGE][] = array(
340 'name' => 'reply_focus',
341 'caption' => _("Cursor Position when Replying"),
342 'type' => SMOPT_TYPE_STRLIST,
343 'refresh' => SMOPT_REFRESH_NONE,
344 'posvals' => array('' => _("To: field"),
345 'focus' => _("Focus in body"),
346 'select' => _("Select body"))
347 );
348
349 $optvals[SMOPT_GRP_MESSAGE][] = array(
350 'name' => 'strip_sigs',
351 'caption' => _("Strip signature when replying"),
352 'type' => SMOPT_TYPE_BOOLEAN,
353 'refresh' => SMOPT_REFRESH_NONE
354 );
355
356 $optvals[SMOPT_GRP_MESSAGE][] = array(
357 'name' => 'internal_date_sort',
358 'caption' => _("Enable Sort by of Receive Date"),
359 'type' => SMOPT_TYPE_BOOLEAN,
360 'refresh' => SMOPT_REFRESH_ALL
361 );
362 if ($allow_thread_sort == TRUE) {
363 $optvals[SMOPT_GRP_MESSAGE][] = array(
364 'name' => 'sort_by_ref',
365 'caption' => _("Enable Thread Sort by References Header"),
366 'type' => SMOPT_TYPE_BOOLEAN,
367 'refresh' => SMOPT_REFRESH_ALL
368 );
369 }
370 /* Assemble all this together and return it as our result. */
371 $result = array(
372 'grps' => $optgrps,
373 'vals' => $optvals,
374 'xtra' => $onLoadScript
375 );
376 return ($result);
377 }
378
379 /******************************************************************/
380 /** Define any specialized save functions for this option page. ***/
381 /******************************************************************/
382
383 function save_option_theme($option) {
384 global $theme;
385
386 /* Do checking to make sure $new_theme is in the array. */
387 $theme_in_array = false;
388 for ($i = 0; $i < count($theme); ++$i) {
389 if ($theme[$i]['PATH'] == $option->new_value) {
390 $theme_in_array = true;
391 break;
392 }
393 }
394
395 if (!$theme_in_array) {
396 $option->new_value = '';
397 }
398
399 /* Save the option like normal. */
400 save_option($option);
401 }
402
403 function save_option_javascript_autodetect($option) {
404 global $data_dir, $username, $new_javascript_setting;
405
406 /* Set javascript either on or off. */
407 if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
408 if ($option->new_value == SMPREF_JS_ON) {
409 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON);
410 } else {
411 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
412 }
413 } else {
414 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
415 }
416 }
417
418 ?>