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