6 * Copyright (c) 1999-2002 The SquirrelMail Project 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['NAME']] = $theme_attributes['PATH'];
41 $theme_values = array_flip($theme_values);
42 $optvals[SMOPT_GRP_GENERAL
][] = array(
43 'name' => 'chosen_theme',
44 'caption' => _("Theme"),
45 'type' => SMOPT_TYPE_STRLIST
,
46 'refresh' => SMOPT_REFRESH_ALL
,
47 'posvals' => $theme_values,
48 'save' => 'save_option_theme'
51 $language_values = array();
52 foreach ($languages as $lang_key => $lang_attributes) {
53 if (isset($lang_attributes['NAME'])) {
54 $language_values[$lang_attributes['NAME']] = $lang_key;
57 asort($language_values);
58 $language_values = array_flip($language_values);
59 $optvals[SMOPT_GRP_GENERAL
][] = array(
61 'caption' => _("Language"),
62 'type' => SMOPT_TYPE_STRLIST
,
63 'refresh' => SMOPT_REFRESH_ALL
,
64 'posvals' => $language_values
67 /* Set values for the "use javascript" option. */
68 $optvals[SMOPT_GRP_GENERAL
][] = array(
69 'name' => 'javascript_setting',
70 'caption' => _("Use Javascript"),
71 'type' => SMOPT_TYPE_STRLIST
,
72 'refresh' => SMOPT_REFRESH_ALL
,
73 'posvals' => array(SMPREF_JS_AUTODETECT
=> _("Autodetect"),
74 SMPREF_JS_ON
=> _("Always"),
75 SMPREF_JS_OFF
=> _("Never"))
78 $js_autodetect_script =
79 "<SCRIPT LANGUAGE=\"JavaScript\"><!--\n".
80 "document.forms[0].new_js_autodetect_results.value = '" . SMPREF_JS_ON
. "';\n".
82 $js_autodetect_results = SMPREF_JS_OFF
;
83 $optvals[SMOPT_GRP_GENERAL
][] = array(
84 'name' => 'js_autodetect_results',
86 'type' => SMOPT_TYPE_HIDDEN
,
87 'refresh' => SMOPT_REFRESH_NONE
,
88 'script' => $js_autodetect_script,
89 'save' => 'save_option_javascript_autodetect'
92 /*** Load the General Options into the array ***/
93 $optgrps[SMOPT_GRP_MAILBOX
] = _("Mailbox Display Options");
94 $optvals[SMOPT_GRP_MAILBOX
] = array();
96 $optvals[SMOPT_GRP_MAILBOX
][] = array(
98 'caption' => _("Number of Messages to Index"),
99 'type' => SMOPT_TYPE_INTEGER
,
100 'refresh' => SMOPT_REFRESH_NONE
,
101 'size' => SMOPT_SIZE_TINY
104 $optvals[SMOPT_GRP_MAILBOX
][] = array(
105 'name' => 'alt_index_colors',
106 'caption' => _("Enable Alternating Row Colors"),
107 'type' => SMOPT_TYPE_BOOLEAN
,
108 'refresh' => SMOPT_REFRESH_NONE
111 $optvals[SMOPT_GRP_MAILBOX
][] = array(
112 'name' => 'page_selector',
113 'caption' => _("Enable Page Selector"),
114 'type' => SMOPT_TYPE_BOOLEAN
,
115 'refresh' => SMOPT_REFRESH_NONE
118 $optvals[SMOPT_GRP_MAILBOX
][] = array(
119 'name' => 'page_selector_max',
120 'caption' => _("Maximum Number of Pages to Show"),
121 'type' => SMOPT_TYPE_INTEGER
,
122 'refresh' => SMOPT_REFRESH_NONE
,
123 'size' => SMOPT_SIZE_TINY
126 /*** Load the General Options into the array ***/
127 $optgrps[SMOPT_GRP_MESSAGE
] = _("Message Display and Composition");
128 $optvals[SMOPT_GRP_MESSAGE
] = array();
130 $optvals[SMOPT_GRP_MESSAGE
][] = array(
132 'caption' => _("Wrap Incoming Text At"),
133 'type' => SMOPT_TYPE_INTEGER
,
134 'refresh' => SMOPT_REFRESH_NONE
,
135 'size' => SMOPT_SIZE_TINY
138 $optvals[SMOPT_GRP_MESSAGE
][] = array(
139 'name' => 'editor_size',
140 'caption' => _("Size of Editor Window"),
141 'type' => SMOPT_TYPE_INTEGER
,
142 'refresh' => SMOPT_REFRESH_NONE
,
143 'size' => SMOPT_SIZE_TINY
146 $optvals[SMOPT_GRP_MESSAGE
][] = array(
147 'name' => 'location_of_buttons',
148 'caption' => _("Location of Buttons when Composing"),
149 'type' => SMOPT_TYPE_STRLIST
,
150 'refresh' => SMOPT_REFRESH_NONE
,
151 'posvals' => array(SMPREF_LOC_TOP
=> _("Before headers"),
152 SMPREF_LOC_BETWEEN
=> _("Between headers and message body"),
153 SMPREF_LOC_BOTTOM
=> _("After message body"))
156 $optvals[SMOPT_GRP_MESSAGE
][] = array(
157 'name' => 'use_javascript_addr_book',
158 'caption' => _("Addressbook Display Format"),
159 'type' => SMOPT_TYPE_STRLIST
,
160 'refresh' => SMOPT_REFRESH_NONE
,
161 'posvals' => array('1' => _("Javascript"),
165 $optvals[SMOPT_GRP_MESSAGE
][] = array(
166 'name' => 'show_html_default',
167 'caption' => _("Show HTML Version by Default"),
168 'type' => SMOPT_TYPE_BOOLEAN
,
169 'refresh' => SMOPT_REFRESH_NONE
172 $optvals[SMOPT_GRP_MESSAGE
][] = array(
173 'name' => 'include_self_reply_all',
174 'caption' => _("Include Me in CC when I Reply All"),
175 'type' => SMOPT_TYPE_BOOLEAN
,
176 'refresh' => SMOPT_REFRESH_NONE
179 $optvals[SMOPT_GRP_MESSAGE
][] = array(
180 'name' => 'show_xmailer_default',
181 'caption' => _("Enable Mailer Display"),
182 'type' => SMOPT_TYPE_BOOLEAN
,
183 'refresh' => SMOPT_REFRESH_NONE
186 $optvals[SMOPT_GRP_MESSAGE
][] = array(
187 'name' => 'attachment_common_show_images',
188 'caption' => _("Display Attached Images with Message"),
189 'type' => SMOPT_TYPE_BOOLEAN
,
190 'refresh' => SMOPT_REFRESH_NONE
193 $optvals[SMOPT_GRP_MESSAGE
][] = array(
194 'name' => 'pf_subtle_link',
195 'caption' => _("Enable Subtle Printer Friendly Link"),
196 'type' => SMOPT_TYPE_BOOLEAN
,
197 'refresh' => SMOPT_REFRESH_NONE
200 $optvals[SMOPT_GRP_MESSAGE
][] = array(
201 'name' => 'pf_cleandisplay',
202 'caption' => _("Enable Printer Friendly Clean Display"),
203 'type' => SMOPT_TYPE_BOOLEAN
,
204 'refresh' => SMOPT_REFRESH_NONE
207 /* Assemble all this together and return it as our result. */
215 /******************************************************************/
216 /** Define any specialized save functions for this option page. ***/
217 /******************************************************************/
219 function save_option_theme($option) {
222 /* Do checking to make sure $new_theme is in the array. */
223 $theme_in_array = false;
224 for ($i = 0; $i < count($theme); ++
$i) {
225 if ($theme[$i]['PATH'] == $option->new_value
) {
226 $theme_in_array = true;
231 if (!$theme_in_array) {
232 $option->new_value
= '';
235 /* Save the option like normal. */
236 save_option($option);
239 function save_option_javascript_autodetect($option) {
240 global $data_dir, $username, $new_javascript_setting;
242 /* Set javascript either on or off. */
243 if ($new_javascript_setting == SMPREF_JS_AUTODETECT
) {
244 if ($option->new_value
== SMPREF_JS_ON
) {
245 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON
);
247 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF
);
250 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);