Various UI tweaks...
[squirrelmail.git] / src / options_display.php
CommitLineData
c36ed9cf 1<?php
e7db48af 2
35586184 3/**
4 * options_display.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 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 */
cbe5423b 13
14/* Define the group constants for the display options page. */
15define('SMOPT_GRP_GENERAL', 0);
16define('SMOPT_GRP_MAILBOX', 1);
17define('SMOPT_GRP_MESSAGE', 2);
18
19/* Define the optpage load function for the display options page. */
20function load_optpage_data_display() {
21 global $theme, $languages, $js_autodetect_results;
a3ec3c91 22
ce393174 23 /* Build a simple array into which we will build options. */
bbcafebd 24 $optgrps = array();
25 $optvals = array();
a3ec3c91 26
bbcafebd 27 /******************************************************/
28 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
29 /******************************************************/
bbcafebd 30
31 /*** Load the General Options into the array ***/
32 $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options");
33 $optvals[SMOPT_GRP_GENERAL] = array();
34
35 /* Load the theme option. */
ce393174 36 $theme_values = array();
37 foreach ($theme as $theme_key => $theme_attributes) {
be278741 38 $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
ce393174 39 }
be278741 40 ksort($theme_values);
41 $theme_values = array_flip($theme_values);
bbcafebd 42 $optvals[SMOPT_GRP_GENERAL][] = array(
ce393174 43 'name' => 'chosen_theme',
44 'caption' => _("Theme"),
45 'type' => SMOPT_TYPE_STRLIST,
46 'refresh' => SMOPT_REFRESH_ALL,
cbe5423b 47 'posvals' => $theme_values,
48 'save' => 'save_option_theme'
ce393174 49 );
50
e557fdb0 51 $language_values = array();
ce393174 52 foreach ($languages as $lang_key => $lang_attributes) {
53 if (isset($lang_attributes['NAME'])) {
7f79cdf0 54 $language_values[$lang_key] = $lang_attributes['NAME'];
ce393174 55 }
56 }
e557fdb0 57 asort($language_values);
bbcafebd 58 $optvals[SMOPT_GRP_GENERAL][] = array(
ce393174 59 'name' => 'language',
60 'caption' => _("Language"),
61 'type' => SMOPT_TYPE_STRLIST,
62 'refresh' => SMOPT_REFRESH_ALL,
63 'posvals' => $language_values
64 );
65
a3ec3c91 66 /* Set values for the "use javascript" option. */
bbcafebd 67 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 68 'name' => 'javascript_setting',
ce393174 69 'caption' => _("Use Javascript"),
a3ec3c91 70 'type' => SMOPT_TYPE_STRLIST,
71 'refresh' => SMOPT_REFRESH_ALL,
72 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
73 SMPREF_JS_ON => _("Always"),
74 SMPREF_JS_OFF => _("Never"))
75 );
76
e697b6cc 77 $js_autodetect_script =
78 "<SCRIPT LANGUAGE=\"JavaScript\"><!--\n".
79 "document.forms[0].new_js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
80 "// --></SCRIPT>\n";
a3ec3c91 81 $js_autodetect_results = SMPREF_JS_OFF;
bbcafebd 82 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 83 'name' => 'js_autodetect_results',
84 'caption' => '',
85 'type' => SMOPT_TYPE_HIDDEN,
cbe5423b 86 'refresh' => SMOPT_REFRESH_NONE,
87 'script' => $js_autodetect_script,
88 'save' => 'save_option_javascript_autodetect'
a3ec3c91 89 );
90
bbcafebd 91 /*** Load the General Options into the array ***/
92 $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
93 $optvals[SMOPT_GRP_MAILBOX] = array();
94
95 $optvals[SMOPT_GRP_MAILBOX][] = array(
a3ec3c91 96 'name' => 'show_num',
97 'caption' => _("Number of Messages to Index"),
98 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 99 'refresh' => SMOPT_REFRESH_NONE,
100 'size' => SMOPT_SIZE_TINY
a3ec3c91 101 );
102
bbcafebd 103 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 104 'name' => 'alt_index_colors',
105 'caption' => _("Enable Alternating Row Colors"),
106 'type' => SMOPT_TYPE_BOOLEAN,
107 'refresh' => SMOPT_REFRESH_NONE
108 );
109
bbcafebd 110 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 111 'name' => 'page_selector',
112 'caption' => _("Enable Page Selector"),
113 'type' => SMOPT_TYPE_BOOLEAN,
114 'refresh' => SMOPT_REFRESH_NONE
115 );
116
bbcafebd 117 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 118 'name' => 'page_selector_max',
119 'caption' => _("Maximum Number of Pages to Show"),
120 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 121 'refresh' => SMOPT_REFRESH_NONE,
122 'size' => SMOPT_SIZE_TINY
a440e68f 123 );
124
bbcafebd 125 /*** Load the General Options into the array ***/
126 $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display and Composition");
127 $optvals[SMOPT_GRP_MESSAGE] = array();
128
129 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 130 'name' => 'wrap_at',
131 'caption' => _("Wrap Incoming Text At"),
132 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 133 'refresh' => SMOPT_REFRESH_NONE,
134 'size' => SMOPT_SIZE_TINY
a3ec3c91 135 );
136
bbcafebd 137 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 138 'name' => 'editor_size',
139 'caption' => _("Size of Editor Window"),
140 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 141 'refresh' => SMOPT_REFRESH_NONE,
142 'size' => SMOPT_SIZE_TINY
a3ec3c91 143 );
144
bbcafebd 145 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 146 'name' => 'location_of_buttons',
ce393174 147 'caption' => _("Location of Buttons when Composing"),
a3ec3c91 148 'type' => SMOPT_TYPE_STRLIST,
149 'refresh' => SMOPT_REFRESH_NONE,
ce393174 150 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
151 SMPREF_LOC_BETWEEN => _("Between headers and message body"),
152 SMPREF_LOC_BOTTOM => _("After message body"))
a3ec3c91 153 );
154
bbcafebd 155 $optvals[SMOPT_GRP_MESSAGE][] = array(
a440e68f 156 'name' => 'use_javascript_addr_book',
157 'caption' => _("Addressbook Display Format"),
ce393174 158 'type' => SMOPT_TYPE_STRLIST,
a440e68f 159 'refresh' => SMOPT_REFRESH_NONE,
160 'posvals' => array('1' => _("Javascript"),
161 '0' => _("HTML"))
fd87494d 162 );
163
bbcafebd 164 $optvals[SMOPT_GRP_MESSAGE][] = array(
fd87494d 165 'name' => 'show_html_default',
166 'caption' => _("Show HTML Version by Default"),
167 'type' => SMOPT_TYPE_BOOLEAN,
168 'refresh' => SMOPT_REFRESH_NONE
169 );
170
bbcafebd 171 $optvals[SMOPT_GRP_MESSAGE][] = array(
fd87494d 172 'name' => 'include_self_reply_all',
bbcafebd 173 'caption' => _("Include Me in CC when I Reply All"),
fd87494d 174 'type' => SMOPT_TYPE_BOOLEAN,
175 'refresh' => SMOPT_REFRESH_NONE
176 );
177
bbcafebd 178 $optvals[SMOPT_GRP_MESSAGE][] = array(
9ab0d96f 179 'name' => 'show_xmailer_default',
a440e68f 180 'caption' => _("Enable Mailer Display"),
9ab0d96f 181 'type' => SMOPT_TYPE_BOOLEAN,
182 'refresh' => SMOPT_REFRESH_NONE
183 );
184
7baf86a9 185 $optvals[SMOPT_GRP_MESSAGE][] = array(
186 'name' => 'attachment_common_show_images',
10f0ce72 187 'caption' => _("Display Attached Images with Message"),
7baf86a9 188 'type' => SMOPT_TYPE_BOOLEAN,
189 'refresh' => SMOPT_REFRESH_NONE
190 );
191
f226cba7 192 $optvals[SMOPT_GRP_MESSAGE][] = array(
193 'name' => 'pf_subtle_link',
10f0ce72 194 'caption' => _("Enable Subtle Printer Friendly Link"),
f226cba7 195 'type' => SMOPT_TYPE_BOOLEAN,
196 'refresh' => SMOPT_REFRESH_NONE
197 );
198
199 $optvals[SMOPT_GRP_MESSAGE][] = array(
200 'name' => 'pf_cleandisplay',
10f0ce72 201 'caption' => _("Enable Printer Friendly Clean Display"),
f226cba7 202 'type' => SMOPT_TYPE_BOOLEAN,
203 'refresh' => SMOPT_REFRESH_NONE
204 );
205
cbe5423b 206 /* Assemble all this together and return it as our result. */
207 $result = array(
208 'grps' => $optgrps,
209 'vals' => $optvals
210 );
211 return ($result);
212}
a3ec3c91 213
cbe5423b 214/******************************************************************/
215/** Define any specialized save functions for this option page. ***/
216/******************************************************************/
f1e6f580 217
cbe5423b 218function save_option_theme($option) {
219 global $theme;
e7db48af 220
cbe5423b 221 /* Do checking to make sure $new_theme is in the array. */
222 $theme_in_array = false;
223 for ($i = 0; $i < count($theme); ++$i) {
224 if ($theme[$i]['PATH'] == $option->new_value) {
225 $theme_in_array = true;
226 break;
227 }
228 }
229
230 if (!$theme_in_array) {
231 $option->new_value = '';
232 }
e7db48af 233
cbe5423b 234 /* Save the option like normal. */
235 save_option($option);
236}
e7db48af 237
cbe5423b 238function save_option_javascript_autodetect($option) {
239 global $data_dir, $username, $new_javascript_setting;
23d6bd09 240
cbe5423b 241 /* Set javascript either on or off. */
242 if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
243 if ($option->new_value == SMPREF_JS_ON) {
244 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON);
245 } else {
246 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
247 }
248 } else {
249 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
250 }
251}
252
253?>