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