Completed
Push — master ( db5110...b3c1ec )
by Robbie
05:38 queued 03:17
created
src/PageTypes/FooterHolder.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -14,54 +14,54 @@
 block discarded – undo
14 14
 class FooterHolder extends RedirectorPage
15 15
 {
16 16
 
17
-    private static $description = 'Holder page that displays all child pages as links in the footer';
17
+	private static $description = 'Holder page that displays all child pages as links in the footer';
18 18
 
19
-    private static $singular_name = 'Footer Holder';
19
+	private static $singular_name = 'Footer Holder';
20 20
 
21
-    private static $plural_name = 'Footer Holders';
21
+	private static $plural_name = 'Footer Holders';
22 22
 
23
-    private static $defaults = [
24
-        'ShowInMenus' => 0,
25
-        'ShowInSearch' => 0,
26
-    ];
23
+	private static $defaults = [
24
+		'ShowInMenus' => 0,
25
+		'ShowInSearch' => 0,
26
+	];
27 27
 
28
-    private static $table_name = 'FooterHolder';
28
+	private static $table_name = 'FooterHolder';
29 29
 
30
-    public function getCMSFields()
31
-    {
32
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
33
-            $fields->removeByName('RedirectorDescHeader');
34
-            $fields->removeByName('RedirectionType');
35
-            $fields->removeByName('LinkToID');
36
-            $fields->removeByName('ExternalURL');
37
-        });
38
-        return parent::getCMSFields();
39
-    }
30
+	public function getCMSFields()
31
+	{
32
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
33
+			$fields->removeByName('RedirectorDescHeader');
34
+			$fields->removeByName('RedirectionType');
35
+			$fields->removeByName('LinkToID');
36
+			$fields->removeByName('ExternalURL');
37
+		});
38
+		return parent::getCMSFields();
39
+	}
40 40
 
41
-    /**
42
-     * Return the link to the first child page.
43
-     */
44
-    public function redirectionLink()
45
-    {
46
-        $childPage = $this->Children()->first();
41
+	/**
42
+	 * Return the link to the first child page.
43
+	 */
44
+	public function redirectionLink()
45
+	{
46
+		$childPage = $this->Children()->first();
47 47
 
48
-        if ($childPage) {
49
-            // If we're linking to another redirectorpage then just return the URLSegment, to prevent a cycle of
50
-            // redirector pages from causing an infinite loop.  Instead, they will cause a 30x redirection loop in
51
-            // the browser, but this can be handled sufficiently gracefully by the browser.
52
-            if ($childPage instanceof RedirectorPage) {
53
-                return $childPage->regularLink();
54
-            }
55
-            // For all other pages, just return the link of the page.
56
-            return $childPage->Link();
57
-        }
58
-    }
48
+		if ($childPage) {
49
+			// If we're linking to another redirectorpage then just return the URLSegment, to prevent a cycle of
50
+			// redirector pages from causing an infinite loop.  Instead, they will cause a 30x redirection loop in
51
+			// the browser, but this can be handled sufficiently gracefully by the browser.
52
+			if ($childPage instanceof RedirectorPage) {
53
+				return $childPage->regularLink();
54
+			}
55
+			// For all other pages, just return the link of the page.
56
+			return $childPage->Link();
57
+		}
58
+	}
59 59
 
60
-    public function syncLinkTracking()
61
-    {
62
-        // If we don't have anything to link to, then we have a broken link.
63
-        if (!$this->Children()) {
64
-            $this->HasBrokenLink = true;
65
-        }
66
-    }
60
+	public function syncLinkTracking()
61
+	{
62
+		// If we don't have anything to link to, then we have a broken link.
63
+		if (!$this->Children()) {
64
+			$this->HasBrokenLink = true;
65
+		}
66
+	}
67 67
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 
30 30
     public function getCMSFields()
