1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-30 18:24:29 +01:00

theme update

This commit is contained in:
Savetheinternet 2011-04-17 01:28:25 +10:00
parent 21d97bab29
commit e47279b3f0
3 changed files with 28 additions and 6 deletions

View File

@ -286,7 +286,7 @@
// Check if everything is submitted // Check if everything is submitted
foreach($theme['config'] as &$c) { foreach($theme['config'] as &$c) {
if(!isset($_POST[$c['name']]) && $c['type'] != 'checkbox') if(!isset($_POST[$c['name']]) && $c['type'] != 'checkbox')
error(spritnf($config['error']['required'], $c['title'])); error(sprintf($config['error']['required'], $c['title']));
} }
// Clear previous settings // Clear previous settings
@ -327,6 +327,8 @@
default: default:
$body .= '<input type="text" name="' . $c['name'] . '" />'; $body .= '<input type="text" name="' . $c['name'] . '" />';
} }
if(isset($c['comment']))
$body .= ' <span class="unimportant">' . $c['comment'] . '</span>';
$body .= '</td></tr>'; $body .= '</td></tr>';
} }
$body .= '</table>'; $body .= '</table>';

View File

@ -16,6 +16,13 @@
'type' => 'text' 'type' => 'text'
); );
$theme['config'][] = Array(
'title' => 'Excluded boards',
'name' => 'exclude',
'type' => 'text',
'comment' => '(space seperated)'
);
// Unique function name for building everything // Unique function name for building everything
$theme['build_function'] = 'recentposts_build'; $theme['build_function'] = 'recentposts_build';
?> ?>

View File

@ -8,25 +8,28 @@
// - boards (board list changed) // - boards (board list changed)
// - post (a post has been made) // - post (a post has been made)
Basic::build($action, $settings); $b = new Basic();
$b->build($action, $settings);
} }
// Wrap functions in a class so they don't interfere with normal Tinyboard operations // Wrap functions in a class so they don't interfere with normal Tinyboard operations
class Basic { class Basic {
public static function build($action, $settings) { public function build($action, $settings) {
global $config, $_theme; global $config, $_theme;
if($action == 'all') { if($action == 'all') {
copy($config['dir']['homepage'] . '/' . $_theme . '/recent.css', $config['dir']['home'] . 'recent.css'); copy($config['dir']['homepage'] . '/' . $_theme . '/recent.css', $config['dir']['home'] . 'recent.css');
} }
$this->excluded = explode(' ', $settings['exclude']);
if($action == 'all' || $action == 'post') if($action == 'all' || $action == 'post')
// file_put_contents($config['dir']['home'] . $config['file_index'], Basic::homepage($settings)); // file_put_contents($config['dir']['home'] . $config['file_index'], $this->homepage($settings));
file_put_contents($config['dir']['home'] . 'recent.html', Basic::homepage($settings)); file_put_contents($config['dir']['home'] . 'recent.html', $this->homepage($settings));
} }
// Build news page // Build news page
public static function homepage($settings) { public function homepage($settings) {
global $config, $board; global $config, $board;
// HTML5 // HTML5
@ -52,6 +55,8 @@
$body .= '<div class="box left"><h2>Recent Images</h2><ul>'; $body .= '<div class="box left"><h2>Recent Images</h2><ul>';
$query = ''; $query = '';
foreach($boards as &$_board) { foreach($boards as &$_board) {
if(in_array($_board['uri'], $this->excluded))
continue;
$query .= sprintf("SELECT *, '%s' AS `board` FROM `posts_%s` WHERE `file` IS NOT NULL UNION ALL ", $_board['uri'], $_board['uri']); $query .= sprintf("SELECT *, '%s' AS `board` FROM `posts_%s` WHERE `file` IS NOT NULL UNION ALL ", $_board['uri'], $_board['uri']);
} }
$query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT 3', $query); $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT 3', $query);
@ -70,6 +75,8 @@
$body .= '<div class="box right"><h2>Latest Posts</h2><ul>'; $body .= '<div class="box right"><h2>Latest Posts</h2><ul>';
$query = ''; $query = '';
foreach($boards as &$_board) { foreach($boards as &$_board) {
if(in_array($_board['uri'], $this->excluded))
continue;
$query .= sprintf("SELECT *, '%s' AS `board` FROM `posts_%s` UNION ALL ", $_board['uri'], $_board['uri']); $query .= sprintf("SELECT *, '%s' AS `board` FROM `posts_%s` UNION ALL ", $_board['uri'], $_board['uri']);
} }
$query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT 30', $query); $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT 30', $query);
@ -92,6 +99,8 @@
// Total posts // Total posts
$query = 'SELECT SUM(`top`) AS `count` FROM ('; $query = 'SELECT SUM(`top`) AS `count` FROM (';
foreach($boards as &$_board) { foreach($boards as &$_board) {
if(in_array($_board['uri'], $this->excluded))
continue;
$query .= sprintf("SELECT MAX(`id`) AS `top` FROM `posts_%s` UNION ALL ", $_board['uri']); $query .= sprintf("SELECT MAX(`id`) AS `top` FROM `posts_%s` UNION ALL ", $_board['uri']);
} }
$query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);
@ -102,6 +111,8 @@
// Unique IPs // Unique IPs
$query = 'SELECT COUNT(DISTINCT(`ip`)) AS `count` FROM ('; $query = 'SELECT COUNT(DISTINCT(`ip`)) AS `count` FROM (';
foreach($boards as &$_board) { foreach($boards as &$_board) {
if(in_array($_board['uri'], $this->excluded))
continue;
$query .= sprintf("SELECT `ip` FROM `posts_%s` UNION ALL ", $_board['uri']); $query .= sprintf("SELECT `ip` FROM `posts_%s` UNION ALL ", $_board['uri']);
} }
$query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);
@ -112,6 +123,8 @@
// Active content // Active content
$query = 'SELECT SUM(`filesize`) AS `count` FROM ('; $query = 'SELECT SUM(`filesize`) AS `count` FROM (';
foreach($boards as &$_board) { foreach($boards as &$_board) {
if(in_array($_board['uri'], $this->excluded))
continue;
$query .= sprintf("SELECT `filesize` FROM `posts_%s` UNION ALL ", $_board['uri']); $query .= sprintf("SELECT `filesize` FROM `posts_%s` UNION ALL ", $_board['uri']);
} }
$query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);