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/CategoryListFormatter.inc.php
2010-08-14 22:32:09 +02:00

42 lines
1.1 KiB
PHP

<?php
include_once './includes/tournaments/Category.inc.php';
include_once './includes/tournaments/CategoryLister.inc.php';
/**
* This class allows for easy formatting of lists of categories.
*
* @author Thomas Schwery <thomas.schwery@epfl.ch>
*/
class CategoryListFormatter {
/**
* Returns a select entries list containing the categories.
*
* @param string $inputName
* @param string $selectedCategory
* @return string
*/
public static function getSelectCategories($inputName, $selectedCategory) {
$categoryArray = CategoryLister::GetAllCategories();
$content = '<select name="'.$inputName.'">';
foreach ($categoryArray as $category) {
$name = $category->getName();
if ($name == $selectedCategory) {
$selected = "selected='selected'";
} else {
$selected = "";
}
$content .= '<option value="' . $name . '" ' . $selected . '>' . $name . '</option>';
}
$content .= "</select>";
return $content;
}
}
?>