Source of file NewsPage.php
Size: 2,063 Bytes - Last Modified: 2021-12-24T06:43:14+00:00
/var/www/docs.ssmods.com/process/src/src/PageTypes/NewsPage.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 | <?php namespace CWP\CWP\PageTypes; use SilverStripe\AssetAdmin\Forms\UploadField; use SilverStripe\Assets\Image; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\TextField; use SilverStripe\ORM\FieldType\DBField; class NewsPage extends DatedUpdatePage { private static $description = 'Describes an item of news'; private static $default_parent = 'NewsHolderPage'; private static $can_be_root = false; private static $icon_class = 'font-icon-p-news-item'; private static $singular_name = 'News Page'; private static $plural_name = 'News Pages'; private static $db = [ 'Author' => 'Varchar(255)', ]; private static $has_one = [ 'FeaturedImage' => Image::class, ]; private static $owns = [ 'FeaturedImage', ]; private static $table_name = 'NewsPage'; public function fieldLabels($includerelations = true) { $labels = parent::fieldLabels($includerelations); $labels['Author'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.AuthorFieldLabel', 'Author'); $labels['FeaturedImageID'] = _t( 'CWP\\CWP\\PageTypes\\DateUpdatePage.FeaturedImageFieldLabel', 'Featured Image' ); return $labels; } public function getCMSFields() { $this->beforeUpdateCMSFields(function (FieldList $fields) { $fields->addFieldToTab( 'Root.Main', TextField::create('Author', $this->fieldLabel('Author')), 'Abstract' ); $fields->addFieldToTab( 'Root.Main', UploadField::create('FeaturedImage', $this->fieldLabel('FeaturedImageID')), 'Abstract' ); }); return parent::getCMSFields(); } /** * Returns the Author DB field for this page type. * * Used to avoid conflicts with `Versioned::Author()` * * @return DBField */ public function getNewsPageAuthor() { return $this->dbObject('Author'); } } |