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