From 5bcb138ac97476619e78aaa52e9f5507003d5caf Mon Sep 17 00:00:00 2001 From: Dylan Lloyd Date: Sat, 24 Mar 2012 15:17:42 -0400 Subject: [PATCH] rss layout now fully separated m/v/c --- model/rss.php | 29 +++++++++++++---------------- view/rss.php | 11 ++++++++++- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/model/rss.php b/model/rss.php index b7c5164..a169ead 100644 --- a/model/rss.php +++ b/model/rss.php @@ -2,35 +2,32 @@ class rss extends model { + public $items = array(); + public function display() { + $this->fetch_items(); require_once("view/rss.php"); } - public function display_items() { + public function fetch_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, '.'); + $entry->url = "http://dylansserver.com/note/" . $entry->url; + $entry->text = strip_tags($entry->text); + $end_of_first_sentence = strpos($entry->text, '.'); if ($end_of_first_sentence) { - $end_of_second_sentence = strpos($text, '.', ($end_of_first_sentence + 1)); + $end_of_second_sentence = strpos($entry->text, '.', ($end_of_first_sentence + 1)); if ($end_of_second_sentence) { - $description = substr($text, '0', ($end_of_second_sentence + 1)); + $entry->description = substr($entry->text, '0', ($end_of_second_sentence + 1)); } else { - $description = substr($text, '0', ($end_of_first_sentence + 1)); + $entry->description = substr($entry->text, '0', ($end_of_first_sentence + 1)); } + foreach ($entry as $key => $val) { + $this->items[][$key] = $entry->$key; + } } - echo ""; - echo " $title"; - echo " $url"; - echo " $url"; - echo " $description"; - echo ""; } } } diff --git a/view/rss.php b/view/rss.php index 2f55ca3..7d0c60c 100644 --- a/view/rss.php +++ b/view/rss.php @@ -4,6 +4,15 @@ http://dylansserver.com/notes dylansserver.com/notes/rss - display_items() ?> + items as $item) { + echo ""; + echo " " . $item['title'] . ""; + echo " " . $item['url'] . ""; + echo " " . $item['url'] . ""; + echo " " . $item['description'] . ""; + echo ""; + } + ?> -- 2.30.2