31 31
     {
32
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
32
+        $this->beforeUpdateCMSFields(function(FieldList $fields) {
33 33
             $fields->removeByName('RedirectorDescHeader');
34 34
             $fields->removeByName('RedirectionType');
35 35
             $fields->removeByName('LinkToID');
Please login to merge, or discard this patch.
src/PageTypes/SitemapPage.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
6 6
 
7 7
 class SitemapPage extends Page
8 8
 {
9
-    private static $description = 'Lists all pages on the site';
9
+	private static $description = 'Lists all pages on the site';
10 10
 
11
-    private static $singular_name = 'Sitemap Page';
11
+	private static $singular_name = 'Sitemap Page';
12 12
 
13
-    private static $plural_name = 'Sitemap Pages';
13
+	private static $plural_name = 'Sitemap Pages';
14 14
 
15
-    private static $table_name = 'SitemapPage';
15
+	private static $table_name = 'SitemapPage';
16 16
 }
Please login to merge, or discard this patch.
src/PageTypes/BaseHomePage.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
 
67 67
     public function getCMSFields()
68 68
     {
69
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
69
+        $this->beforeUpdateCMSFields(function(FieldList $fields) {
70 70
             // Main Content tab
71 71
             $fields->addFieldToTab(
72 72
                 'Root.Main',
Please login to merge, or discard this patch.
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -26,137 +26,137 @@
 block discarded – undo
26 26
  */
27 27
 class BaseHomePage extends Page
28 28
 {
29
-    private static $icon = 'cwp/cwp:images/icons/sitetree_images/home.png';
30
-
31
-    private static $hide_ancestor = BaseHomePage::class;
32
-
33
-    private static $singular_name = 'Home Page';
34
-
35
-    private static $plural_name = 'Home Pages';
36
-
37
-    private static $table_name = 'BaseHomePage';
38
-
39
-    private static $db = [
40
-        'FeatureOneTitle' => 'Varchar(255)',
41
-        'FeatureOneCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')",
42
-        'FeatureOneContent' => 'HTMLText',
43
-        'FeatureOneButtonText' => 'Varchar(255)',
44
-        'FeatureTwoTitle' => 'Varchar(255)',
45
-        'FeatureTwoCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')",
46
-        'FeatureTwoContent' => 'HTMLText',
47
-        'FeatureTwoButtonText' => 'Varchar(255)'
48
-    ];
49
-
50
-    private static $has_one = [
51
-        'LearnMorePage' => SiteTree::class,
52
-        'FeatureOneLink' => SiteTree::class,
53
-        'FeatureTwoLink' => SiteTree::class,
54
-    ];
55
-
56
-    private static $has_many = [
57
-        'Quicklinks' => Quicklink::class . '.Parent',
58
-    ];
59
-
60
-    public function Quicklinks()
61
-    {
62
-        return $this->getComponents('Quicklinks')->sort('SortOrder');
63
-    }
64
-
65
-    public function getCMSFields()
66
-    {
67
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
68
-            // Main Content tab
69
-            $fields->addFieldToTab(
70
-                'Root.Main',
71
-                TreeDropdownField::create(
72
-                    'LearnMorePageID',
73
-                    _t(__CLASS__ . '.LearnMoreLink', 'Page to link the "Learn More" button to:'),
74
-                    SiteTree::class
75
-                ),
76
-                'Metadata'
77
-            );
78
-
79
-            $gridField = GridField::create(
80
-                'Quicklinks',
81
-                'Quicklinks',
82
-                $this->Quicklinks(),
83
-                GridFieldConfig_RelationEditor::create()
84
-            );
85
-            $gridConfig = $gridField->getConfig();
86
-            $gridConfig->getComponentByType(GridFieldAddNewButton::class)->setButtonName(
87
-                _t(__CLASS__ . '.AddNewButton', 'Add new')
88
-            );
89
-
90
-            $injector = Injector::inst();
91
-
92
-            $gridConfig->removeComponentsByType(GridFieldAddExistingAutocompleter::class);
93
-            $gridConfig->removeComponentsByType(GridFieldDeleteAction::class);
94
-            $gridConfig->addComponent($injector->create(GridFieldDeleteAction::class));
95
-            $gridConfig->addComponent($injector->create(GridFieldOrderableRows::class, 'SortOrder'));
96
-            $gridField->setModelClass(Quicklink::class);
97
-
98
-            $fields->addFieldToTab('Root.Quicklinks', $gridField);
99
-
100
-            $fields->removeByName('Import');
101
-
102
-            $fields->addFieldToTab(
103
-                'Root.Features',
104
-                ToggleCompositeField::create(
105
-                    'FeatureOne',
106
-                    _t(__CLASS__ . '.FeatureOne', 'Feature One'),
107
-                    array(
108
-                        TextField::create('FeatureOneTitle', _t(__CLASS__ . '.Title', 'Title')),
109
-                        $dropdownField = DropdownField::create(
110
-                            'FeatureOneCategory',
111
-                            _t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'),
112
-                            singleton(BaseHomePage::class)->dbObject('FeatureOneCategory')->enumValues()
113
-                        ),
114
-                        HTMLEditorField::create(
115
-                            'FeatureOneContent',
116
-                            _t(__CLASS__ . '.FeatureContentFieldLabel', 'Content')
117
-                        ),
118
-                        TextField::create(
119
-                            'FeatureOneButtonText',
120
-                            _t(__CLASS__ . '.FeatureButtonText', 'Button text')
121
-                        ),
122
-                        TreeDropdownField::create(
123
-                            'FeatureOneLinkID',
124
-                            _t(__CLASS__ . '.FeatureLink', 'Page to link to'),
125
-                            SiteTree::class
126
-                        )->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in'))
127
-                    )
128
-                )->setHeadingLevel(3)
129
-            );
130
-            $dropdownField->setEmptyString('none');
131
-
132
-            $fields->addFieldToTab('Root.Features', ToggleCompositeField::create(
133
-                'FeatureTwo',
134
-                _t(__CLASS__ . '.FeatureTwo', 'Feature Two'),
135
-                array(
136
-                    TextField::create('FeatureTwoTitle', _t(__CLASS__ . '.Title', 'Title')),
137
-                    $dropdownField = DropdownField::create(
138
-                        'FeatureTwoCategory',
139
-                        _t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'),
140
-                        singleton(BaseHomePage::class)->dbObject('FeatureTwoCategory')->enumValues()
141
-                    ),
142
-                    HTMLEditorField::create(
143
-                        'FeatureTwoContent',
144
-                        _t(__CLASS__ . '.FeatureContentFieldLabel', 'Content')
145
-                    ),
146
-                    TextField::create(
147
-                        'FeatureTwoButtonText',
148
-                        _t(__CLASS__ . '.FeatureButtonText', 'Button text')
149
-                    ),
150
-                    TreeDropdownField::create(
151
-                        'FeatureTwoLinkID',
152
-                        _t(__CLASS__ . '.FeatureLink', 'Page to link to'),
153
-                        SiteTree::class
154
-                    )->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in'))
155
-                )
156
-            )->setHeadingLevel(3));
157
-            $dropdownField->setEmptyString('none');
158
-        });
159
-
160
-        return parent::getCMSFields();
161
-    }
29
+	private static $icon = 'cwp/cwp:images/icons/sitetree_images/home.png';
30
+
31
+	private static $hide_ancestor = BaseHomePage::class;
32
+
33
+	private static $singular_name = 'Home Page';
34
+
35
+	private static $plural_name = 'Home Pages';
36
+
37
+	private static $table_name = 'BaseHomePage';
38
+
39
+	private static $db = [
40
+		'FeatureOneTitle' => 'Varchar(255)',
41
+		'FeatureOneCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')",
42
+		'FeatureOneContent' => 'HTMLText',
43
+		'FeatureOneButtonText' => 'Varchar(255)',
44
+		'FeatureTwoTitle' => 'Varchar(255)',
45
+		'FeatureTwoCategory' => "Enum('bell,comments,film,flag,globe,group,list,phone,rss,time,user','comments')",
46
+		'FeatureTwoContent' => 'HTMLText',
47
+		'FeatureTwoButtonText' => 'Varchar(255)'
48
+	];
49
+
50
+	private static $has_one = [
51
+		'LearnMorePage' => SiteTree::class,
52
+		'FeatureOneLink' => SiteTree::class,
53
+		'FeatureTwoLink' => SiteTree::class,
54
+	];
55
+
56
+	private static $has_many = [
57
+		'Quicklinks' => Quicklink::class . '.Parent',
58
+	];
59
+
60
+	public function Quicklinks()
61
+	{
62
+		return $this->getComponents('Quicklinks')->sort('SortOrder');
63
+	}
64
+
65
+	public function getCMSFields()
66
+	{
67
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
68
+			// Main Content tab
69
+			$fields->addFieldToTab(
70
+				'Root.Main',
71
+				TreeDropdownField::create(
72
+					'LearnMorePageID',
73
+					_t(__CLASS__ . '.LearnMoreLink', 'Page to link the "Learn More" button to:'),
74
+					SiteTree::class
75
+				),
76
+				'Metadata'
77
+			);
78
+
79
+			$gridField = GridField::create(
80
+				'Quicklinks',
81
+				'Quicklinks',
82
+				$this->Quicklinks(),
83
+				GridFieldConfig_RelationEditor::create()
84
+			);
85
+			$gridConfig = $gridField->getConfig();
86
+			$gridConfig->getComponentByType(GridFieldAddNewButton::class)->setButtonName(
87
+				_t(__CLASS__ . '.AddNewButton', 'Add new')
88
+			);
89
+
90
+			$injector = Injector::inst();
91
+
92
+			$gridConfig->removeComponentsByType(GridFieldAddExistingAutocompleter::class);
93
+			$gridConfig->removeComponentsByType(GridFieldDeleteAction::class);
94
+			$gridConfig->addComponent($injector->create(GridFieldDeleteAction::class));
95
+			$gridConfig->addComponent($injector->create(GridFieldOrderableRows::class, 'SortOrder'));
96
+			$gridField->setModelClass(Quicklink::class);
97
+
98
+			$fields->addFieldToTab('Root.Quicklinks', $gridField);
99
+
100
+			$fields->removeByName('Import');
101
+
102
+			$fields->addFieldToTab(
103
+				'Root.Features',
104
+				ToggleCompositeField::create(
105
+					'FeatureOne',
106
+					_t(__CLASS__ . '.FeatureOne', 'Feature One'),
107
+					array(
108
+						TextField::create('FeatureOneTitle', _t(__CLASS__ . '.Title', 'Title')),
109
+						$dropdownField = DropdownField::create(
110
+							'FeatureOneCategory',
111
+							_t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'),
112
+							singleton(BaseHomePage::class)->dbObject('FeatureOneCategory')->enumValues()
113
+						),
114
+						HTMLEditorField::create(
115
+							'FeatureOneContent',
116
+							_t(__CLASS__ . '.FeatureContentFieldLabel', 'Content')
117
+						),
118
+						TextField::create(
119
+							'FeatureOneButtonText',
120
+							_t(__CLASS__ . '.FeatureButtonText', 'Button text')
121
+						),
122
+						TreeDropdownField::create(
123
+							'FeatureOneLinkID',
124
+							_t(__CLASS__ . '.FeatureLink', 'Page to link to'),
125
+							SiteTree::class
126
+						)->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in'))
127
+					)
128
+				)->setHeadingLevel(3)
129
+			);
130
+			$dropdownField->setEmptyString('none');
131
+
132
+			$fields->addFieldToTab('Root.Features', ToggleCompositeField::create(
133
+				'FeatureTwo',
134
+				_t(__CLASS__ . '.FeatureTwo', 'Feature Two'),
135
+				array(
136
+					TextField::create('FeatureTwoTitle', _t(__CLASS__ . '.Title', 'Title')),
137
+					$dropdownField = DropdownField::create(
138
+						'FeatureTwoCategory',
139
+						_t(__CLASS__ . '.FeatureCategoryDropdown', 'Category icon'),
140
+						singleton(BaseHomePage::class)->dbObject('FeatureTwoCategory')->enumValues()
141
+					),
142
+					HTMLEditorField::create(
143
+						'FeatureTwoContent',
144
+						_t(__CLASS__ . '.FeatureContentFieldLabel', 'Content')
145
+					),
146
+					TextField::create(
147
+						'FeatureTwoButtonText',
148
+						_t(__CLASS__ . '.FeatureButtonText', 'Button text')
149
+					),
150
+					TreeDropdownField::create(
151
+						'FeatureTwoLinkID',
152
+						_t(__CLASS__ . '.FeatureLink', 'Page to link to'),
153
+						SiteTree::class
154
+					)->setDescription(_t(__CLASS__ . '.ButtonTextRequired', 'Button text must be filled in'))
155
+				)
156
+			)->setHeadingLevel(3));
157
+			$dropdownField->setEmptyString('none');
158
+		});
159
+
160
+		return parent::getCMSFields();
161
+	}
162 162
 }
