From 98b514f5005e981ed6a8a23fa9bf3f4def2aed7c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 May 2012 09:23:22 +0200 Subject: [PATCH] rss --- htdocs/application/controllers/main.php | 8 ++++-- htdocs/application/models/pastes.php | 35 +++++++++++++++++++++++++ htdocs/application/views/view/rss.php | 15 ++++++----- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/htdocs/application/controllers/main.php b/htdocs/application/controllers/main.php index 3c99d11..96841d8 100755 --- a/htdocs/application/controllers/main.php +++ b/htdocs/application/controllers/main.php @@ -6,6 +6,7 @@ * - _form_prep() * - index() * - raw() + * - rss() * - embed() * - download() * - lists() @@ -300,8 +301,11 @@ class Main extends CI_Controller if ($check) { - $data = $this->pastes->getPaste(3, true); - print_r($data); + $data = $this->pastes->getReplies(3); + $data['feed_url'] = ''; + $data['page_description'] = ''; + $data['page_language'] = ''; + $data['creator_email'] = ''; $this->load->view('view/rss', $data); } else diff --git a/htdocs/application/models/pastes.php b/htdocs/application/models/pastes.php index a9cf6db..58510ef 100755 --- a/htdocs/application/models/pastes.php +++ b/htdocs/application/models/pastes.php @@ -8,6 +8,7 @@ * - createPaste() * - checkPaste() * - getPaste() + * - getReplies() * - getLists() * - cron() * Classes list: @@ -298,6 +299,40 @@ class Pastes extends CI_Model return $data; } + function getReplies($seg = 3) + { + $amount = $this->config->item('per_page'); + + if ($this->uri->segment($seg) == '') + { + redirect(''); + } + else + { + $pid = $this->uri->segment($seg); + } + $this->db->select('title, name, created, pid, paste'); + $this->db->where('replyto', $pid); + $this->db->order_by('id', 'desc'); + $this->db->limit($amount); + $query = $this->db->get('pastes', $amount); + + if ($query->num_rows() > 0) + { + $n = 0; + foreach ($query->result_array() as $row) + { + $data['replies'][$n]['title'] = $row['title']; + $data['replies'][$n]['name'] = $row['name']; + $data['replies'][$n]['created'] = $row['created']; + $data['replies'][$n]['pid'] = $row['pid']; + $data['replies'][$n]['paste'] = $row['paste']; + $n++; + } + } + return $data; + } + function getLists($root = 'lists/', $seg = 2) { $this->load->library('pagination'); diff --git a/htdocs/application/views/view/rss.php b/htdocs/application/views/view/rss.php index c7075a1..27316ee 100644 --- a/htdocs/application/views/view/rss.php +++ b/htdocs/application/views/view/rss.php @@ -1,8 +1,9 @@ - ' . "\n"; ?> +' . "\n"; ?> - + Stikked + @@ -10,14 +11,14 @@ Copyright - result() as $post): ?> + -id) ?> - id) ?> + + - <[CDATA[ text, 200); ?> ]]> -date; ?> + <[CDATA[ ]]> +