summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-02-22 17:10:50 -0800
committerZach Copley <zach@status.net>2010-02-22 17:10:50 -0800
commit6a711c6cdc5d1e1b1a64e5858b12e6964a0abe9c (patch)
treef4ee85621ed4b534f2bb6d7e2ac420ca2fff9cae /classes
parenta3e800e67c8ced785a1ca6c2628cc5116ef44730 (diff)
Move ActivityObject and related stuff to core
Diffstat (limited to 'classes')
-rw-r--r--classes/Notice.php21
-rw-r--r--classes/Profile.php78
2 files changed, 4 insertions, 95 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index a12839d72..ba8646f68 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -1119,25 +1119,8 @@ class Notice extends Memcached_DataObject
*/
function asActivityNoun($element)
{
- $xs = new XMLStringer(true);
-
- $xs->elementStart('activity:' . $element);
- $xs->element('activity:object-type',
- null,
- 'http://activitystrea.ms/schema/1.0/note');
- $xs->element('id',
- null,
- $this->uri);
- $xs->element('content',
- array('type' => 'text/html'),
- $this->rendered);
- $xs->element('link',
- array('type' => 'text/html',
- 'rel' => 'alternate',
- 'href' => $this->bestUrl()));
- $xs->elementEnd('activity:' . $element);
-
- return $xs->getString();
+ $noun = ActivityObject::fromNotice($this);
+ return $noun->asString('activity:' . $element);
}
function bestUrl()
diff --git a/classes/Profile.php b/classes/Profile.php
index 7fb2b87bc..78223b34a 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -801,82 +801,8 @@ class Profile extends Memcached_DataObject
*/
function asActivityNoun($element)
{
- $xs = new XMLStringer(true);
-
- $xs->elementStart('activity:' . $element);
- $xs->element(
- 'activity:object-type',
- null,
- 'http://activitystrea.ms/schema/1.0/person'
- );
- $xs->element(
- 'id',
- null,
- $this->getUri()
- );
-
- // title should contain fullname
- $xs->element('title', null, $this->getBestName());
-
- $xs->element('link', array('rel' => 'alternate',
- 'type' => 'text/html'),
- $this->profileurl);
-
- $xs->element('poco:preferredUsername', null, $this->nickname);
-
- // Portable Contacts stuff
-
- if (isset($this->bio)) {
-
- // XXX: Possible to use OpenSocial's aboutMe?
-
- $xs->element('poco:note', null, $this->bio);
- }
-
- if (isset($this->homepage)) {
-
- $xs->elementStart('poco:urls');
- $xs->element('poco:value', null, $this->homepage);
- $xs->element('poco:type', null, 'homepage');
- $xs->element('poco:primary', null, 'true');
- $xs->elementEnd('poco:urls');
- }
-
- if (isset($this->location)) {
- $xs->elementStart('poco:address');
- $xs->element('poco:formatted', null, $this->location);
- $xs->elementEnd('poco:address');
- }
-
- if (isset($this->lat) && isset($this->lon)) {
- $this->element(
- 'georss:point',
- null,
- (float)$this->lat . ' ' . (float)$this->lon
- );
- }
-
- // XXX: Should we send all avatar sizes we have? I think
- // cliqset does -Z
-
- $avatar = $this->getAvatar(AVATAR_PROFILE_SIZE);
-
- $xs->element(
- 'link', array(
- 'type' => empty($avatar) ? 'image/png' : $avatar->mediatype,
- 'rel' => 'avatar',
- 'href' => empty($avatar)
- ? Avatar::defaultImage(AVATAR_PROFILE_SIZE)
- : $avatar->displayUrl()
- ),
- ''
- );
-
- $xs->elementEnd('activity:' . $element);
-
- // XXX: Add people tags with <poco:tags> plural?
-
- return $xs->getString();
+ $noun = ActivityObject::fromProfile($this);
+ return $noun->asString('activity:' . $element);
}
/**