]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/conversation.php
Merge branch 'group-members-pending' into 'nightly'
[quix0rs-gnu-social.git] / actions / conversation.php
index 05cfb76e3c85cc324c74a90f822de90241bae4a4..b1cb50abacdde4b179e5b0c9f6b5c5a35e1a9a07 100644 (file)
@@ -5,13 +5,14 @@
  * PHP version 5
  *
  * @category Action
- * @package  Laconica
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@status.net>
+ * @author   Mikael Nordfeldth <mmn@hethane.se>
  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  *
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2009, StatusNet, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) {
-    exit(1);
-}
-
-require_once(INSTALLDIR.'/lib/noticelist.php');
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Conversation tree in the browser
  *
+ * Will always try to show the entire conversation, since that's how our
+ * ConversationNoticeStream works.
+ *
  * @category Action
- * @package  Laconica
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@status.net>
+ * @author   Mikael Nordfeldth <mmn@hethane.se>
  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  */
-class ConversationAction extends Action
+class ConversationAction extends ManagedAction
 {
-    var $id = null;
-    var $page = null;
+    var $conv        = null;
+    var $page        = null;
+    var $notices     = null;
 
     /**
      * Initialization.
@@ -54,54 +56,79 @@ class ConversationAction extends Action
      *
      * @return boolean false if id not passed in
      */
-
-    function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
-        $this->id = $this->trimmed('id');
-        if (empty($this->id)) {
-            return false;
-        }
-        $this->page = $this->trimmed('page');
-        if (empty($this->page)) {
-            $this->page = 1;
+        $convId = $this->int('id');
+
+        $this->conv = Conversation::getKV('id', $convId);
+        if (!$this->conv instanceof Conversation) {
+            throw new ClientException('Could not find specified conversation');
         }
-        return true;
-    }
 
-    function handle($args)
-    {
-        parent::handle($args);
-        $this->showPage();
+        return true;
     }
 
+    /**
+     * Returns the page title
+     *
+     * @return string page title
+     */
     function title()
     {
-        return _("Conversation");
+        // TRANS: Title for page with a conversion (multiple notices in context).
+        return _('Conversation');
     }
 
+    /**
+     * Show content.
+     *
+     * NoticeList extended classes do most heavy lifting. Plugins can override.
+     *
+     * @return void
+     */
     function showContent()
     {
-        // FIXME this needs to be a tree, not a list
-
-        $qry = 'SELECT * FROM notice WHERE conversation = %s ';
-
-        $offset = ($this->page-1)*NOTICES_PER_PAGE;
-        $limit  = NOTICES_PER_PAGE + 1;
-
-        $txt = sprintf($qry, $this->id);
-
-        $notices = Notice::getStream($txt,
-                                     'notice:conversation:'.$this->id,
-                                     $offset, $limit);
-
-        $nl = new NoticeList($notices, $this);
-
-        $cnt = $nl->show();
-
-        $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
-                          $this->page, 'conversation', array('id' => $this->id));
+        if (Event::handle('StartShowConversation', array($this, $this->conv, $this->scoped))) {
+            $notices = $this->conv->getNotices();
+            $nl = new FullThreadedNoticeList($notices, $this, $this->scoped);
+            $cnt = $nl->show();
+        }
+        Event::handle('EndShowConversation', array($this, $this->conv, $this->scoped));
     }
 
+    function isReadOnly($args)
+    {
+        return true;
+    }
+    
+    function getFeeds()
+    {
+       
+        return array(new Feed(Feed::JSON,
+                              common_local_url('apiconversation',
+                                               array(
+                                                    'id' => $this->conv->id,
+                                                    'format' => 'as')),
+                              // TRANS: Title for link to notice feed.
+                              // TRANS: %s is a user nickname.
+                              _('Conversation feed (Activity Streams JSON)')),
+                     new Feed(Feed::RSS2,
+                              common_local_url('apiconversation',
+                                               array(
+                                                    'id' => $this->conv->id,
+                                                    'format' => 'rss')),
+                              // TRANS: Title for link to notice feed.
+                              // TRANS: %s is a user nickname.
+                              _('Conversation feed (RSS 2.0)')),
+                     new Feed(Feed::ATOM,
+                              common_local_url('apiconversation',
+                                               array(
+                                                    'id' => $this->conv->id,
+                                                    'format' => 'atom')),
+                              // TRANS: Title for link to notice feed.
+                              // TRANS: %s is a user nickname.
+                              _('Conversation feed (Atom)')));
+    }
 }