Passed
Pull Request — 2.3 (#194)
by Garion
01:54
created
src/Extensions/TaxonomyTermExtension.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@
 block discarded – undo
10 10
 class TaxonomyTermExtension extends DataExtension
11 11
 {
12 12
 
13
-    private static $api_access = true;
13
+	private static $api_access = true;
14 14
 
15
-    private static $belongs_many_many = array(
16
-        'Pages' => BasePage::class
17
-    );
15
+	private static $belongs_many_many = array(
16
+		'Pages' => BasePage::class
17
+	);
18 18
 
19
-    public function updateCMSFields(FieldList $fields)
20
-    {
21
-        $pagesGridField = $fields->dataFieldByName('Pages');
22
-        if ($pagesGridField) {
23
-            $pagesGridField->getConfig()->removeComponentsByType(GridFieldAddNewButton::class);
24
-        }
25
-    }
19
+	public function updateCMSFields(FieldList $fields)
20
+	{
21
+		$pagesGridField = $fields->dataFieldByName('Pages');
22
+		if ($pagesGridField) {
23
+			$pagesGridField->getConfig()->removeComponentsByType(GridFieldAddNewButton::class);
24
+		}
25
+	}
26 26
 }
Please login to merge, or discard this patch.
src/Extensions/CwpSiteSummaryExtension.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -5,41 +5,41 @@
 block discarded – undo
5 5
  */
6 6
 class CwpSiteSummaryExtension extends Extension
7 7
 {
8
-    /**
9
-     * Updates the modules used for the version label by:
10
-     *  - Removing SS Framework
11
-     *  - Adding CWP
12
-     *  - Relabelling SS CMS
13
-     *
14
-     * @param array $modules
15
-     */
16
-    public function updateVersionModules(&$modules)
17
-    {
18
-        unset($modules['silverstripe/framework']);
19
-        $modules = ['cwp/cwp' => 'CWP'] + $modules;
20
-        $modules['silverstripe/cms'] = 'SilverStripe CMS';
21
-    }
8
+	/**
9
+	 * Updates the modules used for the version label by:
10
+	 *  - Removing SS Framework
11
+	 *  - Adding CWP
12
+	 *  - Relabelling SS CMS
13
+	 *
14
+	 * @param array $modules
15
+	 */
16
+	public function updateVersionModules(&$modules)
17
+	{
18
+		unset($modules['silverstripe/framework']);
19
+		$modules = ['cwp/cwp' => 'CWP'] + $modules;
20
+		$modules['silverstripe/cms'] = 'SilverStripe CMS';
21
+	}
22 22
 
23
-    /**
24
-     * Updates the dropdown filter used to filter supported packages by renaming the labels (replaces the existing
25
-     * filter options)
26
-     *
27
-     * @param GridFieldDropdownFilter $dropdownFilter
28
-     */
29
-    public function updateDropdownFilterOptions($dropdownFilter)
30
-    {
31
-        $dropdownFilter->removeFilterOption('supported');
32
-        $dropdownFilter->removeFilterOption('unsupported');
23
+	/**
24
+	 * Updates the dropdown filter used to filter supported packages by renaming the labels (replaces the existing
25
+	 * filter options)
26
+	 *
27
+	 * @param GridFieldDropdownFilter $dropdownFilter
28
+	 */
29
+	public function updateDropdownFilterOptions($dropdownFilter)
30
+	{
31
+		$dropdownFilter->removeFilterOption('supported');
32
+		$dropdownFilter->removeFilterOption('unsupported');
33 33
 
34
-        $dropdownFilter->addFilterOption(
35
-            'supported',
36
-            _t(__CLASS__ . '.FilterSupported', 'CWP recipe modules'),
37
-            ['Supported' => true]
38
-        );
39
-        $dropdownFilter->addFilterOption(
40
-            'unsupported',
41
-            _t(__CLASS__ . '.FilterUnsupported', 'Non CWP modules'),
42
-            ['Supported' => false]
43
-        );
44
-    }
34
+		$dropdownFilter->addFilterOption(
35
+			'supported',
36
+			_t(__CLASS__ . '.FilterSupported', 'CWP recipe modules'),
37
+			['Supported' => true]
38
+		);
39
+		$dropdownFilter->addFilterOption(
40
+			'unsupported',
41
+			_t(__CLASS__ . '.FilterUnsupported', 'Non CWP modules'),
42
+			['Supported' => false]
43
+		);
44
+	}
45 45
 }
Please login to merge, or discard this patch.
src/Extensions/MaintenanceProxyExtension.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -13,48 +13,48 @@
 block discarded – undo
13 13
  */
14 14
 class MaintenanceProxyExtension extends Extension
15 15
 {
16
-    /**
17
-     * Configures required environment settings for Composer's use, applies to
18
-     * {@link \BringYourOwnIdeas\Maintenance\Util\ComposerLoader} and is applied before ComposerLoaderExtension in
19
-     * bringyourownideas/silverstripe-composer-update-checker to ensure the proxy information is set before Composer
20
-     * is created
21
-     */
22
-    public function onAfterBuild()
23
-    {
24
-        // Provide access for Composer's StreamContextFactory, since it creates its own stream context
25
-        if ($proxy = $this->getCwpProxy()) {
26
-            $_SERVER['CGI_HTTP_PROXY'] = $proxy;
27
-        }
28
-    }
16
+	/**
17
+	 * Configures required environment settings for Composer's use, applies to
18
+	 * {@link \BringYourOwnIdeas\Maintenance\Util\ComposerLoader} and is applied before ComposerLoaderExtension in
19
+	 * bringyourownideas/silverstripe-composer-update-checker to ensure the proxy information is set before Composer
20
+	 * is created
21
+	 */
22
+	public function onAfterBuild()
23
+	{
24
+		// Provide access for Composer's StreamContextFactory, since it creates its own stream context
25
+		if ($proxy = $this->getCwpProxy()) {
26
+			$_SERVER['CGI_HTTP_PROXY'] = $proxy;
27
+		}
28
+	}
29 29
 
30
-    /**
31
-     * Provide proxy options for {@link \BringYourOwnIdeas\Maintenance\Util\ApiLoader} instances to use in
32
-     * their Guzzle clients
33
-     *
34
-     * @param array $options
35
-     */
36
-    public function updateClientOptions(&$options)
37
-    {
38
-        if ($proxy = $this->getCwpProxy()) {
39
-            $options['proxy'] = $proxy;
40
-        }
41
-    }
30
+	/**
31
+	 * Provide proxy options for {@link \BringYourOwnIdeas\Maintenance\Util\ApiLoader} instances to use in
32
+	 * their Guzzle clients
33
+	 *
34
+	 * @param array $options
35
+	 */
36
+	public function updateClientOptions(&$options)
37
+	{
38
+		if ($proxy = $this->getCwpProxy()) {
39
+			$options['proxy'] = $proxy;
40
+		}
41
+	}
42 42
 
43
-    /**
44
-     * Returns a formatted CWP proxy string, e.g. `tcp://proxy.cwp.govt.nz:1234`
45
-     *
46
-     * @return string
47
-     */
48
-    protected function getCwpProxy()
49
-    {
50
-        if (!Environment::getEnv('SS_OUTBOUND_PROXY') || !Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) {
51
-            return '';
52
-        }
43
+	/**
44
+	 * Returns a formatted CWP proxy string, e.g. `tcp://proxy.cwp.govt.nz:1234`
45
+	 *
46
+	 * @return string
47
+	 */
48
+	protected function getCwpProxy()
49
+	{
50
+		if (!Environment::getEnv('SS_OUTBOUND_PROXY') || !Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) {
51
+			return '';
52
+		}
53 53
 
54
-        return sprintf(
55
-            'tcp://%s:%d',
56
-            Environment::getEnv('SS_OUTBOUND_PROXY'),
57
-            Environment::getEnv('SS_OUTBOUND_PROXY_PORT')
58
-        );
59
-    }
54
+		return sprintf(
55
+			'tcp://%s:%d',
56
+			Environment::getEnv('SS_OUTBOUND_PROXY'),
57
+			Environment::getEnv('SS_OUTBOUND_PROXY_PORT')
58
+		);
59
+	}
60 60
 }
Please login to merge, or discard this patch.
tests/Report/CwpStatsReportTest.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -11,42 +11,42 @@
 block discarded – undo
11 11
 
12 12
 class CwpStatsReportTest extends SapphireTest
13 13
 {
14
-    protected static $fixture_file = 'CwpStatsReportTest.yml';
15
-
16
-    protected function setUp()
17
-    {
18
-        Config::modify()->set(SiteTree::class, 'create_default_pages', false);
19
-
20
-        parent::setUp();
21
-    }
22
-
23
-    public function testCount()
24
-    {
25
-        // Publish all pages apart from page3.
26
-        $this->objFromFixture(Page::class, 'page1')->publishRecursive();
27
-        $this->objFromFixture(Page::class, 'page2')->publishRecursive();
28
-        $this->objFromFixture(Page::class, 'page3')->publishRecursive();
29
-
30
-        // Add page5s to a subsite, if the module is installed.
31
-        $page5s = $this->objFromFixture(Page::class, 'page5s');
32
-        if (class_exists(Subsite::class)) {
33
-            $subsite = Subsite::create();
34
-            $subsite->Title = 'subsite';
35
-            $subsite->write();
36
-
37
-            $page5s->SubsiteID = $subsite->ID;
38
-            $page5s->write();
39
-        }
40
-        $page5s->publishRecursive();
41
-
42
-        $report = CwpStatsReport::create();
43
-        $records = $report->sourceRecords([])->toArray();
44
-        $i = 0;
45
-        $this->assertEquals(4, $records[$i++]['Count'], 'Four pages in total, across locales, subsites, live only.');
46
-        if (class_exists(Subsite::class)) {
47
-            $this->assertEquals(3, $records[$i++]['Count'], 'Three pages in the main site, if subsites installed.');
48
-            $this->assertEquals(1, $records[$i++]['Count'], 'One page in the subsite, if subsites installed');
49
-        }
50
-        $this->assertEquals(1, $records[$i++]['Count'], 'One file in total.');
51
-    }
14
+	protected static $fixture_file = 'CwpStatsReportTest.yml';
15
+
16
+	protected function setUp()
17
+	{
18
+		Config::modify()->set(SiteTree::class, 'create_default_pages', false);
19
+
20
+		parent::setUp();
21
+	}
22
+
23
+	public function testCount()
24
+	{
25
+		// Publish all pages apart from page3.
26
+		$this->objFromFixture(Page::class, 'page1')->publishRecursive();
27
+		$this->objFromFixture(Page::class, 'page2')->publishRecursive();
28
+		$this->objFromFixture(Page::class, 'page3')->publishRecursive();
29
+
30
+		// Add page5s to a subsite, if the module is installed.
31
+		$page5s = $this->objFromFixture(Page::class, 'page5s');
32
+		if (class_exists(Subsite::class)) {
33
+			$subsite = Subsite::create();
34
+			$subsite->Title = 'subsite';
35
+			$subsite->write();
36
+
37
+			$page5s->SubsiteID = $subsite->ID;
38
+			$page5s->write();
39
+		}
40
+		$page5s->publishRecursive();
41
+
42
+		$report = CwpStatsReport::create();
43
+		$records = $report->sourceRecords([])->toArray();
44
+		$i = 0;
45
+		$this->assertEquals(4, $records[$i++]['Count'], 'Four pages in total, across locales, subsites, live only.');
46
+		if (class_exists(Subsite::class)) {
47
+			$this->assertEquals(3, $records[$i++]['Count'], 'Three pages in the main site, if subsites installed.');
48
+			$this->assertEquals(1, $records[$i++]['Count'], 'One page in the subsite, if subsites installed');
49
+		}
50
+		$this->assertEquals(1, $records[$i++]['Count'], 'One file in total.');
51
+	}
52 52
 }
Please login to merge, or discard this patch.
src/Extensions/CwpCommentingExtension.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -14,20 +14,20 @@
 block discarded – undo
14 14
  */
15 15
 class CwpCommentingExtension extends Extension
16 16
 {
17
-    public function alterCommentForm(Form $form)
18
-    {
19
-        $fields = $form->Fields();
17
+	public function alterCommentForm(Form $form)
18
+	{
19
+		$fields = $form->Fields();
20 20
 
21
-        if ($emailField = $fields->dataFieldByName('Email')) {
22
-            $emailField
23
-                ->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', 'Email'))
24
-                ->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.'));
25
-        }
21
+		if ($emailField = $fields->dataFieldByName('Email')) {
22
+			$emailField
23
+				->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', 'Email'))
24
+				->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.'));
25
+		}
26 26
 
27
-        if ($urlField = $fields->dataFieldByName('URL')) {
28
-            $urlField
29
-                ->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)'))
30
-                ->setAttribute('placeholder', 'http://');
31
-        }
32
-    }
27
+		if ($urlField = $fields->dataFieldByName('URL')) {
28
+			$urlField
29
+				->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)'))
30
+				->setAttribute('placeholder', 'http://');
31
+		}
32
+	}
33 33
 }
