@@ -2,84 +2,84 @@ |
||
2 | 2 | |
3 | 3 | class SlideImage extends DataObject implements PermissionProvider |
4 | 4 | { |
5 | - //TODO: move to config.yml |
|
6 | - private static $defaults = array( |
|
7 | - 'ShowSlide' => true, |
|
8 | - ); |
|
5 | + //TODO: move to config.yml |
|
6 | + private static $defaults = array( |
|
7 | + 'ShowSlide' => true, |
|
8 | + ); |
|
9 | 9 | |
10 | - public function getCMSFields() |
|
11 | - { |
|
12 | - $fields = parent::getCMSFields(); |
|
13 | - $ImageField = new UploadField('Image', 'Image'); |
|
14 | - $ImageField->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png'); |
|
15 | - $ImageField->setFolderName('Uploads/SlideImages'); |
|
16 | - $ImageField->setConfig('allowedMaxFileNumber', 1); |
|
17 | - $ImageField->getValidator()->setAllowedMaxFileSize(FLEXSLIDER_IMAGE_FILE_SIZE_LIMIT); |
|
10 | + public function getCMSFields() |
|
11 | + { |
|
12 | + $fields = parent::getCMSFields(); |
|
13 | + $ImageField = new UploadField('Image', 'Image'); |
|
14 | + $ImageField->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png'); |
|
15 | + $ImageField->setFolderName('Uploads/SlideImages'); |
|
16 | + $ImageField->setConfig('allowedMaxFileNumber', 1); |
|
17 | + $ImageField->getValidator()->setAllowedMaxFileSize(FLEXSLIDER_IMAGE_FILE_SIZE_LIMIT); |
|
18 | 18 | |
19 | - $fields->removeByName(array('ShowSlide')); |
|
19 | + $fields->removeByName(array('ShowSlide')); |
|
20 | 20 | |
21 | - $fields->addFieldsToTab('Root.Main', array( |
|
22 | - TextField::create('Name') |
|
23 | - ->setDescription('for internal reference only'), |
|
24 | - TextField::create('Headline') |
|
25 | - ->setDescription('optional, used in template'), |
|
26 | - TextareaField::create('Description') |
|
27 | - ->setDescription('optional, used in template'), |
|
28 | - TreeDropdownField::create('PageLinkID', 'Choose a page to link to:', 'SiteTree'), |
|
29 | - $ImageField, |
|
30 | - CheckboxField::create('ShowSlide')->setTitle('Show Slide') |
|
31 | - ->setDescription('Include this slide in the slider. Uncheck to hide'), |
|
32 | - )); |
|
33 | - $fields->removeByName(array( |
|
34 | - 'SortOrder', |
|
35 | - 'PageID', |
|
36 | - )); |
|
21 | + $fields->addFieldsToTab('Root.Main', array( |
|
22 | + TextField::create('Name') |
|
23 | + ->setDescription('for internal reference only'), |
|
24 | + TextField::create('Headline') |
|
25 | + ->setDescription('optional, used in template'), |
|
26 | + TextareaField::create('Description') |
|
27 | + ->setDescription('optional, used in template'), |
|
28 | + TreeDropdownField::create('PageLinkID', 'Choose a page to link to:', 'SiteTree'), |
|
29 | + $ImageField, |
|
30 | + CheckboxField::create('ShowSlide')->setTitle('Show Slide') |
|
31 | + ->setDescription('Include this slide in the slider. Uncheck to hide'), |
|
32 | + )); |
|
33 | + $fields->removeByName(array( |
|
34 | + 'SortOrder', |
|
35 | + 'PageID', |
|
36 | + )); |
|
37 | 37 | |
38 | - $this->extend('updateCMSFields', $fields); |
|
38 | + $this->extend('updateCMSFields', $fields); |
|
39 | 39 | |
40 | - return $fields; |
|
41 | - } |
|
40 | + return $fields; |
|
41 | + } |
|
42 | 42 | |
43 | - public function validate() |
|
44 | - { |
|
45 | - $result = parent::validate(); |
|
43 | + public function validate() |
|
44 | + { |
|
45 | + $result = parent::validate(); |
|
46 | 46 | |
47 | - if (!$this->Name) { |
|
48 | - $result->error('A Name is required before you can save'); |
|
49 | - } |
|
47 | + if (!$this->Name) { |
|
48 | + $result->error('A Name is required before you can save'); |
|
49 | + } |
|
50 | 50 | |
51 | - if (!$this->ImageID) { |
|
52 | - $result->error('An Image is required before you can save'); |
|
53 | - } |
|
51 | + if (!$this->ImageID) { |
|
52 | + $result->error('An Image is required before you can save'); |
|
53 | + } |
|
54 | 54 | |
55 | - return $result; |
|
56 | - } |
|
55 | + return $result; |
|
56 | + } |
|
57 | 57 | |
58 | - public function providePermissions() |
|
59 | - { |
|
60 | - return array( |
|
61 | - 'Slide_EDIT' => 'Slide Edit', |
|
62 | - 'Slide_DELETE' => 'Slide Delete', |
|
63 | - 'Slide_CREATE' => 'Slide Create', |
|
64 | - ); |
|
65 | - } |
|
66 | - public function canCreate($member = null) |
|
67 | - { |
|
68 | - return Permission::check('Slide_CREATE'); |
|
69 | - } |
|
58 | + public function providePermissions() |
|
59 | + { |
|
60 | + return array( |
|
61 | + 'Slide_EDIT' => 'Slide Edit', |
|
62 | + 'Slide_DELETE' => 'Slide Delete', |
|
63 | + 'Slide_CREATE' => 'Slide Create', |
|
64 | + ); |
|
65 | + } |
|
66 | + public function canCreate($member = null) |
|
67 | + { |
|
68 | + return Permission::check('Slide_CREATE'); |
|
69 | + } |
|
70 | 70 | |
71 | - public function canEdit($member = null) |
|
72 | - { |
|
73 | - return Permission::check('Slide_EDIT'); |
|
74 | - } |
|
71 | + public function canEdit($member = null) |
|
72 | + { |
|
73 | + return Permission::check('Slide_EDIT'); |
|
74 | + } |
|
75 | 75 | |
76 | - public function canDelete($member = null) |
|
77 | - { |
|
78 | - return Permission::check('Slide_DELETE'); |
|
79 | - } |
|
76 | + public function canDelete($member = null) |
|
77 | + { |
|
78 | + return Permission::check('Slide_DELETE'); |
|
79 | + } |
|
80 | 80 | |
81 | - public function canView($member = null) |
|
82 | - { |
|
83 | - return true; |
|
84 | - } |
|
81 | + public function canView($member = null) |
|
82 | + { |
|
83 | + return true; |
|
84 | + } |
|
85 | 85 | } |