Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x
This commit is contained in:
commit
f8a459a88a
|
@ -109,15 +109,13 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
|
|||
$title = sprintf(_("%s timeline"), $this->group->nickname);
|
||||
$taguribase = common_config('integration', 'taguri');
|
||||
$id = "tag:$taguribase:GroupTimeline:" . $this->group->id;
|
||||
$link = common_local_url(
|
||||
'showgroup',
|
||||
array('nickname' => $this->group->nickname)
|
||||
);
|
||||
|
||||
$subtitle = sprintf(
|
||||
_('Updates from %1$s on %2$s!'),
|
||||
$this->group->nickname,
|
||||
$sitename
|
||||
);
|
||||
|
||||
$logo = ($avatar) ? $avatar : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
|
||||
|
||||
switch($this->format) {
|
||||
|
@ -125,22 +123,56 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
|
|||
$this->showXmlTimeline($this->notices);
|
||||
break;
|
||||
case 'rss':
|
||||
$this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
|
||||
break;
|
||||
case 'atom':
|
||||
$selfuri = common_root_url() .
|
||||
'api/statusnet/groups/timeline/' .
|
||||
$this->group->id . '.atom';
|
||||
$this->showAtomTimeline(
|
||||
$this->showRssTimeline(
|
||||
$this->notices,
|
||||
$title,
|
||||
$id,
|
||||
$link,
|
||||
$this->group->homeUrl(),
|
||||
$subtitle,
|
||||
null,
|
||||
$selfuri,
|
||||
$logo
|
||||
);
|
||||
break;
|
||||
case 'atom':
|
||||
|
||||
header('Content-Type: application/atom+xml; charset=utf-8');
|
||||
|
||||
try {
|
||||
|
||||
$atom = new AtomNoticeFeed();
|
||||
|
||||
$atom->setId($id);
|
||||
$atom->setTitle($title);
|
||||
$atom->setSubtitle($subtitle);
|
||||
$atom->setLogo($logo);
|
||||
$atom->setUpdated('now');
|
||||
|
||||
$atom->addAuthorRaw($this->group->asAtomAuthor());
|
||||
$atom->setActivitySubject($this->group->asActivitySubject());
|
||||
|
||||
$atom->addLink($this->group->homeUrl());
|
||||
|
||||
$id = $this->arg('id');
|
||||
$aargs = array('format' => 'atom');
|
||||
if (!empty($id)) {
|
||||
$aargs['id'] = $id;
|
||||
}
|
||||
|
||||
$atom->addLink(
|
||||
$this->getSelfUri('ApiTimelineGroup', $aargs),
|
||||
array('rel' => 'self', 'type' => 'application/atom+xml')
|
||||
);
|
||||
|
||||
$atom->addEntryFromNotices($this->notices);
|
||||
|
||||
$this->raw($atom->getString());
|
||||
|
||||
} catch (Atom10FeedException $e) {
|
||||
$this->serverError(
|
||||
'Could not generate feed for group - ' . $e->getMessage()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'json':
|
||||
$this->showJsonTimeline($this->notices);
|
||||
|
|
|
@ -1016,7 +1016,7 @@ class Notice extends Memcached_DataObject
|
|||
}
|
||||
|
||||
if (!empty($this->conversation)
|
||||
&& $this->conversation != $this->notice->id) {
|
||||
&& $this->conversation != $this->id) {
|
||||
$xs->element(
|
||||
'link', array(
|
||||
'rel' => 'ostatus:conversation',
|
||||
|
|
|
@ -355,6 +355,39 @@ class User_group extends Memcached_DataObject
|
|||
return $xs->getString();
|
||||
}
|
||||
|
||||
function asAtomAuthor()
|
||||
{
|
||||
$xs = new XMLStringer(true);
|
||||
|
||||
$xs->elementStart('author');
|
||||
$xs->element('name', null, $this->nickname);
|
||||
$xs->element('uri', null, $this->permalink());
|
||||
$xs->elementEnd('author');
|
||||
|
||||
return $xs->getString();
|
||||
}
|
||||
|
||||
function asActivitySubject()
|
||||
{
|
||||
$xs = new XMLStringer(true);
|
||||
|
||||
$xs->elementStart('activity:subject');
|
||||
$xs->element('activity:object', null, 'http://activitystrea.ms/schema/1.0/group');
|
||||
$xs->element('id', null, $this->permalink());
|
||||
$xs->element('title', null, $this->getBestName());
|
||||
$xs->element(
|
||||
'link', array(
|
||||
'rel' => 'avatar',
|
||||
'href' => empty($this->homepage_logo)
|
||||
? User_group::defaultLogo(AVATAR_PROFILE_SIZE)
|
||||
: $this->homepage_logo
|
||||
)
|
||||
);
|
||||
$xs->elementEnd('activity:subject');
|
||||
|
||||
return $xs->getString();
|
||||
}
|
||||
|
||||
static function register($fields) {
|
||||
|
||||
// MAGICALLY put fields into current scope
|
||||
|
|
|
@ -1104,7 +1104,7 @@ class ApiAction extends Action
|
|||
}
|
||||
}
|
||||
|
||||
function serverError($msg, $code = 500, $content_type = 'json')
|
||||
function serverError($msg, $code = 500, $content_type = 'xml')
|
||||
{
|
||||
$action = $this->trimmed('action');
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ class Atom10Feed extends XMLStringer
|
|||
public $xw;
|
||||
private $namespaces;
|
||||
private $authors;
|
||||
private $subject;
|
||||
private $categories;
|
||||
private $contributors;
|
||||
private $generator;
|
||||
|
@ -74,6 +75,7 @@ class Atom10Feed extends XMLStringer
|
|||
function __construct($indent = true) {
|
||||
parent::__construct($indent);
|
||||
$this->namespaces = array();
|
||||
$this->authors = array();
|
||||
$this->links = array();
|
||||
$this->entries = array();
|
||||
$this->addNamespace('xmlns', 'http://www.w3.org/2005/Atom');
|
||||
|
@ -93,6 +95,64 @@ class Atom10Feed extends XMLStringer
|
|||
$this->namespaces = array_merge($this->namespaces, $ns);
|
||||
}
|
||||
|
||||
function addAuthor($name, $uri = null, $email = null)
|
||||
{
|
||||
$xs = new XMLStringer(true);
|
||||
|
||||
$xs->elementStart('author');
|
||||
|
||||
if (!empty($name)) {
|
||||
$xs->element('name', null, $name);
|
||||
} else {
|
||||
throw new Atom10FeedException(
|
||||
'author element must contain a name element.'
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_null($uri)) {
|
||||
$xs->element('uri', null, $uri);
|
||||
}
|
||||
|
||||
if (!is_null(email)) {
|
||||
$xs->element('email', null, $email);
|
||||
}
|
||||
|
||||
$xs->elementEnd('author');
|
||||
|
||||
array_push($this->authors, $xs->getString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an Author to the feed via raw XML string
|
||||
*
|
||||
* @param string $xmlAuthor An XML string representation author
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function addAuthorRaw($xmlAuthor)
|
||||
{
|
||||
array_push($this->authors, $xmlAuthor);
|
||||
}
|
||||
|
||||
function renderAuthors()
|
||||
{
|
||||
foreach ($this->authors as $author) {
|
||||
$this->raw($author);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a activity feed subject via raw XML string
|
||||
*
|
||||
* @param string $xmlSubject An XML string representation of the subject
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function setActivitySubject($xmlSubject)
|
||||
{
|
||||
$this->subject = $xmlSubject;
|
||||
}
|
||||
|
||||
function getNamespaces()
|
||||
{
|
||||
return $this->namespaces;
|
||||
|
@ -136,9 +196,9 @@ class Atom10Feed extends XMLStringer
|
|||
}
|
||||
}
|
||||
|
||||
function addEntryRaw($entry)
|
||||
function addEntryRaw($xmlEntry)
|
||||
{
|
||||
array_push($this->entries, $entry);
|
||||
array_push($this->entries, $xmlEntry);
|
||||
}
|
||||
|
||||
function addEntry($entry)
|
||||
|
@ -164,6 +224,12 @@ class Atom10Feed extends XMLStringer
|
|||
$this->validate();
|
||||
|
||||
$this->initFeed();
|
||||
$this->renderAuthors();
|
||||
|
||||
if (!empty($this->subject)) {
|
||||
$this->raw($this->subject);
|
||||
}
|
||||
|
||||
$this->renderEntries();
|
||||
$this->endFeed();
|
||||
|
||||
|
|
|
@ -367,7 +367,8 @@ function common_current_user()
|
|||
|
||||
if ($_cur === false) {
|
||||
|
||||
if (isset($_REQUEST[session_name()]) || (isset($_SESSION['userid']) && $_SESSION['userid'])) {
|
||||
if (isset($_COOKIE[session_name()]) || isset($_GET[session_name()])
|
||||
|| (isset($_SESSION['userid']) && $_SESSION['userid'])) {
|
||||
common_ensure_session();
|
||||
$id = isset($_SESSION['userid']) ? $_SESSION['userid'] : false;
|
||||
if ($id) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user