Please login to merge, or discard this patch.
src/Model/RelatedPageLink.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -8,30 +8,30 @@
 block discarded – undo
8 8
 
9 9
 class RelatedPageLink extends DataObject
10 10
 {
11
-    private static $table_name = 'BasePage_RelatedPages';
11
+	private static $table_name = 'BasePage_RelatedPages';
12 12
 
13
-    private static $extensions = [
14
-        Versioned::class,
15
-    ];
13
+	private static $extensions = [
14
+		Versioned::class,
15
+	];
16 16
 
17
-    private static $db = [
18
-        'SortOrder' => 'Int',
19
-    ];
17
+	private static $db = [
18
+		'SortOrder' => 'Int',
19
+	];
20 20
 
21
-    /**
22
-     * For backwards compatibility these must match a traditional 'many_many' definition.
23
-     * This was BasePage.RelatedPages => BasePage
24
-     * ManyMany relations are normally joined by ${DefiningClass}ID && ${RelatedClass}ID
25
-     * excepting in the case where ${DefiningClass} === ${RelatedClass}
26
-     * Then the 'related class' column changes from ${RelatedClass}ID to "ChildID".
27
-     *
28
-     * {@see SilverStripe\ORM\DataObjectSchema->parseManyManyComponent()}
29
-     *
30
-     * @var array
31
-     * @config
32
-     */
33
-    private static $has_one = [
34
-        'BasePage' => BasePage::class,
35
-        'Child' => BasePage::class,
36
-    ];
21
+	/**
22
+	 * For backwards compatibility these must match a traditional 'many_many' definition.
23
+	 * This was BasePage.RelatedPages => BasePage
24
+	 * ManyMany relations are normally joined by ${DefiningClass}ID && ${RelatedClass}ID
25
+	 * excepting in the case where ${DefiningClass} === ${RelatedClass}
26
+	 * Then the 'related class' column changes from ${RelatedClass}ID to "ChildID".
27
+	 *
28
+	 * {@see SilverStripe\ORM\DataObjectSchema->parseManyManyComponent()}
29
+	 *
30
+	 * @var array
31
+	 * @config
32
+	 */
33
+	private static $has_one = [
34
+		'BasePage' => BasePage::class,
35
+		'Child' => BasePage::class,
36
+	];
37 37
 }
