]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/conversation.php
ConversationAction extends from ManagedAction
[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 ManagedAction
49 {
50     var $id          = null;
51     var $page        = null;
52     var $notices     = null;
53
54     const MAX_NOTICES = 500;
55
56     /**
57      * Initialization.
58      *
59      * @param array $args Web and URL arguments
60      *
61      * @return boolean false if id not passed in
62      */
63     protected function prepare(array $args=array())
64     {
65         parent::prepare($args);
66         $this->id = $this->trimmed('id');
67         if (empty($this->id)) {
68             return false;
69         }
70         $this->id = $this->id+0;
71         $this->page = $this->trimmed('page');
72         if (empty($this->page)) {
73             $this->page = 1;
74         }
75
76         $stream = new ConversationNoticeStream($this->id, $this->scoped);
77
78         $this->notices = $stream->getNotices(0, self::MAX_NOTICES);
79
80         return true;
81     }
82
83     /**
84      * Returns the page title
85      *
86      * @return string page title
87      */
88     function title()
89     {
90         // TRANS: Title for page with a conversion (multiple notices in context).
91         return _('Conversation');
92     }
93
94     /**
95      * Show content.
96      *
97      * Display a hierarchical unordered list in the content area.
98      * Uses ConversationTree to do most of the heavy lifting.
99      *
100      * @return void
101      */
102     function showContent()
103     {
104         $user = common_current_user();
105
106         if (!empty($user) && $user->conversationTree()) {
107             $nl = new ConversationTree($this->notices, $this);
108         } else {
109             $nl = new FullThreadedNoticeList($this->notices, $this, $this->scoped);
110         }
111
112         $cnt = $nl->show();
113     }
114
115     function isReadOnly()
116     {
117         return true;
118     }
119     
120     function getFeeds()
121     {
122         
123         return array(new Feed(Feed::JSON,
124                               common_local_url('apiconversation',
125                                                array(
126                                                     'id' => $this->id,
127                                                     'format' => 'as')),
128                               // TRANS: Title for link to notice feed.
129                               // TRANS: %s is a user nickname.
130                               _('Conversation feed (Activity Streams JSON)')),
131                      new Feed(Feed::RSS2,
132                               common_local_url('apiconversation',
133                                                array(
134                                                     'id' => $this->id,
135                                                     'format' => 'rss')),
136                               // TRANS: Title for link to notice feed.
137                               // TRANS: %s is a user nickname.
138                               _('Conversation feed (RSS 2.0)')),
139                      new Feed(Feed::ATOM,
140                               common_local_url('apiconversation',
141                                                array(
142                                                     'id' => $this->id,
143                                                     'format' => 'atom')),
144                               // TRANS: Title for link to notice feed.
145                               // TRANS: %s is a user nickname.
146                               _('Conversation feed (Activity Streams JSON)')));
147     }
148 }
149