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...
121 //TODO: Rewrite this too
123 $this->out->elementStart('div', array('id' => 'form' . $this->notice->id, 'class' => 'replyform'));
124 $noticeform = new NoticeForm($this->out, null, null, null, $this->notice->id);
126 $this->out->elementEnd('div');
130 function showContext()
135 //Just changing the link...
136 function showReplyLink()
138 if (common_logged_in()) {
139 $this->out->text(' ');
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');