Please login to merge, or discard this patch.
src/Extensions/CustomSiteConfig.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -12,58 +12,58 @@
 block discarded – undo
12 12
  */
13 13
 class CustomSiteConfig extends DataExtension
14 14
 {
15
-    private static $db = array(
16
-        'GACode' => 'Varchar(16)',
17
-        'FacebookURL' => 'Varchar(256)', // multitude of ways to link to Facebook accounts, best to leave it open.
18
-        'TwitterUsername' => 'Varchar(16)', // max length of Twitter username 15
19
-    );
15
+	private static $db = array(
16
+		'GACode' => 'Varchar(16)',
17
+		'FacebookURL' => 'Varchar(256)', // multitude of ways to link to Facebook accounts, best to leave it open.
18
+		'TwitterUsername' => 'Varchar(16)', // max length of Twitter username 15
19
+	);
20 20
 
21
-    public function updateCMSFields(FieldList $fields)
22
-    {
23
-        $fields->addFieldToTab(
24
-            'Root.Main',
25
-            $gaCode = TextField::create(
26
-                'GACode',
27
-                _t(__CLASS__ . '.GaField', 'Google Analytics account')
28
-            )
29
-        );
21
+	public function updateCMSFields(FieldList $fields)
22
+	{
23
+		$fields->addFieldToTab(
24
+			'Root.Main',
25
+			$gaCode = TextField::create(
26
+				'GACode',
27
+				_t(__CLASS__ . '.GaField', 'Google Analytics account')
28
+			)
29
+		);
30 30
 
31
-        $gaCode->setDescription(
32
-            DBField::create_field('HTMLFragment', _t(
33
-                __CLASS__ . '.GaFieldDesc',
34
-                'Account number to be used all across the site (in the format <strong>UA-XXXXX-X</strong>)'
35
-            ))
36
-        );
31
+		$gaCode->setDescription(
32
+			DBField::create_field('HTMLFragment', _t(
33
+				__CLASS__ . '.GaFieldDesc',
34
+				'Account number to be used all across the site (in the format <strong>UA-XXXXX-X</strong>)'
35
+			))
36
+		);
37 37
 
38
-        $fields->findOrMakeTab('Root.SocialMedia', _t(__CLASS__ . '.SocialMediaTab', 'Social Media'));
38
+		$fields->findOrMakeTab('Root.SocialMedia', _t(__CLASS__ . '.SocialMediaTab', 'Social Media'));
39 39
 
40
-        $fields->addFieldToTab(
41
-            'Root.SocialMedia',
42
-            $facebookURL = TextField::create(
43
-                'FacebookURL',
44
-                _t(__CLASS__ . '.FbField', 'Facebook UID or username')
45
-            )
46
-        );
47
-        $facebookURL->setDescription(
48
-            DBField::create_field('HTMLFragment', _t(
49
-                __CLASS__ . '.FbFieldDesc',
50
-                'Facebook link (everything after the "http://facebook.com/", eg http://facebook.com/'
51
-                . '<strong>username</strong> or http://facebook.com/<strong>pages/108510539573</strong>)'
52
-            ))
53
-        );
40
+		$fields->addFieldToTab(
41
+			'Root.SocialMedia',
42
+			$facebookURL = TextField::create(
43
+				'FacebookURL',
44
+				_t(__CLASS__ . '.FbField', 'Facebook UID or username')
45
+			)
46
+		);
47
+		$facebookURL->setDescription(
48
+			DBField::create_field('HTMLFragment', _t(
49
+				__CLASS__ . '.FbFieldDesc',
50
+				'Facebook link (everything after the "http://facebook.com/", eg http://facebook.com/'
51
+				. '<strong>username</strong> or http://facebook.com/<strong>pages/108510539573</strong>)'
52
+			))
53
+		);
54 54
 
55
-        $fields->addFieldToTab(
56
-            'Root.SocialMedia',
57
-            $twitterUsername = TextField::create(
58
-                'TwitterUsername',
59
-                _t(__CLASS__ . '.TwitterField', 'Twitter username')
60
-            )
61
-        );
62
-        $twitterUsername->setDescription(
63
-            DBField::create_field('HTMLFragment', _t(
64
-                __CLASS__ . '.TwitterFieldDesc',
65
-                'Twitter username (eg, http://twitter.com/<strong>username</strong>)'
66
-            ))
67
-        );
68
-    }
55
+		$fields->addFieldToTab(
56
+			'Root.SocialMedia',
57
+			$twitterUsername = TextField::create(
58
+				'TwitterUsername',
59
+				_t(__CLASS__ . '.TwitterField', 'Twitter username')
60
+			)
61
+		);
62
+		$twitterUsername->setDescription(
63
+			DBField::create_field('HTMLFragment', _t(
64
+				__CLASS__ . '.TwitterFieldDesc',
65
+				'Twitter username (eg, http://twitter.com/<strong>username</strong>)'
66
+			))
67
+		);
68
+	}
69 69
 }
