3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2011, StatusNet, Inc.
6 * Notice-list representation of an event
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Evan Prodromou <evan@status.net>
26 * @copyright 2011 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28 * @link http://status.net/
31 if (!defined('STATUSNET')) {
32 // This check helps protect against security problems;
33 // your code file can't be executed directly from the web.
38 * Notice-list representation of an event
42 * @author Evan Prodromou <evan@status.net>
43 * @copyright 2011 StatusNet, Inc.
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
45 * @link http://status.net/
47 class EventListItem extends NoticeListItemAdapter
51 $this->nli->out->elementStart('div', 'entry-title');
52 $this->nli->showAuthor();
54 $this->nli->out->elementEnd('div');
57 function showContent()
59 $notice = $this->nli->notice;
60 $out = $this->nli->out;
62 $profile = $notice->getProfile();
63 $event = Happening::fromNotice($notice);
66 // TRANS: Content for a deleted RSVP list item (RSVP stands for "please respond").
67 $out->element('p', null, _m('Deleted.'));
71 $out->elementStart('div', 'vevent event'); // VEVENT IN
73 $out->elementStart('h3'); // VEVENT/H3 IN
75 if (!empty($event->url)) {
77 array('href' => $event->url,
78 'class' => 'event-title entry-title summary'),
81 $out->text($event->title);
84 $out->elementEnd('h3'); // VEVENT/H3 OUT
86 $startDate = strftime("%x", strtotime($event->start_time));
87 $startTime = strftime("%R", strtotime($event->start_time));
89 $endDate = strftime("%x", strtotime($event->end_time));
90 $endTime = strftime("%R", strtotime($event->end_time));
92 // FIXME: better dates
94 $out->elementStart('div', 'event-times'); // VEVENT/EVENT-TIMES IN
96 // TRANS: Field label for event description.
97 $out->element('strong', null, _m('Time:'));
99 $out->element('abbr', array('class' => 'dtstart',
100 'title' => common_date_iso8601($event->start_time)),
101 $startDate . ' ' . $startTime);
103 if ($startDate == $endDate) {
104 $out->element('span', array('class' => 'dtend',
105 'title' => common_date_iso8601($event->end_time)),
108 $out->element('span', array('class' => 'dtend',
109 'title' => common_date_iso8601($event->end_time)),
110 $endDate . ' ' . $endTime);
113 $out->elementEnd('div'); // VEVENT/EVENT-TIMES OUT
115 if (!empty($event->location)) {
116 $out->elementStart('div', 'event-location');
117 // TRANS: Field label for event description.
118 $out->element('strong', null, _m('Location:'));
119 $out->element('span', 'location', $event->location);
120 $out->elementEnd('div');
123 if (!empty($event->description)) {
124 $out->elementStart('div', 'event-description');
125 // TRANS: Field label for event description.
126 $out->element('strong', null, _m('Description:'));
127 $out->element('span', 'description', $event->description);
128 $out->elementEnd('div');
131 $rsvps = $event->getRSVPs();
133 $out->elementStart('div', 'event-rsvps');
134 // TRANS: Field label for event description.
135 $out->element('strong', null, _m('Attending:'));
136 $out->element('span', 'event-rsvps',
137 // TRANS: RSVP counts.
138 // TRANS: %1$d, %2$d and %3$d are numbers of RSVPs.
139 sprintf(_m('Yes: %1$d No: %2$d Maybe: %3$d'),
140 count($rsvps[RSVP::POSITIVE]),
141 count($rsvps[RSVP::NEGATIVE]),
142 count($rsvps[RSVP::POSSIBLE])));
143 $out->elementEnd('div');
145 $user = common_current_user();
148 $rsvp = $event->getRSVP($user->getProfile());
151 $form = new RSVPForm($event, $out);
153 $form = new CancelRSVPForm($rsvp, $out);
159 $out->elementEnd('div'); // vevent out