Function renamed

This commit is contained in:
Michael 2020-09-13 19:40:38 +00:00
parent 20b25a1acd
commit 34257e78ca
2 changed files with 17 additions and 11 deletions

View file

@ -1766,15 +1766,15 @@ class DFRN
$msg = [];
$msg["uid"] = $importer["importer_uid"];
$msg["from-name"] = XML::queryValue($xpath, "dfrn:sender/dfrn:name/text()", $mail);
$msg["from-url"] = XML::queryValue($xpath, "dfrn:sender/dfrn:uri/text()", $mail);
$msg["from-photo"] = XML::queryValue($xpath, "dfrn:sender/dfrn:avatar/text()", $mail);
$msg["from-name"] = XML::getFirstValue($xpath, "dfrn:sender/dfrn:name/text()", $mail);
$msg["from-url"] = XML::getFirstValue($xpath, "dfrn:sender/dfrn:uri/text()", $mail);
$msg["from-photo"] = XML::getFirstValue($xpath, "dfrn:sender/dfrn:avatar/text()", $mail);
$msg["contact-id"] = $importer["id"];
$msg["uri"] = XML::queryValue($xpath, "dfrn:id/text()", $mail);
$msg["parent-uri"] = XML::queryValue($xpath, "dfrn:in-reply-to/text()", $mail);
$msg["created"] = DateTimeFormat::utc(XML::queryValue($xpath, "dfrn:sentdate/text()", $mail));
$msg["title"] = XML::queryValue($xpath, "dfrn:subject/text()", $mail);
$msg["body"] = XML::queryValue($xpath, "dfrn:content/text()", $mail);
$msg["uri"] = XML::getFirstValue($xpath, "dfrn:id/text()", $mail);
$msg["parent-uri"] = XML::getFirstValue($xpath, "dfrn:in-reply-to/text()", $mail);
$msg["created"] = DateTimeFormat::utc(XML::getFirstValue($xpath, "dfrn:sentdate/text()", $mail));
$msg["title"] = XML::getFirstValue($xpath, "dfrn:subject/text()", $mail);
$msg["body"] = XML::getFirstValue($xpath, "dfrn:content/text()", $mail);
Mail::insert($msg);
}

View file

@ -488,13 +488,19 @@ class XML
return $first_item->attributes;
}
public static function queryValue($xpath, $search, $context)
public static function getFirstValue($xpath, $search, $context)
{
$result = $xpath->query($search, $context)->item(0)->nodeValue;
$result = $xpath->query($search, $context);
if (!is_object($result)) {
return '';
}
return $result->nodeValue;
$first_item = $result->item(0);
if (!is_object($first_item)) {
return '';
}
return $first_item->nodeValue;
}
/**