Merge branch '0.9.x' into 1.0.x
This commit is contained in:
commit
d9c1ac9053
@ -342,10 +342,24 @@ class TwitapisearchatomAction extends ApiAction
|
||||
'rel' => 'related',
|
||||
'href' => $profile->avatarUrl()));
|
||||
|
||||
// TODO: Here is where we'd put in a link to an atom feed for threads
|
||||
// @todo: Here is where we'd put in a link to an atom feed for threads
|
||||
|
||||
$this->element("twitter:source", null,
|
||||
htmlentities($this->sourceLink($notice->source)));
|
||||
$source = null;
|
||||
|
||||
$ns = $notice->getSource();
|
||||
if ($ns) {
|
||||
if (!empty($ns->name) && !empty($ns->url)) {
|
||||
$source = '<a href="'
|
||||
. htmlspecialchars($ns->url)
|
||||
. '" rel="nofollow">'
|
||||
. htmlspecialchars($ns->name)
|
||||
. '</a>';
|
||||
} else {
|
||||
$source = $ns->code;
|
||||
}
|
||||
}
|
||||
|
||||
$this->element("twitter:source", null, $source);
|
||||
|
||||
$this->elementStart('author');
|
||||
|
||||
|
@ -1172,7 +1172,7 @@ class Notice extends Memcached_DataObject
|
||||
return $groups;
|
||||
}
|
||||
|
||||
function asAtomEntry($namespace=false, $source=false, $author=true)
|
||||
function asAtomEntry($namespace=false, $source=false, $author=true, $cur=null)
|
||||
{
|
||||
$profile = $this->getProfile();
|
||||
|
||||
@ -1185,7 +1185,8 @@ class Notice extends Memcached_DataObject
|
||||
'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
|
||||
'xmlns:media' => 'http://purl.org/syndication/atommedia',
|
||||
'xmlns:poco' => 'http://portablecontacts.net/spec/1.0',
|
||||
'xmlns:ostatus' => 'http://ostatus.org/schema/1.0');
|
||||
'xmlns:ostatus' => 'http://ostatus.org/schema/1.0',
|
||||
'xmlns:statusnet' => 'http://status.net/ont/');
|
||||
} else {
|
||||
$attrs = array();
|
||||
}
|
||||
@ -1211,6 +1212,24 @@ class Notice extends Memcached_DataObject
|
||||
|
||||
$xs->element('icon', null, $profile->avatarUrl(AVATAR_PROFILE_SIZE));
|
||||
$xs->element('updated', null, common_date_w3dtf($this->created));
|
||||
|
||||
$noticeInfoAttr = array(
|
||||
'local_id' => $this->id, // local notice ID (useful to clients for ordering)
|
||||
'source' => $this->source // the client name (source attribution)
|
||||
);
|
||||
|
||||
$ns = $this->getSource();
|
||||
if ($ns) {
|
||||
if (!empty($ns->url)) {
|
||||
$noticeInfoAttr['source_link'] = $ns->url;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($cur)) {
|
||||
$noticeInfoAttr['favorited'] = ($cur->hasFave($this)) ? 'true' : 'false';
|
||||
}
|
||||
|
||||
$xs->element('statusnet:notice_info', $noticeInfoAttr, null);
|
||||
}
|
||||
|
||||
if ($source) {
|
||||
@ -1799,4 +1818,41 @@ class Notice extends Memcached_DataObject
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source of the notice
|
||||
*
|
||||
* @return Notice_source $ns A notice source object. 'code' is the only attribute
|
||||
* guaranteed to be populated.
|
||||
*/
|
||||
function getSource()
|
||||
{
|
||||
$ns = new Notice_source();
|
||||
if (!empty($this->source)) {
|
||||
switch ($this->source) {
|
||||
case 'web':
|
||||
case 'xmpp':
|
||||
case 'mail':
|
||||
case 'omb':
|
||||
case 'system':
|
||||
case 'api':
|
||||
$ns->code = $this->source;
|
||||
break;
|
||||
default:
|
||||
$ns = Notice_source::staticGet($this->source);
|
||||
if (!$ns) {
|
||||
$ns = new Notice_source();
|
||||
$ns->code = $this->source;
|
||||
$app = Oauth_application::staticGet('name', $this->source);
|
||||
if ($app) {
|
||||
$ns->name = $app->name;
|
||||
$ns->url = $app->source_url;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $ns;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -313,7 +313,23 @@ class ApiAction extends Action
|
||||
$twitter_status['created_at'] = $this->dateTwitter($notice->created);
|
||||
$twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ?
|
||||
intval($notice->reply_to) : null;
|
||||
$twitter_status['source'] = $this->sourceLink($notice->source);
|
||||
|
||||
$source = null;
|
||||
|
||||
$ns = $notice->getSource();
|
||||
if ($ns) {
|
||||
if (!empty($ns->name) && !empty($ns->url)) {
|
||||
$source = '<a href="'
|
||||
. htmlspecialchars($ns->url)
|
||||
. '" rel="nofollow">'
|
||||
. htmlspecialchars($ns->name)
|
||||
. '</a>';
|
||||
} else {
|
||||
$source = $ns->code;
|
||||
}
|
||||
}
|
||||
|
||||
$twitter_status['source'] = $source;
|
||||
$twitter_status['id'] = intval($notice->id);
|
||||
|
||||
$replier_profile = null;
|
||||
@ -1354,43 +1370,6 @@ class ApiAction extends Action
|
||||
}
|
||||
}
|
||||
|
||||
function sourceLink($source)
|
||||
{
|
||||
$source_name = _($source);
|
||||
switch ($source) {
|
||||
case 'web':
|
||||
case 'xmpp':
|
||||
case 'mail':
|
||||
case 'omb':
|
||||
case 'api':
|
||||
break;
|
||||
default:
|
||||
|
||||
$name = null;
|
||||
$url = null;
|
||||
|
||||
$ns = Notice_source::staticGet($source);
|
||||
|
||||
if ($ns) {
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns query argument or default value if not found. Certain
|
||||
* parameters used throughout the API are lightly scrubbed and
|
||||
|
@ -79,6 +79,11 @@ class AtomNoticeFeed extends Atom10Feed
|
||||
'ostatus',
|
||||
'http://ostatus.org/schema/1.0'
|
||||
);
|
||||
|
||||
$this->addNamespace(
|
||||
'statusnet',
|
||||
'http://status.net/ont/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,7 +115,9 @@ class AtomNoticeFeed extends Atom10Feed
|
||||
$source = $this->showSource();
|
||||
$author = $this->showAuthor();
|
||||
|
||||
$this->addEntryRaw($notice->asAtomEntry(false, $source, $author));
|
||||
$cur = common_current_user();
|
||||
|
||||
$this->addEntryRaw($notice->asAtomEntry(false, $source, $author, $cur));
|
||||
}
|
||||
|
||||
function showSource()
|
||||
|
@ -488,54 +488,46 @@ class NoticeListItem extends Widget
|
||||
|
||||
function showNoticeSource()
|
||||
{
|
||||
if ($this->notice->source) {
|
||||
$ns = $this->notice->getSource();
|
||||
|
||||
if ($ns) {
|
||||
$source_name = _($ns->code);
|
||||
$this->out->text(' ');
|
||||
$this->out->elementStart('span', 'source');
|
||||
$this->out->text(_('from'));
|
||||
$source_name = _($this->notice->source);
|
||||
$this->out->text(' ');
|
||||
switch ($this->notice->source) {
|
||||
case 'web':
|
||||
case 'xmpp':
|
||||
case 'mail':
|
||||
case 'omb':
|
||||
case 'system':
|
||||
case 'api':
|
||||
$this->out->element('span', 'device', $source_name);
|
||||
break;
|
||||
default:
|
||||
|
||||
$name = $source_name;
|
||||
$url = $ns->url;
|
||||
$title = null;
|
||||
|
||||
if (Event::handle('StartNoticeSourceLink', array($this->notice, &$name, &$url, &$title))) {
|
||||
$name = $source_name;
|
||||
$url = null;
|
||||
|
||||
if (Event::handle('StartNoticeSourceLink', array($this->notice, &$name, &$url, &$title))) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Event::handle('EndNoticeSourceLink', array($this->notice, &$name, &$url, &$title));
|
||||
|
||||
if (!empty($name) && !empty($url)) {
|
||||
$this->out->elementStart('span', 'device');
|
||||
$this->out->element('a', array('href' => $url,
|
||||
'rel' => 'external',
|
||||
'title' => $title),
|
||||
$name);
|
||||
$this->out->elementEnd('span');
|
||||
} else {
|
||||
$this->out->element('span', 'device', $name);
|
||||
}
|
||||
break;
|
||||
$url = $ns->url;
|
||||
}
|
||||
Event::handle('EndNoticeSourceLink', array($this->notice, &$name, &$url, &$title));
|
||||
|
||||
// if $ns->name and $ns->url are populated we have
|
||||
// configured a source attr somewhere
|
||||
if (!empty($name) && !empty($url)) {
|
||||
|
||||
$this->out->elementStart('span', 'device');
|
||||
|
||||
$attrs = array(
|
||||
'href' => $url,
|
||||
'rel' => 'external'
|
||||
);
|
||||
|
||||
if (!empty($title)) {
|
||||
$attrs['title'] = $title;
|
||||
}
|
||||
|
||||
$this->out->element('a', $attrs, $name);
|
||||
$this->out->elementEnd('span');
|
||||
} else {
|
||||
$this->out->element('span', 'device', $name);
|
||||
}
|
||||
|
||||
$this->out->elementEnd('span');
|
||||
}
|
||||
}
|
||||
|
@ -138,6 +138,7 @@ class MobileProfilePlugin extends WAP20Plugin
|
||||
'vodafone',
|
||||
'wap1',
|
||||
'wap2',
|
||||
'webos',
|
||||
'windows ce'
|
||||
);
|
||||
|
||||
@ -254,6 +255,10 @@ class MobileProfilePlugin extends WAP20Plugin
|
||||
$action->cssLink('plugins/MobileProfile/mp-handheld.css',null,'handheld');
|
||||
}
|
||||
|
||||
// Allow other plugins to load their styles.
|
||||
Event::handle('EndShowStatusNetStyles', array($action));
|
||||
Event::handle('EndShowLaconicaStyles', array($action));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -452,6 +452,7 @@ class OStatusPlugin extends Plugin
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user