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