$albumidlist .= ' OR ';
             $albumids .= ' OR ';
         }
         $albumidlist .= prefix('images') . '.albumid=' . $ID;
         $albumids .= '`id`=' . $ID;
         $i++;
     }
     if (!empty($albumlist)) {
         $albumids = ' AND (' . $albumids . ')';
         $albumidlist = ' AND (' . $albumidlist . ')';
     }
 }
 if (isset($_GET['propagate_unpublished'])) {
     foreach ($albumlist as $albumname) {
         $album = new Album($gallery, $albumname);
         if (!$album->getShow()) {
             unpublishSubalbums($album);
         }
     }
 }
 $mtime = dateTimeConvert($requestdate, true);
 $sql = "SELECT `folder`, `id` FROM " . prefix('albums') . ' WHERE `show`="0"' . $albumids;
 $result = query_full_array($sql);
 if (is_array($result)) {
     foreach ($result as $row) {
         $publish_albums_list[$row['folder']] = $row['id'];
     }
 }
 $sql = 'SELECT `filename`, ' . prefix('images') . '.id as id, folder FROM ' . prefix('images') . ',' . prefix('albums') . ' WHERE ' . prefix('images') . '.show="0" AND ' . prefix('images') . '.mtime < "' . $mtime . '" AND ' . prefix('albums') . '.id=' . prefix('images') . '.albumid' . $albumidlist;
 $result = query_full_array($sql);
 if (is_array($result)) {
/**
 *
 * Enter description here ...
 * @param object $obj the starting point
 * @param array $albumlist the container for the results
 * @param string $gateway name of validation function
 */
function getSitemapAlbumList($obj, &$albumlist, $gateway)
{
    global $_zp_gallery;
    $locallist = $obj->getAlbums();
    foreach ($locallist as $folder) {
        $album = new Album($_zp_gallery, $folder);
        if ($album->getShow() && $gateway($album)) {
            $albumlist[] = array('folder' => $album->name, 'date' => $album->getDateTime(), 'title' => $album->getTitle());
            getSitemapAlbumList($album, $albumlist, $gateway);
        }
    }
}
Example #3
0
 /**
  * Gets the album's set thumbnail image from the database if one exists,
  * otherwise, finds the first image in the album or sub-album and returns it
  * as an Image object.
  *
  * @return Image
  */
 function getAlbumThumbImage()
 {
     if (!is_null($this->albumthumbnail)) {
         return $this->albumthumbnail;
     }
     $albumdir = $this->localpath;
     $thumb = $this->get('thumb');
     $i = strpos($thumb, '/');
     if ($root = $i === 0) {
         $thumb = substr($thumb, 1);
         // strip off the slash
         $albumdir = ALBUM_FOLDER_SERVERPATH;
     }
     $shuffle = empty($thumb);
     $field = getOption('AlbumThumbSelectField');
     $direction = getOption('AlbumThumbSelectDirection');
     if (!empty($thumb) && !is_numeric($thumb) && file_exists($albumdir . internalToFilesystem($thumb))) {
         if ($i === false) {
             return newImage($this, $thumb);
         } else {
             $pieces = explode('/', $thumb);
             $i = count($pieces);
             $thumb = $pieces[$i - 1];
             unset($pieces[$i - 1]);
             $albumdir = implode('/', $pieces);
             if (!$root) {
                 $albumdir = $this->name . "/" . $albumdir;
             } else {
                 $albumdir = $albumdir . "/";
             }
             $this->albumthumbnail = newImage(new Album($this->gallery, $albumdir), $thumb);
             return $this->albumthumbnail;
         }
     } else {
         $this->getImages(0, 0, $field, $direction);
         $thumbs = $this->images;
         if (!is_null($thumbs)) {
             if ($shuffle) {
                 shuffle($thumbs);
             }
             $mine = $this->isMyItem(LIST_RIGHTS);
             $other = NULL;
             while (count($thumbs) > 0) {
                 // first check for images
                 $thumb = array_shift($thumbs);
                 $thumb = newImage($this, $thumb);
                 if ($mine || $thumb->getShow()) {
                     if (isImagePhoto($thumb)) {
                         // legitimate image
                         $this->albumthumbnail = $thumb;
                         return $this->albumthumbnail;
                     } else {
                         if (!is_null($thumb->objectsThumb)) {
                             //	"other" image with a thumb sidecar
                             $this->albumthumbnail = $thumb;
                             return $this->albumthumbnail;
                         } else {
                             if (is_null($other)) {
                                 $other = $thumb;
                             }
                         }
                     }
                 }
             }
             if (!is_null($other)) {
                 //	"other" image, default thumb
                 $this->albumthumbnail = $other;
                 return $this->albumthumbnail;
             }
         }
     }
     // Otherwise, look in sub-albums.
     $subalbums = $this->getAlbums();
     if (!is_null($subalbums)) {
         if ($shuffle) {
             shuffle($subalbums);
         }
         while (count($subalbums) > 0) {
             $folder = array_pop($subalbums);
             $subalbum = new Album($this->gallery, $folder);
             $pwd = $subalbum->getPassword();
             if ($subalbum->getShow() && empty($pwd) || $subalbum->isMyItem(LIST_RIGHTS)) {
                 $thumb = $subalbum->getAlbumThumbImage();
                 if (strtolower(get_class($thumb)) !== 'transientimage' && $thumb->exists) {
                     $this->albumthumbnail = $thumb;
                     return $thumb;
                 }
             }
         }
     }
     $nullimage = SERVERPATH . '/' . ZENFOLDER . '/images/imageDefault.png';
     if (OFFSET_PATH == 0) {
         // check for theme imageDefault.png if we are in the gallery
         $theme = '';
         $uralbum = getUralbum($this);
         $albumtheme = $uralbum->getAlbumTheme();
         if (!empty($albumtheme)) {
             $theme = $albumtheme;
         } else {
             $theme = $this->gallery->getCurrentTheme();
         }
         if (!empty($theme)) {
             $themeimage = SERVERPATH . '/' . THEMEFOLDER . '/' . $theme . '/images/imageDefault.png';
             if (file_exists(internalToFilesystem($themeimage))) {
                 $nullimage = $themeimage;
             }
         }
     }
     $this->albumthumbnail = new transientimage($this, $nullimage);
     return $this->albumthumbnail;
 }
 /**
  * Gets the album's set thumbnail image from the database if one exists,
  * otherwise, finds the first image in the album or sub-album and returns it
  * as an Image object.
  *
  * @return Image
  */
 function getAlbumThumbImage()
 {
     if (!is_null($this->albumthumbnail)) {
         return $this->albumthumbnail;
     }
     $albumdir = $this->localpath;
     $thumb = $this->get('thumb');
     $i = strpos($thumb, '/');
     if ($root = $i === 0) {
         $thumb = substr($thumb, 1);
         // strip off the slash
         $albumdir = getAlbumFolder();
     }
     $shuffle = $thumb != '1';
     if (!empty($thumb) && $thumb != '1' && file_exists($albumdir . UTF8ToFilesystem($thumb))) {
         if ($i === false) {
             return newImage($this, $thumb);
         } else {
             $pieces = explode('/', $thumb);
             $i = count($pieces);
             $thumb = $pieces[$i - 1];
             unset($pieces[$i - 1]);
             $albumdir = implode('/', $pieces);
             if (!$root) {
                 $albumdir = $this->name . "/" . $albumdir;
             } else {
                 $albumdir = $albumdir . "/";
             }
             $this->albumthumbnail = newImage(new Album($this->gallery, $albumdir), $thumb);
             return $this->albumthumbnail;
         }
     } else {
         if ($this->isDynamic()) {
             $this->getImages(0, 0, 'ID', 'DESC');
             $thumbs = $this->images;
             if (!is_null($thumbs)) {
                 if ($shuffle) {
                     shuffle($thumbs);
                 }
                 while (count($thumbs) > 0) {
                     $thumb = array_shift($thumbs);
                     if (is_valid_image($thumb['filename'])) {
                         $alb = new Album($this->gallery, $thumb['folder']);
                         $thumb = newImage($alb, $thumb['filename']);
                         if ($thumb->getShow()) {
                             $this->albumthumbnail = $thumb;
                             return $thumb;
                         }
                     }
                 }
             }
         } else {
             $this->getImages(0, 0, 'ID', 'DESC');
             $thumbs = $this->images;
             if (!is_null($thumbs)) {
                 if ($shuffle) {
                     shuffle($thumbs);
                 }
                 while (count($thumbs) > 0) {
                     $thumb = array_shift($thumbs);
                     if (is_valid_image($thumb)) {
                         $thumb = newImage($this, $thumb);
                         if ($thumb->getShow()) {
                             $this->albumthumbnail = $thumb;
                             return $thumb;
                         }
                     }
                 }
             }
             // Otherwise, look in sub-albums.
             $subalbums = $this->getSubAlbums();
             if (!is_null($subalbums)) {
                 if ($shuffle) {
                     shuffle($subalbums);
                 }
                 while (count($subalbums) > 0) {
                     $folder = array_pop($subalbums);
                     $subalbum = new Album($this->gallery, $folder);
                     $pwd = $subalbum->getPassword();
                     if ($subalbum->getShow() && empty($pwd) || isMyALbum($folder, ALL_RIGHTS)) {
                         $thumb = $subalbum->getAlbumThumbImage();
                         if (strtolower(get_class($thumb)) !== 'transientimage' && $thumb->exists) {
                             $this->albumthumbnail = $thumb;
                             return $thumb;
                         }
                     }
                 }
             }
             //jordi-kun - no images, no subalbums, check for videos
             $dp = opendir($albumdir);
             while ($thumb = readdir($dp)) {
                 if (is_file($albumdir . $thumb) && is_valid_video($thumb)) {
                     $othersThumb = checkObjectsThumb($albumdir, $thumb);
                     if (!empty($othersThumb)) {
                         $thumb = newImage($this, $othersThumb);
                         if ($this->getShow()) {
                             $this->albumthumbnail = $thumb;
                             return $thumb;
                         }
                     }
                 }
             }
         }
     }
     $nullimage = SERVERPATH . '/' . ZENFOLDER . '/images/imageDefault.png';
     if (OFFSET_PATH == 0) {
         // check for theme imageDefault.png if we are in the gallery
         $theme = '';
         $uralbum = getUralbum($this);
         $albumtheme = $uralbum->getAlbumTheme();
         if (!empty($albumtheme)) {
             $theme = $albumtheme;
         } else {
             $theme = $this->gallery->getCurrentTheme();
         }
         if (!empty($theme)) {
             $themeimage = SERVERPATH . '/' . THEMEFOLDER . '/' . $theme . '/images/imageDefault.png';
             if (file_exists(UTF8ToFilesystem($themeimage))) {
                 $nullimage = $themeimage;
             }
         }
     }
     $this->albumthumbnail = new transientimage($this, $nullimage);
     return $this->albumthumbnail;
 }