app->rssEnabled)) {
$gallery->app->rssEnabled = "yes";
$gallery->app->rssMode = "basic";
$gallery->app->rssHighlight = "";
$gallery->app->rssVisibleOnly = "yes";
$gallery->app->rssDCDate = "no";
$gallery->app->rssBigPhoto = "yes";
$gallery->app->rssPhotoTag = "yes";
}
if ($gallery->app->rssEnabled == "no") {
header("Location: " . makeAlbumHeaderUrl());
}
list($set_albumName) = getRequestVar(array('set_albumName'));
$gallery->session->offlineAlbums["albums.php"] = true;
function albumSort($a, $b) {
$aTime = $a["!date"];
$bTime = $b["!date"];
if ($aTime < $bTime) {
return 1;
} else {
return -1;
}
}
function bestDate($album) {
if (isset($album->fields['clicks_date']) && strtotime($album->fields["clicks_date"]) > strtotime($album->fields["last_mod_time"])) {
return $album->fields['clicks_date'];
}
else {
return $album->fields['last_mod_time'];
}
}
function getThumbs($album) {
$tags = "border=0 vspace=2 hspace=0 align=top";
$photos = "";
$photoCount = $album->numPhotos(1);
for ($i = 1; $i <= $photoCount; $i += 1) {
$photo = $album->getPhoto($i);
if (!$photo->isHidden() && !$photo->isMovie() && $photo->thumbnail) {
$imgtag = $album->getThumbnailTag($i, 0, $tags);
$photos .= "fields['name'], $i) . "\">" . $imgtag . "\n";
}
}
return $photos;
}
function getThumbsAndCaptions($album) {
$tags = "border=0 vspace=2 hspace=0 align=top";
$photos = "";
$photoCount = $album->numPhotos(1);
for ($i = 1; $i <= $photoCount; $i += 1) {
$photo = $album->getPhoto($i);
if (!$photo->isHidden() && !$photo->isMovie() && is_object($photo->thumbnail)) {
$imgtag = $album->getThumbnailTag($i, 0, $tags);
$caption = $photo->getCaption();
$photos .= "fields['name'], $i) .
"\">" . $imgtag . "$caption
\n";
}
}
return $photos;
}
function makeDCDate($unixDate) {
$dcDate = date("Y-m-d\TH:i:sO", $unixDate);
/* CAUTION: This will not work in zones with
* half-our time offsets
*/
return eregi_replace("..$", ":00", $dcDate);
}
/* Read the album list */
$albumDB = new AlbumDB(FALSE);
$gallery->session->albumName = "";
$page = 1;
$albumList = array();
/* Initialize album and photo counts */
$numAlbums = 0;
$numPhotos = 0;
if (isset($set_albumName)) {
$rssAlbumList = $albumDB->getAlbumsByRoot($set_albumName);
}
else {
$rssAlbumList = $albumDB->albumList;
}
foreach ($rssAlbumList as $album) {
// Save time later.. if we can't read it, don't add it.
if (!$gallery->user->canReadAlbum($album)) {
continue;
}
// Increment counters
$numAlbums++;
$album->load($album->fields['name']);
$numPhotos += $album->numPhotos(0, 1);
$albumInfo = array(
"!name" => $album->fields["name"],
"link" => makeAlbumUrl($album->fields["name"]),
"guid" => array($album->fields['guid'], array("isPermaLink" => "false")),
"!date" => bestDate($album),
"title" => htmlspecialchars($album->fields["title"]));
// DATE TAGS
$unixDate = $albumInfo["!date"];
if (isset($unixDate)) {
$albumInfo["pubDate"] = date("r", $unixDate);
if ($gallery->app->rssDCDate == "yes") {
$albumInfo["dc:date"] = makeDCDate($unixDate);
}
}
// COMMENTS TAG
if (method_exists($album, "canViewComments")
&& $album->canViewComments($gallery->user->uid)) {
$albumInfo["comments"] = makeGalleryUrl("view_comments.php",
array("set_albumName" => $album->fields["name"]));
}
// PHEED AND PHOTO TAGS
if ($gallery->app->rssPhotoTag == "yes") {
if (!$album->transient->photosloaded) {
$album->load($album->fields["name"], TRUE);
}
list($subalbum, $highlight) = $album->getHighlightedItem();
if ($highlight) {
# makeAlbumURL is for the pretty page, getAlbumDirURL is for the image itself
// $subalbum is either the current album, or the album which contains the
// highlight, so it's always correct.
$base = $subalbum->getAlbumDirURL("highlight");
$albumInfo["photo:imgsrc"] = $highlight->thumbnail->getPath($base);
$albumInfo["photo:thumbnail"] = $highlight->getPhotoPath($base);
$width = $highlight->thumbnail->width;
$height = $highlight->thumbnail->height;
if ($gallery->app->rssBigPhoto == "no") {
$ratio = 1;
if ($width > 144) {
$ratio = 144 / $width;
$width = 144;
}
if ($height > 400 || $ratio != 1) {
if (($height * $ratio) > 400) {
$ratio = 400 / ($height * $ratio);
$height = 400;
$width = $width * $ratio;
} else {
$height = $height * $ratio;
}
}
$height = floor($height);
$width = floor($width);
}
$albumInfo['pb:thumb'] = $highlight->thumbnail->getPath($base);
$albumInfo['pb:height'] = $height;
$albumInfo['pb:width'] = $width;
}
}
// INSET HTML IMAGES
if (!isset($gallery->app->rssMode)) {
$gallery->app->rssMode="basic";
}
if ($gallery->app->rssMode == "thumbs") {
if (!$album->transient->photosloaded) {
$album->load($album->fields["name"], TRUE);
}
$albumInfo["description"] = $album->fields["description"] . '
'; $albumInfo["description"] .= getThumbs($album); } elseif ($gallery->app->rssMode == "thumbs-with-captions") { if (!$album->transient->photosloaded) { $album->load($album->fields["name"], TRUE); } $albumInfo["description"] = $album->fields["description"] . '
';
$albumInfo["description"] .= getThumbsAndCaptions($album);
} elseif ($gallery->app->rssMode == "highlight" && isset($highlight)) {
$url = makeAlbumUrl($album->fields["name"]);
$imgtag = $highlight->thumbnail->getTag($base, 0, 0, 'border=0');
$albumInfo["description"] = "$imgtag
";
$albumInfo["description"] .= $album->fields["description"];
} else { # mode = "basic"
$albumInfo["description"] = $album->fields["description"];
}
$albumInfo["description"] = htmlspecialchars($albumInfo["description"]);
array_push($albumList, $albumInfo);
}
usort($albumList, "albumSort");
unset($ha); $channel_image = $channel_width = $channel_height = "";
if (isset($gallery->app->rssHighlight) && $gallery->app->rssHighlight != "*") {
foreach($albumList as $album) {
if ($album["!name"] == $gallery->app->rssHighlight && isset($album["pb:thumb"])) {
$ha = $album;
break;
}
}
} elseif (isset($albumList[0]["pb:thumb"])) {
$ha = $albumList[0];
}
if (isset($ha)) {
$channel_image = $ha["pb:thumb"];
$channel_image_width = $ha["pb:width"];
$channel_image_height = $ha["pb:height"];
}
$total_str = pluralize_n2(ngettext(_("1 album"), _("%s albums"), $numAlbums), $numAlbums, _("no albums"));
$image_str = pluralize_n2(ngettext(_("1 photo"), _("%s photos"), $numPhotos), $numPhotos, _("no photos"));
$description = sprintf(_("%s in %s"), $image_str, $total_str);
header("Content-Type: application/xml");
$xml_header = 'xml version="1.0"';
if ($gallery->locale == 0) {
$gallery->locale = 'ISO-8859-1';
}
echo '<' . '?xml version="1.0" encoding="' . $gallery->locale . '"?' . '>';
?>