-
Notifications
You must be signed in to change notification settings - Fork 3
/
Event.php
104 lines (87 loc) · 3.36 KB
/
Event.php
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
namespace IdnoPlugins\Event {
class Event extends \Idno\Common\Entity
{
function getTitle()
{
if (empty($this->title)) return \Idno\Core\Idno::site()->language()->_('Untitled');
return $this->title;
}
function getDescription()
{
if (!empty($this->body)) return $this->body;
return '';
}
function getURL()
{
// If we have a URL override, use it
if (!empty($this->url)) {
return $this->url;
}
if (!empty($this->canonical)) {
return $this->canonical;
}
if (!($this->getSlug()) && ($this->getID())) {
return \Idno\Core\Idno::site()->config()->url . 'event/' . $this->getID() . '/' . $this->getPrettyURLTitle();
} else {
return parent::getURL();
}
}
/**
* Event objects have type 'article'
* @return 'article'
*/
function getActivityStreamsObjectType()
{
return 'event';
}
/**
* Event objects show up as h-event in a Microformats stream
* @return string
*/
function getMicroformats2ObjectType()
{
return 'h-event';
}
function saveDataFromInput()
{
if (empty($this->_id)) {
$new = true;
} else {
$new = false;
}
$body = \Idno\Core\Idno::site()->currentPage()->getInput('body');
if (!empty($body)) {
$this->body = $body;
$this->title = \Idno\Core\Idno::site()->currentPage()->getInput('title');
$this->summary = \Idno\Core\Idno::site()->currentPage()->getInput('summary');
$this->location = \Idno\Core\Idno::site()->currentPage()->getInput('location');
$this->starttime = \Idno\Core\Idno::site()->currentPage()->getInput('starttime');
$this->endtime = \Idno\Core\Idno::site()->currentPage()->getInput('endtime');
$this->timezone = \Idno\Core\Idno::site()->currentPage()->getInput('timezone');
$access = \Idno\Core\Idno::site()->currentPage()->getInput('access');
if ($time = \Idno\Core\Idno::site()->currentPage()->getInput('created')) {
if ($time = strtotime($time)) {
$this->created = $time;
}
}
$this->setAccess($access);
if ($this->publish($new)) {
if ($this->getAccess() == 'PUBLIC') {
\Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getDescription()));
}
return true;
}
} else {
\Idno\Core\Idno::site()->session()->addErrorMessage(\Idno\Core\Idno::site()->language()->_('You can\'t save an event with no description.'));
}
return false;
}
function deleteData()
{
if ($this->getAccess() == 'PUBLIC') {
\Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getDescription()));
}
}
}
}