* Last Updated: April 16, 2004 * */ /* CONFIGURATION SECTION */ # mode # # In-set HTML photo modes. If you turn this on, tags will be # placed in each item's description. Options for this are: # # basic - no images at all # highlight - only the highlighted image # thumbs - all thumbnails # thumbs-with-captions - all thumbnails AND captions for each # mdm - the mystery option! # # Note that this setting has no effect on the photo and pb elements, # discussed above. Also note that 'thumbs' and 'thumbs-with-captions' # have been known to crash NetNewsWire. $mode = "basic"; # highlightAlbum # # Which album's highlight picture should be the highlight for the # whole RSS feed? If set to '*' it will select the highlight image # of the most-recently-created album. # # If set to "", it will turn off the channel highlight feature. # (See noBigPhoto below for more info). $highlightAlbum = "*"; # onlyFindable # # Suppose you have an album with 5 sub-albums, and you don't want # anyone to look at any of them, so you mark the big album as # hidden. Technically, users can still look at the sub-albums, but # they can't actually _find_ them. # # Given that definition of findable, turn this off if you want # only finadable albums to be visible. $onlyFindable = TRUE; # noPhotoTag # # There are two RSS extensions that allow for images representing # items to be linked from feeds. They are: # # From Pheed Spec (see http://www.pheed.com/pheed/): # photo:imgsrc and photo:thumbnail # # From PhotoBlog Spec (see http://snaplog.com/backend/PhotoBlog.html): # pb:thumb # # These elements shouldn't be damaging at all, even to clients # unaware of their meaning, but if you want to turn them off, you can. $noPhotoTag = FALSE; # noDCDate # # Having both pubDate and dc:date elements for an item may cause it # to not validate. If you absolutely MUST have strictly valid RSS, # set this option to TRUE. However, doing this may break some older # RSS readers that don't fully support RSS 2.0. $noDCDate = FALSE; # noBigPhotos # # The whole channel can have one highlight image, but it can be no # more than 144 pixels wide and 400 pixels tall. Since most galleries # have thumbnails 150 pixels wide (for landscape photos), a small # amount of clipping may occur on some clients. So most people won't # really even notice, we lie about the sizes if the thumbnail is too # big. # # If some clients complain that the channel thumbnail is garbled # in their news reader because of the bogus size, you can set this to # false to turn that feature off, but it will cause your RSS feed # to not validate. $noBigPhoto = TRUE; /* END OF CONFIGURATION SECTION */ /* Authored in the Gallery coding style, because * I think it makes hacks and changes quite easy. */ /* Hack prevention. */ if (!empty($HTTP_GET_VARS["GALLERY_BASEDIR"]) || !empty($HTTP_POST_VARS["GALLERY_BASEDIR"]) || !empty($HTTP_COOKIE_VARS["GALLERY_BASEDIR"])) { print _("Security violation") ."\n"; exit; } if (!isset($GALLERY_BASEDIR)) { $GALLERY_BASEDIR = './'; } require($GALLERY_BASEDIR . 'init.php'); $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"])) { return $album->fields["clicks_date"]; } else { return $album->fields["last_mod_time"]; } } function removeUnprintable($string) { return preg_replace("/[^[:print:]]/", "", $string); } function albumFindable($db, $album) { global $gallery; if ($album->fields["marked"]) { /* Cyclic loop! */ return FALSE; } else { $album->fields["marked"] = TRUE; } if (! $gallery->user->canReadAlbum($album)) { return FALSE; } elseif ($album->isRoot()) { return TRUE; } else { $parentName = $album->fields["parentAlbumName"]; $parentAlbum = $db->getAlbumbyName($parentName); return albumFindable($db, $parentAlbum); } } function getThumbs($album) { $tags = "border=0 vspace=2 hspace=0 align=$align"; $photos = ""; $base = makeAlbumURL($album->fields["name"]); $photoCount = $album->numPhotos(1); for ($i = 1; $i <= $photoCount; $i += 1) { $photo = $album->getPhoto($i); if (!$photo->isHidden() && !$photo->isMovie() && $photo->thumbnail) { $path = $photo->image->getName($album->getPhotoPath($i)); $imgtag = $album->getThumbnailTag($i, 0, $tags); $photos .= "$imgtag\n"; } } return $photos; } function getThumbsAndCaptions($album) { $tags = "border=0 vspace=2 hspace=0 align=top"; $photos = ""; $base = makeAlbumURL($album->fields["name"]); $photoCount = $album->numPhotos(1); for ($i = 1; $i <= $photoCount; $i += 1) { $photo = $album->getPhoto($i); if (!$photo->isHidden() && !$photo->isMovie() && is_object($photo->thumbnail)) { # incredibly complicated way of saying PATH + FILENAME $path = $photo->image->getName($album->getPhotoPath($i)); $imgtag = $album->getThumbnailTag($i, 0, $tags); $caption = $photo->getCaption(); $photos .= "$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; $numAlbums = 0; $albumList = array(); if (method_exists($albumDB, "getCachedNumPhotos")) { $numPhotos = $albumDB->getCachedNumPhotos($gallery->user); } else { $numPhotos = $albumDB->numPhotos($gallery->user); } foreach ($albumDB->albumList as $album) { if ($onlyFindable) { if(! albumFindable($albumDB, $album)) { continue; } } else { if(! $gallery->user->canReadAlbum($album)) { continue; } } $numAlbums++; $albumInfo = array( "!name" => $album->fields["name"], "link" => makeAlbumUrl($album->fields["name"]), "guid" => makeAlbumUrl($album->fields["name"]), "!date" => bestDate($album), "title" => htmlspecialchars(removeUnprintable($album->fields["title"]))); # DATE TAGS $unixDate = $albumInfo["!date"]; if (IsSet($unixDate)) { $albumInfo["pubDate"] = date("r", $unixDate); if (! $noDCDate) { $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 (! $noPhotoTag) { 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 $base = $album->getAlbumDirURL("highlight"); $albumInfo["photo:imgsrc"] = $highlight->thumbnail->getPath($base); $albumInfo["photo:thumbnail"] = $highlight->getPhotoPath($base); $width = $highlight->thumbnail->width; $height = $highlight->thumbnail->height; if ($noBigPhoto) { if ($width > 144) { $width = 144; } if ($height > 400) { $height = 400; } } $albumInfo["pb:thumb"] = array($highlight->thumbnail->getPath($base), array(height => $height, width => $width)); } } # INSET HTML IMAGES if ($mode == "thumbs" || $mode == "mdm") { if (! $album->transient->photosloaded) { $album->load($album->fields["name"], TRUE); } $albumInfo["description"] = removeUnprintable($album->fields["description"]) . '

