X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Factivityobject.php;h=597792ffdeb2528852dd7a8e76b21c6928b01e51;hb=586fb5a5175d7a10f5f78dd026434e48202e5451;hp=9a6218de3af9e954a97d7cd92a0e509c2f88fd24;hpb=d32fef60394dbacca2f1dec24fd55043e328d0d1;p=quix0rs-gnu-social.git diff --git a/lib/activityobject.php b/lib/activityobject.php index 9a6218de3a..597792ffde 100644 --- a/lib/activityobject.php +++ b/lib/activityobject.php @@ -28,9 +28,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } require_once(INSTALLDIR.'/lib/activitystreamjsondocument.php'); @@ -102,6 +100,7 @@ class ActivityObject public $content; public $owner; public $link; + public $selfLink; // think APP (Atom Publishing Protocol) public $source; public $avatarLinks = array(); public $geopoint; @@ -263,17 +262,38 @@ class ActivityObject $this->source = $this->_getSource($element); $this->link = ActivityUtils::getPermalink($element); + $this->selfLink = ActivityUtils::getSelfLink($element); $this->id = $this->_childContent($element, self::ID); if (empty($this->id) && !empty($this->link)) { // fallback if there's no ID $this->id = $this->link; } + + $els = $element->childNodes; + $out = array(); + + for ($i = 0; $i < $els->length; $i++) { + $link = $els->item($i); + if ($link->localName == ActivityUtils::LINK && $link->namespaceURI == ActivityUtils::ATOM) { + $attrs = array(); + foreach ($link->attributes as $attrName=>$attrNode) { + $attrs[$attrName] = $attrNode->nodeValue; + } + $this->extra[] = [$link->localName, + $attrs, + $link->nodeValue]; + } + } } // @todo FIXME: rationalize with Activity::_fromRssItem() private function _fromRssItem($item) { + if (empty($this->type)) { + $this->type = ActivityObject::NOTE; + } + $this->title = ActivityUtils::childContent($item, ActivityObject::TITLE, Activity::RSS); $contentEl = ActivityUtils::child($item, ActivityUtils::CONTENT, Activity::CONTENTNS); @@ -294,7 +314,7 @@ class ActivityObject if (!empty($guidEl)) { $this->id = $guidEl->textContent; - if ($guidEl->hasAttribute('isPermaLink')) { + if ($guidEl->hasAttribute('isPermaLink') && $guidEl->getAttribute('isPermaLink') != 'false') { // overwrites $this->link = $this->id; } @@ -487,7 +507,7 @@ class ActivityObject $object->type = self::mimeTypeToObjectType($file->mimetype); $object->id = TagURI::mint(sprintf("file:%d", $file->id)); - $object->link = common_local_url('attachment', array('attachment' => $file->id)); + $object->link = $file->getAttachmentUrl(); if ($file->title) { $object->title = $file->title; @@ -508,11 +528,11 @@ class ActivityObject switch (self::canonicalType($object->type)) { case 'image': - $object->largerImage = $file->url; + $object->largerImage = $file->getUrl(); break; case 'video': case 'audio': - $object->stream = $file->url; + $object->stream = $file->getUrl(); break; } @@ -647,6 +667,18 @@ class ActivityObject ); } + if (!empty($this->selfLink)) { + $xo->element( + 'link', + array( + 'rel' => 'self', + 'type' => 'application/atom+xml', + 'href' => $this->selfLink + ), + null + ); + } + if(!empty($this->owner)) { $owner = $this->owner->asActivityNoun(self::AUTHOR); $xo->raw($owner); @@ -857,7 +889,7 @@ class ActivityObject if (is_string($this->thumbnail)) { $object['image'] = array('url' => $this->thumbnail); } else { - $object['image'] = array('url' => $this->thumbnail->url); + $object['image'] = array('url' => $this->thumbnail->getUrl()); if ($this->thumbnail->width) { $object['image']['width'] = $this->thumbnail->width; }