The auto focus module has been a little bit improved in order
[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() {
0f529285 21 global $theme, $language, $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);
8405d0a4 58 $language_values =
59 array_merge(array('' => _("Default")), $language_values);
bbcafebd 60 $optvals[SMOPT_GRP_GENERAL][] = array(
ce393174 61 'name' => 'language',
62 'caption' => _("Language"),
63 'type' => SMOPT_TYPE_STRLIST,
64 'refresh' => SMOPT_REFRESH_ALL,
65 'posvals' => $language_values
66 );
67
a3ec3c91 68 /* Set values for the "use javascript" option. */
bbcafebd 69 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 70 'name' => 'javascript_setting',
ce393174 71 'caption' => _("Use Javascript"),
a3ec3c91 72 'type' => SMOPT_TYPE_STRLIST,
73 'refresh' => SMOPT_REFRESH_ALL,
74 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
75 SMPREF_JS_ON => _("Always"),
76 SMPREF_JS_OFF => _("Never"))
77 );
78
e697b6cc 79 $js_autodetect_script =
80 "<SCRIPT LANGUAGE=\"JavaScript\"><!--\n".
81 "document.forms[0].new_js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
82 "// --></SCRIPT>\n";
a3ec3c91 83 $js_autodetect_results = SMPREF_JS_OFF;
bbcafebd 84 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 85 'name' => 'js_autodetect_results',
86 'caption' => '',
87 'type' => SMOPT_TYPE_HIDDEN,
cbe5423b 88 'refresh' => SMOPT_REFRESH_NONE,
89 'script' => $js_autodetect_script,
90 'save' => 'save_option_javascript_autodetect'
a3ec3c91 91 );
92
bbcafebd 93 /*** Load the General Options into the array ***/
94 $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
95 $optvals[SMOPT_GRP_MAILBOX] = array();
96
97 $optvals[SMOPT_GRP_MAILBOX][] = array(
a3ec3c91 98 'name' => 'show_num',
99 'caption' => _("Number of Messages to Index"),
100 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 101 'refresh' => SMOPT_REFRESH_NONE,
102 'size' => SMOPT_SIZE_TINY
a3ec3c91 103 );
104
bbcafebd 105 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 106 'name' => 'alt_index_colors',
107 'caption' => _("Enable Alternating Row Colors"),
108 'type' => SMOPT_TYPE_BOOLEAN,
109 'refresh' => SMOPT_REFRESH_NONE
110 );
111
bbcafebd 112 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 113 'name' => 'page_selector',
114 'caption' => _("Enable Page Selector"),
115 'type' => SMOPT_TYPE_BOOLEAN,
116 'refresh' => SMOPT_REFRESH_NONE
117 );
118
bbcafebd 119 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 120 'name' => 'page_selector_max',
121 'caption' => _("Maximum Number of Pages to Show"),
122 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 123 'refresh' => SMOPT_REFRESH_NONE,
124 'size' => SMOPT_SIZE_TINY
a440e68f 125 );
126
bbcafebd 127 /*** Load the General Options into the array ***/
128 $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display and Composition");
129 $optvals[SMOPT_GRP_MESSAGE] = array();
130
131 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 132 'name' => 'wrap_at',
133 'caption' => _("Wrap Incoming Text At"),
134 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 135 'refresh' => SMOPT_REFRESH_NONE,
136 'size' => SMOPT_SIZE_TINY
a3ec3c91 137 );
138
bbcafebd 139 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 140 'name' => 'editor_size',
141 'caption' => _("Size of Editor Window"),
142 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 143 'refresh' => SMOPT_REFRESH_NONE,
144 'size' => SMOPT_SIZE_TINY
a3ec3c91 145 );
146
bbcafebd 147 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 148 'name' => 'location_of_buttons',
ce393174 149 'caption' => _("Location of Buttons when Composing"),
a3ec3c91 150 'type' => SMOPT_TYPE_STRLIST,
151 'refresh' => SMOPT_REFRESH_NONE,
ce393174 152 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
153 SMPREF_LOC_BETWEEN => _("Between headers and message body"),
154 SMPREF_LOC_BOTTOM => _("After message body"))
a3ec3c91 155 );
156
bbcafebd 157 $optvals[SMOPT_GRP_MESSAGE][] = array(
a440e68f 158 'name' => 'use_javascript_addr_book',
159 'caption' => _("Addressbook Display Format"),
ce393174 160 'type' => SMOPT_TYPE_STRLIST,
a440e68f 161 'refresh' => SMOPT_REFRESH_NONE,
162 'posvals' => array('1' => _("Javascript"),
163 '0' => _("HTML"))
fd87494d 164 );
165
bbcafebd 166 $optvals[SMOPT_GRP_MESSAGE][] = array(
fd87494d 167 'name' => 'show_html_default',
168 'caption' => _("Show HTML Version by Default"),
169 'type' => SMOPT_TYPE_BOOLEAN,
170 'refresh' => SMOPT_REFRESH_NONE
171 );
172
bbcafebd 173 $optvals[SMOPT_GRP_MESSAGE][] = array(
fd87494d 174 'name' => 'include_self_reply_all',
bbcafebd 175 'caption' => _("Include Me in CC when I Reply All"),
fd87494d 176 'type' => SMOPT_TYPE_BOOLEAN,
177 'refresh' => SMOPT_REFRESH_NONE
178 );
179
bbcafebd 180 $optvals[SMOPT_GRP_MESSAGE][] = array(
9ab0d96f 181 'name' => 'show_xmailer_default',
a440e68f 182 'caption' => _("Enable Mailer Display"),
9ab0d96f 183 'type' => SMOPT_TYPE_BOOLEAN,
184 'refresh' => SMOPT_REFRESH_NONE
185 );
186
7baf86a9 187 $optvals[SMOPT_GRP_MESSAGE][] = array(
188 'name' => 'attachment_common_show_images',
10f0ce72 189 'caption' => _("Display Attached Images with Message"),
7baf86a9 190 'type' => SMOPT_TYPE_BOOLEAN,
191 'refresh' => SMOPT_REFRESH_NONE
192 );
193
f226cba7 194 $optvals[SMOPT_GRP_MESSAGE][] = array(
195 'name' => 'pf_subtle_link',
10f0ce72 196 'caption' => _("Enable Subtle Printer Friendly Link"),
f226cba7 197 'type' => SMOPT_TYPE_BOOLEAN,
198 'refresh' => SMOPT_REFRESH_NONE
199 );
200
201 $optvals[SMOPT_GRP_MESSAGE][] = array(
202 'name' => 'pf_cleandisplay',
10f0ce72 203 'caption' => _("Enable Printer Friendly Clean Display"),
f226cba7 204 'type' => SMOPT_TYPE_BOOLEAN,
205 'refresh' => SMOPT_REFRESH_NONE
206 );
207
cbe5423b 208 /* Assemble all this together and return it as our result. */
209 $result = array(
210 'grps' => $optgrps,
211 'vals' => $optvals
212 );
213 return ($result);
214}
a3ec3c91 215
cbe5423b 216/******************************************************************/
217/** Define any specialized save functions for this option page. ***/
218/******************************************************************/
f1e6f580 219
cbe5423b 220function save_option_theme($option) {
221 global $theme;
e7db48af 222
cbe5423b 223 /* Do checking to make sure $new_theme is in the array. */
224 $theme_in_array = false;
225 for ($i = 0; $i < count($theme); ++$i) {
226 if ($theme[$i]['PATH'] == $option->new_value) {
227 $theme_in_array = true;
228 break;
229 }
230 }
231
232 if (!$theme_in_array) {
233 $option->new_value = '';
234 }
e7db48af 235
cbe5423b 236 /* Save the option like normal. */
237 save_option($option);
238}
e7db48af 239
cbe5423b 240function save_option_javascript_autodetect($option) {
241 global $data_dir, $username, $new_javascript_setting;
23d6bd09 242
cbe5423b 243 /* Set javascript either on or off. */
244 if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
245 if ($option->new_value == SMPREF_JS_ON) {
246 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON);
247 } else {
248 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
249 }
250 } else {
251 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
252 }
253}
254
255?>