예제 #1
0
 public function view()
 {
     Loader::model('deluxe_image_gallery', 'deluxe_image_gallery');
     $sg = new DeluxeImageGallery($this->bID);
     $files = $sg->getPermittedImages();
     $ch = Loader::helper('deluxe_image_gallery', 'deluxe_image_gallery');
     $ih = Loader::helper('image');
     $images = array();
     $max_img_height = 0;
     foreach ($files as $file) {
         $image = array();
         $image['fID'] = $file['fID'];
         $image['title'] = htmlentities($file['title'], ENT_QUOTES, APP_CHARSET);
         if (defined('DELUXE_IMAGE_GALLERY_HTML_CAPTIONS') && (bool) DELUXE_IMAGE_GALLERY_HTML_CAPTIONS) {
             $image['caption'] = $file['caption'];
         } else {
             $image['caption'] = htmlentities($file['caption'], ENT_QUOTES, APP_CHARSET);
         }
         if ($this->lightboxTitlePosition == 'inside' || $this->lightboxTitlePosition == 'over') {
             $image['caption'] = nl2br($image['caption']);
             //Don't insert linebreaks if title position is 'float'/'outside',
             // because that style doesn't expand down to fit more than one line.
         }
         $f = $file['file'];
         if ($this->enableCropping) {
             $thumb = $ch->getThumbnail($f, $this->thumbWidth, $this->thumbHeight);
         } else {
             $thumb = $ih->getThumbnail($f, $this->thumbWidth, $this->thumbHeight);
         }
         $image['thumb_src'] = $thumb->src;
         $image['thumb_width'] = $thumb->width;
         $image['thumb_height'] = $thumb->height;
         $max_img_height = $thumb->height > $max_img_height ? $thumb->height : $max_img_height;
         if ($this->enableLightbox && empty($this->fullWidth) && empty($this->fullHeight)) {
             $image['full_src'] = $f->getRelativePath();
             $image['full_width'] = $f->getAttribute('width');
             $image['full_height'] = $f->getAttribute('height');
         } else {
             if ($this->enableLightbox) {
                 $maxWidth = empty($this->fullWidth) ? 9999 : $this->fullWidth;
                 $maxHeight = empty($this->fullHeight) ? 9999 : $this->fullHeight;
                 $full = $ih->getThumbnail($f, $maxWidth, $maxHeight);
                 $image['full_src'] = $full->src;
                 $image['full_width'] = $full->width;
                 $image['full_height'] = $full->height;
             } else {
                 $image['full_src'] = '';
                 $image['full_width'] = 0;
                 $image['full_height'] = 0;
             }
         }
         $images[] = $image;
     }
     $this->set('images', $images);
     $this->set('max_img_height', $max_img_height);
     //For "initial block add" css workaround:
     // (Note that this is only needed if the site is under a sub-directory)
     $inline_view_css_url = '';
     $dir_rel = DIR_REL;
     //uhh... php is weird -- won't let us put a constant inside the empty() function?!
     if (!empty($dir_rel)) {
         $html = Loader::helper('html');
         $bv = new BlockView();
         $bv->setBlockObject($this->getBlockObject());
         $css_output_object = $html->css($bv->getBlockURL() . '/view.css');
         //Pick up theme overrides
         $inline_view_css_url = $css_output_object->file;
     }
     $this->set('inline_view_css_url', $inline_view_css_url);
 }
예제 #2
0
<?php

defined('C5_EXECUTE') or die(_("Access Denied."));
Loader::model('deluxe_image_gallery', 'deluxe_image_gallery');
$bID = empty($_GET['bID']) ? 0 : intval($_GET['bID']);
$fsID = empty($_GET['fsID']) ? 0 : intval($_GET['fsID']);
//Load the primary database record for the given bID
Loader::model('block');
//<--need this in 5.6+ (otherwise the new autoloader can't find the BlockRecord class)
$block = new BlockRecord('btDeluxeImageGallery');
$block->Load("bID={$bID}");
//Loads empty object if bID=0
//Retrieve sorted images from our custom table if a block record exists and its fsID matches the fsID passed here...
if ($block && $block->fsID == $fsID) {
    $sg = new DeluxeImageGallery($bID);
    $images = $sg->getPermittedImages();
} else {
    //Retrieve images directly from the fileset if this is a new block or the fsID's don't match...
    $use_file_props_for_title_and_description = defined('DELUXE_IMAGE_GALLERY_DEFAULT_TITLES') && (bool) DELUXE_IMAGE_GALLERY_DEFAULT_TITLES;
    $images = DeluxeImageGallery::getPermittedFilesetImages($fsID, $use_file_props_for_title_and_description);
}