diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2011-05-17 17:20:06 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net ; true> | 2011-05-17 17:20:06 -0700 |
commit | 251349acaf0f8fed47aad1610b5b627a7e684f27 (patch) | |
tree | 933268c87ea64e432cf511a0f77133380490976f /htdocs/categories.php | |
parent | c7ede0038e98b386cbd1ef333d89faa2568b1cb1 (diff) |
Added category buttons and categories page
Diffstat (limited to 'htdocs/categories.php')
-rw-r--r-- | htdocs/categories.php | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/htdocs/categories.php b/htdocs/categories.php new file mode 100644 index 0000000..5725125 --- /dev/null +++ b/htdocs/categories.php @@ -0,0 +1,71 @@ +<?php + +/* Foursquare Community Site + * + * Copyright (C) 2011 Foursquare Church. + * + * Developers: Jesse Morgan <jmorgan@foursquarestaff.com> + * + */ + +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 "<h2>Categories</h2>"; + + $cats = Category::getCategories(); + foreach ($cats as $short => $name) { + $url = $GLOBALS['CONFIG']['urlroot'] . "/categories/$short"; + echo "<p><a href=\"$url\">$name</a></p>"; + } +} + +function displayEvents($category) { + echo "<h2>". $category->getName() ."</h2>"; + + // 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("<div class=\"post\"><p><a href=\"postings/%s.html\">%s</a></p>" + . "<div class=\"desc\"><span class=\"location\">%s</span>" + . " <span class=\"age\">%s</span></div></div>", + + $id, $post->getName(), $post->getLocation(), $post->getAge()); + } + + } else { + echo "<p>No recent posts.</p>"; + } +} + +require_once "src/footer.inc.php"; + +?> + |