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