6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Displays all optinos about display preferences
12 * @package squirrelmail
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);
20 /* Define the optpage load function for the display options page. */
21 function load_optpage_data_display() {
22 global $theme, $language, $languages, $js_autodetect_results,
23 $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
24 $optmode, $show_alternative_names, $available_languages;
26 /* Build a simple array into which we will build options. */
30 /******************************************************/
31 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
32 /******************************************************/
34 /*** Load the General Options into the array ***/
35 $optgrps[SMOPT_GRP_GENERAL
] = _("General Display Options");
36 $optvals[SMOPT_GRP_GENERAL
] = array();
38 /* Load the theme option. */
39 $theme_values = array();
40 foreach ($theme as $theme_key => $theme_attributes) {
41 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
44 $theme_values = array_flip($theme_values);
45 $optvals[SMOPT_GRP_GENERAL
][] = array(
46 'name' => 'chosen_theme',
47 'caption' => _("Theme"),
48 'type' => SMOPT_TYPE_STRLIST
,
49 'refresh' => SMOPT_REFRESH_ALL
,
50 'posvals' => $theme_values,
51 'save' => 'save_option_theme'
54 $css_values = array( 'none' => _("Default" ) );
55 $handle=opendir('../themes/css/');
56 while ($file = readdir($handle) ) {
57 if ( substr( $file, -4 ) == '.css' ) {
58 $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
63 if ( count( $css_values ) > 1 ) {
65 $optvals[SMOPT_GRP_GENERAL
][] = array(
66 'name' => 'custom_css',
67 'caption' => _("Custom Stylesheet"),
68 'type' => SMOPT_TYPE_STRLIST
,
69 'refresh' => SMOPT_REFRESH_ALL
,
70 'posvals' => $css_values
75 // config.php can be unupdated.
76 if (! isset($available_languages) ||
$available_languages=="" ) {
77 $available_languages="ALL"; }
79 $language_values = array();
80 if ( strtoupper($available_languages)=='ALL') {
81 foreach ($languages as $lang_key => $lang_attributes) {
82 if (isset($lang_attributes['NAME'])) {
83 $language_values[$lang_key] = $lang_attributes['NAME'];
84 if ( isset($show_alternative_names) &&
85 $show_alternative_names &&
86 isset($lang_attributes['ALTNAME']) ) {
87 $language_values[$lang_key] .= " / " . $lang_attributes['ALTNAME'];
91 } else if (strtoupper($available_languages)!='NONE') {
92 // admin can set list of available languages in config
93 $available_languages_array=explode (" ",$available_languages);
94 foreach ($available_languages_array as $lang_key ) {
95 if (isset($languages[$lang_key]['NAME'])) {
96 $language_values[$lang_key] = $languages[$lang_key]['NAME'];
97 if ( isset($show_alternative_names) &&
98 $show_alternative_names &&
99 isset($languages[$lang_key]['ALTNAME']) ) {
100 $language_values[$lang_key] .= " / " . $languages[$lang_key]['ALTNAME'];
105 asort($language_values);
107 array_merge(array('' => _("Default")), $language_values);
108 $language = $squirrelmail_language;
109 if (strtoupper($available_languages)!='NONE') {
110 // if set to 'none', interface will use only default language
111 $optvals[SMOPT_GRP_GENERAL
][] = array(
112 'name' => 'language',
113 'caption' => _("Language"),
114 'type' => SMOPT_TYPE_STRLIST
,
115 'refresh' => SMOPT_REFRESH_ALL
,
116 'posvals' => $language_values
120 /* Set values for the "use javascript" option. */
121 $optvals[SMOPT_GRP_GENERAL
][] = array(
122 'name' => 'javascript_setting',
123 'caption' => _("Use Javascript"),
124 'type' => SMOPT_TYPE_STRLIST
,
125 'refresh' => SMOPT_REFRESH_ALL
,
126 'posvals' => array(SMPREF_JS_AUTODETECT
=> _("Autodetect"),
127 SMPREF_JS_ON
=> _("Always"),
128 SMPREF_JS_OFF
=> _("Never"))
132 if ($optmode != 'submit')
133 $onLoadScript = 'document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON
. '\'';
137 $optvals[SMOPT_GRP_GENERAL
][] = array(
138 'name' => 'js_autodetect_results',
140 'type' => SMOPT_TYPE_HIDDEN
,
141 'refresh' => SMOPT_REFRESH_NONE
,
142 //'post_script' => $js_autodetect_script,
143 'save' => 'save_option_javascript_autodetect'
146 /*** Load the General Options into the array ***/
147 $optgrps[SMOPT_GRP_MAILBOX
] = _("Mailbox Display Options");
148 $optvals[SMOPT_GRP_MAILBOX
] = array();
150 $optvals[SMOPT_GRP_MAILBOX
][] = array(
151 'name' => 'show_num',
152 'caption' => _("Number of Messages to Index"),
153 'type' => SMOPT_TYPE_INTEGER
,
154 'refresh' => SMOPT_REFRESH_NONE
,
155 'size' => SMOPT_SIZE_TINY
158 $optvals[SMOPT_GRP_MAILBOX
][] = array(
159 'name' => 'alt_index_colors',
160 'caption' => _("Enable Alternating Row Colors"),
161 'type' => SMOPT_TYPE_BOOLEAN
,
162 'refresh' => SMOPT_REFRESH_NONE
165 $optvals[SMOPT_GRP_MAILBOX
][] = array(
166 'name' => 'page_selector',
167 'caption' => _("Enable Page Selector"),
168 'type' => SMOPT_TYPE_BOOLEAN
,
169 'refresh' => SMOPT_REFRESH_NONE
172 $optvals[SMOPT_GRP_MAILBOX
][] = array(
173 'name' => 'page_selector_max',
174 'caption' => _("Maximum Number of Pages to Show"),
175 'type' => SMOPT_TYPE_INTEGER
,
176 'refresh' => SMOPT_REFRESH_NONE
,
177 'size' => SMOPT_SIZE_TINY
180 $optvals[SMOPT_GRP_MAILBOX
][] = array(
181 'name' => 'show_full_date',
182 'caption' => _("Always Show Full Date"),
183 'type' => SMOPT_TYPE_BOOLEAN
,
184 'refresh' => SMOPT_REFRESH_NONE
187 $optvals[SMOPT_GRP_MAILBOX
][] = array(
188 'name' => 'truncate_sender',
189 'caption' => _("Length of From/To Field (0 for full)"),
190 'type' => SMOPT_TYPE_INTEGER
,
191 'refresh' => SMOPT_REFRESH_NONE
,
192 'size' => SMOPT_SIZE_TINY
195 $optvals[SMOPT_GRP_MAILBOX
][] = array(
196 'name' => 'truncate_subject',
197 'caption' => _("Length of Subject Field (0 for full)"),
198 'type' => SMOPT_TYPE_INTEGER
,
199 'refresh' => SMOPT_REFRESH_NONE
,
200 'size' => SMOPT_SIZE_TINY
203 $optvals[SMOPT_GRP_MAILBOX
][] = array(
204 'name' => 'show_recipient_instead',
205 'caption' => _("Show recipient name if the message is from your default identity"),
206 'type' => SMOPT_TYPE_BOOLEAN
,
207 'refresh' => SMOPT_REFRESH_NONE
,
208 'size' => SMOPT_SIZE_TINY
212 /*** Load the General Options into the array ***/
213 $optgrps[SMOPT_GRP_MESSAGE
] = _("Message Display and Composition");
214 $optvals[SMOPT_GRP_MESSAGE
] = array();
216 $optvals[SMOPT_GRP_MESSAGE
][] = array(
218 'caption' => _("Wrap Incoming Text At"),
219 'type' => SMOPT_TYPE_INTEGER
,
220 'refresh' => SMOPT_REFRESH_NONE
,
221 'size' => SMOPT_SIZE_TINY
224 $optvals[SMOPT_GRP_MESSAGE
][] = array(
225 'name' => 'editor_size',
226 'caption' => _("Size of Editor Window"),
227 'type' => SMOPT_TYPE_INTEGER
,
228 'refresh' => SMOPT_REFRESH_NONE
,
229 'size' => SMOPT_SIZE_TINY
232 $optvals[SMOPT_GRP_MESSAGE
][] = array(
233 'name' => 'location_of_buttons',
234 'caption' => _("Location of Buttons when Composing"),
235 'type' => SMOPT_TYPE_STRLIST
,
236 'refresh' => SMOPT_REFRESH_NONE
,
237 'posvals' => array(SMPREF_LOC_TOP
=> _("Before headers"),
238 SMPREF_LOC_BETWEEN
=> _("Between headers and message body"),
239 SMPREF_LOC_BOTTOM
=> _("After message body"))
243 $optvals[SMOPT_GRP_MESSAGE
][] = array(
244 'name' => 'use_javascript_addr_book',
245 'caption' => _("Addressbook Display Format"),
246 'type' => SMOPT_TYPE_STRLIST
,
247 'refresh' => SMOPT_REFRESH_NONE
,
248 'posvals' => array('1' => _("Javascript"),
252 $optvals[SMOPT_GRP_MESSAGE
][] = array(
253 'name' => 'show_html_default',
254 'caption' => _("Show HTML Version by Default"),
255 'type' => SMOPT_TYPE_BOOLEAN
,
256 'refresh' => SMOPT_REFRESH_NONE
259 $optvals[SMOPT_GRP_MESSAGE
][] = array(
260 'name' => 'enable_forward_as_attachment',
261 'caption' => _("Enable Forward as Attachment"),
262 'type' => SMOPT_TYPE_BOOLEAN
,
263 'refresh' => SMOPT_REFRESH_NONE
266 $optvals[SMOPT_GRP_MESSAGE
][] = array(
267 'name' => 'forward_cc',
268 'caption' => _("Include CCs when Forwarding Messages"),
269 'type' => SMOPT_TYPE_BOOLEAN
,
270 'refresh' => SMOPT_REFRESH_NONE
273 $optvals[SMOPT_GRP_MESSAGE
][] = array(
274 'name' => 'include_self_reply_all',
275 'caption' => _("Include Me in CC when I Reply All"),
276 'type' => SMOPT_TYPE_BOOLEAN
,
277 'refresh' => SMOPT_REFRESH_NONE
280 $optvals[SMOPT_GRP_MESSAGE
][] = array(
281 'name' => 'show_xmailer_default',
282 'caption' => _("Enable Mailer Display"),
283 'type' => SMOPT_TYPE_BOOLEAN
,
284 'refresh' => SMOPT_REFRESH_NONE
287 $optvals[SMOPT_GRP_MESSAGE
][] = array(
288 'name' => 'attachment_common_show_images',
289 'caption' => _("Display Attached Images with Message"),
290 'type' => SMOPT_TYPE_BOOLEAN
,
291 'refresh' => SMOPT_REFRESH_NONE
294 $optvals[SMOPT_GRP_MESSAGE
][] = array(
295 'name' => 'pf_cleandisplay',
296 'caption' => _("Enable Printer Friendly Clean Display"),
297 'type' => SMOPT_TYPE_BOOLEAN
,
298 'refresh' => SMOPT_REFRESH_NONE
301 if ($default_use_mdn) {
302 $optvals[SMOPT_GRP_MESSAGE
][] = array(
303 'name' => 'mdn_user_support',
304 'caption' => _("Enable Mail Delivery Notification"),
305 'type' => SMOPT_TYPE_BOOLEAN
,
306 'refresh' => SMOPT_REFRESH_NONE
310 $optvals[SMOPT_GRP_MESSAGE
][] = array(
311 'name' => 'compose_new_win',
312 'caption' => _("Compose Messages in New Window"),
313 'type' => SMOPT_TYPE_BOOLEAN
,
314 'refresh' => SMOPT_REFRESH_ALL
317 $optvals[SMOPT_GRP_MESSAGE
][] = array(
318 'name' => 'compose_width',
319 'caption' => _("Width of Compose Window"),
320 'type' => SMOPT_TYPE_INTEGER
,
321 'refresh' => SMOPT_REFRESH_ALL
,
322 'size' => SMOPT_SIZE_TINY
325 $optvals[SMOPT_GRP_MESSAGE
][] = array(
326 'name' => 'compose_height',
327 'caption' => _("Height of Compose Window"),
328 'type' => SMOPT_TYPE_INTEGER
,
329 'refresh' => SMOPT_REFRESH_ALL
,
330 'size' => SMOPT_SIZE_TINY
333 $optvals[SMOPT_GRP_MESSAGE
][] = array(
334 'name' => 'sig_first',
335 'caption' => _("Append Signature before Reply/Forward Text"),
336 'type' => SMOPT_TYPE_BOOLEAN
,
337 'refresh' => SMOPT_REFRESH_NONE
340 $optvals[SMOPT_GRP_MESSAGE
][] = array(
341 'name' => 'reply_focus',
342 'caption' => _("Cursor Position when Replying"),
343 'type' => SMOPT_TYPE_STRLIST
,
344 'refresh' => SMOPT_REFRESH_NONE
,
345 'posvals' => array('' => _("To: field"),
346 'focus' => _("Focus in body"),
347 'select' => _("Select body"))
350 $optvals[SMOPT_GRP_MESSAGE
][] = array(
351 'name' => 'strip_sigs',
352 'caption' => _("Strip signature when replying"),
353 'type' => SMOPT_TYPE_BOOLEAN
,
354 'refresh' => SMOPT_REFRESH_NONE
357 $optvals[SMOPT_GRP_MESSAGE
][] = array(
358 'name' => 'internal_date_sort',
359 'caption' => _("Enable Sort by of Receive Date"),
360 'type' => SMOPT_TYPE_BOOLEAN
,
361 'refresh' => SMOPT_REFRESH_ALL
363 if ($allow_thread_sort == TRUE) {
364 $optvals[SMOPT_GRP_MESSAGE
][] = array(
365 'name' => 'sort_by_ref',
366 'caption' => _("Enable Thread Sort by References Header"),
367 'type' => SMOPT_TYPE_BOOLEAN
,
368 'refresh' => SMOPT_REFRESH_ALL
371 /* Assemble all this together and return it as our result. */
375 'xtra' => $onLoadScript
380 /******************************************************************/
381 /** Define any specialized save functions for this option page. ***/
382 /******************************************************************/
384 function save_option_theme($option) {
387 /* Do checking to make sure $new_theme is in the array. */
388 $theme_in_array = false;
389 for ($i = 0; $i < count($theme); ++
$i) {
390 if ($theme[$i]['PATH'] == $option->new_value
) {
391 $theme_in_array = true;
396 if (!$theme_in_array) {
397 $option->new_value
= '';
400 /* Save the option like normal. */
401 save_option($option);
404 function save_option_javascript_autodetect($option) {
405 global $data_dir, $username, $new_javascript_setting;
407 /* Set javascript either on or off. */
408 if ($new_javascript_setting == SMPREF_JS_AUTODETECT
) {
409 if ($option->new_value
== SMPREF_JS_ON
) {
410 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON
);
412 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF
);
415 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);