diff options
Diffstat (limited to 'htdocs/src')
-rw-r--r-- | htdocs/src/Category.inc.php | 20 | ||||
-rw-r--r-- | htdocs/src/Post.inc.php | 25 | ||||
-rw-r--r-- | htdocs/src/header.inc.php | 10 |
3 files changed, 48 insertions, 7 deletions
diff --git a/htdocs/src/Category.inc.php b/htdocs/src/Category.inc.php index fdcd210..cfef06b 100644 --- a/htdocs/src/Category.inc.php +++ b/htdocs/src/Category.inc.php @@ -12,10 +12,16 @@ require_once "base.inc.php"; class Category { private $info; - + private $options = array('price' => false); public function __construct($info=null) { $this->info = $info; + + if (isset($this->info['options'])) { + foreach (split(',', $this->info['options']) as $op) { + $this->options[$op] = true; + } + } } public static function getCategories() { @@ -54,8 +60,7 @@ class Category { $row = $db->fetchAssocRow($query); if ($row) { - $category = new Category(); - $category->info = $row; + $category = new Category($row); return $category; @@ -85,7 +90,14 @@ class Category { public function getDescription() { return htmlspecialchars($this->info['description']); } + + public function getOption($name) { + return $this->options[$name]; + } + + public function setOption($value) { + $this->options[$name] = $value; + } } ?> - diff --git a/htdocs/src/Post.inc.php b/htdocs/src/Post.inc.php index 9747d3f..d887694 100644 --- a/htdocs/src/Post.inc.php +++ b/htdocs/src/Post.inc.php @@ -14,6 +14,7 @@ class Post { private $info; private $indatabase = false; private $images; + private $category; public function __construct($info=null) { @@ -26,7 +27,8 @@ class Post { $this->indatabase = false; } - $images = null; + $this->images = null; + $this->category = null; } public static function getById($id) { @@ -205,8 +207,17 @@ class Post { $this->info['email'] = $value; } - public function setCategory($value) { - $this->info['category_id'] = $value; + public function setCategory(Category $cat) { + $this->info['category_id'] = $cat->getId(); + $this->category = $cat; + } + + public function getCategory() { + if ($this->category == NULL) { + $this->category = Categories::getById($this->info['category_id']); + } + + return $this->category; } public function getAge() { @@ -237,6 +248,14 @@ class Post { $this->info['location'] = $value; } + public function getPrice() { + return $this->info['price']; + } + + public function setPrice($value) { + $this->info['price'] = $value; + } + public function getImages() { if ($this->images == null) { $this->loadImages(); diff --git a/htdocs/src/header.inc.php b/htdocs/src/header.inc.php index 839ebaf..856022e 100644 --- a/htdocs/src/header.inc.php +++ b/htdocs/src/header.inc.php @@ -31,11 +31,21 @@ <div id="buttonblock"> <p>What are you looking for?</p> <div> + <a href="<?= $CONFIG['urlroot'] ?>/categories/free"><img src="<?= $CONFIG['urlroot'] ?>/images/tag.png" alt="Free Items" /></a> + <br /> + <a href="<?= $CONFIG['urlroot'] ?>/categories/free" class="smallbutton">Free Items</a> + </div> + <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/needs"><img src="<?= $CONFIG['urlroot'] ?>/images/tag.png" alt="Needs" /></a> + <br /> + <a href="<?= $CONFIG['urlroot'] ?>/categories/needs" class="smallbutton">Needs</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> |