Incorporated getIconPath to allow third-party packages (like dTree) to getch the...
[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
6309ffc2 37/* get template name and set used template directory */
38if (sqgetGlobalVar('templateid',$templateid,SQ_GET) &&
39 file_exists(SM_PATH.'templates/'.basename($templateid).'/stylesheet.tpl')) {
40 $sTplDir = SM_PATH.'templates/'.basename($templateid).'/';
41} else {
42 $sTplDir = SM_PATH.'templates/default/';
43}
44
d3c2ff0a 45$oTemplate = new Template($sTplDir);
46/** end block copy */
47
48/* set default colors in case color theme is not full */
49$color = array();
50$color[0] = '#dcdcdc'; // (light gray) TitleBar
51$color[1] = '#800000'; // (red)
52$color[2] = '#cc0000'; // (light red) Warning/Error Messages
53$color[3] = '#a0b8c8'; // (green-blue) Left Bar Background
54$color[4] = '#ffffff'; // (white) Normal Background
55$color[5] = '#ffffcc'; // (light yellow) Table Headers
56$color[6] = '#000000'; // (black) Text on left bar
57$color[7] = '#0000cc'; // (blue) Links
58$color[8] = '#000000'; // (black) Normal text
59$color[9] = '#ababab'; // (mid-gray) Darker version of #0
60$color[10] = '#666666'; // (dark gray) Darker version of #9
61$color[11] = '#770000'; // (dark red) Special Folders color
62$color[12] = '#ededed'; // (light gray) Alternate color for message list
63$color[13] = '#800000'; // (dark red) Color for quoted text -- > 1 quote
64$color[14] = '#ff0000'; // (red) Color for quoted text -- >> 2 or more
65$color[15] = '#002266'; // (dark blue) Unselectable folders
66$color[16] = '#ff9933'; // (orange) Highlight color
67
68/** get theme from GET */
69if (sqgetGlobalVar('themeid',$themeid,SQ_GET) &&
70 file_exists(SM_PATH . 'themes/'.basename($themeid,'.php').'.php')) {
71 include_once(SM_PATH . 'themes/'.basename($themeid,'.php').'.php');
72} elseif (file_exists($theme[$theme_default]['PATH'])) {
73 include_once($theme[$theme_default]['PATH']);
74}
75
5c4ff7bf 76/**
f549a706 77 * Get text direction
5c4ff7bf 78 */
f549a706 79if (sqgetGlobalVar('dir',$text_direction,SQ_GET) &&
80 $text_direction == 'rtl') {
81 $align = array('left' => 'right', 'right' => 'left');
82} else {
83 $align = array('left' => 'left', 'right' => 'right');
5c4ff7bf 84}
85
d3c2ff0a 86/**/
87$oTemplate->assign('color', $color);
88
89/**
90 * set color constants in order to use simple names instead of color array
5c4ff7bf 91 * 0 - SQM_TEXT_DISABLED, SQM_TITLE_BACKGROUND, SQM_BUTTON_BACKGROUND_DISABLED,
d3c2ff0a 92 * SQM_ROW_BACKGROUND_1
93 * 1 -
94 * 2 - SQM_ERROR_TEXT
95 * 3 - SQM_BACKGROUND_LEFT
96 * 4 - SQM_BACKGROUND
97 * 5 - SQM_ROW_BACKGROUND_HIGHLIGHT, SQM_COLUMN_HEADER_BACKGROUND
98 * 6 - SQM_TEXT_STANDARD_LEFT
99 * 7 - SQM_TITLE_TEXT, SQM_BLOCK_TITLE_TEXT
5c4ff7bf 100 * 8 - SQM_TEXT_STANDARD, SQM_BUTTON_TEXT, SQM_BLOCK_TEXT, SQM_ROW_TEXT_1,
101 * SQM_ROW_TEXT_2, SQM_ROW_TEXT_HIGHLIGHT, SQM_ROW_TEXT_SELECTED,
d3c2ff0a 102 * SQM_COLUMN_HEADER_TEXT
103 * 9 - SQM_BUTTON_BACKGROUND
104 * 10 - SQM_BLOCK_TITLE
105 * 11 - SQM_TEXT_SPECIAL
106 * 12 - SQM_BUTTON_BACKGROUND_TEXT, SQM_BLOCK_BACKGROUND, SQM_ROW_BACKGROUND_2
107 * 13 - SQM_MESSAGE_QUOTE_1
108 * 14 - SQM_MESSAGE_QUOTE_2
109 * 15 - SQM_TEXT_HIGHLIGHT
110 * 16 - SQM_ROW_BACKGROUND_SELECTED
111 */
112define('SQM_BACKGROUND',$color[4]);
113define('SQM_BACKGROUND_LEFT',$color[3]);
114
115define('SQM_TEXT_STANDARD',$color[8]);
116define('SQM_TEXT_STANDARD_LEFT',$color[6]);
117define('SQM_TEXT_HIGHLIGHT',$color[15]);
118define('SQM_TEXT_DISABLED',$color[0]);
119define('SQM_TEXT_SPECIAL',$color[11]);
120
121define('SQM_LINK',$color[7]);
122define('SQM_LINK_LEFT',$color[6]);
123
124define('SQM_TITLE_BACKGROUND',$color[0]);
125define('SQM_TITLE_TEXT',$color[7]);
126
127define('SQM_BUTTON_BACKGROUND',$color[9]);
128define('SQM_BUTTON_TEXT',$color[8]);
129define('SQM_BUTTON_BACKGROUND_DISABLED',$color[0]);
130define('SQM_BUTTON_BACKGROUND_TEXT',$color[12]);
131
132define('SQM_BLOCK_BACKGROUND',$color[12]);
133define('SQM_BLOCK_TEXT',$color[8]);
134define('SQM_BLOCK_TITLE',$color[10]);
135define('SQM_BLOCK_TITLE_TEXT',$color[7]);
136
137define('SQM_ROW_BACKGROUND_1',$color[0]);
138define('SQM_ROW_BACKGROUND_2',$color[12]);
139define('SQM_ROW_TEXT_1',$color[8]);
140define('SQM_ROW_TEXT_2',$color[8]);
141define('SQM_ROW_BACKGROUND_HIGHLIGHT',$color[5]);
142define('SQM_ROW_TEXT_HIGHLIGHT',$color[8]);
143define('SQM_ROW_BACKGROUND_SELECTED',$color[16]);
144define('SQM_ROW_TEXT_SELECTED',$color[8]);
145
146define('SQM_COLUMN_HEADER_BACKGROUND',$color[5]);
147define('SQM_COLUMN_HEADER_TEXT',$color[8]);
148
149define('SQM_MESSAGE_QUOTE_1',$color[13]);
150define('SQM_MESSAGE_QUOTE_2',$color[14]);
151
152define('SQM_ERROR_TEXT',$color[2]);
153
5c4ff7bf 154define('SQM_ALIGN_LEFT', $align['left']);
155define('SQM_ALIGN_RIGHT', $align['right']);
156
d3c2ff0a 157if (sqgetGlobalVar('fontset',$fontset,SQ_GET) &&
158 isset($fontsets[$fontset])) {
6309ffc2 159 $fontfamily=$fontsets[$fontset];
d3c2ff0a 160} else {
161 $fontfamily='';
162}
163$oTemplate->assign('fontfamily', $fontfamily);
164
165if (! sqgetGlobalVar('fontsize',$fontsize,SQ_GET)) {
166 $fontsize = 0;
167} else {
168 $fontsize = (int) $fontsize;
169}
170$oTemplate->assign('fontsize', $fontsize);
171
172header('Content-Type: text/css');
00a68572 173// output a last-modified header if we can
174if ( $lastmod = @filemtime($oTemplate->template_dir . 'stylesheet.tpl') ) {
175 $gmlastmod = gmdate('D, d M Y H:i:s', $lastmod) . ' GMT';
176 header('Last-Modified: ' . $gmlastmod);
177}
d3c2ff0a 178$oTemplate->display('stylesheet.tpl');
179
00a68572 180?>