Source of file ElementSlideshow.php
Size: 2,435 Bytes - Last Modified: 2021-12-24T06:45:56+00:00
/var/www/docs.ssmods.com/process/src/src/Elements/ElementSlideshow.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 | <?php namespace Dynamic\Elements\Flexslider\Elements; use DNADesign\Elemental\Models\BaseElement; use Dynamic\FlexSlider\Model\SlideImage; use SilverStripe\Forms\FieldList; use SilverStripe\ORM\FieldType\DBField; /** * Class ElementSlideshow * @package Dynamic\Elements\Flexslider\Elements * * @property string Content */ class ElementSlideshow extends BaseElement { /** * @var string */ private static $icon = 'font-icon-block-carousel'; /** * @var string */ private static $table_name = 'ElementSlideshow'; /** * @var array */ private static $db = [ 'Content' => 'HTMLText', ]; /** * @var array */ private static $owns = [ 'Slides', ]; /** * @var bool */ private static $inline_editable = false; /** * @var string */ private static $slide_tab_title = 'Main'; /** * @param bool $includerelations * @return array */ public function fieldLabels($includerelations = true) { $labels = parent::fieldLabels($includerelations); $labels['Content'] = _t(__CLASS__.'.ContentLabel', 'Description'); return $labels; } /** * @return FieldList */ public function getCMSFields() { $this->beforeUpdateCMSFields(function (FieldList $fields) { $fields->dataFieldByName('Content') ->setRows(5) ->setDescription(_t( __CLASS__ . '.ContentDescription', 'optional. Add introductory copy to your slideshow.' )); }); return parent::getCMSFields(); } /** * @return \SilverStripe\ORM\FieldType\DBHTMLText */ public function getSummary() { $count = $this->Slides()->count(); $label = _t( SlideImage::class . '.PLURALS', '{count} Slide|{count} Slides', [ 'count' => $count ] ); return DBField::create_field('HTMLText', $label)->Summary(20); } /** * @return array */ protected function provideBlockSchema() { $blockSchema = parent::provideBlockSchema(); $blockSchema['content'] = $this->getSummary(); return $blockSchema; } /** * @return string */ public function getType() { return _t(__CLASS__.'.BlockType', 'Slideshow'); } } |