allowed enabling multiple themes simultaneously

This commit is contained in:
Savetheinternet 2011-05-28 01:43:04 +10:00
parent bb67062cd5
commit d9b82cfe4f
5 changed files with 29 additions and 21 deletions

27
mod.php
View file

@ -344,21 +344,24 @@
}
// Clear previous settings
query("TRUNCATE TABLE `theme_settings`") or error(db_error());
$query = prepare("DELETE FROM `theme_settings` WHERE `theme` = :theme");
$query->bindValue(':theme', $_theme);
$query->execute() or error(db_error($query));
foreach($theme['config'] as &$c) {
$query = prepare("INSERT INTO `theme_settings` VALUES(:name, :value)");
$query = prepare("INSERT INTO `theme_settings` VALUES(:theme, :name, :value)");
$query->bindValue(':theme', $_theme);
$query->bindValue(':name', $c['name']);
$query->bindValue(':value', $_POST[$c['name']]);
$query->execute() or error(db_error($query));
}
$query = prepare("INSERT INTO `theme_settings` VALUES('theme', :value)");
$query->bindValue(':value', $_theme);
$query = prepare("INSERT INTO `theme_settings` VALUES(:theme, NULL, NULL)");
$query->bindValue(':theme', $_theme);
$query->execute() or error(db_error($query));
// Build theme
rebuildTheme('all');
// Build themes
rebuildThemes('all');
echo Element('page.html', Array(
'config'=>$config,
@ -545,7 +548,7 @@
$query->bindValue(':id', $match[1], PDO::PARAM_INT);
$query->execute() or error(db_error($query));
rebuildTheme('news');
rebuildThemes('news');
header('Location: ?/news', true, $config['redirect_http']);
} elseif(preg_match('/^\/news$/', $query)) {
@ -568,7 +571,7 @@
$query->bindValue(':body', $_POST['body']);
$query->execute() or error(db_error($query));
rebuildTheme('news');
rebuildThemes('news');
}
$body .= '<fieldset><legend>New post</legend><form style="display:inline" action="" method="post"><table>' .
@ -1260,7 +1263,7 @@
$query->bindValue(':id', $board['id'], PDO::PARAM_INT);
$query->execute() or error(db_error($query));
rebuildTheme('boards');
rebuildThemes('boards');
header('Location: ?/', true, $config['redirect_http']);
} else {
@ -1276,7 +1279,7 @@
$query->bindValue(':id', $board['id'], PDO::PARAM_INT);
$query->execute() or error(db_error($query));
rebuildTheme('boards');
rebuildThemes('boards');
openBoard($board['uri']);
}
@ -1453,7 +1456,7 @@
$body = '<div class="ban"><h2>Rebuilding…</h2><p>';
$body .= 'Regenerating theme files…<br/>';
rebuildTheme('all');
rebuildThemes('all');
$body .= 'Generating Javascript file…<br/>';
buildJavascript();
@ -1599,7 +1602,7 @@
// Build the board
buildIndex();
rebuildTheme('boards');
rebuildThemes('boards');
header('Location: ?/board/' . $board['uri'], true, $config['redirect_http']);
} else {