Please login to merge, or discard this patch.
src/PageTypes/DatedUpdatePage.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 
56 56
     public function getCMSFields()
57 57
     {
58
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
58
+        $this->beforeUpdateCMSFields(function(FieldList $fields) {
59 59
             $fields->addFieldToTab(
60 60
                 'Root.Main',
61 61
                 $dateTimeField = DatetimeField::create('Date', $this->fieldLabel('Date')),
Please login to merge, or discard this patch.
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -10,70 +10,70 @@
 block discarded – undo
10 10
 
11 11
 class DatedUpdatePage extends Page
12 12
 {
13
-    /**
14
-     * Meant as an abstract base class.
15
-     *
16
-     * {@inheritDoc}
17
-     */
18
-    private static $hide_ancestor = DatedUpdatePage::class;
13
+	/**
14
+	 * Meant as an abstract base class.
15
+	 *
16
+	 * {@inheritDoc}
17
+	 */
18
+	private static $hide_ancestor = DatedUpdatePage::class;
19 19
 
20
-    private static $singular_name = 'Dated Update Page';
20
+	private static $singular_name = 'Dated Update Page';
21 21
 
22
-    private static $plural_name = 'Dated Update Pages';
22
+	private static $plural_name = 'Dated Update Pages';
23 23
 
24
-    private static $table_name = 'DatedUpdatePage';
24
+	private static $table_name = 'DatedUpdatePage';
25 25
 
26
-    private static $defaults = [
27
-        'ShowInMenus' => false,
28
-    ];
26
+	private static $defaults = [
27
+		'ShowInMenus' => false,
28
+	];
29 29
 
30
-    private static $db = [
31
-        'Abstract' => 'Text',
32
-        'Date' => 'Datetime',
33
-    ];
30
+	private static $db = [
31
+		'Abstract' => 'Text',
32
+		'Date' => 'Datetime',
33
+	];
34 34
 
35
-    /**
36
-     * Add the default for the Date being the current day.
37
-     */
38
-    public function populateDefaults()
39
-    {
40
-        parent::populateDefaults();
35
+	/**
36
+	 * Add the default for the Date being the current day.
37
+	 */
38
+	public function populateDefaults()
39
+	{
40
+		parent::populateDefaults();
41 41
 
42
-        if (!isset($this->Date) || $this->Date === null) {
43
-            $this->Date = DBDatetime::now()->Format('y-MM-dd 09:00:00');
44
-        }
45
-    }
42
+		if (!isset($this->Date) || $this->Date === null) {
43
+			$this->Date = DBDatetime::now()->Format('y-MM-dd 09:00:00');
44
+		}
45
+	}
46 46
 
47
-    public function fieldLabels($includerelations = true)
48
-    {
49
-        $labels = parent::fieldLabels($includerelations);
50
-        $labels['Date'] = _t(__CLASS__ . '.DateLabel', 'Date');
51
-        $labels['Abstract'] = _t(__CLASS__ . '.AbstractTextFieldLabel', 'Abstract');
47
+	public function fieldLabels($includerelations = true)
48
+	{
49
+		$labels = parent::fieldLabels($includerelations);
50
+		$labels['Date'] = _t(__CLASS__ . '.DateLabel', 'Date');
51
+		$labels['Abstract'] = _t(__CLASS__ . '.AbstractTextFieldLabel', 'Abstract');
52 52
 
53
-        return $labels;
54
-    }
53
+		return $labels;
54
+	}
55 55
 
56
-    public function getCMSFields()
57
-    {
58
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
59
-            $fields->addFieldToTab(
60
-                'Root.Main',
61
-                $dateTimeField = DatetimeField::create('Date', $this->fieldLabel('Date')),
62
-                'Content'
63
-            );
56
+	public function getCMSFields()
57
+	{
58
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
59
+			$fields->addFieldToTab(
60
+				'Root.Main',
61
+				$dateTimeField = DatetimeField::create('Date', $this->fieldLabel('Date')),
62
+				'Content'
63
+			);
64 64
 
65
-            $fields->addfieldToTab(
66
-                'Root.Main',
67
-                $abstractField = TextareaField::create('Abstract', $this->fieldLabel('Abstract')),
68
-                'Content'
69
-            );
70
-            $abstractField->setAttribute('maxlength', '160');
71
-            $abstractField->setRightTitle(_t(
72
-                __CLASS__ . '.AbstractDesc',
73
-                'The abstract is used as a summary on the listing pages. It is limited to 160 characters.'
74
-            ));
75
-            $abstractField->setRows(6);
76
-        });
77
-        return parent::getCMSFields();
78
-    }
65
+			$fields->addfieldToTab(
66
+				'Root.Main',
67
+				$abstractField = TextareaField::create('Abstract', $this->fieldLabel('Abstract')),
68
+				'Content'
69
+			);
70
+			$abstractField->setAttribute('maxlength', '160');
71
+			$abstractField->setRightTitle(_t(
72
+				__CLASS__ . '.AbstractDesc',
73
+				'The abstract is used as a summary on the listing pages. It is limited to 160 characters.'
74
+			));
75
+			$abstractField->setRows(6);
76
+		});
77
+		return parent::getCMSFields();
78
+	}
79 79
 }
