1 | <?php |
||
8 | class GalleryPage extends GalleryHub |
||
|
|||
9 | { |
||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | private static $description = 'Display a "gallery" of images'; |
||
14 | |||
15 | private static $icon = "gallery/images/gallery.png"; |
||
16 | |||
17 | private static $db = array( |
||
18 | "ImageWidth" => "Int", |
||
19 | "ImageHeight" => "Int", |
||
20 | "ImageResizeType" => "Enum(array('crop','pad','ratio','width','height'), 'ratio')" |
||
21 | ); |
||
22 | |||
23 | private static $defaults = array( |
||
24 | "ImageWidth" => 950, |
||
25 | "ImageHeight" => 500, |
||
26 | "ShowSideBar" => 1 |
||
27 | ); |
||
28 | |||
29 | private static $many_many = array( |
||
30 | 'Images' => 'Image' |
||
31 | ); |
||
32 | |||
33 | private static $many_many_extraFields = array( |
||
34 | 'Images' => array('SortOrder' => 'Int') |
||
35 | ); |
||
36 | |||
37 | /** |
||
38 | * Return sorted images |
||
39 | * |
||
40 | * @return ArrayList |
||
41 | */ |
||
42 | public function SortedImages() |
||
43 | { |
||
44 | return $this->Images()->Sort('SortOrder'); |
||
45 | } |
||
46 | |||
47 | public function getCMSFields() |
||
74 | |||
75 | public function getSettingsFields() { |
||
76 | $fields = parent::getSettingsFields(); |
||
77 | |||
78 | $fields->addFieldsToTab( |
||
79 | 'Root.Settings', |
||
80 | array( |
||
81 | NumericField::create("ImageWidth"), |
||
82 | NumericField::create("ImageHeight"), |
||
83 | DropdownField::create("ImageResizeType") |
||
84 | ->setSource($this->dbObject("ImageResizeType")->enumValues()) |
||
85 | ) |
||
86 | ); |
||
87 | |||
88 | return $fields; |
||
89 | } |
||
90 | |||
91 | public function onBeforeWrite() |
||
92 | { |
||
93 | parent::onBeforeWrite(); |
||
94 | |||
95 | // default settings (if not set) |
||
96 | $defaults = $this->config()->defaults; |
||
97 | $this->ImageWidth = ($this->ImageWidth) ? $this->ImageWidth : $defaults["ImageWidth"]; |
||
98 | $this->ImageHeight = ($this->ImageHeight) ? $this->ImageHeight : $defaults["ImageHeight"]; |
||
99 | } |
||
100 | |||
101 | } |
||
102 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.