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