Please login to merge, or discard this patch.
src/PageTypes/BasePage.php 1 patch
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -31,147 +31,147 @@
 block discarded – undo
31 31
 
32 32
 class BasePage extends SiteTree
33 33
 {
34
-    private static $icon = 'cwp/cwp:images/icons/sitetree_images/page.png';
35
-
36
-    /**
37
-     * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide"
38
-     *
39
-     * {@inheritDoc}
40
-     */
41
-    private static $hide_ancestor = BasePage::class;
42
-
43
-    private static $api_access = [
44
-        'view' => [
45
-            'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
46
-            'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
47
-        ],
48
-        'edit' => [
49
-            'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
50
-            'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
51
-        ],
52
-    ];
53
-
54
-    private static $table_name = 'BasePage';
55
-
56
-    /**
57
-     * @config
58
-     * @var string
59
-     */
60
-    private static $related_pages_title = 'Related pages';
61
-
62
-    private static $many_many = [
63
-        'Terms' => TaxonomyTerm::class,
64
-        'RelatedPagesThrough' => [
65
-            'through' => RelatedPageLink::class,
66
-            'from' => 'BasePage',
67
-            'to' => 'Child',
68
-        ]
69
-    ];
70
-
71
-    private static $owns = [
72
-        'RelatedPagesThrough',
73
-    ];
74
-
75
-    private static $belongs_many_many = [
76
-        'SimilarPages' => BasePage::class
77
-    ];
78
-
79
-    /**
80
-     * @var array
81
-     * @config
82
-     */
83
-    private static $many_many_extraFields = [
84
-        'RelatedPages' => [
85
-            'SortOrder' => 'Int',
86
-        ],
87
-    ];
88
-
89
-    private static $plural_name = 'Base Pages';
90
-
91
-    /**
92
-     * Get the footer holder.
93
-     */
94
-    public function getFooter()
95
-    {
96
-        return FooterHolder::get_one(FooterHolder::class);
97
-    }
98
-
99
-    /**
100
-     * @deprecated 2.2.0:3.0.0 Please use RelatedPagesThrough() instead
101
-     */
102
-    public function RelatedPages()
103
-    {
104
-        return $this->getManyManyComponents('RelatedPagesThrough');
105
-    }
106
-
107
-    public function RelatedPagesTitle()
108
-    {
109
-        return $this->config()->get('related_pages_title');
110
-    }
111
-
112
-    public function getCMSFields()
113
-    {
114
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
115
-            // Related Pages
116
-            $components = GridFieldConfig_RelationEditor::create();
117
-            $components->removeComponentsByType(GridFieldAddNewButton::class);
118
-            $components->removeComponentsByType(GridFieldEditButton::class);
119
-            $components->removeComponentsByType(GridFieldFilterHeader::class);
120
-            $components->addComponent(new GridFieldOrderableRows('SortOrder'));
121
-
122
-            /** @var GridFieldDataColumns $dataColumns */
123
-            $dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
124
-            $dataColumns->setDisplayFields([
125
-                'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'),
126
-                'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type')
127
-            ]);
128
-
129
-            $fields->findOrMakeTab(
130
-                'Root.RelatedPages',
131
-                _t(__CLASS__ . '.RelatedPages', 'Related pages')
132
-            );
133
-            $fields->addFieldToTab(
134
-                'Root.RelatedPages',
135
-                GridField::create(
136
-                    'RelatedPages',
137
-                    _t(__CLASS__ . '.RelatedPages', 'Related pages'),
138
-                    $this->RelatedPagesThrough(),
139
-                    $components
140
-                )
141
-            );
142
-
143
-            // Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc)
144
-            $hasMany = $this->hasMany();
145
-            $manyMany = $this->manyMany();
146
-            if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) {
147
-                $fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags'));
148
-                $fields->addFieldToTab(
149
-                    'Root.Tags',
150
-                    TreeMultiselectField::create(
151
-                        'Terms',
152
-                        _t(__CLASS__ . '.Terms', 'Terms'),
153
-                        TaxonomyTerm::class
154
-                    )->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms'))
155
-                );
156
-            }
157
-        });
158
-        return parent::getCMSFields();
159
-    }
160
-
161
-    /**
162
-     * Returns the native language name for the selected locale/language, empty string if Fluent is not available
163
-     *
164
-     * @return string
165
-     */
166
-    public function getSelectedLanguage()
167
-    {
168
-        if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) {
169
-            return '';
170
-        }
171
-
172
-        /** @var ArrayData $information */
173
-        $information = $this->LocaleInformation(FluentState::singleton()->getLocale());
174
-
175
-        return $information->LanguageNative;
176
-    }
34
+	private static $icon = 'cwp/cwp:images/icons/sitetree_images/page.png';
35
+
36
+	/**
37
+	 * Hide this page type from the CMS. hide_ancestor is slightly misnamed, should really be just "hide"
38
+	 *
39
+	 * {@inheritDoc}
40
+	 */
41
+	private static $hide_ancestor = BasePage::class;
42
+
43
+	private static $api_access = [
44
+		'view' => [
45
+			'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
46
+			'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
47
+		],
48
+		'edit' => [
49
+			'Locale', 'URLSegment', 'Title', 'MenuTitle', 'Content', 'MetaDescription',
50
+			'ExtraMenu', 'Sort', 'Version', 'ParentID', 'ID'
51
+		],
52
+	];
53
+
54
+	private static $table_name = 'BasePage';
55
+
56
+	/**
57
+	 * @config
58
+	 * @var string
59
+	 */
60
+	private static $related_pages_title = 'Related pages';
61
+
62
+	private static $many_many = [
63
+		'Terms' => TaxonomyTerm::class,
64
+		'RelatedPagesThrough' => [
65
+			'through' => RelatedPageLink::class,
66
+			'from' => 'BasePage',
67
+			'to' => 'Child',
68
+		]
69
+	];
70
+
71
+	private static $owns = [
72
+		'RelatedPagesThrough',
73
+	];
74
+
75
+	private static $belongs_many_many = [
76
+		'SimilarPages' => BasePage::class
77
+	];
78
+
79
+	/**
80
+	 * @var array
81
+	 * @config
82
+	 */
83
+	private static $many_many_extraFields = [
84
+		'RelatedPages' => [
85
+			'SortOrder' => 'Int',
86
+		],
87
+	];
88
+
89
+	private static $plural_name = 'Base Pages';
90
+
91
+	/**
92
+	 * Get the footer holder.
93
+	 */
94
+	public function getFooter()
95
+	{
96
+		return FooterHolder::get_one(FooterHolder::class);
97
+	}
98
+
99
+	/**
100
+	 * @deprecated 2.2.0:3.0.0 Please use RelatedPagesThrough() instead
101
+	 */
102
+	public function RelatedPages()
103
+	{
104
+		return $this->getManyManyComponents('RelatedPagesThrough');
105
+	}
106
+
107
+	public function RelatedPagesTitle()
108
+	{
109
+		return $this->config()->get('related_pages_title');
110
+	}
111
+
112
+	public function getCMSFields()
113
+	{
114
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
115
+			// Related Pages
116
+			$components = GridFieldConfig_RelationEditor::create();
117
+			$components->removeComponentsByType(GridFieldAddNewButton::class);
118
+			$components->removeComponentsByType(GridFieldEditButton::class);
119
+			$components->removeComponentsByType(GridFieldFilterHeader::class);
120
+			$components->addComponent(new GridFieldOrderableRows('SortOrder'));
121
+
122
+			/** @var GridFieldDataColumns $dataColumns */
123
+			$dataColumns = $components->getComponentByType(GridFieldDataColumns::class);
124
+			$dataColumns->setDisplayFields([
125
+				'Title' => _t(__CLASS__ . '.ColumnTitle', 'Title'),
126
+				'ClassName' => _t(__CLASS__ . '.ColumnPageType', 'Page Type')
127
+			]);
128
+
129
+			$fields->findOrMakeTab(
130
+				'Root.RelatedPages',
131
+				_t(__CLASS__ . '.RelatedPages', 'Related pages')
132
+			);
133
+			$fields->addFieldToTab(
134
+				'Root.RelatedPages',
135
+				GridField::create(
136
+					'RelatedPages',
137
+					_t(__CLASS__ . '.RelatedPages', 'Related pages'),
138
+					$this->RelatedPagesThrough(),
139
+					$components
140
+				)
141
+			);
142
+
143
+			// Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc)
144
+			$hasMany = $this->hasMany();
145
+			$manyMany = $this->manyMany();
146
+			if (!isset($hasMany['Tags']) && !isset($manyMany['Tags'])) {
147
+				$fields->findOrMakeTab('Root.Tags', _t(__CLASS__ . '.TagsTabTitle', 'Tags'));
148
+				$fields->addFieldToTab(
149
+					'Root.Tags',
150
+					TreeMultiselectField::create(
151
+						'Terms',
152
+						_t(__CLASS__ . '.Terms', 'Terms'),
153
+						TaxonomyTerm::class
154
+					)->setDescription(_t(__CLASS__ . '.TermsDescription', 'Click to search for additional terms'))
155
+				);
156
+			}
157
+		});
158
+		return parent::getCMSFields();
159
+	}
160
+
161
+	/**
162
+	 * Returns the native language name for the selected locale/language, empty string if Fluent is not available
163
+	 *
164
+	 * @return string
165
+	 */
166
+	public function getSelectedLanguage()
167
+	{
168
+		if (!class_exists(Locale::class) || !$this->hasMethod('Locales')) {
169
+			return '';
170
+		}
171
+
172
+		/** @var ArrayData $information */
173
+		$information = $this->LocaleInformation(FluentState::singleton()->getLocale());
174
+
175
+		return $information->LanguageNative;
176
+	}
177 177
 }
