/* Gallery Recent Albums v0.9 for Gallery v1.3.2
Copyright (c) 2002 Lucas Nealan
Recent Albums: http://brainkrash.com/
Gallery: http://gallery.sourceforge.net/
Contains portions of code from Gallery
Copyright (C) 2000-2002 Bharat Mediratta
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*****************************************************
INSTALLATION
*****************************************************
1. Place recent_albums.php in gallery base directory.
2. Add links to recent_albums.php from albums.php (add to appropriate location
where adminCommands are defined: $adminCommands .= '
// 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;
}
require_once(dirname(__FILE__) . '/init.php');
$frame=$gallery->html_wrap['frame'];
// Cache for speed. Requires lwp-request, a Perl libwww utility.
//
// cron (update every 15 minutes):
//
// */15 * * * * root /path/to/gallery/cache_recent_albums > /dev/null
//
// cache script /path/to/gallery/cache_recent_albums:
//
// #!/bin/sh
// lwp-request http://brainkrash.com/photo/recent_albums.php?cache=1 > /usr/local/www/v2/photo/cache.recent_albums.tmp
// mv -f /usr/local/www/v2/photo/cache.recent_albums.tmp /usr/local/www/v2/photo/cache.recent_albums
//
?>
if (! $gallery->user->isLoggedIn() && ! $cache && ! $set_recentListPage) {
if (file_exists('cache.recent_albums'))
{
includeHtmlWrap("wrapper.header");
include('cache.recent_albums'); // not logged in
includeHtmlWrap("wrapper.footer");
includeHtmlWrap("../html/footer.inc");
exit;
}
}
/* Read the album list */
$albumDB = new AlbumDB();
$gallery->session->albumName = "";
$recent_albums =& get_recent(0, count($albumDB->albumList));
function get_recent($start, $finish)
{
global $gallery, $albumDB;
$recent_albums = array();
for ($i = $start; $i < $finish; $i++)
{
$gallery->album =& $albumDB->albumList[$i];
if (! $gallery->album->isRoot())
{
for ($j = 1; $j < $gallery->album->numPhotos(); $j++)
{
$isNested = $gallery->album->isAlbum($j);
if (! $isNested)
break;
}
$hasPhotos = ($j != $gallery->album->numPhotos());
}
if (is_nightlife($gallery->album) && $gallery->user->canReadAlbum($gallery->album) && !$gallery->album->isRoot() && $hasPhotos && $gallery->album->numPhotos())
{ //hack last_mod_time
$recent_albums[($gallery->album->fields["clicks_date"]+$i)] =& $gallery->album;
// wish for a database
}
}
krsort($recent_albums, SORT_NUMERIC); // decending sort by date
$i = 1;
$ret = array();
foreach($recent_albums as $album)
{
$ret[$i] = $album;
$i++;
}
return($ret);
}
function is_nightlife($album)
{
global $albumDB;
$parentIsNightlife = false;
while($parentName = $album->fields['parentAlbumName'])
{
$album = $albumDB->getAlbumbyName($parentName);
if (!strcmp($album->fields["name"], "nightlife"))
{
$parentIsNightlife = true;
}
}
return($parentIsNightlife);
}
function get_crumbs($album)
{
global $albumDB;
while($parentName = $album->fields['parentAlbumName'])
{
$album = $albumDB->getAlbumbyName($parentName);
$url = makeAlbumUrl($album->fields["name"]);
$trail = "".$album->fields['title'].'::'.$trail;
}
return($trail);
}
// DISPLAY
$numAlbums = count($recent_albums);
if ($set_recentListPage)
$gallery->session->recentListPage = $set_recentListPage;
if (!$gallery->session->recentListPage) {
$gallery->session->recentListPage = 1;
}
$perPage = $gallery->app->albumsPerPage;
$maxPages = max(ceil($numAlbums / $perPage), 1);
if ($gallery->session->recentListPage > $maxPages) {
$gallery->session->recentListPage = $maxPages;
}
$pixelImage = "
";
$navigator["page"] = $gallery->session->recentListPage;
$navigator["pageVar"] = "set_recentListPage";
$navigator["url"] = makeGalleryUrl("recent_albums.php");
$navigator["maxPages"] = $maxPages;
$navigator["spread"] = 6;
$navigator["fullWidth"] = 100;
$navigator["widthUnits"] = "%";
$navigator["bordercolor"] = $borderColor;
?>
if (!$GALLERY_EMBEDDED_INSIDE) { ?>