-
Notifications
You must be signed in to change notification settings - Fork 0
/
tournament.php
63 lines (46 loc) · 2.06 KB
/
tournament.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
require_once 'vendor/autoload.php';
use FileListPoker\Content\TournamentContent;
use FileListPoker\Main\Site;
use FileListPoker\Main\FLPokerException;
use FileListPoker\Renderers\TournamentRenderer;
use FileListPoker\Renderers\FullPageRenderer;
use Symfony\Component\HttpFoundation\Response;
$site = new Site();
$errors = $site->isValidNumericQueryParameter('id', 3);
if (count($errors) > 0) {
$message = 'Invalid tournament ID specified when acccessing tournament.php';
throw new FLPokerException($message, FLPokerException::INVALID_REQUEST);
}
$tid = $site->request->query->get('id');
$tournamentPage = new TournamentContent();
$details = $tournamentPage->getTournamentDetails($tid);
if (! isset($details['tournament_id'])) {
$message = 'Non-existent tournament ID specified when acccessing tournament.php';
throw new FLPokerException($message, FLPokerException::INVALID_REQUEST);
}
$results = $tournamentPage->getTournamentResults($tid);
$bonuses = $tournamentPage->getTournamentBonuses($tid);
$pageContent = file_get_contents('templates/tournament/tournament.tpl');
$renderer = new TournamentRenderer($site);
$detailsTpl = file_get_contents('templates/tournament/details.tpl');
$resultsTpl = file_get_contents('templates/tournament/results.tpl');
$bonusesTpl = file_get_contents('templates/tournament/bonuses.tpl');
$detailsTpl = $renderer->renderDetails($detailsTpl, $details);
$resultsTpl = $renderer->renderResults($resultsTpl, $results);
$bonusesTpl = $renderer->renderBonuses($bonusesTpl, $bonuses);
$pageContent = str_replace(
array('{tournament_details}', '{tournament_results}', '{tournament_bonuses}'),
array($detailsTpl, $resultsTpl, $bonusesTpl),
$pageContent
);
$mainRenderer = new FullPageRenderer($site);
$htmlout = $mainRenderer->renderPage('tournaments.php');
$htmlout = str_replace(
array('{content_type_id}', '{page_content}', '{bottom_page_scripts}'),
array('content-narrower', $pageContent, ''),
$htmlout
);
$site->response->setContent($htmlout);
$site->response->setStatusCode(Response::HTTP_OK);
$site->response->send();