1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class GalleryPage extends PageWithImage |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
public static $has_many = array( |
6
|
|
|
'GalleryImages' => 'GalleryImage', |
7
|
|
|
); |
8
|
|
|
|
9
|
|
|
private static $db = array( |
|
|
|
|
10
|
|
|
'GalleryDate' => 'Date', |
11
|
|
|
); |
12
|
|
|
|
13
|
|
|
private static $icon = 'ss3gallery/icons/photo.png'; |
|
|
|
|
14
|
|
|
|
15
|
1 |
|
public function getCMSFields() |
16
|
|
|
{ |
17
|
1 |
|
$fields = parent::getCMSFields(); |
18
|
1 |
|
$gridFieldConfig = GridFieldConfig_RecordEditor::create(); |
19
|
|
|
//$gridFieldConfig->addComponent(new GridFieldBulkEditingTools()); |
20
|
1 |
|
$gridFieldConfig->addComponent($gbu = new GridFieldBulkUpload()); |
21
|
1 |
|
$editableFields = array('Title', 'Caption', 'Aperture', 'ShutterSpeed', 'Image'); |
22
|
1 |
|
$gridFieldConfig->addComponent($gbm = new GridFieldBulkManager($editableFields)); |
23
|
1 |
|
$gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder')); |
24
|
1 |
|
$galleryimagesi18n = _t('GalleryImage.PLURALNAME', 'Gallery Images'); |
25
|
|
|
//$gbu->setConfig('fileRelationName','Image'); |
26
|
|
|
|
27
|
1 |
|
$gbu->setUfConfig('folderName', 'galleries/'.$this->ID); |
28
|
1 |
|
$gbm->setConfig('editableFields', $editableFields); |
29
|
|
|
// This is no longer available... $gbm->setConfig('fieldsNameBlacklist', array('Lat', 'Lon', 'ZoomLevel')); |
30
|
1 |
|
$gridfield = new GridField('GalleryImages', $galleryimagesi18n, $this->GalleryImages()->sort('"SortOrder"'), $gridFieldConfig); |
31
|
1 |
|
$fields->addFieldToTab('Root.'.$galleryimagesi18n, $gridfield); |
32
|
|
|
|
33
|
1 |
|
$fields->addFieldToTab('Root.Date', new DateField('GalleryDate')); |
34
|
|
|
|
35
|
1 |
|
return $fields; |
36
|
|
|
} |
37
|
|
|
|
38
|
2 |
|
public function Map() |
|
|
|
|
39
|
|
|
{ |
40
|
2 |
|
$photosWithLocation = $this->GalleryImages()->where('"Lat" != 0 AND "Lon" !=0'); |
41
|
2 |
|
if ($photosWithLocation->count() == 0) { |
42
|
1 |
|
return '<!-- no image locations found -->'; // don't render a map |
43
|
|
|
} |
44
|
1 |
|
$map = $photosWithLocation->getRenderableMap(); |
45
|
1 |
|
$map->setZoom(10); |
46
|
1 |
|
$map->setAdditionalCSSClasses('fullWidthMap'); |
47
|
1 |
|
$map->setShowInlineMapDivStyle(true); |
48
|
1 |
|
$map->setClusterer(true); |
49
|
|
|
|
50
|
1 |
|
$map->setSize('100%', '400px'); |
51
|
1 |
|
return $map; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getGalleryImages() |
|
|
|
|
55
|
|
|
{ |
|
|
|
|
56
|
|
|
return $this->GalleryImages()->sort('SortOrder'); |
57
|
|
|
} |
|
|
|
|
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
|
63
|
|
|
class GalleryPage_Controller extends Page_Controller |
|
|
|
|
64
|
|
|
{ |
65
|
|
|
public static $allowed_actions = array(); |
66
|
|
|
|
67
|
|
|
public function GetGalleryImages() |
|
|
|
|
68
|
|
|
{ |
69
|
|
|
return $this->GalleryImages()->sort('SortOrder'); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
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.