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.
*
$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));
*/
function showNoticeLink()
{
- $noticeurl = $this->notice->bestUrl();
+ $noticeurl = $this->notice->getUrl();
// above should always return an URL
// 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,
// 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,
// 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,
// 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,
// 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());
// 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());
// 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());
// 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());
$this->elementEnd('body');
$this->endHTML();
} else {
- common_redirect($saved->bestUrl(), 303);
+ common_redirect($saved->getUrl(), 303);
}
}
}
}
$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
$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'),
$object->type = ActivityObject::BOOKMARK;
$object->title = $nb->title;
$object->summary = $nb->description;
- $object->link = $notice->bestUrl();
+ $object->link = $notice->getUrl();
// Attributes of the URL
$this->elementEnd('body');
$this->endHTML();
} else {
- common_redirect($saved->bestUrl(), 303);
+ common_redirect($saved->getUrl(), 303);
}
}
$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(
$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',
$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?!
$this->elementEnd('body');
$this->endHTML();
} else {
- common_redirect($saved->bestUrl(), 303);
+ common_redirect($saved->getUrl(), 303);
}
}
$this->elementEnd('body');
$this->endHTML();
} else {
- common_redirect($saved->bestUrl(), 303);
+ common_redirect($saved->getUrl(), 303);
}
}
$eventTitle = _m('an unknown event');
} else {
$notice = $event->getNotice();
- $eventUrl = $notice->bestUrl();
+ $eventUrl = $notice->getUrl();
$eventTitle = $event->title;
}
$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;
$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);
$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;
}
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');
}
$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) {
$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) {
$this->elementEnd('body');
$this->endHTML();
} else {
- common_redirect($saved->bestUrl(), 303);
+ common_redirect($saved->getUrl(), 303);
}
}
$this->elementEnd('body');
$this->endHTML();
} else {
- common_redirect($this->poll->bestUrl(), 303);
+ common_redirect($this->poll->getUrl(), 303);
}
}
return Notice::getKV('uri', $this->uri);
}
- function bestUrl()
+ function getUrl()
{
- return $this->getNotice()->bestUrl();
+ return $this->getNotice()->getUrl();
}
/**
return Notice::getKV('uri', $this->uri);
}
- function bestUrl()
+ function getUrl()
{
- return $this->getNotice()->bestUrl();
+ return $this->getNotice()->getUrl();
}
/**
$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
$this->elementEnd('body');
$this->endHTML();
} else {
- common_redirect($this->question->bestUrl(), 303);
+ common_redirect($this->question->getUrl(), 303);
}
}
$this->endHTML();
} else {
common_debug("not ajax");
- common_redirect($this->question->bestUrl(), 303);
+ common_redirect($this->question->getUrl(), 303);
}
}
$this->elementEnd('body');
$this->endHTML();
} else {
- common_redirect($saved->bestUrl(), 303);
+ common_redirect($saved->getUrl(), 303);
}
}
$this->elementEnd('body');
$this->endHTML();
} else {
- common_redirect($this->answer->bestUrl(), 303);
+ common_redirect($this->answer->getUrl(), 303);
}
}
$this->elementEnd('body');
$this->endHTML();
} else {
- common_redirect($this->answer->bestUrl(), 303);
+ common_redirect($this->answer->getUrl(), 303);
}
}
$this->elementEnd('body');
$this->endHTML();
} else {
- common_redirect($this->question->bestUrl(), 303);
+ common_redirect($this->question->getUrl(), 303);
}
}
return QnA_Answer::getKV('uri', $notice->uri);
}
- function bestUrl()
+ function getUrl()
{
- return $this->getNotice()->bestUrl();
+ return $this->getNotice()->getUrl();
}
/**
return Notice::getKV('uri', $this->uri);
}
- function bestUrl()
+ function getUrl()
{
- return $this->getNotice()->bestUrl();
+ return $this->getNotice()->getUrl();
}
function getProfile()
$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);
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;
{
// 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'));
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),
);
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,
$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()