Source for file style.php

Documentation is available at style.php

  1. <?php
  2. /**
  3. * Style sheet script
  4. *
  5. * Script processes GET arguments and generates CSS output from stylesheet.tpl,
  6. * which is defined in each template set.
  7. *
  8. * Used GET arguments:
  9. * <ul>
  10. * <li>themeid - string, sets theme file from themes/*.php
  11. * <li>templateid - string, sets template set ID
  12. * <li>fontset - string, sets selected set of fonts from $fontsets array.
  13. * <li>fontsize - integer, sets selected font size
  14. * <li>dir - string, sets text direction variables. Possible values 'rtl' or 'ltr'
  15. * </ul>
  16. * @copyright 2005-2020 The SquirrelMail Project Team
  17. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  18. * @version $Id: style.php 14845 2020年01月07日 08:09:34Z pdontthink $
  19. * @package squirrelmail
  20. */
  21. /** This is the style page */
  22. define ('PAGE_NAME', 'style');
  23. /**
  24. * Include the SquirrelMail initialization file.
  25. */
  26. require('../include/init.php');
  27. /* safety check for older config.php */
  28. if (!isset($fontsets) || !is_array ($fontsets)) {
  29. $fontsets=array();
  30. }
  31. /**
  32. * The following code should no longer be neccesary, but it will remain for the
  33. * time being, just in case.
  34. *
  35. * TODO: Remove if no longer needed.
  36. **/
  37. /* set default colors in case color theme is not full */
  38. $color = array();
  39. $color[0] = '#dcdcdc'; // (light gray) TitleBar
  40. $color[1] = '#800000'; // (red)
  41. $color[2] = '#cc0000'; // (light red) Warning/Error Messages
  42. $color[3] = '#a0b8c8'; // (green-blue) Left Bar Background
  43. $color[4] = '#ffffff'; // (white) Normal Background
  44. $color[5] = '#ffffcc'; // (light yellow) Table Headers
  45. $color[6] = '#000000'; // (black) Text on left bar
  46. $color[7] = '#0000cc'; // (blue) Links
  47. $color[8] = '#000000'; // (black) Normal text
  48. $color[9] = '#ababab'; // (mid-gray) Darker version of #0
  49. $color[10] = '#666666'; // (dark gray) Darker version of #9
  50. $color[11] = '#770000'; // (dark red) Special Folders color
  51. $color[12] = '#ededed'; // (light gray) Alternate color for message list
  52. $color[13] = '#800000'; // (dark red) Color for quoted text -- > 1 quote
  53. $color[14] = '#ff0000'; // (red) Color for quoted text -- >> 2 or more
  54. $color[15] = '#002266'; // (dark blue) Unselectable folders
  55. $color[16] = '#ff9933'; // (orange) Highlight color
  56. /**
  57. * set color constants in order to use simple names instead of color array
  58. * 0 - SQM_TEXT_DISABLED, SQM_TITLE_BACKGROUND, SQM_BUTTON_BACKGROUND_DISABLED,
  59. * SQM_ROW_BACKGROUND_1
  60. * 1 -
  61. * 2 - SQM_ERROR_TEXT
  62. * 3 - SQM_BACKGROUND_LEFT
  63. * 4 - SQM_BACKGROUND
  64. * 5 - SQM_ROW_BACKGROUND_HIGHLIGHT, SQM_COLUMN_HEADER_BACKGROUND
  65. * 6 - SQM_TEXT_STANDARD_LEFT
  66. * 7 - SQM_TITLE_TEXT, SQM_BLOCK_TITLE_TEXT
  67. * 8 - SQM_TEXT_STANDARD, SQM_BUTTON_TEXT, SQM_BLOCK_TEXT, SQM_ROW_TEXT_1,
  68. * SQM_ROW_TEXT_2, SQM_ROW_TEXT_HIGHLIGHT, SQM_ROW_TEXT_SELECTED,
  69. * SQM_COLUMN_HEADER_TEXT
  70. * 9 - SQM_BUTTON_BACKGROUND
  71. * 10 - SQM_BLOCK_TITLE
  72. * 11 - SQM_TEXT_SPECIAL
  73. * 12 - SQM_BUTTON_BACKGROUND_TEXT, SQM_BLOCK_BACKGROUND, SQM_ROW_BACKGROUND_2
  74. * 13 - SQM_MESSAGE_QUOTE_1
  75. * 14 - SQM_MESSAGE_QUOTE_2
  76. * 15 - SQM_TEXT_HIGHLIGHT
  77. * 16 - SQM_ROW_BACKGROUND_SELECTED
  78. */
  79. define ('SQM_BACKGROUND',$color[4]);
  80. define ('SQM_BACKGROUND_LEFT',$color[3]);
  81. define ('SQM_TEXT_STANDARD',$color[8]);
  82. define ('SQM_TEXT_STANDARD_LEFT',$color[6]);
  83. define ('SQM_TEXT_HIGHLIGHT',$color[15]);
  84. define ('SQM_TEXT_DISABLED',$color[0]);
  85. define ('SQM_TEXT_SPECIAL',$color[11]);
  86. define ('SQM_LINK',$color[7]);
  87. define ('SQM_LINK_LEFT',$color[6]);
  88. define ('SQM_TITLE_BACKGROUND',$color[0]);
  89. define ('SQM_TITLE_TEXT',$color[7]);
  90. define ('SQM_BUTTON_BACKGROUND',$color[9]);
  91. define ('SQM_BUTTON_TEXT',$color[8]);
  92. define ('SQM_BUTTON_BACKGROUND_DISABLED',$color[0]);
  93. define ('SQM_BUTTON_BACKGROUND_TEXT',$color[12]);
  94. define ('SQM_BLOCK_BACKGROUND',$color[12]);
  95. define ('SQM_BLOCK_TEXT',$color[8]);
  96. define ('SQM_BLOCK_TITLE',$color[10]);
  97. define ('SQM_BLOCK_TITLE_TEXT',$color[7]);
  98. define ('SQM_ROW_BACKGROUND_1',$color[0]);
  99. define ('SQM_ROW_BACKGROUND_2',$color[12]);
  100. define ('SQM_ROW_TEXT_1',$color[8]);
  101. define ('SQM_ROW_TEXT_2',$color[8]);
  102. define ('SQM_ROW_BACKGROUND_HIGHLIGHT',$color[5]);
  103. define ('SQM_ROW_TEXT_HIGHLIGHT',$color[8]);
  104. define ('SQM_ROW_BACKGROUND_SELECTED',$color[16]);
  105. define ('SQM_ROW_TEXT_SELECTED',$color[8]);
  106. define ('SQM_COLUMN_HEADER_BACKGROUND',$color[5]);
  107. define ('SQM_COLUMN_HEADER_TEXT',$color[8]);
  108. define ('SQM_MESSAGE_QUOTE_1',$color[13]);
  109. define ('SQM_MESSAGE_QUOTE_2',$color[14]);
  110. define ('SQM_ERROR_TEXT',$color[2]);
  111. define ('SQM_ALIGN_LEFT', $align['left']);
  112. define ('SQM_ALIGN_RIGHT', $align['right']);
  113. // END TODO
  114. if (sqgetGlobalVar ('fontset',$fontset,SQ_GET ) &&
  115. isset($fontsets[$fontset])) {
  116. $fontfamily=$fontsets[$fontset];
  117. } else {
  118. $fontfamily='';
  119. }
  120. if (! sqgetGlobalVar ('fontsize',$fontsize,SQ_GET )) {
  121. $fontsize = 0;
  122. } else {
  123. $fontsize = (int) $fontsize;
  124. }
  125. $oTemplate->header ('Content-Type: text/css');
  126. /**
  127. * GOTCHA #1: When sending the headers for caching, we must send Expires,
  128. * Last-Modified, Pragma, and Cache-Control headers. If we don't PHP
  129. * will makeup values that will break the cacheing.
  130. *
  131. * GOTCHA #2: If the current template does not contain a template named
  132. * stylesheet.tpl, this cacheing will break because filemtime() won't
  133. * work. This is a problem e.g. with the default_advanced template
  134. * that inherits CSS properties from the default template but
  135. * doesn't contain stylesheet.tpl itself.
  136. IDEA: So ask the Template class object to return the mtime or better yet, the full file path (at least from SM_PATH) by using $oTemplate->get_template_file_path(stylesheet.tpl) but this is still a problem if the default template also does not have such a file (in which case, we fall back to SM's css/deafult css file (so in that case, go get that file's mtime!)
  137. * Possibly naive suggestion - template can define its own default
  138. * template name
  139. *
  140. * GOTCHA #3: If the user changes user prefs for things like font size then
  141. * the mtime should be updated to the time of that change, and not
  142. * that of the stylesheet.tpl file. IDEA: can this be a value kept
  143. * in user prefs (always compare to actual file mtime before sending
  144. * to the browser)
  145. *
  146. * Comment re gotcha #3: If we only define basic font prefs here, we really
  147. * only need to refresh the cache if one of the font prefs changes.
  148. * Possibly some type of "force nocache flag could be set if a font pref is
  149. * changed?
  150. *
  151. * Response: Perhaps, if that can be implemented great, but I think the
  152. * user prefs solution would definitely work: catch the font setting change
  153. * in a custom save() routine from user prefs and away we go.
  154. *
  155. * TODO: Fix this. :)
  156. */
  157. if ( $lastmod = @filemtime (SM_PATH . $oTemplate->get_template_file_directory()
  158. . 'css/stylesheet.tpl') ) {
  159. $gmlastmod = gmdate ('D, d M Y H:i:s', $lastmod) . ' GMT';
  160. $expires = gmdate ('D, d M Y H:i:s', strtotime ('+1 week')) . ' GMT';
  161. $oTemplate->header ('Last-Modified: ' . $gmlastmod);
  162. $oTemplate->header ('Expires: '. $expires);
  163. $oTemplate->header ('Pragma: ');
  164. $oTemplate->header ('Cache-Control: public, must-revalidate');
  165. }
  166. // Steve, why did you remove this? Is it irrelevant now? If so, let's
  167. // remove the rest of the references to it here (note that it is being
  168. // used above in the filetime() statement) and elsewhere
  169. // $oTemplate->display('css/stylesheet.tpl');
  170. // don't show version as a security measure
  171. //$oTemplate->header('X-Powered-By: SquirrelMail/' . SM_VERSION, FALSE);
  172. $oTemplate->header ('X-Powered-By: SquirrelMail', FALSE);
  173. /**
  174. * Additional styles are now handled by adding stylesheets to
  175. * templates/<template>/css/, so here, we simply define some
  176. * basic styles based on user prefs.
  177. */
  178. ?>
  179. /* older css template */
  180. body, td, th, dd, dt, h1, h2, h3, h4, h5, h6, p, ol, ul, li {
  181. <?php
  182. if($fontfamily) echo ' font-family: '.$fontfamily.";\n";
  183. ?>
  184. }
  185. body, small {
  186. <?php
  187. if($fontsize) echo ' font-size: '.($fontsize-2)."pt;\n";
  188. ?>
  189. }
  190. td, th {
  191. <?php
  192. if($fontsize) echo ' font-size: '.$fontsize."pt;\n";
  193. ?>
  194. }
  195. textarea, pre {
  196. font-family: monospace;
  197. <?php
  198. if($fontsize) echo ' font-size: '.($fontsize-1)."pt;\n";
  199. ?>
  200. }

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

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