archive now separated m/v/c
authorDylan Lloyd <dylan@dylansserver.com>
Sat, 24 Mar 2012 19:40:06 +0000 (15:40 -0400)
committerDylan Lloyd <dylan@dylansserver.com>
Sat, 24 Mar 2012 19:40:06 +0000 (15:40 -0400)
model/archive.php
view/archive.php

index 0f805d4..d0947c4 100644 (file)
@@ -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 "<div id='notes'>";
-      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 "<div class='note'>";
-        echo "<h1><span class='date'>";
-        echo "$year_posted/$month_posted/$day_posted/";
-        echo "</span><a href='$url'>$title</a></h1>";
-        echo $entry['text'];
-        echo "</div>";
-      }
-      echo "</div>";
-    } else {
-      echo "<br>";
-      echo "<h1>sorry, nothing here</h2>";
-      echo "<pre>Empty set (0.00 sec)</pre>";
+    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;
     }
   }
 
index 2829668..073c65f 100644 (file)
 
     <div id="content">
       <div id='notes'>
-        <?php $this->display_notes() ?>
-    <div id='navigation'>
-    <h1>
-    <?php
-    if($this->page > 1){
-      $previous_page = $this->page - 1;
-      echo "<a href='/notes/page/$previous_page'>prev</a>";
-    }
-    if($this->page < $this->number_of_pages) {
-    $forward_page = $this->page + 1;
-    echo " <a href='/notes/page/$forward_page'>next</a>";
-    } ?>
-    </h1>
-    </div>
+        <?php
+          if (count($this->notes) >= 1) {
+            foreach ($this->notes as $note) {
+              echo "<div class='note'>";
+              echo "<h1><span class='date'>";
+              echo $note['year_posted'] . "/";
+              echo $note['month_posted'] . "/";
+              echo $note['day_posted'] . "/";
+              echo "</span><a href='" . $note['url'] . "'>";
+              echo $note['title'] . "</a></h1>";
+              echo $note['text'];
+              echo "</div>";
+            }
+          } else {
+            echo "<br>";
+            echo "<h1>sorry, nothing here</h2>";
+            echo "<pre>Empty set (0.00 sec)</pre>";
+          }
+        ?>
+      </div>
       <div id="contact_me"><h1><a href=
       "mailto:dylan@psu.edu">dylan</a></h1><a href=
       "mailto:dylan@psu.edu">@psu.edu</a>