Пример #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);
     }
 }
Пример #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;
 }