getConversationUrl introduced for linking to conversations
This commit is contained in:
parent
4774a25040
commit
27ed6b7db0
@ -97,4 +97,22 @@ class Conversation extends Managed_DataObject
|
|||||||
|
|
||||||
return $cnt;
|
return $cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public function getUrlFromNotice(Notice $notice, $anchor=true)
|
||||||
|
{
|
||||||
|
$conv = self::getKV('id', $notice->conversation);
|
||||||
|
return $conv->getUrl($anchor ? $notice->id : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUri()
|
||||||
|
{
|
||||||
|
return $this->uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUrl($noticeId=null)
|
||||||
|
{
|
||||||
|
// FIXME: the URL router should take notice-id as an argument...
|
||||||
|
return common_local_url('conversation', array('id' => $this->id)) .
|
||||||
|
($noticeId===null ? '' : "#notice-{$noticeId}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,11 +210,27 @@ class Notice extends Managed_DataObject
|
|||||||
return $this->uri;
|
return $this->uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @param $root boolean If true, link to just the conversation root.
|
||||||
|
*
|
||||||
|
* @return URL to conversation
|
||||||
|
*/
|
||||||
|
public function getConversationUrl($anchor=true)
|
||||||
|
{
|
||||||
|
return Conversation::getUrlFromNotice($this, $anchor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the local representation URL of this notice.
|
||||||
|
*/
|
||||||
public function getLocalUrl()
|
public function getLocalUrl()
|
||||||
{
|
{
|
||||||
return common_local_url('shownotice', array('notice' => $this->id), null, null, false);
|
return common_local_url('shownotice', array('notice' => $this->id), null, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the original representation URL of this notice.
|
||||||
|
*/
|
||||||
public function getUrl()
|
public function getUrl()
|
||||||
{
|
{
|
||||||
// The risk is we start having empty urls and non-http uris...
|
// The risk is we start having empty urls and non-http uris...
|
||||||
|
@ -126,7 +126,9 @@ class NoticeListItem extends Widget
|
|||||||
$this->showNoticeLink();
|
$this->showNoticeLink();
|
||||||
$this->showNoticeSource();
|
$this->showNoticeSource();
|
||||||
$this->showNoticeLocation();
|
$this->showNoticeLocation();
|
||||||
$this->showContext();
|
if ($this->notice->hasConversation()) {
|
||||||
|
$this->showContext();
|
||||||
|
}
|
||||||
$this->showRepeat();
|
$this->showRepeat();
|
||||||
Event::handle('EndShowNoticeInfo', array($this));
|
Event::handle('EndShowNoticeInfo', array($this));
|
||||||
}
|
}
|
||||||
@ -520,32 +522,11 @@ class NoticeListItem extends Widget
|
|||||||
*/
|
*/
|
||||||
function showContext()
|
function showContext()
|
||||||
{
|
{
|
||||||
if ($this->notice->hasConversation()) {
|
$this->out->element('a',
|
||||||
$conv = Conversation::getKV(
|
array('href' => $this->notice->getConversationUrl(),
|
||||||
'id',
|
'class' => 'conversation'),
|
||||||
$this->notice->conversation
|
// TRANS: Addition in notice list item if notice is part of a conversation.
|
||||||
);
|
_('in context'));
|
||||||
$convurl = $conv->uri;
|
|
||||||
if (!empty($convurl)) {
|
|
||||||
$this->out->text(' ');
|
|
||||||
$this->out->element(
|
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => $convurl.'#notice-'.$this->notice->id,
|
|
||||||
'class' => 'response'),
|
|
||||||
// TRANS: Addition in notice list item if notice is part of a conversation.
|
|
||||||
_('in context')
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$msg = sprintf(
|
|
||||||
"Couldn't find Conversation ID %d to make 'in context'"
|
|
||||||
. "link for Notice ID %d",
|
|
||||||
$this->notice->conversation,
|
|
||||||
$this->notice->id
|
|
||||||
);
|
|
||||||
common_log(LOG_WARNING, $msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,17 +183,9 @@ class UserEmailSummaryHandler extends QueueHandler
|
|||||||
'title' => $dt),
|
'title' => $dt),
|
||||||
common_date_string($notice->created));
|
common_date_string($notice->created));
|
||||||
$out->elementEnd('a');
|
$out->elementEnd('a');
|
||||||
if ($notice->hasConversation()) {
|
$out->element('a', array('href' => $notice->getConversationUrl()),
|
||||||
$conv = Conversation::getKV('id', $notice->conversation);
|
// TRANS: Link text for link to conversation view.
|
||||||
$convurl = $conv->uri;
|
_m('in context'));
|
||||||
if (!empty($convurl)) {
|
|
||||||
$out->text(' ');
|
|
||||||
$out->element('a',
|
|
||||||
array('href' => $convurl.'#notice-'.$notice->id),
|
|
||||||
// TRANS: Link text for link to conversation view.
|
|
||||||
_m('in context'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$out->elementEnd('div');
|
$out->elementEnd('div');
|
||||||
$out->elementEnd('td');
|
$out->elementEnd('td');
|
||||||
$out->elementEnd('tr');
|
$out->elementEnd('tr');
|
||||||
|
@ -321,7 +321,7 @@ class RealtimePlugin extends Plugin
|
|||||||
$arr['url'] = $notice->getUrl();
|
$arr['url'] = $notice->getUrl();
|
||||||
$arr['html'] = htmlspecialchars($notice->rendered);
|
$arr['html'] = htmlspecialchars($notice->rendered);
|
||||||
$arr['source'] = htmlspecialchars($arr['source']);
|
$arr['source'] = htmlspecialchars($arr['source']);
|
||||||
$arr['conversation_url'] = $this->getConversationUrl($notice);
|
$arr['conversation_url'] = $notice->getConversationUrl();
|
||||||
|
|
||||||
$profile = $notice->getProfile();
|
$profile = $notice->getProfile();
|
||||||
$arr['user']['profile_url'] = $profile->profileurl;
|
$arr['user']['profile_url'] = $profile->profileurl;
|
||||||
@ -336,7 +336,7 @@ class RealtimePlugin extends Plugin
|
|||||||
$arr['retweeted_status']['source'] = htmlspecialchars($original->source);
|
$arr['retweeted_status']['source'] = htmlspecialchars($original->source);
|
||||||
$originalProfile = $original->getProfile();
|
$originalProfile = $original->getProfile();
|
||||||
$arr['retweeted_status']['user']['profile_url'] = $originalProfile->profileurl;
|
$arr['retweeted_status']['user']['profile_url'] = $originalProfile->profileurl;
|
||||||
$arr['retweeted_status']['conversation_url'] = $this->getConversationUrl($original);
|
$arr['retweeted_status']['conversation_url'] = $original->getConversationUrl();
|
||||||
}
|
}
|
||||||
unset($original);
|
unset($original);
|
||||||
}
|
}
|
||||||
@ -364,33 +364,6 @@ class RealtimePlugin extends Plugin
|
|||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConversationUrl($notice)
|
|
||||||
{
|
|
||||||
$convurl = null;
|
|
||||||
|
|
||||||
if ($notice->hasConversation()) {
|
|
||||||
$conv = Conversation::getKV(
|
|
||||||
'id',
|
|
||||||
$notice->conversation
|
|
||||||
);
|
|
||||||
$convurl = $conv->uri;
|
|
||||||
|
|
||||||
if(empty($convurl)) {
|
|
||||||
$msg = sprintf( "Could not find Conversation ID %d to make 'in context'"
|
|
||||||
. "link for Notice ID %d.",
|
|
||||||
$notice->conversation,
|
|
||||||
$notice->id
|
|
||||||
);
|
|
||||||
|
|
||||||
common_log(LOG_WARNING, $msg);
|
|
||||||
} else {
|
|
||||||
$convurl .= '#notice-' . $notice->id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $convurl;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _getScripts()
|
function _getScripts()
|
||||||
{
|
{
|
||||||
$urlpath = self::staticPath(str_replace('Plugin','',__CLASS__),
|
$urlpath = self::staticPath(str_replace('Plugin','',__CLASS__),
|
||||||
|
@ -526,7 +526,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$element = $this->_entryToElement($entry, true);
|
$element = $this->_entryToElement($entry, true);
|
||||||
|
|
||||||
$this->assertEquals($conv->uri, ActivityUtils::getLink($element, 'ostatus:conversation'));
|
$this->assertEquals($conv->getUri(), ActivityUtils::getLink($element, 'ostatus:conversation'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function __destruct()
|
function __destruct()
|
||||||
|
@ -457,11 +457,11 @@ h6 {font-size: 1em;}
|
|||||||
max-width: 440px;
|
max-width: 440px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.entry-content a.response:before {
|
.entry-content a.conversation:before {
|
||||||
content: "(";
|
content: " (";
|
||||||
}
|
}
|
||||||
|
|
||||||
div.entry-content a.response:after {
|
.entry-content a.conversation:after {
|
||||||
content: ")";
|
content: ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user