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 14845 2020年01月07日 08:09:34Z 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. define ('SMOPT_GRP_ABOOK', 3);
  17. global $use_iframe;
  18. if (! isset($use_iframe)) $use_iframe=false;
  19. /**
  20. * This function builds an array with all the information about
  21. * the options available to the user, and returns it. The options
  22. * are grouped by the groups in which they are displayed.
  23. * For each option, the following information is stored:
  24. * - name: the internal (variable) name
  25. * - caption: the description of the option in the UI
  26. * - type: one of SMOPT_TYPE_*
  27. * - refresh: one of SMOPT_REFRESH_*
  28. * - size: one of SMOPT_SIZE_*
  29. * - save: the name of a function to call when saving this option
  30. * @return array all option information
  31. */
  32. global $theme, $fontsets , $language, $languages ,$aTemplateSet,
  33. $default_use_mdn , $squirrelmail_language, $allow_thread_sort,
  34. $sTemplateID, $oTemplate,
  35. $user_themes , $chosen_theme;
  36. /* Build a simple array into which we will build options. */
  37. $optgrps = array();
  38. $optvals = array();
  39. /******************************************************/
  40. /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
  41. /******************************************************/
  42. /*** Load the General Options into the array ***/
  43. $optgrps[SMOPT_GRP_GENERAL ] = _ ("General Display Options");
  44. $optvals[SMOPT_GRP_GENERAL ] = array();
  45. /* load the template set option */
  46. $templateset_values = array();
  47. foreach ($aTemplateSet as $sKey => $aTemplateSetAttributes) {
  48. $templateset_values[$aTemplateSetAttributes['NAME']] = $aTemplateSetAttributes['ID'];
  49. }
  50. ksort ($templateset_values);
  51. $templateset_values = array_flip ($templateset_values);
  52. // display template options only when there is more than one template
  53. if (count ($templateset_values)>1) {
  54. $optvals[SMOPT_GRP_GENERAL ][] = array(
  55. 'name' => 'sTemplateID',
  56. 'caption' => _ ("Skin"),
  57. 'type' => SMOPT_TYPE_STRLIST ,
  58. 'refresh' => SMOPT_REFRESH_ALL ,
  59. 'posvals' => $templateset_values,
  60. 'save' => 'save_option_template'
  61. );
  62. }
  63. /* Load the theme option. */
  64. $theme_values = array();
  65. // Always provide the template default first.
  66. $theme_values['none'] = 'Template Default Theme';
  67. // List alternate themes provided by templates first
  68. $template_themes = $oTemplate->get_alternative_stylesheets(true);
  69. asort ($template_themes);
  70. foreach ($template_themes as $sheet=>$name) {
  71. $theme_values[$sheet] = 'Template Theme - '.sm_encode_html_special_chars ($name);
  72. }
  73. // Next, list user-provided styles
  74. asort ($user_themes);
  75. foreach ($user_themes as $style) {
  76. if ($style['PATH'] == 'none')
  77. continue;
  78. $theme_values[$style['PATH']] = 'User Theme - '.sm_encode_html_special_chars ($style['NAME']);
  79. }
  80. if (count ($user_themes) + count ($template_themes) > 1) {
  81. $optvals[SMOPT_GRP_GENERAL ][] = array(
  82. 'name' => 'chosen_theme',
  83. 'caption' => _ ("Theme"),
  84. 'type' => SMOPT_TYPE_STRLIST ,
  85. 'refresh' => SMOPT_REFRESH_ALL ,
  86. 'posvals' => $theme_values,
  87. 'save' => 'css_theme_save'
  88. );
  89. }
  90. /* Icon theme selection */
  91. if ($use_icons) {
  92. global $icon_themes , $icon_theme;
  93. $temp = array();
  94. $value = 0;
  95. for ($count = 0; $count < sizeof ($icon_themes); $count++) {
  96. $temp[$icon_themes[$count]['PATH']] = $icon_themes[$count]['NAME'];
  97. }
  98. if (sizeof ($icon_themes) > 0) {
  99. $optvals[SMOPT_GRP_GENERAL ][] = array(
  100. 'name' => 'icon_theme',
  101. 'caption' => _ ("Icon Theme"),
  102. 'type' => SMOPT_TYPE_STRLIST ,
  103. 'refresh' => SMOPT_REFRESH_NONE ,
  104. 'posvals' => $temp,
  105. 'save' => 'icon_theme_save'
  106. );
  107. }
  108. }
  109. $fontset_values = array();
  110. $fontset_list = array();
  111. if (!empty($fontsets) && is_array ($fontsets)) {
  112. foreach (array_keys ($fontsets) as $fontset_key) {
  113. $fontset_list[$fontset_key]=$fontset_key;
  114. }
  115. ksort ($fontset_list);
  116. }
  117. if (count ($fontset_list) > 1) {
  118. $fontset_list = array_merge (array('' => _ ("Default font style")), $fontset_list);
  119. $optvals[SMOPT_GRP_GENERAL ][] = array(
  120. 'name' => 'chosen_fontset',
  121. 'caption' => _ ("Font style"),
  122. 'type' => SMOPT_TYPE_STRLIST ,
  123. 'refresh' => SMOPT_REFRESH_ALL ,
  124. 'posvals' => $fontset_list
  125. );
  126. }
  127. $optvals[SMOPT_GRP_GENERAL ][] = array(
  128. 'name' => 'chosen_fontsize',
  129. 'caption' => _ ("Font size"),
  130. 'type' => SMOPT_TYPE_STRLIST ,
  131. 'refresh' => SMOPT_REFRESH_ALL ,
  132. 'posvals' => array('' => _ ("Default font size"),
  133. '8' => '8 px',
  134. '10' => '10 px',
  135. '12' => '12 px',
  136. '14' => '14 px')
  137. );
  138. $language_values = array();
  139. foreach ($languages as $lang_key => $lang_attributes) {
  140. if (isset($lang_attributes['NAME'])) {
  141. $language_values[$lang_key] = $lang_attributes['NAME'];
  142. if ( isset($show_alternative_names) &&
  143. $show_alternative_names &&
  144. isset($lang_attributes['ALTNAME']) ) {
  145. $language_values[$lang_key] .= " / " . $lang_attributes['ALTNAME'];
  146. }
  147. }
  148. }
  149. asort ($language_values);
  150. $language_values =
  151. array_merge (array('' => _ ("Default")), $language_values);
  152. $language = $squirrelmail_language;
  153. // add language selection only when more than 2 languages are available
  154. // (default, English and some other)
  155. if (count ($language_values)>2) {
  156. $optvals[SMOPT_GRP_GENERAL ][] = array(
  157. 'name' => 'language',
  158. 'caption' => _ ("Language"),
  159. 'type' => SMOPT_TYPE_STRLIST ,
  160. 'refresh' => SMOPT_REFRESH_ALL ,
  161. 'posvals' => $language_values,
  162. 'htmlencoded' => true
  163. );
  164. }
  165. /* Set values for the "use javascript" option. */
  166. $optvals[SMOPT_GRP_GENERAL ][] = array(
  167. 'name' => 'javascript_setting',
  168. 'caption' => _ ("Use Javascript"),
  169. 'type' => SMOPT_TYPE_STRLIST ,
  170. 'refresh' => SMOPT_REFRESH_ALL ,
  171. 'posvals' => array(SMPREF_JS_AUTODETECT => _ ("Autodetect"),
  172. SMPREF_JS_ON => _ ("Always"),
  173. SMPREF_JS_OFF => _ ("Never")),
  174. 'save' => 'save_option_javascript_autodetect',
  175. 'extra_attributes' => array('onclick' => 'document.option_form.new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\';'),
  176. );
  177. $optvals[SMOPT_GRP_GENERAL ][] = array(
  178. 'name' => 'js_autodetect_results',
  179. 'caption' => '',
  180. 'type' => SMOPT_TYPE_HIDDEN ,
  181. 'refresh' => SMOPT_REFRESH_NONE
  182. //'post_script' => $js_autodetect_script,
  183. );
  184. $optvals[SMOPT_GRP_GENERAL ][] = array(
  185. 'name' => 'hour_format',
  186. 'caption' => _ ("Hour Format"),
  187. 'type' => SMOPT_TYPE_STRLIST ,
  188. 'refresh' => SMOPT_REFRESH_FOLDERLIST ,
  189. 'posvals' => array(SMPREF_TIME_12HR => _ ("12-hour clock"),
  190. SMPREF_TIME_24HR => _ ("24-hour clock"))
  191. );
  192. /*** Load the General Options into the array ***/
  193. $optgrps[SMOPT_GRP_MAILBOX ] = _ ("Mailbox Display Options");
  194. $optvals[SMOPT_GRP_MAILBOX ] = array();
  195. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  196. 'name' => 'show_num',
  197. 'caption' => _ ("Number of Messages per Page"),
  198. 'type' => SMOPT_TYPE_INTEGER ,
  199. 'refresh' => SMOPT_REFRESH_NONE ,
  200. 'size' => SMOPT_SIZE_TINY
  201. );
  202. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  203. 'name' => 'alt_index_colors',
  204. 'caption' => _ ("Enable Alternating Row Colors"),
  205. 'type' => SMOPT_TYPE_BOOLEAN ,
  206. 'refresh' => SMOPT_REFRESH_NONE
  207. );
  208. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  209. 'name' => 'fancy_index_highlite',
  210. 'caption' => _ ("Enable Fancy Row Mouseover Highlighting"),
  211. 'type' => SMOPT_TYPE_BOOLEAN ,
  212. 'refresh' => SMOPT_REFRESH_NONE
  213. );
  214. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  215. 'name' => 'show_flag_buttons',
  216. 'caption' => _ ("Show Flag / Unflag Buttons"),
  217. 'type' => SMOPT_TYPE_BOOLEAN ,
  218. 'refresh' => SMOPT_REFRESH_NONE
  219. );
  220. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  221. 'name' => 'show_copy_buttons',
  222. 'caption' => _ ("Enable Message Copy Buttons"),
  223. 'type' => SMOPT_TYPE_BOOLEAN ,
  224. 'refresh' => SMOPT_REFRESH_NONE
  225. );
  226. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  227. 'name' => 'page_selector',
  228. 'caption' => _ ("Enable Page Selector"),
  229. 'type' => SMOPT_TYPE_BOOLEAN ,
  230. 'refresh' => SMOPT_REFRESH_NONE
  231. );
  232. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  233. 'name' => 'compact_paginator',
  234. 'caption' => _ ("Use Compact Page Selector"),
  235. 'type' => SMOPT_TYPE_BOOLEAN ,
  236. 'refresh' => SMOPT_REFRESH_NONE
  237. );
  238. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  239. 'name' => 'page_selector_max',
  240. 'caption' => _ ("Maximum Number of Pages to Show"),
  241. 'type' => SMOPT_TYPE_INTEGER ,
  242. 'refresh' => SMOPT_REFRESH_NONE ,
  243. 'size' => SMOPT_SIZE_TINY
  244. );
  245. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  246. 'name' => 'show_personal_names',
  247. 'caption' => _ ("Show Names Instead of Email Addresses"),
  248. 'type' => SMOPT_TYPE_BOOLEAN ,
  249. 'refresh' => SMOPT_REFRESH_NONE ,
  250. );
  251. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  252. 'name' => 'show_full_date',
  253. 'caption' => _ ("Always Show Full Date"),
  254. 'type' => SMOPT_TYPE_BOOLEAN ,
  255. 'refresh' => SMOPT_REFRESH_NONE
  256. );
  257. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  258. 'name' => 'custom_date_format',
  259. 'caption' => _ ("Custom Date Format"),
  260. //FIXME: need better wording here. users should be made aware that this is for advanced use. It might be nice to provide a list of the more common date format characters. It may be helpful to know that it overrides settings such as the one above show_full_date, and only if kept empty will the other date formats apply. For non-English users, it also may be helpful to know that the format is still passed through our own date_intl() function which translates things like the day of the week, month names and abbreviations, etc.
  261. 'trailing_text' => ' ' . _ ("(Uses format of PHP date() function)"),
  262. 'type' => SMOPT_TYPE_STRING ,
  263. 'refresh' => SMOPT_REFRESH_NONE ,
  264. 'size' => SMOPT_SIZE_TINY ,
  265. );
  266. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  267. 'name' => 'truncate_sender',
  268. 'caption' => _ ("Length of From/To Field (0 for full)"),
  269. 'type' => SMOPT_TYPE_INTEGER ,
  270. 'refresh' => SMOPT_REFRESH_NONE ,
  271. 'size' => SMOPT_SIZE_TINY
  272. );
  273. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  274. 'name' => 'truncate_subject',
  275. 'caption' => _ ("Length of Subject Field (0 for full)"),
  276. 'type' => SMOPT_TYPE_INTEGER ,
  277. 'refresh' => SMOPT_REFRESH_NONE ,
  278. 'size' => SMOPT_SIZE_TINY
  279. );
  280. /*
  281. FIXME!
  282. disabled because the template doesn't support it (yet?)
  283. $optvals[SMOPT_GRP_MAILBOX][] = array(
  284. 'name' => 'show_recipient_instead',
  285. 'caption' => _("Show recipient name if the message is from your default identity"),
  286. 'type' => SMOPT_TYPE_BOOLEAN,
  287. 'refresh' => SMOPT_REFRESH_NONE,
  288. 'size' => SMOPT_SIZE_TINY
  289. );
  290. */
  291. if ($allow_thread_sort == TRUE) {
  292. $optvals[SMOPT_GRP_MAILBOX ][] = array(
  293. 'name' => 'sort_by_ref',
  294. 'caption' => _ ("Enable Thread Sort by References Header"),
  295. 'type' => SMOPT_TYPE_BOOLEAN ,
  296. 'refresh' => SMOPT_REFRESH_ALL
  297. );
  298. }
  299. /*** Load the General Options into the array ***/
  300. $optgrps[SMOPT_GRP_MESSAGE ] = _ ("Message Display Options");
  301. $optvals[SMOPT_GRP_MESSAGE ] = array();
  302. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  303. 'name' => 'wrap_at',
  304. 'caption' => _ ("Wrap Incoming Text At"),
  305. 'type' => SMOPT_TYPE_INTEGER ,
  306. 'refresh' => SMOPT_REFRESH_NONE ,
  307. 'size' => SMOPT_SIZE_TINY
  308. );
  309. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  310. 'name' => 'show_html_default',
  311. 'caption' => _ ("Show HTML Version by Default"),
  312. 'type' => SMOPT_TYPE_BOOLEAN ,
  313. 'refresh' => SMOPT_REFRESH_NONE
  314. );
  315. if ($use_iframe) {
  316. // Type is set to string in order to be able to use 100%.
  317. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  318. 'name' => 'iframe_height',
  319. 'caption' => _ ("Height of inline frame"),
  320. 'type' => SMOPT_TYPE_STRING ,
  321. 'size' => SMOPT_SIZE_TINY ,
  322. 'refresh' => SMOPT_REFRESH_NONE
  323. );
  324. }
  325. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  326. 'name' => 'enable_forward_as_attachment',
  327. 'caption' => _ ("Enable Forward as Attachment"),
  328. 'type' => SMOPT_TYPE_BOOLEAN ,
  329. 'refresh' => SMOPT_REFRESH_NONE
  330. );
  331. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  332. 'name' => 'show_xmailer_default',
  333. 'caption' => _ ("Enable Mailer Display"),
  334. 'type' => SMOPT_TYPE_BOOLEAN ,
  335. 'refresh' => SMOPT_REFRESH_NONE
  336. );
  337. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  338. 'name' => 'attachment_common_show_images',
  339. 'caption' => _ ("Display Attached Images with Message"),
  340. 'type' => SMOPT_TYPE_BOOLEAN ,
  341. 'refresh' => SMOPT_REFRESH_NONE
  342. );
  343. if ($default_use_mdn) {
  344. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  345. 'name' => 'mdn_user_support',
  346. 'caption' => _ ("Enable Mail Delivery Notification"),
  347. 'type' => SMOPT_TYPE_BOOLEAN ,
  348. 'refresh' => SMOPT_REFRESH_NONE
  349. );
  350. }
  351. $optvals[SMOPT_GRP_MESSAGE ][] = array(
  352. 'name' => 'delete_prev_next_display',
  353. 'caption' => _ ("Show 'Delete &amp; Prev/Next' Links"),
  354. 'type' => SMOPT_TYPE_BOOLEAN ,
  355. 'refresh' => SMOPT_REFRESH_ALL
  356. );
  357. /*** Load the Address Book Options into the array ***/
  358. $optgrps[SMOPT_GRP_ABOOK ] = _ ("Address Book Display Options");
  359. $optvals[SMOPT_GRP_ABOOK ] = array();
  360. $optvals[SMOPT_GRP_ABOOK ][] = array(
  361. 'name' => 'abook_show_num',
  362. 'caption' => _ ("Number of Addresses per Page"),
  363. 'type' => SMOPT_TYPE_INTEGER ,
  364. 'refresh' => SMOPT_REFRESH_NONE ,
  365. 'size' => SMOPT_SIZE_TINY
  366. );
  367. $optvals[SMOPT_GRP_ABOOK ][] = array(
  368. 'name' => 'abook_page_selector',
  369. 'caption' => _ ("Enable Page Selector"),
  370. 'type' => SMOPT_TYPE_BOOLEAN ,
  371. 'refresh' => SMOPT_REFRESH_NONE
  372. );
  373. $optvals[SMOPT_GRP_ABOOK ][] = array(
  374. 'name' => 'abook_compact_paginator',
  375. 'caption' => _ ("Use Compact Page Selector"),
  376. 'type' => SMOPT_TYPE_BOOLEAN ,
  377. 'refresh' => SMOPT_REFRESH_NONE
  378. );
  379. $optvals[SMOPT_GRP_ABOOK ][] = array(
  380. 'name' => 'abook_page_selector_max',
  381. 'caption' => _ ("Maximum Number of Pages to Show"),
  382. 'type' => SMOPT_TYPE_INTEGER ,
  383. 'refresh' => SMOPT_REFRESH_NONE ,
  384. 'size' => SMOPT_SIZE_TINY
  385. );
  386. /* Assemble all this together and return it as our result. */
  387. $result = array(
  388. 'grps' => $optgrps,
  389. 'vals' => $optvals
  390. );
  391. return ($result);
  392. }
  393. /******************************************************************/
  394. /** Define any specialized save functions for this option page. ***/
  395. /******************************************************************/
  396. /**
  397. * This function saves a new template setting.
  398. * It updates the template array.
  399. */
  400. function save_option_template ($option) {
  401. global $aTemplateSet;
  402. /* Do checking to make sure new template is in the available templates array. */
  403. $templateset_in_array = false;
  404. for ($i = 0; $i < count ($aTemplateSet); ++$i) {
  405. if ($aTemplateSet[$i]['ID'] == $option->new_value) {
  406. $templateset_in_array = true;
  407. break;
  408. }
  409. }
  410. if (!$templateset_in_array) {
  411. $option->new_value = '';
  412. } else {
  413. // clear template cache when changing template sets
  414. // (in order to do so, we have to change the global
  415. // template set ID now... should not be a problem --
  416. // in fact, if we don't do it now, very anomalous
  417. // problems occur)
  418. //
  419. global $sTemplateID;
  420. $sTemplateID = $option->new_value;
  421. Template ::cache_template_file_hierarchy ($sTemplateID, TRUE);
  422. }
  423. /**
  424. * TODO: If the template changes and we are using a template provided theme
  425. * ($user_theme), do we want to reset $user_theme?
  426. */
  427. /* Save the option like normal. */
  428. save_option ($option);
  429. }
  430. /**
  431. * This function saves the javascript detection option.
  432. */
  433. save_option ($option);
  434. }
  435. /**
  436. * This function saves the user's icon theme setting
  437. */
  438. function icon_theme_save ($option) {
  439. global $icon_themes ;
  440. // Don't assume the new value is there, double check
  441. // and only save if found
  442. $found = false;
  443. while (!$found && (list($index, $data) = each ($icon_themes))) {
  444. if ($data['PATH'] == $option->new_value)
  445. $found = true;
  446. }
  447. if (!$found)
  448. $option->new_value = 'none';
  449. save_option ($option);
  450. }
  451. function css_theme_save ($option) {
  452. global $user_themes , $oTemplate;
  453. // Don't assume the new value is there, double check
  454. // and only save if found
  455. $found = false;
  456. reset ($user_themes);
  457. while (!$found && (list($index, $data) = each ($user_themes))) {
  458. if ($data['PATH'] == $option->new_value)
  459. $found = true;
  460. }
  461. if (!$found) {
  462. $template_themes = $oTemplate->get_alternative_stylesheets(true);
  463. while (!$found && (list($path, $name) = each ($template_themes))) {
  464. if ($path == $option->new_value)
  465. $found = true;
  466. }
  467. }
  468. if (!$found)
  469. $option->new_value = 'none';
  470. save_option ($option);
  471. }

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

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