adds catalog for overboard
This commit is contained in:
parent
ab4b6592b5
commit
1251fa01e7
|
@ -83,6 +83,20 @@
|
|||
'default' => true,
|
||||
'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'
|
||||
);
|
||||
|
||||
// Unique function name for building everything
|
||||
$theme['build_function'] = 'catalog_build';
|
||||
|
|
|
@ -41,6 +41,9 @@
|
|||
elseif ($action == 'rebuild') {
|
||||
print_err("catalog_build calling Catalog.build 2");
|
||||
$b->build($settings, $board);
|
||||
if($settings['has_overboard']) {
|
||||
$b->buildOverboardCatalog($settings, $boards);
|
||||
}
|
||||
}
|
||||
}
|
||||
// FIXME: Check that Ukko is actually enabled
|
||||
|
@ -332,6 +335,33 @@
|
|||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build and save the HTML of the catalog for the overboard
|
||||
*/
|
||||
public function buildOverboardCatalog($settings, $board_names) {
|
||||
global $config;
|
||||
$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 ";
|
||||
}
|
||||
$query = preg_replace('/UNION ALL $/', 'ORDER BY `bump` DESC', $query);
|
||||
$result = query($query) or error(db_error());
|
||||
$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);
|
||||
}
|
||||
|
||||
private function generateRecentPosts($threads) {
|
||||
global $config, $board;
|
||||
|
||||
|
|
Loading…
Reference in New Issue