From f3a82e787c70e8cf749c79f22fe37ce6c9c9d4d3 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Feb 2010 19:00:35 -0800 Subject: Add OStatus PuSH hub and Salmon links back into user and group feeds --- lib/api.php | 1 - lib/atom10feed.php | 21 ++++++++------ lib/atomgroupnoticefeed.php | 67 +++++++++++++++++++++++++++++++++++++++++++++ lib/atomnoticefeed.php | 4 ++- lib/atomusernoticefeed.php | 66 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 149 insertions(+), 10 deletions(-) create mode 100644 lib/atomgroupnoticefeed.php create mode 100644 lib/atomusernoticefeed.php (limited to 'lib') diff --git a/lib/api.php b/lib/api.php index 494b595d1..22eef7436 100644 --- a/lib/api.php +++ b/lib/api.php @@ -1154,7 +1154,6 @@ class ApiAction extends Action $this->elementStart('feed', array('xmlns' => 'http://www.w3.org/2005/Atom', 'xml:lang' => 'en-US', 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0')); - Event::handle('StartApiAtom', array($this)); } function endTwitterAtom() diff --git a/lib/atom10feed.php b/lib/atom10feed.php index 806a9684b..14a3beb83 100644 --- a/lib/atom10feed.php +++ b/lib/atom10feed.php @@ -175,6 +175,8 @@ class Atom10Feed extends XMLStringer $this->element('updated', null, $this->updated); + $this->renderAuthors(); + $this->renderLinks(); } @@ -221,17 +223,20 @@ class Atom10Feed extends XMLStringer function getString() { - $this->validate(); + if (Event::handle('StartApiAtom', array($this))) { - $this->initFeed(); - $this->renderAuthors(); + $this->validate(); + $this->initFeed(); - if (!empty($this->subject)) { - $this->raw($this->subject); - } + if (!empty($this->subject)) { + $this->raw($this->subject); + } + + $this->renderEntries(); + $this->endFeed(); - $this->renderEntries(); - $this->endFeed(); + Event::handle('EndApiAtom', array($this)); + } return $this->xw->outputMemory(); } diff --git a/lib/atomgroupnoticefeed.php b/lib/atomgroupnoticefeed.php new file mode 100644 index 000000000..52ee4c7d6 --- /dev/null +++ b/lib/atomgroupnoticefeed.php @@ -0,0 +1,67 @@ +. + * + * @category Feed + * @package StatusNet + * @author Zach Copley + * @copyright 2010 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) +{ + exit(1); +} + +/** + * Class for group notice feeds. May contains a reference to the group. + * + * @category Feed + * @package StatusNet + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ +class AtomGroupNoticeFeed extends AtomNoticeFeed +{ + private $group; + + /** + * Constructor + * + * @param Group $group the group for the feed (optional) + * @param boolean $indent flag to turn indenting on or off + * + * @return void + */ + function __construct($group = null, $indent = true) { + parent::__construct($indent); + $this->group = $group; + } + + function getGroup() + { + return $this->group; + } + +} diff --git a/lib/atomnoticefeed.php b/lib/atomnoticefeed.php index 34ed44b2e..b7a60bde6 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 * @@ -101,3 +101,5 @@ class AtomNoticeFeed extends Atom10Feed } } + + diff --git a/lib/atomusernoticefeed.php b/lib/atomusernoticefeed.php new file mode 100644 index 000000000..9f224325c --- /dev/null +++ b/lib/atomusernoticefeed.php @@ -0,0 +1,66 @@ +. + * + * @category Feed + * @package StatusNet + * @author Zach Copley + * @copyright 2010 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) +{ + exit(1); +} + +/** + * Class for user notice feeds. May contain a reference to the user. + * + * @category Feed + * @package StatusNet + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ +class AtomUserNoticeFeed extends AtomNoticeFeed +{ + private $user; + + /** + * Constructor + * + * @param User $user the user for the feed (optional) + * @param boolean $indent flag to turn indenting on or off + * + * @return void + */ + function __construct($user = null, $indent = true) { + parent::__construct($indent); + $this->user = $user; + } + + function getUser() + { + return $this->user; + } +} -- cgit v1.2.3-54-g00ecf