Use an Event to present notices conversations
This commit is contained in:
parent
4358ac0675
commit
1a81188355
10
EVENTS.txt
10
EVENTS.txt
@ -1298,6 +1298,16 @@ EndShowGroupProfileBlock: After showing the profile block for a group
|
|||||||
- $out: XMLOutputter to append custom output
|
- $out: XMLOutputter to append custom output
|
||||||
- $group: the group being shown
|
- $group: the group being shown
|
||||||
|
|
||||||
|
StartShowConversation: start the listing of a conversation
|
||||||
|
- $action: Action object (used mainly as HTMLOutputter)
|
||||||
|
- $conv: Conversation object, has functions to retrieve relevant notices
|
||||||
|
- $scoped: Profile for scoping (null if not logged in)
|
||||||
|
|
||||||
|
EndShowConversation: after the listing of a conversation
|
||||||
|
- $action: Action object (used mainly as HTMLOutputter)
|
||||||
|
- $conv: Conversation object, has functions to retrieve relevant notices
|
||||||
|
- $scoped: Profile for scoping (null if not logged in)
|
||||||
|
|
||||||
StartShowThreadedNoticeTail: when showing the replies etc. to a notice
|
StartShowThreadedNoticeTail: when showing the replies etc. to a notice
|
||||||
- $nli: parent noticelistitem
|
- $nli: parent noticelistitem
|
||||||
- $notice: parent notice
|
- $notice: parent notice
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
* @category Action
|
* @category Action
|
||||||
* @package StatusNet
|
* @package StatusNet
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*
|
*
|
||||||
@ -27,32 +28,27 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX: not sure how to do paging yet,
|
|
||||||
// so set a 60-notice limit
|
|
||||||
|
|
||||||
require_once INSTALLDIR.'/lib/noticelist.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conversation tree in the browser
|
* Conversation tree in the browser
|
||||||
*
|
*
|
||||||
|
* Will always try to show the entire conversation, since that's how our
|
||||||
|
* ConversationNoticeStream works.
|
||||||
|
*
|
||||||
* @category Action
|
* @category Action
|
||||||
* @package StatusNet
|
* @package StatusNet
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
class ConversationAction extends ManagedAction
|
class ConversationAction extends ManagedAction
|
||||||
{
|
{
|
||||||
var $id = null;
|
var $conv = null;
|
||||||
var $page = null;
|
var $page = null;
|
||||||
var $notices = null;
|
var $notices = null;
|
||||||
|
|
||||||
const MAX_NOTICES = 500;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization.
|
* Initialization.
|
||||||
*
|
*
|
||||||
@ -63,19 +59,12 @@ class ConversationAction extends ManagedAction
|
|||||||
protected function prepare(array $args=array())
|
protected function prepare(array $args=array())
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
$this->id = $this->trimmed('id');
|
$convId = $this->int('id');
|
||||||
if (empty($this->id)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$this->id = $this->id+0;
|
|
||||||
$this->page = $this->trimmed('page');
|
|
||||||
if (empty($this->page)) {
|
|
||||||
$this->page = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$stream = new ConversationNoticeStream($this->id, $this->scoped);
|
$this->conv = Conversation::getKV('id', $convId);
|
||||||
|
if (!$this->conv instanceof Conversation) {
|
||||||
$this->notices = $stream->getNotices(0, self::MAX_NOTICES);
|
throw new ClientException('Could not find specified conversation');
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -94,22 +83,18 @@ class ConversationAction extends ManagedAction
|
|||||||
/**
|
/**
|
||||||
* Show content.
|
* Show content.
|
||||||
*
|
*
|
||||||
* Display a hierarchical unordered list in the content area.
|
* NoticeList extended classes do most heavy lifting. Plugins can override.
|
||||||
* Uses ConversationTree to do most of the heavy lifting.
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showContent()
|
function showContent()
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
if (Event::handle('StartShowConversation', array($this, $this->conv, $this->scoped))) {
|
||||||
|
$notices = $this->conv->getNotices();
|
||||||
if (!empty($user) && $user->conversationTree()) {
|
$nl = new FullThreadedNoticeList($notices, $this, $this->scoped);
|
||||||
$nl = new ConversationTree($this->notices, $this);
|
$cnt = $nl->show();
|
||||||
} else {
|
|
||||||
$nl = new FullThreadedNoticeList($this->notices, $this, $this->scoped);
|
|
||||||
}
|
}
|
||||||
|
Event::handle('EndShowConversation', array($this, $this->conv, $this->scoped));
|
||||||
$cnt = $nl->show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isReadOnly()
|
function isReadOnly()
|
||||||
@ -123,7 +108,7 @@ class ConversationAction extends ManagedAction
|
|||||||
return array(new Feed(Feed::JSON,
|
return array(new Feed(Feed::JSON,
|
||||||
common_local_url('apiconversation',
|
common_local_url('apiconversation',
|
||||||
array(
|
array(
|
||||||
'id' => $this->id,
|
'id' => $this->conv->id,
|
||||||
'format' => 'as')),
|
'format' => 'as')),
|
||||||
// TRANS: Title for link to notice feed.
|
// TRANS: Title for link to notice feed.
|
||||||
// TRANS: %s is a user nickname.
|
// TRANS: %s is a user nickname.
|
||||||
@ -131,7 +116,7 @@ class ConversationAction extends ManagedAction
|
|||||||
new Feed(Feed::RSS2,
|
new Feed(Feed::RSS2,
|
||||||
common_local_url('apiconversation',
|
common_local_url('apiconversation',
|
||||||
array(
|
array(
|
||||||
'id' => $this->id,
|
'id' => $this->conv->id,
|
||||||
'format' => 'rss')),
|
'format' => 'rss')),
|
||||||
// TRANS: Title for link to notice feed.
|
// TRANS: Title for link to notice feed.
|
||||||
// TRANS: %s is a user nickname.
|
// TRANS: %s is a user nickname.
|
||||||
@ -139,7 +124,7 @@ class ConversationAction extends ManagedAction
|
|||||||
new Feed(Feed::ATOM,
|
new Feed(Feed::ATOM,
|
||||||
common_local_url('apiconversation',
|
common_local_url('apiconversation',
|
||||||
array(
|
array(
|
||||||
'id' => $this->id,
|
'id' => $this->conv->id,
|
||||||
'format' => 'atom')),
|
'format' => 'atom')),
|
||||||
// TRANS: Title for link to notice feed.
|
// TRANS: Title for link to notice feed.
|
||||||
// TRANS: %s is a user nickname.
|
// TRANS: %s is a user nickname.
|
||||||
|
@ -121,4 +121,15 @@ class Conversation extends Managed_DataObject
|
|||||||
return common_local_url('conversation', array('id' => $this->id)) .
|
return common_local_url('conversation', array('id' => $this->id)) .
|
||||||
($noticeId===null ? '' : "#notice-{$noticeId}");
|
($noticeId===null ? '' : "#notice-{$noticeId}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: ...will 500 ever be too low? Taken from ConversationAction::MAX_NOTICES
|
||||||
|
public function getNotices($offset=0, $limit=500, Profile $scoped=null)
|
||||||
|
{
|
||||||
|
if ($scoped === null) {
|
||||||
|
$scoped = Profile::current();
|
||||||
|
}
|
||||||
|
$stream = new ConversationNoticeStream($this->id, $scoped);
|
||||||
|
$notices = $stream->getNotices($offset, $limit);
|
||||||
|
return $notices;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user