-
Notifications
You must be signed in to change notification settings - Fork 0
/
Slides.php
93 lines (78 loc) · 3.07 KB
/
Slides.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
<?php
namespace IdnoPlugins\Presentation {
class Slides extends \Idno\Common\Entity {
function getTitle() {
if (empty($this->title)) return 'Untitled';
return $this->title;
}
function getDescription() {
if (!empty($this->slides)) {
if (is_array($this->slides)) {
return implode(' ',$this->slides);
} else {
return $this->slides;
}
}
return '';
}
function getShortDescription() {
$slides = sizeof($this->slides);
if ($slides == 1) {
$s = '';
} else {
$s = 's';
}
return 'Presentation with ' . sizeof($this->slides) . ' slide' . $s;
}
function getURL() {
if (($this->getID())) {
return \Idno\Core\site()->config()->url . 'slides/' . $this->getID(); // . '/' . $this->getPrettyURLTitle();
} else {
return parent::getURL();
}
}
/**
* Slides objects have type 'article'
* @return 'article'
*/
function getActivityStreamsObjectType() {
return 'article';
}
function saveDataFromInput() {
if (empty($this->_id)) {
$new = true;
} else {
$new = false;
}
$slides = \Idno\Core\site()->currentPage()->getInput('slide');
$title = \Idno\Core\site()->currentPage()->getInput('title');
// Remove blank slides
if (is_array($slides)) {
foreach($slides as $key => $slide) {
if (empty($slide)) {
unset($slides[$key]);
}
}
} else {
$slides = array();
}
$this->slides = $slides;
$this->title = $title;
$this->body = $this->getDescription();
$this->setAccess('PUBLIC');
if ($this->save()) {
if ($new) {
// Add it to the Activity Streams feed
$this->addToFeed();
}
\Idno\Core\Webmention::pingMentions(\Idno\Core\site()->config()->url . 'slides/' . $this->getID() . '/view/', \Idno\Core\site()->template()->parseURLs($this->getDescription()));
\Idno\Core\site()->session()->addMessage('Your slides were successfully saved.');
return true;
}
return false;
}
function deleteData() {
\Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\site()->template()->parseURLs($this->getDescription()));
}
}
}