3 * StatusNet, the distributed open-source microblogging tool
5 * Class for building an Atom feed from a collection of notices
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Zach Copley <zach@status.net>
25 * @copyright 2010 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET'))
36 * Class for creating a feed that represents a collection of notices. Builds the
37 * feed in memory. Get the feed as a string with AtomNoticeFeed::getString().
41 * @author Zach Copley <zach@status.net>
42 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
43 * @link http://status.net/
45 class AtomNoticeFeed extends Atom10Feed
50 * Constructor - adds a bunch of XML namespaces we need in our
51 * notice-specific Atom feeds, and allows setting the current
52 * authenticated user (useful for API methods).
54 * @param User $cur the current authenticated user (optional)
55 * @param boolean $indent Whether to indent XML output
58 function __construct($cur = null, $indent = true) {
59 parent::__construct($indent);
63 // Feeds containing notice info use these namespaces
67 'http://purl.org/syndication/thread/1.0'
72 'http://www.georss.org/georss'
77 'http://activitystrea.ms/spec/1.0/'
82 'http://purl.org/syndication/atommedia'
87 'http://portablecontacts.net/spec/1.0'
90 // XXX: What should the uri be?
93 'http://ostatus.org/schema/1.0'
98 'http://status.net/schema/api/1/'
103 * Add more than one Notice to the feed
105 * @param mixed $notices an array of Notice objects or handle
108 function addEntryFromNotices($notices)
110 if (is_array($notices)) {
111 foreach ($notices as $notice) {
112 $this->addEntryFromNotice($notice);
115 while ($notices->fetch()) {
116 $this->addEntryFromNotice($notices);
122 * Add a single Notice to the feed
124 * @param Notice $notice a Notice to add
126 function addEntryFromNotice($notice)
128 $source = $this->showSource();
129 $author = $this->showAuthor();
131 $cur = empty($this->cur) ? common_current_user() : $this->cur;
133 $this->addEntryRaw($notice->asAtomEntry(false, $source, $author, $cur));
136 function showSource()
141 function showAuthor()