Example #1
0
<?php

defined('C5_EXECUTE') or die(_("Access Denied."));
Loader::model('sortable_responsive_gallery', 'sortable_responsive_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('btSortableResponsiveGallery');
$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 SortableResponsiveGallery($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 = SortableResponsiveGallery::getUnsortedPermittedFilesetImages($fsID);
}
//Render the images
Loader::packageElement('thumbnail_items', 'sortable_responsive_gallery', array('images' => $images));
exit;
Example #2
0
 public function save($args)
 {
     //checkboxes are weird in C5 -- must be handled in this way.
     $args['enableLightbox'] = isset($args['enableLightbox']) ? 1 : 0;
     parent::save($args);
     //Save child records (parent::save only saves the primary block record)
     Loader::model('sortable_responsive_gallery', 'sortable_responsive_gallery');
     $sg = new SortableResponsiveGallery($this->bID);
     $sortedFileIDs = empty($args['sortedFileIDs']) ? array() : explode(',', $args['sortedFileIDs']);
     //explode returns array with 1 element (whose value is an empty string) when passed an empty string. We don't want that, so explicitly check for empty string.
     $sg->setPositions($sortedFileIDs);
 }