First attempt at converting $color themes to CSS stylesheets. Seems to work pretty...
[squirrelmail.git] / themes / color_theme_to_css.php
CommitLineData
7e2ddf11 1#!/usr/bin/env php
2<?php
3/**
4 * color_theme_to_css.php
5 *
6 * This script can be used to convert an old $color theme to a stylesheet for
7 * use with templates. Output is sent to STDOUT.
8 *
9 * HOWTO:
10 * 1. Create a .php file containing your $color theme.
11 * 2. Run this script from a command line, giving the name of your theme file
12 * as an arguement to this script, e.g.:
13 *
14 * /path/to/squirrelmail/templates/theme_to_css.php /path/to/mytheme.php
15 *
16 * To send the output to a .css file, do the following:
17 *
18 * /path/to/squirrelmail/templates/theme_to_css.php /path/to/mytheme.php > my_theme.css
19 *
20 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
21 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
22 * @version $Id$
23 * @package squirrelmail
24 * @subpackage templates
25 * @author Steve Brown
26 * @since 1.5.2
27 */
28
29if (empty($argv[1])) {
30 echo "Please provide the path to the file containing the \$color theme you\n" .
31 "wish to convert to a stylesheet.\n\n";
32 exit (1);
33}
34
35$theme_file = $argv[1];
36if (!is_file($theme_file) || !is_readable($theme_file)) {
37 echo "The requested theme could not be converted because the file could not\n" .
38 "be opened. Please specify a theme file that can be read.\n\n";
39 exit(1);
40}
41
42/* set default colors in case color theme is not full */
43$def_color = array();
44$def_color[0] = '#dcdcdc'; // (light gray) TitleBar
45$def_color[1] = '#800000'; // (red)
46$def_color[2] = '#cc0000'; // (light red) Warning/Error Messages
47$def_color[3] = '#a0b8c8'; // (green-blue) Left Bar Background
48$def_color[4] = '#ffffff'; // (white) Normal Background
49$def_color[5] = '#ffffcc'; // (light yellow) Table Headers
50$def_color[6] = '#000000'; // (black) Text on left bar
51$def_color[7] = '#0000cc'; // (blue) Links
52$def_color[8] = '#000000'; // (black) Normal text
53$def_color[9] = '#ababab'; // (mid-gray) Darker version of #0
54$def_color[10] = '#666666'; // (dark gray) Darker version of #9
55$def_color[11] = '#770000'; // (dark red) Special Folders color
56$def_color[12] = '#ededed'; // (light gray) Alternate color for message list
57$def_color[13] = '#800000'; // (dark red) Color for quoted text -- > 1 quote
58$def_color[14] = '#ff0000'; // (red) Color for quoted text -- >> 2 or more
59$def_color[15] = '#002266'; // (dark blue) Unselectable folders
60$def_color[16] = '#ff9933'; // (orange) Highlight color
61
62$color = $def_color;
63include($theme_file);
64if ($color === $def_color) {
65 echo "The theme file you specified did not make any alterations to the default\n" .
66 "color scheme. Please choose a different file.\n\n";
67 exit(1);
68}
69
70$css_source = <<<CSS
71/* older css template */
72/* page body formatting */
73body {
74 color: __COLOR8__;
75 background-color: __COLOR4__;
76}
77body.sqm_leftMain {
78 color: __COLOR6__;
79 background-color: __COLOR3__;
80}
81
82/* right links */
83a:link, a:visited, a:hover, a:active {
84 color: __COLOR7__;
85}
86
87/* left links */
88.sqm_leftMain a:link, .sqm_leftMain a:visited, .sqm_leftMain a:hover, .sqm_leftMain a:active {
89 color: __COLOR6__;
90}
91.leftunseen, .leftspecial, .leftspecial a:link, .leftspecial a:visited, .leftspecial a:hover, .leftspecial a:active {
92 color: __COLOR11__;
93}
94.leftnoselect a:link, .leftnoselect a:visited, .leftnoselect a:hover, .leftnoselect a:active {
95 color: __COLOR15__;
96}
97
98/* highlighted texts */
99.highlight {
100 color: __COLOR15__;
101}
102.error_table {
103 color: __COLOR14__;
104 border: 2px solid __COLOR0__;
105 background-color: __COLOR3__;
106}
107.error_thead {
108 background-color: __COLOR10__;
109}
110.error_thead_caption {
111 background-color: __COLOR10__;
112}
113.error_row {
114 color: __COLOR14__;
115}
116.error_val {
117 color: __COLOR8__;
118 border: 2px solid __COLOR0__;
119
120}
121.error_key {
122 border: 2px solid __COLOR0__;
123 color: __COLOR14__;
124 background-color: __COLOR0__;
125}
126
127/* Standard defs */
128table.table1 {
129 border: 1px solid __COLOR0__;
130}
131table.table2 {
132 border: 1px solid __COLOR9__;
133}
134td.header1 {
135 background: __COLOR0__;
136}
137td.header2 {
138 background: __COLOR9__;
139}
140td.header4 {
141 background: __COLOR5__;
142}
143tr.even {
144 background: __COLOR12__;
145}
146tr.odd {
147 background: __COLOR4__;
148}
149.table_standard {
150 border:1px solid __COLOR0__;
151}
152
153.sqm_loginOrgName, .sqm_signoutBar {
154 background: __COLOR0__;
155}
156.sqm_motd {
157 background: __COLOR9__;
158}
159.sqm_motd td {
160 background: __COLOR4__;
161}
162
163/* empty_folder.tpl defs */
164.sqm_emptyFolder {
165 background: __COLOR9__;
166}
167.sqm_emptyFolder td {
168 background: __COLOR4__;
169}
170
171/* error_box.tpl definitions */
172.table_errorBoxWrapper {
173 background: __COLOR9__;
174}
175.table_errorBox {
176 background: __COLOR0__;
177}
178.error_message {
179 background: __COLOR4__;
180}
181
182/* page_header.tpl definitions */
183.sqm_currentFolder {
184 background: __COLOR9__;
185}
186.sqm_headerSignout {
187 background: __COLOR9__;
188}
189
190/* message_list.tpl definitions */
191.table_messageListWrapper {
192 background: __COLOR9__;
193}
194
195.table_messageList {
196 background: __COLOR5__;
197}
198.table_messageList td.spacer {
199 background: __COLOR0__;
200}
201.table_messageList tr.mouse_over {
202 background: __COLOR5__;
203}
204.table_messageList tr.clicked {
205 background: __COLOR16__;
206}
207.deleted {
208 color: __COLOR9__;
209}
210.flagged {
211 color: __COLOR2__;
212}
213.high_priority {
214 color: __COLOR1__;
215}
216.low_priority {
217 color: __COLOR8__;
218}
219.message_list_controls {
220 background: __COLOR0__;
221}
222.spacer {
223 background: __COLOR4__;
224}
225
226/* folder_manip.tpl defs */
227#folderManip table.wrapper {
228 border: 1px solid __COLOR0__;
229}
230#folderManip td.folderAction {
231 background: __COLOR0__;
232}
233
234/* addressbook_list.tpl defs */
235#addressList table {
236 border: 1px solid __COLOR9__;
237}
238#addressList td.header1 {
239 background: __COLOR9__;
240}
241#addressList td.abookSwitch {
242 background: __COLOR0__;
243}
244
245#addressList td.abookButtons {
246 background: __COLOR0__;
247}
248#addressList td.abookField {
249 border-left: 1px solid __COLOR9__;
250 border-right: 1px solid __COLOR9__;
251}
252#addressList td.colHeader {
253 background: __COLOR9__;
254}
255#addrBookSearch table.wrapper {
256 border: 1px solid __COLOR9__;
257}
258#addrAddEdit table {
259 border: 1px solid __COLOR9__;
260}
261#addrAddEdit td.header {
262 background: __COLOR9__;
263}
264
265/* options defs */
266#optionGroups table {
267 border: 1px solid __COLOR0__;
268}
269#optionGroups td.title {
270 background: __COLOR0__;
271}
272#optionGroups td.optionElement table {
273 border:1px solid __COLOR9__;
274}
275#optionGroups td.optionName {
276 background: __COLOR9__;
277}
278#optionGroups td.optionDesc {
279 background: __COLOR0__;
280}
281#optionDisplay table {
282 border: 1px solid __COLOR0__
283}
284#optionOrder table {
285 border: 1px solid __COLOR0__
286}
287#optionOrder table.moveFields td {
288 border-left: 1px solid __COLOR0__;
289 border-right: 1px solid __COLOR0__;
290}
291#optionsIdentity table.table2 tr {
292 background: __COLOR0__;
293}
294#optionsIdentity hr {
295 width: 95%;
296 border: 1px solid __COLOR9__;
297}
298
299/* help defs */
300#help td.nav {
301 color: __COLOR0__;
302}
303
304/* search defs */
305div.search td.header4 {
306 border-bottom: 1px solid __COLOR9__;
307}
308div.search td.queryAction {
309 border-left: 1px solid __COLOR9__;
310 border-top: 1px solid __COLOR9__;
311 border-bottom: 1px solid __COLOR9__;
312}
313
314div.search td.queryDesc {
315 border-top: 1px solid __COLOR9__;
316 border-bottom: 1px solid __COLOR9__;
317}
318div.search span.error {
319 color: __COLOR2__;
320}
321div.search td.searchForm {
322 border-right: 1px solid __COLOR0__;
323 border-left: 1px solid __COLOR0__;
324}
325div.search td.queryError {
326 color: __COLOR2__;
327}
328div.search h2 {
329 color: __COLOR2__;
330}
331
332/* compse defs */
333div.compose tr.header {
334 background: __COLOR9__;
335}
336div.compose tr.attachment td {
337 background: __COLOR0__;
338 border-top: 1px solid __COLOR9__;
339 border-bottom: 1px solid __COLOR9__;
340}
341
342div.compose table.close {
343 background: __COLOR0__;
344 border:1px solid __COLOR9__;
345}
346CSS;
347
348$p = array();
349for ($k = 0; $k<=16; $k++) {
350 $p[$k] = '__COLOR'.$k.'__';
351 if (!isset($color[$k])) {
352 $color[$k] = $def_color[$k];
353 }
354}
355
356// Just to make sure...
357ksort($p);
358ksort($color);
359$css_source = str_replace($p, $color, $css_source);
360echo $css_source;
361exit(0);
362?>