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

73 lines
2.0 KiB
PHP
Raw Normal View History

<?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;
if($action == 'all')
2012-02-14 11:26:08 +01:00
file_write($config['dir']['home'] . $settings['file_main'], Categories::homepage($settings));
if($action == 'all' || $action == 'boards')
2012-02-14 11:26:08 +01:00
file_write($config['dir']['home'] . $settings['file_sidebar'], Categories::sidebar($settings));
if($action == 'all' || $action == 'news')
2012-02-14 11:26:08 +01:00
file_write($config['dir']['home'] . $settings['file_news'], Categories::news($settings));
}
// Build homepage
public static function homepage($settings) {
global $config;
2012-02-14 11:26:08 +01:00
return Element('themes/frameset/frames.html', Array('config' => $config, 'settings' => $settings));
}
// 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 11:26:08 +01:00
$news = $query->fetchAll(PDO::FETCH_ASSOC);
2012-02-14 11:26:08 +01:00
return Element('themes/frameset/news.html', Array(
'settings' => $settings,
'config' => $config,
'news' => $news
));
}
// Build sidebar
public static function sidebar($settings) {
global $config, $board;
2012-02-14 11:26:08 +01:00
$categories = $config['categories'];
2012-02-14 11:26:08 +01:00
foreach($categories as &$boards) {
foreach($boards as &$board) {
$title = boardTitle($board);
if(!$title)
$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 15:00:13 +02:00
}
}
2012-02-14 11:26:08 +01:00
return Element('themes/frameset/sidebar.html', Array(
'settings' => $settings,
'config' => $config,
'categories' => $categories
));
}
};
?>