Skip to content

Commit c9ccc0f

Browse files
author
helpfulrobot
committed
Converted to PSR-2
1 parent 1976bd3 commit c9ccc0f

7 files changed

+182
-162
lines changed

code/DataListExtension.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@ public function WithVisible($relation)
3838
return $obj->{$relation}()->OnlyVisible()->exists();
3939
});
4040
}
41-
4241
}

code/ExtraPageFieldsExtension.php

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,54 @@
44
* Class ExtraPageFieldsExtension
55
*
66
*/
7-
class ExtraPageFieldsExtension extends SiteTreeExtension {
7+
class ExtraPageFieldsExtension extends SiteTreeExtension
8+
{
89

9-
private static $db = array(
10-
'SubTitle' => 'Text',
11-
'MetaTitle' => 'Text',
12-
'MenuTarget' => 'Varchar(255)'
13-
);
10+
private static $db = array(
11+
'SubTitle' => 'Text',
12+
'MetaTitle' => 'Text',
13+
'MenuTarget' => 'Varchar(255)'
14+
);
1415

15-
public function updateCMSFields(FieldList $fields) {
16+
public function updateCMSFields(FieldList $fields)
17+
{
1618

17-
//change Page Name label to Primary Heading - H1 - Only if the title hasn't already been changed
18-
/** @var TextField $titleField */
19-
$titleField = $fields->dataFieldByName('Title');
20-
if ($titleField->Title() == 'Page Name') {
21-
$fields->renameField('Title', 'Primary Heading');
22-
}
19+
//change Page Name label to Primary Heading - H1 - Only if the title hasn't already been changed
20+
/** @var TextField $titleField */
21+
$titleField = $fields->dataFieldByName('Title');
22+
if ($titleField->Title() == 'Page Name') {
23+
$fields->renameField('Title', 'Primary Heading');
24+
}
2325

24-
//Add secondary heading - H2
25-
$fields->insertAfter(TextField::create('SubTitle', 'Secondary Heading'), 'Title');
26+
//Add secondary heading - H2
27+
$fields->insertAfter(TextField::create('SubTitle', 'Secondary Heading'), 'Title');
2628

27-
//Move meta fields to their own tab
29+
//Move meta fields to their own tab
2830

29-
/** @var ToggleCompositeField $metaDataChildren */
30-
$metaDataChildren = $fields->fieldByName('Root.Main.Metadata');
31-
$children = array_merge([$metaTitle = TextField::create('MetaTitle')], $metaDataChildren->getChildren()->toArray());
32-
$fields->removeFieldFromTab('Root.Main', 'Metadata');
33-
$fields->addFieldToTab('Root', Tab::create('Metadata'), 'Content');
31+
/** @var ToggleCompositeField $metaDataChildren */
32+
$metaDataChildren = $fields->fieldByName('Root.Main.Metadata');
33+
$children = array_merge([$metaTitle = TextField::create('MetaTitle')], $metaDataChildren->getChildren()->toArray());
34+
$fields->removeFieldFromTab('Root.Main', 'Metadata');
35+
$fields->addFieldToTab('Root', Tab::create('Metadata'), 'Content');
3436

35-
//Add META Title tag to METADATA
36-
$fields->addFieldsToTab('Root.Metadata', $children);
37+
//Add META Title tag to METADATA
38+
$fields->addFieldsToTab('Root.Metadata', $children);
3739

38-
$metaTitle->setDescription('Displayed as the tab/window name; Also displayed in search engine result listings as the page title.<br />
40+
$metaTitle->setDescription('Displayed as the tab/window name; Also displayed in search engine result listings as the page title.<br />
3941
Falls back to the Primary Heading field if not provided.');
40-
41-
}
42-
43-
public function updateSettingsFields(FieldList $fields) {
44-
//quick links option
45-
$fields->addFieldToTab("Root.Settings", new DropdownField('MenuTarget', 'Open page in', [
46-
'' => 'Current Tab (Browser default)',
47-
'_blank' => 'New Tab'
48-
]));
49-
}
50-
51-
Public function MenuTarget(){
52-
return empty($this->owner->MenuTarget) ? '' : "target=\"{$this->owner->MenuTarget}\"";
53-
}
42+
}
43+
44+
public function updateSettingsFields(FieldList $fields)
45+
{
46+
//quick links option
47+
$fields->addFieldToTab("Root.Settings", new DropdownField('MenuTarget', 'Open page in', [
48+
'' => 'Current Tab (Browser default)',
49+
'_blank' => 'New Tab'
50+
]));
51+
}
52+
53+
public function MenuTarget()
54+
{
55+
return empty($this->owner->MenuTarget) ? '' : "target=\"{$this->owner->MenuTarget}\"";
56+
}
5457
}
55-

code/FooterMenuExtension.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44
* Class FooterMenuExtension
55
*
66
*/
7-
class FooterMenuExtension extends SiteTreeExtension {
7+
class FooterMenuExtension extends SiteTreeExtension
8+
{
89

9-
private static $db = array(
10-
'ShowInFooter' => 'Boolean'
11-
);
12-
13-
public function updateSettingsFields(FieldList $fields) {
14-
//quick links option
15-
$fields->addFieldToTab("Root.Settings", new CheckBoxField('ShowInFooter', 'Show in footer menu?'), 'ShowInSearch');
16-
}
17-
18-
Public function FooterPages(){
19-
return SiteTree::get()->filter('ShowInFooter', true);
20-
}
21-
22-
}
10+
private static $db = array(
11+
'ShowInFooter' => 'Boolean'
12+
);
13+
14+
public function updateSettingsFields(FieldList $fields)
15+
{
16+
//quick links option
17+
$fields->addFieldToTab("Root.Settings", new CheckBoxField('ShowInFooter', 'Show in footer menu?'), 'ShowInSearch');
18+
}
19+
20+
public function FooterPages()
21+
{
22+
return SiteTree::get()->filter('ShowInFooter', true);
23+
}
24+
}

code/HelpersTemplateProvider.php

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
<?php
22

3-
class HelpersTemplateProvider implements TemplateGlobalProvider {
4-
/**
5-
* @return array
6-
*/
7-
public static function get_template_global_variables() {
8-
return array(
9-
'Repeat',
10-
'Dump'
11-
);
12-
}
3+
class HelpersTemplateProvider implements TemplateGlobalProvider
4+
{
5+
/**
6+
* @return array
7+
*/
8+
public static function get_template_global_variables()
9+
{
10+
return array(
11+
'Repeat',
12+
'Dump'
13+
);
14+
}
1315

14-
public static function Repeat($times){
15-
$list = new ArrayList();
16-
$formatter = new NumberFormatter('en-NZ', NumberFormatter::SPELLOUT);
17-
for($i = 1; $i <= $times; $i++){
18-
$list->push(array('Num' => $i, 'Word' => ucwords(strtolower($formatter->format($i)))));
19-
}
16+
public static function Repeat($times)
17+
{
18+
$list = new ArrayList();
19+
$formatter = new NumberFormatter('en-NZ', NumberFormatter::SPELLOUT);
20+
for ($i = 1; $i <= $times; $i++) {
21+
$list->push(array('Num' => $i, 'Word' => ucwords(strtolower($formatter->format($i)))));
22+
}
2023

21-
return $list;
22-
}
24+
return $list;
25+
}
2326

24-
public static function Dump($object){
25-
dd($object);
26-
}
27+
public static function Dump($object)
28+
{
29+
dd($object);
30+
}
2731
}

code/ImageExtension.php

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@
55
*
66
* @property Image $owner
77
*/
8-
class ImageExtension extends DataExtension {
8+
class ImageExtension extends DataExtension
9+
{
910

10-
private static $db = [
11-
'AltText' => 'Varchar(255)',
12-
];
11+
private static $db = [
12+
'AltText' => 'Varchar(255)',
13+
];
1314

14-
private static $has_one = [
15-
'OwningPage' => 'Page'
16-
];
15+
private static $has_one = [
16+
'OwningPage' => 'Page'
17+
];
1718

18-
public function updateCMSFields(FieldList $fields) {
19-
20-
Requirements::customCSS(
21-
<<<CSS
19+
public function updateCMSFields(FieldList $fields)
20+
{
21+
Requirements::customCSS(
22+
<<<CSS
2223
form.small .field input.text,
2324
form.small .field textarea,
2425
form.small .field select,
@@ -30,28 +31,27 @@ public function updateCMSFields(FieldList $fields) {
3031
width: 100%;
3132
}
3233
CSS
33-
);
34-
35-
$fields->dataFieldByName('Title')->setTitle(_t('Linkable.TITLE', 'Title Attribute'))
36-
->setDescription('Describe the image to humans');
37-
38-
/** @var TextField $altText */
39-
$fields->addFieldToTab('Root.Main', $altText = TextField::create('AltText', _t('Linkable.SEOTEXT', 'Alt Attribute')), 'Name');
40-
$altText->setDescription('Describe the image to google');
41-
42-
$fields->removeByName('OwningPageID');
43-
}
44-
45-
public function getDownloadAttribute() {
46-
/** @var File $component */
47-
if ($this->owner->Type === 'File' && $component = $this->owner->getComponent($this->owner->Type)) {
48-
if ($component->exists()) {
49-
return ' download="' . $component->Name . '" ';
50-
}
51-
52-
}
53-
54-
return null;
55-
}
56-
57-
}
34+
);
35+
36+
$fields->dataFieldByName('Title')->setTitle(_t('Linkable.TITLE', 'Title Attribute'))
37+
->setDescription('Describe the image to humans');
38+
39+
/** @var TextField $altText */
40+
$fields->addFieldToTab('Root.Main', $altText = TextField::create('AltText', _t('Linkable.SEOTEXT', 'Alt Attribute')), 'Name');
41+
$altText->setDescription('Describe the image to google');
42+
43+
$fields->removeByName('OwningPageID');
44+
}
45+
46+
public function getDownloadAttribute()
47+
{
48+
/** @var File $component */
49+
if ($this->owner->Type === 'File' && $component = $this->owner->getComponent($this->owner->Type)) {
50+
if ($component->exists()) {
51+
return ' download="' . $component->Name . '" ';
52+
}
53+
}
54+
55+
return null;
56+
}
57+
}

code/LinkExtension.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*
66
* @property Link $owner
77
*/
8-
class LinkExtension extends DataExtension {
8+
class LinkExtension extends DataExtension
9+
{
910

1011
private static $db = [
1112
'LinkSeoText' => 'Varchar(255)',
@@ -16,8 +17,8 @@ class LinkExtension extends DataExtension {
1617
'OwningPage' => 'Page'
1718
];
1819

19-
public function updateCMSFields(FieldList $fields) {
20-
20+
public function updateCMSFields(FieldList $fields)
21+
{
2122
$fields->dataFieldByName('Title')->setTitle(_t('Linkable.TITLE', 'Link Text'));
2223

2324
$fields->dataFieldByName('OpenInNewWindow')->hideIf("Type")->isEqualTo("File")->end();
@@ -33,40 +34,45 @@ public function updateCMSFields(FieldList $fields) {
3334
$fields->removeByName('OwningPageID');
3435
}
3536

36-
public function getDownloadAttribute() {
37+
public function getDownloadAttribute()
38+
{
3739
/** @var File $component */
3840
if ($this->owner->Type === 'File' && $component = $this->owner->getComponent($this->owner->Type)) {
3941
if ($component->exists()) {
4042
return ' download="' . $component->Name . '" ';
4143
}
42-
4344
}
4445

4546
return null;
4647
}
4748

48-
public function getTitleAttribute() {
49+
public function getTitleAttribute()
50+
{
4951
return ' title="' . ($this->owner->LinkSeoText ?: $this->owner->Title) . '" ';
5052
}
5153

52-
public function getAttributes(){
53-
54+
public function getAttributes()
55+
{
5456
return join(' ', [$this->owner->getTargetAttr(), $this->getDownloadAttribute(), $this->getTitleAttribute()]);
5557
}
5658

57-
public function canView($member = null) {
59+
public function canView($member = null)
60+
{
5861
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
5962
}
6063

61-
public function canEdit($member = null) {
64+
public function canEdit($member = null)
65+
{
6266
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
6367
}
6468

65-
public function canDelete($member = null) {
69+
public function canDelete($member = null)
70+
{
6671
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
6772
}
6873

69-
public function canCreate($member = null) {
74+
public function canCreate($member = null)
75+
{
7076
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
7177
}
7278
}

0 commit comments

Comments
 (0)