2011-09-20 15:49:07 -04:00
|
|
|
<?php
|
|
|
|
require 'info.php';
|
|
|
|
|
|
|
|
function categories_build($action, $settings) {
|
|
|
|
// Possible values for $action:
|
|
|
|
// - all (rebuild everything, initialization)
|
|
|
|
// - news (news has been updated)
|
|
|
|
// - boards (board list changed)
|
|
|
|
|
|
|
|
Categories::build($action, $settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wrap functions in a class so they don't interfere with normal Tinyboard operations
|
|
|
|
class Categories {
|
|
|
|
public static function build($action, $settings) {
|
|
|
|
global $config;
|
|
|
|
|
2012-05-05 11:33:10 -04:00
|
|
|
if ($action == 'all')
|
2012-02-14 05:26:08 -05:00
|
|
|
file_write($config['dir']['home'] . $settings['file_main'], Categories::homepage($settings));
|
2011-09-20 15:49:07 -04:00
|
|
|
|
2012-05-05 11:33:10 -04:00
|
|
|
if ($action == 'all' || $action == 'boards')
|
2012-02-14 05:26:08 -05:00
|
|
|
file_write($config['dir']['home'] . $settings['file_sidebar'], Categories::sidebar($settings));
|
2011-09-20 15:49:07 -04:00
|
|
|
|
2012-05-05 11:33:10 -04:00
|
|
|
if ($action == 'all' || $action == 'news')
|
2012-02-14 05:26:08 -05:00
|
|
|
file_write($config['dir']['home'] . $settings['file_news'], Categories::news($settings));
|
2011-09-20 15:49:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Build homepage
|
|
|
|
public static function homepage($settings) {
|
|
|
|
global $config;
|
|
|
|
|
2012-03-03 07:41:14 -05:00
|
|
|
return Element('themes/categories/frames.html', Array('config' => $config, 'settings' => $settings));
|
2011-09-20 15:49:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Build news page
|
|
|
|
public static function news($settings) {
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
$query = query("SELECT * FROM `news` ORDER BY `time` DESC") or error(db_error());
|
2012-02-14 05:26:08 -05:00
|
|
|
$news = $query->fetchAll(PDO::FETCH_ASSOC);
|
2011-09-20 15:49:07 -04:00
|
|
|
|
2012-03-03 07:41:14 -05:00
|
|
|
return Element('themes/categories/news.html', Array(
|
2012-02-14 05:26:08 -05:00
|
|
|
'settings' => $settings,
|
|
|
|
'config' => $config,
|
|
|
|
'news' => $news
|
|
|
|
));
|
2011-09-20 15:49:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Build sidebar
|
|
|
|
public static function sidebar($settings) {
|
|
|
|
global $config, $board;
|
|
|
|
|
2012-02-14 05:26:08 -05:00
|
|
|
$categories = $config['categories'];
|
2011-09-20 15:49:07 -04:00
|
|
|
|
2012-05-05 11:33:10 -04:00
|
|
|
foreach ($categories as &$boards) {
|
|
|
|
foreach ($boards as &$board) {
|
2012-02-14 05:26:08 -05:00
|
|
|
$title = boardTitle($board);
|
2012-05-05 11:33:10 -04:00
|
|
|
if (!$title)
|
2012-02-14 05:26:08 -05:00
|
|
|
$title = $board; // board doesn't exist, but for some reason you want to display it anyway
|
|
|
|
$board = Array('title' => $title, 'uri' => sprintf($config['board_path'], $board));
|
2011-10-06 09:00:13 -04:00
|
|
|
}
|
2011-09-20 15:49:07 -04:00
|
|
|
}
|
|
|
|
|
2012-03-03 07:41:14 -05:00
|
|
|
return Element('themes/categories/sidebar.html', Array(
|
2012-02-14 05:26:08 -05:00
|
|
|
'settings' => $settings,
|
|
|
|
'config' => $config,
|
|
|
|
'categories' => $categories
|
|
|
|
));
|
2011-09-20 15:49:07 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
?>
|