session->albumName == "" && $gallery->app->gallery_slideshow_type == "off") { header("Location: albums.php"); return; } $albumName=$gallery->session->albumName; // default settings --- $defaultLoop = 0; $defaultTransition = 0; $defaultPause = 3; $full_option = false; if (empty($albumName)) { $album=NULL; $recursive=true; $number=(int)$gallery->app->gallery_slideshow_length; $random=($gallery->app->gallery_slideshow_type == "random"); $loop=($gallery->app->gallery_slideshow_loop == "yes"); $borderColor = $gallery->app->default["bordercolor"]; $borderwidth = 1; } else { $album = new Album(); $album->load($albumName); if ($album->fields["slideshow_type"] == "off") { header("Location: " . makeAlbumUrl($gallery->session->albumName)); return; } $recursive=($album->fields["slideshow_recursive"] == "yes"); $loop=($album->fields["slideshow_loop"] == "yes"); $random=($album->fields["slideshow_type"] == "random"); $number=(int)$album->fields["slideshow_length"]; $borderColor = $gallery->album->fields["bordercolor"]; $borderwidth = $gallery->album->fields["border"]; if (!strcmp($borderwidth, "off")) { $borderwidth = 1; } $bgcolor = $gallery->album->fields['bgcolor']; } define('PHOTO_URL', 1 << 0); define('PHOTO_CAPTION', 1 << 1); define('PHOTO_URL_AS_HREF', 1 << 2); define('PHOTO_ALL', (1<<16)-1); // all bits set function buildSlideshowPhotos(&$full_urls, &$urls, &$captions, $album=NULL, $recursive=true) { global $gallery, $full_option; $photo_count=0; if (!$album) { // Top level $albumDB = new AlbumDB(false); $numAlbums = $albumDB->numAlbums($gallery->user); for ($i=1; $i <= $numAlbums; $i++) { $subAlbum= $albumDB->getAlbum($gallery->user, $i); if (!$gallery->user->canReadAlbum($subAlbum)) { continue; } $photo_count+=buildSlideshowPhotos($full_urls, $urls, $captions, $subAlbum, $recursive); } return $photo_count; } if (!$gallery->user->canReadAlbum($album)) { return $photo_count; } $numPhotos = $album->numPhotos(1); $numDisplayed = 0; // Find the correct starting point, accounting for hidden photos $index = getNextPhoto(0,$album); $photo_count = 0; while ($numDisplayed < $numPhotos) { if ($index > $numPhotos) { /* * We went past the end -- this can happen if the last element is * an album that we can't read. */ break; } $photo = $album->getPhoto($index); $numDisplayed++; // Skip movies, pdfs and docs and nested albums if ($photo->isMovie() || $photo->isPdf() || $photo->isDoc() || $photo->isAlbumName) { $index = getNextPhoto($index,$album); continue; } if ($photo->isAlbumName ) { if ($recursive) { $subAlbumName = $album->isAlbumName($index); $subAlbum = new Album(); $subAlbum->load($subAlbumName); if ($gallery->user->canReadAlbum($subAlbum)) { $photo_count+=buildSlideshowPhotos($full_urls, $urls, $captions, $subAlbum, $recursive); } } $index = getNextPhoto($index, $album); continue; } $photo_count++; $urls[] = $album->getPhotoPath($index, 0); if ($gallery->user->canViewFullImages($album)) { $full_option = true; $full_urls[] = $album->getPhotoPath($index, 1); } else { $full_urls[] = $album->getPhotoPath($index, 0); } $caption = $album->getCaption($index); if ($recursive) { $caption .= ' (' . $album->fields['title'] . ')'; } $caption .= $album->getCaptionName($index); $caption = str_replace("\"", " ", $caption); $caption = str_replace("\n", " ", $caption); $caption = str_replace("\r", " ", $caption); // Print out the entry for this image as Javascript $captions[] = $caption; // Go to the next photo $index = getNextPhoto($index,$album); } return $photo_count; } function printSlideshowPhotos($full_urls, $urls, $captions, $what, $photo_count) { $count=0; for ($index=0; $index<$photo_count; $index++) { $count++; if ( ($what & PHOTO_URL) != 0 ) { print "photo_urls[$count] = \"".$urls[$index]."\";\n"; } if ( ($what & PHOTO_URL_AS_HREF) != 0 ) { print "\n"; print "\n"; } if ( ($what & PHOTO_CAPTION) != 0 ) { // Print out the entry for this image as Javascript print "photo_captions[$count] = \"".$captions[$index]."\";\n"; } } } ?> 0) { if ($number == 0 || $number > $photo_count) { $number=$photo_count; } if ($random) { $random_full_urls=array(); $random_photos=array(); srand ((float) microtime() * 10000000); $rand_keys = array_rand ($urls, $number); if ($number == 1) { $rand_keys=array($rand_keys); } foreach ($rand_keys as $key) { $random_urls[] = $urls[$key]; $random_full_urls[] = $full_urls[$key]; $random_captions[] = $captions[$key]; } $urls=$random_urls; $full_urls=$random_full_urls; $captions=$random_captions; } if (empty($albumName)) { if ($random) { $title = sprintf(_("%s Random Images from %s"), $number, $gallery->app->galleryTitle); } else { $title = sprintf(_("Slide Show for Gallery :: %s"), $gallery->app->galleryTitle); } } else { if ($random) { $title = sprintf(_("%d Random Images from album :: %s"), $number, $gallery->album->fields["title"] ); } else { $title = sprintf(_("Slide Show for album :: %s"), $gallery->album->fields["title"] ); } } }?>