forked from leftypol/leftypol
sitemap theme for smart_build
This commit is contained in:
parent
61d2729a40
commit
e273111340
2 changed files with 37 additions and 21 deletions
|
@ -10,30 +10,37 @@
|
|||
// - boards (board list changed)
|
||||
// - post (a post has been made)
|
||||
// - thread (a thread has been made)
|
||||
|
||||
if ($action != 'all') {
|
||||
if ($action != 'post-thread' && $action != 'post-delete')
|
||||
return;
|
||||
|
||||
if ($action != 'post-thread' && $action != 'post-delete')
|
||||
return;
|
||||
|
||||
if (isset($settings['regen_time']) && $settings['regen_time'] > 0) {
|
||||
if ($last_gen = @filemtime($settings['path'])) {
|
||||
if (time() - $last_gen < (int)$settings['regen_time'])
|
||||
return; // Too soon
|
||||
if (isset($settings['regen_time']) && $settings['regen_time'] > 0) {
|
||||
if ($last_gen = @filemtime($settings['path'])) {
|
||||
if (time() - $last_gen < (int)$settings['regen_time'])
|
||||
return; // Too soon
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$boards = explode(' ', $settings['boards']);
|
||||
|
||||
$threads = array();
|
||||
|
||||
foreach ($boards as $board) {
|
||||
$query = query(sprintf("SELECT `id`, `id` AS `thread_id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error());
|
||||
$threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($config['smart_build']) {
|
||||
file_unlink($settings['path']);
|
||||
}
|
||||
else {
|
||||
$boards = explode(' ', $settings['boards']);
|
||||
|
||||
$threads = array();
|
||||
|
||||
foreach ($boards as $board) {
|
||||
$query = query(sprintf("SELECT `id`, `id` AS `thread_id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error());
|
||||
$threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
file_write($settings['path'], Element('themes/sitemap/sitemap.xml', Array(
|
||||
'settings' => $settings,
|
||||
'config' => $config,
|
||||
'threads' => $threads,
|
||||
'boards' => $boards,
|
||||
)));
|
||||
file_write($settings['path'], Element('themes/sitemap/sitemap.xml', Array(
|
||||
'settings' => $settings,
|
||||
'config' => $config,
|
||||
'threads' => $threads,
|
||||
'boards' => $boards,
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue