2008-11-18 19:09:24 +00:00
|
|
|
<?php defined("SYSPATH") or die("No direct script access.");
|
|
|
|
|
/**
|
|
|
|
|
* Gallery - a web based photo album viewer and editor
|
2009-05-13 20:04:58 +00:00
|
|
|
* Copyright (C) 2000-2009 Bharat Mediratta
|
2008-11-18 19:09:24 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
|
* your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
2009-02-19 15:24:17 +00:00
|
|
|
class Rss_Controller extends Controller {
|
2008-11-28 05:18:17 +00:00
|
|
|
public static $page_size = 30;
|
2008-11-20 02:59:43 +00:00
|
|
|
|
2009-06-14 10:13:12 -07:00
|
|
|
public function feed($method, $id=null) {
|
2009-02-23 02:47:29 +00:00
|
|
|
$page = $this->input->get("page", 1);
|
2009-06-14 10:13:12 -07:00
|
|
|
$feed_uri = "rss/feed/$method" . (empty($id) ? "" : "/$id");
|
2009-02-23 02:47:29 +00:00
|
|
|
if ($page < 1) {
|
2009-06-12 08:52:03 -07:00
|
|
|
url::redirect($feed_uri);
|
2009-02-23 02:47:29 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-14 11:20:08 -07:00
|
|
|
$feed = rss::feed_data($method, ($page - 1) * self::$page_size, self::$page_size, $id);
|
2009-06-12 08:52:03 -07:00
|
|
|
if ($feed->max_pages && $page > $feed->max_pages) {
|
|
|
|
|
url::redirect("$feed_uri?page={$feed->max_pages}");
|
2009-02-23 02:47:29 +00:00
|
|
|
}
|
2009-02-26 02:09:41 +00:00
|
|
|
|
2009-06-12 08:52:03 -07:00
|
|
|
$view = new View(empty($feed->view) ? "feed.mrss" : $feed->view);
|
|
|
|
|
foreach ($feed->data as $field => $value) {
|
|
|
|
|
$view->$field = $value;
|
2009-02-23 02:47:29 +00:00
|
|
|
}
|
2009-06-12 08:52:03 -07:00
|
|
|
$view->feed_link = url::abs_site($feed_uri);
|
2009-02-23 02:47:29 +00:00
|
|
|
|
|
|
|
|
if ($page > 1) {
|
|
|
|
|
$previous_page = $page - 1;
|
2009-06-12 08:52:03 -07:00
|
|
|
$view->previous_page_link = url::site("$feed_uri?page={$previous_page}");
|
2009-02-23 02:47:29 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-12 08:52:03 -07:00
|
|
|
if ($page < $feed->max_pages) {
|
2009-02-23 02:47:29 +00:00
|
|
|
$next_page = $page + 1;
|
2009-06-12 08:52:03 -07:00
|
|
|
$view->next_page_link = url::site("$feed_uri?page={$next_page}");
|
2009-02-23 02:47:29 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-12 08:52:03 -07:00
|
|
|
$view->pub_date = date("D, d M Y H:i:s T");
|
|
|
|
|
|
2009-02-23 02:47:29 +00:00
|
|
|
rest::http_content_type(rest::RSS);
|
2009-02-24 19:19:58 +00:00
|
|
|
print $view;
|
2009-02-23 02:47:29 +00:00
|
|
|
}
|
2008-11-18 19:09:24 +00:00
|
|
|
}
|