X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=lib%2Factivity.php;h=2cb80f9e1a26bba80f94c19822b41f4db67fc0b1;hb=c4ee2b20bee567e1c41888bb46bfc8d5f98e8951;hp=b2015321386ae454df53ce32587c3d26f8fe2e0c;hpb=6781f95c733ed4d678fc4c09926efe195e590359;p=quix0rs-gnu-social.git diff --git a/lib/activity.php b/lib/activity.php index b201532138..2cb80f9e1a 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -344,16 +344,18 @@ class ActivityUtils static function getLink(DOMNode $element, $rel, $type=null) { - $links = $element->getElementsByTagnameNS(self::ATOM, self::LINK); + $els = $element->childNodes; - foreach ($links as $link) { + foreach ($els as $link) { + if ($link->localName == self::LINK && $link->namespaceURI == self::ATOM) { - $linkRel = $link->getAttribute(self::REL); - $linkType = $link->getAttribute(self::TYPE); + $linkRel = $link->getAttribute(self::REL); + $linkType = $link->getAttribute(self::TYPE); - if ($linkRel == $rel && - (is_null($type) || $linkType == $type)) { - return $link->getAttribute(self::HREF); + if ($linkRel == $rel && + (is_null($type) || $linkType == $type)) { + return $link->getAttribute(self::HREF); + } } } @@ -362,17 +364,19 @@ class ActivityUtils static function getLinks(DOMNode $element, $rel, $type=null) { - $links = $element->getElementsByTagnameNS(self::ATOM, self::LINK); + $els = $element->childNodes; $out = array(); - foreach ($links as $link) { + foreach ($els as $link) { + if ($link->localName == self::LINK && $link->namespaceURI == self::ATOM) { - $linkRel = $link->getAttribute(self::REL); - $linkType = $link->getAttribute(self::TYPE); + $linkRel = $link->getAttribute(self::REL); + $linkType = $link->getAttribute(self::TYPE); - if ($linkRel == $rel && - (is_null($type) || $linkType == $type)) { - $out[] = $link; + if ($linkRel == $rel && + (is_null($type) || $linkType == $type)) { + $out[] = $link; + } } } @@ -1044,6 +1048,7 @@ class Activity public $id; // ID of the activity public $title; // title of the activity public $categories = array(); // list of AtomCategory objects + public $enclosures = array(); // list of enclosure URL references /** * Turns a regular old Atom into a magical activity @@ -1059,6 +1064,18 @@ class Activity } $this->entry = $entry; + + // @fixme Don't send in a DOMDocument + if ($feed instanceof DOMDocument) { + common_log( + LOG_WARNING, + 'Activity::__construct() - ' + . 'DOMDocument passed in for feed by mistake. ' + . "Expecting a 'feed' DOMElement." + ); + $feed = $feed->getElementsByTagName('feed')->item(0); + } + $this->feed = $feed; $pubEl = $this->_child($entry, self::PUBLISHED, self::ATOM); @@ -1140,6 +1157,10 @@ class Activity $this->categories[] = new AtomCategory($catEl); } } + + foreach (ActivityUtils::getLinks($entry, 'enclosure') as $link) { + $this->enclosures[] = $link->getAttribute('href'); + } } /**