]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/conversation.php
parent::handlePost() in CancelsubscriptionAction
[quix0rs-gnu-social.git] / actions / conversation.php
1 <?php
2 /**
3  * Display a conversation in the browser
4  *
5  * PHP version 5
6  *
7  * @category Action
8  * @package  StatusNet
9  * @author   Evan Prodromou <evan@status.net>
10  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11  * @link     http://status.net/
12  *
13  * StatusNet - the distributed open-source microblogging tool
14  * Copyright (C) 2009, StatusNet, Inc.
15  *
16  * This program is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU Affero General Public License as published by
18  * the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU Affero General Public License for more details.
25  *
26  * You should have received a copy of the GNU Affero General Public License
27  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
28  */
29
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
31     exit(1);
32 }
33
34 // XXX: not sure how to do paging yet,
35 // so set a 60-notice limit
36
37 require_once INSTALLDIR.'/lib/noticelist.php';
38
39 /**
40  * Conversation tree in the browser
41  *
42  * @category Action
43  * @package  StatusNet
44  * @author   Evan Prodromou <evan@status.net>
45  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
46  * @link     http://status.net/
47  */
48 class ConversationAction extends Action
49 {
50     var $id          = null;
51     var $page        = null;
52     var $notices     = null;
53     var $userProfile = null;
54
55     const MAX_NOTICES = 500;
56
57     /**
58      * Initialization.
59      *
60      * @param array $args Web and URL arguments
61      *
62      * @return boolean false if id not passed in
63      */
64     function prepare($args)
65     {
66         parent::prepare($args);
67         $this->id = $this->trimmed('id');
68         if (empty($this->id)) {
69             return false;
70         }
71         $this->id = $this->id+0;
72         $this->page = $this->trimmed('page');
73         if (empty($this->page)) {
74             $this->page = 1;
75         }
76
77         $cur = common_current_user();
78
79         if (empty($cur)) {
80             $this->userProfile = null;
81         } else {
82             $this->userProfile = $cur->getProfile();
83         }
84
85         $stream = new ConversationNoticeStream($this->id, $this->userProfile);
86
87         $this->notices = $stream->getNotices(0, self::MAX_NOTICES);
88
89         return true;
90     }
91
92     /**
93      * Handle the action
94      *
95      * @param array $args Web and URL arguments
96      *
97      * @return void
98      */
99     function handle($args)
100     {
101         parent::handle($args);
102         $this->showPage();
103     }
104
105     /**
106      * Returns the page title
107      *
108      * @return string page title
109      */
110     function title()
111     {
112         // TRANS: Title for page with a conversion (multiple notices in context).
113         return _('Conversation');
114     }
115
116     /**
117      * Show content.
118      *
119      * Display a hierarchical unordered list in the content area.
120      * Uses ConversationTree to do most of the heavy lifting.
121      *
122      * @return void
123      */
124     function showContent()
125     {
126         $user = common_current_user();
127
128         if (!empty($user) && $user->conversationTree()) {
129             $nl = new ConversationTree($this->notices, $this);
130         } else {
131             $nl = new FullThreadedNoticeList($this->notices, $this, $this->userProfile);
132         }
133
134         $cnt = $nl->show();
135     }
136
137     function isReadOnly()
138     {
139         return true;
140     }
141     
142     function getFeeds()
143     {
144         
145         return array(new Feed(Feed::JSON,
146                               common_local_url('apiconversation',
147                                                array(
148                                                     'id' => $this->id,
149                                                     'format' => 'as')),
150                               // TRANS: Title for link to notice feed.
151                               // TRANS: %s is a user nickname.
152                               _('Conversation feed (Activity Streams JSON)')),
153                      new Feed(Feed::RSS2,
154                               common_local_url('apiconversation',
155                                                array(
156                                                     'id' => $this->id,
157                                                     'format' => 'rss')),
158                               // TRANS: Title for link to notice feed.
159                               // TRANS: %s is a user nickname.
160                               _('Conversation feed (RSS 2.0)')),
161                      new Feed(Feed::ATOM,
162                               common_local_url('apiconversation',
163                                                array(
164                                                     'id' => $this->id,
165                                                     'format' => 'atom')),
166                               // TRANS: Title for link to notice feed.
167                               // TRANS: %s is a user nickname.
168                               _('Conversation feed (Activity Streams JSON)')));
169     }
170 }
171