Completed
Push — master ( 64e89d...d0c2d0 )
by
unknown
02:21
created
src/Extensions/CwpSiteTreeExtension.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -9,39 +9,39 @@
 block discarded – undo
9 9
 
10 10
 class CwpSiteTreeExtension extends DataExtension
11 11
 {
12
-    private static $db = array(
13
-        'ShowPageUtilities' => 'Boolean(1)'
14
-    );
12
+	private static $db = array(
13
+		'ShowPageUtilities' => 'Boolean(1)'
14
+	);
15 15
 
16
-    private static $defaults = array(
17
-        'ShowPageUtilities' => true
18
-    );
16
+	private static $defaults = array(
17
+		'ShowPageUtilities' => true
18
+	);
19 19
 
20
-    /**
21
-     * Modify the settings for a SiteTree
22
-     *
23
-     * {@inheritDoc}
24
-     *
25
-     * @param FieldList $fields
26
-     */
27
-    public function updateSettingsFields(FieldList $fields)
28
-    {
29
-        $helpText = _t(
30
-            __CLASS__ . '.SHOW_PAGE_UTILITIES_HELP',
31
-            'You can disable page utilities (print, share, etc) for this page'
32
-        );
20
+	/**
21
+	 * Modify the settings for a SiteTree
22
+	 *
23
+	 * {@inheritDoc}
24
+	 *
25
+	 * @param FieldList $fields
26
+	 */
27
+	public function updateSettingsFields(FieldList $fields)
28
+	{
29
+		$helpText = _t(
30
+			__CLASS__ . '.SHOW_PAGE_UTILITIES_HELP',
31
+			'You can disable page utilities (print, share, etc) for this page'
32
+		);
33 33
 
34
-        $fields->addFieldsToTab(
35
-            'Root.Settings',
36
-            array(
37
-                LiteralField::create('PageUtilitiesHelp', $helpText),
38
-                CheckboxField::create('ShowPageUtilities', $this->owner->fieldLabel('ShowPageUtilities'))
39
-            )
40
-        );
41
-    }
34
+		$fields->addFieldsToTab(
35
+			'Root.Settings',
36
+			array(
37
+				LiteralField::create('PageUtilitiesHelp', $helpText),
38
+				CheckboxField::create('ShowPageUtilities', $this->owner->fieldLabel('ShowPageUtilities'))
39
+			)
40
+		);
41
+	}
42 42
 
43
-    public function updateFieldLabels(&$labels)
44
-    {
45
-        $labels['ShowPageUtilities'] = _t(__CLASS__ . '.SHOW_PAGE_UTILITIES', 'Show page utilities?');
46
-    }
43
+	public function updateFieldLabels(&$labels)
44
+	{
45
+		$labels['ShowPageUtilities'] = _t(__CLASS__ . '.SHOW_PAGE_UTILITIES', 'Show page utilities?');
46
+	}
47 47
 }
Please login to merge, or discard this patch.
src/Tasks/PopulateThemeSampleDataTask.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -17,133 +17,133 @@
 block discarded – undo
17 17
  */
18 18
 class PopulateThemeSampleDataTask extends BuildTask
