X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fconversation.php;h=b1cb50abacdde4b179e5b0c9f6b5c5a35e1a9a07;hb=d5d806863240379fe23e081c75097ddee53babec;hp=05cfb76e3c85cc324c74a90f822de90241bae4a4;hpb=9a566c51cdda646804caf88578d657a9c643fe3c;p=quix0rs-gnu-social.git diff --git a/actions/conversation.php b/actions/conversation.php index 05cfb76e3c..b1cb50abac 100644 --- a/actions/conversation.php +++ b/actions/conversation.php @@ -5,13 +5,14 @@ * PHP version 5 * * @category Action - * @package Laconica - * @author Evan Prodromou + * @package StatusNet + * @author Evan Prodromou + * @author Mikael Nordfeldth * @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 @@ -27,25 +28,26 @@ * along with this program. If not, see . */ -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 + * @package StatusNet + * @author Evan Prodromou + * @author Mikael Nordfeldth * @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)'))); + } }