We've seen this several times now and we still can't figure out what it is...
` <div id="gallerytitle">
<h2><span><a href="`
Is all that's printed for the album.php page, indicating the problem traces back to the `<?php echo getGalleryIndexURL();?>` call, which is the strangest thing... Let's look at all code that's called with that one call, shall we? I'm going to nail this bugger once and for all....
So, let's backtrace.
album.php:16 `getGalleryIndexURL();`
> template-functions.php:77
`function getGalleryIndexURL() {
global $_zp_current_album;
if (in_context(ZP_ALBUM) && $_zp_current_album->getGalleryPage() > 1) {
$page = $_zp_current_album->getGalleryPage();
return rewrite_path("/page/" . $page, "/index.php?page=" . $page);
} else {
return WEBPATH . "/";
}
}`
> class-album.php:279
`function getGalleryPage() {
$albums_per_page = zp_conf('albums_per_page');
if ($this->index == null)
$this->index = array_search($this->name, $this->gallery->getAlbums(0));
return floor(($this->index / $albums_per_page)+1);
}`
> class-gallery:36
` function getAlbums($page=0) {
// Have the albums been loaded yet?
if (is_null($this->albums)) {
$albumnames = $this->loadAlbumNames();
$albums = $this->sortAlbumArray($albumnames);
$this->albums = $albums;
}
if ($page == 0) {
return $this->albums;
} else {
$albums_per_page = zp_conf('albums_per_page');
return array_slice($this->albums, $albums_per_page*($page-1), $albums_per_page);
}
}`
> class-gallery.php:107
` function loadAlbumNames() {
$albumdir = $this->getAlbumDir();
if (!is_dir($albumdir) || !is_readable($albumdir)) {
die("Error: The 'albums' directory cannot be found or is not readable.");
}
$dir = opendir($albumdir);
$albums = array();
while ($dirname = readdir($dir)) {
if (is_dir($albumdir.$dirname) && substr($dirname, 0, 1) != '.') {
$albums[] = $dirname;
}
}
closedir($dir);
return $albums;
}`
> class-gallery.php:67
` function sortAlbumArray($albums) {
$albums_r = array();
$result = query("SELECT folder, sort_order FROM " . prefix("albums")
. " ORDER BY sort_order");
$i = 0;
$albums_r = array_flip($albums);
$albums_touched = array();
while ($row = mysql_fetch_assoc($result)) {
$folder = $row['folder'];
if (array_key_exists($folder, $albums_r)) {
$albums_r[$folder] = $i;
$albums_touched[] = $folder;
}
$i++;
}
$albums_untouched = array_diff($albums, $albums_touched);
foreach($albums_untouched as $alb) {
$albums_r[$alb] = $i;
$i++;
}
$albums = array_flip($albums_r);
ksort($albums);
$albums_ordered = array();
foreach($albums as $album) {
$albums_ordered[] = $album;
}
return $albums_ordered;
}`
Whew. That's all the meaningful code that gets executed with that one call... crazy. I'm posting this, then I'm going to look through it for possible problems.