Correctly page the overboard json
This commit is contained in:
parent
24b9b8bafd
commit
eafcce12cf
|
@ -378,19 +378,26 @@
|
|||
if ($config['api']['enabled']) {
|
||||
$api = new Api();
|
||||
|
||||
$threads = array();
|
||||
// Separate the threads into pages
|
||||
$pages = array(array());
|
||||
$totalThreads = count($recent_posts);
|
||||
$page = 0;
|
||||
for ($i = 1; $i <= $totalThreads; $i++) {
|
||||
$pages[$page][] = new Thread($recent_posts[$i-1]);
|
||||
|
||||
foreach ($recent_posts as $post) {
|
||||
$threads[] = new Thread($post);
|
||||
// If we have not yet visited all threads,
|
||||
// and we hit the limit on the current page,
|
||||
// skip to the next page
|
||||
if ($i < $totalThreads && ($i % $config['threads_per_page'] == 0)) {
|
||||
$page++;
|
||||
$pages[$page] = array();
|
||||
}
|
||||
}
|
||||
|
||||
// Page 0, the only page
|
||||
$threads = array($threads);
|
||||
|
||||
$json = json_encode($api->translateCatalog($threads));
|
||||
$json = json_encode($api->translateCatalog($pages));
|
||||
file_write($config['dir']['home'] . $board_name . '/catalog.json', $json);
|
||||
|
||||
$json = json_encode($api->translateCatalog($threads, true));
|
||||
$json = json_encode($api->translateCatalog($pages, true));
|
||||
file_write($config['dir']['home'] . $board_name . '/threads.json', $json);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue