X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fatomnoticefeed.php;h=6ed803ce4ebb35a0350f669b26fc098b896a3585;hb=4c4dc6571231b188740c106a1f558b10388004cc;hp=34ed44b2ed5294d747af5e811942b545d538c821;hpb=32084e33a266797b306158df29e48f057651b410;p=quix0rs-gnu-social.git diff --git a/lib/atomnoticefeed.php b/lib/atomnoticefeed.php index 34ed44b2ed..6ed803ce4e 100644 --- a/lib/atomnoticefeed.php +++ b/lib/atomnoticefeed.php @@ -2,7 +2,7 @@ /** * StatusNet, the distributed open-source microblogging tool * - * Class for building and Atom feed from a collection of notices + * Class for building an Atom feed from a collection of notices * * PHP version 5 * @@ -44,31 +44,59 @@ if (!defined('STATUSNET')) */ class AtomNoticeFeed extends Atom10Feed { - function __construct($indent = true) { + var $cur; + + /** + * Constructor - adds a bunch of XML namespaces we need in our + * notice-specific Atom feeds, and allows setting the current + * authenticated user (useful for API methods). + * + * @param User $cur the current authenticated user (optional) + * @param boolean $indent Whether to indent XML output + * + */ + function __construct($cur = null, $indent = true) { parent::__construct($indent); + $this->cur = $cur; + // Feeds containing notice info use these namespaces $this->addNamespace( - 'xmlns:thr', + 'thr', 'http://purl.org/syndication/thread/1.0' ); $this->addNamespace( - 'xmlns:georss', + 'georss', 'http://www.georss.org/georss' ); $this->addNamespace( - 'xmlns:activity', + 'activity', 'http://activitystrea.ms/spec/1.0/' ); + $this->addNamespace( + 'media', + 'http://purl.org/syndication/atommedia' + ); + + $this->addNamespace( + 'poco', + 'http://portablecontacts.net/spec/1.0' + ); + // XXX: What should the uri be? $this->addNamespace( - 'xmlns:ostatus', + 'ostatus', 'http://ostatus.org/schema/1.0' ); + + $this->addNamespace( + 'statusnet', + 'http://status.net/schema/api/1/' + ); } /** @@ -97,7 +125,21 @@ class AtomNoticeFeed extends Atom10Feed */ function addEntryFromNotice($notice) { - $this->addEntryRaw($notice->asAtomEntry()); + $source = $this->showSource(); + $author = $this->showAuthor(); + + $cur = empty($this->cur) ? common_current_user() : $this->cur; + + $this->addEntryRaw($notice->asAtomEntry(false, $source, $author, $cur)); } + function showSource() + { + return true; + } + + function showAuthor() + { + return true; + } }