commit
13bebb70d0
|
@ -56,6 +56,31 @@ function doBoardListPart($list, $root, &$boards) {
|
||||||
return $body;
|
return $body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createForeignBoardListSection($configKey){
|
||||||
|
global $config;
|
||||||
|
$body = '';
|
||||||
|
|
||||||
|
if (isset($config[$configKey])){
|
||||||
|
$body .= ' <span class="sub">[';
|
||||||
|
|
||||||
|
// Append links to foreign boards
|
||||||
|
$i = 0;
|
||||||
|
foreach ($config[$configKey] as $fboardname => $fboardurl) {
|
||||||
|
$i++;
|
||||||
|
$body .= ' <a href="' . $fboardurl . '">' . $fboardname . '</a>';
|
||||||
|
|
||||||
|
// only put slash in between elements
|
||||||
|
if ($i != count($config[$configKey])) {
|
||||||
|
$body .= ' /';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$body .= ']</span> ';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
function createBoardlist($mod=false) {
|
function createBoardlist($mod=false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -66,27 +91,10 @@ function createBoardlist($mod=false) {
|
||||||
foreach ($xboards as $val) {
|
foreach ($xboards as $val) {
|
||||||
$boards[$val['uri']] = $val['title'];
|
$boards[$val['uri']] = $val['title'];
|
||||||
}
|
}
|
||||||
|
$body = '';
|
||||||
$body = doBoardListPart($config['boards'], $mod?'?/':$config['root'], $boards);
|
$body .= createForeignBoardListSection('prepended_foreign_boards');
|
||||||
|
$body .= doBoardListPart($config['boards'], $mod?'?/':$config['root'], $boards);
|
||||||
if (isset($config['foreign_boards'])) {
|
$body .= createForeignBoardListSection('foreign_boards');
|
||||||
|
|
||||||
$body .= ' <span class="sub">[';
|
|
||||||
|
|
||||||
// Append links to foreign boards
|
|
||||||
$i = 0;
|
|
||||||
foreach ($config['foreign_boards'] as $fboardname => $fboardurl) {
|
|
||||||
$i++;
|
|
||||||
$body .= ' <a href="' . $fboardurl . '">' . $fboardname . '</a>';
|
|
||||||
|
|
||||||
// only put slash in between elements
|
|
||||||
if ($i != count($config['foreign_boards'])) {
|
|
||||||
$body .= ' /';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$body .= ']</span> ';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($config['boardlist_wrap_bracket'] && !preg_match('/\] $/', $body))
|
if ($config['boardlist_wrap_bracket'] && !preg_match('/\] $/', $body))
|
||||||
$body = '[' . $body . ']';
|
$body = '[' . $body . ']';
|
||||||
|
|
|
@ -23,6 +23,11 @@ $config['boards'] = array(
|
||||||
) ,
|
) ,
|
||||||
array('meta')
|
array('meta')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$config['prepended_foreign_boards'] = array(
|
||||||
|
'overboard' => '/overboard/',
|
||||||
|
);
|
||||||
|
|
||||||
$config['foreign_boards'] = array(
|
$config['foreign_boards'] = array(
|
||||||
'GET' => 'https://getchan.net/GET/',
|
'GET' => 'https://getchan.net/GET/',
|
||||||
'ref' => 'https://getchan.net/ref/'
|
'ref' => 'https://getchan.net/ref/'
|
||||||
|
|
|
@ -83,6 +83,27 @@
|
||||||
'default' => true,
|
'default' => true,
|
||||||
'comment' => 'Check this if you wish to show a nice tooltip with info about the thread on mouse over.'
|
'comment' => 'Check this if you wish to show a nice tooltip with info about the thread on mouse over.'
|
||||||
);
|
);
|
||||||
|
$theme['config'][] = Array(
|
||||||
|
'title' => 'Build overboard catalog',
|
||||||
|
'name' => 'has_overboard',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'default' => false,
|
||||||
|
'comment' => 'Check this if you wish to create a catalog for the overboard.'
|
||||||
|
);
|
||||||
|
$theme['config'][] = Array(
|
||||||
|
'title' => 'Overboard location (default \'overboard\')',
|
||||||
|
'name' => 'overboard_location',
|
||||||
|
'type' => 'text',
|
||||||
|
'default' => 'overboard',
|
||||||
|
'comment' => 'Fill in the location of the overboard directory. Default is \'overboard\' which corresponds to ./overboard'
|
||||||
|
);
|
||||||
|
$theme['config'][] = Array(
|
||||||
|
'title' => 'Max posts in catalog overboard',
|
||||||
|
'name' => 'overboard_limit',
|
||||||
|
'type' => 'text',
|
||||||
|
'default' => '350',
|
||||||
|
'comment' => 'The maximum number of thread that will appear in the overboard catalog'
|
||||||
|
);
|
||||||
|
|
||||||
// Unique function name for building everything
|
// Unique function name for building everything
|
||||||
$theme['build_function'] = 'catalog_build';
|
$theme['build_function'] = 'catalog_build';
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
// - post-thread (a thread has been made)
|
// - post-thread (a thread has been made)
|
||||||
if ($action === 'all') {
|
if ($action === 'all') {
|
||||||
foreach ($boards as $board) {
|
foreach ($boards as $board) {
|
||||||
$b = new Catalog($settings);
|
|
||||||
|
|
||||||
$action = generation_strategy("sb_catalog", array($board));
|
$action = generation_strategy("sb_catalog", array($board));
|
||||||
if ($action == 'delete') {
|
if ($action == 'delete') {
|
||||||
file_unlink($config['dir']['home'] . $board . '/catalog.html');
|
file_unlink($config['dir']['home'] . $board . '/catalog.html');
|
||||||
|
@ -29,6 +27,17 @@
|
||||||
$b->build($settings, $board);
|
$b->build($settings, $board);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($settings['has_overboard']) {
|
||||||
|
$board = $settings['overboard_location'];
|
||||||
|
$action = generation_strategy("sb_catalog", array($board));
|
||||||
|
if ($action == 'delete') {
|
||||||
|
file_unlink($config['dir']['home'] . $board . '/catalog.html');
|
||||||
|
file_unlink($config['dir']['home'] . $board . '/index.rss');
|
||||||
|
}
|
||||||
|
elseif ($action == 'rebuild') {
|
||||||
|
$b->buildOverboardCatalog($settings, $boards);
|
||||||
|
}
|
||||||
|
}
|
||||||
} elseif ($action == 'post-thread' || ($settings['update_on_posts'] && $action == 'post') || ($settings['update_on_posts'] && $action == 'post-delete')
|
} elseif ($action == 'post-thread' || ($settings['update_on_posts'] && $action == 'post') || ($settings['update_on_posts'] && $action == 'post-delete')
|
||||||
|| $action == 'sticky' || ($action == 'lock' && in_array($board, $boards))) {
|
|| $action == 'sticky' || ($action == 'lock' && in_array($board, $boards))) {
|
||||||
$b = new Catalog($settings);
|
$b = new Catalog($settings);
|
||||||
|
@ -41,6 +50,9 @@
|
||||||
elseif ($action == 'rebuild') {
|
elseif ($action == 'rebuild') {
|
||||||
print_err("catalog_build calling Catalog.build 2");
|
print_err("catalog_build calling Catalog.build 2");
|
||||||
$b->build($settings, $board);
|
$b->build($settings, $board);
|
||||||
|
if($settings['has_overboard']) {
|
||||||
|
$b->buildOverboardCatalog($settings, $boards);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// FIXME: Check that Ukko is actually enabled
|
// FIXME: Check that Ukko is actually enabled
|
||||||
|
@ -332,6 +344,35 @@
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build and save the HTML of the catalog for the overboard
|
||||||
|
*/
|
||||||
|
public function buildOverboardCatalog($settings, $boards) {
|
||||||
|
$board_name = $settings['overboard_location'];
|
||||||
|
|
||||||
|
if (array_key_exists($board_name, $this->threadsCache)) {
|
||||||
|
$threads = $this->threadsCache[$board_name];
|
||||||
|
} else {
|
||||||
|
$sql = '';
|
||||||
|
foreach ($boards as $board) {
|
||||||
|
$sql .= '('. $this->buildThreadsQuery($board) . ')';
|
||||||
|
$sql .= " UNION ALL ";
|
||||||
|
}
|
||||||
|
$sql = preg_replace('/UNION ALL $/', 'ORDER BY `bump` DESC LIMIT :limit', $sql);
|
||||||
|
$query = prepare($sql);
|
||||||
|
$query->bindValue(':limit', $settings['overboard_limit'], PDO::PARAM_INT);
|
||||||
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
|
$threads = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
// Save for posterity
|
||||||
|
$this->threadsCache[$board_name] = $threads;
|
||||||
|
}
|
||||||
|
// Generate data for the template
|
||||||
|
$recent_posts = $this->generateRecentPosts($threads);
|
||||||
|
|
||||||
|
$this->saveForBoard($board_name, $recent_posts, '/' . $settings['overboard_location']);
|
||||||
|
}
|
||||||
|
|
||||||
private function generateRecentPosts($threads) {
|
private function generateRecentPosts($threads) {
|
||||||
global $config, $board;
|
global $config, $board;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
require 'info.php';
|
require 'info.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the board's HTML and move it and its JavaScript in place, whence
|
* Generate the board's HTML and move it and its JavaScript in place, whence
|
||||||
* it's served
|
* it's served
|
||||||
*/
|
*/
|
||||||
function semirand_build($action, $settings) {
|
function semirand_build($action, $settings) {
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain list of all threads from all non-excluded boards
|
* Obtain list of all threads from all non-excluded boards
|
||||||
*/
|
*/
|
||||||
private function fetchThreads() {
|
private function fetchThreads() {
|
||||||
$query = '';
|
$query = '';
|
||||||
|
@ -87,9 +87,11 @@
|
||||||
/**
|
/**
|
||||||
* Retrieve all replies to a given thread
|
* Retrieve all replies to a given thread
|
||||||
*/
|
*/
|
||||||
private function fetchReplies($board, $thread_id) {
|
private function fetchReplies($board, $thread_id, $preview_count) {
|
||||||
$query = prepare("SELECT * FROM ``posts_$board`` WHERE `thread` = :id");
|
$query = prepare("SELECT * FROM (SELECT * FROM ``posts_$board`` WHERE `thread` = :id ORDER BY `time` DESC LIMIT :limit) as
|
||||||
|
t ORDER BY t.time ASC");
|
||||||
$query->bindValue(':id', $thread_id, PDO::PARAM_INT);
|
$query->bindValue(':id', $thread_id, PDO::PARAM_INT);
|
||||||
|
$query->bindValue(':limit', $preview_count, PDO::PARAM_INT);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
return $query->fetchAll(PDO::FETCH_ASSOC);
|
return $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
@ -131,13 +133,13 @@
|
||||||
|
|
||||||
openBoard($post['board']);
|
openBoard($post['board']);
|
||||||
$thread = new Thread($post, $mod ? '?/' : $config['root'], $mod);
|
$thread = new Thread($post, $mod ? '?/' : $config['root'], $mod);
|
||||||
$replies = $this->fetchReplies($post['board'], $post['id']);
|
|
||||||
// Number of replies to a thread that are displayed beneath it
|
// Number of replies to a thread that are displayed beneath it
|
||||||
$preview_count = $post['sticky'] ? $config['threads_preview_sticky'] :
|
$preview_count = $post['sticky'] ? $config['threads_preview_sticky'] :
|
||||||
$config['threads_preview'];
|
$config['threads_preview'];
|
||||||
|
$replies = $this->fetchReplies($post['board'], $post['id'], $preview_count);
|
||||||
|
|
||||||
// Chomp the last few replies
|
// Chomp the last few replies
|
||||||
$disp_replies = array_splice($replies, 0, $preview_count);
|
$disp_replies = $replies;
|
||||||
$disp_img_count = 0;
|
$disp_img_count = 0;
|
||||||
foreach ($disp_replies as $reply) {
|
foreach ($disp_replies as $reply) {
|
||||||
if ($reply['files'] !== '')
|
if ($reply['files'] !== '')
|
||||||
|
@ -182,7 +184,7 @@
|
||||||
|
|
||||||
// Fetch threads from all boards and chomp the first 'n' posts, depending
|
// Fetch threads from all boards and chomp the first 'n' posts, depending
|
||||||
// on the setting
|
// on the setting
|
||||||
$threads = $this->shuffleThreads($this->fetchThreads());
|
$threads = $this->fetchThreads();
|
||||||
$total_count = count($threads);
|
$total_count = count($threads);
|
||||||
// Top threads displayed on load
|
// Top threads displayed on load
|
||||||
$top_threads = array_splice($threads, 0, $this->settings['thread_limit']);
|
$top_threads = array_splice($threads, 0, $this->settings['thread_limit']);
|
||||||
|
|
Loading…
Reference in New Issue