|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Defines the SupportingProjectPage page type - initial code created by ss generator |
|
4
|
|
|
*/ |
|
5
|
|
|
class PageWithImage extends Page implements RenderableAsPortlet, RenderableAsTwitterCard, SeoInformationProvider { |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
// Brief summary to show on facebook and twitter when linking |
|
8
|
|
|
private static $db = array( |
|
|
|
|
|
|
9
|
|
|
'ImageAttribution' => 'Varchar(255)', |
|
10
|
|
|
'BriefIntroduction' => 'HTMLText' |
|
11
|
|
|
); |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
static $has_one = array( |
|
|
|
|
|
|
15
|
|
|
'MainImage' => 'Image' |
|
16
|
|
|
); |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
// for rendering thumbnail when linked in facebook |
|
20
|
|
|
function getOGImage() { |
|
|
|
|
|
|
21
|
|
|
return $this->MainImage(); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
function getCMSFields() { |
|
|
|
|
|
|
26
|
|
|
$fields = parent::getCMSFields(); |
|
27
|
|
|
$imagename = _t('PageWithImage.IMAGE', 'Image'); |
|
28
|
|
|
$fields->addFieldToTab( 'Root.'.$imagename, $uf = new UploadField('MainImage', _t('PageWithImage.MAIN_IMAGE', 'Main Image'))); |
|
29
|
|
|
$dirname = strtolower($this->ClassName).'s'; |
|
30
|
|
|
$uf->setFolderName($dirname); |
|
31
|
|
|
$fields->addFieldToTab('Root.'.$imagename, new TextField('ImageAttribution', 'Image Credit')); |
|
32
|
|
|
$fields->addFieldToTab('Root', new TextAreaField('BriefIntroduction', 'Brief description of the page for Twitter and Facebook purposes'), 'Content'); |
|
33
|
|
|
return $fields; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
public function getPortletTitle() { |
|
38
|
|
|
return $this->Title; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getPortletImage() { |
|
42
|
|
|
return $this->MainImage(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function getPortletCaption() { |
|
46
|
|
|
return $this->BriefIntroduction; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function getTwitterTitle() { |
|
50
|
|
|
return $this->Title; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function getTwitterImage() { |
|
54
|
|
|
return $this->MainImage(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function getTwitterDescription() { |
|
58
|
|
|
return Convert::html2raw($this->BriefIntroduction); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function getImagesForSeo() { |
|
62
|
|
|
$result = new ArrayList(); |
|
63
|
|
|
$mainimage = $this->owner->MainImage(); |
|
64
|
|
|
if ($mainimage) { |
|
65
|
|
|
$result->push($mainimage); |
|
66
|
|
|
} |
|
67
|
|
|
return $result; |
|
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
public function getLinksForSeo() { |
|
72
|
|
|
$result = false; |
|
73
|
|
|
if ($this->hasExtension('LinksExtension')) { |
|
74
|
|
|
$result = $this->Links(); |
|
75
|
|
|
} |
|
76
|
|
|
return $result; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
class PageWithImage_Controller extends Page_Controller { |
|
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
} |
|
84
|
|
|
|
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.