4 * Copyright (C) 2010, Free Software Foundation, Inc.
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Max Shinn <trombonechamp@gmail.com>
25 * @copyright 2011 Free Software Foundation, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
29 class NoticeTree extends NoticeList
33 $this->out->elementStart('div', array('id' =>'notices_primary'));
34 // TRANS: Header on conversation page. Hidden by default (h2).
35 $this->out->element('h2', null, _('Notices'));
36 $this->out->elementStart('ol', array('class' => 'notices xoxo'));
40 while ($this->notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
41 if (!empty($this->notice->reply_to))
46 if ($cnt > NOTICES_PER_PAGE) {
51 $this->showNoticePlus($this->notice);
52 } catch (Exception $e) {
53 // we log exceptions and continue
54 common_log(LOG_ERR, $e->getMessage());
59 $this->out->elementEnd('ol');
60 $this->out->elementEnd('div');
66 function showNoticePlus($notice)
68 $replies = new Notice();
69 $replies->reply_to = $notice->id;
71 // We take responsibility for doing the li
73 $this->out->elementStart('li', array('class' => 'hentry notice',
74 'id' => 'notice-' . $id));
76 $item = $this->newListItem($notice);
79 if ($replies->find()) {
80 $this->out->elementStart('ol', array('class' => 'notices'));
82 while ($replies->fetch()) {
83 $this->showNoticePlus($replies);
86 $this->out->elementEnd('ol');
89 $this->out->elementEnd('li');
92 function newListItem($notice)
94 return new NoticeTreeItem($notice, $this->out);
98 class NoticeTreeItem extends NoticeListItem
108 //Showing number of favorites
110 $fave->notice_id = $this->notice->id;
113 while ($fave->fetch())
117 $this->out->text(_m("Favorited by $cnt user"));
118 if ($cnt > 1) $this->out->text("s"); //there has to be a better way to do this...
122 $this->out->elementStart('div', array('id' => 'form' . $this->notice->id, 'class' => 'replyform'));
123 $noticeform = new ReplyForm($this->out, null, null, null, $this->notice->id);
125 $this->out->elementEnd('div');
129 function showContext()
134 //Just changing the link...
135 function showReplyLink()
137 if (common_logged_in()) {
138 $this->out->text(' ');
139 //Why doesn't common_local_url work here?
140 $reply_url = '/notice/respond?replyto=' . $this->profile->nickname . '&inreplyto=' . $this->notice->id;
141 $this->out->elementStart('a', array('href' => $reply_url,
142 'class' => 'notice_reply',
143 'title' => _('Reply to this notice')));
144 $this->out->text(_('Reply'));
145 $this->out->text(' ');
146 $this->out->element('span', 'notice_id', $this->notice->id);
147 $this->out->elementEnd('a');
153 class ReplyForm extends NoticeForm
155 //Changing the text. We have to either repeat ids or get hacky. I vote repeat ids.
158 if (Event::handle('StartShowNoticeFormData', array($this))) {
159 // XXX: vary by defined max size
160 $this->out->element('textarea', array('id' => 'notice_data-text',
163 'name' => 'status_textarea'),
164 ($this->content) ? $this->content : '');
166 $contentLimit = Notice::maxContent();
168 if ($contentLimit > 0) {
169 $this->out->elementStart('dl', 'form_note');
170 $this->out->element('dt', null, _('Available characters'));
171 $this->out->element('dd', array('id' => 'notice_text-count'),
173 $this->out->elementEnd('dl');
176 if (common_config('attachments', 'uploads')) {
177 $this->out->element('label', array('for' => 'notice_data-attach'),_('Attach'));
178 $this->out->element('input', array('id' => 'notice_data-attach',
181 'title' => _('Attach a file')));
182 $this->out->hidden('MAX_FILE_SIZE', common_config('attachments', 'file_quota'));
185 $this->out->hidden('notice_return-to', $this->action, 'returnto');
187 $this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto');
189 if ($this->user->shareLocation()) {
190 $this->out->hidden('notice_data-lat', empty($this->lat) ? (empty($this->profile->lat) ? null : $this->profile->lat) : $this->lat, 'lat');
191 $this->out->hidden('notice_data-lon', empty($this->lon) ? (empty($this->profile->lon) ? null : $this->profile->lon) : $this->lon, 'lon');
192 $this->out->hidden('notice_data-location_id', empty($this->location_id) ? (empty($this->profile->location_id) ? null : $this->profile->location_id) : $this->location_id, 'location_id');
193 $this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? (empty($this->profile->location_ns) ? null : $this->profile->location_ns) : $this->location_ns, 'location_ns');
195 $this->out->elementStart('div', array('id' => 'notice_data-geo_wrap',
196 'title' => common_local_url('geocode')));
197 $this->out->checkbox('notice_data-geo', _('Share my location'), true);
198 $this->out->elementEnd('div');
199 $this->out->inlineScript(' var NoticeDataGeo_text = {'.
200 'ShareDisable: ' .json_encode(_('Do not share my location')).','.
201 'ErrorTimeout: ' .json_encode(_('Sorry, retrieving your geo location is taking longer than expected, please try again later')).
205 Event::handle('EndShowNoticeFormData', array($this));