summaryrefslogtreecommitdiff
path: root/plugins/OStatus/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-02-20 19:58:20 -0500
committerEvan Prodromou <evan@status.net>2010-02-20 19:58:20 -0500
commit96c6019638f6407b38fbc5a45485a3797af47adb (patch)
tree68115f1d30264b8c7ba3f4403d2fd2f19daf6c8c /plugins/OStatus/lib
parentf3b08461bd476d368d444d48025709fb6a111b7d (diff)
Add support for favor and disfavor notification
Added support for favoring and disfavoring in OStatusPlugin. Needed to represent the Notice as an activity:object, so added some code for that in lib/activity.php. Also, made some small changes to OStatusPlugin so it handled having a non-default argument $object correctly.
Diffstat (limited to 'plugins/OStatus/lib')
-rw-r--r--plugins/OStatus/lib/activity.php55
1 files changed, 53 insertions, 2 deletions
diff --git a/plugins/OStatus/lib/activity.php b/plugins/OStatus/lib/activity.php
index 5bc8f78e5..6d15f85b0 100644
--- a/plugins/OStatus/lib/activity.php
+++ b/plugins/OStatus/lib/activity.php
@@ -199,7 +199,7 @@ class ActivityObject
public $link;
public $source;
- /**
+ /**
* Constructor
*
* This probably needs to be refactored
@@ -209,8 +209,12 @@ class ActivityObject
* @param DOMElement $element DOM thing to turn into an Activity thing
*/
- function __construct($element)
+ function __construct($element = null)
{
+ if (empty($element)) {
+ return;
+ }
+
$this->element = $element;
if ($element->tagName == 'author') {
@@ -279,6 +283,53 @@ class ActivityObject
}
}
}
+
+ static fromNotice($notice)
+ {
+ $object = new ActivityObject();
+
+ $object->type = ActivityObject::NOTE;
+
+ $object->id = $notice->uri;
+ $object->title = $notice->content;
+ $object->content = $notice->rendered;
+ $object->link = $notice->bestUrl();
+
+ return $object;
+ }
+
+ function asString($tag='activity:object')
+ {
+ $xs = new XMLStringer(true);
+
+ $xs->elementStart($tag);
+
+ $xs->element('activity:object-type', null, $this->type);
+
+ $xs->element(self::ID, null, $this->id);
+
+ if (!empty($this->title)) {
+ $xs->element(self::TITLE, null, $this->title);
+ }
+
+ if (!empty($this->summary)) {
+ $xs->element(self::SUMMARY, null, $this->summary);
+ }
+
+ if (!empty($this->content)) {
+ // XXX: assuming HTML content here
+ $xs->element(self::CONTENT, array('type' => 'html'), $this->content);
+ }
+
+ if (!empty($this->link)) {
+ $xs->element('link', array('rel' => 'alternate', 'type' => 'text/html'),
+ $this->content);
+ }
+
+ $xs->elementEnd($tag);
+
+ return $xs->getString();
+ }
}
/**