'; $albumInfo["description"] .= getThumbs($album); } elseif ($mode == "thumbs-with-captions") { if (! $album->transient->photosloaded) { $album->load($album->fields["name"], TRUE); } $albumInfo["description"] = removeUnprintable($album->fields["description"]) . '

'; $albumInfo["description"] .= getThumbsAndCaptions($album); } elseif ($mode == "highlight" && isset($highlight)) { $url = makeAlbumUrl($album->fields["name"]); $imgtag = $highlight->thumbnail->getTag($base, 0, 0, 'border=0'); $albumInfo["description"] = "$imgtag "; $albumInfo["description"] .= removeUnprintable($album->fields["description"]); } else { # mode = "basic" $albumInfo["description"] = removeUnprintable($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($highlightAlbum) && $highlightAlbum != "*") { foreach($albumList as $album) { if ($album["!name"] == $highlightAlbum && isset($album["pb:thumb"])) { $ha = $album; break; } } } elseif (isset($albumList[0]["pb:thumb"])) { $ha = $albumList[0]; } if (isset($ha)) { $channel_image = $ha["pb:thumb"][0]; $channel_image_width = $ha["pb:thumb"][1]["width"]; $channel_image_height = $ha["pb:thumb"][1]["height"]; } if (is_callable('pluralize_n')) { $total_str = pluralize_n($numAlbums, _("1 album"), _("albums"), _("no albums")); $image_str = pluralize_n($numPhotos, _("1 photo"), _("photos"), _("no photos")); } else { /* Probably older version of Gallery */ $total_str = pluralize($numAlbums, "album", "no"); $image_str = pluralize($numPhotos, "photo", "no"); } $description = sprintf(_("%s in %s"), $image_str, $total_str); @header("Content-Type: text/xml"); $xml_header = 'xml version="1.0"'; if($gallery->locale == 0) { $gallery->locale = 'ISO-8859-1'; } echo '<' . '?xml version="1.0" encoding="' . $gallery->locale . '"?' . '>'; ?> <?= htmlspecialchars($gallery->app->galleryTitle) ?> app->photoAlbumURL ?> app->default_language)) { ?> app->default_language) ?> app->adminEmail)) { ?> app->adminEmail ?> app->adminEmail ?> Gallery Generator v0.4, http://www.c7f.net/gal.php http://blogs.law.harvard.edu/tech/rss 40 <?= htmlspecialchars($gallery->app->galleryTitle) ?> app->photoAlbumURL ?> \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"; } ?>