summaryrefslogtreecommitdiff
path: root/htdocs
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2011-06-09 16:56:39 -0700
committerJesse Morgan <jesse@jesterpm.net ; true>2011-06-09 16:56:39 -0700
commit8439ed9ba5b36fa382e32ea883a0877d6ec536c0 (patch)
treecb49279c74804503d42c543e4a2c244695d5ce8a /htdocs
parent0b1deccfe6cbe7fca0a6abd03abb18cafca59c60 (diff)
Finished added prices. Added more buttons to the headers. Fixed the categories.
Diffstat (limited to 'htdocs')
-rw-r--r--htdocs/categories.php7
-rw-r--r--htdocs/index.php7
-rw-r--r--htdocs/new-post.php18
-rw-r--r--htdocs/postings.php9
-rw-r--r--htdocs/src/Category.inc.php20
-rw-r--r--htdocs/src/Post.inc.php25
-rw-r--r--htdocs/src/header.inc.php10
7 files changed, 84 insertions, 12 deletions
diff --git a/htdocs/categories.php b/htdocs/categories.php
index a3e8ba2..86e5f9a 100644
--- a/htdocs/categories.php
+++ b/htdocs/categories.php
@@ -56,12 +56,17 @@ function displayEvents($category) {
if ($posts->valid()) {
foreach ($posts as $id => $post) {
+ $title = $post->getName();
+ if ($post->getPrice() != 0) {
+ $title .= ' - $' . $post->getPrice();
+ }
+
printf("<div class=\"post\"><p><a href=\"". $GLOBALS['CONFIG']['urlroot']
. "/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());
+ $id, $title, $post->getLocation(), $post->getAge());
}
} else {
diff --git a/htdocs/index.php b/htdocs/index.php
index 148cfd6..b09c4bf 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -22,12 +22,17 @@ $posts->query();
if ($posts->valid()) {
foreach ($posts as $id => $post) {
+ $title = $post->getName();
+ if ($post->getPrice() != 0) {
+ $title .= ' - $' . $post->getPrice();
+ }
+
printf("<div class=\"post\"><p><a href=\"". $GLOBALS['CONFIG']['urlroot']
. "/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());
+ $id, $title, $post->getLocation(), $post->getAge());
}
} else {
diff --git a/htdocs/new-post.php b/htdocs/new-post.php
index 961cdda..e421d3c 100644
--- a/htdocs/new-post.php
+++ b/htdocs/new-post.php
@@ -99,7 +99,7 @@ function finish_category() {
if (isset($_GET['category'])) {
$category = Category::getByShortname(addslashes($_GET['category']));
if ($category) {
- $post->setCategory($category->getId());
+ $post->setCategory($category);
return true;
}
}
@@ -168,6 +168,11 @@ function finish_post() {
$post->setName($values['title']);
$post->setDescription($values['description']);
$post->setLocation($values['location']);
+
+ // Price is optional
+ if (isset($_POST['price'])) {
+ $post->setPrice($_POST['price']);
+ }
if ($post->save()) {
return true;
@@ -293,8 +298,10 @@ require_once "src/footer.inc.php";
function render_form($error="") {
+ $category = $_SESSION['newpost']->getCategory();
$title = isset($_POST['title']) ? $_POST['title'] : '';
+ $price = isset($_POST['price']) ? $_POST['price'] : '';
$location = isset($_POST['location']) ? $_POST['location'] : '';
$description = isset($_POST['description']) ? $_POST['description'] : '';
$email = isset($_POST['email']) ? $_POST['email'] : '';
@@ -304,7 +311,14 @@ function render_form($error="") {
echo "<div class=\"errorbox\">$error</div>";
}
- echo "<p><label>Title: <input type=\"text\" name=\"title\" value=\"$title\" /></label></p>";
+ echo "<p><label>Title: <input type=\"text\" name=\"title\" value=\"$title\" /></label>";
+
+ if ($category->getOption('price')) {
+ echo " <label>Price: $<input type=\"text\" name=\"price\" value=\"$price\" /></label>";
+ }
+
+
+ echo "</p>";
echo "<p><label>Location: <input type=\"text\" name=\"location\" value=\"$location\" /></label></p>";
diff --git a/htdocs/postings.php b/htdocs/postings.php
index b69767e..a52d939 100644
--- a/htdocs/postings.php
+++ b/htdocs/postings.php
@@ -48,7 +48,14 @@ if (isset($_GET['moderate'])) {
// Display the post.
-echo "<h2>". $post->getName() ."</h2>";
+echo "<h2>". $post->getName();
+
+if ($post->getPrice() != 0) {
+ echo ' - $' . $post->getPrice();
+}
+
+echo "</h2>";
+
echo "<p>Date: ". date('r', $post->getTimestamp()) ."</p>";
echo "<p>Email: <a href=\"mailto:". $post->getPublicEmail() ."\">"
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>