summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-02-02 08:47:14 +0000
committerZach Copley <zach@status.net>2010-02-02 08:51:01 +0000
commitdae28d98d1958b1d7ba6572f72efc3e6cdbff276 (patch)
treef121d7f2036893920654d7d3124649c5cf2e5888 /lib
parent3906713b2aec17d889d79dcf526ae05e284b5b33 (diff)
Linkify notice source when posting from registered OAuth apps
Diffstat (limited to 'lib')
-rw-r--r--lib/api.php19
-rw-r--r--lib/noticelist.php20
2 files changed, 36 insertions, 3 deletions
diff --git a/lib/api.php b/lib/api.php
index 10a2fae28..f81975216 100644
--- a/lib/api.php
+++ b/lib/api.php
@@ -1249,10 +1249,27 @@ class ApiAction extends Action
case 'api':
break;
default:
+
+ $name = null;
+ $url = null;
+
$ns = Notice_source::staticGet($source);
+
if ($ns) {
- $source_name = '<a href="' . $ns->url . '">' . $ns->name . '</a>';
+ $name = $ns->name;
+ $url = $ns->url;
+ } else {
+ $app = Oauth_application::staticGet('name', $source);
+ if ($app) {
+ $name = $app->name;
+ $url = $app->source_url;
+ }
+ }
+
+ if (!empty($name) && !empty($url)) {
+ $source_name = '<a href="' . $url . '">' . $name . '</a>';
}
+
break;
}
return $source_name;
diff --git a/lib/noticelist.php b/lib/noticelist.php
index 85c169716..a4a0f2651 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -486,12 +486,28 @@ class NoticeListItem extends Widget
$this->out->element('span', 'device', $source_name);
break;
default:
+
+ $name = null;
+ $url = null;
+
$ns = Notice_source::staticGet($this->notice->source);
+
if ($ns) {
+ $name = $ns->name;
+ $url = $ns->url;
+ } else {
+ $app = Oauth_application::staticGet('name', $this->notice->source);
+ if ($app) {
+ $name = $app->name;
+ $url = $app->source_url;
+ }
+ }
+
+ if (!empty($name) && !empty($url)) {
$this->out->elementStart('span', 'device');
- $this->out->element('a', array('href' => $ns->url,
+ $this->out->element('a', array('href' => $url,
'rel' => 'external'),
- $ns->name);
+ $name);
$this->out->elementEnd('span');
} else {
$this->out->element('span', 'device', $source_name);