mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-10-22 11:05:46 +02:00
Moved slider image sizing to elemental-basics
This commit is contained in:
parent
347c389447
commit
98590f6871
@ -18,66 +18,5 @@ use SilverStripe\ORM\DataExtension;
|
|||||||
|
|
||||||
class SlideImageExtension extends DataExtension
|
class SlideImageExtension extends DataExtension
|
||||||
{
|
{
|
||||||
private static $db = [
|
|
||||||
'Hide' => 'Boolean(0)',
|
|
||||||
'DateOn' => 'Datetime',
|
|
||||||
'DateOff' => 'Datetime',
|
|
||||||
];
|
|
||||||
|
|
||||||
private $_cache = [];
|
|
||||||
|
|
||||||
public function getElement()
|
|
||||||
{
|
|
||||||
if(!isset($this->_cache['element'])) {
|
|
||||||
$this->_cache['element'] = $this->owner->SlideshowElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->_cache['element'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSlideWidth()
|
|
||||||
{
|
|
||||||
$element = $this->getElement();
|
|
||||||
if(!$element->ID) {
|
|
||||||
return SliderElement::config()->get('slide_width');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $element->getSlideWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSlideHeight()
|
|
||||||
{
|
|
||||||
$element = $this->getElement();
|
|
||||||
if(!$element->ID) {
|
|
||||||
return SliderElement::config()->get('slide_height');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $element->getSlideHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateCMSFields(FieldList $fields)
|
|
||||||
{
|
|
||||||
parent::updateCMSFields($fields);
|
|
||||||
|
|
||||||
$fields->removeByName([
|
|
||||||
'PageLinkID',
|
|
||||||
'Hide',
|
|
||||||
'DateOn',
|
|
||||||
'DateOff',
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
$fields->dataFieldByName('Image')
|
|
||||||
->setTitle('Image ('.$this->getSlideWidth().' x '.$this->getSlideHeight().' px)');
|
|
||||||
|
|
||||||
$fields->addFieldToTab('Root.Main', ToggleCompositeField::create(
|
|
||||||
'ConfigHD',
|
|
||||||
'Slide Settings',
|
|
||||||
[
|
|
||||||
CheckboxField::create('Hide', 'Hide this slide? (That will hide the slide regardless of start/end fields)'),
|
|
||||||
DatetimeField::create('DateOn', 'When would you like to start showing the slide?'),
|
|
||||||
DatetimeField::create('DateOff', 'When would you like to stop showing the slide?'),
|
|
||||||
]
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user