Skip to content

Commit

Permalink
Merge pull request #19 from mzur/dev
Browse files Browse the repository at this point in the history
Converts all fixed event field names to snake case. Fixes #18.
  • Loading branch information
mzur committed Jan 15, 2015
2 parents 10ab3c5 + b284838 commit 7e75148
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ Title: Calendar
Calendar:
-
summary: My Event
_beginDate: 12/14/2014
_beginTime: 10:00
_endDate: 12/14/2014
_endTime: 15:00
_begin_date: 12/14/2014
_begin_time: 10:00
_end_date: 12/14/2014
_end_time: 15:00
-
summary: My supercool event for the whole day
description: This wil be a nice event!
_beginDate: 10/01/2014
_begin_date: 10/01/2014
```

The `Calendar` field contains all events in a [YAML](http://getkirby.com/blog/structured-field-content) list. Each event has several own fields, too, but of them only `_beginDate` is mandatory (see [event-fields](#event-fields)). You can define as many other fields as you like.
The `Calendar` field contains all events in a [YAML](http://getkirby.com/blog/structured-field-content) list. Each event has several own fields, too, but of them only `_begin_date` is mandatory (see [event-fields](#event-fields)). You can define as many other fields as you like.

### Calendar object

Expand Down Expand Up @@ -120,20 +120,20 @@ The locale is set by Kirby's language configuration. So if you've set up everyth

Events can have arbitrary fields. However there are the special fields for this plugin marked by a `_`-prefix:

- `_beginDate`: The only **mandatory** field specifying the date, the event begins.
- `_beginTime`: The time of the day the event begins.
- `_endDate`: The date the event ends.
- `_endTime`: The time of the day the event ends.
- `_begin_date`: The only **mandatory** field specifying the date, the event begins.
- `_begin_time`: The time of the day the event begins.
- `_end_date`: The date the event ends.
- `_end_time`: The time of the day the event ends.

The behavior with different combinations of these fields is the following:

- only `_beginDate` given: The event lasts the whole day.
- only `_begin_date` given: The event lasts the whole day.

- `_beginDate` and `_beginTime` given: The event lasts from the given time until midnight (12 am) of the following day.
- `_begin_date` and `_begin_time` given: The event lasts from the given time until midnight (12 am) of the following day.

- `_beginDate` and `_endTime` given: The event lasts from midnight until the given time of the day.
- `_begin_date` and `_end_time` given: The event lasts from midnight until the given time of the day.

- `_beginDate` and `_endDate` given: The event lasts from mindnight of the beginning day until midnight of the day after the ending day.
- `_begin_date` and `_end_date` given: The event lasts from mindnight of the beginning day until midnight of the day after the ending day.

## Functions

Expand Down
12 changes: 6 additions & 6 deletions blueprints/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
entry: >
<strong>{{summary}}</strong><br>
{{description}}<br>
Beginning: {{_beginDate}} {{_beginTime}}<br>
End: {{_endDate}} {{_endTime}}
Beginning: {{_begin_date}} {{_begin_time}}<br>
End: {{_end_date}} {{_end_time}}
fields:
summary:
label: Summary
Expand All @@ -22,19 +22,19 @@
label: Description
type: textarea
size: small
_beginDate:
_begin_date:
label: Beginning date
type: date
format: MM/DD/YYYY
_beginTime:
_begin_time:
label: Beginning time
type: time
interval: 15
_endDate:
_end_date:
label: Ending date
type: date
format: MM/DD/YYYY
_endTime:
_end_time:
label: Ending time
type: time
interval: 15
10 changes: 5 additions & 5 deletions calendar/lib/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ class Event {
/**
* The string for the beginning date field key of an event.
*/
const beginDateKey = '_beginDate';
const beginDateKey = '_begin_date';

/**
* The string for the beginning time field key of an event.
*/
const beginTimeKey = '_beginTime';
const beginTimeKey = '_begin_time';

/**
* The string for the end date field key of an event.
*/
const endDateKey = '_endDate';
const endDateKey = '_end_date';

/**
* The string for the end time field key of an event.
*/
const endTimeKey = '_endTime';
const endTimeKey = '_end_time';

/**
* An array of field keys that are required to create an event.
Expand Down Expand Up @@ -66,7 +66,7 @@ class Event {

/**
* @param array $event The fields of this event including the 'private'
* fields which start with a <code>_</code> (e.g. <code>_beginDate</code>).
* fields which start with a <code>_</code> (e.g. <code>_begin_date</code>).
*/
function __construct($event) {
self::validate($event);
Expand Down

0 comments on commit 7e75148

Please sign in to comment.