示例#1
0
 public function view()
 {
     Loader::model('sortable_fancybox_gallery', 'sortable_fancybox_gallery');
     $sg = new SortableFancyboxGallery($this->bID);
     $files = $sg->getPermittedImages();
     $ih = Loader::helper('image');
     $images = array();
     $max_row_height = 0;
     foreach ($files as $file) {
         $image = array();
         //$image['src'] = $file->getRelativePath();
         // $size = @getimagesize($file->getPath());
         // $image['width'] = $size[0];
         // $image['height'] = $size[1];
         $fv = $file->getRecentVersion();
         $image['title'] = htmlspecialchars($fv->getTitle(), ENT_QUOTES, 'UTF-8');
         $image['description'] = htmlspecialchars($fv->getDescription(), ENT_QUOTES, 'UTF-8');
         $full = $ih->getThumbnail($file, $this->fullWidth, $this->fullHeight);
         $image['full_src'] = $full->src;
         $image['full_width'] = $full->width;
         $image['full_height'] = $full->height;
         if ($this->enableLightbox) {
             $thumb = $ih->getThumbnail($file, $this->thumbWidth, $this->thumbHeight, true);
             $image['thumb_src'] = $thumb->src;
             $image['thumb_width'] = $thumb->width;
             $image['thumb_height'] = $thumb->height;
             $max_row_height = $thumb->height > $max_row_height ? $thumb->height : $max_row_height;
         } else {
             $image['thumb_src'] = '';
             $image['thumb_width'] = 0;
             $image['thumb_height'] = 0;
             $max_row_height = $full->height > $max_row_height ? $full->height : $max_row_height;
         }
         $images[] = $image;
     }
     $this->set('images', $images);
     $this->set('max_row_height', $max_row_height);
     //For "initial block add" css workaround:
     $html = Loader::helper('html');
     $bv = new BlockView();
     $bv->setBlockObject($this->getBlockObject());
     $css_output_object = $html->css($bv->getBlockURL() . '/view.css');
     //Pick up theme overrides
     $this->set('inline_view_css_url', $css_output_object->file);
 }
<?php

defined('C5_EXECUTE') or die(_("Access Denied."));
Loader::model('sortable_fancybox_gallery', 'sortable_fancybox_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('btSortableFancyboxGallery');
$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 SortableFancyboxGallery($bID);
    $images = $sg->getPermittedImages();
} else {
    //Retrieve unsorted images from the fileset if this is a new block or the fsID's don't match...
    $images = SortableFancyboxGallery::getUnsortedPermittedFilesetImages($fsID);
}
//Render the images
Loader::packageElement('thumbnail_items', 'sortable_fancybox_gallery', array('images' => $images));
exit;