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) { $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); $photos .= "fields['name'], $i) . "\">" . $imgtag . "\n"; } } return $photos; } function getThumbsAndCaptions($album) { $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); $caption = $photo->getCaption(); $photos .= "fields['name'], $i) . "\">" . $imgtag . ""; $photos .= nl2br($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; } if (empty($rssAlbumList)) { printPopupStart(gTranslate('core', "Gallery RSS feed")); showInvalidReqMesg(); exit; } 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" => nl2br(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 (isset($gallery->app->comments_enabled) && $gallery->app->comments_enabled == "yes" && 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"] .= nl2br($album->fields["description"]); } else { # mode = "basic" $albumInfo["description"] = nl2br($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 = gTranslate('core', "1 album", "%d albums", $numAlbums, gTranslate('core', "no albums"), true); $image_str = gTranslate('core', "1 photo", "%d photos", $numPhotos, gTranslate('core', "no photos"), true); $description = sprintf(gTranslate('core', "%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 . '"?' . '>'; ?> <?php echo htmlspecialchars($gallery->app->galleryTitle) ?> app->photoAlbumURL ?> app->default_language)) { ?> app->default_language) ?> app->adminEmail)) { ?> app->adminEmail ?> app->adminEmail ?> Gallery version; ?>, http://gallery.menalto.com/ http://blogs.law.harvard.edu/tech/rss 40 <?php echo htmlspecialchars($gallery->app->galleryTitle) ?> app->photoAlbumURL ?> $gallery->app->rssMaxAlbums) { break; } // Retrieve if (isset($gallery->app->rssVisibleOnly)) { $myAlbum = $albumDB->getAlbumByName($album['!name']); if ($myAlbum->isHiddenRecurse() || !$myAlbum->canReadRecurse($gallery->user->uid)) { continue; } } // Only increment after we've determined that the album // is valid to add to the feed $maxAlbums++; echo "\t\t\n"; foreach($album as $tag => $info) { # meta fields that should not be printed in the feed # start with bang. if (ereg("^!", $tag)) { continue; } if (is_array($info)) { echo "\t\t\t<$tag"; foreach($info[1] as $attr => $value) { echo ' ' . $attr . '="' . $value . '"'; } echo ">$info[0]\n"; } else { echo "\t\t\t<$tag>$info\n"; } } echo "\t\t\n"; } ?>