summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/Nonce.php15
-rw-r--r--classes/Notice.php52
-rw-r--r--classes/Profile.php85
-rw-r--r--classes/User_group.php33
-rw-r--r--classes/statusnet.links.ini7
5 files changed, 182 insertions, 10 deletions
diff --git a/classes/Nonce.php b/classes/Nonce.php
index 486a65a3c..2f8ab00b5 100644
--- a/classes/Nonce.php
+++ b/classes/Nonce.php
@@ -22,4 +22,19 @@ class Nonce extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
+
+ /**
+ * Compatibility hack for PHP 5.3
+ *
+ * The statusnet.links.ini entry cannot be read because "," is no longer
+ * allowed in key names when read by parse_ini_file().
+ *
+ * @return array
+ * @access public
+ */
+ function links()
+ {
+ return array('consumer_key,token' => 'token:consumer_key,token');
+ }
+
}
diff --git a/classes/Notice.php b/classes/Notice.php
index 247440f29..73b22d58a 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -957,7 +957,10 @@ class Notice extends Memcached_DataObject
if ($namespace) {
$attrs = array('xmlns' => 'http://www.w3.org/2005/Atom',
- 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0');
+ 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0',
+ 'xmlns:georss' => 'http://www.georss.org/georss',
+ 'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
+ 'xmlns:ostatus' => 'http://ostatus.org/schema/1.0');
} else {
$attrs = array();
}
@@ -983,11 +986,6 @@ class Notice extends Memcached_DataObject
$xs->element('icon', null, $profile->avatarUrl(AVATAR_PROFILE_SIZE));
}
- $xs->elementStart('author');
- $xs->element('name', null, $profile->nickname);
- $xs->element('uri', null, $profile->profileurl);
- $xs->elementEnd('author');
-
if ($source) {
$xs->elementEnd('source');
}
@@ -995,6 +993,9 @@ class Notice extends Memcached_DataObject
$xs->element('title', null, $this->content);
$xs->element('summary', null, $this->content);
+ $xs->raw($profile->asAtomAuthor());
+ $xs->raw($profile->asActivityActor());
+
$xs->element('link', array('rel' => 'alternate',
'href' => $this->bestUrl()));
@@ -1014,6 +1015,43 @@ class Notice extends Memcached_DataObject
}
}
+ if (!empty($this->conversation)
+ && $this->conversation != $this->id) {
+ $xs->element(
+ 'link', array(
+ 'rel' => 'ostatus:conversation',
+ 'href' => common_local_url(
+ 'conversation',
+ array('id' => $this->conversation)
+ )
+ )
+ );
+ }
+
+ $reply_ids = $this->getReplies();
+
+ foreach ($reply_ids as $id) {
+ $profile = Profile::staticGet('id', $id);
+ if (!empty($profile)) {
+ $xs->element(
+ 'link', array(
+ 'rel' => 'ostatus:attention',
+ 'href' => $profile->getAcctUri()
+ )
+ );
+ }
+ }
+
+ if (!empty($this->repeat_of)) {
+ $repeat = Notice::staticGet('id', $this->repeat_of);
+ if (!empty($repeat)) {
+ $xs->element(
+ 'ostatus:forward',
+ array('ref' => $repeat->uri, 'href' => $repeat->bestUrl())
+ );
+ }
+ }
+
$xs->element('content', array('type' => 'html'), $this->rendered);
$tag = new Notice_tag();
@@ -1041,9 +1079,7 @@ class Notice extends Memcached_DataObject
}
if (!empty($this->lat) && !empty($this->lon)) {
- $xs->elementStart('geo', array('xmlns:georss' => 'http://www.georss.org/georss'));
$xs->element('georss:point', null, $this->lat . ' ' . $this->lon);
- $xs->elementEnd('geo');
}
$xs->elementEnd('entry');
diff --git a/classes/Profile.php b/classes/Profile.php
index feabc2508..ab05bb854 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -754,4 +754,89 @@ class Profile extends Memcached_DataObject
return !empty($notice);
}
+
+ /**
+ * Returns an XML string fragment with limited profile information
+ * as an Atom <author> element.
+ *
+ * Assumes that Atom has been previously set up as the base namespace.
+ *
+ * @return string
+ */
+ function asAtomAuthor()
+ {
+ $xs = new XMLStringer(true);
+
+ $xs->elementStart('author');
+ $xs->element('name', null, $this->nickname);
+ $xs->element('uri', null, $this->profileurl);
+ $xs->elementEnd('author');
+
+ return $xs->getString();
+ }
+
+ /**
+ * Returns an XML string fragment with profile information as an
+ * Activity Streams <activity:actor> 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:' . $element);
+ $xs->element(
+ 'activity:object-type',
+ null,
+ 'http://activitystrea.ms/schema/1.0/person'
+ );
+ $xs->element(
+ 'id',
+ null,
+ common_local_url(
+ 'userbyid',
+ array('id' => $this->id)
+ )
+ );
+ $xs->element('title', null, $this->getBestName());
+
+ $avatar = $this->getAvatar(AVATAR_PROFILE_SIZE);
+
+ $xs->element(
+ 'link', array(
+ 'type' => empty($avatar) ? 'image/png' : $avatar->mediatype,
+ 'href' => empty($avatar)
+ ? Avatar::defaultImage(AVATAR_PROFILE_SIZE)
+ : $avatar->displayUrl()
+ ),
+ ''
+ );
+
+ $xs->elementEnd('activity:' . $element);
+
+ return $xs->getString();
+ }
+
+ function getAcctUri()
+ {
+ return $this->nickname . '@' . common_config('site', 'server');
+ }
+
}
diff --git a/classes/User_group.php b/classes/User_group.php
index 1fbb50a6e..379e6b721 100644
--- a/classes/User_group.php
+++ b/classes/User_group.php
@@ -355,6 +355,39 @@ class User_group extends Memcached_DataObject
return $xs->getString();
}
+ function asAtomAuthor()
+ {
+ $xs = new XMLStringer(true);
+
+ $xs->elementStart('author');
+ $xs->element('name', null, $this->nickname);
+ $xs->element('uri', null, $this->permalink());
+ $xs->elementEnd('author');
+
+ return $xs->getString();
+ }
+
+ function asActivitySubject()
+ {
+ $xs = new XMLStringer(true);
+
+ $xs->elementStart('activity:subject');
+ $xs->element('activity:object', null, 'http://activitystrea.ms/schema/1.0/group');
+ $xs->element('id', null, $this->permalink());
+ $xs->element('title', null, $this->getBestName());
+ $xs->element(
+ 'link', array(
+ 'rel' => 'avatar',
+ 'href' => empty($this->homepage_logo)
+ ? User_group::defaultLogo(AVATAR_PROFILE_SIZE)
+ : $this->homepage_logo
+ )
+ );
+ $xs->elementEnd('activity:subject');
+
+ return $xs->getString();
+ }
+
static function register($fields) {
// MAGICALLY put fields into current scope
diff --git a/classes/statusnet.links.ini b/classes/statusnet.links.ini
index 7f233e676..b9dd5af0c 100644
--- a/classes/statusnet.links.ini
+++ b/classes/statusnet.links.ini
@@ -19,8 +19,11 @@ profile_id = profile:id
[token]
consumer_key = consumer:consumer_key
-[nonce]
-consumer_key,token = token:consumer_key,token
+; Compatibility hack for PHP 5.3
+; This entry has been moved to the class definition, as commas are no longer
+; considered valid in keys, causing parse_ini_file() to reject the whole file.
+;[nonce]
+;consumer_key,token = token:consumer_key,token
[confirm_address]
user_id = user:id