public function save($args) { $args['fullWidth'] = empty($args['fullWidth']) ? 0 : intval($args['fullWidth']); $args['fullHeight'] = empty($args['fullHeight']) ? 0 : intval($args['fullHeight']); //checkboxes are weird in C5 -- must be handled in this way. $args['enableLightbox'] = isset($args['enableLightbox']) ? 1 : 0; $args['enableCropping'] = isset($args['enableCropping']) ? 1 : 0; $args['displayThumbTitles'] = isset($args['displayThumbTitles']) ? 1 : 0; parent::save($args); //Save child records (parent::save only saves the primary block record) Loader::model('deluxe_image_gallery', 'deluxe_image_gallery'); $sg = new DeluxeImageGallery($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. $sortedFiles = array(); foreach ($sortedFileIDs as $fID) { $sortedFiles[] = array('fID' => $fID, 'title' => $args["properties_title_{$fID}"], 'caption' => $args["properties_caption_{$fID}"]); } $sg->setProperties($sortedFiles); }
<?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); }