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