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_key] = $lang_attributes['NAME'];
57 asort($language_values);
58 $optvals[SMOPT_GRP_GENERAL
][] = array(
60 'caption' => _("Language"),
61 'type' => SMOPT_TYPE_STRLIST
,
62 'refresh' => SMOPT_REFRESH_ALL
,
63 'posvals' => $language_values
66 /* Set values for the "use javascript" option. */
67 $optvals[SMOPT_GRP_GENERAL
][] = array(
68 'name' => 'javascript_setting',
69 'caption' => _("Use Javascript"),
70 'type' => SMOPT_TYPE_STRLIST
,
71 'refresh' => SMOPT_REFRESH_ALL
,
72 'posvals' => array(SMPREF_JS_AUTODETECT
=> _("Autodetect"),
73 SMPREF_JS_ON
=> _("Always"),
74 SMPREF_JS_OFF
=> _("Never"))
77 $js_autodetect_script =
78 "<SCRIPT LANGUAGE=\"JavaScript\"><!--\n".
79 "document.forms[0].new_js_autodetect_results.value = '" . SMPREF_JS_ON
. "';\n".
81 $js_autodetect_results = SMPREF_JS_OFF
;
82 $optvals[SMOPT_GRP_GENERAL
][] = array(
83 'name' => 'js_autodetect_results',
85 'type' => SMOPT_TYPE_HIDDEN
,
86 'refresh' => SMOPT_REFRESH_NONE
,
87 'script' => $js_autodetect_script,
88 'save' => 'save_option_javascript_autodetect'
91 /*** Load the General Options into the array ***/
92 $optgrps[SMOPT_GRP_MAILBOX
] = _("Mailbox Display Options");
93 $optvals[SMOPT_GRP_MAILBOX
] = array();
95 $optvals[SMOPT_GRP_MAILBOX
][] = array(
97 'caption' => _("Number of Messages to Index"),
98 'type' => SMOPT_TYPE_INTEGER
,
99 'refresh' => SMOPT_REFRESH_NONE
,
100 'size' => SMOPT_SIZE_TINY
103 $optvals[SMOPT_GRP_MAILBOX
][] = array(
104 'name' => 'alt_index_colors',
105 'caption' => _("Enable Alternating Row Colors"),
106 'type' => SMOPT_TYPE_BOOLEAN
,
107 'refresh' => SMOPT_REFRESH_NONE
110 $optvals[SMOPT_GRP_MAILBOX
][] = array(
111 'name' => 'page_selector',
112 'caption' => _("Enable Page Selector"),
113 'type' => SMOPT_TYPE_BOOLEAN
,
114 'refresh' => SMOPT_REFRESH_NONE
117 $optvals[SMOPT_GRP_MAILBOX
][] = array(
118 'name' => 'page_selector_max',
119 'caption' => _("Maximum Number of Pages to Show"),
120 'type' => SMOPT_TYPE_INTEGER
,
121 'refresh' => SMOPT_REFRESH_NONE
,
122 'size' => SMOPT_SIZE_TINY
125 /*** Load the General Options into the array ***/
126 $optgrps[SMOPT_GRP_MESSAGE
] = _("Message Display and Composition");
127 $optvals[SMOPT_GRP_MESSAGE
] = array();
129 $optvals[SMOPT_GRP_MESSAGE
][] = array(
131 'caption' => _("Wrap Incoming Text At"),
132 'type' => SMOPT_TYPE_INTEGER
,
133 'refresh' => SMOPT_REFRESH_NONE
,
134 'size' => SMOPT_SIZE_TINY
137 $optvals[SMOPT_GRP_MESSAGE
][] = array(
138 'name' => 'editor_size',
139 'caption' => _("Size of Editor Window"),
140 'type' => SMOPT_TYPE_INTEGER
,
141 'refresh' => SMOPT_REFRESH_NONE
,
142 'size' => SMOPT_SIZE_TINY
145 $optvals[SMOPT_GRP_MESSAGE
][] = array(
146 'name' => 'location_of_buttons',
147 'caption' => _("Location of Buttons when Composing"),
148 'type' => SMOPT_TYPE_STRLIST
,
149 'refresh' => SMOPT_REFRESH_NONE
,
150 'posvals' => array(SMPREF_LOC_TOP
=> _("Before headers"),
151 SMPREF_LOC_BETWEEN
=> _("Between headers and message body"),
152 SMPREF_LOC_BOTTOM
=> _("After message body"))
155 $optvals[SMOPT_GRP_MESSAGE
][] = array(
156 'name' => 'use_javascript_addr_book',
157 'caption' => _("Addressbook Display Format"),
158 'type' => SMOPT_TYPE_STRLIST
,
159 'refresh' => SMOPT_REFRESH_NONE
,
160 'posvals' => array('1' => _("Javascript"),
164 $optvals[SMOPT_GRP_MESSAGE
][] = array(
165 'name' => 'show_html_default',
166 'caption' => _("Show HTML Version by Default"),
167 'type' => SMOPT_TYPE_BOOLEAN
,
168 'refresh' => SMOPT_REFRESH_NONE
171 $optvals[SMOPT_GRP_MESSAGE
][] = array(
172 'name' => 'include_self_reply_all',
173 'caption' => _("Include Me in CC when I Reply All"),
174 'type' => SMOPT_TYPE_BOOLEAN
,
175 'refresh' => SMOPT_REFRESH_NONE
178 $optvals[SMOPT_GRP_MESSAGE
][] = array(
179 'name' => 'show_xmailer_default',
180 'caption' => _("Enable Mailer Display"),
181 'type' => SMOPT_TYPE_BOOLEAN
,
182 'refresh' => SMOPT_REFRESH_NONE
185 $optvals[SMOPT_GRP_MESSAGE
][] = array(
186 'name' => 'attachment_common_show_images',
187 'caption' => _("Display Attached Images with Message"),
188 'type' => SMOPT_TYPE_BOOLEAN
,
189 'refresh' => SMOPT_REFRESH_NONE
192 $optvals[SMOPT_GRP_MESSAGE
][] = array(
193 'name' => 'pf_subtle_link',
194 'caption' => _("Enable Subtle Printer Friendly Link"),
195 'type' => SMOPT_TYPE_BOOLEAN
,
196 'refresh' => SMOPT_REFRESH_NONE
199 $optvals[SMOPT_GRP_MESSAGE
][] = array(
200 'name' => 'pf_cleandisplay',
201 'caption' => _("Enable Printer Friendly Clean Display"),
202 'type' => SMOPT_TYPE_BOOLEAN
,
203 'refresh' => SMOPT_REFRESH_NONE
206 /* Assemble all this together and return it as our result. */
214 /******************************************************************/
215 /** Define any specialized save functions for this option page. ***/
216 /******************************************************************/
218 function save_option_theme($option) {
221 /* Do checking to make sure $new_theme is in the array. */
222 $theme_in_array = false;
223 for ($i = 0; $i < count($theme); ++
$i) {
224 if ($theme[$i]['PATH'] == $option->new_value
) {
225 $theme_in_array = true;
230 if (!$theme_in_array) {
231 $option->new_value
= '';
234 /* Save the option like normal. */
235 save_option($option);
238 function save_option_javascript_autodetect($option) {
239 global $data_dir, $username, $new_javascript_setting;
241 /* Set javascript either on or off. */
242 if ($new_javascript_setting == SMPREF_JS_AUTODETECT
) {
243 if ($option->new_value
== SMPREF_JS_ON
) {
244 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON
);
246 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF
);
249 setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);