Ejemplo n.º 1
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_fancybox_gallery', 'sortable_fancybox_gallery');
     $sg = new SortableFancyboxGallery($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);
 }
Ejemplo n.º 2
0
<?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;