Add support for Ukko2 and Ukko3 included boards overboards to Catalog theme / extension
This commit is contained in:
parent
f453fa1ee3
commit
91ab810a5d
@ -47,6 +47,22 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
$theme['config'][] = Array(
|
$theme['config'][] = Array(
|
||||||
|
'title' => 'Enable Ukko2 catalog',
|
||||||
|
'name' => 'enable_ukko2',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'default' => false,
|
||||||
|
'comment' => 'Enable catalog for the Ukko2 theme. This requires the Ukko2 theme to be enabled.'
|
||||||
|
);
|
||||||
|
|
||||||
|
$theme['config'][] = Array(
|
||||||
|
'title' => 'Enable Ukko3 catalog',
|
||||||
|
'name' => 'enable_ukko3',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'default' => false,
|
||||||
|
'comment' => 'Enable catalog for the Ukko theme. This requires the Ukko3 theme to be enabled.'
|
||||||
|
);
|
||||||
|
|
||||||
|
$theme['config'][] = Array(
|
||||||
'title' => 'Enable Rand catalog',
|
'title' => 'Enable Rand catalog',
|
||||||
'name' => 'enable_rand',
|
'name' => 'enable_rand',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
|
@ -39,19 +39,33 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Check that Ukko is actually enabled
|
// FIXME: Check that Ukko is actually enabled
|
||||||
if ($settings['enable_ukko'] && (
|
if ($settings['enable_ukko'] && (
|
||||||
$action === 'all' || $action === 'post' ||
|
$action === 'all' || $action === 'post' ||
|
||||||
$action === 'post-thread' || $action === 'post-delete'))
|
$action === 'post-thread' || $action === 'post-delete' || $action === 'rebuild'))
|
||||||
{
|
{
|
||||||
$b->buildUkko();
|
$b->buildUkko();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Check that Ukko2 is actually enabled
|
||||||
|
if ($settings['enable_ukko2'] && (
|
||||||
|
$action === 'all' || $action === 'post' ||
|
||||||
|
$action === 'post-thread' || $action === 'post-delete' || $action === 'rebuild'))
|
||||||
|
{
|
||||||
|
$b->buildUkko2();
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: Check that Ukko3 is actually enabled
|
||||||
|
if ($settings['enable_ukko3'] && (
|
||||||
|
$action === 'all' || $action === 'post' ||
|
||||||
|
$action === 'post-thread' || $action === 'post-delete' || $action === 'rebuild'))
|
||||||
|
{
|
||||||
|
$b->buildUkko3();
|
||||||
|
}
|
||||||
// FIXME: Check that Rand is actually enabled
|
// FIXME: Check that Rand is actually enabled
|
||||||
if ($settings['enable_rand'] && (
|
if ($settings['enable_rand'] && (
|
||||||
$action === 'all' || $action === 'post' ||
|
$action === 'all' || $action === 'post' ||
|
||||||
$action === 'post-thread' || $action === 'post-delete'))
|
$action === 'post-thread' || $action === 'post-delete' || $action === 'rebuild'))
|
||||||
{
|
{
|
||||||
$b->buildRand();
|
$b->buildRand();
|
||||||
}
|
}
|
||||||
@ -105,6 +119,83 @@
|
|||||||
$this->saveForBoard($ukkoSettings['uri'], $recent_posts,
|
$this->saveForBoard($ukkoSettings['uri'], $recent_posts,
|
||||||
$config['root'] . $ukkoSettings['uri']);
|
$config['root'] . $ukkoSettings['uri']);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Build and save the HTML of the catalog for the Ukko2 theme
|
||||||
|
*/
|
||||||
|
public function buildUkko2() {
|
||||||
|
global $config;
|
||||||
|
error_log("ZZZ UK2 ",0);
|
||||||
|
$ukkoSettings = themeSettings('ukko2');
|
||||||
|
$queries = array();
|
||||||
|
$threads = array();
|
||||||
|
|
||||||
|
$inclusions = explode(' ', $ukkoSettings['include']);
|
||||||
|
$boards = array_intersect(listBoards(true), $inclusions);
|
||||||
|
|
||||||
|
foreach ($boards as $b) {
|
||||||
|
if (array_key_exists($b, $this->threadsCache)) {
|
||||||
|
$threads = array_merge($threads, $this->threadsCache[$b]);
|
||||||
|
} else {
|
||||||
|
$queries[] = $this->buildThreadsQuery($b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch threads from boards that haven't beenp processed yet
|
||||||
|
if (!empty($queries)) {
|
||||||
|
$sql = implode(' UNION ALL ', $queries);
|
||||||
|
$res = query($sql) or error(db_error());
|
||||||
|
$threads = array_merge($threads, $res->fetchAll(PDO::FETCH_ASSOC));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort in bump order
|
||||||
|
usort($threads, function($a, $b) {
|
||||||
|
return strcmp($b['bump'], $a['bump']);
|
||||||
|
});
|
||||||
|
// Generate data for the template
|
||||||
|
$recent_posts = $this->generateRecentPosts($threads);
|
||||||
|
|
||||||
|
$this->saveForBoard($ukkoSettings['uri'], $recent_posts,
|
||||||
|
$config['root'] . $ukkoSettings['uri']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build and save the HTML of the catalog for the Ukko3 theme
|
||||||
|
*/
|
||||||
|
public function buildUkko3() {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$ukkoSettings = themeSettings('ukko3');
|
||||||
|
$queries = array();
|
||||||
|
$threads = array();
|
||||||
|
|
||||||
|
$inclusions = explode(' ', $ukkoSettings['include']);
|
||||||
|
$boards = array_intersect(listBoards(true), $inclusions);
|
||||||
|
|
||||||
|
foreach ($boards as $b) {
|
||||||
|
if (array_key_exists($b, $this->threadsCache)) {
|
||||||
|
$threads = array_merge($threads, $this->threadsCache[$b]);
|
||||||
|
} else {
|
||||||
|
$queries[] = $this->buildThreadsQuery($b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch threads from boards that haven't beenp processed yet
|
||||||
|
if (!empty($queries)) {
|
||||||
|
$sql = implode(' UNION ALL ', $queries);
|
||||||
|
$res = query($sql) or error(db_error());
|
||||||
|
$threads = array_merge($threads, $res->fetchAll(PDO::FETCH_ASSOC));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort in bump order
|
||||||
|
usort($threads, function($a, $b) {
|
||||||
|
return strcmp($b['bump'], $a['bump']);
|
||||||
|
});
|
||||||
|
// Generate data for the template
|
||||||
|
$recent_posts = $this->generateRecentPosts($threads);
|
||||||
|
|
||||||
|
$this->saveForBoard($ukkoSettings['uri'], $recent_posts,
|
||||||
|
$config['root'] . $ukkoSettings['uri']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build and save the HTML of the catalog for the Rand theme
|
* Build and save the HTML of the catalog for the Rand theme
|
||||||
|
Loading…
Reference in New Issue
Block a user