*
 */
require_once "src/base.inc.php";
require_once "src/header.inc.php";
// Do we have a path info?
if (isset($_SERVER['PATH_INFO'])) {
    // Get the category
    $category = addslashes(substr($_SERVER['PATH_INFO'], 1));
    $category = Category::getByShortname($category);
    if ($category) {
        displayEvents($category);
    
    } else {
        // Bad category. List them all.
        listCategories();
    }
} else {
    // No category. List them all.
    listCategories();
}
function listCategories() {
    echo "
Categories
";
    $cats = Category::getCategories();
    foreach ($cats as $short => $name) {
        $url = $GLOBALS['CONFIG']['urlroot'] . "/categories/$short";
        echo "$name
";
    }
}
function displayEvents($category) {
    echo "". $category->getName() ."
";
    // Get all recent, approved posts.
    $posts = new PostIterator();
    $posts->filterCategory($category->getId());
    $posts->filterStage('approved');
    $posts->query();
    if ($posts->valid()) {
        foreach ($posts as $id => $post) {
            printf("",
                    
                    $id, $post->getName(), $post->getLocation(), $post->getAge());
        }
    } else {
        echo "No recent posts.
";
    }
}
require_once "src/footer.inc.php";
?>