moving main color tags to css
[squirrelmail.git] / include / options / display.php
CommitLineData
c36ed9cf 1<?php
e7db48af 2
35586184 3/**
4 * options_display.php
5 *
35586184 6 * Displays all optinos about display preferences
7 *
4b4abf93 8 * @copyright &copy; 1999-2005 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
763b63fe 10 * @version $Id$
2b646597 11 * @package squirrelmail
35586184 12 */
cbe5423b 13
2b646597 14/** Define the group constants for the display options page. */
cbe5423b 15define('SMOPT_GRP_GENERAL', 0);
16define('SMOPT_GRP_MAILBOX', 1);
17define('SMOPT_GRP_MESSAGE', 2);
18
6395c46d 19// load icon themes if in use
20global $use_icons;
21if ($use_icons) {
22 global $icon_themes;
23 $dirName = SM_PATH . 'images/themes';
4f7a5870 24 if (is_readable($dirName) && is_dir($dirName)) {
25 $d = dir($dirName);
26 while($dir = $d->read()) {
27 if ($dir != "." && $dir != "..") {
28 if (is_dir($dirName."/".$dir) && file_exists("$dirName/$dir/theme.php"))
29 include("$dirName/$dir/theme.php");
30 }
6395c46d 31 }
32 }
33}
34
a144f6b8 35global $use_iframe;
36if (! isset($use_iframe)) $use_iframe=false;
37
48af4b64 38/**
39 * This function builds an array with all the information about
40 * the options available to the user, and returns it. The options
41 * are grouped by the groups in which they are displayed.
42 * For each option, the following information is stored:
43 * - name: the internal (variable) name
44 * - caption: the description of the option in the UI
45 * - type: one of SMOPT_TYPE_*
46 * - refresh: one of SMOPT_REFRESH_*
47 * - size: one of SMOPT_SIZE_*
48 * - save: the name of a function to call when saving this option
49 * @return array all option information
50 */
cbe5423b 51function load_optpage_data_display() {
81132de8 52 global $theme, $fontsets, $language, $languages,
ce68b76b 53 $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
5ba5dc8e 54 $show_alternative_names, $use_icons, $use_iframe;
a3ec3c91 55
ce393174 56 /* Build a simple array into which we will build options. */
bbcafebd 57 $optgrps = array();
58 $optvals = array();
a3ec3c91 59
bbcafebd 60 /******************************************************/
61 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
62 /******************************************************/
bbcafebd 63
64 /*** Load the General Options into the array ***/
65 $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options");
66 $optvals[SMOPT_GRP_GENERAL] = array();
67
68 /* Load the theme option. */
ce393174 69 $theme_values = array();
70 foreach ($theme as $theme_key => $theme_attributes) {
be278741 71 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
ce393174 72 }
be278741 73 ksort($theme_values);
74 $theme_values = array_flip($theme_values);
bbcafebd 75 $optvals[SMOPT_GRP_GENERAL][] = array(
ce393174 76 'name' => 'chosen_theme',
77 'caption' => _("Theme"),
78 'type' => SMOPT_TYPE_STRLIST,
79 'refresh' => SMOPT_REFRESH_ALL,
cbe5423b 80 'posvals' => $theme_values,
81 'save' => 'save_option_theme'
ce393174 82 );
5d110fa6 83
8f1ba72b 84 $css_values = array( 'none' => _("Default" ) );
bb7173fa 85 $css_dir = SM_PATH . 'themes/css';
86 if (is_readable($css_dir) && is_dir($css_dir)) {
87 $handle=opendir($css_dir);
4f7a5870 88 while ($file = readdir($handle) ) {
89 if ( substr( $file, -4 ) == '.css' ) {
90 $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
91 }
8f1ba72b 92 }
4f7a5870 93 closedir($handle);
dcd6f144 94 }
5d110fa6 95
81132de8 96 /*
54078578 97 if ( count( $css_values ) > 1 ) {
5d110fa6 98
e2cdae1f 99 $optvals[SMOPT_GRP_GENERAL][] = array(
100 'name' => 'custom_css',
101 'caption' => _("Custom Stylesheet"),
102 'type' => SMOPT_TYPE_STRLIST,
103 'refresh' => SMOPT_REFRESH_ALL,
104 'posvals' => $css_values
105 );
5d110fa6 106
e2cdae1f 107 }
81132de8 108 */
109
110 $fontset_values = array();
111 foreach (array_keys($fontsets) as $fontset_key) {
112 $fontset_list[$fontset_key]=$fontset_key;
113 }
114 ksort($fontset_list);
115
116 if (count($fontset_list) > 1) {
117 $fontset_list = array_merge(array('' => _("Default font style")), $fontset_list);
118 $optvals[SMOPT_GRP_GENERAL][] = array(
119 'name' => 'chosen_fontset',
120 'caption' => _("Font style"),
121 'type' => SMOPT_TYPE_STRLIST,
122 'refresh' => SMOPT_REFRESH_ALL,
123 'posvals' => $fontset_list
124 );
125 }
126
127 $optvals[SMOPT_GRP_GENERAL][] = array(
128 'name' => 'chosen_fontsize',
129 'caption' => _("Font size"),
130 'type' => SMOPT_TYPE_STRLIST,
131 'refresh' => SMOPT_REFRESH_ALL,
132 'posvals' => array('' => _("Default font size"),
133 '8' => '8 px',
134 '10' => '10 px',
135 '12' => '12 px',
136 '14' => '14 px')
137 );
39d3ec89 138
e557fdb0 139 $language_values = array();
5ba5dc8e 140 foreach ($languages as $lang_key => $lang_attributes) {
141 if (isset($lang_attributes['NAME'])) {
142 $language_values[$lang_key] = $lang_attributes['NAME'];
143 if ( isset($show_alternative_names) &&
144 $show_alternative_names &&
145 isset($lang_attributes['ALTNAME']) ) {
146 $language_values[$lang_key] .= " / " . $lang_attributes['ALTNAME'];
0bb37159 147 }
148 }
ce393174 149 }
5ba5dc8e 150
e557fdb0 151 asort($language_values);
8405d0a4 152 $language_values =
153 array_merge(array('' => _("Default")), $language_values);
ec2c91a1 154 $language = $squirrelmail_language;
5ba5dc8e 155
48d5ec1f 156 // add language selection only when more than 2 languages are available
157 // (default, English and some other)
158 if (count($language_values)>2) {
159 $optvals[SMOPT_GRP_GENERAL][] = array(
160 'name' => 'language',
161 'caption' => _("Language"),
162 'type' => SMOPT_TYPE_STRLIST,
163 'refresh' => SMOPT_REFRESH_ALL,
164 'posvals' => $language_values,
165 'htmlencoded' => true
166 );
167 }
ce393174 168
a3ec3c91 169 /* Set values for the "use javascript" option. */
bbcafebd 170 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 171 'name' => 'javascript_setting',
ce393174 172 'caption' => _("Use Javascript"),
a3ec3c91 173 'type' => SMOPT_TYPE_STRLIST,
174 'refresh' => SMOPT_REFRESH_ALL,
175 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
176 SMPREF_JS_ON => _("Always"),
ae958cd3 177 SMPREF_JS_OFF => _("Never")),
178 'save' => 'save_option_javascript_autodetect',
179 'script' => 'onclick="document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\';"'
a3ec3c91 180 );
181
bbcafebd 182 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 183 'name' => 'js_autodetect_results',
184 'caption' => '',
185 'type' => SMOPT_TYPE_HIDDEN,
ae958cd3 186 'refresh' => SMOPT_REFRESH_NONE
5826affb 187 //'post_script' => $js_autodetect_script,
a3ec3c91 188 );
f2df3fa1 189
5bcd1b00 190 $optvals[SMOPT_GRP_GENERAL][] = array(
191 'name' => 'hour_format',
192 'caption' => _("Hour Format"),
193 'type' => SMOPT_TYPE_STRLIST,
194 'refresh' => SMOPT_REFRESH_FOLDERLIST,
195 'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"),
196 SMPREF_TIME_24HR => _("24-hour clock"))
197 );
a3ec3c91 198
bbcafebd 199 /*** Load the General Options into the array ***/
200 $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
201 $optvals[SMOPT_GRP_MAILBOX] = array();
202
203 $optvals[SMOPT_GRP_MAILBOX][] = array(
a3ec3c91 204 'name' => 'show_num',
f2df3fa1 205 'caption' => _("Number of Messages per Page"),
a3ec3c91 206 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 207 'refresh' => SMOPT_REFRESH_NONE,
208 'size' => SMOPT_SIZE_TINY
a3ec3c91 209 );
210
bbcafebd 211 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 212 'name' => 'alt_index_colors',
213 'caption' => _("Enable Alternating Row Colors"),
214 'type' => SMOPT_TYPE_BOOLEAN,
215 'refresh' => SMOPT_REFRESH_NONE
216 );
217
18adc53f 218 $optvals[SMOPT_GRP_MAILBOX][] = array(
219 'name' => 'fancy_index_highlite',
220 'caption' => _("Enable Fancy Row Mouseover Highlighting"),
221 'type' => SMOPT_TYPE_BOOLEAN,
222 'refresh' => SMOPT_REFRESH_NONE
223 );
224
6395c46d 225 if ($use_icons) {
226 global $icon_themes, $icon_theme;
227 $temp = array();
228 for ($count = 0; $count < sizeof($icon_themes); $count++) {
229 $temp[$count] = $icon_themes[$count]['NAME'];
230 if ($icon_theme == $icon_themes[$count]['PATH'])
231 $value = $count;
232 }
4f7a5870 233 if (sizeof($icon_themes) > 0) {
234 $optvals[SMOPT_GRP_MAILBOX][] = array(
235 'name' => 'icon_theme',
236 'caption' => _("Message Flags Icon Theme"),
237 'type' => SMOPT_TYPE_STRLIST,
238 'refresh' => SMOPT_REFRESH_NONE,
239 'posvals' => $temp,
240 'initial_value' => $value,
241 'save' => 'icon_theme_save'
242 );
243 }
6395c46d 244 }
245
fd181f53 246 $optvals[SMOPT_GRP_MAILBOX][] = array(
247 'name' => 'show_flag_buttons',
248 'caption' => _("Show Flag / Unflag Buttons"),
249 'type' => SMOPT_TYPE_BOOLEAN,
250 'refresh' => SMOPT_REFRESH_NONE
251 );
252
bbcafebd 253 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 254 'name' => 'page_selector',
255 'caption' => _("Enable Page Selector"),
256 'type' => SMOPT_TYPE_BOOLEAN,
257 'refresh' => SMOPT_REFRESH_NONE
258 );
259
0bb37159 260 $optvals[SMOPT_GRP_MAILBOX][] = array(
261 'name' => 'compact_paginator',
262 'caption' => _("Use Compact Page Selector"),
263 'type' => SMOPT_TYPE_BOOLEAN,
264 'refresh' => SMOPT_REFRESH_NONE
265 );
266
bbcafebd 267 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 268 'name' => 'page_selector_max',
269 'caption' => _("Maximum Number of Pages to Show"),
270 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 271 'refresh' => SMOPT_REFRESH_NONE,
272 'size' => SMOPT_SIZE_TINY
a440e68f 273 );
274
3e3b60e3 275 $optvals[SMOPT_GRP_MAILBOX][] = array(
276 'name' => 'show_full_date',
277 'caption' => _("Always Show Full Date"),
278 'type' => SMOPT_TYPE_BOOLEAN,
279 'refresh' => SMOPT_REFRESH_NONE
280 );
281
459e3347 282 $optvals[SMOPT_GRP_MAILBOX][] = array(
283 'name' => 'truncate_sender',
284 'caption' => _("Length of From/To Field (0 for full)"),
285 'type' => SMOPT_TYPE_INTEGER,
286 'refresh' => SMOPT_REFRESH_NONE,
287 'size' => SMOPT_SIZE_TINY
288 );
289
3fc1a95f 290 $optvals[SMOPT_GRP_MAILBOX][] = array(
291 'name' => 'truncate_subject',
292 'caption' => _("Length of Subject Field (0 for full)"),
293 'type' => SMOPT_TYPE_INTEGER,
294 'refresh' => SMOPT_REFRESH_NONE,
295 'size' => SMOPT_SIZE_TINY
296 );
91c27aee 297/*
298 disabled because the template doesn't support it (yet?)
1ae2832e 299 $optvals[SMOPT_GRP_MAILBOX][] = array(
300 'name' => 'show_recipient_instead',
301 'caption' => _("Show recipient name if the message is from your default identity"),
302 'type' => SMOPT_TYPE_BOOLEAN,
303 'refresh' => SMOPT_REFRESH_NONE,
304 'size' => SMOPT_SIZE_TINY
305 );
91c27aee 306*/
f2df3fa1 307
5ed9d4fd 308 if ($allow_thread_sort == TRUE) {
309 $optvals[SMOPT_GRP_MAILBOX][] = array(
310 'name' => 'sort_by_ref',
311 'caption' => _("Enable Thread Sort by References Header"),
312 'type' => SMOPT_TYPE_BOOLEAN,
313 'refresh' => SMOPT_REFRESH_ALL
314 );
315 }
316
1ae2832e 317
459e3347 318
bbcafebd 319 /*** Load the General Options into the array ***/
5ed9d4fd 320 $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display Options");
bbcafebd 321 $optvals[SMOPT_GRP_MESSAGE] = array();
322
323 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 324 'name' => 'wrap_at',
325 'caption' => _("Wrap Incoming Text At"),
326 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 327 'refresh' => SMOPT_REFRESH_NONE,
328 'size' => SMOPT_SIZE_TINY
a3ec3c91 329 );
330
bbcafebd 331 $optvals[SMOPT_GRP_MESSAGE][] = array(
fd87494d 332 'name' => 'show_html_default',
333 'caption' => _("Show HTML Version by Default"),
334 'type' => SMOPT_TYPE_BOOLEAN,
335 'refresh' => SMOPT_REFRESH_NONE
336 );
337
a144f6b8 338 if ($use_iframe) {
339 // Type is set to string in order to be able to use 100%.
340 $optvals[SMOPT_GRP_MESSAGE][] = array(
341 'name' => 'iframe_height',
342 'caption' => _("Height of inline frame"),
343 'type' => SMOPT_TYPE_STRING,
344 'size' => SMOPT_SIZE_TINY,
345 'refresh' => SMOPT_REFRESH_NONE
346 );
347 }
bbcafebd 348 $optvals[SMOPT_GRP_MESSAGE][] = array(
6206f6c4 349 'name' => 'enable_forward_as_attachment',
350 'caption' => _("Enable Forward as Attachment"),
fd87494d 351 'type' => SMOPT_TYPE_BOOLEAN,
352 'refresh' => SMOPT_REFRESH_NONE
353 );
354
bbcafebd 355 $optvals[SMOPT_GRP_MESSAGE][] = array(
9ab0d96f 356 'name' => 'show_xmailer_default',
a440e68f 357 'caption' => _("Enable Mailer Display"),
9ab0d96f 358 'type' => SMOPT_TYPE_BOOLEAN,
359 'refresh' => SMOPT_REFRESH_NONE
360 );
361
7baf86a9 362 $optvals[SMOPT_GRP_MESSAGE][] = array(
363 'name' => 'attachment_common_show_images',
10f0ce72 364 'caption' => _("Display Attached Images with Message"),
7baf86a9 365 'type' => SMOPT_TYPE_BOOLEAN,
366 'refresh' => SMOPT_REFRESH_NONE
367 );
368
57257333 369 if ($default_use_mdn) {
370 $optvals[SMOPT_GRP_MESSAGE][] = array(
371 'name' => 'mdn_user_support',
6206f6c4 372 'caption' => _("Enable Mail Delivery Notification"),
57257333 373 'type' => SMOPT_TYPE_BOOLEAN,
374 'refresh' => SMOPT_REFRESH_NONE
375 );
376 }
07687736 377
4267d5de 378 $optvals[SMOPT_GRP_MESSAGE][] = array(
379 'name' => 'delete_prev_next_display',
380 'caption' => _("Show 'Delete & Prev/Next' Links"),
381 'type' => SMOPT_TYPE_BOOLEAN,
382 'refresh' => SMOPT_REFRESH_ALL
383 );
5d110fa6 384
cbe5423b 385 /* Assemble all this together and return it as our result. */
386 $result = array(
387 'grps' => $optgrps,
ae958cd3 388 'vals' => $optvals
cbe5423b 389 );
390 return ($result);
391}
a3ec3c91 392
cbe5423b 393/******************************************************************/
394/** Define any specialized save functions for this option page. ***/
395/******************************************************************/
f1e6f580 396
48af4b64 397/**
398 * This function saves a new theme setting.
399 * It updates the theme array.
400 */
cbe5423b 401function save_option_theme($option) {
402 global $theme;
bb7173fa 403
cbe5423b 404 /* Do checking to make sure $new_theme is in the array. */
405 $theme_in_array = false;
406 for ($i = 0; $i < count($theme); ++$i) {
407 if ($theme[$i]['PATH'] == $option->new_value) {
408 $theme_in_array = true;
409 break;
410 }
411 }
412
413 if (!$theme_in_array) {
414 $option->new_value = '';
415 }
e7db48af 416
cbe5423b 417 /* Save the option like normal. */
418 save_option($option);
419}
e7db48af 420
48af4b64 421/**
422 * This function saves the javascript detection option.
423 */
cbe5423b 424function save_option_javascript_autodetect($option) {
ae958cd3 425 save_option($option);
426 checkForJavascript(TRUE);
cbe5423b 427}
428
5d110fa6 429/**
6395c46d 430 * This function saves the user's icon theme setting
431 */
432function icon_theme_save($option) {
433
434 global $icon_themes, $data_dir, $username;
435
436
5d110fa6 437 // Don't assume the new value is there, double check
438 // and only save if found
6395c46d 439 //
440 if (isset($icon_themes[$option->new_value]['PATH']))
441 setPref($data_dir, $username, 'icon_theme', $icon_themes[$option->new_value]['PATH']);
442 else
443 setPref($data_dir, $username, 'icon_theme', 'none');
444
445}
446
f8a1ed5a 447?>