diff -r 5faff33a6580 -r cb7dde69c301 plugins/SpecialAdmin.php
--- a/plugins/SpecialAdmin.php Mon Jul 30 10:46:17 2007 -0400
+++ b/plugins/SpecialAdmin.php Wed Aug 01 13:39:27 2007 -0400
@@ -1888,7 +1888,7 @@
}
}
elseif(isset($_POST['install'])) {
- $q = 'SELECT * FROM '.table_prefix.'themes;';
+ $q = 'SELECT theme_id FROM '.table_prefix.'themes;';
$s = $db->sql_query($q);
if(!$s) die('Error getting theme count: '.mysql_error().'
SQL:
'.$q);
$n = $db->numrows($s);
@@ -1896,10 +1896,42 @@
$theme_id = $_POST['theme_id'];
$theme = Array();
include('./themes/'.$theme_id.'/theme.cfg');
- $q = 'INSERT INTO '.table_prefix.'themes(theme_id,theme_name,theme_order,enabled) VALUES(\''.$theme['theme_id'].'\', \''.$theme['theme_name'].'\', '.$n.', 1)';
- $s = $db->sql_query($q);
- if(!$s) die('Error inserting theme data: '.mysql_error().'
SQL:
'.$q);
- else echo('
Theme "'.$theme['theme_name'].'" installed.
');
+ if ( !isset($theme['theme_id']) )
+ {
+ echo 'Could not load theme.cfg (theme metadata file)
';
+ }
+ else
+ {
+ $default_style = false;
+ if ( $dh = opendir('./themes/' . $theme_id . '/css') )
+ {
+ while ( $file = readdir($dh) )
+ {
+ if ( $file != '_printable.css' && preg_match('/\.css$/i', $file) )
+ {
+ $default_style = $file;
+ break;
+ }
+ }
+ closedir($dh);
+ }
+ else
+ {
+ die('The /css subdirectory could not be located in the theme\'s directory');
+ }
+
+ if ( $default_style )
+ {
+ $q = 'INSERT INTO '.table_prefix.'themes(theme_id,theme_name,theme_order,enabled,default_style) VALUES(\''.$db->escape($theme['theme_id']).'\', \''.$db->escape($theme['theme_name']).'\', '.$n.', 1, \'' . $db->escape($default_style) . '\')';
+ $s = $db->sql_query($q);
+ if(!$s) die('Error inserting theme data: '.mysql_error().'
SQL:
'.$q);
+ else echo('Theme "'.$theme['theme_name'].'" installed.
');
+ }
+ else
+ {
+ echo 'Could not determine the default style for the theme.
';
+ }
+ }
}
echo('
Currently installed themes