forked from GNUsocial/gnu-social
Try to get only immediate children (again)
This commit is contained in:
parent
c86f0ffa2f
commit
383f14c781
|
@ -171,15 +171,12 @@ class Activity
|
||||||
// XXX: do other implied stuff here
|
// XXX: do other implied stuff here
|
||||||
}
|
}
|
||||||
|
|
||||||
$objectEls = $entry->getElementsByTagNameNS(self::SPEC, self::OBJECT);
|
// get immediate object children
|
||||||
|
|
||||||
if ($objectEls->length > 0) {
|
$objectEls = ActivityUtils::children($entry, self::OBJECT, self::SPEC);
|
||||||
for ($i = 0; $i < $objectEls->length; $i++) {
|
|
||||||
$objectEl = $objectEls->item($i);
|
if (count($objectEls) > 0) {
|
||||||
// Only immediate children (don't slurp embedded activities' objects!)
|
foreach ($objectEls as $objectEl) {
|
||||||
if ($objectEl->parentNode != $entry) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Special case for embedded activities
|
// Special case for embedded activities
|
||||||
$objectType = ActivityUtils::childContent($objectEl, self::OBJECTTYPE, self::SPEC);
|
$objectType = ActivityUtils::childContent($objectEl, self::OBJECTTYPE, self::SPEC);
|
||||||
if (!empty($objectType) && $objectType == ActivityObject::ACTIVITY) {
|
if (!empty($objectType) && $objectType == ActivityObject::ACTIVITY) {
|
||||||
|
|
|
@ -145,6 +145,34 @@ class ActivityUtils
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all immediate child elements with the given tag
|
||||||
|
*
|
||||||
|
* @param DOMElement $element element to pick at
|
||||||
|
* @param string $tag tag to look for
|
||||||
|
* @param string $namespace Namespace to look under
|
||||||
|
*
|
||||||
|
* @return array found element or null
|
||||||
|
*/
|
||||||
|
|
||||||
|
static function children(DOMNode $element, $tag, $namespace=self::ATOM)
|
||||||
|
{
|
||||||
|
$results = array();
|
||||||
|
|
||||||
|
$els = $element->childNodes;
|
||||||
|
|
||||||
|
if (!empty($els) && $els->length > 0) {
|
||||||
|
for ($i = 0; $i < $els->length; $i++) {
|
||||||
|
$el = $els->item($i);
|
||||||
|
if ($el->localName == $tag && $el->namespaceURI == $namespace) {
|
||||||
|
$results[] = $el;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab the text content of a DOM element child of the current element
|
* Grab the text content of a DOM element child of the current element
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue