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->showAuthor();
55 function showContent()
57 $notice = $this->nli->notice;
58 $out = $this->nli->out;
60 $profile = $notice->getProfile();
61 $event = Happening::fromNotice($notice);
64 // TRANS: Content for a deleted RSVP list item (RSVP stands for "please respond").
65 $out->element('p', null, _m('Deleted.'));
69 $out->elementStart('div', 'vevent event e-content'); // VEVENT IN
71 $out->elementStart('h3', 'summary'); // VEVENT/H3 IN
73 if (!empty($event->url)) {
75 array('href' => $event->url,
76 'class' => 'event-title entry-title summary'),
79 $out->text($event->title);
82 $out->elementEnd('h3'); // VEVENT/H3 OUT
84 $now = new DateTime();
85 $startDate = new DateTime($event->start_time);
86 $endDate = new DateTime($event->end_time);
87 $userTz = new DateTimeZone(common_timezone());
89 // Localize the time for the observer
90 $now->setTimeZone($userTz);
91 $startDate->setTimezone($userTz);
92 $endDate->setTimezone($userTz);
94 $thisYear = $now->format('Y');
95 $startYear = $startDate->format('Y');
96 $endYear = $endDate->format('Y');
98 $dateFmt = 'D, F j, '; // e.g.: Mon, Aug 31
100 if ($startYear != $thisYear || $endYear != $thisYear) {
101 $dateFmt .= 'Y,'; // append year if we need to think about years
104 $startDateStr = $startDate->format($dateFmt);
105 $endDateStr = $endDate->format($dateFmt);
109 $startTimeStr = $startDate->format($timeFmt);
110 $endTimeStr = $endDate->format("{$timeFmt} (T)");
112 $out->elementStart('div', 'event-times'); // VEVENT/EVENT-TIMES IN
114 // TRANS: Field label for event description.
115 $out->element('strong', null, _m('Time:'));
117 $out->element('abbr', array('class' => 'dtstart',
118 'title' => common_date_iso8601($event->start_time)),
119 $startDateStr . ' ' . $startTimeStr);
121 if ($startDateStr == $endDateStr) {
122 $out->element('span', array('class' => 'dtend',
123 'title' => common_date_iso8601($event->end_time)),
126 $out->element('span', array('class' => 'dtend',
127 'title' => common_date_iso8601($event->end_time)),
128 $endDateStr . ' ' . $endTimeStr);
131 $out->elementEnd('div'); // VEVENT/EVENT-TIMES OUT
133 if (!empty($event->location)) {
134 $out->elementStart('div', 'event-location');
135 // TRANS: Field label for event description.
136 $out->element('strong', null, _m('Location:'));
137 $out->element('span', 'location', $event->location);
138 $out->elementEnd('div');
141 if (!empty($event->description)) {
142 $out->elementStart('div', 'event-description');
143 // TRANS: Field label for event description.
144 $out->element('strong', null, _m('Description:'));
145 $out->element('span', 'description', $event->description);
146 $out->elementEnd('div');
149 $rsvps = $event->getRSVPs();
151 $out->elementStart('div', 'event-rsvps');
152 // TRANS: Field label for event description.
154 $out->text(_('Attending:'));
155 $out->elementStart('ul', 'attending-list');
157 foreach ($rsvps as $verb => $responses) {
158 $out->elementStart('li', 'rsvp-list');
162 $out->text(_('Yes:'));
165 $out->text(_('No:'));
168 $out->text(_('Maybe:'));
172 foreach ($responses as $response) {
173 $ids[] = $response->profile_id;
175 $ids = array_slice($ids, 0, ProfileMiniList::MAX_PROFILES + 1);
176 $profiles = Profile::pivotGet('id', $ids);
177 $profile = new ArrayWrapper(array_values($profiles));
178 $minilist = new ProfileMiniList($profile, $out);
181 $out->elementEnd('li');
184 $out->elementEnd('ul');
185 $out->elementEnd('div');
187 $user = common_current_user();
190 $rsvp = $event->getRSVP($user->getProfile());
193 $form = new RSVPForm($event, $out);
195 $form = new CancelRSVPForm($rsvp, $out);
201 $out->elementEnd('div'); // vevent out