Source of file SSGuru_CarouselItem.php
Size: 3,018 Bytes - Last Modified: 2021-12-24T06:49:04+00:00
/var/www/docs.ssmods.com/process/src/code/Models/SSGuru_CarouselItem.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 | <?php /** * @property Varchar $Title * @property Text $Caption * @property Boolean $Archived * @property Int $SortID * @method Page Parent() * @method Image Image() * @method Link Link() * @method type methodName(type $paramName) Description */ class SSGuru_CarouselItem extends DataObject { private static $singular_name = "Carousel Item"; private static $plural_name = "Carousel Items"; public static $db = array( 'Title' => 'Varchar(255)', 'Caption' => 'Text', 'Archived' => 'Boolean', 'SortID' => 'Int' ); public static $has_one = array( 'Parent' => 'Page', 'Image' => 'Image', 'Link' => 'Link' ); public static $summary_fields = array( 'ImageThumb' => 'Image', 'Title' => 'Title', 'Caption' => 'Text', 'Link.Title' => 'Link', 'ArchivedReadable' => 'Current Status' ); public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('ParentID'); $fields->removeByName('SortID'); $fields->removeByName('Archived'); $fields->addFieldToTab('Root.Main', LinkField::create('LinkID', 'Link')); if (class_exists('SelectUploadField')) { $fields->removeByName('Image'); $imageField = SelectUploadField::create("Image", "Image"); if ($this->Parent() && $this->Parent()->exists()) { // Debug::message($this->Parent()->ImageFolder("carousel")); $uploadFolderPath = $this->Parent()->ImageFolder("carousel"); $imageField->setFolderName($uploadFolderPath); $uploadFolder = File::find($uploadFolderPath); if ($uploadFolder) { $imageField->FolderSelector()->setValue($uploadFolder->ID); } } $fields->addFieldToTab('Root.Main',$imageField); } $fields->addFieldToTab('Root.Main', CompositeField::create(array( LabelField::create("LabelArchive", "Archive this carousel item?")->addExtraClass("left"), CheckboxField::create('Archived', '') ))->addExtraClass("field special") ); $imageField = $fields->dataFieldByName('Image'); if ($imageField) { $imageField-> setAllowedFileCategories("image")-> setAllowedMaxFileNumber(1); if ($this->Parent() && $this->Parent()->hasMethod("ImageFolder")) { $imageField-> setFolderName($this->Parent()->ImageFolder("carousel")); } } return $fields; } public function ImageThumb() { return $this->Image()->SetWidth(50); } public function ArchivedReadable() { return $this->Archived ? _t('GridField.Archived', 'Archived') : _t('GridField.Live', 'Live'); } } |