Commit 7d191f80 authored by mmn's avatar mmn

s/bestUrl/getUrl/ for notices and microapp objects

parent c1d2f251
......@@ -1697,17 +1697,6 @@ class Notice extends Managed_DataObject
return $noun->asString('activity:' . $element);
}
// FIXME: Replace all bestUrl with getUrl and do exception handling
function bestUrl()
{
try {
return $this->getUrl();
} catch (InvalidUrlException $e) {
return common_local_url('shownotice', array('notice' => $this->id));
}
}
/**
* Determine which notice, if any, a new notice is in reply to.
*
......
......@@ -445,7 +445,7 @@ class ActivityObject
$object->title .= $e->profile->nickname;
}
$object->content = $notice->rendered;
$object->link = $notice->bestUrl();
$object->link = $notice->getUrl();
$object->extra[] = array('status_net', array('notice_id' => $notice->id));
......
......@@ -361,7 +361,7 @@ class NoticeListItem extends Widget
*/
function showNoticeLink()
{
$noticeurl = $this->notice->bestUrl();
$noticeurl = $this->notice->getUrl();
// above should always return an URL
......
......@@ -73,18 +73,18 @@ class ActivityPlugin extends Plugin
// TRANS: %1$s is a profile URL, %2$s is a profile name,
// TRANS: %3$s is a profile URL, %4$s is a profile name.
$rendered = sprintf(_m('<a href="%1$s">%2$s</a> started following <a href="%3$s">%4$s</a>.'),
$profile->profileurl,
$profile->getUrl(),
$profile->getBestName(),
$other->profileurl,
$other->getUrl(),
$other->getBestName());
// TRANS: Text for "started following" item in activity plugin.
// TRANS: %1$s is a profile name, %2$s is a profile URL,
// TRANS: %3$s is a profile name, %4$s is a profile URL.
$content = sprintf(_m('%1$s (%2$s) started following %3$s (%4$s).'),
$profile->getBestName(),
$profile->profileurl,
$profile->getUrl(),
$other->getBestName(),
$other->profileurl);
$other->getUrl());
$notice = Notice::saveNew($profile->id,
$content,
......@@ -111,18 +111,18 @@ class ActivityPlugin extends Plugin
// TRANS: %1$s is a profile URL, %2$s is a profile name,
// TRANS: %3$s is a profile URL, %4$s is a profile name.
$rendered = sprintf(_m('<a href="%1$s">%2$s</a> stopped following <a href="%3$s">%4$s</a>.'),
$profile->profileurl,
$profile->getUrl(),
$profile->getBestName(),
$other->profileurl,
$other->getUrl(),
$other->getBestName());
// TRANS: Text for "stopped following" item in activity plugin.
// TRANS: %1$s is a profile name, %2$s is a profile URL,
// TRANS: %3$s is a profile name, %4$s is a profile URL.
$content = sprintf(_m('%1$s (%2$s) stopped following %3$s (%4$s).'),
$profile->getBestName(),
$profile->profileurl,
$profile->getUrl(),
$other->getBestName(),
$other->profileurl);
$other->getUrl());
$uri = TagURI::mint('stop-following:%d:%d:%s',
$profile->id,
......@@ -159,18 +159,18 @@ class ActivityPlugin extends Plugin
// TRANS: %1$s is a profile URL, %2$s is a profile name,
// TRANS: %3$s is a notice URL, %4$s is an author name.
$rendered = sprintf(_m('<a href="%1$s">%2$s</a> liked <a href="%3$s">%4$s\'s update</a>.'),
$profile->profileurl,
$profile->getUrl(),
$profile->getBestName(),
$notice->bestUrl(),
$notice->getUrl(),
$author->getBestName());
// TRANS: Text for "liked" item in activity plugin.
// TRANS: %1$s is a profile name, %2$s is a profile URL,
// TRANS: %3$s is an author name, %4$s is a notice URL.
$content = sprintf(_m('%1$s (%2$s) liked %3$s\'s status (%4$s).'),
$profile->getBestName(),
$profile->profileurl,
$profile->getUrl(),
$author->getBestName(),
$notice->bestUrl());
$notice->getUrl());
$notice = Notice::saveNew($profile->id,
$content,
......@@ -200,18 +200,18 @@ class ActivityPlugin extends Plugin
// TRANS: %1$s is a profile URL, %2$s is a profile name,
// TRANS: %3$s is a notice URL, %4$s is an author name.
$rendered = sprintf(_m('<a href="%1$s">%2$s</a> stopped liking <a href="%3$s">%4$s\'s update</a>.'),
$profile->profileurl,
$profile->getUrl(),
$profile->getBestName(),
$notice->bestUrl(),
$notice->getUrl(),
$author->getBestName());
// TRANS: Text for "stopped liking" item in activity plugin.
// TRANS: %1$s is a profile name, %2$s is a profile URL,
// TRANS: %3$s is an author name, %4$s is a notice URL.
$content = sprintf(_m('%1$s (%2$s) stopped liking %3$s\'s status (%4$s).'),
$profile->getBestName(),
$profile->profileurl,
$profile->getUrl(),
$author->getBestName(),
$notice->bestUrl());
$notice->getUrl());
$uri = TagURI::mint('unlike:%d:%d:%s',
$profile->id,
......@@ -245,7 +245,7 @@ class ActivityPlugin extends Plugin
// TRANS: %1$s is a profile URL, %2$s is a profile name,
// TRANS: %3$s is a group URL, %4$s is a group name.
$rendered = sprintf(_m('<a href="%1$s">%2$s</a> joined the group <a href="%3$s">%4$s</a>.'),
$profile->profileurl,
$profile->getUrl(),
$profile->getBestName(),
$group->homeUrl(),
$group->getBestName());
......@@ -254,7 +254,7 @@ class ActivityPlugin extends Plugin
// TRANS: %3$s is a group name, %4$s is a group URL.
$content = sprintf(_m('%1$s (%2$s) joined the group %3$s (%4$s).'),
$profile->getBestName(),
$profile->profileurl,
$profile->getUrl(),
$group->getBestName(),
$group->homeUrl());
......@@ -286,7 +286,7 @@ class ActivityPlugin extends Plugin
// TRANS: %1$s is a profile URL, %2$s is a profile name,
// TRANS: %3$s is a group URL, %4$s is a group name.
$rendered = sprintf(_m('<a href="%1$s">%2$s</a> left the group <a href="%3$s">%4$s</a>.'),
$profile->profileurl,
$profile->getUrl(),
$profile->getBestName(),
$group->homeUrl(),
$group->getBestName());
......@@ -295,7 +295,7 @@ class ActivityPlugin extends Plugin
// TRANS: %3$s is a group name, %4$s is a group URL.
$content = sprintf(_m('%1$s (%2$s) left the group %3$s (%4$s).'),
$profile->getBestName(),
$profile->profileurl,
$profile->getUrl(),
$group->getBestName(),
$group->homeUrl());
......
......@@ -131,7 +131,7 @@ class NewblogentryAction extends Action
$this->elementEnd('body');
$this->endHTML();
} else {
common_redirect($saved->bestUrl(), 303);
common_redirect($saved->getUrl(), 303);
}
}
}
......@@ -68,7 +68,7 @@ class BlogEntryListItem extends NoticeListItemAdapter
}
$out->elementStart('h4', array('class' => 'blog-entry-title'));
$out->element('a', array('href' => $notice->bestUrl()), $entry->title);
$out->element('a', array('href' => $notice->getUrl()), $entry->title);
$out->elementEnd('h4');
// XXX: kind of a hack
......@@ -91,7 +91,7 @@ class BlogEntryListItem extends NoticeListItemAdapter
$out->elementEnd('div');
}
$url = ($entry->url) ? $entry->url : $notice->bestUrl();
$url = ($entry->url) ? $entry->url : $notice->getUrl();
$out->element('a',
array('href' => $url,
'class' => 'blog-entry-link'),
......
......@@ -467,7 +467,7 @@ class BookmarkPlugin extends MicroAppPlugin
$object->type = ActivityObject::BOOKMARK;
$object->title = $nb->title;
$object->summary = $nb->description;
$object->link = $notice->bestUrl();
$object->link = $notice->getUrl();
// Attributes of the URL
......
......@@ -178,7 +178,7 @@ class NewbookmarkAction extends Action
$this->elementEnd('body');
$this->endHTML();
} else {
common_redirect($saved->bestUrl(), 303);
common_redirect($saved->getUrl(), 303);
}
}
......
......@@ -195,7 +195,7 @@ ENDOFSCRIPT;
$profile = Profile::getKV('id', $noticeListItem->notice->profile_id);
if ($this->isAllowedRichEdit($profile)) {
$noticeUrl = $noticeListItem->notice->bestUrl();
$noticeUrl = $noticeListItem->notice->getUrl();
$noticeUrl .= '#disqus_thread';
$noticeListItem->out->element(
......
......@@ -173,7 +173,7 @@ class UserEmailSummaryHandler extends QueueHandler
$out->text(' ');
$out->raw($notice->rendered);
$out->elementStart('div', array('style' => 'font-size: 0.8em; padding-top: 4px;'));
$noticeurl = $notice->bestUrl();
$noticeurl = $notice->getUrl();
// above should always return an URL
assert(!empty($noticeurl));
$out->elementStart('a', array('rel' => 'bookmark',
......
......@@ -216,7 +216,7 @@ class EventPlugin extends MicroappPlugin
$obj->type = Happening::OBJECT_TYPE;
$obj->title = $happening->title;
$obj->summary = $happening->description;
$obj->link = $notice->bestUrl();
$obj->link = $notice->getUrl();
// XXX: how to get this stuff into JSON?!
......
......@@ -254,7 +254,7 @@ class NeweventAction extends Action
$this->elementEnd('body');
$this->endHTML();
} else {
common_redirect($saved->bestUrl(), 303);
common_redirect($saved->getUrl(), 303);
}
}
......
......@@ -166,7 +166,7 @@ class NewrsvpAction extends Action
$this->elementEnd('body');
$this->endHTML();
} else {
common_redirect($saved->bestUrl(), 303);
common_redirect($saved->getUrl(), 303);
}
}
......
......@@ -347,7 +347,7 @@ class RSVP extends Managed_DataObject
$eventTitle = _m('an unknown event');
} else {
$notice = $event->getNotice();
$eventUrl = $notice->bestUrl();
$eventUrl = $notice->getUrl();
$eventTitle = $event->title;
}
......
......@@ -107,7 +107,7 @@ class GNUsocialPhotoPlugin extends MicroAppPlugin
$object->type = Photo::OBJECT_TYPE;
$object->title = $photo->title;
$object->summary = $notice->content;
$object->link = $notice->bestUrl();
$object->link = $notice->getUrl();
$object->largerImage = $photo->photo_uri;
$object->thumbnail = $photo->thumb_uri;
......
......@@ -98,7 +98,7 @@ class GNUsocialVideoPlugin extends MicroAppPlugin
$object->type = Video::OBJECT_TYPE;
$object->title = $notice->content;
$object->summary = $notice->content;
$object->link = $notice->bestUrl();
$object->link = $notice->getUrl();
$vid = Video::getByNotice($notice);
......
......@@ -143,14 +143,14 @@ class MapAction extends Action
$act = new ApiAction('/dev/null');
$arr = $act->twitterStatusArray($notice, true);
$arr['url'] = $notice->bestUrl();
$arr['url'] = $notice->getUrl();
$arr['html'] = $notice->rendered;
$arr['source'] = $arr['source'];
if (!empty($notice->reply_to)) {
$reply_to = Notice::getKV('id', $notice->reply_to);
if (!empty($reply_to)) {
$arr['in_reply_to_status_url'] = $reply_to->bestUrl();
$arr['in_reply_to_status_url'] = $reply_to->getUrl();
}
$reply_to = null;
}
......
......@@ -187,7 +187,7 @@ class NoticeTitlePlugin extends Plugin
if (!empty($title)) {
$nli->out->elementStart('h4', array('class' => 'notice_title'));
$nli->out->element('a', array('href' => $nli->notice->bestUrl()), $title);
$nli->out->element('a', array('href' => $nli->notice->getUrl()), $title);
$nli->out->elementEnd('h4');
}
......
......@@ -242,7 +242,7 @@ class PollPlugin extends MicroAppPlugin
$object->type = self::POLL_RESPONSE_OBJECT;
$object->title = $notice->content;
$object->summary = $notice->content;
$object->link = $notice->bestUrl();
$object->link = $notice->getUrl();
$response = Poll_response::getByNotice($notice);
if ($response) {
......@@ -265,7 +265,7 @@ class PollPlugin extends MicroAppPlugin
$object->type = self::POLL_OBJECT;
$object->title = $notice->content;
$object->summary = $notice->content;
$object->link = $notice->bestUrl();
$object->link = $notice->getUrl();
$poll = Poll::getByNotice($notice);
if ($poll) {
......
......@@ -168,7 +168,7 @@ class NewPollAction extends Action
$this->elementEnd('body');
$this->endHTML();
} else {
common_redirect($saved->bestUrl(), 303);
common_redirect($saved->getUrl(), 303);
}
}
......
......@@ -155,7 +155,7 @@ class RespondPollAction extends Action
$this->elementEnd('body');
$this->endHTML();
} else {
common_redirect($this->poll->bestUrl(), 303);
common_redirect($this->poll->getUrl(), 303);
}
}
......
......@@ -114,9 +114,9 @@ class Poll extends Managed_DataObject
return Notice::getKV('uri', $this->uri);
}
function bestUrl()
function getUrl()
{
return $this->getNotice()->bestUrl();
return $this->getNotice()->getUrl();
}
/**
......
......@@ -100,9 +100,9 @@ class Poll_response extends Managed_DataObject
return Notice::getKV('uri', $this->uri);
}
function bestUrl()
function getUrl()
{
return $this->getNotice()->bestUrl();
return $this->getNotice()->getUrl();
}
/**
......
......@@ -242,7 +242,7 @@ class QnAPlugin extends MicroAppPlugin
$obj->id = $question->uri;
$obj->type = QnA_Question::OBJECT_TYPE;
$obj->title = $question->title;
$obj->link = $notice->bestUrl();
$obj->link = $notice->getUrl();
// XXX: probably need other stuff here
......
......@@ -158,7 +158,7 @@ class QnaclosequestionAction extends Action
$this->elementEnd('body');
$this->endHTML();
} else {
common_redirect($this->question->bestUrl(), 303);
common_redirect($this->question->getUrl(), 303);
}
}
......
......@@ -167,7 +167,7 @@ class QnanewanswerAction extends Action
$this->endHTML();
} else {
common_debug("not ajax");
common_redirect($this->question->bestUrl(), 303);
common_redirect($this->question->getUrl(), 303);
}
}
......
......@@ -158,7 +158,7 @@ class QnanewquestionAction extends Action
$this->elementEnd('body');
$this->endHTML();
} else {
common_redirect($saved->bestUrl(), 303);
common_redirect($saved->getUrl(), 303);
}
}
......
......@@ -166,7 +166,7 @@ class QnareviseanswerAction extends Action
$this->elementEnd('body');
$this->endHTML();
} else {
common_redirect($this->answer->bestUrl(), 303);
common_redirect($this->answer->getUrl(), 303);
}
}
......@@ -208,7 +208,7 @@ class QnareviseanswerAction extends Action
$this->elementEnd('body');
$this->endHTML();
} else {
common_redirect($this->answer->bestUrl(), 303);
common_redirect($this->answer->getUrl(), 303);
}
}
......
......@@ -153,7 +153,7 @@ class Qnavote extends Action
$this->elementEnd('body');
$this->endHTML();
} else {
common_redirect($this->question->bestUrl(), 303);
common_redirect($this->question->getUrl(), 303);
}
}
......
......@@ -127,9 +127,9 @@ class QnA_Answer extends Managed_DataObject
return QnA_Answer::getKV('uri', $notice->uri);
}
function bestUrl()
function getUrl()
{
return $this->getNotice()->bestUrl();
return $this->getNotice()->getUrl();
}
/**
......
......@@ -107,9 +107,9 @@ class QnA_Question extends Managed_DataObject
return Notice::getKV('uri', $this->uri);
}
function bestUrl()
function getUrl()
{
return $this->getNotice()->bestUrl();
return $this->getNotice()->getUrl();
}
function getProfile()
......
......@@ -318,7 +318,7 @@ class RealtimePlugin extends Plugin
$act = new ApiAction('/dev/null');
$arr = $act->twitterStatusArray($notice, true);
$arr['url'] = $notice->bestUrl();
$arr['url'] = $notice->getUrl();
$arr['html'] = htmlspecialchars($notice->rendered);
$arr['source'] = htmlspecialchars($arr['source']);
$arr['conversation_url'] = $this->getConversationUrl($notice);
......@@ -330,15 +330,15 @@ class RealtimePlugin extends Plugin
if (!empty($notice->repeat_of)) {
$original = Notice::getKV('id', $notice->repeat_of);
if (!empty($original)) {
$arr['retweeted_status']['url'] = $original->bestUrl();
if ($original instanceof Notice) {
$arr['retweeted_status']['url'] = $original->getUrl();
$arr['retweeted_status']['html'] = htmlspecialchars($original->rendered);
$arr['retweeted_status']['source'] = htmlspecialchars($original->source);
$originalProfile = $original->getProfile();
$arr['retweeted_status']['user']['profile_url'] = $originalProfile->profileurl;
$arr['retweeted_status']['conversation_url'] = $this->getConversationUrl($original);
}
$original = null;
unset($original);
}
return $arr;
......
......@@ -104,7 +104,7 @@ abstract class GenericNoticeShareTarget extends NoticeShareTarget
{
// TRANS: %s is notice content that is shared on Twitter, Facebook or another platform.
$pattern = _m('"%s"');
$url = $this->notice->bestUrl();
$url = $this->notice->getUrl();
$suffix = ' ' . $url;
$room = $this->maxLength() - mb_strlen($suffix) - (mb_strlen($pattern) - mb_strlen('%s'));
......@@ -192,7 +192,7 @@ class FacebookShareTarget extends NoticeShareTarget
public function targetUrl()
{
$args = array(
'u' => $this->notice->bestUrl(),
'u' => $this->notice->getUrl(),
// TRANS: %s is notice content that is shared on Twitter, Facebook or another platform.
't' => sprintf(_m('"%s"'), $this->notice->content),
);
......
......@@ -194,7 +194,7 @@ class SubMirror extends Managed_DataObject
protected function copyNotice($profile, $notice)
{
$options = array('is_local' => Notice::LOCAL_PUBLIC,
'url' => $notice->bestUrl(), // pass through the foreign link...
'url' => $notice->getUrl(), // pass through the foreign link...
'rendered' => $notice->rendered);
$saved = Notice::saveNew($profile->id,
......
......@@ -372,7 +372,7 @@ class ActivityGenerationTests extends PHPUnit_Framework_TestCase
$this->assertNotNull($forward);
$this->assertEquals($notice->getUri(), $forward->getAttribute('ref'));
$this->assertEquals($notice->bestUrl(), $forward->getAttribute('href'));
$this->assertEquals($notice->getUrl(), $forward->getAttribute('href'));
}
public function testTag()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment