Made compose textarea height configurable
[squirrelmail.git] / include / options / display.php
1 <?php
2
3 /**
4 * options_display.php
5 *
6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
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 * @package squirrelmail
13 */
14
15 /** Define the group constants for the display options page. */
16 define('SMOPT_GRP_GENERAL', 0);
17 define('SMOPT_GRP_MAILBOX', 1);
18 define('SMOPT_GRP_MESSAGE', 2);
19
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 */
33 function load_optpage_data_display() {
34 global $theme, $language, $languages, $js_autodetect_results,
35 $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
36 $optmode, $show_alternative_names, $available_languages;
37
38 /* Build a simple array into which we will build options. */
39 $optgrps = array();
40 $optvals = array();
41
42 /******************************************************/
43 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
44 /******************************************************/
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. */
51 $theme_values = array();
52 foreach ($theme as $theme_key => $theme_attributes) {
53 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
54 }
55 ksort($theme_values);
56 $theme_values = array_flip($theme_values);
57 $optvals[SMOPT_GRP_GENERAL][] = array(
58 'name' => 'chosen_theme',
59 'caption' => _("Theme"),
60 'type' => SMOPT_TYPE_STRLIST,
61 'refresh' => SMOPT_REFRESH_ALL,
62 'posvals' => $theme_values,
63 'save' => 'save_option_theme'
64 );
65
66 $css_values = array( 'none' => _("Default" ) );
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 );
71 }
72 }
73 closedir($handle);
74
75 if ( count( $css_values ) > 1 ) {
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 }
86
87 // config.php can be unupdated.
88 if (! isset($available_languages) || $available_languages=="" ) {
89 $available_languages="ALL"; }
90
91 $language_values = array();
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 }
116 }
117 asort($language_values);
118 $language_values =
119 array_merge(array('' => _("Default")), $language_values);
120 $language = $squirrelmail_language;
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 }
131
132 /* Set values for the "use javascript" option. */
133 $optvals[SMOPT_GRP_GENERAL][] = array(
134 'name' => 'javascript_setting',
135 'caption' => _("Use Javascript"),
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
143
144 if ($optmode != 'submit')
145 $onLoadScript = 'document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\'';
146 else
147 $onLoadScript = '';
148
149 $optvals[SMOPT_GRP_GENERAL][] = array(
150 'name' => 'js_autodetect_results',
151 'caption' => '',
152 'type' => SMOPT_TYPE_HIDDEN,
153 'refresh' => SMOPT_REFRESH_NONE,
154 //'post_script' => $js_autodetect_script,
155 'save' => 'save_option_javascript_autodetect'
156 );
157
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(
163 'name' => 'show_num',
164 'caption' => _("Number of Messages to Index"),
165 'type' => SMOPT_TYPE_INTEGER,
166 'refresh' => SMOPT_REFRESH_NONE,
167 'size' => SMOPT_SIZE_TINY
168 );
169
170 $optvals[SMOPT_GRP_MAILBOX][] = array(
171 'name' => 'alt_index_colors',
172 'caption' => _("Enable Alternating Row Colors"),
173 'type' => SMOPT_TYPE_BOOLEAN,
174 'refresh' => SMOPT_REFRESH_NONE
175 );
176
177 $optvals[SMOPT_GRP_MAILBOX][] = array(
178 'name' => 'page_selector',
179 'caption' => _("Enable Page Selector"),
180 'type' => SMOPT_TYPE_BOOLEAN,
181 'refresh' => SMOPT_REFRESH_NONE
182 );
183
184 $optvals[SMOPT_GRP_MAILBOX][] = array(
185 'name' => 'page_selector_max',
186 'caption' => _("Maximum Number of Pages to Show"),
187 'type' => SMOPT_TYPE_INTEGER,
188 'refresh' => SMOPT_REFRESH_NONE,
189 'size' => SMOPT_SIZE_TINY
190 );
191
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
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
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
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
223
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(
229 'name' => 'wrap_at',
230 'caption' => _("Wrap Incoming Text At"),
231 'type' => SMOPT_TYPE_INTEGER,
232 'refresh' => SMOPT_REFRESH_NONE,
233 'size' => SMOPT_SIZE_TINY
234 );
235
236 $optvals[SMOPT_GRP_MESSAGE][] = array(
237 'name' => 'editor_size',
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"),
247 'type' => SMOPT_TYPE_INTEGER,
248 'refresh' => SMOPT_REFRESH_NONE,
249 'size' => SMOPT_SIZE_TINY
250 );
251
252 $optvals[SMOPT_GRP_MESSAGE][] = array(
253 'name' => 'location_of_buttons',
254 'caption' => _("Location of Buttons when Composing"),
255 'type' => SMOPT_TYPE_STRLIST,
256 'refresh' => SMOPT_REFRESH_NONE,
257 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
258 SMPREF_LOC_BETWEEN => _("Between headers and message body"),
259 SMPREF_LOC_BOTTOM => _("After message body"))
260 );
261
262
263 $optvals[SMOPT_GRP_MESSAGE][] = array(
264 'name' => 'use_javascript_addr_book',
265 'caption' => _("Addressbook Display Format"),
266 'type' => SMOPT_TYPE_STRLIST,
267 'refresh' => SMOPT_REFRESH_NONE,
268 'posvals' => array('1' => _("Javascript"),
269 '0' => _("HTML"))
270 );
271
272 $optvals[SMOPT_GRP_MESSAGE][] = array(
273 'name' => 'show_html_default',
274 'caption' => _("Show HTML Version by Default"),
275 'type' => SMOPT_TYPE_BOOLEAN,
276 'refresh' => SMOPT_REFRESH_NONE
277 );
278
279 $optvals[SMOPT_GRP_MESSAGE][] = array(
280 'name' => 'enable_forward_as_attachment',
281 'caption' => _("Enable Forward as Attachment"),
282 'type' => SMOPT_TYPE_BOOLEAN,
283 'refresh' => SMOPT_REFRESH_NONE
284 );
285
286 $optvals[SMOPT_GRP_MESSAGE][] = array(
287 'name' => 'forward_cc',
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"),
296 'type' => SMOPT_TYPE_BOOLEAN,
297 'refresh' => SMOPT_REFRESH_NONE
298 );
299
300 $optvals[SMOPT_GRP_MESSAGE][] = array(
301 'name' => 'show_xmailer_default',
302 'caption' => _("Enable Mailer Display"),
303 'type' => SMOPT_TYPE_BOOLEAN,
304 'refresh' => SMOPT_REFRESH_NONE
305 );
306
307 $optvals[SMOPT_GRP_MESSAGE][] = array(
308 'name' => 'attachment_common_show_images',
309 'caption' => _("Display Attached Images with Message"),
310 'type' => SMOPT_TYPE_BOOLEAN,
311 'refresh' => SMOPT_REFRESH_NONE
312 );
313
314 $optvals[SMOPT_GRP_MESSAGE][] = array(
315 'name' => 'pf_cleandisplay',
316 'caption' => _("Enable Printer Friendly Clean Display"),
317 'type' => SMOPT_TYPE_BOOLEAN,
318 'refresh' => SMOPT_REFRESH_NONE
319 );
320
321 if ($default_use_mdn) {
322 $optvals[SMOPT_GRP_MESSAGE][] = array(
323 'name' => 'mdn_user_support',
324 'caption' => _("Enable Mail Delivery Notification"),
325 'type' => SMOPT_TYPE_BOOLEAN,
326 'refresh' => SMOPT_REFRESH_NONE
327 );
328 }
329
330 $optvals[SMOPT_GRP_MESSAGE][] = array(
331 'name' => 'compose_new_win',
332 'caption' => _("Compose Messages in New Window"),
333 'type' => SMOPT_TYPE_BOOLEAN,
334 'refresh' => SMOPT_REFRESH_ALL
335 );
336
337 $optvals[SMOPT_GRP_MESSAGE][] = array(
338 'name' => 'compose_width',
339 'caption' => _("Width of Compose Window"),
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',
347 'caption' => _("Height of Compose Window"),
348 'type' => SMOPT_TYPE_INTEGER,
349 'refresh' => SMOPT_REFRESH_ALL,
350 'size' => SMOPT_SIZE_TINY
351 );
352
353 $optvals[SMOPT_GRP_MESSAGE][] = array(
354 'name' => 'sig_first',
355 'caption' => _("Append Signature before Reply/Forward Text"),
356 'type' => SMOPT_TYPE_BOOLEAN,
357 'refresh' => SMOPT_REFRESH_NONE
358 );
359
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
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
377 $optvals[SMOPT_GRP_MESSAGE][] = array(
378 'name' => 'internal_date_sort',
379 'caption' => _("Enable Sort by of Receive Date"),
380 'type' => SMOPT_TYPE_BOOLEAN,
381 'refresh' => SMOPT_REFRESH_ALL
382 );
383 if ($allow_thread_sort == TRUE) {
384 $optvals[SMOPT_GRP_MESSAGE][] = array(
385 'name' => 'sort_by_ref',
386 'caption' => _("Enable Thread Sort by References Header"),
387 'type' => SMOPT_TYPE_BOOLEAN,
388 'refresh' => SMOPT_REFRESH_ALL
389 );
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
397 }
398 /* Assemble all this together and return it as our result. */
399 $result = array(
400 'grps' => $optgrps,
401 'vals' => $optvals,
402 'xtra' => $onLoadScript
403 );
404 return ($result);
405 }
406
407 /******************************************************************/
408 /** Define any specialized save functions for this option page. ***/
409 /******************************************************************/
410
411 /**
412 * This function saves a new theme setting.
413 * It updates the theme array.
414 */
415 function save_option_theme($option) {
416 global $theme;
417
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 }
430
431 /* Save the option like normal. */
432 save_option($option);
433 }
434
435 /**
436 * This function saves the javascript detection option.
437 */
438 function save_option_javascript_autodetect($option) {
439 global $data_dir, $username, $new_javascript_setting;
440
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 ?>