3 if (!defined('GNUSOCIAL')) { exit(1); }
6 * widget for displaying a single notice
8 * This widget has the core smarts for showing a single notice: what to display,
9 * where, and under which circumstances. Its key method is show(); this is a recipe
10 * that calls all the other show*() methods to build up a single notice. The
11 * ProfileNoticeListItem subclass, for example, overrides showAuthor() to skip
12 * author info (since that's implicit by the data in the page).
16 * @author Evan Prodromou <evan@status.net>
17 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
18 * @link http://status.net/
20 * @see ProfileNoticeListItem
22 class ThreadedNoticeListItem extends NoticeListItem
24 protected $userProfile = null;
26 function __construct(Notice $notice, Action $out=null, $profile=null)
28 parent::__construct($notice, $out);
29 $this->userProfile = $profile;
32 function initialItems()
40 * Close the last elements in the notice list item
46 $max = $this->initialItems();
47 if (!$this->repeat instanceof Notice) {
48 $stream = new ConversationNoticeStream($this->notice->conversation, $this->userProfile);
49 $notice = $stream->getNotices(0, $max + 2);
53 while ($notice->fetch()) {
54 if (Event::handle('StartAddNoticeReply', array($this, $this->notice, $notice))) {
55 // Don't list repeats as separate notices in a conversation
56 if (!empty($notice->repeat_of)) {
60 if ($notice->id == $this->notice->id) {
65 if (!$notice->isVerb([ActivityVerb::POST])) {
72 $moreCutoff = clone($notice);
75 $notices[] = clone($notice); // *grumble* inefficient as hell
76 Event::handle('EndAddNoticeReply', array($this, $this->notice, $notice));
80 if (Event::handle('StartShowThreadedNoticeTail', array($this, $this->notice, &$notices))) {
81 $threadActive = count($notices) > 0; // has this thread had any activity?
83 $this->out->elementStart('ul', 'notices threaded-replies xoxo');
85 if (Event::handle('StartShowThreadedNoticeTailItems', array($this, $this->notice, &$threadActive))) {
86 // Repeats and Faves/Likes are handled in plugins.
87 Event::handle('EndShowThreadedNoticeTailItems', array($this, $this->notice, &$threadActive));
90 if (count($notices)>0) {
92 $item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out, count($notices));
95 foreach (array_reverse($notices) as $notice) {
96 if (Event::handle('StartShowThreadedNoticeSub', array($this, $this->notice, $notice))) {
97 $item = new ThreadedNoticeListSubItem($notice, $this->notice, $this->out);
99 Event::handle('EndShowThreadedNoticeSub', array($this, $this->notice, $notice));
104 Event::handle('EndShowThreadedNoticeTail', array($this, $this->notice, $notices));
105 $this->out->elementEnd('ul');