1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Generate a page that can display it's children as a grid of thumbnails |
5
|
|
|
* |
6
|
|
|
* @package gallery |
7
|
|
|
*/ |
8
|
|
|
class GalleryHub extends Page |
|
|
|
|
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @var string |
13
|
|
|
*/ |
14
|
|
|
private static $description = 'Display child galleries as a thumbnail grid'; |
|
|
|
|
15
|
|
|
|
16
|
|
|
private static $icon = "gallery/images/gallery-hub.png"; |
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var array |
20
|
|
|
*/ |
21
|
|
|
private static $allowed_children = array( |
|
|
|
|
22
|
|
|
'GalleryPage', |
23
|
|
|
); |
24
|
|
|
|
25
|
|
|
private static $db = array( |
|
|
|
|
26
|
|
|
"ShowSideBar" => "Boolean", |
27
|
|
|
"ShowImageTitles" => "Boolean", |
28
|
|
|
"ThumbnailWidth" => "Int", |
29
|
|
|
"ThumbnailHeight" => "Int", |
30
|
|
|
"ThumbnailResizeType" => "Enum(array('crop','pad','ratio','width','height'), 'crop')", |
31
|
|
|
"PaddedImageBackground" => "Varchar", |
32
|
|
|
"ThumbnailsPerPage" => "Int" |
33
|
|
|
); |
34
|
|
|
|
35
|
|
|
private static $defaults = array( |
|
|
|
|
36
|
|
|
"ThumbnailWidth" => 150, |
37
|
|
|
"ThumbnailHeight" => 150, |
38
|
|
|
"ThumbnailsPerPage" => 18, |
39
|
|
|
"PaddedImageBackground" => "ffffff", |
40
|
|
|
"ThumbnailsPerPage" => 18 |
41
|
|
|
); |
42
|
|
|
|
43
|
|
|
public function getSettingsFields() |
|
|
|
|
44
|
|
|
{ |
45
|
|
|
$fields = parent::getSettingsFields(); |
46
|
|
|
|
47
|
|
|
$fields->addFieldsToTab( |
48
|
|
|
"Root.Settings", |
49
|
|
|
[ |
50
|
|
|
CheckboxField::create('ShowSideBar'), |
51
|
|
|
CheckboxField::create('ShowImageTitles'), |
52
|
|
|
NumericField::create("ThumbnailWidth"), |
53
|
|
|
NumericField::create("ThumbnailHeight"), |
54
|
|
|
DropdownField::create("ThumbnailResizeType") |
55
|
|
|
->setSource($this->dbObject("ThumbnailResizeType")->enumValues()), |
56
|
|
|
NumericField::create('ThumbnailsPerPage'), |
57
|
|
|
TextField::create("PaddedImageBackground") |
58
|
|
|
] |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
return $fields; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function onBeforeWrite() |
65
|
|
|
{ |
66
|
|
|
parent::onBeforeWrite(); |
67
|
|
|
|
68
|
|
|
// default settings (if not set) |
69
|
|
|
$defaults = $this->config()->defaults; |
70
|
|
|
$this->ThumbnailWidth = ($this->ThumbnailWidth) ? $this->ThumbnailWidth : $defaults["ThumbnailWidth"]; |
71
|
|
|
$this->ThumbnailHeight = ($this->ThumbnailHeight) ? $this->ThumbnailHeight : $defaults["ThumbnailHeight"]; |
72
|
|
|
$this->ThumbnailsPerPage = ($this->ThumbnailsPerPage) ? $this->ThumbnailsPerPage : $defaults["ThumbnailsPerPage"]; |
73
|
|
|
$this->PaddedImageBackground = ($this->PaddedImageBackground) ? $this->PaddedImageBackground : $defaults["PaddedImageBackground"]; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
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.