Passed
Push — master ( 7075a8...97270a )
by Robbie
09:53 queued 07:47
created
src/PageTypes/FooterHolder.php 1 patch
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.
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/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 1 patch
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.
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.
src/Extensions/CwpCommentingExtension.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@
 block discarded – undo
13 13
  */
14 14
 class CwpCommentingExtension extends Extension
15 15
 {
16
-    public function alterCommentForm(Form $form)
17
-    {
18
-        $fields = $form->Fields();
16
+	public function alterCommentForm(Form $form)
17
+	{
18
+		$fields = $form->Fields();
19 19
 
20
-        if ($emailField = $fields->dataFieldByName(Email::class)) {
21
-            $emailField
22
-                ->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', Email::class))
23
-                ->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.'));
24
-        }
20
+		if ($emailField = $fields->dataFieldByName(Email::class)) {
21
+			$emailField
22
+				->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', Email::class))
23
+				->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.'));
24
+		}
25 25
 
26
-        if ($urlField = $fields->dataFieldByName('URL')) {
27
-            $urlField
28
-                ->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)'))
29
-                ->setAttribute('placeholder', 'http://');
30
-        }
31
-    }
26
+		if ($urlField = $fields->dataFieldByName('URL')) {
27
+			$urlField
28
+				->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)'))
29
+				->setAttribute('placeholder', 'http://');
30
+		}
31
+	}
32 32
 }
Please login to merge, or discard this patch.
src/Extensions/CwpSiteTreeFileExtension.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -11,53 +11,53 @@
 block discarded – undo
11 11
 class CwpSiteTreeFileExtension extends DataExtension
12 12
 {
13 13
 
14
-    public function updateCMSFields(FieldList $fields)
15
-    {
16
-        Requirements::css('cwp/cwp:css/fieldDescriptionToggle.css');
17
-        Requirements::javascript('cwp/cwp:javascript/fieldDescriptionToggle.js');
18
-
19
-        $fields->insertAfter(
20
-            'LastEdited',
21
-            ReadonlyField::create(
22
-                'BackLinkCount',
23
-                _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.BACKLINKCOUNT', 'Used on:'),
24
-                $this->owner->BackLinkTracking()->Count() . ' '
25
-                    . _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.PAGES', 'page(s)')
26
-            )
27
-            ->addExtraClass('cms-description-toggle')
28
-            ->setDescription($this->BackLinkHTMLList())
29
-        );
30
-    }
31
-
32
-    /**
33
-     * Generate an HTML list which provides links to where a file is used.
34
-     *
35
-     * @return string
36
-     */
37
-    public function BackLinkHTMLList()
38
-    {
39
-        $html = '<em>' . _t(
40
-            __CLASS__ . '.BACKLINK_LIST_DESCRIPTION',
41
-            'This list shows all pages where the file has been added through a WYSIWYG editor.'
42
-        ) . '</em>';
43
-        $html .= '<ul>';
44
-
45
-        foreach ($this->owner->BackLinkTracking() as $backLink) {
46
-            $listItem = '<li>';
47
-
48
-            // Add the page link
49
-            $listItem .= '<a href="' . $backLink->Link() . '" target="_blank">'
50
-                . Convert::raw2xml($backLink->MenuTitle) . '</a> &ndash; ';
51
-
52
-            // Add the CMS link
53
-            $listItem .= '<a href="' . $backLink->CMSEditLink() . '">'
54
-                . _t(__CLASS__ . '.EDIT', 'Edit') . '</a>';
55
-
56
-            $html .= $listItem . '</li>';
57
-        }
58
-
59
-        $html .= '</ul>';
60
-
61
-        return $html;
62
-    }
14
+	public function updateCMSFields(FieldList $fields)
15
+	{
16
+		Requirements::css('cwp/cwp:css/fieldDescriptionToggle.css');
17
+		Requirements::javascript('cwp/cwp:javascript/fieldDescriptionToggle.js');
18
+
19
+		$fields->insertAfter(
20
+			'LastEdited',
21
+			ReadonlyField::create(
22
+				'BackLinkCount',
23
+				_t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.BACKLINKCOUNT', 'Used on:'),
24
+				$this->owner->BackLinkTracking()->Count() . ' '
25
+					. _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.PAGES', 'page(s)')
26
+			)
27
+			->addExtraClass('cms-description-toggle')
28
+			->setDescription($this->BackLinkHTMLList())
29
+		);
30
+	}
31
+
32
+	/**
33
+	 * Generate an HTML list which provides links to where a file is used.
34
+	 *
35
+	 * @return string
36
+	 */
37
+	public function BackLinkHTMLList()
38
+	{
39
+		$html = '<em>' . _t(
40
+			__CLASS__ . '.BACKLINK_LIST_DESCRIPTION',
41
+			'This list shows all pages where the file has been added through a WYSIWYG editor.'
42
+		) . '</em>';
43
+		$html .= '<ul>';
44
+
45
+		foreach ($this->owner->BackLinkTracking() as $backLink) {
46
+			$listItem = '<li>';
47
+
48
+			// Add the page link
49
+			$listItem .= '<a href="' . $backLink->Link() . '" target="_blank">'
50
+				. Convert::raw2xml($backLink->MenuTitle) . '</a> &ndash; ';
51
+
52
+			// Add the CMS link
53
+			$listItem .= '<a href="' . $backLink->CMSEditLink() . '">'
54
+				. _t(__CLASS__ . '.EDIT', 'Edit') . '</a>';
55
+
56
+			$html .= $listItem . '</li>';
57
+		}
58
+
59
+		$html .= '</ul>';
60
+
61
+		return $html;
62
+	}
63 63
 }
Please login to merge, or discard this patch.