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
|
2013-01-21 01:22:01 -05:00
|
|
|
* Copyright (C) 2000-2013 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 {
|
2009-06-14 16:40:57 -07:00
|
|
|
public static $page_size = 20;
|
2008-11-20 02:59:43 +00:00
|
|
|
|
2009-06-14 21:51:54 -07:00
|
|
|
public function feed($module_id, $feed_id, $id=null) {
|
2009-12-21 21:27:43 -08:00
|
|
|
$page = (int) Input::instance()->get("page", 1);
|
2009-02-23 02:47:29 +00:00
|
|
|
if ($page < 1) {
|
2009-06-14 21:51:54 -07:00
|
|
|
url::redirect(url::merge(array("page" => 1)));
|
2009-02-23 02:47:29 +00:00
|
|
|
}
|
|
|
|
|
|
2009-09-01 20:13:23 -07:00
|
|
|
// Configurable page size between 1 and 100, default 20
|
2009-12-21 21:27:43 -08:00
|
|
|
$page_size = max(1, min(100, (int) Input::instance()->get("page_size", self::$page_size)));
|
2009-09-01 20:13:23 -07:00
|
|
|
|
2009-06-14 21:51:54 -07:00
|
|
|
// Run the appropriate feed callback
|
|
|
|
|
if (module::is_active($module_id)) {
|
|
|
|
|
$class_name = "{$module_id}_rss";
|
2013-03-02 13:25:10 +01:00
|
|
|
if (class_exists($class_name) && method_exists($class_name, "feed")) {
|
2009-06-14 21:51:54 -07:00
|
|
|
$feed = call_user_func(
|
|
|
|
|
array($class_name, "feed"), $feed_id,
|
2009-09-01 20:13:23 -07:00
|
|
|
($page - 1) * $page_size, $page_size, $id);
|
2009-06-14 21:51:54 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (empty($feed)) {
|
2009-11-25 13:49:40 -08:00
|
|
|
throw new Kohana_404_Exception();
|
2009-06-14 21:51:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($feed->max_pages && $page > $feed->max_pages) {
|
|
|
|
|
url::redirect(url::merge(array("page" => $feed->max_pages)));
|
2009-02-23 02:47:29 +00:00
|
|
|
}
|
2009-02-26 02:09:41 +00:00
|
|
|
|
2009-06-14 16:40:57 -07:00
|
|
|
$view = new View(empty($feed->view) ? "feed.mrss" : $feed->view);
|
|
|
|
|
unset($feed->view);
|
2009-06-14 12:38:57 -07:00
|
|
|
|
2009-06-14 16:40:57 -07:00
|
|
|
$view->feed = $feed;
|
2012-05-07 13:29:52 -07:00
|
|
|
$view->pub_date = date("D, d M Y H:i:s O");
|
2009-02-23 02:47:29 +00:00
|
|
|
|
2010-01-18 11:10:37 -08:00
|
|
|
$feed->uri = url::abs_site(url::merge($_GET));
|
2009-02-23 02:47:29 +00:00
|
|
|
if ($page > 1) {
|
2010-01-18 11:10:37 -08:00
|
|
|
$feed->previous_page_uri = url::abs_site(url::merge(array("page" => $page - 1)));
|
2009-02-23 02:47:29 +00:00
|
|
|
}
|
2009-06-14 21:51:54 -07:00
|
|
|
if ($page < $feed->max_pages) {
|
2010-01-18 11:10:37 -08:00
|
|
|
$feed->next_page_uri = url::abs_site(url::merge(array("page" => $page + 1)));
|
2009-02-23 02:47:29 +00:00
|
|
|
}
|
|
|
|
|
|
2009-11-25 13:02:14 -08:00
|
|
|
header("Content-Type: application/rss+xml");
|
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
|
|
|
}
|