text before displayHtmlHeader() causes error notices (#1454409).
[squirrelmail.git] / src / style.php
CommitLineData
d3c2ff0a 1<?php
2/**
3 * Style sheet script
5c4ff7bf 4 *
d3c2ff0a 5 * Script processes GET arguments and generates CSS output from stylesheet.tpl.
6 * Used GET arguments:
7 * <ul>
8 * <li>themeid - string, sets theme file from themes/*.php
6309ffc2 9 * <li>templateid - string, sets template directory from templates/
d3c2ff0a 10 * <li>fontset - string, sets selected set of fonts from $fontsets array.
11 * <li>fontsize - integer, sets selected font size
12 * </ul>
47ccfad4 13 * @copyright &copy; 2005-2006 The SquirrelMail Project Team
d3c2ff0a 14 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
15 * @version $Id$
16 * @package squirrelmail
17 */
18
19/** @ignore */
20define('SM_PATH','../');
21
22/* SquirrelMail required files. */
23require_once(SM_PATH . 'functions/global.php');
24require_once(SM_PATH . 'functions/strings.php');
25require_once(SM_PATH . 'config/config.php');
26
2cc2227d 27/* safety check for older config.php */
28if (!isset($fontsets) || !is_array($fontsets)) {
29 $fontsets=array();
30}
d3c2ff0a 31
6309ffc2 32
d3c2ff0a 33/* template init */
34/** start block copy from right_main.php */
35include_once(SM_PATH . 'class/template/template.class.php');
5c4ff7bf 36
6373ad12 37/**
38 * get template name and set used template directory
39 *
40 * Existing file check has been moved into the template object, so it is
41 * not neccesary to do file_exists() here.
42 * */
43if (sqgetGlobalVar('templateid',$templateid,SQ_GET)) {
6309ffc2 44 $sTplDir = SM_PATH.'templates/'.basename($templateid).'/';
45} else {
46 $sTplDir = SM_PATH.'templates/default/';
47}
48
d3c2ff0a 49$oTemplate = new Template($sTplDir);
50/** end block copy */
51
52/* set default colors in case color theme is not full */
53$color = array();
54$color[0] = '#dcdcdc'; // (light gray) TitleBar
55$color[1] = '#800000'; // (red)
56$color[2] = '#cc0000'; // (light red) Warning/Error Messages
57$color[3] = '#a0b8c8'; // (green-blue) Left Bar Background
58$color[4] = '#ffffff'; // (white) Normal Background
59$color[5] = '#ffffcc'; // (light yellow) Table Headers
60$color[6] = '#000000'; // (black) Text on left bar
61$color[7] = '#0000cc'; // (blue) Links
62$color[8] = '#000000'; // (black) Normal text
63$color[9] = '#ababab'; // (mid-gray) Darker version of #0
64$color[10] = '#666666'; // (dark gray) Darker version of #9
65$color[11] = '#770000'; // (dark red) Special Folders color
66$color[12] = '#ededed'; // (light gray) Alternate color for message list
67$color[13] = '#800000'; // (dark red) Color for quoted text -- > 1 quote
68$color[14] = '#ff0000'; // (red) Color for quoted text -- >> 2 or more
69$color[15] = '#002266'; // (dark blue) Unselectable folders
70$color[16] = '#ff9933'; // (orange) Highlight color
71
72/** get theme from GET */
73if (sqgetGlobalVar('themeid',$themeid,SQ_GET) &&
74 file_exists(SM_PATH . 'themes/'.basename($themeid,'.php').'.php')) {
75 include_once(SM_PATH . 'themes/'.basename($themeid,'.php').'.php');
76} elseif (file_exists($theme[$theme_default]['PATH'])) {
77 include_once($theme[$theme_default]['PATH']);
78}
79
5c4ff7bf 80/**
f549a706 81 * Get text direction
5c4ff7bf 82 */
f549a706 83if (sqgetGlobalVar('dir',$text_direction,SQ_GET) &&
84 $text_direction == 'rtl') {
85 $align = array('left' => 'right', 'right' => 'left');
86} else {
87 $align = array('left' => 'left', 'right' => 'right');
5c4ff7bf 88}
89
d3c2ff0a 90/**/
91$oTemplate->assign('color', $color);
92
93/**
94 * set color constants in order to use simple names instead of color array
5c4ff7bf 95 * 0 - SQM_TEXT_DISABLED, SQM_TITLE_BACKGROUND, SQM_BUTTON_BACKGROUND_DISABLED,
d3c2ff0a 96 * SQM_ROW_BACKGROUND_1
97 * 1 -
98 * 2 - SQM_ERROR_TEXT
99 * 3 - SQM_BACKGROUND_LEFT
100 * 4 - SQM_BACKGROUND
101 * 5 - SQM_ROW_BACKGROUND_HIGHLIGHT, SQM_COLUMN_HEADER_BACKGROUND
102 * 6 - SQM_TEXT_STANDARD_LEFT
103 * 7 - SQM_TITLE_TEXT, SQM_BLOCK_TITLE_TEXT
5c4ff7bf 104 * 8 - SQM_TEXT_STANDARD, SQM_BUTTON_TEXT, SQM_BLOCK_TEXT, SQM_ROW_TEXT_1,
105 * SQM_ROW_TEXT_2, SQM_ROW_TEXT_HIGHLIGHT, SQM_ROW_TEXT_SELECTED,
d3c2ff0a 106 * SQM_COLUMN_HEADER_TEXT
107 * 9 - SQM_BUTTON_BACKGROUND
108 * 10 - SQM_BLOCK_TITLE
109 * 11 - SQM_TEXT_SPECIAL
110 * 12 - SQM_BUTTON_BACKGROUND_TEXT, SQM_BLOCK_BACKGROUND, SQM_ROW_BACKGROUND_2
111 * 13 - SQM_MESSAGE_QUOTE_1
112 * 14 - SQM_MESSAGE_QUOTE_2
113 * 15 - SQM_TEXT_HIGHLIGHT
114 * 16 - SQM_ROW_BACKGROUND_SELECTED
115 */
116define('SQM_BACKGROUND',$color[4]);
117define('SQM_BACKGROUND_LEFT',$color[3]);
118
119define('SQM_TEXT_STANDARD',$color[8]);
120define('SQM_TEXT_STANDARD_LEFT',$color[6]);
121define('SQM_TEXT_HIGHLIGHT',$color[15]);
122define('SQM_TEXT_DISABLED',$color[0]);
123define('SQM_TEXT_SPECIAL',$color[11]);
124
125define('SQM_LINK',$color[7]);
126define('SQM_LINK_LEFT',$color[6]);
127
128define('SQM_TITLE_BACKGROUND',$color[0]);
129define('SQM_TITLE_TEXT',$color[7]);
130
131define('SQM_BUTTON_BACKGROUND',$color[9]);
132define('SQM_BUTTON_TEXT',$color[8]);
133define('SQM_BUTTON_BACKGROUND_DISABLED',$color[0]);
134define('SQM_BUTTON_BACKGROUND_TEXT',$color[12]);
135
136define('SQM_BLOCK_BACKGROUND',$color[12]);
137define('SQM_BLOCK_TEXT',$color[8]);
138define('SQM_BLOCK_TITLE',$color[10]);
139define('SQM_BLOCK_TITLE_TEXT',$color[7]);
140
141define('SQM_ROW_BACKGROUND_1',$color[0]);
142define('SQM_ROW_BACKGROUND_2',$color[12]);
143define('SQM_ROW_TEXT_1',$color[8]);
144define('SQM_ROW_TEXT_2',$color[8]);
145define('SQM_ROW_BACKGROUND_HIGHLIGHT',$color[5]);
146define('SQM_ROW_TEXT_HIGHLIGHT',$color[8]);
147define('SQM_ROW_BACKGROUND_SELECTED',$color[16]);
148define('SQM_ROW_TEXT_SELECTED',$color[8]);
149
150define('SQM_COLUMN_HEADER_BACKGROUND',$color[5]);
151define('SQM_COLUMN_HEADER_TEXT',$color[8]);
152
153define('SQM_MESSAGE_QUOTE_1',$color[13]);
154define('SQM_MESSAGE_QUOTE_2',$color[14]);
155
156define('SQM_ERROR_TEXT',$color[2]);
157
5c4ff7bf 158define('SQM_ALIGN_LEFT', $align['left']);
159define('SQM_ALIGN_RIGHT', $align['right']);
160
d3c2ff0a 161if (sqgetGlobalVar('fontset',$fontset,SQ_GET) &&
162 isset($fontsets[$fontset])) {
6309ffc2 163 $fontfamily=$fontsets[$fontset];
d3c2ff0a 164} else {
165 $fontfamily='';
166}
167$oTemplate->assign('fontfamily', $fontfamily);
168
169if (! sqgetGlobalVar('fontsize',$fontsize,SQ_GET)) {
170 $fontsize = 0;
171} else {
172 $fontsize = (int) $fontsize;
173}
174$oTemplate->assign('fontsize', $fontsize);
175
176header('Content-Type: text/css');
00a68572 177// output a last-modified header if we can
178if ( $lastmod = @filemtime($oTemplate->template_dir . 'stylesheet.tpl') ) {
179 $gmlastmod = gmdate('D, d M Y H:i:s', $lastmod) . ' GMT';
180 header('Last-Modified: ' . $gmlastmod);
181}
d3c2ff0a 182$oTemplate->display('stylesheet.tpl');
183
00a68572 184?>