rss now using model
authorDylan Lloyd <dylan@dylansserver.com>
Fri, 23 Mar 2012 08:56:21 +0000 (04:56 -0400)
committerDylan Lloyd <dylan@dylansserver.com>
Fri, 23 Mar 2012 08:56:21 +0000 (04:56 -0400)
cms.php
view/rss.php

diff --git a/cms.php b/cms.php
index 428cae1..b5b3b20 100644 (file)
--- a/cms.php
+++ b/cms.php
@@ -94,8 +94,9 @@ abstract class cms {
         require_once("view/page.php");
         break;
       case "rss":
+        require_once("model/rss.php");
         $rss = new rss();
-        $rss->display();
+        require_once("view/rss.php");
         break;
       case 'archive':
         $archive = new archive;
@@ -235,42 +236,6 @@ class archive extends cms {
 }
 
 
-class rss extends cms {
-
-  public function display() {
-    require_once("view/rss.php");
-  }
-
-  public function display_items() {
-    $result = $this->db->query("SELECT date_posted, title, text, url
-                                         FROM notes ORDER BY date_posted DESC
-                                         LIMIT 5");
-       while ($entry = $result->fetch_object()) {
-         $title = $entry->title;
-         $date_posted = $entry->date_posted;
-         $url = "http://dylansserver.com/note/" . $entry->url;
-         $text = $entry->text;
-         $text = strip_tags($text);
-         $end_of_first_sentence = strpos($text, '.');
-         if ($end_of_first_sentence) {
-           $end_of_second_sentence = strpos($text, '.', ($end_of_first_sentence + 1));
-               if ($end_of_second_sentence) {
-                 $description = substr($text, '0', ($end_of_second_sentence + 1));
-               } else {
-                 $description = substr($text, '0', ($end_of_first_sentence + 1));
-               }
-         }
-      echo "<item>";
-      echo "  <title>$title</title>";
-      echo "  <link>$url</link>";
-      echo "  <guid>$url</guid>";
-      echo "  <description>$description</description>";
-      echo "</item>";
-       }
-  }
-}
-
-
 class notFound extends Exception {
 
     public function __construct() {
index 2f55ca3..4e2609b 100644 (file)
@@ -4,6 +4,6 @@
     <link>http://dylansserver.com/notes</link>
     <description>dylansserver.com/notes/rss</description>
     <atom:link href="http://dylansserver.com/notes/rss" rel="self" type="application/rss+xml" />
-    <?php $this->display_items() ?>
+    <?php $rss->display_items() ?>
   </channel>
 </rss>