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, $language, $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_key] = $lang_attributes['NAME'];
57 asort($language_values);
59 array_merge(array('' => _("Default")), $language_values);
60 $optvals[SMOPT_GRP_GENERAL
][] = array(
62 'caption' => _("Language"),
63 'type' => SMOPT_TYPE_STRLIST
,
64 'refresh' => SMOPT_REFRESH_ALL
,
65 'posvals' => $language_values
68 /* Set values for the "use javascript" option. */
69 $optvals[SMOPT_GRP_GENERAL
][] = array(
70 'name' => 'javascript_setting',
71 'caption' => _("Use Javascript"),
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"))
79 $js_autodetect_script =
80 "<SCRIPT LANGUAGE=\"JavaScript\"><!--\n".
81 "document.forms[0].new_js_autodetect_results.value = '" . SMPREF_JS_ON
. "';\n".
83 $js_autodetect_results = SMPREF_JS_OFF
;
84 $optvals[SMOPT_GRP_GENERAL
][] = array(
85 'name' => 'js_autodetect_results',
87 'type' => SMOPT_TYPE_HIDDEN
,
88 'refresh' => SMOPT_REFRESH_NONE
,
89 'script' => $js_autodetect_script,
90 'save' => 'save_option_javascript_autodetect'
93 /*** Load the General Options into the array ***/
94 $optgrps[SMOPT_GRP_MAILBOX
] = _("Mailbox Display Options");
95 $optvals[SMOPT_GRP_MAILBOX
] = array();
97 $optvals[SMOPT_GRP_MAILBOX
][] = array(
99 'caption' => _("Number of Messages to Index"),
100 'type' => SMOPT_TYPE_INTEGER
,
101 'refresh' => SMOPT_REFRESH_NONE
,
102 'size' => SMOPT_SIZE_TINY
105 $optvals[SMOPT_GRP_MAILBOX
][] = array(
106 'name' => 'alt_index_colors',
107 'caption' => _("Enable Alternating Row Colors"),
108 'type' => SMOPT_TYPE_BOOLEAN
,
109 'refresh' => SMOPT_REFRESH_NONE
112 $optvals[SMOPT_GRP_MAILBOX
][] = array(
113 'name' => 'page_selector',
114 'caption' => _("Enable Page Selector"),
115 'type' => SMOPT_TYPE_BOOLEAN
,
116 'refresh' => SMOPT_REFRESH_NONE
119 $optvals[SMOPT_GRP_MAILBOX
][] = array(
120 'name' => 'page_selector_max',
121 'caption' => _("Maximum Number of Pages to Show"),
122 'type' => SMOPT_TYPE_INTEGER
,
123 'refresh' => SMOPT_REFRESH_NONE
,
124 'size' => SMOPT_SIZE_TINY
127 /*** Load the General Options into the array ***/
128 $optgrps[SMOPT_GRP_MESSAGE
] = _("Message Display and Composition");
129 $optvals[SMOPT_GRP_MESSAGE
] = array();
131 $optvals[SMOPT_GRP_MESSAGE
][] = array(
133 'caption' => _("Wrap Incoming Text At"),
134 'type' => SMOPT_TYPE_INTEGER
,
135 'refresh' => SMOPT_REFRESH_NONE
,
136 'size' => SMOPT_SIZE_TINY
139 $optvals[SMOPT_GRP_MESSAGE
][] = array(
140 'name' => 'editor_size',
141 'caption' => _("Size of Editor Window"),
142 'type' => SMOPT_TYPE_INTEGER
,
143 'refresh' => SMOPT_REFRESH_NONE
,
144 'size' => SMOPT_SIZE_TINY
147 $optvals[SMOPT_GRP_MESSAGE
][] = array(
148 'name' => 'location_of_buttons',
149 'caption' => _("Location of Buttons when Composing"),
150 'type' => SMOPT_TYPE_STRLIST
,
151 'refresh' => SMOPT_REFRESH_NONE
,
152 'posvals' => array(SMPREF_LOC_TOP
=> _("Before headers"),
153 SMPREF_LOC_BETWEEN
=> _("Between headers and message body"),
154 SMPREF_LOC_BOTTOM
=> _("After message body"))
157 $optvals[SMOPT_GRP_MESSAGE
][] = array(
158 'name' => 'use_javascript_addr_book',
159 'caption' => _("Addressbook Display Format"),
160 'type' => SMOPT_TYPE_STRLIST
,
161 'refresh' => SMOPT_REFRESH_NONE
,
162 'posvals' => array('1' => _("Javascript"),
166 $optvals[SMOPT_GRP_MESSAGE
][] = array(
167 'name' => 'show_html_default',
168 'caption' => _("Show HTML Version by Default"),
169 'type' => SMOPT_TYPE_BOOLEAN
,
170 'refresh' => SMOPT_REFRESH_NONE
173 $optvals[SMOPT_GRP_MESSAGE
][] = array(
174 'name' => 'include_self_reply_all',
175 'caption' => _("Include Me in CC when I Reply All"),
176 'type' => SMOPT_TYPE_BOOLEAN
,
177 'refresh' => SMOPT_REFRESH_NONE
180 $optvals[SMOPT_GRP_MESSAGE
][] = array(
181 'name' => 'show_xmailer_default',
182 'caption' => _("Enable Mailer Display"),
183 'type' => SMOPT_TYPE_BOOLEAN
,
184 'refresh' => SMOPT_REFRESH_NONE
187 $optvals[SMOPT_GRP_MESSAGE
][] = array(
188 'name' => 'attachment_common_show_images',
189 'caption' => _("Display Attached Images with Message"),
190 'type' => SMOPT_TYPE_BOOLEAN
,
191 'refresh' => SMOPT_REFRESH_NONE
194 $optvals[SMOPT_GRP_MESSAGE
][] = array(
195 'name' => 'pf_subtle_link',
196 'caption' => _("Enable Subtle Printer Friendly Link"),
197 'type' => SMOPT_TYPE_BOOLEAN
,
198 'refresh' => SMOPT_REFRESH_NONE
201 $optvals[SMOPT_GRP_MESSAGE
][] = array(
202 'name' => 'pf_cleandisplay',
203 'caption' => _("Enable Printer Friendly Clean Display"),
204 'type' => SMOPT_TYPE_BOOLEAN
,
205 'refresh' => SMOPT_REFRESH_NONE
208 /* Assemble all this together and return it as our result. */
216 /******************************************************************/
217 /** Define any specialized save functions for this option page. ***/
218 /******************************************************************/
220 function save_option_theme($option) {
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;
232 if (!$theme_in_array) {
233 $option->new_value
= '';
236 /* Save the option like normal. */
237 save_option($option);
240 function save_option_javascript_autodetect($option) {
241 global $data_dir, $username, $new_javascript_setting;
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
);
248 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF
);
251 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);