Source of file ElementCallToAction.php
Size: 2,902 Bytes - Last Modified: 2018-10-12T10:12:34+00:00
/var/www/docs.ssmods.com/process/src/src/Element/ElementCallToAction.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 | <?php namespace Derralf\Elements\CallToAction\Element; use DNADesign\Elemental\Models\BaseElement; use Sheadawson\Linkable\Forms\LinkField; use Sheadawson\Linkable\Models\Link; use SilverStripe\Core\Config\Config; use SilverStripe\Forms\DropdownField; class ElementCallToAction extends BaseElement { public function getType() { return self::$singular_name; } private static $icon = 'font-icon-right-dir'; private static $table_name = 'ElementCallToAction'; private static $singular_name = 'CTA-Element, einfach mit Button'; private static $plural_name = 'CTA-Elemente, einfach mit Button'; private static $description = ''; private static $db = [ 'HTML' => 'HTMLText', 'Color' => 'Varchar(255)', ]; private static $has_one = [ 'ReadMoreLink' => Link::Class ]; private static $has_many = [ ]; private static $many_many = []; private static $belongs_many_many = []; private static $owns = [ ]; private static $defaults = [ ]; private static $colors = []; private static $field_labels = [ 'Title' => 'Titel', 'Sort' => 'Sortierung' ]; public function FieldLabels($includerelations = true) { $labels = parent::fieldLabels($includerelations=true); $labels['Color'] = _t(__CLASS__ . '.ColorLabel', 'Color'); $labels['ReadMoreLink'] = _t(__CLASS__ . '.ReadMoreLinkLabel', 'ReadMoreLink'); } public function getCMSFields() { $this->beforeUpdateCMSFields(function ($fields) { // Style: Description for default style (describes Layout thats used, when no special style is selected) $Style = $fields->dataFieldByName('Style'); $StyleDefaultDescription = $this->owner->config()->get('styles_default_description', Config::UNINHERITED); if ($Style && $StyleDefaultDescription) { $Style->setDescription($StyleDefaultDescription); } // ReadMoreLink: use Linkfield $ReadMoreLink = LinkField::create('ReadMoreLinkID', 'Link'); $fields->replaceField('ReadMoreLinkID', $ReadMoreLink); $colors = $this->config()->get('colors'); if ($colors && count($colors) > 0) { $colorDropdown = DropdownField::create('Color', _t(__CLASS__.'.COLOR', 'Color variation'), $colors); $fields->insertBefore($colorDropdown, 'HTML'); $colorDropdown->setEmptyString(_t(__CLASS__.'.CUSTOM_COLORS', 'Select a color...')); } else { $fields->removeByName('Color'); } }); $fields = parent::getCMSFields(); return $fields; } public function ReadmoreLinkClass() { return $this->config()->get('readmore_link_class'); } } |