mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-30 18:24:29 +01:00
Themes edit: Split "post" into two seperate actions: "post" (replies) and "post-thread". And add a $board variable.
This commit is contained in:
parent
de4b5b3962
commit
e4bd9a6886
@ -239,12 +239,12 @@ function create_antibot($board, $thread = null) {
|
|||||||
return _create_antibot($board, $thread);
|
return _create_antibot($board, $thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rebuildThemes($action) {
|
function rebuildThemes($action, $board = false) {
|
||||||
// List themes
|
// List themes
|
||||||
$query = query("SELECT `theme` FROM `theme_settings` WHERE `name` IS NULL AND `value` IS NULL") or error(db_error());
|
$query = query("SELECT `theme` FROM `theme_settings` WHERE `name` IS NULL AND `value` IS NULL") or error(db_error());
|
||||||
|
|
||||||
while ($theme = $query->fetch()) {
|
while ($theme = $query->fetch()) {
|
||||||
rebuildTheme($theme['theme'], $action);
|
rebuildTheme($theme['theme'], $action, $board);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ function loadThemeConfig($_theme) {
|
|||||||
return $theme;
|
return $theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rebuildTheme($theme, $action) {
|
function rebuildTheme($theme, $action, $board = false) {
|
||||||
global $config, $_theme;
|
global $config, $_theme;
|
||||||
$_theme = $theme;
|
$_theme = $theme;
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ function rebuildTheme($theme, $action) {
|
|||||||
if (file_exists($config['dir']['themes'] . '/' . $_theme . '/theme.php')) {
|
if (file_exists($config['dir']['themes'] . '/' . $_theme . '/theme.php')) {
|
||||||
require_once $config['dir']['themes'] . '/' . $_theme . '/theme.php';
|
require_once $config['dir']['themes'] . '/' . $_theme . '/theme.php';
|
||||||
|
|
||||||
$theme['build_function']($action, themeSettings($_theme));
|
$theme['build_function']($action, themeSettings($_theme), $board);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
post.php
6
post.php
@ -677,7 +677,11 @@ if (isset($_POST['delete'])) {
|
|||||||
_syslog(LOG_INFO, 'New post: /' . $board['dir'] . $config['dir']['res'] .
|
_syslog(LOG_INFO, 'New post: /' . $board['dir'] . $config['dir']['res'] .
|
||||||
sprintf($config['file_page'], $post['op'] ? $id : $post['thread']) . (!$post['op'] ? '#' . $id : ''));
|
sprintf($config['file_page'], $post['op'] ? $id : $post['thread']) . (!$post['op'] ? '#' . $id : ''));
|
||||||
|
|
||||||
rebuildThemes('post');
|
if ($post['op'])
|
||||||
|
rebuildThemes('post-thread', $board['uri']);
|
||||||
|
else
|
||||||
|
rebuildThemes('post', $board['uri']);
|
||||||
|
|
||||||
header('Location: ' . $redirect, true, $config['redirect_http']);
|
header('Location: ' . $redirect, true, $config['redirect_http']);
|
||||||
} else {
|
} else {
|
||||||
if (!file_exists($config['has_installed'])) {
|
if (!file_exists($config['has_installed'])) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require 'info.php';
|
require 'info.php';
|
||||||
|
|
||||||
function basic_build($action, $settings) {
|
function basic_build($action, $settings, $board) {
|
||||||
// Possible values for $action:
|
// Possible values for $action:
|
||||||
// - all (rebuild everything, initialization)
|
// - all (rebuild everything, initialization)
|
||||||
// - news (news has been updated)
|
// - news (news has been updated)
|
||||||
|
@ -1,37 +1,38 @@
|
|||||||
<?php
|
<?php
|
||||||
require 'info.php';
|
require 'info.php';
|
||||||
|
|
||||||
function catalog_build($action, $settings) {
|
function catalog_build($action, $settings, $board) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
// Possible values for $action:
|
// Possible values for $action:
|
||||||
// - all (rebuild everything, initialization)
|
// - all (rebuild everything, initialization)
|
||||||
// - news (news has been updated)
|
// - news (news has been updated)
|
||||||
// - boards (board list changed)
|
// - boards (board list changed)
|
||||||
// - post (a post has been made)
|
// - post (a reply has been made)
|
||||||
|
// - post-thread (a thread has been made)
|
||||||
|
|
||||||
$b = new Catalog();
|
$boards = explode(' ', $settings['boards']);
|
||||||
$b->build($action, $settings);
|
|
||||||
|
if ($action == 'all') {
|
||||||
|
copy('templates/themes/catalog/catalog.css', $config['dir']['home'] . $settings['css']);
|
||||||
|
|
||||||
|
foreach ($boards as $board) {
|
||||||
|
$b = new Catalog();
|
||||||
|
$b->build($settings, $board);
|
||||||
|
}
|
||||||
|
} elseif ($action == 'post-thread' && in_array($board, $boards)) {
|
||||||
|
$b = new Catalog();
|
||||||
|
$b->build($settings, $board);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 Catalog {
|
class Catalog {
|
||||||
public function build($action, $settings) {
|
public function build($settings, $board_name) {
|
||||||
global $config, $_theme;
|
|
||||||
|
|
||||||
if ($action == 'all') {
|
|
||||||
copy('templates/themes/catalog/catalog.css', $config['dir']['home'] . $settings['css']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$boards = explode(' ', $settings['boards']);
|
|
||||||
foreach ($boards as $board) {
|
|
||||||
if ($action == 'all' || $action == 'post')
|
|
||||||
file_write($config['dir']['home'] . $board . '/catalog.html', $this->homepage($settings, $board));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function homepage($settings, $board_name) {
|
|
||||||
global $config, $board;
|
global $config, $board;
|
||||||
|
|
||||||
|
openBoard($board_name);
|
||||||
|
|
||||||
$recent_images = array();
|
$recent_images = array();
|
||||||
$recent_posts = array();
|
$recent_posts = array();
|
||||||
$stats = array();
|
$stats = array();
|
||||||
@ -39,16 +40,13 @@
|
|||||||
$query = query(sprintf("SELECT *, `id` AS `thread_id`, (SELECT COUNT(*) FROM `posts_%s` WHERE `thread` = `thread_id`) AS `reply_count`, '%s' AS `board` FROM `posts_%s` WHERE `thread` IS NULL ORDER BY `bump` DESC", $board_name, $board_name, $board_name)) or error(db_error());
|
$query = query(sprintf("SELECT *, `id` AS `thread_id`, (SELECT COUNT(*) FROM `posts_%s` WHERE `thread` = `thread_id`) AS `reply_count`, '%s' AS `board` FROM `posts_%s` WHERE `thread` IS NULL ORDER BY `bump` DESC", $board_name, $board_name, $board_name)) or error(db_error());
|
||||||
|
|
||||||
while ($post = $query->fetch()) {
|
while ($post = $query->fetch()) {
|
||||||
openBoard($post['board']);
|
|
||||||
|
|
||||||
$post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id']));
|
$post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id']));
|
||||||
$post['board_name'] = $board['name'];
|
$post['board_name'] = $board['name'];
|
||||||
$post['file'] = $config['uri_thumb'] . $post['thumb'];
|
$post['file'] = $config['uri_thumb'] . $post['thumb'];
|
||||||
$recent_posts[] = $post;
|
$recent_posts[] = $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file_write($config['dir']['home'] . $board_name . '/catalog.html', Element('themes/catalog/catalog.html', Array(
|
||||||
return Element('themes/catalog/catalog.html', Array(
|
|
||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
'boardlist' => createBoardlist(),
|
'boardlist' => createBoardlist(),
|
||||||
@ -57,8 +55,6 @@
|
|||||||
'stats' => $stats,
|
'stats' => $stats,
|
||||||
'board' => $board_name,
|
'board' => $board_name,
|
||||||
'link' => $config['root'] . $board['dir']
|
'link' => $config['root'] . $board['dir']
|
||||||
));
|
)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require 'info.php';
|
require 'info.php';
|
||||||
|
|
||||||
function categories_build($action, $settings) {
|
function categories_build($action, $settings, $board) {
|
||||||
// Possible values for $action:
|
// Possible values for $action:
|
||||||
// - all (rebuild everything, initialization)
|
// - all (rebuild everything, initialization)
|
||||||
// - news (news has been updated)
|
// - news (news has been updated)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require 'info.php';
|
require 'info.php';
|
||||||
|
|
||||||
function frameset_build($action, $settings) {
|
function frameset_build($action, $settings, $board) {
|
||||||
// Possible values for $action:
|
// Possible values for $action:
|
||||||
// - all (rebuild everything, initialization)
|
// - all (rebuild everything, initialization)
|
||||||
// - news (news has been updated)
|
// - news (news has been updated)
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
require 'info.php';
|
require 'info.php';
|
||||||
|
|
||||||
function recentposts_build($action, $settings) {
|
function recentposts_build($action, $settings, $board) {
|
||||||
// Possible values for $action:
|
// Possible values for $action:
|
||||||
// - all (rebuild everything, initialization)
|
// - all (rebuild everything, initialization)
|
||||||
// - news (news has been updated)
|
// - news (news has been updated)
|
||||||
// - boards (board list changed)
|
// - boards (board list changed)
|
||||||
// - post (a post has been made)
|
// - post (a post has been made)
|
||||||
|
// - post-thread (a thread has been made)
|
||||||
|
|
||||||
$b = new RecentPosts();
|
$b = new RecentPosts();
|
||||||
$b->build($action, $settings);
|
$b->build($action, $settings);
|
||||||
@ -23,7 +24,7 @@
|
|||||||
|
|
||||||
$this->excluded = explode(' ', $settings['exclude']);
|
$this->excluded = explode(' ', $settings['exclude']);
|
||||||
|
|
||||||
if ($action == 'all' || $action == 'post')
|
if ($action == 'all' || $action == 'post' || $action == 'post-thread')
|
||||||
file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings));
|
file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require 'info.php';
|
require 'info.php';
|
||||||
|
|
||||||
function rrdtool_build($action, $settings) {
|
function rrdtool_build($action, $settings, $board) {
|
||||||
// Possible values for $action:
|
// Possible values for $action:
|
||||||
// - all (rebuild everything, initialization)
|
// - all (rebuild everything, initialization)
|
||||||
// - news (news has been updated)
|
// - news (news has been updated)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require 'info.php';
|
require 'info.php';
|
||||||
|
|
||||||
function sitemap_build($action, $settings) {
|
function sitemap_build($action, $settings, $board) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// Possible values for $action:
|
// Possible values for $action:
|
||||||
@ -9,6 +9,10 @@
|
|||||||
// - news (news has been updated)
|
// - news (news has been updated)
|
||||||
// - boards (board list changed)
|
// - boards (board list changed)
|
||||||
// - post (a post has been made)
|
// - post (a post has been made)
|
||||||
|
// - thread (a thread has been made)
|
||||||
|
|
||||||
|
if ($action != 'post' && $action != 'post-thread')
|
||||||
|
return;
|
||||||
|
|
||||||
$boards = explode(' ', $settings['boards']);
|
$boards = explode(' ', $settings['boards']);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user