19 19
 {
20
-    protected $title = 'Populate sample data for theme demo';
21
-
22
-    protected $description = 'Populates some sample data for showcasing the functionality of the '
23
-        . 'starter and Wātea themes';
24
-
25
-    /**
26
-     * A series of method calls to create sample data
27
-     *
28
-     * @param HTTPRequest $request
29
-     */
30
-    public function run($request)
31
-    {
32
-        $this->handleContactForm();
33
-    }
34
-
35
-    /**
36
-     * Decide whether to create a contact user defined form, and call it to be be created if so
37
-     *
38
-     * @return $this
39
-     */
40
-    protected function handleContactForm()
41
-    {
42
-        if (!$this->getContactFormExists()) {
43
-            $this->createContactForm();
44
-        }
45
-        return $this;
46
-    }
47
-
48
-    /**
49
-     * Determine whether a "contact us" userform exists yet
50
-     *
51
-     * @return bool
52
-     */
53
-    protected function getContactFormExists()
54
-    {
55
-        $exists = false;
56
-        foreach (UserDefinedForm::get()->column('ID') as $formId) {
57
-            $count = Versioned::get_all_versions(UserDefinedForm::class, $formId)
58
-                ->filter('URLSegment', 'contact')
59
-                ->count();
60
-
61
-            if ($count >= 1) {
62
-                $exists = true;
63
-                break;
64
-            }
65
-        }
66
-        return $exists;
67
-    }
68
-
69
-    /**
70
-     * Create a "contact us" userform. Please note that this form does not have any recipients by default, so
71
-     * no emails will be sent. To add recipients - edit the page in the CMS and add a recipient via the "Recipients"
72
-     * tab.
73
-     *
74
-     * @return $this
75
-     */
76
-    protected function createContactForm()
77
-    {
78
-        $form = UserDefinedForm::create(array(
79
-            'Title' => 'Contact',
80
-            'URLSegment' => 'contact',
81
-            'Content' => '<p>$UserDefinedForm</p>',
82
-            'SubmitButtonText' => 'Submit',
83
-            'ClearButtonText' => 'Clear',
84
-            'OnCompleteMessage' => "<p>Thanks, we've received your submission and will be in touch shortly.</p>",
85
-            'EnableLiveValidation' => true
86
-        ));
87
-
88
-        $form->write();
89
-
90
-        // Add form fields
91
-        $fields = array(
92
-            EditableFormStep::create([
93
-                'Title' => _t(
94
-                    'SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFormStep.TITLE_FIRST',
95
-                    'First Page'
96
-                )
97
-            ]),
98
-            EditableTextField::create([
99
-                'Title' => 'Name',
100
-                'Required' => true,
101
-                'RightTitle' => 'Please enter your first and last name'
102
-            ]),
103
-            EditableEmailField::create([
104
-                'Title' => Email::class,
105
-                'Required' => true,
106
-                'Placeholder' => '[email protected]'
107
-            ]),
108
-            EditableTextField::create([
109
-                'Title' => 'Subject'
110
-            ]),
111
-            EditableTextField::create([
112
-                'Title' => 'Message',
113
-                'Required' => true,
114
-                'Rows' => 5
115
-            ])
116
-        );
117
-
118
-        foreach ($fields as $field) {
119
-            $field->write();
120
-            $form->Fields()->add($field);
121
-            $field->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
122
-        }
123
-
124
-        $form->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
125
-        $form->flushCache();
126
-
127
-        $this->output(' + Created "contact" UserDefinedForm page');
128
-
129
-        return $this;
130
-    }
131
-
132
-    /**
133
-     * Output a message either to the console or browser
134
-     *
135
-     * @param  string $message
136
-     * @return $this
137
-     */
138
-    protected function output($message)
139
-    {
140
-        if (Director::is_cli()) {
141
-            $message .= PHP_EOL;
142
-        } else {
143
-            $message = sprintf('<p>%s</p>', $message);
144
-        }
145
-        echo $message;
146
-
147
-        return $this;
148
-    }
20
+	protected $title = 'Populate sample data for theme demo';
21
+
22
+	protected $description = 'Populates some sample data for showcasing the functionality of the '
23
+		. 'starter and Wātea themes';
24
+
25
+	/**
26
+	 * A series of method calls to create sample data
27
+	 *
28
+	 * @param HTTPRequest $request
29
+	 */
30
+	public function run($request)
31
+	{
32
+		$this->handleContactForm();
33
+	}
34
+
35
+	/**
36
+	 * Decide whether to create a contact user defined form, and call it to be be created if so
37
+	 *
38
+	 * @return $this
39
+	 */
40
+	protected function handleContactForm()
41
+	{
42
+		if (!$this->getContactFormExists()) {
43
+			$this->createContactForm();
44
+		}
45
+		return $this;
46
+	}
47
+
48
+	/**
49
+	 * Determine whether a "contact us" userform exists yet
50
+	 *
51
+	 * @return bool
52
+	 */
53
+	protected function getContactFormExists()
54
+	{
55
+		$exists = false;
56
+		foreach (UserDefinedForm::get()->column('ID') as $formId) {
57
+			$count = Versioned::get_all_versions(UserDefinedForm::class, $formId)
58
+				->filter('URLSegment', 'contact')
59
+				->count();
60
+
61
+			if ($count >= 1) {
62
+				$exists = true;
63
+				break;
64
+			}
65
+		}
66
+		return $exists;
67
+	}
68
+
69
+	/**
70
+	 * Create a "contact us" userform. Please note that this form does not have any recipients by default, so
71
+	 * no emails will be sent. To add recipients - edit the page in the CMS and add a recipient via the "Recipients"
72
+	 * tab.
73
+	 *
74
+	 * @return $this
75
+	 */
76
+	protected function createContactForm()
77
+	{
78
+		$form = UserDefinedForm::create(array(
79
+			'Title' => 'Contact',
80
+			'URLSegment' => 'contact',
81
+			'Content' => '<p>$UserDefinedForm</p>',
82
+			'SubmitButtonText' => 'Submit',
83
+			'ClearButtonText' => 'Clear',
84
+			'OnCompleteMessage' => "<p>Thanks, we've received your submission and will be in touch shortly.</p>",
85
+			'EnableLiveValidation' => true
86
+		));
87
+
88
+		$form->write();
89
+
90
+		// Add form fields
91
+		$fields = array(
92
+			EditableFormStep::create([
93
+				'Title' => _t(
94
+					'SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFormStep.TITLE_FIRST',
95
+					'First Page'
96
+				)
97
+			]),
98
+			EditableTextField::create([
99
+				'Title' => 'Name',
100
+				'Required' => true,
101
+				'RightTitle' => 'Please enter your first and last name'
102
+			]),
103
+			EditableEmailField::create([
104
+				'Title' => Email::class,
105
+				'Required' => true,
106
+				'Placeholder' => '[email protected]'
107
+			]),
108
+			EditableTextField::create([
109
+				'Title' => 'Subject'
110
+			]),
111
+			EditableTextField::create([
112
+				'Title' => 'Message',
113
+				'Required' => true,
114
+				'Rows' => 5
115
+			])
116
+		);
117
+
118
+		foreach ($fields as $field) {
119
+			$field->write();
120
+			$form->Fields()->add($field);
121
+			$field->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
122
+		}
123
+
124
+		$form->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
125
+		$form->flushCache();
126
+
127
+		$this->output(' + Created "contact" UserDefinedForm page');
128
+
129
+		return $this;
130
+	}
131
+
132
+	/**
133
+	 * Output a message either to the console or browser
134
+	 *
135
+	 * @param  string $message
136
+	 * @return $this
137
+	 */
138
+	protected function output($message)
139
+	{
140
+		if (Director::is_cli()) {
141
+			$message .= PHP_EOL;
142
+		} else {
143
+			$message = sprintf('<p>%s</p>', $message);
144
+		}
145
+		echo $message;
146
+
147
+		return $this;
148
+	}
149 149
 }
