restoring globalization of text alignment vars.
[squirrelmail.git] / src / style.php
1 <?php
2 /**
3 * Style sheet script
4 *
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
9 * <li>templateid - string, sets template directory from templates/
10 * <li>fontset - string, sets selected set of fonts from $fontsets array.
11 * <li>fontsize - integer, sets selected font size
12 * </ul>
13 * @copyright &copy; 2005-2006 The SquirrelMail Project Team
14 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
15 * @version $Id$
16 * @package squirrelmail
17 */
18
19 /** @ignore */
20 define('SM_PATH','../');
21
22 /* SquirrelMail required files. */
23 require_once(SM_PATH . 'functions/global.php');
24 require_once(SM_PATH . 'functions/strings.php');
25 require_once(SM_PATH . 'config/config.php');
26
27 /* safety check for older config.php */
28 if (!isset($fontsets) || !is_array($fontsets)) {
29 $fontsets=array();
30 }
31
32
33 /* template init */
34 /** start block copy from right_main.php */
35 include_once(SM_PATH . 'class/template/template.class.php');
36
37 /* get template name and set used template directory */
38 if (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
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 */
69 if (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
76 /**
77 * Get text direction
78 */
79 if (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');
84 }
85
86 /**/
87 $oTemplate->assign('color', $color);
88
89 /**
90 * set color constants in order to use simple names instead of color array
91 * 0 - SQM_TEXT_DISABLED, SQM_TITLE_BACKGROUND, SQM_BUTTON_BACKGROUND_DISABLED,
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
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,
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 */
112 define('SQM_BACKGROUND',$color[4]);
113 define('SQM_BACKGROUND_LEFT',$color[3]);
114
115 define('SQM_TEXT_STANDARD',$color[8]);
116 define('SQM_TEXT_STANDARD_LEFT',$color[6]);
117 define('SQM_TEXT_HIGHLIGHT',$color[15]);
118 define('SQM_TEXT_DISABLED',$color[0]);
119 define('SQM_TEXT_SPECIAL',$color[11]);
120
121 define('SQM_LINK',$color[7]);
122 define('SQM_LINK_LEFT',$color[6]);
123
124 define('SQM_TITLE_BACKGROUND',$color[0]);
125 define('SQM_TITLE_TEXT',$color[7]);
126
127 define('SQM_BUTTON_BACKGROUND',$color[9]);
128 define('SQM_BUTTON_TEXT',$color[8]);
129 define('SQM_BUTTON_BACKGROUND_DISABLED',$color[0]);
130 define('SQM_BUTTON_BACKGROUND_TEXT',$color[12]);
131
132 define('SQM_BLOCK_BACKGROUND',$color[12]);
133 define('SQM_BLOCK_TEXT',$color[8]);
134 define('SQM_BLOCK_TITLE',$color[10]);
135 define('SQM_BLOCK_TITLE_TEXT',$color[7]);
136
137 define('SQM_ROW_BACKGROUND_1',$color[0]);
138 define('SQM_ROW_BACKGROUND_2',$color[12]);
139 define('SQM_ROW_TEXT_1',$color[8]);
140 define('SQM_ROW_TEXT_2',$color[8]);
141 define('SQM_ROW_BACKGROUND_HIGHLIGHT',$color[5]);
142 define('SQM_ROW_TEXT_HIGHLIGHT',$color[8]);
143 define('SQM_ROW_BACKGROUND_SELECTED',$color[16]);
144 define('SQM_ROW_TEXT_SELECTED',$color[8]);
145
146 define('SQM_COLUMN_HEADER_BACKGROUND',$color[5]);
147 define('SQM_COLUMN_HEADER_TEXT',$color[8]);
148
149 define('SQM_MESSAGE_QUOTE_1',$color[13]);
150 define('SQM_MESSAGE_QUOTE_2',$color[14]);
151
152 define('SQM_ERROR_TEXT',$color[2]);
153
154 define('SQM_ALIGN_LEFT', $align['left']);
155 define('SQM_ALIGN_RIGHT', $align['right']);
156
157 if (sqgetGlobalVar('fontset',$fontset,SQ_GET) &&
158 isset($fontsets[$fontset])) {
159 $fontfamily=$fontsets[$fontset];
160 } else {
161 $fontfamily='';
162 }
163 $oTemplate->assign('fontfamily', $fontfamily);
164
165 if (! sqgetGlobalVar('fontsize',$fontsize,SQ_GET)) {
166 $fontsize = 0;
167 } else {
168 $fontsize = (int) $fontsize;
169 }
170 $oTemplate->assign('fontsize', $fontsize);
171
172 header('Content-Type: text/css');
173 // output a last-modified header if we can
174 if ( $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 }
178 $oTemplate->display('stylesheet.tpl');
179
180 ?>