phpDocumentor updates
[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() {
91e0dccc 52 global $theme, $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
54078578 96 if ( count( $css_values ) > 1 ) {
5d110fa6 97
e2cdae1f 98 $optvals[SMOPT_GRP_GENERAL][] = array(
99 'name' => 'custom_css',
100 'caption' => _("Custom Stylesheet"),
101 'type' => SMOPT_TYPE_STRLIST,
102 'refresh' => SMOPT_REFRESH_ALL,
103 'posvals' => $css_values
104 );
5d110fa6 105
e2cdae1f 106 }
39d3ec89 107
e557fdb0 108 $language_values = array();
5ba5dc8e 109 foreach ($languages as $lang_key => $lang_attributes) {
110 if (isset($lang_attributes['NAME'])) {
111 $language_values[$lang_key] = $lang_attributes['NAME'];
112 if ( isset($show_alternative_names) &&
113 $show_alternative_names &&
114 isset($lang_attributes['ALTNAME']) ) {
115 $language_values[$lang_key] .= " / " . $lang_attributes['ALTNAME'];
0bb37159 116 }
117 }
ce393174 118 }
5ba5dc8e 119
e557fdb0 120 asort($language_values);
8405d0a4 121 $language_values =
122 array_merge(array('' => _("Default")), $language_values);
ec2c91a1 123 $language = $squirrelmail_language;
5ba5dc8e 124
125 // TODO: maybe we can add count($language_values) check here
126 $optvals[SMOPT_GRP_GENERAL][] = array(
127 'name' => 'language',
128 'caption' => _("Language"),
129 'type' => SMOPT_TYPE_STRLIST,
130 'refresh' => SMOPT_REFRESH_ALL,
131 'posvals' => $language_values,
132 'htmlencoded' => true
133 );
ce393174 134
a3ec3c91 135 /* Set values for the "use javascript" option. */
bbcafebd 136 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 137 'name' => 'javascript_setting',
ce393174 138 'caption' => _("Use Javascript"),
a3ec3c91 139 'type' => SMOPT_TYPE_STRLIST,
140 'refresh' => SMOPT_REFRESH_ALL,
141 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
142 SMPREF_JS_ON => _("Always"),
ae958cd3 143 SMPREF_JS_OFF => _("Never")),
144 'save' => 'save_option_javascript_autodetect',
145 'script' => 'onclick="document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\';"'
a3ec3c91 146 );
147
bbcafebd 148 $optvals[SMOPT_GRP_GENERAL][] = array(
a3ec3c91 149 'name' => 'js_autodetect_results',
150 'caption' => '',
151 'type' => SMOPT_TYPE_HIDDEN,
ae958cd3 152 'refresh' => SMOPT_REFRESH_NONE
5826affb 153 //'post_script' => $js_autodetect_script,
a3ec3c91 154 );
f2df3fa1 155
5bcd1b00 156 $optvals[SMOPT_GRP_GENERAL][] = array(
157 'name' => 'hour_format',
158 'caption' => _("Hour Format"),
159 'type' => SMOPT_TYPE_STRLIST,
160 'refresh' => SMOPT_REFRESH_FOLDERLIST,
161 'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"),
162 SMPREF_TIME_24HR => _("24-hour clock"))
163 );
a3ec3c91 164
bbcafebd 165 /*** Load the General Options into the array ***/
166 $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
167 $optvals[SMOPT_GRP_MAILBOX] = array();
168
169 $optvals[SMOPT_GRP_MAILBOX][] = array(
a3ec3c91 170 'name' => 'show_num',
f2df3fa1 171 'caption' => _("Number of Messages per Page"),
a3ec3c91 172 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 173 'refresh' => SMOPT_REFRESH_NONE,
174 'size' => SMOPT_SIZE_TINY
a3ec3c91 175 );
176
bbcafebd 177 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 178 'name' => 'alt_index_colors',
179 'caption' => _("Enable Alternating Row Colors"),
180 'type' => SMOPT_TYPE_BOOLEAN,
181 'refresh' => SMOPT_REFRESH_NONE
182 );
183
18adc53f 184 $optvals[SMOPT_GRP_MAILBOX][] = array(
185 'name' => 'fancy_index_highlite',
186 'caption' => _("Enable Fancy Row Mouseover Highlighting"),
187 'type' => SMOPT_TYPE_BOOLEAN,
188 'refresh' => SMOPT_REFRESH_NONE
189 );
190
6395c46d 191 if ($use_icons) {
192 global $icon_themes, $icon_theme;
193 $temp = array();
194 for ($count = 0; $count < sizeof($icon_themes); $count++) {
195 $temp[$count] = $icon_themes[$count]['NAME'];
196 if ($icon_theme == $icon_themes[$count]['PATH'])
197 $value = $count;
198 }
4f7a5870 199 if (sizeof($icon_themes) > 0) {
200 $optvals[SMOPT_GRP_MAILBOX][] = array(
201 'name' => 'icon_theme',
202 'caption' => _("Message Flags Icon Theme"),
203 'type' => SMOPT_TYPE_STRLIST,
204 'refresh' => SMOPT_REFRESH_NONE,
205 'posvals' => $temp,
206 'initial_value' => $value,
207 'save' => 'icon_theme_save'
208 );
209 }
6395c46d 210 }
211
fd181f53 212 $optvals[SMOPT_GRP_MAILBOX][] = array(
213 'name' => 'show_flag_buttons',
214 'caption' => _("Show Flag / Unflag Buttons"),
215 'type' => SMOPT_TYPE_BOOLEAN,
216 'refresh' => SMOPT_REFRESH_NONE
217 );
218
bbcafebd 219 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 220 'name' => 'page_selector',
221 'caption' => _("Enable Page Selector"),
222 'type' => SMOPT_TYPE_BOOLEAN,
223 'refresh' => SMOPT_REFRESH_NONE
224 );
225
0bb37159 226 $optvals[SMOPT_GRP_MAILBOX][] = array(
227 'name' => 'compact_paginator',
228 'caption' => _("Use Compact Page Selector"),
229 'type' => SMOPT_TYPE_BOOLEAN,
230 'refresh' => SMOPT_REFRESH_NONE
231 );
232
bbcafebd 233 $optvals[SMOPT_GRP_MAILBOX][] = array(
a440e68f 234 'name' => 'page_selector_max',
235 'caption' => _("Maximum Number of Pages to Show"),
236 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 237 'refresh' => SMOPT_REFRESH_NONE,
238 'size' => SMOPT_SIZE_TINY
a440e68f 239 );
240
3e3b60e3 241 $optvals[SMOPT_GRP_MAILBOX][] = array(
242 'name' => 'show_full_date',
243 'caption' => _("Always Show Full Date"),
244 'type' => SMOPT_TYPE_BOOLEAN,
245 'refresh' => SMOPT_REFRESH_NONE
246 );
247
459e3347 248 $optvals[SMOPT_GRP_MAILBOX][] = array(
249 'name' => 'truncate_sender',
250 'caption' => _("Length of From/To Field (0 for full)"),
251 'type' => SMOPT_TYPE_INTEGER,
252 'refresh' => SMOPT_REFRESH_NONE,
253 'size' => SMOPT_SIZE_TINY
254 );
255
3fc1a95f 256 $optvals[SMOPT_GRP_MAILBOX][] = array(
257 'name' => 'truncate_subject',
258 'caption' => _("Length of Subject Field (0 for full)"),
259 'type' => SMOPT_TYPE_INTEGER,
260 'refresh' => SMOPT_REFRESH_NONE,
261 'size' => SMOPT_SIZE_TINY
262 );
91c27aee 263/*
264 disabled because the template doesn't support it (yet?)
1ae2832e 265 $optvals[SMOPT_GRP_MAILBOX][] = array(
266 'name' => 'show_recipient_instead',
267 'caption' => _("Show recipient name if the message is from your default identity"),
268 'type' => SMOPT_TYPE_BOOLEAN,
269 'refresh' => SMOPT_REFRESH_NONE,
270 'size' => SMOPT_SIZE_TINY
271 );
91c27aee 272*/
f2df3fa1 273
5ed9d4fd 274 if ($allow_thread_sort == TRUE) {
275 $optvals[SMOPT_GRP_MAILBOX][] = array(
276 'name' => 'sort_by_ref',
277 'caption' => _("Enable Thread Sort by References Header"),
278 'type' => SMOPT_TYPE_BOOLEAN,
279 'refresh' => SMOPT_REFRESH_ALL
280 );
281 }
282
1ae2832e 283
459e3347 284
bbcafebd 285 /*** Load the General Options into the array ***/
5ed9d4fd 286 $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display Options");
bbcafebd 287 $optvals[SMOPT_GRP_MESSAGE] = array();
288
289 $optvals[SMOPT_GRP_MESSAGE][] = array(
a3ec3c91 290 'name' => 'wrap_at',
291 'caption' => _("Wrap Incoming Text At"),
292 'type' => SMOPT_TYPE_INTEGER,
bbcafebd 293 'refresh' => SMOPT_REFRESH_NONE,
294 'size' => SMOPT_SIZE_TINY
a3ec3c91 295 );
296
bbcafebd 297 $optvals[SMOPT_GRP_MESSAGE][] = array(
fd87494d 298 'name' => 'show_html_default',
299 'caption' => _("Show HTML Version by Default"),
300 'type' => SMOPT_TYPE_BOOLEAN,
301 'refresh' => SMOPT_REFRESH_NONE
302 );
303
a144f6b8 304 if ($use_iframe) {
305 // Type is set to string in order to be able to use 100%.
306 $optvals[SMOPT_GRP_MESSAGE][] = array(
307 'name' => 'iframe_height',
308 'caption' => _("Height of inline frame"),
309 'type' => SMOPT_TYPE_STRING,
310 'size' => SMOPT_SIZE_TINY,
311 'refresh' => SMOPT_REFRESH_NONE
312 );
313 }
bbcafebd 314 $optvals[SMOPT_GRP_MESSAGE][] = array(
6206f6c4 315 'name' => 'enable_forward_as_attachment',
316 'caption' => _("Enable Forward as Attachment"),
fd87494d 317 'type' => SMOPT_TYPE_BOOLEAN,
318 'refresh' => SMOPT_REFRESH_NONE
319 );
320
bbcafebd 321 $optvals[SMOPT_GRP_MESSAGE][] = array(
9ab0d96f 322 'name' => 'show_xmailer_default',
a440e68f 323 'caption' => _("Enable Mailer Display"),
9ab0d96f 324 'type' => SMOPT_TYPE_BOOLEAN,
325 'refresh' => SMOPT_REFRESH_NONE
326 );
327
7baf86a9 328 $optvals[SMOPT_GRP_MESSAGE][] = array(
329 'name' => 'attachment_common_show_images',
10f0ce72 330 'caption' => _("Display Attached Images with Message"),
7baf86a9 331 'type' => SMOPT_TYPE_BOOLEAN,
332 'refresh' => SMOPT_REFRESH_NONE
333 );
334
57257333 335 if ($default_use_mdn) {
336 $optvals[SMOPT_GRP_MESSAGE][] = array(
337 'name' => 'mdn_user_support',
6206f6c4 338 'caption' => _("Enable Mail Delivery Notification"),
57257333 339 'type' => SMOPT_TYPE_BOOLEAN,
340 'refresh' => SMOPT_REFRESH_NONE
341 );
342 }
07687736 343
4267d5de 344 $optvals[SMOPT_GRP_MESSAGE][] = array(
345 'name' => 'delete_prev_next_display',
346 'caption' => _("Show 'Delete & Prev/Next' Links"),
347 'type' => SMOPT_TYPE_BOOLEAN,
348 'refresh' => SMOPT_REFRESH_ALL
349 );
5d110fa6 350
cbe5423b 351 /* Assemble all this together and return it as our result. */
352 $result = array(
353 'grps' => $optgrps,
ae958cd3 354 'vals' => $optvals
cbe5423b 355 );
356 return ($result);
357}
a3ec3c91 358
cbe5423b 359/******************************************************************/
360/** Define any specialized save functions for this option page. ***/
361/******************************************************************/
f1e6f580 362
48af4b64 363/**
364 * This function saves a new theme setting.
365 * It updates the theme array.
366 */
cbe5423b 367function save_option_theme($option) {
368 global $theme;
bb7173fa 369
cbe5423b 370 /* Do checking to make sure $new_theme is in the array. */
371 $theme_in_array = false;
372 for ($i = 0; $i < count($theme); ++$i) {
373 if ($theme[$i]['PATH'] == $option->new_value) {
374 $theme_in_array = true;
375 break;
376 }
377 }
378
379 if (!$theme_in_array) {
380 $option->new_value = '';
381 }
e7db48af 382
cbe5423b 383 /* Save the option like normal. */
384 save_option($option);
385}
e7db48af 386
48af4b64 387/**
388 * This function saves the javascript detection option.
389 */
cbe5423b 390function save_option_javascript_autodetect($option) {
ae958cd3 391 save_option($option);
392 checkForJavascript(TRUE);
cbe5423b 393}
394
5d110fa6 395/**
6395c46d 396 * This function saves the user's icon theme setting
397 */
398function icon_theme_save($option) {
399
400 global $icon_themes, $data_dir, $username;
401
402
5d110fa6 403 // Don't assume the new value is there, double check
404 // and only save if found
6395c46d 405 //
406 if (isset($icon_themes[$option->new_value]['PATH']))
407 setPref($data_dir, $username, 'icon_theme', $icon_themes[$option->new_value]['PATH']);
408 else
409 setPref($data_dir, $username, 'icon_theme', 'none');
410
411}
412
f8a1ed5a 413?>