6 * Copyright (c) 1999-2001 The Squirrelmail Development Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Displays all optinos about display preferences
14 /* Define the group constants for the display options page. */
15 define('SMOPT_GRP_GENERAL', 0);
16 define('SMOPT_GRP_MAILBOX', 1);
17 define('SMOPT_GRP_MESSAGE', 2);
19 /* Define the optpage load function for the display options page. */
20 function load_optpage_data_display() {
21 global $theme, $languages, $js_autodetect_results;
23 /* Build a simple array into which we will build options. */
27 /******************************************************/
28 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
29 /******************************************************/
31 /*** Load the General Options into the array ***/
32 $optgrps[SMOPT_GRP_GENERAL
] = _("General Display Options");
33 $optvals[SMOPT_GRP_GENERAL
] = array();
35 /* Load the theme option. */
36 $theme_values = array();
37 foreach ($theme as $theme_key => $theme_attributes) {
38 $theme_values[$theme_attributes['PATH']] = $theme_attributes['NAME'];
40 $optvals[SMOPT_GRP_GENERAL
][] = array(
41 'name' => 'chosen_theme',
42 'caption' => _("Theme"),
43 'type' => SMOPT_TYPE_STRLIST
,
44 'refresh' => SMOPT_REFRESH_ALL
,
45 'posvals' => $theme_values,
46 'save' => 'save_option_theme'
49 $language_values = array('');
50 foreach ($languages as $lang_key => $lang_attributes) {
51 if (isset($lang_attributes['NAME'])) {
52 $language_values[$lang_key] = $lang_attributes['NAME'];
55 $optvals[SMOPT_GRP_GENERAL
][] = array(
57 'caption' => _("Language"),
58 'type' => SMOPT_TYPE_STRLIST
,
59 'refresh' => SMOPT_REFRESH_ALL
,
60 'posvals' => $language_values
63 /* Set values for the "use javascript" option. */
64 $optvals[SMOPT_GRP_GENERAL
][] = array(
65 'name' => 'javascript_setting',
66 'caption' => _("Use Javascript"),
67 'type' => SMOPT_TYPE_STRLIST
,
68 'refresh' => SMOPT_REFRESH_ALL
,
69 'posvals' => array(SMPREF_JS_AUTODETECT
=> _("Autodetect"),
70 SMPREF_JS_ON
=> _("Always"),
71 SMPREF_JS_OFF
=> _("Never"))
74 $js_autodetect_script =
75 "<SCRIPT LANGUAGE=\"JavaScript\"><!--\n".
76 "document.forms[0].new_js_autodetect_results.value = '" . SMPREF_JS_ON
. "';\n".
78 $js_autodetect_results = SMPREF_JS_OFF
;
79 $optvals[SMOPT_GRP_GENERAL
][] = array(
80 'name' => 'js_autodetect_results',
82 'type' => SMOPT_TYPE_HIDDEN
,
83 'refresh' => SMOPT_REFRESH_NONE
,
84 'script' => $js_autodetect_script,
85 'save' => 'save_option_javascript_autodetect'
88 /*** Load the General Options into the array ***/
89 $optgrps[SMOPT_GRP_MAILBOX
] = _("Mailbox Display Options");
90 $optvals[SMOPT_GRP_MAILBOX
] = array();
92 $optvals[SMOPT_GRP_MAILBOX
][] = array(
94 'caption' => _("Number of Messages to Index"),
95 'type' => SMOPT_TYPE_INTEGER
,
96 'refresh' => SMOPT_REFRESH_NONE
,
97 'size' => SMOPT_SIZE_TINY
100 $optvals[SMOPT_GRP_MAILBOX
][] = array(
101 'name' => 'alt_index_colors',
102 'caption' => _("Enable Alternating Row Colors"),
103 'type' => SMOPT_TYPE_BOOLEAN
,
104 'refresh' => SMOPT_REFRESH_NONE
107 $optvals[SMOPT_GRP_MAILBOX
][] = array(
108 'name' => 'page_selector',
109 'caption' => _("Enable Page Selector"),
110 'type' => SMOPT_TYPE_BOOLEAN
,
111 'refresh' => SMOPT_REFRESH_NONE
114 $optvals[SMOPT_GRP_MAILBOX
][] = array(
115 'name' => 'page_selector_max',
116 'caption' => _("Maximum Number of Pages to Show"),
117 'type' => SMOPT_TYPE_INTEGER
,
118 'refresh' => SMOPT_REFRESH_NONE
,
119 'size' => SMOPT_SIZE_TINY
122 /*** Load the General Options into the array ***/
123 $optgrps[SMOPT_GRP_MESSAGE
] = _("Message Display and Composition");
124 $optvals[SMOPT_GRP_MESSAGE
] = array();
126 $optvals[SMOPT_GRP_MESSAGE
][] = array(
128 'caption' => _("Wrap Incoming Text At"),
129 'type' => SMOPT_TYPE_INTEGER
,
130 'refresh' => SMOPT_REFRESH_NONE
,
131 'size' => SMOPT_SIZE_TINY
134 $optvals[SMOPT_GRP_MESSAGE
][] = array(
135 'name' => 'editor_size',
136 'caption' => _("Size of Editor Window"),
137 'type' => SMOPT_TYPE_INTEGER
,
138 'refresh' => SMOPT_REFRESH_NONE
,
139 'size' => SMOPT_SIZE_TINY
142 $optvals[SMOPT_GRP_MESSAGE
][] = array(
143 'name' => 'location_of_buttons',
144 'caption' => _("Location of Buttons when Composing"),
145 'type' => SMOPT_TYPE_STRLIST
,
146 'refresh' => SMOPT_REFRESH_NONE
,
147 'posvals' => array(SMPREF_LOC_TOP
=> _("Before headers"),
148 SMPREF_LOC_BETWEEN
=> _("Between headers and message body"),
149 SMPREF_LOC_BOTTOM
=> _("After message body"))
152 $optvals[SMOPT_GRP_MESSAGE
][] = array(
153 'name' => 'use_javascript_addr_book',
154 'caption' => _("Addressbook Display Format"),
155 'type' => SMOPT_TYPE_STRLIST
,
156 'refresh' => SMOPT_REFRESH_NONE
,
157 'posvals' => array('1' => _("Javascript"),
161 $optvals[SMOPT_GRP_MESSAGE
][] = array(
162 'name' => 'show_html_default',
163 'caption' => _("Show HTML Version by Default"),
164 'type' => SMOPT_TYPE_BOOLEAN
,
165 'refresh' => SMOPT_REFRESH_NONE
168 $optvals[SMOPT_GRP_MESSAGE
][] = array(
169 'name' => 'include_self_reply_all',
170 'caption' => _("Include Me in CC when I Reply All"),
171 'type' => SMOPT_TYPE_BOOLEAN
,
172 'refresh' => SMOPT_REFRESH_NONE
175 $optvals[SMOPT_GRP_MESSAGE
][] = array(
176 'name' => 'show_xmailer_default',
177 'caption' => _("Enable Mailer Display"),
178 'type' => SMOPT_TYPE_BOOLEAN
,
179 'refresh' => SMOPT_REFRESH_NONE
182 $optvals[SMOPT_GRP_MESSAGE
][] = array(
183 'name' => 'attachment_common_show_images',
184 'caption' => _("Display Attached Images with Message"),
185 'type' => SMOPT_TYPE_BOOLEAN
,
186 'refresh' => SMOPT_REFRESH_NONE
189 $optvals[SMOPT_GRP_MESSAGE
][] = array(
190 'name' => 'pf_subtle_link',
191 'caption' => _("Enable Subtle Printer Friendly Link"),
192 'type' => SMOPT_TYPE_BOOLEAN
,
193 'refresh' => SMOPT_REFRESH_NONE
196 $optvals[SMOPT_GRP_MESSAGE
][] = array(
197 'name' => 'pf_cleandisplay',
198 'caption' => _("Enable Printer Friendly Clean Display"),
199 'type' => SMOPT_TYPE_BOOLEAN
,
200 'refresh' => SMOPT_REFRESH_NONE
203 /* Assemble all this together and return it as our result. */
211 /******************************************************************/
212 /** Define any specialized save functions for this option page. ***/
213 /******************************************************************/
215 function save_option_theme($option) {
218 /* Do checking to make sure $new_theme is in the array. */
219 $theme_in_array = false;
220 for ($i = 0; $i < count($theme); ++
$i) {
221 if ($theme[$i]['PATH'] == $option->new_value
) {
222 $theme_in_array = true;
227 if (!$theme_in_array) {
228 $option->new_value
= '';
231 /* Save the option like normal. */
232 save_option($option);
235 function save_option_javascript_autodetect($option) {
236 global $data_dir, $username, $new_javascript_setting;
238 /* Set javascript either on or off. */
239 if ($new_javascript_setting == SMPREF_JS_AUTODETECT
) {
240 if ($option->new_value
== SMPREF_JS_ON
) {
241 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON
);
243 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF
);
246 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);