Please login to merge, or discard this patch.
src/PageTypes/EventPage.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -12,81 +12,81 @@
 block discarded – undo
12 12
 
13 13
 class EventPage extends DatedUpdatePage
14 14
 {
15
-    private static $description = 'Describes an event occurring on a specific date.';
16
-
17
-    private static $default_parent = EventHolder::class;
18
-
19
-    private static $can_be_root = false;
20
-
21
-    private static $icon_class = 'font-icon-p-event';
22
-
23
-    private static $singular_name = 'Event Page';
24
-
25
-    private static $plural_name = 'Event Pages';
26
-
27
-    private static $db = [
28
-        'StartTime' => 'Time',
29
-        'EndTime' => 'Time',
30
-        'Location' => 'Text',
31
-    ];
32
-
33
-    private static $table_name = 'EventPage';
34
-
35
-    public function fieldLabels($includerelations = true)
36
-    {
37
-        $labels = parent::fieldLabels($includerelations);
38
-        $labels['StartTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.StartTimeFieldLabel', 'Start Time');
39
-        $labels['EndTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.EndTimeFieldLabel', 'End Time');
40
-        $labels['Location'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.LocationFieldLabel', 'Location');
41
-
42
-        return $labels;
43
-    }
44
-
45
-    /**
46
-     * Add the default for the Date being the current day.
47
-     */
48
-    public function populateDefaults()
49
-    {
50
-        if (!isset($this->Date) || $this->Date === null) {
51
-            $this->Date = DBDatetime::now()->Format('y-MM-dd');
52
-        }
53
-
54
-        if (!isset($this->StartTime) || $this->StartTime === null) {
55
-            $this->StartTime = '09:00:00';
56
-        }
57
-
58
-        if (!isset($this->EndTime) || $this->EndTime === null) {
59
-            $this->EndTime = '17:00:00';
60
-        }
61
-
62
-        parent::populateDefaults();
63
-    }
64
-
65
-    public function getCMSFields()
66
-    {
67
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
68
-            $fields->removeByName('Date');
69
-
70
-            $dateTimeFields = array();
71
-
72
-            $dateTimeFields[] = $dateField = DateField::create('Date', 'Date');
73
-            $dateTimeFields[] = $startTimeField = TimeField::create(
74
-                'StartTime',
75
-                $this->fieldLabel('StartTime')
76
-            );
77
-            $dateTimeFields[] = $endTimeField = TimeField::create('EndTime', $this->fieldLabel('EndTime'));
78
-
79
-            $fields->addFieldsToTab('Root.Main', [
80
-                $dateTimeField = FieldGroup::create('Date and time', $dateTimeFields),
81
-                $locationField = TextareaField::create('Location', $this->fieldLabel('Location'))
82
-            ], 'Abstract');
83
-            $locationField->setRows(4);
84
-        });
85
-        return parent::getCMSFields();
86
-    }
87
-
88
-    public function NiceLocation()
89
-    {
90
-        return nl2br(Convert::raw2xml($this->Location), true);
91
-    }
15
+	private static $description = 'Describes an event occurring on a specific date.';
16
+
17
+	private static $default_parent = EventHolder::class;
18
+
19
+	private static $can_be_root = false;
20
+
21
+	private static $icon_class = 'font-icon-p-event';
22
+
23
+	private static $singular_name = 'Event Page';
24
+
25
+	private static $plural_name = 'Event Pages';
26
+
27
+	private static $db = [
28
+		'StartTime' => 'Time',
29
+		'EndTime' => 'Time',
30
+		'Location' => 'Text',
31
+	];
32
+
33
+	private static $table_name = 'EventPage';
34
+
35
+	public function fieldLabels($includerelations = true)
36
+	{
37
+		$labels = parent::fieldLabels($includerelations);
38
+		$labels['StartTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.StartTimeFieldLabel', 'Start Time');
39
+		$labels['EndTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.EndTimeFieldLabel', 'End Time');
40
+		$labels['Location'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.LocationFieldLabel', 'Location');
41
+
42
+		return $labels;
43
+	}
44
+
45
+	/**
46
+	 * Add the default for the Date being the current day.
47
+	 */
48
+	public function populateDefaults()
49
+	{
50
+		if (!isset($this->Date) || $this->Date === null) {
51
+			$this->Date = DBDatetime::now()->Format('y-MM-dd');
52
+		}
53
+
54
+		if (!isset($this->StartTime) || $this->StartTime === null) {
55
+			$this->StartTime = '09:00:00';
56
+		}
57
+
58
+		if (!isset($this->EndTime) || $this->EndTime === null) {
59
+			$this->EndTime = '17:00:00';
60
+		}
61
+
62
+		parent::populateDefaults();
63
+	}
64
+
65
+	public function getCMSFields()
66
+	{
67
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
68
+			$fields->removeByName('Date');
69
+
70
+			$dateTimeFields = array();
71
+
72
+			$dateTimeFields[] = $dateField = DateField::create('Date', 'Date');
73
+			$dateTimeFields[] = $startTimeField = TimeField::create(
74
+				'StartTime',
75
+				$this->fieldLabel('StartTime')
76
+			);
77
+			$dateTimeFields[] = $endTimeField = TimeField::create('EndTime', $this->fieldLabel('EndTime'));
78
+
79
+			$fields->addFieldsToTab('Root.Main', [
80
+				$dateTimeField = FieldGroup::create('Date and time', $dateTimeFields),
81
+				$locationField = TextareaField::create('Location', $this->fieldLabel('Location'))
82
+			], 'Abstract');
83
+			$locationField->setRows(4);
84
+		});
85
+		return parent::getCMSFields();
86
+	}
87
+
88
+	public function NiceLocation()
89
+	{
90
+		return nl2br(Convert::raw2xml($this->Location), true);
91
+	}
92 92
 }
Please login to merge, or discard this patch.