Source of file ElementContent.php
Size: 1,451 Bytes - Last Modified: 2021-12-24T06:44:48+00:00
/var/www/docs.ssmods.com/process/src/src/Models/ElementContent.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | <?php namespace DNADesign\Elemental\Models; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\HTMLEditor\HTMLEditorField; use SilverStripe\ORM\FieldType\DBField; /** * @property string $HTML */ class ElementContent extends BaseElement { private static $icon = 'font-icon-block-content'; private static $db = [ 'HTML' => 'HTMLText' ]; private static $table_name = 'ElementContent'; private static $singular_name = 'content block'; private static $plural_name = 'content blocks'; private static $description = 'HTML text block'; /** * Re-title the HTML field to Content * * {@inheritDoc} */ public function getCMSFields() { $this->beforeUpdateCMSFields(function (FieldList $fields) { /** @var HTMLEditorField $editorField */ $editorField = $fields->fieldByName('Root.Main.HTML'); $editorField->setTitle(_t(__CLASS__ . '.ContentLabel', 'Content')); }); return parent::getCMSFields(); } public function getSummary() { return DBField::create_field('HTMLText', $this->HTML)->Summary(20); } protected function provideBlockSchema() { $blockSchema = parent::provideBlockSchema(); $blockSchema['content'] = $this->getSummary(); return $blockSchema; } public function getType() { return _t(__CLASS__ . '.BlockType', 'Content'); } } |