Source of file CleanTeaser.php
Size: 2,109 Bytes - Last Modified: 2022-02-21T10:01:58+00:00
/var/www/docs.ssmods.com/process/src/code/models/CleanTeaser.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 | <?php /** * A DataObject for Teasers * Provides Title, Description and an Image * * @package cleanutilities * @subpackage models * * @author arillo */ class CleanTeaser extends DataObject { private static $db = array( 'Title'=> 'Text', 'Description' => 'HTMLText' ); private static $has_one = array( 'Reference' => 'SiteTree', 'Image' => 'Image' ); private static $searchable_fields = array( 'Title', 'Reference.Title' ); private static $summary_fields = array( 'Title', 'Description' => 'Description', 'Thumbnail' => 'Thumbnail' ); public static $upload_folder = "Teaser"; public function getCMSFields() { $fields = FieldList::create( new TabSet( "Root", new Tab("Main") ) ); $fields->addFieldToTab('Root.Main', TextField::create('Title', 'Title')); $fields->addFieldToTab('Root.Main', TextareaField::create('Description', 'Description')); $upload = UploadField::create('Image', 'Image'); $upload->setConfig('allowedMaxFileNumber', 1); $upload->getValidator()->setAllowedExtensions( CleanImage::$allowed_extensions ); if ($this->hasExtension('ControlledFolderDataExtension')) { $upload->setFolderName($this->getUploadFolder()); } else { $upload->setFolderName(self::$upload_folder); } $fields->addFieldToTab( 'Root.Main', $upload ); $this->extend('updateCMSFields', $fields); return $fields; } public function getCleanDescription() { return strip_tags($this->Description); } /** * Returns CMS thumbnail, if an image is attached. * Mainly used by GridField. * * @return mixed */ public function getThumbnail() { if ($image = $this->Image()) { return $image->CMSThumbnail(); } return _t('CleanTeaser.NO_IMAGE', '(No Image)'); } } |