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/src | |
parent | c7ede0038e98b386cbd1ef333d89faa2568b1cb1 (diff) |
Added category buttons and categories page
Diffstat (limited to 'htdocs/src')
-rw-r--r-- | htdocs/src/Category.inc.php | 86 | ||||
-rw-r--r-- | htdocs/src/PostIterator.inc.php | 4 | ||||
-rw-r--r-- | htdocs/src/header.inc.php | 27 |
3 files changed, 114 insertions, 3 deletions
diff --git a/htdocs/src/Category.inc.php b/htdocs/src/Category.inc.php new file mode 100644 index 0000000..edc0303 --- /dev/null +++ b/htdocs/src/Category.inc.php @@ -0,0 +1,86 @@ +<?php + +/* Foursquare Community Site + * + * Copyright (C) 2011 Foursquare Church. + * + * Developers: Jesse Morgan <jmorgan@foursquarestaff.com> + * + */ + +require_once "base.inc.php"; + +class Category { + private $info; + + + public function __construct($info=null) { + $this->info = $info; + } + + public static function getCategories() { + $db = getDatabase(); + + $query = "SELECT * FROM category ORDER BY name"; + + $rows = $db->fetchAssocRows($query); + + $result = array(); + foreach ($rows as $row) { + $result[$row['shortname']] = $row['name']; + } + + return $result; + } + + public static function getById($id) { + $where = "id='$id'"; + + return Category::getCategory($where); + } + + public static function getByShortname($shortname) { + $where = "shortname='$shortname'"; + + return Category::getCategory($where); + } + + private static function getCategory($where) { + $query = "SELECT * FROM category WHERE $where"; + + $db = getDatabase(); + + $row = $db->fetchAssocRow($query); + + if ($row) { + $category = new Category(); + $category->info = $row; + + return $category; + + } else { + return false; + } + } + + public function save() { + $db = getDatabase(); + + // TODO: Implement Save + } + + public function getId() { + return $this->info['id']; + } + + public function getName() { + return htmlspecialchars($this->info['name']); + } + + public function getShortname() { + return htmlspecialchars($this->info['shortname']); + } +} + +?> + diff --git a/htdocs/src/PostIterator.inc.php b/htdocs/src/PostIterator.inc.php index 52eb750..cced79b 100644 --- a/htdocs/src/PostIterator.inc.php +++ b/htdocs/src/PostIterator.inc.php @@ -33,6 +33,10 @@ class PostIterator implements Iterator { $this->where[] = "source_id='$source'"; } + public function filterCategory($category_id) { + $this->where[] = "category_id='$category_id'"; + } + public function orderBy($order) { $this->order = $order; } diff --git a/htdocs/src/header.inc.php b/htdocs/src/header.inc.php index f2966e4..856ba32 100644 --- a/htdocs/src/header.inc.php +++ b/htdocs/src/header.inc.php @@ -18,14 +18,35 @@ <div id="nav"> <ul> - <li><a href="" class="button">Create Post</a></li> - <li><a href="" class="button">Safety Tips</a></li> - <li><a href="" class="button">Contact Us</a></li> + <li><a href="" class="bigbutton">Create Post</a></li> + <li><a href="" class="bigbutton">Safety Tips</a></li> + <li><a href="" class="bigbutton">Contact Us</a></li> </ul> </div> <div id="buttonblock"> <p>What are you looking for?</p> + <div> + <a href="<?= $CONFIG['urlroot'] ?>/categories/forsale"><img src="<?= $CONFIG['urlroot'] ?>/images/tag.png" alt="For Sale" /></a> + <br /> + <a href="<?= $CONFIG['urlroot'] ?>/categories/forsale" class="smallbutton">For Sale</a> + </div> + <div> + <a href="<?= $CONFIG['urlroot'] ?>/categories/events"><img src="<?= $CONFIG['urlroot'] ?>/images/calendar.png" alt="Events" /></a> + <br /> + <a href="<?= $CONFIG['urlroot'] ?>/categories/events" class="smallbutton">Events</a> + </div> + <div> + <a href="<?= $CONFIG['urlroot'] ?>/categories/housing"><img src="<?= $CONFIG['urlroot'] ?>/images/house.png" alt="Housing" /></a> + <br /> + <a href="<?= $CONFIG['urlroot'] ?>/categories/housing" class="smallbutton">Housing</a> + </div> + <div> + <a href="<?= $CONFIG['urlroot'] ?>/categories/jobs"><img src="<?= $CONFIG['urlroot'] ?>/images/jobs.png" alt="Jobs" /></a> + <br /> + <a href="<?= $CONFIG['urlroot'] ?>/categories/jobs" class="smallbutton">Jobs</a> + </div> + </div> <div id="content"> |