From b39047d95b447251de75d15b986017286aca05e0 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 12 Feb 2010 18:54:48 +0000 Subject: OStatus: prep work for sending notifications on sub/unsub/join/leave/favorite/unfavorite via Salmon; needs to be completed and hooked up once feed gen is fixed. --- classes/Profile.php | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'classes/Profile.php') diff --git a/classes/Profile.php b/classes/Profile.php index 3e5150c18..ab05bb854 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -755,6 +755,14 @@ class Profile extends Memcached_DataObject return !empty($notice); } + /** + * Returns an XML string fragment with limited profile information + * as an Atom element. + * + * Assumes that Atom has been previously set up as the base namespace. + * + * @return string + */ function asAtomAuthor() { $xs = new XMLStringer(true); @@ -767,11 +775,33 @@ class Profile extends Memcached_DataObject return $xs->getString(); } + /** + * Returns an XML string fragment with profile information as an + * Activity Streams element. + * + * Assumes that 'activity' namespace has been previously defined. + * + * @return string + */ function asActivityActor() + { + return $this->asActivityNoun('actor'); + } + + /** + * Returns an XML string fragment with profile information as an + * Activity Streams noun object with the given element type. + * + * Assumes that 'activity' namespace has been previously defined. + * + * @param string $element one of 'actor', 'subject', 'object', 'target' + * @return string + */ + function asActivityNoun($element) { $xs = new XMLStringer(true); - $xs->elementStart('activity:actor'); + $xs->elementStart('activity:' . $element); $xs->element( 'activity:object-type', null, @@ -799,7 +829,7 @@ class Profile extends Memcached_DataObject '' ); - $xs->elementEnd('activity:actor'); + $xs->elementEnd('activity:' . $element); return $xs->getString(); } -- cgit v1.2.3