Please login to merge, or discard this patch.
src/PageTypes/BaseHomePageController.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,20 +6,20 @@
 block discarded – undo
6 6
 
7 7
 class BaseHomePageController extends PageController
8 8
 {
9
-    public function getNewsPage()
10
-    {
11
-        return NewsHolder::get_one(NewsHolder::class);
12
-    }
9
+	public function getNewsPage()
10
+	{
11
+		return NewsHolder::get_one(NewsHolder::class);
12
+	}
13 13
 
14
-    /**
15
-     * @param int $amount The amount of items to provide.
16
-     */
17
-    public function getNewsItems($amount = 2)
18
-    {
19
-        $newsHolder = $this->getNewsPage();
20
-        if ($newsHolder) {
21
-            $controller = NewsHolderController::create($newsHolder);
22
-            return $controller->Updates()->limit($amount);
23
-        }
24
-    }
14
+	/**
15
+	 * @param int $amount The amount of items to provide.
16
+	 */
17
+	public function getNewsItems($amount = 2)
18
+	{
19
+		$newsHolder = $this->getNewsPage();
20
+		if ($newsHolder) {
21
+			$controller = NewsHolderController::create($newsHolder);
22
+			return $controller->Updates()->limit($amount);
23
+		}
24
+	}
25 25
 }
Please login to merge, or discard this patch.
src/PageTypes/DatedUpdateHolder.php 2 patches
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -17,247 +17,247 @@
 block discarded – undo
17 17
 
18 18
 class DatedUpdateHolder extends Page