Please login to merge, or discard this patch.
src/PageTypes/EventHolder.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -7,57 +7,57 @@
 block discarded – undo
7 7
 
8 8
 class EventHolder extends DatedUpdateHolder
9 9
 {
10
-    private static $description = 'Container page for Event Pages, provides event filtering and pagination';
11
-
12
-    private static $allowed_children = [
13
-        EventPage::class,
14
-    ];
15
-
16
-    private static $default_child = EventPage::class;
17
-
18
-    private static $update_name = 'Events';
19
-
20
-    private static $update_class = EventPage::class;
21
-
22
-    private static $icon = 'cwp/cwp:images/icons/sitetree_images/event_holder.png';
23
-
24
-    private static $singular_name = 'Event Holder';
25
-
26
-    private static $plural_name = 'Event Holders';
27
-
28
-    private static $table_name = 'EventHolder';
29
-
30
-    /**
31
-     * Find all site's news items, based on some filters.
32
-     * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
33
-     *
34
-     * @param string $className The name of the class to fetch.
35
-     * @param int $parentID The ID of the holder to extract the news items from.
36
-     * @param int $tagID The ID of the tag to filter the news items by.
37
-     * @param string $dateFrom The beginning of a date filter range.
38
-     * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for.
39
-     * @param int $year Numeric value of the year to show.
40
-     * @param int $monthNumber Numeric value of the month to show.
41
-     *
42
-     * @returns DataList|PaginatedList
43
-     */
44
-    public static function AllUpdates(
45
-        $className = 'Events',
46
-        $parentID = null,
47
-        $tagID = null,
48
-        $dateFrom = null,
49
-        $dateTo = null,
50
-        $year = null,
51
-        $monthNumber = null
52
-    ) {
53
-        return parent::AllUpdates(
54
-            $className,
55
-            $parentID,
56
-            $tagID,
57
-            $dateFrom,
58
-            $dateTo,
59
-            $year,
60
-            $monthNumber
61
-        )->Sort('Date', 'ASC');
62
-    }
10
+	private static $description = 'Container page for Event Pages, provides event filtering and pagination';
11
+
12
+	private static $allowed_children = [
13
+		EventPage::class,
14
+	];
15
+
16
+	private static $default_child = EventPage::class;
17
+
18
+	private static $update_name = 'Events';
19
+
20
+	private static $update_class = EventPage::class;
21
+
22
+	private static $icon = 'cwp/cwp:images/icons/sitetree_images/event_holder.png';
23
+
24
+	private static $singular_name = 'Event Holder';
25
+
26
+	private static $plural_name = 'Event Holders';
27
+
28
+	private static $table_name = 'EventHolder';
29
+
30
+	/**
31
+	 * Find all site's news items, based on some filters.
32
+	 * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
33
+	 *
34
+	 * @param string $className The name of the class to fetch.
35
+	 * @param int $parentID The ID of the holder to extract the news items from.
36
+	 * @param int $tagID The ID of the tag to filter the news items by.
37
+	 * @param string $dateFrom The beginning of a date filter range.
38
+	 * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for.
39
+	 * @param int $year Numeric value of the year to show.
40
+	 * @param int $monthNumber Numeric value of the month to show.
41
+	 *
42
+	 * @returns DataList|PaginatedList
43
+	 */
44
+	public static function AllUpdates(
45
+		$className = 'Events',
46
+		$parentID = null,
47
+		$tagID = null,
48
+		$dateFrom = null,
49
+		$dateTo = null,
50
+		$year = null,
51
+		$monthNumber = null
52
+	) {
53
+		return parent::AllUpdates(
54
+			$className,
55
+			$parentID,
56
+			$tagID,
57
+			$dateFrom,
58
+			$dateTo,
59
+			$year,
60
+			$monthNumber
61
+		)->Sort('Date', 'ASC');
62
+	}
63 63
 }
