]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/conversation.php
3b6f48c853f59a976d22e7340616f11e67e87162
[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  * @author   Mikael Nordfeldth <mmn@hethane.se>
11  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12  * @link     http://status.net/
13  *
14  * StatusNet - the distributed open-source microblogging tool
15  * Copyright (C) 2009, StatusNet, Inc.
16  *
17  * This program is free software: you can redistribute it and/or modify
18  * it under the terms of the GNU Affero General Public License as published by
19  * the Free Software Foundation, either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU Affero General Public License for more details.
26  *
27  * You should have received a copy of the GNU Affero General Public License
28  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
29  */
30
31 if (!defined('GNUSOCIAL')) { exit(1); }
32
33 /**
34  * Conversation tree in the browser
35  *
36  * Will always try to show the entire conversation, since that's how our
37  * ConversationNoticeStream works.
38  *
39  * @category Action
40  * @package  StatusNet
41  * @author   Evan Prodromou <evan@status.net>
42  * @author   Mikael Nordfeldth <mmn@hethane.se>
43  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
44  * @link     http://status.net/
45  */
46 class ConversationAction extends ManagedAction
47 {
48     var $conv        = null;
49     var $page        = null;
50     var $notices     = null;
51
52     /**
53      * Initialization.
54      *
55      * @param array $args Web and URL arguments
56      *
57      * @return boolean false if id not passed in
58      */
59     protected function prepare(array $args=array())
60     {
61         parent::prepare($args);
62         $convId = $this->int('id');
63
64         $this->conv = Conversation::getKV('id', $convId);
65         if (!$this->conv instanceof Conversation) {
66             throw new ClientException('Could not find specified conversation');
67         }
68
69         return true;
70     }
71
72     /**
73      * Returns the page title
74      *
75      * @return string page title
76      */
77     function title()
78     {
79         // TRANS: Title for page with a conversion (multiple notices in context).
80         return _('Conversation');
81     }
82
83     /**
84      * Show content.
85      *
86      * NoticeList extended classes do most heavy lifting. Plugins can override.
87      *
88      * @return void
89      */
90     function showContent()
91     {
92         if (Event::handle('StartShowConversation', array($this, $this->conv, $this->scoped))) {
93             $notices = $this->conv->getNotices();
94             $nl = new FullThreadedNoticeList($notices, $this, $this->scoped);
95             $cnt = $nl->show();
96         }
97         Event::handle('EndShowConversation', array($this, $this->conv, $this->scoped));
98     }
99
100     function isReadOnly()
101     {
102         return true;
103     }
104     
105     function getFeeds()
106     {
107         
108         return array(new Feed(Feed::JSON,
109                               common_local_url('apiconversation',
110                                                array(
111                                                     'id' => $this->conv->id,
112                                                     'format' => 'as')),
113                               // TRANS: Title for link to notice feed.
114                               // TRANS: %s is a user nickname.
115                               _('Conversation feed (Activity Streams JSON)')),
116                      new Feed(Feed::RSS2,
117                               common_local_url('apiconversation',
118                                                array(
119                                                     'id' => $this->conv->id,
120                                                     'format' => 'rss')),
121                               // TRANS: Title for link to notice feed.
122                               // TRANS: %s is a user nickname.
123                               _('Conversation feed (RSS 2.0)')),
124                      new Feed(Feed::ATOM,
125                               common_local_url('apiconversation',
126                                                array(
127                                                     'id' => $this->conv->id,
128                                                     'format' => 'atom')),
129                               // TRANS: Title for link to notice feed.
130                               // TRANS: %s is a user nickname.
131                               _('Conversation feed (Activity Streams JSON)')));
132     }
133 }
134