X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fconversation.php;h=b1cb50abacdde4b179e5b0c9f6b5c5a35e1a9a07;hb=b209dcf8a75dd1ead7fa9ae7df06d9a73d77928d;hp=637e86e4b26eb95b8d26cdb429878ab76314f856;hpb=59043dca7fb6f974b11797c4d0f20e5b78b0611d;p=quix0rs-gnu-social.git diff --git a/actions/conversation.php b/actions/conversation.php index 637e86e4b2..b1cb50abac 100644 --- a/actions/conversation.php +++ b/actions/conversation.php @@ -7,6 +7,7 @@ * @category Action * @package StatusNet * @author Evan Prodromou + * @author Mikael Nordfeldth * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @link http://status.net/ * @@ -27,32 +28,26 @@ * along with this program. If not, see . */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} - -// XXX: not sure how to do paging yet, -// so set a 60-notice limit - -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 StatusNet * @author Evan Prodromou + * @author Mikael Nordfeldth * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @link http://status.net/ */ -class ConversationAction extends Action +class ConversationAction extends ManagedAction { - var $id = null; + var $conv = null; var $page = null; var $notices = null; - var $userProfile = null; - - const MAX_NOTICES = 500; /** * Initialization. @@ -61,47 +56,19 @@ 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->id = $this->id+0; - $this->page = $this->trimmed('page'); - if (empty($this->page)) { - $this->page = 1; - } - - $cur = common_current_user(); + $convId = $this->int('id'); - if (empty($cur)) { - $this->userProfile = null; - } else { - $this->userProfile = $cur->getProfile(); + $this->conv = Conversation::getKV('id', $convId); + if (!$this->conv instanceof Conversation) { + throw new ClientException('Could not find specified conversation'); } - $stream = new ConversationNoticeStream($this->id, $this->userProfile); - - $this->notices = $stream->getNotices(0, self::MAX_NOTICES); - return true; } - /** - * Handle the action - * - * @param array $args Web and URL arguments - * - * @return void - */ - function handle($args) - { - parent::handle($args); - $this->showPage(); - } - /** * Returns the page title * @@ -116,19 +83,21 @@ class ConversationAction extends Action /** * Show content. * - * Display a hierarchical unordered list in the content area. - * Uses ConversationTree to do most of the heavy lifting. + * NoticeList extended classes do most heavy lifting. Plugins can override. * * @return void */ function showContent() { - $tnl = new FullThreadedNoticeList($this->notices, $this, $this->userProfile); - - $cnt = $tnl->show(); + 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() + function isReadOnly($args) { return true; } @@ -139,7 +108,7 @@ class ConversationAction extends Action return array(new Feed(Feed::JSON, common_local_url('apiconversation', array( - 'id' => $this->id, + 'id' => $this->conv->id, 'format' => 'as')), // TRANS: Title for link to notice feed. // TRANS: %s is a user nickname. @@ -147,7 +116,7 @@ class ConversationAction extends Action new Feed(Feed::RSS2, common_local_url('apiconversation', array( - 'id' => $this->id, + 'id' => $this->conv->id, 'format' => 'rss')), // TRANS: Title for link to notice feed. // TRANS: %s is a user nickname. @@ -155,10 +124,11 @@ class ConversationAction extends Action new Feed(Feed::ATOM, common_local_url('apiconversation', array( - 'id' => $this->id, + 'id' => $this->conv->id, 'format' => 'atom')), // TRANS: Title for link to notice feed. // TRANS: %s is a user nickname. - _('Conversation feed (Activity Streams JSON)'))); + _('Conversation feed (Atom)'))); } } +