diff options
| author | Savetheinternet <savetheinternet@n0v4.com> | 2011-04-17 01:28:25 +1000 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@n0v4.com> | 2011-04-17 01:28:25 +1000 |
| commit | e47279b3f078b133a1ddb132264c401ed713357e (patch) | |
| tree | 45ab65aa69f7eb4ce6b673005499ffa8c1e34575 | |
| parent | 21d97bab29cc09c807bfa08c751aa47a55987539 (diff) | |
theme update
| -rw-r--r-- | mod.php | 4 | ||||
| -rw-r--r-- | templates/homepage/recent/info.php | 7 | ||||
| -rw-r--r-- | templates/homepage/recent/theme.php | 23 |
3 files changed, 28 insertions, 6 deletions
@@ -286,7 +286,7 @@ // Check if everything is submitted foreach($theme['config'] as &$c) { 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 @@ -327,6 +327,8 @@ default: $body .= '<input type="text" name="' . $c['name'] . '" />'; } + if(isset($c['comment'])) + $body .= ' <span class="unimportant">' . $c['comment'] . '</span>'; $body .= '</td></tr>'; } $body .= '</table>'; diff --git a/templates/homepage/recent/info.php b/templates/homepage/recent/info.php index 2f5c977a..734908c4 100644 --- a/templates/homepage/recent/info.php +++ b/templates/homepage/recent/info.php @@ -16,6 +16,13 @@ 'type' => 'text' ); + $theme['config'][] = Array( + 'title' => 'Excluded boards', + 'name' => 'exclude', + 'type' => 'text', + 'comment' => '(space seperated)' + ); + // Unique function name for building everything $theme['build_function'] = 'recentposts_build'; ?>
\ No newline at end of file diff --git a/templates/homepage/recent/theme.php b/templates/homepage/recent/theme.php index 963ce235..f7c5da45 100644 --- a/templates/homepage/recent/theme.php +++ b/templates/homepage/recent/theme.php @@ -8,25 +8,28 @@ // - boards (board list changed) // - 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 class Basic { - public static function build($action, $settings) { + public function build($action, $settings) { global $config, $_theme; if($action == 'all') { copy($config['dir']['homepage'] . '/' . $_theme . '/recent.css', $config['dir']['home'] . 'recent.css'); } + $this->excluded = explode(' ', $settings['exclude']); + if($action == 'all' || $action == 'post') - // file_put_contents($config['dir']['home'] . $config['file_index'], Basic::homepage($settings)); - file_put_contents($config['dir']['home'] . 'recent.html', Basic::homepage($settings)); + // file_put_contents($config['dir']['home'] . $config['file_index'], $this->homepage($settings)); + file_put_contents($config['dir']['home'] . 'recent.html', $this->homepage($settings)); } // Build news page - public static function homepage($settings) { + public function homepage($settings) { global $config, $board; // HTML5 @@ -52,6 +55,8 @@ $body .= '<div class="box left"><h2>Recent Images</h2><ul>'; $query = ''; 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 = 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>'; $query = ''; 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 = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT 30', $query); @@ -92,6 +99,8 @@ // Total posts $query = 'SELECT SUM(`top`) AS `count` FROM ('; 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 = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); @@ -102,6 +111,8 @@ // Unique IPs $query = 'SELECT COUNT(DISTINCT(`ip`)) AS `count` FROM ('; foreach($boards as &$_board) { + if(in_array($_board['uri'], $this->excluded)) + continue; $query .= sprintf("SELECT `ip` FROM `posts_%s` UNION ALL ", $_board['uri']); } $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); @@ -112,6 +123,8 @@ // Active content $query = 'SELECT SUM(`filesize`) AS `count` FROM ('; foreach($boards as &$_board) { + if(in_array($_board['uri'], $this->excluded)) + continue; $query .= sprintf("SELECT `filesize` FROM `posts_%s` UNION ALL ", $_board['uri']); } $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); |
