|
|
@ -40,6 +40,14 @@ |
|
|
|
{ |
|
|
|
$b->buildUkko(); |
|
|
|
} |
|
|
|
|
|
|
|
// FIXME: Check that Rand is actually enabled |
|
|
|
if ($settings['enable_rand'] && ( |
|
|
|
$action === 'all' || $action === 'post' || |
|
|
|
$action === 'post-thread' || $action === 'post-delete')) |
|
|
|
{ |
|
|
|
$b->buildRand(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Wrap functions in a class so they don't interfere with normal Tinyboard operations |
|
|
@ -90,6 +98,45 @@ |
|
|
|
$this->saveForBoard($ukkoSettings['uri'], $recent_posts, |
|
|
|
$config['root'] . $ukkoSettings['uri']); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Build and save the HTML of the catalog for the Rand theme |
|
|
|
*/ |
|
|
|
public function buildRand() { |
|
|
|
global $config; |
|
|
|
|
|
|
|
$randSettings = themeSettings('rand'); |
|
|
|
$queries = array(); |
|
|
|
$threads = array(); |
|
|
|
|
|
|
|
$exclusions = explode(' ', $randSettings['exclude']); |
|
|
|
$boards = array_diff(listBoards(true), $exclusions); |
|
|
|
|
|
|
|
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($randSettings['uri'], $recent_posts, |
|
|
|
$config['root'] . $randSettings['uri']); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Build and save the HTML of the catalog for the given board |
|
|
|