public function setPath($path) { // Require readable dir and existing (and readable) info file if (self::isFolderReadable($path) && self::isInfoFileReadable($path)) { $this->path = $path; $this->mtime = filemtime($path); $this->foldername = getFolderNameFromPath($this->path); $this->safename = getUrlSafeString(getFolderNameFromPath($this->path)); if ($this->mtime > self::$latestUpdate) { self::$latestUpdate = $this->mtime; } $this->parseInfoFile(); $this->scanFiles(); } }
public function renderGallery() { global $siteWebRoot, $useNiceUrls, $galleryTitle, $galleryDescription, $galleryKeywords, $galleryDate, $galleryRowTemplate, $galleryIndexLink, $olderGalleryLink, $olderGalleryTitle, $newerGalleryLink, $newerGalleryTitle; $newerGalleryLink = null; $olderGalleryLink = null; $newerGalleryTitle = null; $olderGalleryTitle = null; $galleryIndexLink = $useNiceUrls ? sprintf("%s/index/", $siteWebRoot) : sprintf("%s?index=", $siteWebRoot); $galleryId = getRequestVar('galleryID'); if (is_null($galleryId) || empty($galleryId)) { forwardTo($galleryIndexLink); } ob_start(); $keys = array_keys($this->gallerydata); for ($i = 0; $i < count($keys); $i++) { $gallery = $this->gallerydata[$keys[$i]]; if ($gallery->safename == $galleryId) { $galleryTitle = $gallery->title; $galleryDescription = $gallery->description; $galleryKeywords = $gallery->keywords; $galleryDate = $gallery->date; $galleryPath = sprintf('%s/assets/galleries/%s', $siteWebRoot, $gallery->foldername); foreach ($gallery->files as $image) { $row = $galleryRowTemplate; $row = str_replace('IMGSRC', sprintf("%s/%s", $galleryPath, $image), $row); $row = str_replace('ALTTXT', '', $row); $row = str_replace('IMGID', getUrlSafeString(substr($image, 0, strrpos($image, "."))), $row); print $row; } for ($j = $i - 1; $j >= 0; $j--) { $newerGallery = $this->gallerydata[$keys[$j]]; if (is_null($newerGallery->hidden)) { $newerGalleryTitle = $newerGallery->title; $newerGalleryLink = $useNiceUrls ? sprintf('%s/gallery/%s', $siteWebRoot, $newerGallery->safename) : sprintf('%s/?galleryID=%s', $siteWebRoot, $newerGallery->safename); break; } } for ($j = $i + 1; $j < count($keys); $j++) { $olderGallery = $this->gallerydata[$keys[$j]]; if (is_null($olderGallery->hidden)) { $olderGalleryTitle = $olderGallery->title; $olderGalleryLink = $useNiceUrls ? sprintf('%s/gallery/%s', $siteWebRoot, $olderGallery->safename) : sprintf('%s/?galleryID=%s', $siteWebRoot, $olderGallery->safename); break; } } break; } } $this->output = ob_get_clean(); }