sforkowany z mirror/friendica
New function "queryValue"
rodzic
cb647b5b6c
commit
20b25a1acd
|
@ -1766,15 +1766,15 @@ class DFRN
|
||||||
|
|
||||||
$msg = [];
|
$msg = [];
|
||||||
$msg["uid"] = $importer["importer_uid"];
|
$msg["uid"] = $importer["importer_uid"];
|
||||||
$msg["from-name"] = $xpath->query("dfrn:sender/dfrn:name/text()", $mail)->item(0)->nodeValue;
|
$msg["from-name"] = XML::queryValue($xpath, "dfrn:sender/dfrn:name/text()", $mail);
|
||||||
$msg["from-url"] = $xpath->query("dfrn:sender/dfrn:uri/text()", $mail)->item(0)->nodeValue;
|
$msg["from-url"] = XML::queryValue($xpath, "dfrn:sender/dfrn:uri/text()", $mail);
|
||||||
$msg["from-photo"] = $xpath->query("dfrn:sender/dfrn:avatar/text()", $mail)->item(0)->nodeValue;
|
$msg["from-photo"] = XML::queryValue($xpath, "dfrn:sender/dfrn:avatar/text()", $mail);
|
||||||
$msg["contact-id"] = $importer["id"];
|
$msg["contact-id"] = $importer["id"];
|
||||||
$msg["uri"] = $xpath->query("dfrn:id/text()", $mail)->item(0)->nodeValue;
|
$msg["uri"] = XML::queryValue($xpath, "dfrn:id/text()", $mail);
|
||||||
$msg["parent-uri"] = $xpath->query("dfrn:in-reply-to/text()", $mail)->item(0)->nodeValue;
|
$msg["parent-uri"] = XML::queryValue($xpath, "dfrn:in-reply-to/text()", $mail);
|
||||||
$msg["created"] = DateTimeFormat::utc($xpath->query("dfrn:sentdate/text()", $mail)->item(0)->nodeValue);
|
$msg["created"] = DateTimeFormat::utc(XML::queryValue($xpath, "dfrn:sentdate/text()", $mail));
|
||||||
$msg["title"] = $xpath->query("dfrn:subject/text()", $mail)->item(0)->nodeValue;
|
$msg["title"] = XML::queryValue($xpath, "dfrn:subject/text()", $mail);
|
||||||
$msg["body"] = $xpath->query("dfrn:content/text()", $mail)->item(0)->nodeValue;
|
$msg["body"] = XML::queryValue($xpath, "dfrn:content/text()", $mail);
|
||||||
|
|
||||||
Mail::insert($msg);
|
Mail::insert($msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -488,6 +488,15 @@ class XML
|
||||||
return $first_item->attributes;
|
return $first_item->attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function queryValue($xpath, $search, $context)
|
||||||
|
{
|
||||||
|
$result = $xpath->query($search, $context)->item(0)->nodeValue;
|
||||||
|
if (!is_object($result)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return $result->nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* escape text ($str) for XML transport
|
* escape text ($str) for XML transport
|
||||||
*
|
*
|
||||||
|
|
Ładowanie…
Reference in New Issue