/** * creates a transient image (that is, one that is not stored in the database) * * @param object $gallery * @param string $image the full path to the image * @return transientimage */ function Transientimage(&$album, $image) { if (!is_object($album)) { return NULL; } $this->album = $album; $this->localpath = $image; $filename = makeSpecialImageName($image); $this->filename = $filename; $this->displayname = substr(basename($image), 0, strrpos(basename($image), '.')); if (empty($this->displayname)) { $this->displayname = $this->filename; } $this->filemtime = filemtime($this->localpath); $this->comments = null; if (is_valid_video($filename)) { $this->video = true; } parent::PersistentObject('images', array('filename' => $filename, 'albumid' => $this->album->id), 'filename', false, true); }
/** * 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; }
/** * Returns the url to original image. * It will return a protected image is the option "protect_full_image" is set * * @return string */ function getFullImageURL() { global $_zp_current_image; if (is_null($_zp_current_image)) { return false; } $outcome = getOption('protect_full_image'); if ($outcome == 'No access') { return null; } $url = getUnprotectedImageURL(); if (is_valid_video($url)) { // Download, Protected View, and Unprotected access all allowed $album = $_zp_current_image->getAlbum(); $folder = $album->getFolder(); $original = checkVideoOriginal(getAlbumFolder() . $folder, $_zp_current_image->getFileName()); if ($original) { return getAlbumFolder(WEBPATH) . $folder . "/" . $original; } else { return $url; } } else { // normal image if ($outcome == 'Unprotected') { return $url; } else { return getProtectedImageURL(); } } }