Source for file display.php

Documentation is available at display.php

  1. <?php
  2. /**
  3. * options_display.php
  4. *
  5. * Displays all optinos about display preferences
  6. *
  7. * @copyright 1999-2020 The SquirrelMail Project Team
  8. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9. * @version $Id: display.php 14840 2020年01月07日 07:42:38Z pdontthink $
  10. * @package squirrelmail
  11. */
  12. /** Define the group constants for the display options page. */
  13. define ('SMOPT_GRP_GENERAL', 0);
  14. define ('SMOPT_GRP_MAILBOX', 1);
  15. define ('SMOPT_GRP_MESSAGE', 2);
  16. /**
  17. * This function builds an array with all the information about
  18. * the options available to the user, and returns it. The options
  19. * are grouped by the groups in which they are displayed.
  20. * For each option, the following information is stored:
  21. * - name: the internal (variable) name
  22. * - caption: the description of the option in the UI
  23. * - type: one of SMOPT_TYPE_*
  24. * - refresh: one of SMOPT_REFRESH_*
  25. * - size: one of SMOPT_SIZE_*
  26. * - save: the name of a function to call when saving this option
  27. * @return array all option information
  28. */
  29. global $theme , $language, $languages , $js_autodetect_results,
  30. $compose_new_win, $default_use_mdn , $squirrelmail_language, $allow_thread_sort ,
  31. $optmode;
  32. /* Build a simple array into which we will build options. */
  33. $optgrps = array();
  34. $optvals = array();
  35. /******************************************************/
  36. /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
  37. /******************************************************/
  38. /*** Load the General Options into the array ***/
  39. $optgrps[SMOPT_GRP_GENERAL ] = _ ("General Display Options");
  40. $optvals[SMOPT_GRP_GENERAL ] = array();
  41. /* Load the theme option. */
  42. $theme_values = array();
  43. foreach ($theme as $theme_key => $theme_attributes) {
  44. $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
  45. }
  46. ksort ($theme_values);
  47. $theme_values = array_flip ($theme_values);
  48. $optvals[SMOPT_GRP_GENERAL ][] = array(
  49. 'name' => 'chosen_theme',
  50. 'caption' => _ ("Theme"),
  51. 'type' => SMOPT_TYPE_STRLIST ,
  52. 'refresh' => SMOPT_REFRESH_ALL ,
  53. 'posvals' => $theme_values,
  54. 'save' => 'save_option_theme'
  55. );
  56. $css_values = array( 'none' => _ ("Default" ) );
  57. $css_dir = SM_PATH . 'themes/css';
  58. if (is_readable ($css_dir) && is_dir ($css_dir)) {
  59. $handle=opendir ($css_dir);
  60. while ($file = readdir ($handle) ) {
  61. if ( substr ( $file, -4 ) == '.css' ) {
  62. $css_values[$file] = substr ( $file, 0, strlen ( $file ) - 4 );
  63. }
  64. }
  65. closedir ($handle);
  66. }
  67. asort ($css_values);
  68. if ( count ( $css_values ) > 1 ) {
  69. $optvals[SMOPT_GRP_GENERAL ][] = array(
  70. 'name' => 'custom_css',
  71. 'caption' => _ ("Custom Stylesheet"),
  72. 'type' => SMOPT_TYPE_STRLIST ,
  73. 'refresh' => SMOPT_REFRESH_ALL ,
  74. 'posvals' => $css_values
  75. );
  76. }
  77. $language_values = array();
  78. foreach ($languages as $lang_key => $lang_attributes) {
  79. if (isset($lang_attributes['NAME'])) {
  80. $language_values[$lang_key] = $lang_attributes['NAME'];
  81. }
  82. }
  83. asort ($language_values);
  84. $language_values =
  85. array_merge (array('' => _ ("Default")), $language_values);
  86. $language = $squirrelmail_language;
  87. $optvals[SMOPT_GRP_GENERAL ][] = array(
  88. 'name' => 'language',
  89. 'caption' => _ ("Language"),
  90. 'type' => SMOPT_TYPE_STRLIST ,
  91. 'refresh' => SMOPT_REFRESH_ALL ,
  92. 'posvals' => $language_values,
  93. 'htmlencoded' => true
  94. );
  95. /* Set values for the "use javascript" option. */
  96. $optvals[SMOPT_GRP_GENERAL ][] = array(
  97. 'name' => 'javascript_setting',
  98. 'caption' => _ ("Use Javascript"),
  99. 'type' => SMOPT_TYPE_STRLIST ,
  100. 'refresh' => SMOPT_REFRESH_ALL ,
  101. 'posvals' => array(SMPREF_JS_AUTODETECT => _ ("Autodetect"),
  102. SMPREF_JS_ON => _ ("Always"),
  103. SMPREF_JS_OFF => _ ("Never"))
  104. );
  105. if ($optmode != 'submit')
  106. // FIXME: our form is named "f" - why? let's use something better
  107. $onLoadScript = 'document.f.new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\'';
  108. else
  109. $onLoadScript = '';
  110. $optvals[SMOPT_GRP_GENERAL ][] = array(
  111. 'name' => 'js_autodetect_results',
  112. 'caption' => '',
  113. 'type' => SMOPT_TYPE_HIDDEN ,
  114. 'refresh' => SMOPT_REFRESH_NONE ,
  115. //'post_script' => $js_autodetect_script,
  116. 'save' => 'save_option_javascript_autodetect'
  117. );
  118. /*** Load the General Options into the array ***/
  119. $optgrps[SMOPT_GRP_MAILBOX ] = _ ("Mailbox Display Options");
  120. $optvals[SMOPT_GRP_MAILBOX ] = array();
  121. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  122. 'name' => 'show_num',
  123. 'caption' => _ ("Number of Messages per Page"),
  124. 'type' => SMOPT_TYPE_INTEGER ,
  125. 'refresh' => SMOPT_REFRESH_NONE ,
  126. 'size' => SMOPT_SIZE_TINY
  127. );
  128. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  129. 'name' => 'alt_index_colors',
  130. 'caption' => _ ("Enable Alternating Row Colors"),
  131. 'type' => SMOPT_TYPE_BOOLEAN ,
  132. 'refresh' => SMOPT_REFRESH_NONE
  133. );
  134. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  135. 'name' => 'page_selector',
  136. 'caption' => _ ("Enable Page Selector"),
  137. 'type' => SMOPT_TYPE_BOOLEAN ,
  138. 'refresh' => SMOPT_REFRESH_NONE
  139. );
  140. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  141. 'name' => 'page_selector_max',
  142. 'caption' => _ ("Maximum Number of Pages to Show"),
  143. 'type' => SMOPT_TYPE_INTEGER ,
  144. 'refresh' => SMOPT_REFRESH_NONE ,
  145. 'size' => SMOPT_SIZE_TINY
  146. );
  147. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  148. 'name' => 'show_full_date',
  149. 'caption' => _ ("Always Show Full Date"),
  150. 'type' => SMOPT_TYPE_BOOLEAN ,
  151. 'refresh' => SMOPT_REFRESH_NONE
  152. );
  153. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  154. 'name' => 'truncate_sender',
  155. 'caption' => _ ("Length of From/To Field (0 for full)"),
  156. 'type' => SMOPT_TYPE_INTEGER ,
  157. 'refresh' => SMOPT_REFRESH_NONE ,
  158. 'size' => SMOPT_SIZE_TINY ,
  159. 'initial_value' => 55
  160. );
  161. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  162. 'name' => 'truncate_subject',
  163. 'caption' => _ ("Length of Subject Field (0 for full)"),
  164. 'type' => SMOPT_TYPE_INTEGER ,
  165. 'refresh' => SMOPT_REFRESH_NONE ,
  166. 'size' => SMOPT_SIZE_TINY ,
  167. 'initial_value' => 55
  168. );
  169. /*** Load the General Options into the array ***/
  170. $optgrps[SMOPT_GRP_MESSAGE ] = _ ("Message Display and Composition");
  171. $optvals[SMOPT_GRP_MESSAGE ] = array();
  172. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  173. 'name' => 'wrap_at',
  174. 'caption' => _ ("Wrap Incoming Text At"),
  175. 'type' => SMOPT_TYPE_INTEGER ,
  176. 'refresh' => SMOPT_REFRESH_NONE ,
  177. 'size' => SMOPT_SIZE_TINY
  178. );
  179. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  180. 'name' => 'editor_size',
  181. 'caption' => _ ("Width of Editor Window"),
  182. 'type' => SMOPT_TYPE_INTEGER ,
  183. 'refresh' => SMOPT_REFRESH_NONE ,
  184. 'size' => SMOPT_SIZE_TINY
  185. );
  186. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  187. 'name' => 'editor_height',
  188. 'caption' => _ ("Height of Editor Window"),
  189. 'type' => SMOPT_TYPE_INTEGER ,
  190. 'refresh' => SMOPT_REFRESH_NONE ,
  191. 'size' => SMOPT_SIZE_TINY
  192. );
  193. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  194. 'name' => 'location_of_buttons',
  195. 'caption' => _ ("Location of Buttons when Composing"),
  196. 'type' => SMOPT_TYPE_STRLIST ,
  197. 'refresh' => SMOPT_REFRESH_NONE ,
  198. 'posvals' => array(SMPREF_LOC_TOP => _ ("Before headers"),
  199. SMPREF_LOC_BETWEEN => _ ("Between headers and message body"),
  200. SMPREF_LOC_BOTTOM => _ ("After message body"))
  201. );
  202. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  203. 'name' => 'use_javascript_addr_book',
  204. 'caption' => _ ("Address Book Display Format"),
  205. 'type' => SMOPT_TYPE_STRLIST ,
  206. 'refresh' => SMOPT_REFRESH_NONE ,
  207. 'posvals' => array('1' => _ ("Javascript"),
  208. '0' => _ ("HTML"))
  209. );
  210. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  211. 'name' => 'addrsrch_fullname',
  212. 'caption' => _ ("Format of Addresses Added From Address Book"),
  213. 'type' => SMOPT_TYPE_STRLIST ,
  214. 'refresh' => SMOPT_REFRESH_NONE ,
  215. 'posvals' => array('noprefix' => _ ("No prefix/Address only"),
  216. 'nickname' => _ ("Nickname and address"),
  217. 'fullname' => _ ("Full name and address"))
  218. );
  219. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  220. 'name' => 'show_html_default',
  221. 'caption' => _ ("Show HTML Version by Default"),
  222. 'type' => SMOPT_TYPE_BOOLEAN ,
  223. 'refresh' => SMOPT_REFRESH_NONE
  224. );
  225. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  226. 'name' => 'enable_forward_as_attachment',
  227. 'caption' => _ ("Enable Forward as Attachment"),
  228. 'type' => SMOPT_TYPE_BOOLEAN ,
  229. 'refresh' => SMOPT_REFRESH_NONE
  230. );
  231. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  232. 'name' => 'do_not_reply_to_self',
  233. 'caption' => _ ("Send Replies To My Own Messages To Previous Recipient"),
  234. 'type' => SMOPT_TYPE_BOOLEAN ,
  235. 'refresh' => SMOPT_REFRESH_NONE
  236. );
  237. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  238. 'name' => 'include_self_reply_all',
  239. 'caption' => _ ("Include Me in CC when I Reply All"),
  240. 'type' => SMOPT_TYPE_BOOLEAN ,
  241. 'refresh' => SMOPT_REFRESH_NONE
  242. );
  243. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  244. 'name' => 'return_to_message_after_reply',
  245. 'caption' => _ ("Return to Original Message After Replying"),
  246. 'type' => SMOPT_TYPE_BOOLEAN ,
  247. 'refresh' => SMOPT_REFRESH_NONE
  248. );
  249. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  250. 'name' => 'show_xmailer_default',
  251. 'caption' => _ ("Enable Mailer Display"),
  252. 'type' => SMOPT_TYPE_BOOLEAN ,
  253. 'refresh' => SMOPT_REFRESH_NONE
  254. );
  255. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  256. 'name' => 'attachment_common_show_images',
  257. 'caption' => _ ("Display Attached Images with Message"),
  258. 'type' => SMOPT_TYPE_BOOLEAN ,
  259. 'refresh' => SMOPT_REFRESH_NONE
  260. );
  261. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  262. 'name' => 'pf_cleandisplay',
  263. 'caption' => _ ("Enable Printer Friendly Clean Display"),
  264. 'type' => SMOPT_TYPE_BOOLEAN ,
  265. 'refresh' => SMOPT_REFRESH_NONE
  266. );
  267. if ($default_use_mdn) {
  268. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  269. 'name' => 'mdn_user_support',
  270. 'caption' => _ ("Enable Mail Delivery Notification"),
  271. 'type' => SMOPT_TYPE_BOOLEAN ,
  272. 'refresh' => SMOPT_REFRESH_NONE
  273. );
  274. }
  275. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  276. 'name' => 'compose_new_win',
  277. 'caption' => _ ("Compose Messages in New Window"),
  278. 'type' => SMOPT_TYPE_BOOLEAN ,
  279. 'refresh' => SMOPT_REFRESH_ALL
  280. );
  281. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  282. 'name' => 'compose_width',
  283. 'caption' => _ ("Width of Compose Window"),
  284. 'type' => SMOPT_TYPE_INTEGER ,
  285. 'refresh' => SMOPT_REFRESH_ALL ,
  286. 'size' => SMOPT_SIZE_TINY
  287. );
  288. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  289. 'name' => 'compose_height',
  290. 'caption' => _ ("Height of Compose Window"),
  291. 'type' => SMOPT_TYPE_INTEGER ,
  292. 'refresh' => SMOPT_REFRESH_ALL ,
  293. 'size' => SMOPT_SIZE_TINY
  294. );
  295. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  296. 'name' => 'sig_first',
  297. 'caption' => _ ("Prepend Signature before Reply/Forward Text"),
  298. 'type' => SMOPT_TYPE_BOOLEAN ,
  299. 'refresh' => SMOPT_REFRESH_NONE
  300. );
  301. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  302. 'name' => 'strip_sigs',
  303. 'caption' => _ ("Strip signature when replying"),
  304. 'type' => SMOPT_TYPE_BOOLEAN ,
  305. 'refresh' => SMOPT_REFRESH_NONE
  306. );
  307. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  308. 'name' => 'body_quote',
  309. 'caption' => _ ("Prefix for Original Message when Replying"),
  310. 'type' => SMOPT_TYPE_STRING ,
  311. 'refresh' => SMOPT_REFRESH_NONE ,
  312. 'size' => SMOPT_SIZE_TINY ,
  313. 'save' => 'save_option_reply_prefix'
  314. );
  315. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  316. 'name' => 'reply_focus',
  317. 'caption' => _ ("Cursor Position when Replying"),
  318. 'type' => SMOPT_TYPE_STRLIST ,
  319. 'refresh' => SMOPT_REFRESH_NONE ,
  320. 'posvals' => array('' => _ ("To: field"),
  321. 'focus' => _ ("Focus in body"),
  322. 'select' => _ ("Select body"),
  323. 'none' => _ ("No focus"))
  324. );
  325. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  326. 'name' => 'internal_date_sort',
  327. 'caption' => _ ("Sort by Received Date"),
  328. 'type' => SMOPT_TYPE_BOOLEAN ,
  329. 'refresh' => SMOPT_REFRESH_ALL ,
  330. 'initial_value' => SMPREF_ON
  331. );
  332. if ($allow_thread_sort == TRUE) {
  333. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  334. 'name' => 'sort_by_ref',
  335. 'caption' => _ ("Enable Thread Sort by References Header"),
  336. 'type' => SMOPT_TYPE_BOOLEAN ,
  337. 'refresh' => SMOPT_REFRESH_ALL
  338. );
  339. }
  340. /* Assemble all this together and return it as our result. */
  341. $result = array(
  342. 'grps' => $optgrps,
  343. 'vals' => $optvals,
  344. 'xtra' => $onLoadScript
  345. );
  346. return ($result);
  347. }
  348. /******************************************************************/
  349. /** Define any specialized save functions for this option page. ***/
  350. /******************************************************************/
  351. /**
  352. * This function saves a new theme setting.
  353. * It updates the theme array.
  354. */
  355. function save_option_theme ($option) {
  356. global $theme ;
  357. /* Do checking to make sure $new_theme is in the array. */
  358. $theme_in_array = false;
  359. for ($i = 0; $i < count ($theme); ++$i) {
  360. if ($theme[$i]['PATH'] == $option->new_value) {
  361. $theme_in_array = true;
  362. break;
  363. }
  364. }
  365. if (!$theme_in_array) {
  366. $option->new_value = '';
  367. }
  368. /* Save the option like normal. */
  369. save_option ($option);
  370. }
  371. /**
  372. * This function saves the javascript detection option.
  373. */
  374. global $data_dir , $username;
  375. sqGetGlobalVar('new_javascript_setting', $new_javascript_setting);
  376. // Set javascript either on or off.
  377. if ($new_javascript_setting == SMPREF_JS_AUTODETECT ) {
  378. if ($option->new_value == SMPREF_JS_ON ) {
  379. setPref ($data_dir, $username, 'javascript_on', SMPREF_JS_ON );
  380. } else {
  381. setPref ($data_dir, $username, 'javascript_on', SMPREF_JS_OFF );
  382. }
  383. } else {
  384. setPref ($data_dir, $username, 'javascript_on', $new_javascript_setting);
  385. }
  386. }
  387. function save_option_reply_prefix ($option) {
  388. global $data_dir , $username, $new_javascript_setting;
  389. // save as "NONE" if it was blanked out
  390. //
  391. if (empty($option->new_value)) $option->new_value = 'NONE';
  392. // Save the option like normal.
  393. //
  394. save_option ($option);
  395. }

Documentation generated on 2020年1月13日 04:24:33 +0100 by phpDocumentor 1.4.3

AltStyle によって変換されたページ (->オリジナル) /