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