Please login to merge, or discard this patch.
src/PageTypes/NewsHolder.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -7,50 +7,50 @@
 block discarded – undo
7 7
 
8 8
 class NewsHolder extends DatedUpdateHolder
9 9
 {
10
-    private static $description = 'Container page for News Pages, provides news filtering and pagination';
11
-
12
-    private static $allowed_children = [
13
-        NewsPage::class,
14
-    ];
15
-
16
-    private static $default_child = NewsPage::class;
17
-
18
-    private static $update_name = 'News';
19
-
20
-    private static $update_class = NewsPage::class;
21
-
22
-    private static $icon = 'cwp/cwp:images/icons/sitetree_images/news_listing.png';
23
-
24
-    private static $singular_name = 'News Holder';
25
-
26
-    private static $plural_name = 'News Holders';
27
-
28
-    private static $table_name = 'NewsHolder';
29
-
30
-    /**
31
-     * Find all site's news items, based on some filters.
32
-     * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
33
-     *
34
-     * @param string $className The name of the class to fetch.
35
-     * @param int $parentID The ID of the holder to extract the news items from.
36
-     * @param int $tagID The ID of the tag to filter the news items by.
37
-     * @param string $dateFrom The beginning of a date filter range.
38
-     * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for.
39
-     * @param int $year Numeric value of the year to show.
40
-     * @param int $monthNumber Numeric value of the month to show.
41
-     *
42
-     * @returns DataList|PaginatedList
43
-     */
44
-    public static function AllUpdates(
45
-        $className = NewsPage::class,
46
-        $parentID = null,
47
-        $tagID = null,
48
-        $dateFrom = null,
49
-        $dateTo = null,
50
-        $year = null,
51
-        $monthNumber = null
52
-    ) {
53
-        return parent::AllUpdates($className, $parentID, $tagID, $dateFrom, $dateTo, $year, $monthNumber)
54
-            ->Sort('Date', 'DESC');
55
-    }
10
+	private static $description = 'Container page for News Pages, provides news filtering and pagination';
11
+
12
+	private static $allowed_children = [
13
+		NewsPage::class,
14
+	];
15
+
16
+	private static $default_child = NewsPage::class;
17
+
18
+	private static $update_name = 'News';
19
+
20
+	private static $update_class = NewsPage::class;
21
+
22
+	private static $icon = 'cwp/cwp:images/icons/sitetree_images/news_listing.png';
23
+
24
+	private static $singular_name = 'News Holder';
25
+
26
+	private static $plural_name = 'News Holders';
27
+
28
+	private static $table_name = 'NewsHolder';
29
+
30
+	/**
31
+	 * Find all site's news items, based on some filters.
32
+	 * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
33
+	 *
34
+	 * @param string $className The name of the class to fetch.
35
+	 * @param int $parentID The ID of the holder to extract the news items from.
36
+	 * @param int $tagID The ID of the tag to filter the news items by.
37
+	 * @param string $dateFrom The beginning of a date filter range.
38
+	 * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for.
39
+	 * @param int $year Numeric value of the year to show.
40
+	 * @param int $monthNumber Numeric value of the month to show.
41
+	 *
42
+	 * @returns DataList|PaginatedList
43
+	 */
44
+	public static function AllUpdates(
45
+		$className = NewsPage::class,
46
+		$parentID = null,
47
+		$tagID = null,
48
+		$dateFrom = null,
49
+		$dateTo = null,
50
+		$year = null,
51
+		$monthNumber = null
52
+	) {
53
+		return parent::AllUpdates($className, $parentID, $tagID, $dateFrom, $dateTo, $year, $monthNumber)
54
+			->Sort('Date', 'DESC');
55
+	}
56 56
 }
