summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/atom10entry.php48
-rw-r--r--lib/atom10feed.php58
-rw-r--r--lib/atomnoticefeed.php55
3 files changed, 154 insertions, 7 deletions
diff --git a/lib/atom10entry.php b/lib/atom10entry.php
index 1b79ce7ad..5710c80fc 100644
--- a/lib/atom10entry.php
+++ b/lib/atom10entry.php
@@ -1,9 +1,51 @@
<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Class for building / manipulating an Atom entry in memory
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Feed
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @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 Atom10EntryException extends Exception
{
}
+/**
+ * Class for manipulating an Atom entry in memory. Get the entry as an XML
+ * string with Atom10Entry::getString().
+ *
+ * @category Feed
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
class Atom10Entry extends XMLStringer
{
private $namespaces;
@@ -39,6 +81,12 @@ class Atom10Entry extends XMLStringer
}
+ /**
+ * Check that all required elements have been set, etc.
+ * Throws an Atom10EntryException if something's missing.
+ *
+ * @return void
+ */
function validate
{
diff --git a/lib/atom10feed.php b/lib/atom10feed.php
index 01fc69072..a37f6521a 100644
--- a/lib/atom10feed.php
+++ b/lib/atom10feed.php
@@ -1,9 +1,51 @@
<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Class for building an Atom feed in memory
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Feed
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @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 Atom10FeedException extends Exception
{
}
+/**
+ * Class for building an Atom feed in memory. Get the finished doc
+ * as a string with Atom10Feed::getString().
+ *
+ * @category Feed
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
class Atom10Feed extends XMLStringer
{
public $xw;
@@ -23,12 +65,11 @@ class Atom10Feed extends XMLStringer
private $entries;
/**
- * undocumented function
+ * Constructor
*
- * @param array $entries an array of FeedItems
+ * @param boolean $indent flag to turn indenting on or off
*
* @return void
- *
*/
function __construct($indent = true) {
parent::__construct($indent);
@@ -38,6 +79,14 @@ class Atom10Feed extends XMLStringer
$this->addNamespace('xmlns', 'http://www.w3.org/2005/Atom');
}
+ /**
+ * Add another namespace to the feed
+ *
+ * @param string $namespace the namespace
+ * @param string $uri namspace uri
+ *
+ * @return void
+ */
function addNamespace($namespace, $uri)
{
$ns = array($namespace => $uri);
@@ -172,6 +221,3 @@ class Atom10Feed extends XMLStringer
}
}
-
-
-
diff --git a/lib/atomnoticefeed.php b/lib/atomnoticefeed.php
index ce87ec9e6..a626ab549 100644
--- a/lib/atomnoticefeed.php
+++ b/lib/atomnoticefeed.php
@@ -1,5 +1,47 @@
<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Class for building and Atom feed from a collection of notices
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Feed
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @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 creating a feed that represents a collection of notices. Builds the
+ * feed in memory. Get the feed as a string with AtomNoticeFeed::getString().
+ *
+ * @category Feed
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
class AtomNoticeFeed extends Atom10Feed
{
function __construct($indent = true) {
@@ -29,6 +71,12 @@ class AtomNoticeFeed extends Atom10Feed
);
}
+ /**
+ * Add more than one Notice to the feed
+ *
+ * @param mixed $notices an array of Notice objects or handle
+ *
+ */
function addEntryFromNotices($notices)
{
if (is_array($notices)) {
@@ -42,9 +90,14 @@ class AtomNoticeFeed extends Atom10Feed
}
}
+ /**
+ * Add a single Notice to the feed
+ *
+ * @param Notice $notice a Notice to add
+ */
function addEntryFromNotice($notice)
{
$this->addEntryRaw($notice->asAtomEntry());
}
-} \ No newline at end of file
+}