1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class GalleryPage extends Page |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
/** |
6
|
|
|
* @var string |
7
|
|
|
*/ |
8
|
|
|
private static $icon = 'flex-images-gallery/images/icons/gallery.png'; |
|
|
|
|
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @var string |
12
|
|
|
*/ |
13
|
|
|
private static $description = 'Gallery page'; |
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var array |
17
|
|
|
*/ |
18
|
|
|
private static $db = array( |
|
|
|
|
19
|
|
|
'Height' => 'int', |
20
|
|
|
); |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var array |
24
|
|
|
*/ |
25
|
|
|
private static $has_many = array( |
|
|
|
|
26
|
|
|
'GalleryBlocks' => 'ContentBlock_Gallery', |
27
|
|
|
); |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
private static $many_many = array( |
|
|
|
|
33
|
|
|
'Images' => 'Image', |
34
|
|
|
); |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @return FieldList |
38
|
|
|
*/ |
39
|
|
|
public function getCMSFields() |
40
|
|
|
{ |
41
|
|
|
$fields = parent::getCMSFields(); |
42
|
|
|
|
43
|
|
|
// remove the content block |
44
|
|
|
$fields->removeByName('Content'); |
45
|
|
|
|
46
|
|
|
// Add a gallery gridfield for the images. |
47
|
|
|
$fields->addFieldToTab( |
48
|
|
|
'Root.Main', |
49
|
|
|
SortableGalleryField::create('Images'), |
50
|
|
|
'Metadata' |
51
|
|
|
); |
52
|
|
|
|
53
|
|
|
// add configuration tab for the height |
54
|
|
|
$fields->addFieldsToTab( |
55
|
|
|
'Root.Configuration', |
56
|
|
|
array( |
57
|
|
|
NoticeMessage::create('This value defines the height of an image row (in pixel).'), |
58
|
|
|
TextField::create('Height'), |
59
|
|
|
) |
60
|
|
|
); |
61
|
|
|
|
62
|
|
|
return $fields; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
class GalleryPage_Controller extends Page_Controller |
|
|
|
|
67
|
|
|
{ |
68
|
|
|
/** |
69
|
|
|
* add the requirements |
70
|
|
|
*/ |
71
|
|
|
public function init() |
72
|
|
|
{ |
73
|
|
|
parent::init(); |
74
|
|
|
|
75
|
|
|
// add the used libs in. |
76
|
|
|
Requirements::css(FLEX_IMAGES_GALLERY_MODULE_DIR . '/css/styles.css'); |
77
|
|
|
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); |
78
|
|
|
Requirements::javascript(FLEX_IMAGES_GALLERY_MODULE_DIR . '/javascript/jquery.flex-images.js'); |
79
|
|
|
Requirements::javascript(FLEX_IMAGES_GALLERY_MODULE_DIR . '/javascript/lightbox.js'); |
80
|
|
|
|
81
|
|
|
// add the defined rowHeight to the js file |
82
|
|
|
Requirements::javascriptTemplate( |
83
|
|
|
FLEX_IMAGES_GALLERY_MODULE_DIR . '/javascript/GalleryPage.template.js', |
84
|
|
|
array( |
85
|
|
|
'rowHeight' => ($this->Height) ? $this->Height : 180, |
86
|
|
|
) |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
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.