-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEvent.php
More file actions
54 lines (49 loc) · 1.09 KB
/
Copy pathEvent.php
File metadata and controls
54 lines (49 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php namespace ProcessWire;
/**
* FieldtypeEvents: Event
*
* An individual event item to be part of an EventArray for a Page
*
* @property string $date Date string in Y-m-d format
* @property string $title Title of the event
* @property bool $formatted
*
*/
class Event extends WireData {
/**
* Construct a new Event
*
*/
public function __construct() {
// define the fields that represent our event (and their default/blank values)
$this->set('date', '');
$this->set('title', '');
$this->set('formatted', false);
parent::__construct();
}
/**
* Set a value to the event: date, location or notes
*
* @param string $key
* @param string $value
* @return WireData|self
*
*/
public function set($key, $value) {
if($key === 'date') {
$value = $value ? wireDate('Y-m-d', $value) : '';
} else if($key === 'title') {
$value = $this->sanitizer->text($value);
}
return parent::set($key, $value);
}
/**
* Return a string representing this event
*
* @return string
*
*/
public function __toString() {
return "$this->date: $this->title";
}
}