misuzu/public/changelog.php

69 lines
2.3 KiB
PHP
Raw Normal View History

2018-07-06 01:28:06 +00:00
<?php
2019-03-18 19:53:05 +00:00
use Misuzu\Request\RequestVar;
require_once '../misuzu.php';
2018-07-06 01:28:06 +00:00
2019-03-18 20:15:02 +00:00
$changelogChange = RequestVar::get()->select('c')->int(0);
$changelogDate = RequestVar::get()->select('d')->string('');
$changelogUser = RequestVar::get()->select('u')->int(0);
$changelogTags = RequestVar::get()->select('t')->string('');
2018-07-06 01:28:06 +00:00
2019-01-03 00:33:02 +00:00
tpl_var('comments_perms', $commentPerms = comments_get_perms(user_session_current('user_id', 0)));
2018-07-06 01:28:06 +00:00
if ($changelogChange > 0) {
$change = changelog_change_get($changelogChange);
2018-07-06 01:28:06 +00:00
if (!$change) {
2018-11-17 21:59:01 +00:00
echo render_error(404);
return;
2018-07-06 01:28:06 +00:00
}
2018-08-15 01:12:58 +00:00
echo tpl_render('changelog.change', [
2018-08-06 22:19:35 +00:00
'change' => $change,
'tags' => changelog_change_tags_get($change['change_id']),
2018-08-06 22:19:35 +00:00
'comments_category' => $commentsCategory = comments_category_info(
"changelog-date-{$change['change_date']}",
true
),
'comments' => comments_category_get($commentsCategory['category_id'], user_session_current('user_id', 0)),
2018-08-06 22:19:35 +00:00
]);
2018-07-06 01:28:06 +00:00
return;
}
if (!empty($changelogDate)) {
$dateParts = explode('-', $changelogDate, 3);
if (count($dateParts) !== 3
|| !array_test($dateParts, 'is_user_int')
|| !checkdate($dateParts[1], $dateParts[2], $dateParts[0])) {
2018-07-06 01:28:06 +00:00
echo render_error(404);
return;
}
}
$changesCount = !empty($changelogDate) ? -1 : changelog_count_changes($changelogDate, $changelogUser);
2019-01-03 00:33:02 +00:00
$changesPagination = pagination_create($changesCount, 30);
$changesOffset = $changesCount === -1 ? 0 : pagination_offset($changesPagination, pagination_param());
$changes = $changesCount === -1 || pagination_is_valid_offset($changesOffset)
2019-01-03 00:33:02 +00:00
? changelog_get_changes($changelogDate, $changelogUser, $changesOffset, $changesPagination['range'])
: [];
2018-07-06 01:28:06 +00:00
if (!$changes) {
http_response_code(404);
}
2018-07-06 01:28:06 +00:00
2018-08-15 20:29:18 +00:00
if (!empty($changelogDate) && count($changes) > 0) {
2018-08-15 01:12:58 +00:00
tpl_vars([
2018-08-06 22:19:35 +00:00
'comments_category' => $commentsCategory = comments_category_info("changelog-date-{$changelogDate}", true),
'comments' => comments_category_get($commentsCategory['category_id'], user_session_current('user_id', 0)),
2018-08-06 22:19:35 +00:00
]);
}
2018-08-15 01:12:58 +00:00
echo tpl_render('changelog.index', [
2018-07-06 01:28:06 +00:00
'changes' => $changes,
'changelog_count' => $changesCount,
'changelog_date' => $changelogDate,
'changelog_user' => $changelogUser,
2019-01-03 00:33:02 +00:00
'changelog_pagination' => $changesPagination,
2018-07-06 01:28:06 +00:00
]);