Source of file GalleryPage.php
Size: 2,679 Bytes - Last Modified: 2021-12-24T05:18:11+00:00
/var/www/docs.ssmods.com/process/src/src/GalleryPage.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 | <?php /* use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor; use SilverStripe\Forms\GridField\GridField; use SilverStripe\View\Requirements; */ class GalleryPage extends Page { public static $icon = 'simple_gallery/images/treeicons/news'; public static $db = array(); static $can_be_root = false; public static $allowed_children = array( "Gallery" ); public static $has_many = array( 'GalleryImages' => 'GalleryImage', ); public static $has_one = array(); public static $defaults = array(); public function getCMSFields() { $f = parent::getCMSFields(); $f->removeByName( "Images" ); $gridFieldConfig = GridFieldConfig_RecordEditor::create(); $gridFieldConfig->addComponent( new GridFieldBulkUpload() ); $gridFieldConfig->addComponent( new GridFieldSortableRows( 'SortOrder' ) ); $gridFieldConfig->getComponentByType( 'GridFieldBulkUpload' ) ->setUfSetup( 'setFolderName', 'Uploads/galleryimages/' . $this->URLSegment ); $gridfield = new GridField( 'GalleryImages', 'Gallery Image', $this->GalleryImages(), $gridFieldConfig ); $f->addFieldToTab( 'Root.Gallery', $gridfield ); return $f; } public function canCreateee($member = null) { return false; } function MiniGalleryImages( $limit = 8 ) { return $this->GalleryImages()->sort( 'RAND()' )->limit( $limit ); } function Image( $resize = true ) { if ( count( $this->GalleryImages() ) ) { $image = $this->GalleryImages()->first(); if ( $image ) { $Attachment = $image->Attachment(); $GalleryFittedImage = $Attachment->newClassInstance( 'GalleryFittedImage' ); if ( $resize ) { return $GalleryFittedImage->CroppedResize( 360, 280 ); } return $GalleryFittedImage; } } return false; } function ChildImageList() { $images = $this->GalleryImages(); if ( count( $images ) ) { $AttachmentIDs = $images->column( "AttachmentID" ); $images = Image::get()->byIDs( $AttachmentIDs )->exclude( array( "ID" => $this->Image()->ID ) ); return implode( ',', $images->column( "Filename" ) ); } return false; } } class GalleryPage_Controller extends Page_Controller { public function init() { parent::init(); Requirements::css( SIMPLE_GALLERY . '/css/gallery.css' ); } } |