Please login to merge, or discard this patch.
src/PageTypes/EventHolderController.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -19,53 +19,53 @@
 block discarded – undo
19 19
  */
20 20
 class EventHolderController extends DatedUpdateHolderController
21 21
 {
22
-    public function getUpdateName()
23
-    {
24
-        $params = $this->parseParams();
25
-        if ($params['upcomingOnly']) {
26
-            return _t('CWP\\CWP\\PageTypes\\EventHolder.Upcoming', 'Upcoming events');
27
-        }
22
+	public function getUpdateName()
23
+	{
24
+		$params = $this->parseParams();
25
+		if ($params['upcomingOnly']) {
26
+			return _t('CWP\\CWP\\PageTypes\\EventHolder.Upcoming', 'Upcoming events');
27
+		}
28 28
 
29
-        return 'Events';
30
-    }
29
+		return 'Events';
30
+	}
31 31
 
32
-    /**
33
-     * Parse URL parameters.
34
-     *
35
-     * @param boolean $produceErrorMessages Set to false to omit session messages.
36
-     */
37
-    public function parseParams($produceErrorMessages = true)
38
-    {
39
-        $params = parent::parseParams($produceErrorMessages);
32
+	/**
33
+	 * Parse URL parameters.
34
+	 *
35
+	 * @param boolean $produceErrorMessages Set to false to omit session messages.
36
+	 */
37
+	public function parseParams($produceErrorMessages = true)
38
+	{
39
+		$params = parent::parseParams($produceErrorMessages);
40 40
 
41
-        // We need to set whether or not we're supposed to be displaying only upcoming events or all events.
42
-        $params['upcomingOnly'] = !($params['from'] || $params['to'] || $params['year'] || $params['month']);
41
+		// We need to set whether or not we're supposed to be displaying only upcoming events or all events.
42
+		$params['upcomingOnly'] = !($params['from'] || $params['to'] || $params['year'] || $params['month']);
43 43
 
44
-        return $params;
45
-    }
44
+		return $params;
45
+	}
46 46
 
47
-    /**
48
-     * Get the events based on the current query.
49
-     */
50
-    public function FilteredUpdates($pageSize = 20)
51
-    {
52
-        $params = $this->parseParams();
47
+	/**
48
+	 * Get the events based on the current query.
49
+	 */
50
+	public function FilteredUpdates($pageSize = 20)
51
+	{
52
+		$params = $this->parseParams();
53 53
 
54
-        $items = $this->Updates(
55
-            $params['tag'],
56
-            $params['from'],
57
-            $params['to'],
58
-            $params['year'],
59
-            $params['month']
60
-        );
54
+		$items = $this->Updates(
55
+			$params['tag'],
56
+			$params['from'],
57
+			$params['to'],
58
+			$params['year'],
59
+			$params['month']
60
+		);
61 61
 
62
-        if ($params['upcomingOnly']) {
63
-            $items = $items->filter(['Date:LessThan:Not' => DBDatetime::now()->Format('y-MM-dd')]);
64
-        }
62
+		if ($params['upcomingOnly']) {
63
+			$items = $items->filter(['Date:LessThan:Not' => DBDatetime::now()->Format('y-MM-dd')]);
64
+		}
65 65
 
66
-        // Apply pagination
67
-        $list = PaginatedList::create($items, $this->getRequest());
68
-        $list->setPageLength($pageSize);
69
-        return $list;
70
-    }
66
+		// Apply pagination
67
+		$list = PaginatedList::create($items, $this->getRequest());
68
+		$list->setPageLength($pageSize);
69
+		return $list;
70
+	}
71 71
 }
Please login to merge, or discard this patch.
src/PageTypes/EventPage.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -12,81 +12,81 @@
 block discarded – undo
12 12
 
13 13
 class EventPage extends DatedUpdatePage
