2009-06-12 07:46:42 -07: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
|
2009-06-12 07:46:42 -07: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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class gallery_rss_Core {
|
2009-06-14 21:51:54 -07:00
|
|
|
static function available_feeds($item, $tag) {
|
|
|
|
|
$feeds["gallery/latest"] = t("Latest photos and movies");
|
2011-07-12 21:44:40 -07:00
|
|
|
|
|
|
|
|
if ($item) {
|
|
|
|
|
$feed_item = $item -> is_album() ? $item : $item->parent();
|
|
|
|
|
|
|
|
|
|
$feeds["gallery/album/{$feed_item->id}"] =
|
|
|
|
|
t("%title photos and movies", array("title" => $feed_item->title));
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-14 21:51:54 -07:00
|
|
|
return $feeds;
|
2009-06-12 07:46:42 -07:00
|
|
|
}
|
2009-06-12 08:52:03 -07:00
|
|
|
|
2009-06-14 21:51:54 -07:00
|
|
|
static function feed($feed_id, $offset, $limit, $id) {
|
2010-01-31 16:07:41 -08:00
|
|
|
$feed = new stdClass();
|
2009-06-14 21:51:54 -07:00
|
|
|
switch ($feed_id) {
|
|
|
|
|
case "latest":
|
2010-06-20 17:25:23 -07:00
|
|
|
$feed->items = ORM::factory("item")
|
2009-06-14 21:51:54 -07:00
|
|
|
->viewable()
|
2009-11-26 12:09:04 -08:00
|
|
|
->where("type", "<>", "album")
|
2009-11-25 19:26:52 -08:00
|
|
|
->order_by("created", "DESC")
|
2009-06-14 21:51:54 -07:00
|
|
|
->find_all($limit, $offset);
|
|
|
|
|
|
2010-06-20 17:25:23 -07:00
|
|
|
$all_items = ORM::factory("item")
|
2009-06-14 21:51:54 -07:00
|
|
|
->viewable()
|
2009-11-26 12:09:04 -08:00
|
|
|
->where("type", "<>", "album")
|
2009-11-25 19:26:52 -08:00
|
|
|
->order_by("created", "DESC");
|
2009-06-14 21:51:54 -07:00
|
|
|
|
2010-06-20 17:25:23 -07:00
|
|
|
$feed->max_pages = ceil($all_items->find_all()->count() / $limit);
|
2010-09-04 13:40:39 -07:00
|
|
|
$feed->title = t("%site_title - Recent updates", array("site_title" => item::root()->title));
|
2009-10-28 12:15:52 -07:00
|
|
|
$feed->description = t("Recent updates");
|
2009-06-14 21:51:54 -07:00
|
|
|
return $feed;
|
|
|
|
|
|
|
|
|
|
case "album":
|
|
|
|
|
$item = ORM::factory("item", $id);
|
|
|
|
|
access::required("view", $item);
|
|
|
|
|
|
2010-06-20 17:25:23 -07:00
|
|
|
$feed->items = $item
|
2009-06-14 21:51:54 -07:00
|
|
|
->viewable()
|
2009-11-26 19:33:03 -08:00
|
|
|
->descendants($limit, $offset, array(array("type", "=", "photo")));
|
2009-08-05 10:38:53 -07:00
|
|
|
$feed->max_pages = ceil(
|
2009-12-22 21:18:31 -08:00
|
|
|
$item->viewable()->descendants_count(array(array("type", "=", "photo"))) / $limit);
|
2010-09-04 13:40:39 -07:00
|
|
|
if ($item->id == item::root()->id) {
|
|
|
|
|
$feed->title = html::purify($item->title);
|
|
|
|
|
} else {
|
|
|
|
|
$feed->title = t("%site_title - %item_title",
|
|
|
|
|
array("site_title" => item::root()->title,
|
|
|
|
|
"item_title" => $item->title));
|
|
|
|
|
}
|
2009-08-29 22:54:20 -07:00
|
|
|
$feed->description = nl2br(html::purify($item->description));
|
2009-06-14 21:51:54 -07:00
|
|
|
|
|
|
|
|
return $feed;
|
|
|
|
|
}
|
2009-06-12 11:48:13 -07:00
|
|
|
}
|
2009-06-12 07:46:42 -07:00
|
|
|
}
|