19 19
 {
20
-    /**
21
-     * Meant as an abstract base class.
22
-     *
23
-     * {@inheritDoc}
24
-     */
25
-    private static $hide_ancestor = DatedUpdateHolder::class;
26
-
27
-    private static $update_name = 'Updates';
28
-
29
-    private static $update_class = DatedUpdatePage::class;
30
-
31
-    private static $singular_name = 'Dated Update Holder';
32
-
33
-    private static $plural_name = 'Dated Update Holders';
34
-
35
-    private static $table_name = 'DatedUpdateHolder';
36
-
37
-    /**
38
-     * Find all distinct tags (TaxonomyTerms) associated with the DatedUpdatePages under this holder.
39
-     */
40
-    public function UpdateTags()
41
-    {
42
-        $siteTree = DataObject::getSchema()->tableName(SiteTree::class);
43
-        $taxonomy = DataObject::getSchema()->tableName(TaxonomyTerm::class);
44
-
45
-        $tags = TaxonomyTerm::get()
46
-            ->innerJoin('BasePage_Terms', sprintf('"%s"."ID"="BasePage_Terms"."TaxonomyTermID"', $taxonomy))
47
-            ->innerJoin(
48
-                $siteTree,
49
-                sprintf(
50
-                    '"%s"."ID" = "BasePage_Terms"."BasePageID" AND "%s"."ParentID" = \'%d\'',
51
-                    $siteTree,
52
-                    $siteTree,
53
-                    $this->ID
54
-                )
55
-            )
56
-            ->sort('Name');
57
-
58
-        return $tags;
59
-    }
60
-
61
-    /**
62
-     * Wrapper to find all updates belonging to this holder, based on some filters.
63
-     */
64
-    public function Updates($tagID = null, $dateFrom = null, $dateTo = null, $year = null, $monthNumber = null)
65
-    {
66
-        $className = Config::inst()->get($this->ClassName, 'update_class');
67
-        return static::AllUpdates($className, $this->ID, $tagID, $dateFrom, $dateTo, $year, $monthNumber);
68
-    }
69
-
70
-    /**
71
-     * Find all site's updates, based on some filters.
72
-     * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
73
-     *
74
-     * @param string $className The name of the class to fetch.
75
-     * @param int|null $parentID The ID of the holder to extract the updates from.
76
-     * @param int|null $tagID The ID of the tag to filter the updates by.
77
-     * @param string|null $dateFrom The beginning of a date filter range.
78
-     * @param string|null $dateTo The end of the date filter range. If empty, only one day will be searched for.
79
-     * @param int|null $year Numeric value of the year to show.
80
-     * @param int|null $monthNumber Numeric value of the month to show.
81
-     *
82
-     * @returns DataList | PaginatedList
83
-     */
84
-    public static function AllUpdates(
85
-        $className = DatedUpdatePage::class,
86
-        $parentID = null,
87
-        $tagID = null,
88
-        $dateFrom = null,
89
-        $dateTo = null,
90
-        $year = null,
91
-        $monthNumber = null
92
-    ) {
93
-
94
-        $items = $className::get();
95
-        $dbTableName = DataObject::getSchema()->tableForField($className, 'Date');
96
-        if (!$dbTableName) {
97
-            $dbTableName = DatedUpdatePage::class;
98
-        }
99
-
100
-        // Filter by parent holder.
101
-        if (isset($parentID)) {
102
-            $items = $items->filter(['ParentID'=>$parentID]);
103
-        }
104
-
105
-        // Filter down to a single tag.
106
-        if (isset($tagID)) {
107
-            $taxonomy = DataObject::getSchema()->tableName(TaxonomyTerm::class);
108
-            $tableName = DataObject::getSchema()->tableName($className);
109
-
110
-            $items = $items->innerJoin(
111
-                'BasePage_Terms',
112
-                sprintf('"%s"."ID" = "BasePage_Terms"."BasePageID"', $tableName)
113
-            )->innerJoin(
114
-                $taxonomy,
115
-                sprintf(
116
-                    '"BasePage_Terms"."TaxonomyTermID" = "%s"."ID" AND "TaxonomyTerm"."ID" = \'%d\'',
117
-                    $taxonomy,
118
-                    $tagID
119
-                )
120
-            );
121
-        }
122
-
123
-        // Filter by date
124
-        if (isset($dateFrom)) {
125
-            if (!isset($dateTo)) {
126
-                $dateTo = $dateFrom;
127
-            }
128
-
129
-            $items = $items->where([
130
-                sprintf('"%s"."Date" >= \'%s\'', $dbTableName, Convert::raw2sql("$dateFrom 00:00:00")),
131
-                sprintf('"%s"."Date" <= \'%s\'', $dbTableName, Convert::raw2sql("$dateTo 23:59:59"))
132
-            ]);
133
-        }
134
-
135
-        // Filter down to single month.
136
-        if (isset($year) && isset($monthNumber)) {
137
-            $year = (int)$year;
138
-            $monthNumber = (int)$monthNumber;
139
-
140
-            $beginDate = sprintf("%04d-%02d-01 00:00:00", $year, $monthNumber);
141
-            $endDate = date('Y-m-d H:i:s', strtotime("{$beginDate} +1 month"));
142
-
143
-            $items = $items->where(array(
144
-                sprintf('"%s"."Date" >= \'%s\'', $dbTableName, Convert::raw2sql($beginDate)),
145
-                sprintf('"%s"."Date" < \'%s\'', $dbTableName, Convert::raw2sql($endDate))
146
-            ));
147
-        }
148
-
149
-        // Unpaginated DataList.
150
-        return $items;
151
-    }
152
-
153
-    /**
154
-     * Produce an ArrayList of available months out of the updates contained in the DataList.
155
-     *
156
-     * Here is an example of the returned structure:
157
-     * ArrayList:
158
-     *   ArrayData:
159
-     *     YearName => 2013
160
-     *     Months => ArrayList:
161
-     *       MonthName => Jan
162
-     *       MonthNumber => 1
163
-     *       MonthLink => (page URL)year=2012&month=1
164
-     *       Active => true
165
-     *   ArrayData:
166
-     *     YearName => 2012
167
-     *     Months => ArrayList:
168
-     *     ...
169
-     *
170
-     * @param DataList $updates DataList DataList to extract months from.
171
-     * @param string $link Link used as abase to construct the MonthLink.
172
-     * @param int $currentYear Currently selected year, for computing the link active state.
173
-     * @param int $currentMonthNumber Currently selected month, for computing the link active state.
174
-     *
175
-     * @returns ArrayList
176
-     */
177
-    public static function ExtractMonths(
178
-        DataList $updates,
179
-        $link = null,
180
-        $currentYear = null,
181
-        $currentMonthNumber = null
182
-    ) {
183
-        // Set the link to current URL in the same way the HTTP::setGetVar does it.
184
-        if (!isset($link)) {
185
-            $link = Director::makeRelative($_SERVER['REQUEST_URI']);
186
-        }
187
-
188
-        $dates = $updates->dataQuery()
189
-            ->groupby('YEAR("Date")')
190
-            ->groupby('MONTH("Date")')
191
-            ->query()
192
-            ->setSelect([
193
-                'Year' => 'YEAR("Date")',
194
-                'Month' => 'MONTH("Date")',
195
-            ])
196
-            ->addWhere('"Date" IS NOT NULL')
197
-            ->setOrderBy([
198
-                'YEAR("Date")' => 'DESC',
199
-                'MONTH("Date")' => 'DESC',
200
-            ])
201
-            ->execute();
202
-
203
-        $years = [];
204
-        foreach ($dates as $date) {
205
-            $monthNumber = $date['Month'];
206
-            $year = $date['Year'];
207
-            $dateObj = new DateTime(implode('-', [$year, $monthNumber, 1]));
208
-            $monthName = $dateObj->Format('M');
209
-
210
-            // Set up the relevant year array, if not yet available.
211
-            if (!isset($years[$year])) {
212
-                $years[$year] = ['YearName'=>$year, 'Months' => []];
213
-            }
214
-
215
-            // Check if the currently processed month is the one that is selected via GET params.
216
-            $active = false;
217
-            if (isset($year) && isset($monthNumber)) {
218
-                $active = (((int)$currentYear)==$year && ((int)$currentMonthNumber)==$monthNumber);
219
-            }
220
-
221
-            // Build the link - keep the tag and date filter, but reset the pagination.
222
-            if ($active) {
223
-                // Allow clicking to deselect the month.
224
-                $link = HTTP::setGetVar('month', null, $link, '&');
225
-                $link = HTTP::setGetVar('year', null, $link, '&');
226
-            } else {
227
-                $link = HTTP::setGetVar('month', $monthNumber, $link, '&');
228
-                $link = HTTP::setGetVar('year', $year, $link, '&');
229
-            }
230
-            $link = HTTP::setGetVar('start', null, $link, '&');
231
-
232
-            $years[$year]['Months'][$monthNumber] = array(
233
-                'MonthName'=>$monthName,
234
-                'MonthNumber'=>$monthNumber,
235
-                'MonthLink'=>$link,
236
-                'Active'=>$active
237
-            );
238
-        }
239
-
240
-        // ArrayList will not recursively walk through the supplied array, so manually build nested ArrayLists.
241
-        foreach ($years as &$year) {
242
-            $year['Months'] = new ArrayList($year['Months']);
243
-        }
244
-
245
-        // Reverse the list so the most recent years appear first.
246
-        return new ArrayList($years);
247
-    }
248
-
249
-    public function getDefaultRSSLink()
250
-    {
251
-        return $this->Link('rss');
252
-    }
253
-
254
-    public function getDefaultAtomLink()
255
-    {
256
-        return $this->Link('atom');
257
-    }
258
-
259
-    public function getSubscriptionTitle()
260
-    {
261
-        return $this->Title;
262
-    }
20
+	/**
21
+	 * Meant as an abstract base class.
22
+	 *
23
+	 * {@inheritDoc}
24
+	 */
25
+	private static $hide_ancestor = DatedUpdateHolder::class;
26
+
27
+	private static $update_name = 'Updates';
28
+
29
+	private static $update_class = DatedUpdatePage::class;
30
+
31
+	private static $singular_name = 'Dated Update Holder';
32
+
33
+	private static $plural_name = 'Dated Update Holders';
34
+
35
+	private static $table_name = 'DatedUpdateHolder';
36
+
37
+	/**
38
+	 * Find all distinct tags (TaxonomyTerms) associated with the DatedUpdatePages under this holder.
39
+	 */
40
+	public function UpdateTags()
41
+	{
42
+		$siteTree = DataObject::getSchema()->tableName(SiteTree::class);
43
+		$taxonomy = DataObject::getSchema()->tableName(TaxonomyTerm::class);
44
+
45
+		$tags = TaxonomyTerm::get()
46
+			->innerJoin('BasePage_Terms', sprintf('"%s"."ID"="BasePage_Terms"."TaxonomyTermID"', $taxonomy))
47
+			->innerJoin(
48
+				$siteTree,
49
+				sprintf(
50
+					'"%s"."ID" = "BasePage_Terms"."BasePageID" AND "%s"."ParentID" = \'%d\'',
51
+					$siteTree,
52
+					$siteTree,
53
+					$this->ID
54
+				)
55
+			)
56
+			->sort('Name');
57
+
58
+		return $tags;
59
+	}
60
+
61
+	/**
62
+	 * Wrapper to find all updates belonging to this holder, based on some filters.
63
+	 */
64
+	public function Updates($tagID = null, $dateFrom = null, $dateTo = null, $year = null, $monthNumber = null)
65
+	{
66
+		$className = Config::inst()->get($this->ClassName, 'update_class');
67
+		return static::AllUpdates($className, $this->ID, $tagID, $dateFrom, $dateTo, $year, $monthNumber);
68
+	}
69
+
70
+	/**
71
+	 * Find all site's updates, based on some filters.
72
+	 * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
73
+	 *
74
+	 * @param string $className The name of the class to fetch.
75
+	 * @param int|null $parentID The ID of the holder to extract the updates from.
76
+	 * @param int|null $tagID The ID of the tag to filter the updates by.
77
+	 * @param string|null $dateFrom The beginning of a date filter range.
78
+	 * @param string|null $dateTo The end of the date filter range. If empty, only one day will be searched for.
79
+	 * @param int|null $year Numeric value of the year to show.
80
+	 * @param int|null $monthNumber Numeric value of the month to show.
81
+	 *
82
+	 * @returns DataList | PaginatedList
83
+	 */
84
+	public static function AllUpdates(
85
+		$className = DatedUpdatePage::class,
86
+		$parentID = null,
87
+		$tagID = null,
88
+		$dateFrom = null,
89
+		$dateTo = null,
90
+		$year = null,
91
+		$monthNumber = null
92
+	) {
93
+
94
+		$items = $className::get();
95
+		$dbTableName = DataObject::getSchema()->tableForField($className, 'Date');
96
+		if (!$dbTableName) {
97
+			$dbTableName = DatedUpdatePage::class;
98
+		}
99
+
100
+		// Filter by parent holder.
101
+		if (isset($parentID)) {
102
+			$items = $items->filter(['ParentID'=>$parentID]);
103
+		}
104
+
105
+		// Filter down to a single tag.
106
+		if (isset($tagID)) {
107
+			$taxonomy = DataObject::getSchema()->tableName(TaxonomyTerm::class);
108
+			$tableName = DataObject::getSchema()->tableName($className);
109
+
110
+			$items = $items->innerJoin(
111
+				'BasePage_Terms',
112
+				sprintf('"%s"."ID" = "BasePage_Terms"."BasePageID"', $tableName)
113
+			)->innerJoin(
114
+				$taxonomy,
115
+				sprintf(
116
+					'"BasePage_Terms"."TaxonomyTermID" = "%s"."ID" AND "TaxonomyTerm"."ID" = \'%d\'',
117
+					$taxonomy,
118
+					$tagID
119
+				)
120
+			);
121
+		}
122
+
123
+		// Filter by date
124
+		if (isset($dateFrom)) {
125
+			if (!isset($dateTo)) {
126
+				$dateTo = $dateFrom;
127
+			}
128
+
129
+			$items = $items->where([
130
+				sprintf('"%s"."Date" >= \'%s\'', $dbTableName, Convert::raw2sql("$dateFrom 00:00:00")),
131
+				sprintf('"%s"."Date" <= \'%s\'', $dbTableName, Convert::raw2sql("$dateTo 23:59:59"))
132
+			]);
133
+		}
134
+
135
+		// Filter down to single month.
136
+		if (isset($year) && isset($monthNumber)) {
137
+			$year = (int)$year;
138
+			$monthNumber = (int)$monthNumber;
139
+
140
+			$beginDate = sprintf("%04d-%02d-01 00:00:00", $year, $monthNumber);
141
+			$endDate = date('Y-m-d H:i:s', strtotime("{$beginDate} +1 month"));
142
+
143
+			$items = $items->where(array(
144
+				sprintf('"%s"."Date" >= \'%s\'', $dbTableName, Convert::raw2sql($beginDate)),
145
+				sprintf('"%s"."Date" < \'%s\'', $dbTableName, Convert::raw2sql($endDate))
146
+			));
147
+		}
148
+
149
+		// Unpaginated DataList.
150
+		return $items;
151
+	}
152
+
153
+	/**
154
+	 * Produce an ArrayList of available months out of the updates contained in the DataList.
155
+	 *
156
+	 * Here is an example of the returned structure:
157
+	 * ArrayList:
158
+	 *   ArrayData:
159
+	 *     YearName => 2013
160
+	 *     Months => ArrayList:
161
+	 *       MonthName => Jan
162
+	 *       MonthNumber => 1
163
+	 *       MonthLink => (page URL)year=2012&month=1
164
+	 *       Active => true
165
+	 *   ArrayData:
166
+	 *     YearName => 2012
167
+	 *     Months => ArrayList:
168
+	 *     ...
169
+	 *
170
+	 * @param DataList $updates DataList DataList to extract months from.
171
+	 * @param string $link Link used as abase to construct the MonthLink.
172
+	 * @param int $currentYear Currently selected year, for computing the link active state.
173
+	 * @param int $currentMonthNumber Currently selected month, for computing the link active state.
174
+	 *
175
+	 * @returns ArrayList
176
+	 */
177
+	public static function ExtractMonths(
178
+		DataList $updates,
179
+		$link = null,
180
+		$currentYear = null,
181
+		$currentMonthNumber = null
182
+	) {
183
+		// Set the link to current URL in the same way the HTTP::setGetVar does it.
184
+		if (!isset($link)) {
185
+			$link = Director::makeRelative($_SERVER['REQUEST_URI']);
186
+		}
187
+
188
+		$dates = $updates->dataQuery()
189
+			->groupby('YEAR("Date")')
190
+			->groupby('MONTH("Date")')
191
+			->query()
192
+			->setSelect([
193
+				'Year' => 'YEAR("Date")',
194
+				'Month' => 'MONTH("Date")',
195
+			])
196
+			->addWhere('"Date" IS NOT NULL')
197
+			->setOrderBy([
198
+				'YEAR("Date")' => 'DESC',
199
+				'MONTH("Date")' => 'DESC',
200
+			])
201
+			->execute();
202
+
203
+		$years = [];
204
+		foreach ($dates as $date) {
205
+			$monthNumber = $date['Month'];
206
+			$year = $date['Year'];
207
+			$dateObj = new DateTime(implode('-', [$year, $monthNumber, 1]));
208
+			$monthName = $dateObj->Format('M');
209
+
210
+			// Set up the relevant year array, if not yet available.
211
+			if (!isset($years[$year])) {
212
+				$years[$year] = ['YearName'=>$year, 'Months' => []];
213
+			}
214
+
215
+			// Check if the currently processed month is the one that is selected via GET params.
216
+			$active = false;
217
+			if (isset($year) && isset($monthNumber)) {
218
+				$active = (((int)$currentYear)==$year && ((int)$currentMonthNumber)==$monthNumber);
219
+			}
220
+
221
+			// Build the link - keep the tag and date filter, but reset the pagination.
222
+			if ($active) {
223
+				// Allow clicking to deselect the month.
224
+				$link = HTTP::setGetVar('month', null, $link, '&');
225
+				$link = HTTP::setGetVar('year', null, $link, '&');
226
+			} else {
227
+				$link = HTTP::setGetVar('month', $monthNumber, $link, '&');
228
+				$link = HTTP::setGetVar('year', $year, $link, '&');
229
+			}
230
+			$link = HTTP::setGetVar('start', null, $link, '&');
231
+
232
+			$years[$year]['Months'][$monthNumber] = array(
233
+				'MonthName'=>$monthName,
234
+				'MonthNumber'=>$monthNumber,
235
+				'MonthLink'=>$link,
236
+				'Active'=>$active
237
+			);
238
+		}
239
+
240
+		// ArrayList will not recursively walk through the supplied array, so manually build nested ArrayLists.
241
+		foreach ($years as &$year) {
242
+			$year['Months'] = new ArrayList($year['Months']);
243
+		}
244
+
245
+		// Reverse the list so the most recent years appear first.
246
+		return new ArrayList($years);
247
+	}
248
+
249
+	public function getDefaultRSSLink()
250
+	{
251
+		return $this->Link('rss');
252
+	}
253
+
254
+	public function getDefaultAtomLink()
255
+	{
256
+		return $this->Link('atom');
257
+	}
258
+
259
+	public function getSubscriptionTitle()
260
+	{
261
+		return $this->Title;
262
+	}
263 263
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 
135 135
         // Filter down to single month.
136 136
         if (isset($year) && isset($monthNumber)) {
137
-            $year = (int)$year;
138
-            $monthNumber = (int)$monthNumber;
137
+            $year = (int) $year;
138
+            $monthNumber = (int) $monthNumber;
139 139
 
140 140
             $beginDate = sprintf("%04d-%02d-01 00:00:00", $year, $monthNumber);
141 141
             $endDate = date('Y-m-d H:i:s', strtotime("{$beginDate} +1 month"));
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
             // Check if the currently processed month is the one that is selected via GET params.
216 216
             $active = false;
217 217
             if (isset($year) && isset($monthNumber)) {
218
-                $active = (((int)$currentYear)==$year && ((int)$currentMonthNumber)==$monthNumber);
218
+                $active = (((int) $currentYear) == $year && ((int) $currentMonthNumber) == $monthNumber);
219 219
             }
220 220
 
221 221
             // Build the link - keep the tag and date filter, but reset the pagination.
Please login to merge, or discard this patch.
src/Extensions/CwpWorkflowDefinitionExtension.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -12,37 +12,37 @@
 block discarded – undo
12 12
  */
13 13
 class CwpWorkflowDefinitionExtension extends DataExtension
14 14
 {
15
-    /**
16
-     * Create the default 'Two-step Workflow' when this extension is loaded
17
-     *
18
-     * @config
19
-     * @var boolean
20
-     */
21
-    private static $create_default_workflow = true;
15
+	/**
16
+	 * Create the default 'Two-step Workflow' when this extension is loaded
17
+	 *
18
+	 * @config
19
+	 * @var boolean
20
+	 */
21
+	private static $create_default_workflow = true;
22 22
 
23
-    public function requireDefaultRecords()
24
-    {
25
-        if (Config::inst()->get(CwpWorkflowDefinitionExtension::class, 'create_default_workflow')) {
26
-            // Only proceed if a definition using this template has not been created yet
27
-            $definition = WorkflowDefinition::get()->filter("Template", "Review and Approve")->First();
28
-            if ($definition && $definition->exists()) {
29
-                return;
30
-            }
23
+	public function requireDefaultRecords()
24
+	{
25
+		if (Config::inst()->get(CwpWorkflowDefinitionExtension::class, 'create_default_workflow')) {
26
+			// Only proceed if a definition using this template has not been created yet
27
+			$definition = WorkflowDefinition::get()->filter("Template", "Review and Approve")->First();
28
+			if ($definition && $definition->exists()) {
29
+				return;
30
+			}
31 31
 
32
-            //generate from the template, which happens after we write the definition
33
-            $definition = WorkflowDefinition::create();
34
-            $definition->Template = "Review and Approve";
35
-            $definition->write();
32
+			//generate from the template, which happens after we write the definition
33
+			$definition = WorkflowDefinition::create();
34
+			$definition->Template = "Review and Approve";
35
+			$definition->write();
36 36
 
37
-            //change the title, description, and reminder days
38
-            $definition->update(array(
39
-                'Title' => "Two-step Workflow",
40
-                'Description' => "Content Authors can write content and Content Publishers can approve/reject.",
41
-                'RemindDays' => 3,
42
-            ));
43
-            $definition->write();
37
+			//change the title, description, and reminder days
38
+			$definition->update(array(
39
+				'Title' => "Two-step Workflow",
40
+				'Description' => "Content Authors can write content and Content Publishers can approve/reject.",
41
+				'RemindDays' => 3,
42
+			));
43
+			$definition->write();
44 44
 
45
-            DB::alteration_message("Added default workflow definition to WorkflowDefinition table", "created");
46
-        }
47
-    }
45
+			DB::alteration_message("Added default workflow definition to WorkflowDefinition table", "created");
46
+		}
47
+	}
48 48
 }
Please login to merge, or discard this patch.
tests/PageTypes/EventHolderTest.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -8,94 +8,94 @@
 block discarded – undo
8 8
 
9 9
 class EventHolderTest extends SapphireTest
10 10
 {
11
-    protected static $fixture_file = 'EventHolderTest.yml';
11
+	protected static $fixture_file = 'EventHolderTest.yml';
12 12
 
13
-    public function testEventTags()
14
-    {
15
-        $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
13
+	public function testEventTags()
14
+	{
15
+		$holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
16 16
 
17
-        $tags = $holder->UpdateTags();
18
-        $this->assertNotNull($tags->find('Name', 'Future'), 'Finds present terms.');
19
-        $this->assertNull($tags->find('Name', 'Event types', 'Does not find top level taxonomy.'));
20
-        $this->assertNull($tags->find('Name', 'Carrot'), 'Does not find terms that are not applied.');
21
-    }
17
+		$tags = $holder->UpdateTags();
18
+		$this->assertNotNull($tags->find('Name', 'Future'), 'Finds present terms.');
19
+		$this->assertNull($tags->find('Name', 'Event types', 'Does not find top level taxonomy.'));
20
+		$this->assertNull($tags->find('Name', 'Carrot'), 'Does not find terms that are not applied.');
21
+	}
22 22
 
23
-    public function testEventWithParentFilter()
24
-    {
25
-        $holder = $this->objFromFixture(EventHolder::class, 'EventHolder2');
23
+	public function testEventWithParentFilter()
24
+	{
25
+		$holder = $this->objFromFixture(EventHolder::class, 'EventHolder2');
26 26
 
27
-        $items = $holder->Updates();
27
+		$items = $holder->Updates();
28 28
 
29
-        $this->assertNotNull($items->find('URLSegment', 'other-holder'), 'Event from the holder is shown.');
30
-        $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Events from other holders are not shown.');
31
-    }
29
+		$this->assertNotNull($items->find('URLSegment', 'other-holder'), 'Event from the holder is shown.');
30
+		$this->assertNull($items->find('URLSegment', 'future-event-1'), 'Events from other holders are not shown.');
31
+	}
32 32
 
33
-    public function testEventsWithTagFilter()
34
-    {
35
-        $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
33
+	public function testEventsWithTagFilter()
34
+	{
35
+		$holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
36 36
 
37
-        //Get the "Future" tag.
38
-        $tag = $this->objFromFixture(TaxonomyTerm::class, 'TaxonomyTerm1');
37
+		//Get the "Future" tag.
38
+		$tag = $this->objFromFixture(TaxonomyTerm::class, 'TaxonomyTerm1');
39 39
 
40
-        $items = $holder->Updates($tag->ID);
40
+		$items = $holder->Updates($tag->ID);
41 41
 
42
-        $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the tagged page.');
43
-        $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find pages that are not tagged.');
44
-    }
42
+		$this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the tagged page.');
43
+		$this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find pages that are not tagged.');
44
+	}
45 45
 
46
-    public function testEventsWithMonthFilter()
47
-    {
48
-        $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
46
+	public function testEventsWithMonthFilter()
47
+	{
48
+		$holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
49 49
 
50
-        $items = $holder->Updates(null, null, null, 2013, 7);
50
+		$items = $holder->Updates(null, null, null, 2013, 7);
51 51
 
52
-        $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the event in 2013-07.');
53
-        $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find events at other dates.');
54
-    }
52
+		$this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the event in 2013-07.');
53
+		$this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find events at other dates.');
54
+	}
55 55
 
56
-    public function testEventsWithDateRangeFilter()
57
-    {
58
-        $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
56
+	public function testEventsWithDateRangeFilter()
57
+	{
58
+		$holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
59 59
 
60
-        $items = $holder->Updates(null, '2013-01-19', null);
61
-        $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds the event at the date');
62
-        $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find the event at another date');
60
+		$items = $holder->Updates(null, '2013-01-19', null);
61
+		$this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds the event at the date');
62
+		$this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find the event at another date');
63 63
 
64
-        $items = $holder->Updates(null, '2013-01-01', '2013-01-19');
65
-        $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds events in the date range');
66
-        $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find event out of range');
67
-    }
64
+		$items = $holder->Updates(null, '2013-01-01', '2013-01-19');
65
+		$this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds events in the date range');
66
+		$this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find event out of range');
67
+	}
68 68
 
69
-    public function testExtractMonths()
70
-    {
71
-        $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
69
+	public function testExtractMonths()
70
+	{
71
+		$holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
72 72
 
73
-        $months = EventHolder::ExtractMonths(
74
-            $holder->Updates(),
75
-            'http://mybase.org/?tag=12&start=10&from=2010-10-10&to=2010-10-11', // Used for link generation
76
-            2013, // Currently selected
77
-            1 // Currently selected
78
-        );
73
+		$months = EventHolder::ExtractMonths(
74
+			$holder->Updates(),
75
+			'http://mybase.org/?tag=12&start=10&from=2010-10-10&to=2010-10-11', // Used for link generation
76
+			2013, // Currently selected
77
+			1 // Currently selected
78
+		);
79 79
 
80
-        // Check which years are generated.
81
-        $this->assertNotNull($months->find('YearName', 2013), 'Generates existing year');
82
-        $this->assertNull($months->find('YearName', 1990), 'Does not generate non-present year');
80
+		// Check which years are generated.
81
+		$this->assertNotNull($months->find('YearName', 2013), 'Generates existing year');
82
+		$this->assertNull($months->find('YearName', 1990), 'Does not generate non-present year');
83 83
 
84
-        $year = $months->find('YearName', 2013);
84
+		$year = $months->find('YearName', 2013);
85 85
 
86
-        // Check which months come up in 2013
87
-        $this->assertNotNull($year['Months']->find('MonthNumber', 7), 'Generates existing month');
88
-        $this->assertNull($year['Months']->find('MonthNumber', 12), 'Does not generate non-present month');
86
+		// Check which months come up in 2013
87
+		$this->assertNotNull($year['Months']->find('MonthNumber', 7), 'Generates existing month');
88
+		$this->assertNull($year['Months']->find('MonthNumber', 12), 'Does not generate non-present month');
89 89
 
90
-        $month = $year['Months']->find('MonthNumber', 7);
91
-        $this->assertEquals(
92
-            $month['MonthLink'],
93
-            'http://mybase.org/?tag=12&from=2010-10-10&to=2010-10-11&month=7&year=2013',
94
-            'Selection link is built properly - start is removed, and tag, from and to retained.'
95
-        );
90
+		$month = $year['Months']->find('MonthNumber', 7);
91
+		$this->assertEquals(
92
+			$month['MonthLink'],
93
+			'http://mybase.org/?tag=12&from=2010-10-10&to=2010-10-11&month=7&year=2013',
94
+			'Selection link is built properly - start is removed, and tag, from and to retained.'
95
+		);
96 96
 
97
-        // Check if these months are marked properly.
98
-        $month = $year['Months']->find('MonthNumber', 1);
99
-        $this->assertEquals($month['Active'], true, 'Correctly marks active link');
100
-    }
97
+		// Check if these months are marked properly.
98
+		$month = $year['Months']->find('MonthNumber', 1);
99
+		$this->assertEquals($month['Active'], true, 'Correctly marks active link');
100
+	}
101 101
 }
Please login to merge, or discard this patch.
src/PageTypes/NewsHolderController.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,30 +7,30 @@
 block discarded – undo
7 7
 
8 8
 class NewsHolderController extends DatedUpdateHolderController
9 9
 {
10
-    private static $allowed_actions = [
11
-        'rss',
12
-        'atom',
13
-    ];
10
+	private static $allowed_actions = [
11
+		'rss',
12
+		'atom',
13
+	];
14 14
 
15
-    public function rss()
16
-    {
17
-        $rss = RSSFeed::create(
18
-            $this->Updates()->sort('Created DESC')->limit(20),
19
-            $this->Link('rss'),
20
-            $this->getSubscriptionTitle()
21
-        );
22
-        $rss->setTemplate('CWP\\CWP\\PageTypes\\NewsHolder_rss');
23
-        return $rss->outputToBrowser();
24
-    }
15
+	public function rss()
16
+	{
17
+		$rss = RSSFeed::create(
18
+			$this->Updates()->sort('Created DESC')->limit(20),
19
+			$this->Link('rss'),
20
+			$this->getSubscriptionTitle()
21
+		);
22
+		$rss->setTemplate('CWP\\CWP\\PageTypes\\NewsHolder_rss');
23
+		return $rss->outputToBrowser();
24
+	}
25 25
 
26
-    public function atom()
27
-    {
28
-        $atom = CwpAtomFeed::create(
29
-            $this->Updates()->sort('Created DESC')->limit(20),
30
-            $this->Link('atom'),
31
-            $this->getSubscriptionTitle()
32
-        );
33
-        $atom->setTemplate('CWP\\CWP\\PageTypes\\NewsHolder_atom');
34
-        return $atom->outputToBrowser();
35
-    }
26
+	public function atom()
27
+	{
28
+		$atom = CwpAtomFeed::create(
29
+			$this->Updates()->sort('Created DESC')->limit(20),
30
+			$this->Link('atom'),
31
+			$this->getSubscriptionTitle()
32
+		);
33
+		$atom->setTemplate('CWP\\CWP\\PageTypes\\NewsHolder_atom');
34
+		return $atom->outputToBrowser();
35
+	}
36 36
 }
Please login to merge, or discard this patch.