This repository has been archived on 2025-02-01. You can view files and clone it, but cannot push or open issues or pull requests.
accm-website/includes/tournaments/TournamentFormatter.inc.php
2010-08-14 22:32:09 +02:00

62 lines
1.8 KiB
PHP

<?php
include_once './includes/tournaments/TournamentEntryFormatter.inc.php';
include_once './includes/tournaments/TournamentEntryLister.inc.php';
include_once './includes/tournaments/CategoryLister.inc.php';
include_once './includes/tournaments/CategoryFormatter.inc.php';
include_once './includes/utils/DateFormatter.inc.php';
/**
* This class allows for easy formatting of tournaments.
*
* @author Thomas Schwery <thomas.schwery@epfl.ch>
*/
class TournamentFormatter {
public static function getSummary(Tournament $tournament) {
return TournamentFormatter::getHeaders($tournament, true);
}
public static function getFull(Tournament $tournament) {
$content = TournamentFormatter::getHeaders($tournament, false);
$tournamentCategories = CategoryLister::GetCategoriesForTournament($tournament);
foreach ($tournamentCategories as $category) {
$content .= CategoryFormatter::getFullTournament($category, $tournament);
}
return $content;
}
private static function getHeaders(Tournament $tournament, $linkOnName) {
$identifier = $tournament->getIdentifier();
$name = $tournament->getName();
$location = $tournament->getLocation();
$comments = $tournament->getComments();
$type = $tournament->getType();
$date = DateFormatter::formatDMY($tournament->getDate());
$happenedOn = Localization::happenedOn($location, $date);
if ($linkOnName) {
$nameLine = "<a href='index.php?page=Tournaments&amp;tournamentIdentifier=$identifier'>$name</a>";
} else {
$nameLine = $name;
}
$content = <<<BOX
<div id='tournament-$identifier' class='tournament_box'>
<h2>$nameLine</h2>
<p>
$type<br>
$happenedOn
</p>
</div>
BOX;
return $content;
}
}
?>