This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/public/viewforum.php

66 lines
1.5 KiB
PHP
Raw Normal View History

2015-05-06 13:42:02 +00:00
<?php
/*
* Sakura Forum List Viewer
*/
// Declare Namespace
namespace Sakura;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . '_sakura/sakura.php';
2015-06-27 19:29:37 +00:00
// Get the forum's data
$forum = new Forum(isset($_GET['f']) ? $_GET['f'] : -1);
2015-06-27 19:29:37 +00:00
// Initialise templating engine
$template = new Template();
// Change templating engine
$template->setTemplate($templateName);
2015-06-27 19:29:37 +00:00
// Check if the forum exists
if (!$forum) {
2015-06-27 19:29:37 +00:00
// Set render data
$renderData['page'] = [
'title' => 'Information',
'message' => 'The subforum you tried to access does not exist.',
2015-06-27 19:29:37 +00:00
];
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('global/information.tpl');
2015-06-27 19:29:37 +00:00
exit;
}
// Check if the forum isn't a link
if ($forum->type === 2) {
2015-06-27 19:29:37 +00:00
// Set render data
$renderData['page'] = [
'title' => 'Information',
'message' => 'The forum you tried to access is a link. You\'re being redirected.',
'redirect' => $forum->link,
2015-06-27 19:29:37 +00:00
];
// Set parse variables
$template->setVariables($renderData);
// Print page contents
echo $template->render('global/information.tpl');
2015-06-27 19:29:37 +00:00
exit;
}
$renderData['forum'] = $forum;
2015-06-27 19:29:37 +00:00
$renderData['board'] = [
'threads' => array_chunk($forum->threads, 25, true),
2015-06-27 19:29:37 +00:00
];
$renderData['currentPage'] = isset($_GET['page']) && ($_GET['page'] - 1) >= 0 ? $_GET['page'] - 1 : 0;
2015-06-27 19:29:37 +00:00
// Set parse variables
$template->setVariables($renderData);
2015-06-27 19:29:37 +00:00
// Print page contents
echo $template->render('forum/viewforum.tpl');