Need to supply the sequence name and noth the schema name
[infodrom/hallinta] / theme.php
1 <?php
2 require_once('init.php');
3 require_once('lib/general.php');
4
5 $theme = $_SESSION['sys']['theme'];
6
7 $sql = sprintf("SELECT sys_theme_items.name,value FROM sys_theme_values " .
8                "JOIN sys_theme_items ON item = sys_theme_items.id WHERE theme = %d",
9                $theme);
10 $sth = $db->query($sql);
11
12 if ($sth === false) exit;
13
14 $styles = array();
15 while ($row = $sth->fetch()) {
16   switch ($row['name']) {
17   case 'box-background':
18     $styles['div.ricoContent']['background-color'] = $row['value'];
19     $styles['div.form']['background-color'] = $row['value'];
20     break;
21   case 'box-title-background':
22     $styles['div.ricoTitle']['background-color'] = $row['value'];
23     $styles['div.form p.title']['background-color'] = $row['value'];
24     $styles['.ricoLG_table th']['background-color'] = $row['value'];
25     break;
26   case 'box-title-bottom':
27     $styles['div.ricoTitle']['border-bottom'] = $row['value'];
28     $styles['div.form p.title']['border-bottom'] = $row['value'];
29     $styles['.ricoLG_table th']['border-bottom'] = $row['value'];
30     break;
31   case 'box-title-foreground':
32     $styles['div.ricoTitle']['color'] = $row['value'];
33     $styles['div.form p.title']['color'] = $row['value'];
34     $styles['.ricoLG_table th']['color'] = $row['value'];
35     $styles['.ricoLG_table th a']['color'] = $row['value'];
36     break;
37   case 'table-selection':
38     $styles['div.ricoLG_selection']['background-color'] = $row['value'];
39     break;
40   case 'title1-background':
41     $styles['h3.title']['background-color'] = $row['value'];
42     break;
43   case 'title1-bottom':
44     $styles['h3.title']['border-bottom'] = $row['value'];
45     break;
46   case 'title2-background':
47     $styles['h3.title2']['background-color'] = $row['value'];
48     break;
49   case 'title2-bottom':
50     $styles['h3.title2']['border-bottom'] = $row['value'];
51     break;
52   case 'details-background':
53     $styles['div.box#details']['background-color'] = $row['value'];
54     break;
55   case 'form-elem-background':
56     $styles['#form_edit input:focus']['background-color'] = $row['value'];
57     $styles['#form_edit select:focus']['background-color'] = $row['value'];
58     $styles['#form_edit textarea:focus']['background-color'] = $row['value'];
59     break;
60   }
61 }
62
63 header('Content-type: text/css');
64
65 if (defined('PATH_CSS') && (($f = fopen(PATH_CSS,'r')) !== false)) {
66     fpassthru($f);
67     fclose($f);
68 }
69
70 foreach ($styles as $name => $data) {
71   printf("%s {\n", $name);
72   foreach ($data as $key => $value)
73     printf("  %s: %s;\n", $key, $value);
74   echo("}\n");
75 }
76 ?>