From 3ac8e530ad5b9c2f32792ac897852c7989cef2fa Mon Sep 17 00:00:00 2001 From: Dylan Lloyd Date: Sat, 24 Mar 2012 15:40:06 -0400 Subject: [PATCH] archive now separated m/v/c --- model/archive.php | 35 ++++++++++++----------------------- view/archive.php | 34 ++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 37 deletions(-) diff --git a/model/archive.php b/model/archive.php index 0f805d4..d0947c4 100644 --- a/model/archive.php +++ b/model/archive.php @@ -2,6 +2,8 @@ class archive extends model { + public $notes = array(); + public function __construct() { parent::__construct(); } @@ -16,10 +18,11 @@ class archive extends model { } public function display() { + $this->fetch_notes(); require_once("view/archive.php"); } - public function display_notes() { + public function fetch_notes() { switch (true) { case (isset($_GET['year']) && !isset($_GET['month']) && !isset($_GET['day'])): @@ -50,28 +53,14 @@ class archive extends model { $_GET['day']); break; } - if (count($result) >= 1) { - echo "
"; - foreach ($result as $row => $entry) { - $title = $entry['title']; - $url = '/note/' . $entry['url']; - $date_posted = explode("-", $entry['date_posted']); - $year_posted = $date_posted[0]; - $month_posted = $date_posted[1]; - $datetime_posted = explode(' ', $date_posted[2]); - $day_posted = $datetime_posted[0]; - echo "
"; - echo "

"; - echo "$year_posted/$month_posted/$day_posted/"; - echo "$title

"; - echo $entry['text']; - echo "
"; - } - echo "
"; - } else { - echo "
"; - echo "

sorry, nothing here

"; - echo "
Empty set (0.00 sec)
"; + foreach ($result as $row => $entry) { + $entry['url'] = '/note/' . $entry['url']; + $date_posted = explode("-", $entry['date_posted']); + $entry['year_posted'] = $date_posted[0]; + $entry['month_posted'] = $date_posted[1]; + $entry['datetime_posted'] = explode(' ', $date_posted[2]); + $entry['day_posted'] = $entry['date_posted'][0]; + $this->notes[$row] = $entry; } } diff --git a/view/archive.php b/view/archive.php index 2829668..073c65f 100644 --- a/view/archive.php +++ b/view/archive.php @@ -36,20 +36,26 @@
- display_notes() ?> - + notes) >= 1) { + foreach ($this->notes as $note) { + echo "
"; + echo "

"; + echo $note['year_posted'] . "/"; + echo $note['month_posted'] . "/"; + echo $note['day_posted'] . "/"; + echo ""; + echo $note['title'] . "

"; + echo $note['text']; + echo "
"; + } + } else { + echo "
"; + echo "

sorry, nothing here

"; + echo "
Empty set (0.00 sec)
"; + } + ?> +

dylan

@psu.edu -- 2.30.2