Revert "Fix encoding"
[infodrom/hallinta] / theme.php
index 98986f0..8cbede4 100644 (file)
--- a/theme.php
+++ b/theme.php
@@ -2,24 +2,24 @@
 require_once('init.php');
 require_once('lib/general.php');
 
-$theme = 2;
+$theme = $_SESSION['sys']['theme'];
 
-$sql = sprintf("SELECT sys_theme_keys.name,value FROM sys_theme_values " .
-              "JOIN sys_theme_keys ON key = sys_theme_keys.id WHERE theme = %d",
+$sql = sprintf("SELECT sys_theme_items.name,value FROM sys_theme_values " .
+              "JOIN sys_theme_items ON item = sys_theme_items.id WHERE theme = %d",
               $theme);
-$sth = pg_query($sql);
+$sth = $db->query($sql);
 
 if ($sth === false) exit;
 
 $styles = array();
-while ($row = pg_fetch_assoc($sth)) {
+while ($row = $sth->fetch()) {
   switch ($row['name']) {
   case 'box-background':
     $styles['div.ricoContent']['background-color'] = $row['value'];
     $styles['div.form']['background-color'] = $row['value'];
     break;
   case 'box-title-background':
-    $styles['div.ricoTitle']['background-color'] = $row['value'];
+    $styles['div.ricoTitle.ui-widget-header']['background-color'] = $row['value'];
     $styles['div.form p.title']['background-color'] = $row['value'];
     $styles['.ricoLG_table th']['background-color'] = $row['value'];
     break;
@@ -49,12 +49,24 @@ while ($row = pg_fetch_assoc($sth)) {
   case 'title2-bottom':
     $styles['h3.title2']['border-bottom'] = $row['value'];
     break;
+  case 'details-background':
+    $styles['div.box#details']['background-color'] = $row['value'];
+    break;
+  case 'form-elem-background':
+    $styles['#form_edit input:focus']['background-color'] = $row['value'];
+    $styles['#form_edit select:focus']['background-color'] = $row['value'];
+    $styles['#form_edit textarea:focus']['background-color'] = $row['value'];
+    break;
   }
 }
 
-error_log(var_export($styles,true));
 header('Content-type: text/css');
 
+if (defined('PATH_CSS') && (($f = fopen(PATH_CSS,'r')) !== false)) {
+    fpassthru($f);
+    fclose($f);
+}
+
 foreach ($styles as $name => $data) {
   printf("%s {\n", $name);
   foreach ($data as $key => $value)