Example #1
0
 /**
  * Fetches gallery info for the specified gallery and immediate children.
  */
 function get_gallery($gallery_name, $getChildGalleries = 1)
 {
     $gal = new gallery($gallery_name);
     //if fail then try to open generic metadata
     $fp = @fopen($this->config->base_path . $this->config->pathto_galleries . $gallery_name . "/metadata.csv", "r");
     if ($fp) {
         while ($temp[] = fgetcsv($fp, 2048)) {
         }
         fclose($fp);
         list($gal->filename, $gal->name, $gal->desc, $gal->long_desc, $gal->date) = $temp[1];
         for ($i = 0; $i < count($temp) - 3; $i++) {
             $gal->images[$i] = new image();
             list($gal->images[$i]->filename, $gal->images[$i]->name, $gal->images[$i]->desc, $gal->images[$i]->long_desc, $gal->images[$i]->date, $gal->images[$i]->sort) = $temp[$i + 2];
             $gal->images[$i]->full_path = $gal->name . "/" . $gal->images[$i]->filename;
             //get image size and type
             list($gal->images[$i]->width, $gal->images[$i]->height, $gal->images[$i]->type) = substr($gal->images[$i]->filename, 0, 7) == "http://" ? @GetImageSize($gal->images[$i]->filename) : @GetImageSize($this->config->base_path . $this->config->pathto_galleries . $gal->id . "/" . $gal->images[$i]->filename);
         }
         //discover child galleries
         $dir = photostack::get_listing($this->config->base_path . $this->config->pathto_galleries . $gallery_name . "/", "dirs");
         if ($getChildGalleries) {
             //but only fetch their info if required too
             foreach ($dir->dirs as $gallery) {
                 $gal->galleries[] = $this->get_gallery($gallery_name . "/" . $gallery, $getChildGalleries);
             }
         } else {
             //otherwise just copy their names in so they can be counted
             $gal->galleries = $dir->dirs;
         }
         return $gal;
     } else {
         return parent::get_gallery($gallery_name, $getChildGalleries);
     }
 }
Example #2
0
 function getGallery($galleryId, $getChildGalleries = 1)
 {
     $gal =& new gallery($galleryId, $parent);
     //try to open language specific gallery info
     $res = $this->query("SELECT * FROM " . $this->config->sql_prefix . "galleries " . "WHERE galleryid='" . $this->escape_string($galleryId) . "' " . "AND lang='" . $this->escape_string($language) . "'");
     //if fail then try to open generic gallery info
     if (!$res || !$this->num_rows($res)) {
         $res = $this->query("SELECT * FROM " . $this->config->sql_prefix . "galleries " . "WHERE galleryid='" . $this->escape_string($galleryId) . "' and lang=''");
     }
     //if that succeeds then get galleries from db
     if ($res && $this->num_rows($res)) {
         $galinfo = $this->fetch_array($res);
         $gal->filename = $galinfo['filename'];
         $gal->name = $galinfo['name'];
         $gal->desc = $galinfo['description'];
         $gal->date = $galinfo['date'];
         //try to open language specific image info
         $res = $this->query("SELECT * FROM " . $this->config->sql_prefix . "images " . "WHERE galleryid='" . $this->escape_string($galleryId) . "' ");
         //if fail then try to open generic image info
         if (!$res || !$this->num_rows($res)) {
             $res = $this->query("SELECT * FROM " . $this->config->sql_prefix . "images " . "WHERE galleryid='" . $this->escape_string($galleryId) . "'");
         }
         for ($i = 0; $i < $this->num_rows($res); $i++) {
             $imginfo = $this->fetch_array($res);
             $gal->images[$i] =& new image($imginfo['filename'], $gal);
             $gal->images[$i]->thumbnail = $imginfo['thumbnail'];
             $gal->images[$i]->name = $imginfo['name'];
             $gal->images[$i]->desc = $imginfo['description'];
             $gal->images[$i]->date = $imginfo['date'];
         }
     } else {
         //no record found so use iifn method implemented in parent class
         return parent::get_gallery($galleryId, $parent, $getChildGalleries, $language);
     }
     //discover child galleries
     $dir = photostack::get_listing($this->config->base_path . $this->config->pathto_galleries . $galleryId . "/");
     if ($getChildGalleries) {
         //but only fetch their info if required too
         foreach ($dir->dirs as $gallery) {
             $gal->galleries[] =& $this->get_gallery($galleryId . "/" . $gallery, $gal, $getChildGalleries - 1, $language);
         }
     } else {
         //otherwise just copy their names in so they can be counted
         $gal->galleries = $dir->dirs;
     }
     return $gal;
 }
Example #3
0
 /**
  * Fetches gallery info for the specified gallery (and immediate children).
  * @param string  gallery id
  * @param string  language code spec for this request (optional, ignored)
  * @param int     number of levels of child galleries to fetch (optional)
  */
 function get_gallery($gallery_name, $getChildGalleries = 1)
 {
     $gal = new gallery($gallery_name);
     if (file_exists($this->config->base_path . $this->config->pathto_galleries . $gallery_name)) {
         $bits = explode("/", $gal->id);
         $temp = strtr($bits[count($bits) - 1], "_", " ");
         if ($temp == ".") {
             $gal->name = $this->config->gallery_name;
         } elseif (strpos($temp, " - ")) {
             list($gal->artist, $gal->name) = explode(" - ", $temp);
         } else {
             $gal->name = $temp;
         }
         $dir = photostack::get_listing($this->config->base_path . $this->config->pathto_galleries . $gal->id . "/", "images");
         //set gallery thumbnail to first image in gallery (if any)
         if (isset($dir->files[0])) {
             $gal->filename = $dir->files[0];
         }
         for ($i = 0; $i < count($dir->files); $i++) {
             $gal->images[$i] = new image();
             $gal->images[$i]->filename = $dir->files[$i];
             $gal->images[$i]->full_path = $gal->name . "/" . $dir->files[$i];
             //trim off file extension and replace underscores with spaces
             $temp = strtr(substr($gal->images[$i]->filename, 0, strrpos($gal->images[$i]->filename, ".") - strlen($gal->images[$i]->filename)), "_", " ");
             //split string in two on " - " delimiter
             $gal->images[$i]->name = $temp;
             //get image size and type
             list($gal->images[$i]->width, $gal->images[$i]->height, $gal->images[$i]->type) = @GetImageSize($this->config->base_path . $this->config->pathto_galleries . $gal->id . "/" . $gal->images[$i]->filename);
         }
     } else {
         //selected gallery does not exist
         return null;
     }
     //discover child galleries
     $dir = photostack::get_listing($this->config->base_path . $this->config->pathto_galleries . $gallery_name . "/", "dirs");
     if ($getChildGalleries) {
         //but only fetch their info if required too
         foreach ($dir->dirs as $gallery) {
             $gal->galleries[] = $this->get_gallery($gallery_name . "/" . $gallery, $getChildGalleries - 1);
         }
     } else {
         //otherwise just copy their names in so they can be counted
         $gal->galleries = $dir->dirs;
     }
     return $gal;
 }
Example #4
0
<?php

# include main class
require_once "includes/photostack.class.php";
# create a wrapper
$ps = new photostack();
#Start Cache
$ps->cache_start();
#include the template.
include $ps->template();
# End Cache
$ps->cache_end();