| 1 | <?php |
||
| 3 | class SlideImage extends DataObject implements PermissionProvider |
||
| 4 | { |
||
| 5 | //TODO: move to config.yml |
||
| 6 | private static $defaults = array( |
||
|
1 ignored issue
–
show
|
|||
| 7 | 'ShowSlide' => true, |
||
| 8 | ); |
||
| 9 | |||
| 10 | 1 | public function getCMSFields() |
|
| 11 | { |
||
| 12 | 1 | $fields = parent::getCMSFields(); |
|
| 13 | 1 | $ImageField = new UploadField('Image', 'Image'); |
|
| 14 | 1 | $ImageField->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png'); |
|
| 15 | 1 | $ImageField->setFolderName('Uploads/SlideImages'); |
|
| 16 | 1 | $ImageField->setConfig('allowedMaxFileNumber', 1); |
|
| 17 | 1 | $ImageField->getValidator()->setAllowedMaxFileSize(FLEXSLIDER_IMAGE_FILE_SIZE_LIMIT); |
|
| 18 | |||
| 19 | 1 | $fields->removeByName(array('ShowSlide')); |
|
| 20 | |||
| 21 | 1 | $fields->addFieldsToTab('Root.Main', array( |
|
| 22 | 1 | TextField::create('Name') |
|
| 23 | 1 | ->setDescription('for internal reference only'), |
|
| 24 | 1 | TextField::create('Title') |
|
| 25 | 1 | ->setDescription('optional, used in template'), |
|
| 26 | 1 | TextareaField::create('Description') |
|
| 27 | 1 | ->setDescription('optional, used in template'), |
|
| 28 | 1 | TreeDropdownField::create('PageLinkID', 'Choose a page to link to:', 'SiteTree'), |
|
| 29 | 1 | $ImageField, |
|
| 30 | 1 | CheckboxField::create('ShowSlide')->setTitle('Show Slide') |
|
| 31 | 1 | ->setDescription('Include this slide in the slider. Uncheck to hide'), |
|
| 32 | 1 | )); |
|
| 33 | 1 | $fields->removeByName(array( |
|
| 34 | 1 | 'SortOrder', |
|
| 35 | 1 | 'PageID', |
|
| 36 | 1 | )); |
|
| 37 | |||
| 38 | 1 | $this->extend('updateCMSFields', $fields); |
|
| 39 | |||
| 40 | 1 | return $fields; |
|
| 41 | } |
||
| 42 | |||
| 43 | 6 | public function validate() |
|
| 57 | |||
| 58 | 1 | public function providePermissions() |
|
| 70 | |||
| 71 | 1 | public function canEdit($member = null) |
|
| 75 | |||
| 76 | 1 | public function canDelete($member = null) |
|
| 80 | |||
| 81 | 1 | public function canView($member = null) |
|
| 85 | } |
||
| 86 |
This check marks private properties in classes that are never used. Those properties can be removed.