Ejemplo n.º 1
0
<?php

/**
 * @package fisheye
 * @subpackage functions
 */
global $gContent;
$lookup = array();
if (!($gContent = FisheyeGallery::lookup($_REQUEST))) {
    $gContent = new FisheyeGallery();
    $galleryId = NULL;
}
if (!empty($_REQUEST['gallery_path'])) {
    $gContent->setGalleryPath($_REQUEST['gallery_path']);
} elseif ($gContent->isValid() && ($parents = $gContent->getParentGalleries())) {
    $gal = current($parents);
    $gContent->setGalleryPath('/' . $gal['gallery_id']);
}
$gBitSmarty->assignByRef('gContent', $gContent);
$gBitSmarty->assignByRef('galleryId', $gContent->mGalleryId);
Ejemplo n.º 2
0
global $gContent, $gGallery;
if ($gContent = FisheyeImage::lookup($_REQUEST)) {
    // nothing to do. ::lookup will do a full load
} else {
    $gContent = new FisheyeImage();
    $imageId = NULL;
}
if (!empty($_REQUEST['gallery_path'])) {
    $_REQUEST['gallery_path'] = rtrim($_REQUEST['gallery_path'], '/');
    $gContent->setGalleryPath($_REQUEST['gallery_path']);
    $matches = array();
    $tail = strrpos($_REQUEST['gallery_path'], '/');
    $_REQUEST['gallery_id'] = substr($_REQUEST['gallery_path'], $tail + 1);
}
if (empty($_REQUEST['gallery_id'])) {
    if ($parents = $gContent->getParentGalleries()) {
        $gal = current($parents);
        $gContent->setGalleryPath('/' . $gal['gallery_id']);
        $_REQUEST['gallery_id'] = $gal['gallery_id'];
    }
}
// the image is considered the primary content, however the gallery is useful
if (!empty($_REQUEST['gallery_id']) && is_numeric($_REQUEST['gallery_id'])) {
    $gGallery = FisheyeGallery::lookup($_REQUEST);
    $gBitSmarty->assignByRef('gGallery', $gGallery);
    $gBitSmarty->assignByRef('galleryId', $_REQUEST['gallery_id']);
}
// This user does not own this gallery and they have not been granted the permission to edit this gallery
$gContent->verifyViewPermission();
$gBitSmarty->assignByRef('gContent', $gContent);
$gBitSmarty->assignByRef('imageId', $gContent->mImageId);
Ejemplo n.º 3
0
 function addToGalleries($pGalleryArray)
 {
     global $gBitSystem;
     if ($this->isValid()) {
         $inGalleries = $this->mDb->getAssoc("SELECT `gallery_id`,`gallery_content_id` FROM `" . BIT_DB_PREFIX . "fisheye_gallery_image_map` fgim INNER JOIN `" . BIT_DB_PREFIX . "fisheye_gallery` fg ON (fgim.`gallery_content_id`=fg.`content_id`) WHERE `item_content_id` = ?", array($this->mContentId));
         $galleries = array();
         if (count($pGalleryArray)) {
             foreach ($pGalleryArray as $galleryId) {
                 // image has been requested to be put in a new gallery
                 if (empty($inGalleries[$galleryId])) {
                     if (empty($galleries[$galleryId])) {
                         $galleries[$galleryId] = FisheyeGallery::lookup(array('gallery_id' => $galleryId));
                         $galleries[$galleryId]->load();
                     }
                     if ($galleries[$galleryId]->isValid()) {
                         if ($galleries[$galleryId]->hasUserPermission('p_fisheye_upload', TRUE, FALSE) || $galleries[$galleryId]->isPublic()) {
                             if ($gBitSystem->isFeatureActive('fisheye_gallery_default_sort_mode')) {
                                 $pos = NULL;
                             } else {
                                 $query = "SELECT MAX(`item_position`)\n\t\t\t\t\t\t\t\t\t\t\t  FROM `" . BIT_DB_PREFIX . "fisheye_gallery_image_map` fgim\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "fisheye_gallery` fg ON(fgim.`gallery_content_id`=fg.`content_id`)\n\t\t\t\t\t\t\t\t\t\t\t  WHERE fg.`gallery_id`=?";
                                 $pos = $this->mDb->getOne($query, array($galleryId)) + 10;
                             }
                             $galleries[$galleryId]->addItem($this->mContentId, $pos);
                         } else {
                             $this->mErrors[] = "You do not have permission to attach " . $this->getTitle() . " to " . $galleries[$galleryId]->getTitle();
                         }
                     }
                 } else {
                     // image already in an existing gallery.
                     unset($inGalleries[$galleryId]);
                 }
             }
         }
         if (count($inGalleries)) {
             // if we have any left over in the inGalleries array, we should delete them. these were the "unchecked" boxes
             foreach ($inGalleries as $galleryId) {
                 $sql = "DELETE FROM `" . BIT_DB_PREFIX . "fisheye_gallery_image_map` WHERE `gallery_content_id` = ? AND `item_content_id` = ?";
                 $rs = $this->mDb->query($sql, array($galleryId, $this->mContentId));
             }
         }
     }
 }
Ejemplo n.º 4
0
function addGalleryRecursive($pGalleryId, $pPath = '/', &$pZip)
{
    if ($gallery = FisheyeGallery::lookup(array('galley_id' => $pGalleryId))) {
        $gallery->load();
        $gallery->loadImages();
        $pPath .= $gallery->getTitle() . '/';
        foreach ($gallery->mItems as $item) {
            if (is_a($item, 'FisheyeImage')) {
                $sourcePath = $item->getSourceFile();
                $title = $item->getTitle();
                $pZip->addFile($sourcePath, $pPath . $title . substr($sourcePath, strrpos($sourcePath, '.')));
            } elseif (is_a($item, 'FisheyeGallery')) {
                addGalleryRecursive($item->mGalleryId, $pPath, $pZip);
            }
        }
    }
}