14 14
 {
15
-    private static $description = 'Describes an event occurring on a specific date.';
16
-
17
-    private static $default_parent = EventHolder::class;
18
-
19
-    private static $can_be_root = false;
20
-
21
-    private static $icon = 'cwp/cwp:images/icons/sitetree_images/event_page.png';
22
-
23
-    private static $singular_name = 'Event Page';
24
-
25
-    private static $plural_name = 'Event Pages';
26
-
27
-    private static $db = [
28
-        'StartTime' => 'Time',
29
-        'EndTime' => 'Time',
30
-        'Location' => 'Text',
31
-    ];
32
-
33
-    private static $table_name = 'EventPage';
34
-
35
-    public function fieldLabels($includerelations = true)
36
-    {
37
-        $labels = parent::fieldLabels($includerelations);
38
-        $labels['StartTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.StartTimeFieldLabel', 'Start Time');
39
-        $labels['EndTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.EndTimeFieldLabel', 'End Time');
40
-        $labels['Location'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.LocationFieldLabel', 'Location');
41
-
42
-        return $labels;
43
-    }
44
-
45
-    /**
46
-     * Add the default for the Date being the current day.
47
-     */
48
-    public function populateDefaults()
49
-    {
50
-        if (!isset($this->Date) || $this->Date === null) {
51
-            $this->Date = DBDatetime::now()->Format('y-MM-dd');
52
-        }
53
-
54
-        if (!isset($this->StartTime) || $this->StartTime === null) {
55
-            $this->StartTime = '09:00:00';
56
-        }
57
-
58
-        if (!isset($this->EndTime) || $this->EndTime === null) {
59
-            $this->EndTime = '17:00:00';
60
-        }
61
-
62
-        parent::populateDefaults();
63
-    }
64
-
65
-    public function getCMSFields()
66
-    {
67
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
68
-            $fields->removeByName('Date');
69
-
70
-            $dateTimeFields = array();
71
-
72
-            $dateTimeFields[] = $dateField = DateField::create('Date', 'Date');
73
-            $dateTimeFields[] = $startTimeField = TimeField::create(
74
-                'StartTime',
75
-                '&nbsp;&nbsp;' . $this->fieldLabel('StartTime')
76
-            );
77
-            $dateTimeFields[] = $endTimeField = TimeField::create('EndTime', $this->fieldLabel('EndTime'));
78
-
79
-            $fields->addFieldsToTab('Root.Main', [
80
-                $dateTimeField = FieldGroup::create('Date and time', $dateTimeFields),
81
-                $locationField = TextareaField::create('Location', $this->fieldLabel('Location'))
82
-            ], 'Abstract');
83
-            $locationField->setRows(4);
84
-        });
85
-        return parent::getCMSFields();
86
-    }
87
-
88
-    public function NiceLocation()
89
-    {
90
-        return nl2br(Convert::raw2xml($this->Location), true);
91
-    }
15
+	private static $description = 'Describes an event occurring on a specific date.';
16
+
17
+	private static $default_parent = EventHolder::class;
18
+
19
+	private static $can_be_root = false;
20
+
21
+	private static $icon = 'cwp/cwp:images/icons/sitetree_images/event_page.png';
22
+
23
+	private static $singular_name = 'Event Page';
24
+
25
+	private static $plural_name = 'Event Pages';
26
+
27
+	private static $db = [
28
+		'StartTime' => 'Time',
29
+		'EndTime' => 'Time',
30
+		'Location' => 'Text',
31
+	];
32
+
33
+	private static $table_name = 'EventPage';
34
+
35
+	public function fieldLabels($includerelations = true)
36
+	{
37
+		$labels = parent::fieldLabels($includerelations);
38
+		$labels['StartTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.StartTimeFieldLabel', 'Start Time');
39
+		$labels['EndTime'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.EndTimeFieldLabel', 'End Time');
40
+		$labels['Location'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.LocationFieldLabel', 'Location');
41
+
42
+		return $labels;
43
+	}
44
+
45
+	/**
46
+	 * Add the default for the Date being the current day.
47
+	 */
48
+	public function populateDefaults()
49
+	{
50
+		if (!isset($this->Date) || $this->Date === null) {
51
+			$this->Date = DBDatetime::now()->Format('y-MM-dd');
52
+		}
53
+
54
+		if (!isset($this->StartTime) || $this->StartTime === null) {
55
+			$this->StartTime = '09:00:00';
56
+		}
57
+
58
+		if (!isset($this->EndTime) || $this->EndTime === null) {
59
+			$this->EndTime = '17:00:00';
60
+		}
61
+
62
+		parent::populateDefaults();
63
+	}
64
+
65
+	public function getCMSFields()
66
+	{
67
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
68
+			$fields->removeByName('Date');
69
+
70
+			$dateTimeFields = array();
71
+
72
+			$dateTimeFields[] = $dateField = DateField::create('Date', 'Date');
73
+			$dateTimeFields[] = $startTimeField = TimeField::create(
74
+				'StartTime',
75
+				'&nbsp;&nbsp;' . $this->fieldLabel('StartTime')
76
+			);
77
+			$dateTimeFields[] = $endTimeField = TimeField::create('EndTime', $this->fieldLabel('EndTime'));
78
+
79
+			$fields->addFieldsToTab('Root.Main', [
80
+				$dateTimeField = FieldGroup::create('Date and time', $dateTimeFields),
81
+				$locationField = TextareaField::create('Location', $this->fieldLabel('Location'))
82
+			], 'Abstract');
83
+			$locationField->setRows(4);
84
+		});
85
+		return parent::getCMSFields();
86
+	}
87
+
88
+	public function NiceLocation()
89
+	{
90
+		return nl2br(Convert::raw2xml($this->Location), true);
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
 
65 65
     public function getCMSFields()
66 66
     {
67
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
67
+        $this->beforeUpdateCMSFields(function(FieldList $fields) {
68 68
             $fields->removeByName('Date');
69 69
 
70 70
             $dateTimeFields = array();
Please login to merge, or discard this patch.
src/PageTypes/NewsPage.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -9,55 +9,55 @@
 block discarded – undo
9 9
 
10 10
 class NewsPage extends DatedUpdatePage
11 11
 {
12
-    private static $description = 'Describes an item of news';
12
+	private static $description = 'Describes an item of news';
13 13
 
14
-    private static $default_parent = 'NewsHolderPage';
14
+	private static $default_parent = 'NewsHolderPage';
15 15
 
16
-    private static $can_be_root = false;
16
+	private static $can_be_root = false;
17 17
 
18
-    private static $icon = 'cwp/cwp:images/icons/sitetree_images/news.png';
18
+	private static $icon = 'cwp/cwp:images/icons/sitetree_images/news.png';
19 19
 
20
-    private static $singular_name = 'News Page';
20
+	private static $singular_name = 'News Page';
21 21
 
22
-    private static $plural_name = 'News Pages';
22
+	private static $plural_name = 'News Pages';
23 23
 
24
-    private static $db = [
25
-        'Author' => 'Varchar(255)',
26
-    ];
24
+	private static $db = [
25
+		'Author' => 'Varchar(255)',
26
+	];
27 27
 
28
-    private static $has_one = [
29
-        'FeaturedImage' => Image::class,
30
-    ];
28
+	private static $has_one = [
29
+		'FeaturedImage' => Image::class,
30
+	];
31 31
 
32
-    private static $table_name = 'NewsPage';
32
+	private static $table_name = 'NewsPage';
33 33
 
34
-    public function fieldLabels($includerelations = true)
35
-    {
36
-        $labels = parent::fieldLabels($includerelations);
37
-        $labels['Author'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.AuthorFieldLabel', 'Author');
38
-        $labels['FeaturedImageID'] = _t(
39
-            'CWP\\CWP\\PageTypes\\DateUpdatePage.FeaturedImageFieldLabel',
40
-            'Featured Image'
41
-        );
34
+	public function fieldLabels($includerelations = true)
35
+	{
36
+		$labels = parent::fieldLabels($includerelations);
37
+		$labels['Author'] = _t('CWP\\CWP\\PageTypes\\DateUpdatePage.AuthorFieldLabel', 'Author');
38
+		$labels['FeaturedImageID'] = _t(
39
+			'CWP\\CWP\\PageTypes\\DateUpdatePage.FeaturedImageFieldLabel',
40
+			'Featured Image'
41
+		);
42 42
 
43
-        return $labels;
44
-    }
43
+		return $labels;
44
+	}
45 45
 
46
-    public function getCMSFields()
47
-    {
48
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
49
-            $fields->addFieldToTab(
50
-                'Root.Main',
51
-                TextField::create('Author', $this->fieldLabel('Author')),
52
-                'Abstract'
53
-            );
46
+	public function getCMSFields()
47
+	{
48
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
49
+			$fields->addFieldToTab(
50
+				'Root.Main',
51
+				TextField::create('Author', $this->fieldLabel('Author')),
52
+				'Abstract'
53
+			);
54 54
 
55
-            $fields->addFieldToTab(
56
-                'Root.Main',
57
-                UploadField::create('FeaturedImage', $this->fieldLabel('FeaturedImageID')),
58
-                'Abstract'
59
-            );
60
-        });
61
-        return parent::getCMSFields();
62
-    }
55
+			$fields->addFieldToTab(
56
+				'Root.Main',
57
+				UploadField::create('FeaturedImage', $this->fieldLabel('FeaturedImageID')),
58
+				'Abstract'
59
+			);
60
+		});
61
+		return parent::getCMSFields();
62
+	}
63 63
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 
46 46
     public function getCMSFields()
47 47
     {
48
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
48
+        $this->beforeUpdateCMSFields(function(FieldList $fields) {
49 49
             $fields->addFieldToTab(
50 50
                 'Root.Main',
51 51
                 TextField::create('Author', $this->fieldLabel('Author')),
Please login to merge, or discard this patch.
tests/Tasks/CleanupGeneratedPdfDailyTaskTest.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -9,26 +9,26 @@
 block discarded – undo
9 9
 
10 10
 class CleanupGeneratedPdfDailyTaskTest extends SapphireTest
11 11
 {
12
-    /**
13
-     * @var CleanupGeneratedPdfDailyTask
14
-     */
15
-    protected $task;
12
+	/**
13
+	 * @var CleanupGeneratedPdfDailyTask
14
+	 */
15
+	protected $task;
16 16
 
17
-    protected function setUp()
18
-    {
19
-        parent::setUp();
17
+	protected function setUp()
18
+	{
19
+		parent::setUp();
20 20
 
21
-        if (!interface_exists(CronTask::class)) {
22
-            $this->markTestSkipped('Test class requires the silverstripe/crontask module to be installed');
23
-        }
21
+		if (!interface_exists(CronTask::class)) {
22
+			$this->markTestSkipped('Test class requires the silverstripe/crontask module to be installed');
23
+		}
24 24
 
25
-        $this->task = new CleanupGeneratedPdfDailyTask();
26
-    }
25
+		$this->task = new CleanupGeneratedPdfDailyTask();
26
+	}
27 27
 
28
-    public function testCronScheduleIsConfigurable()
29
-    {
30
-        Config::modify()->set(CleanupGeneratedPdfDailyTask::class, 'schedule', '* 1 2 3 *');
28
+	public function testCronScheduleIsConfigurable()
29
+	{
30
+		Config::modify()->set(CleanupGeneratedPdfDailyTask::class, 'schedule', '* 1 2 3 *');
31 31
 
32
-        $this->assertSame('* 1 2 3 *', $this->task->getSchedule());
33
-    }
32
+		$this->assertSame('* 1 2 3 *', $this->task->getSchedule());
33
+	}
34 34
 }
Please login to merge, or discard this patch.
src/Tasks/CleanupGeneratedPdfDailyTask.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use SilverStripe\CronTask\Interfaces\CronTask;
8 8
 
9 9
 if (!interface_exists(CronTask::class)) {
10
-    return;
10
+	return;
11 11
 }
12 12
 
13 13
 /**
@@ -15,36 +15,36 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class CleanupGeneratedPdfDailyTask implements CronTask
17 17
 {
18
-    use Configurable;
19
-
20
-    /**
21
-     * The cron schedule for this task (default: midnight every day)
22
-     *
23
-     * @config
24
-     * @var string
25
-     */
26
-    private static $schedule = '0 0 * * *';
27
-
28
-    /**
29
-     * Whether this task is enabled (default false)
30
-     *
31
-     * @config
32
-     * @return bool
33
-     */
34
-    private static $enabled = false;
35
-
36
-    public function getSchedule()
37
-    {
38
-        return $this->config()->get('schedule');
39
-    }
40
-
41
-    public function process()
42
-    {
43
-        if (!$this->config()->get('enabled')) {
44
-            return;
45
-        }
46
-
47
-        $task = Injector::inst()->create(CleanupGeneratedPdfBuildTask::class);
48
-        $task->run(null);
49
-    }
18
+	use Configurable;
19
+
20
+	/**
21
+	 * The cron schedule for this task (default: midnight every day)
22
+	 *
23
+	 * @config
24
+	 * @var string
25
+	 */
26
+	private static $schedule = '0 0 * * *';
27
+
28
+	/**
29
+	 * Whether this task is enabled (default false)
30
+	 *
31
+	 * @config
32
+	 * @return bool
33
+	 */
34
+	private static $enabled = false;
35
+
36
+	public function getSchedule()
37
+	{
38
+		return $this->config()->get('schedule');
39
+	}
40
+
41
+	public function process()
42
+	{
43
+		if (!$this->config()->get('enabled')) {
44
+			return;
45
+		}
46
+
47
+		$task = Injector::inst()->create(CleanupGeneratedPdfBuildTask::class);
48
+		$task->run(null);
49
+	}
50 50
 }
Please login to merge, or discard this patch.