Source of file RecentVideosBlock.php
Size: 2,122 Bytes - Last Modified: 2021-12-23T10:05:44+00:00
/var/www/docs.ssmods.com/process/src/code/blocks/RecentVideosBlock.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 | <?php if (class_exists('Block')) { /** * Class RecentVideosBlock * * @property int $Limit * @property int $VideoPageID * @method YouTubeIntegrationVideosPage $VideoPage */ class RecentVideosBlock extends Block { /** * @var string */ private static $singular_name = 'Recent Videos Block'; /** * @var string */ private static $plural_name = 'Recent Videos Blocks'; /** * @var array */ private static $db = array( 'Limit' => 'Int', ); /** * @var array */ private static $has_one = array( 'VideoPage' => 'YouTubeIntegrationVideosPage', ); /** * @var array */ private static $defaults = array( 'Limit' => 3, ); /** * @var */ private $recent_videos; /** * @return FieldList */ public function getCMSFields() { $fields = singleton('Block')->getCMSFields(); $fields->addFieldsToTab('Root.Main', array( NumericField::create('Limit'), )); $fields->addFieldToTab( 'Root.Main', DropdownField::create('VideoPageID', 'Featured Video Page', YouTubeIntegrationVideosPage::get()->map()) ->setEmptyString('') ); return $fields; } /** * @return mixed */ public function getRecentVideos() { if (!$this->recent_videos) { $this->setRecentVideos(); } return $this->recent_videos; } /** * @return $this */ public function setRecentVideos() { $this->recent_videos = ($this->VideoPageID != 0) ? $this->VideoPage()->getVideosList()->limit($this->Limit) : SilverStripeYouTubeVideo::get()->limit($this->Limit); return $this; } } } |