0byt3m1n1
Path:
/
data
/
applications
/
aps
/
gallery
/
2.2-08
/
htdocs
/
modules
/
panorama
/
classes
/
[
Home
]
File: PanoramaHelper.class
<?php /* * Gallery - a web based photo album viewer and editor * Copyright (C) 2000-2007 Bharat Mediratta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ /** * A helper class for the Panorama module. * @package Panorama * @subpackage Classes * @author Alan Harder <alan.harder@sun.com> * @version $Revision: 15513 $ * @static */ class PanoramaHelper { /** * Fetch largest viewable images for use in a panorama * * @param array $items of GalleryDataItem * @return array GalleryStatus a status code * array of given-itemId=>GalleryDataItem-for-display */ function fetchViewableImages($items) { global $gallery; foreach ($items as $item) { if (GalleryUtilities::isA($item, 'GalleryPhotoItem')) { $ids[] = $item->getId(); } } if (!isset($ids)) { return array(null, array()); } list ($ret, $preferredFullImages) = GalleryCoreApi::fetchPreferredsByItemIds($ids); if ($ret) { return array($ret, null); } list ($ret, $resizedImages) = GalleryCoreApi::fetchResizesByItemIds($ids); if ($ret) { return array($ret, null); } $ret = GalleryCoreApi::studyPermissions($ids); if ($ret) { return array($ret, null); } $data = array(); foreach ($items as $item) { $id = $item->getId(); if (!in_array($id, $ids)) { continue; } list ($ret, $permissions) = GalleryCoreApi::getPermissions($id); if ($ret) { return array($ret, null); } if (isset($permissions['core.viewSource'])) { /* Full size; check for preferred copy */ if (isset($preferredFullImages[$id])) { $data[$id] = $preferredFullImages[$id]; } else { $data[$id] = $item; } } else if (isset($permissions['core.viewResizes']) && isset($resizedImages[$id])) { $max = -1; foreach ($resizedImages[$id] as $resize) { $size = $resize->getWidth() + $resize->getHeight(); if ($size > $max) { $data[$id] = $resize; } } } } return array(null, $data); } } ?>