ef2ec2adceaa5e67b0764fc55ee3630b9f4afc02
[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 */
13
14 /* Define the group constants for the display options page. */
15 define('SMOPT_GRP_GENERAL', 0);
16 define('SMOPT_GRP_MAILBOX', 1);
17 define('SMOPT_GRP_MESSAGE', 2);
18
19 /* Define the optpage load function for the display options page. */
20 function load_optpage_data_display() {
21 global $theme, $language, $languages, $js_autodetect_results,
22 $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
23 $optmode, $show_alternative_names;
24
25 /* Build a simple array into which we will build options. */
26 $optgrps = array();
27 $optvals = array();
28
29 /******************************************************/
30 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
31 /******************************************************/
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. */
38 $theme_values = array();
39 foreach ($theme as $theme_key => $theme_attributes) {
40 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
41 }
42 ksort($theme_values);
43 $theme_values = array_flip($theme_values);
44 $optvals[SMOPT_GRP_GENERAL][] = array(
45 'name' => 'chosen_theme',
46 'caption' => _("Theme"),
47 'type' => SMOPT_TYPE_STRLIST,
48 'refresh' => SMOPT_REFRESH_ALL,
49 'posvals' => $theme_values,
50 'save' => 'save_option_theme'
51 );
52
53 $css_values = array( 'none' => _("Default" ) );
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 );
58 }
59 }
60 closedir($handle);
61
62 if ( count( $css_values ) > 1 ) {
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 }
73
74 $language_values = array();
75 foreach ($languages as $lang_key => $lang_attributes) {
76 if (isset($lang_attributes['NAME'])) {
77 $language_values[$lang_key] = $lang_attributes['NAME'];
78 if ( isset($show_alternative_names) &&
79 $show_alternative_names &&
80 isset($lang_attributes['ALTNAME']) ) {
81 $language_values[$lang_key] .= " / " . $lang_attributes['ALTNAME'];
82 }
83 }
84 }
85 asort($language_values);
86 $language_values =
87 array_merge(array('' => _("Default")), $language_values);
88 $language = $squirrelmail_language;
89 $optvals[SMOPT_GRP_GENERAL][] = array(
90 'name' => 'language',
91 'caption' => _("Language"),
92 'type' => SMOPT_TYPE_STRLIST,
93 'refresh' => SMOPT_REFRESH_ALL,
94 'posvals' => $language_values
95 );
96
97 /* Set values for the "use javascript" option. */
98 $optvals[SMOPT_GRP_GENERAL][] = array(
99 'name' => 'javascript_setting',
100 'caption' => _("Use Javascript"),
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
108
109 if ($optmode != 'submit')
110 $onLoadScript = 'document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\'';
111 else
112 $onLoadScript = '';
113
114 $optvals[SMOPT_GRP_GENERAL][] = array(
115 'name' => 'js_autodetect_results',
116 'caption' => '',
117 'type' => SMOPT_TYPE_HIDDEN,
118 'refresh' => SMOPT_REFRESH_NONE,
119 //'post_script' => $js_autodetect_script,
120 'save' => 'save_option_javascript_autodetect'
121 );
122
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(
128 'name' => 'show_num',
129 'caption' => _("Number of Messages to Index"),
130 'type' => SMOPT_TYPE_INTEGER,
131 'refresh' => SMOPT_REFRESH_NONE,
132 'size' => SMOPT_SIZE_TINY
133 );
134
135 $optvals[SMOPT_GRP_MAILBOX][] = array(
136 'name' => 'alt_index_colors',
137 'caption' => _("Enable Alternating Row Colors"),
138 'type' => SMOPT_TYPE_BOOLEAN,
139 'refresh' => SMOPT_REFRESH_NONE
140 );
141
142 $optvals[SMOPT_GRP_MAILBOX][] = array(
143 'name' => 'page_selector',
144 'caption' => _("Enable Page Selector"),
145 'type' => SMOPT_TYPE_BOOLEAN,
146 'refresh' => SMOPT_REFRESH_NONE
147 );
148
149 $optvals[SMOPT_GRP_MAILBOX][] = array(
150 'name' => 'page_selector_max',
151 'caption' => _("Maximum Number of Pages to Show"),
152 'type' => SMOPT_TYPE_INTEGER,
153 'refresh' => SMOPT_REFRESH_NONE,
154 'size' => SMOPT_SIZE_TINY
155 );
156
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
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
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
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
188
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(
194 'name' => 'wrap_at',
195 'caption' => _("Wrap Incoming Text At"),
196 'type' => SMOPT_TYPE_INTEGER,
197 'refresh' => SMOPT_REFRESH_NONE,
198 'size' => SMOPT_SIZE_TINY
199 );
200
201 $optvals[SMOPT_GRP_MESSAGE][] = array(
202 'name' => 'editor_size',
203 'caption' => _("Size of Editor Window"),
204 'type' => SMOPT_TYPE_INTEGER,
205 'refresh' => SMOPT_REFRESH_NONE,
206 'size' => SMOPT_SIZE_TINY
207 );
208
209 $optvals[SMOPT_GRP_MESSAGE][] = array(
210 'name' => 'location_of_buttons',
211 'caption' => _("Location of Buttons when Composing"),
212 'type' => SMOPT_TYPE_STRLIST,
213 'refresh' => SMOPT_REFRESH_NONE,
214 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
215 SMPREF_LOC_BETWEEN => _("Between headers and message body"),
216 SMPREF_LOC_BOTTOM => _("After message body"))
217 );
218
219
220 $optvals[SMOPT_GRP_MESSAGE][] = array(
221 'name' => 'use_javascript_addr_book',
222 'caption' => _("Addressbook Display Format"),
223 'type' => SMOPT_TYPE_STRLIST,
224 'refresh' => SMOPT_REFRESH_NONE,
225 'posvals' => array('1' => _("Javascript"),
226 '0' => _("HTML"))
227 );
228
229 $optvals[SMOPT_GRP_MESSAGE][] = array(
230 'name' => 'show_html_default',
231 'caption' => _("Show HTML Version by Default"),
232 'type' => SMOPT_TYPE_BOOLEAN,
233 'refresh' => SMOPT_REFRESH_NONE
234 );
235
236 $optvals[SMOPT_GRP_MESSAGE][] = array(
237 'name' => 'enable_forward_as_attachment',
238 'caption' => _("Enable Forward as Attachment"),
239 'type' => SMOPT_TYPE_BOOLEAN,
240 'refresh' => SMOPT_REFRESH_NONE
241 );
242
243 $optvals[SMOPT_GRP_MESSAGE][] = array(
244 'name' => 'forward_cc',
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"),
253 'type' => SMOPT_TYPE_BOOLEAN,
254 'refresh' => SMOPT_REFRESH_NONE
255 );
256
257 $optvals[SMOPT_GRP_MESSAGE][] = array(
258 'name' => 'show_xmailer_default',
259 'caption' => _("Enable Mailer Display"),
260 'type' => SMOPT_TYPE_BOOLEAN,
261 'refresh' => SMOPT_REFRESH_NONE
262 );
263
264 $optvals[SMOPT_GRP_MESSAGE][] = array(
265 'name' => 'attachment_common_show_images',
266 'caption' => _("Display Attached Images with Message"),
267 'type' => SMOPT_TYPE_BOOLEAN,
268 'refresh' => SMOPT_REFRESH_NONE
269 );
270
271 $optvals[SMOPT_GRP_MESSAGE][] = array(
272 'name' => 'pf_cleandisplay',
273 'caption' => _("Enable Printer Friendly Clean Display"),
274 'type' => SMOPT_TYPE_BOOLEAN,
275 'refresh' => SMOPT_REFRESH_NONE
276 );
277
278 if ($default_use_mdn) {
279 $optvals[SMOPT_GRP_MESSAGE][] = array(
280 'name' => 'mdn_user_support',
281 'caption' => _("Enable Mail Delivery Notification"),
282 'type' => SMOPT_TYPE_BOOLEAN,
283 'refresh' => SMOPT_REFRESH_NONE
284 );
285 }
286
287 $optvals[SMOPT_GRP_MESSAGE][] = array(
288 'name' => 'compose_new_win',
289 'caption' => _("Compose Messages in New Window"),
290 'type' => SMOPT_TYPE_BOOLEAN,
291 'refresh' => SMOPT_REFRESH_ALL
292 );
293
294 $optvals[SMOPT_GRP_MESSAGE][] = array(
295 'name' => 'compose_width',
296 'caption' => _("Width of Compose Window"),
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',
304 'caption' => _("Height of Compose Window"),
305 'type' => SMOPT_TYPE_INTEGER,
306 'refresh' => SMOPT_REFRESH_ALL,
307 'size' => SMOPT_SIZE_TINY
308 );
309
310 $optvals[SMOPT_GRP_MESSAGE][] = array(
311 'name' => 'sig_first',
312 'caption' => _("Append Signature before Reply/Forward Text"),
313 'type' => SMOPT_TYPE_BOOLEAN,
314 'refresh' => SMOPT_REFRESH_NONE
315 );
316
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
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
334 $optvals[SMOPT_GRP_MESSAGE][] = array(
335 'name' => 'internal_date_sort',
336 'caption' => _("Enable Sort by of Receive Date"),
337 'type' => SMOPT_TYPE_BOOLEAN,
338 'refresh' => SMOPT_REFRESH_ALL
339 );
340 if ($allow_thread_sort == TRUE) {
341 $optvals[SMOPT_GRP_MESSAGE][] = array(
342 'name' => 'sort_by_ref',
343 'caption' => _("Enable Thread Sort by References Header"),
344 'type' => SMOPT_TYPE_BOOLEAN,
345 'refresh' => SMOPT_REFRESH_ALL
346 );
347 }
348 /* Assemble all this together and return it as our result. */
349 $result = array(
350 'grps' => $optgrps,
351 'vals' => $optvals,
352 'xtra' => $onLoadScript
353 );
354 return ($result);
355 }
356
357 /******************************************************************/
358 /** Define any specialized save functions for this option page. ***/
359 /******************************************************************/
360
361 function save_option_theme($option) {
362 global $theme;
363
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 }
376
377 /* Save the option like normal. */
378 save_option($option);
379 }
380
381 function save_option_javascript_autodetect($option) {
382 global $data_dir, $username, $new_javascript_setting;
383
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 ?>