3 * Display a conversation in the browser
9 * @author Evan Prodromou <evan@controlyourself.ca>
10 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11 * @link http://laconi.ca/
13 * Laconica - a distributed open-source microblogging tool
14 * Copyright (C) 2008, Controlez-Vous, Inc.
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.
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.
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/>.
30 if (!defined('LACONICA')) {
35 * Conversation tree in the browser
39 * @author Evan Prodromou <evan@controlyourself.ca>
40 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
41 * @link http://laconi.ca/
43 class ConversationAction extends Action
52 * @param array $args Web and URL arguments
54 * @return boolean false if id not passed in
57 function prepare($args)
59 parent::prepare($args);
60 $this->id = $this->trimmed('id');
64 $this->notices = $this->getNotices();
65 $this->page = $this->trimmed('page');
66 if (empty($this->page)) {
75 * @param integer $limit max number of notices to return
77 * @return array notices
80 function getNotices($limit=0)
82 $qry = 'SELECT notice.*, '.
83 'FROM notice WHERE conversation = %d '.
87 $limit = NOTICES_PER_PAGE + 1;
89 if (common_config('db', 'type') == 'pgsql') {
90 $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
92 $qry .= ' LIMIT ' . $offset . ', ' . $limit;
95 return Notice::getStream(sprintf($qry, $this->id),
96 'notice:conversation:'.$this->id,
100 function handle($args)
107 return _("Conversation");
110 function showContent()
112 // FIXME this needs to be a tree, not a list
114 $nl = new NoticeList($this->notices, $this);
118 $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
119 $this->page, 'conversation', array('id' => $this->id));