@@ -25,7 +25,7 @@ |
||
25 | 25 | function getCMSFields() { |
26 | 26 | $fields = parent::getCMSFields(); |
27 | 27 | $imagename = _t('PageWithImage.IMAGE', 'Image'); |
28 | - $fields->addFieldToTab( 'Root.'.$imagename, $uf = new UploadField('MainImage', _t('PageWithImage.MAIN_IMAGE', 'Main Image'))); |
|
28 | + $fields->addFieldToTab('Root.'.$imagename, $uf = new UploadField('MainImage', _t('PageWithImage.MAIN_IMAGE', 'Main Image'))); |
|
29 | 29 | $dirname = strtolower($this->ClassName).'s'; |
30 | 30 | $uf->setFolderName($dirname); |
31 | 31 | $fields->addFieldToTab('Root.'.$imagename, new TextField('ImageAttribution', 'Image Credit')); |
@@ -4,77 +4,77 @@ |
||
4 | 4 | */ |
5 | 5 | class PageWithImage extends Page implements RenderableAsPortlet, RenderableAsTwitterCard, SeoInformationProvider { |
6 | 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 | - } |
|
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 | 78 | |
79 | 79 | } |
80 | 80 |
@@ -4,26 +4,26 @@ |
||
4 | 4 | */ |
5 | 5 | class PageWithImageFolder extends PageWithImage implements SeoInformationProvider { |
6 | 6 | |
7 | - //static $allowed_children = array('PageWithImage', 'NearestPOIPage', 'OpenWeatherMapStationsPage','POIMapPage'); |
|
7 | + //static $allowed_children = array('PageWithImage', 'NearestPOIPage', 'OpenWeatherMapStationsPage','POIMapPage'); |
|
8 | 8 | |
9 | 9 | |
10 | 10 | |
11 | - public function getImagesForSeo() { |
|
12 | - $result = new ArrayList(); |
|
13 | - $pwis = $this->owner->AllChildren()->where("ClassName in ( |
|
11 | + public function getImagesForSeo() { |
|
12 | + $result = new ArrayList(); |
|
13 | + $pwis = $this->owner->AllChildren()->where("ClassName in ( |
|
14 | 14 | 'PageWithImage','PageWithImagesFolder')"); |
15 | - foreach ($pwis->getIterator() as $pwi) { |
|
16 | - if ($pwi->MainImageID > 0) { |
|
17 | - $result->push($pwi->MainImage()); |
|
18 | - } |
|
19 | - } |
|
20 | - return $result; |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - public function getLinksForSeo() { |
|
25 | - return false; |
|
26 | - } |
|
15 | + foreach ($pwis->getIterator() as $pwi) { |
|
16 | + if ($pwi->MainImageID > 0) { |
|
17 | + $result->push($pwi->MainImage()); |
|
18 | + } |
|
19 | + } |
|
20 | + return $result; |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + public function getLinksForSeo() { |
|
25 | + return false; |
|
26 | + } |
|
27 | 27 | |
28 | 28 | } |
29 | 29 |
@@ -1,30 +1,30 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class AddImageExtension extends DataExtension { |
4 | - private static $has_one = array( |
|
5 | - 'MainImage' => 'Image' |
|
6 | - ); |
|
4 | + private static $has_one = array( |
|
5 | + 'MainImage' => 'Image' |
|
6 | + ); |
|
7 | 7 | |
8 | 8 | |
9 | - /* |
|
9 | + /* |
|
10 | 10 | Add a Location tab containing the map |
11 | 11 | */ |
12 | - public function updateCMSFields(FieldList $fields) { |
|
13 | - $fields->addFieldToTab('Root.Image', $uf = new UploadField('MainImage', |
|
14 | - _t('PageWithImage.MAIN_IMAGE', 'Main Image'))); |
|
15 | - $uf->setFolderName('pagewithimage'); |
|
16 | - } |
|
12 | + public function updateCMSFields(FieldList $fields) { |
|
13 | + $fields->addFieldToTab('Root.Image', $uf = new UploadField('MainImage', |
|
14 | + _t('PageWithImage.MAIN_IMAGE', 'Main Image'))); |
|
15 | + $uf->setFolderName('pagewithimage'); |
|
16 | + } |
|
17 | 17 | |
18 | 18 | |
19 | - public function getPortletTitle() { |
|
20 | - return $this->owner->Title; |
|
21 | - } |
|
19 | + public function getPortletTitle() { |
|
20 | + return $this->owner->Title; |
|
21 | + } |
|
22 | 22 | |
23 | - public function getPortletImage() { |
|
24 | - return $this->owner->MainImage(); |
|
25 | - } |
|
23 | + public function getPortletImage() { |
|
24 | + return $this->owner->MainImage(); |
|
25 | + } |
|
26 | 26 | |
27 | - public function getPortletCaption() { |
|
28 | - return $this->owner->Title; |
|
29 | - } |
|
27 | + public function getPortletCaption() { |
|
28 | + return $this->owner->Title; |
|
29 | + } |
|
30 | 30 | } |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class PageWithImageFolderTest extends SapphireTest { |
4 | - public function testGetImagesForSeo() { |
|
5 | - $this->markTestSkipped('TODO'); |
|
6 | - } |
|
4 | + public function testGetImagesForSeo() { |
|
5 | + $this->markTestSkipped('TODO'); |
|
6 | + } |
|
7 | 7 | |
8 | - public function testGetLinksForSeo() { |
|
9 | - $this->markTestSkipped('TODO'); |
|
10 | - } |
|
8 | + public function testGetLinksForSeo() { |
|
9 | + $this->markTestSkipped('TODO'); |
|
10 | + } |
|
11 | 11 | |
12 | 12 | } |
@@ -1,44 +1,44 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class PageWithImageTest extends SapphireTest { |
4 | - public function testGetOGImage() { |
|
5 | - $this->markTestSkipped('TODO'); |
|
6 | - } |
|
4 | + public function testGetOGImage() { |
|
5 | + $this->markTestSkipped('TODO'); |
|
6 | + } |
|
7 | 7 | |
8 | - public function testGetCMSFields() { |
|
9 | - $this->markTestSkipped('TODO'); |
|
10 | - } |
|
8 | + public function testGetCMSFields() { |
|
9 | + $this->markTestSkipped('TODO'); |
|
10 | + } |
|
11 | 11 | |
12 | - public function testGetPortletTitle() { |
|
13 | - $this->markTestSkipped('TODO'); |
|
14 | - } |
|
12 | + public function testGetPortletTitle() { |
|
13 | + $this->markTestSkipped('TODO'); |
|
14 | + } |
|
15 | 15 | |
16 | - public function testGetPortletImage() { |
|
17 | - $this->markTestSkipped('TODO'); |
|
18 | - } |
|
16 | + public function testGetPortletImage() { |
|
17 | + $this->markTestSkipped('TODO'); |
|
18 | + } |
|
19 | 19 | |
20 | - public function testGetPortletCaption() { |
|
21 | - $this->markTestSkipped('TODO'); |
|
22 | - } |
|
20 | + public function testGetPortletCaption() { |
|
21 | + $this->markTestSkipped('TODO'); |
|
22 | + } |
|
23 | 23 | |
24 | - public function testGetTwitterTitle() { |
|
25 | - $this->markTestSkipped('TODO'); |
|
26 | - } |
|
24 | + public function testGetTwitterTitle() { |
|
25 | + $this->markTestSkipped('TODO'); |
|
26 | + } |
|
27 | 27 | |
28 | - public function testGetTwitterImage() { |
|
29 | - $this->markTestSkipped('TODO'); |
|
30 | - } |
|
28 | + public function testGetTwitterImage() { |
|
29 | + $this->markTestSkipped('TODO'); |
|
30 | + } |
|
31 | 31 | |
32 | - public function testGetTwitterDescription() { |
|
33 | - $this->markTestSkipped('TODO'); |
|
34 | - } |
|
32 | + public function testGetTwitterDescription() { |
|
33 | + $this->markTestSkipped('TODO'); |
|
34 | + } |
|
35 | 35 | |
36 | - public function testGetImagesForSeo() { |
|
37 | - $this->markTestSkipped('TODO'); |
|
38 | - } |
|
36 | + public function testGetImagesForSeo() { |
|
37 | + $this->markTestSkipped('TODO'); |
|
38 | + } |
|
39 | 39 | |
40 | - public function testGetLinksForSeo() { |
|
41 | - $this->markTestSkipped('TODO'); |
|
42 | - } |
|
40 | + public function testGetLinksForSeo() { |
|
41 | + $this->markTestSkipped('TODO'); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | } |
@@ -1,20 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class AddImageExtensionTest extends SapphireTest { |
4 | - public function testUpdateCMSFields() { |
|
5 | - $this->markTestSkipped('TODO'); |
|
6 | - } |
|
4 | + public function testUpdateCMSFields() { |
|
5 | + $this->markTestSkipped('TODO'); |
|
6 | + } |
|
7 | 7 | |
8 | - public function testGetPortletTitle() { |
|
9 | - $this->markTestSkipped('TODO'); |
|
10 | - } |
|
8 | + public function testGetPortletTitle() { |
|
9 | + $this->markTestSkipped('TODO'); |
|
10 | + } |
|
11 | 11 | |
12 | - public function testGetPortletImage() { |
|
13 | - $this->markTestSkipped('TODO'); |
|
14 | - } |
|
12 | + public function testGetPortletImage() { |
|
13 | + $this->markTestSkipped('TODO'); |
|
14 | + } |
|
15 | 15 | |
16 | - public function testGetPortletCaption() { |
|
17 | - $this->markTestSkipped('TODO'); |
|
18 | - } |
|
16 | + public function testGetPortletCaption() { |
|
17 | + $this->markTestSkipped('TODO'); |
|
18 | + } |
|
19 | 19 | |
20 | 20 | } |