more curly braces added + dbm::is_result()
Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
parent
4adf74b06c
commit
92901d8626
|
@ -104,24 +104,29 @@ class ostatus {
|
||||||
// $contact["poll"] = $value;
|
// $contact["poll"] = $value;
|
||||||
|
|
||||||
$value = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue;
|
$value = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue;
|
||||||
if ($value != "")
|
if ($value != "") {
|
||||||
$contact["alias"] = $value;
|
$contact["alias"] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
$value = $xpath->evaluate('atom:author/poco:displayName/text()', $context)->item(0)->nodeValue;
|
$value = $xpath->evaluate('atom:author/poco:displayName/text()', $context)->item(0)->nodeValue;
|
||||||
if ($value != "")
|
if ($value != "") {
|
||||||
$contact["name"] = $value;
|
$contact["name"] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
$value = $xpath->evaluate('atom:author/poco:preferredUsername/text()', $context)->item(0)->nodeValue;
|
$value = $xpath->evaluate('atom:author/poco:preferredUsername/text()', $context)->item(0)->nodeValue;
|
||||||
if ($value != "")
|
if ($value != "") {
|
||||||
$contact["nick"] = $value;
|
$contact["nick"] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
$value = $xpath->evaluate('atom:author/poco:note/text()', $context)->item(0)->nodeValue;
|
$value = $xpath->evaluate('atom:author/poco:note/text()', $context)->item(0)->nodeValue;
|
||||||
if ($value != "")
|
if ($value != "") {
|
||||||
$contact["about"] = html2bbcode($value);
|
$contact["about"] = html2bbcode($value);
|
||||||
|
}
|
||||||
|
|
||||||
$value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()', $context)->item(0)->nodeValue;
|
$value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()', $context)->item(0)->nodeValue;
|
||||||
if ($value != "")
|
if ($value != "") {
|
||||||
$contact["location"] = $value;
|
$contact["location"] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
if (($contact["name"] != $r[0]["name"]) OR ($contact["nick"] != $r[0]["nick"]) OR ($contact["about"] != $r[0]["about"]) OR
|
if (($contact["name"] != $r[0]["name"]) OR ($contact["nick"] != $r[0]["nick"]) OR ($contact["about"] != $r[0]["about"]) OR
|
||||||
($contact["alias"] != $r[0]["alias"]) OR ($contact["location"] != $r[0]["location"])) {
|
($contact["alias"] != $r[0]["alias"]) OR ($contact["location"] != $r[0]["location"])) {
|
||||||
|
@ -179,8 +184,9 @@ class ostatus {
|
||||||
*/
|
*/
|
||||||
public static function salmon_author($xml, $importer) {
|
public static function salmon_author($xml, $importer) {
|
||||||
|
|
||||||
if ($xml == "")
|
if ($xml == "") {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$doc = new DOMDocument();
|
$doc = new DOMDocument();
|
||||||
@$doc->loadXML($xml);
|
@$doc->loadXML($xml);
|
||||||
|
@ -217,8 +223,9 @@ class ostatus {
|
||||||
|
|
||||||
logger("Import OStatus message", LOGGER_DEBUG);
|
logger("Import OStatus message", LOGGER_DEBUG);
|
||||||
|
|
||||||
if ($xml == "")
|
if ($xml == "") {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//$tempfile = tempnam(get_temppath(), "import");
|
//$tempfile = tempnam(get_temppath(), "import");
|
||||||
//file_put_contents($tempfile, $xml);
|
//file_put_contents($tempfile, $xml);
|
||||||
|
@ -238,12 +245,14 @@ class ostatus {
|
||||||
|
|
||||||
$gub = "";
|
$gub = "";
|
||||||
$hub_attributes = $xpath->query("/atom:feed/atom:link[@rel='hub']")->item(0)->attributes;
|
$hub_attributes = $xpath->query("/atom:feed/atom:link[@rel='hub']")->item(0)->attributes;
|
||||||
if (is_object($hub_attributes))
|
if (is_object($hub_attributes)) {
|
||||||
foreach($hub_attributes AS $hub_attribute)
|
foreach($hub_attributes AS $hub_attribute) {
|
||||||
if ($hub_attribute->name == "href") {
|
if ($hub_attribute->name == "href") {
|
||||||
$hub = $hub_attribute->textContent;
|
$hub = $hub_attribute->textContent;
|
||||||
logger("Found hub ".$hub, LOGGER_DEBUG);
|
logger("Found hub ".$hub, LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$header = array();
|
$header = array();
|
||||||
$header["uid"] = $importer["uid"];
|
$header["uid"] = $importer["uid"];
|
||||||
|
@ -257,10 +266,11 @@ class ostatus {
|
||||||
// depending on that, the first node is different
|
// depending on that, the first node is different
|
||||||
$first_child = $doc->firstChild->tagName;
|
$first_child = $doc->firstChild->tagName;
|
||||||
|
|
||||||
if ($first_child == "feed")
|
if ($first_child == "feed") {
|
||||||
$entries = $xpath->query('/atom:feed/atom:entry');
|
$entries = $xpath->query('/atom:feed/atom:entry');
|
||||||
else
|
} else {
|
||||||
$entries = $xpath->query('/atom:entry');
|
$entries = $xpath->query('/atom:entry');
|
||||||
|
}
|
||||||
|
|
||||||
$conversation = "";
|
$conversation = "";
|
||||||
$conversationlist = array();
|
$conversationlist = array();
|
||||||
|
@ -277,16 +287,18 @@ class ostatus {
|
||||||
$mention = false;
|
$mention = false;
|
||||||
|
|
||||||
// fetch the author
|
// fetch the author
|
||||||
if ($first_child == "feed")
|
if ($first_child == "feed") {
|
||||||
$author = self::fetchauthor($xpath, $doc->firstChild, $importer, $contact, false);
|
$author = self::fetchauthor($xpath, $doc->firstChild, $importer, $contact, false);
|
||||||
else
|
} else {
|
||||||
$author = self::fetchauthor($xpath, $entry, $importer, $contact, false);
|
$author = self::fetchauthor($xpath, $entry, $importer, $contact, false);
|
||||||
|
}
|
||||||
|
|
||||||
$value = $xpath->evaluate('atom:author/poco:preferredUsername/text()', $context)->item(0)->nodeValue;
|
$value = $xpath->evaluate('atom:author/poco:preferredUsername/text()', $context)->item(0)->nodeValue;
|
||||||
if ($value != "")
|
if ($value != "") {
|
||||||
$nickname = $value;
|
$nickname = $value;
|
||||||
else
|
} else {
|
||||||
$nickname = $author["author-name"];
|
$nickname = $author["author-name"];
|
||||||
|
}
|
||||||
|
|
||||||
$item = array_merge($header, $author);
|
$item = array_merge($header, $author);
|
||||||
|
|
||||||
|
@ -295,7 +307,7 @@ class ostatus {
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s'",
|
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s'",
|
||||||
intval($importer["uid"]), dbesc($item["uri"]));
|
intval($importer["uid"]), dbesc($item["uri"]));
|
||||||
if ($r) {
|
if (dbm::is_result($r)) {
|
||||||
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$r[0]["id"], LOGGER_DEBUG);
|
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$r[0]["id"], LOGGER_DEBUG);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -306,8 +318,9 @@ class ostatus {
|
||||||
if (($item["object-type"] == ACTIVITY_OBJ_BOOKMARK) OR ($item["object-type"] == ACTIVITY_OBJ_EVENT)) {
|
if (($item["object-type"] == ACTIVITY_OBJ_BOOKMARK) OR ($item["object-type"] == ACTIVITY_OBJ_EVENT)) {
|
||||||
$item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
|
$item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
|
||||||
$item["body"] = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
|
$item["body"] = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
|
||||||
} elseif ($item["object-type"] == ACTIVITY_OBJ_QUESTION)
|
} elseif ($item["object-type"] == ACTIVITY_OBJ_QUESTION) {
|
||||||
$item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
|
$item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
$item["object"] = $xml;
|
$item["object"] = $xml;
|
||||||
$item["verb"] = $xpath->query('activity:verb/text()', $entry)->item(0)->nodeValue;
|
$item["verb"] = $xpath->query('activity:verb/text()', $entry)->item(0)->nodeValue;
|
||||||
|
@ -352,8 +365,9 @@ class ostatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://activitystrea.ms/schema/1.0/rsvp-yes
|
// http://activitystrea.ms/schema/1.0/rsvp-yes
|
||||||
if (!in_array($item["verb"], array(ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE)))
|
if (!in_array($item["verb"], array(ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE))) {
|
||||||
logger("Unhandled verb ".$item["verb"]." ".print_r($item, true));
|
logger("Unhandled verb ".$item["verb"]." ".print_r($item, true));
|
||||||
|
}
|
||||||
|
|
||||||
$item["created"] = $xpath->query('atom:published/text()', $entry)->item(0)->nodeValue;
|
$item["created"] = $xpath->query('atom:published/text()', $entry)->item(0)->nodeValue;
|
||||||
$item["edited"] = $xpath->query('atom:updated/text()', $entry)->item(0)->nodeValue;
|
$item["edited"] = $xpath->query('atom:updated/text()', $entry)->item(0)->nodeValue;
|
||||||
|
@ -364,12 +378,14 @@ class ostatus {
|
||||||
$inreplyto = $xpath->query('thr:in-reply-to', $entry);
|
$inreplyto = $xpath->query('thr:in-reply-to', $entry);
|
||||||
if (is_object($inreplyto->item(0))) {
|
if (is_object($inreplyto->item(0))) {
|
||||||
foreach($inreplyto->item(0)->attributes AS $attributes) {
|
foreach($inreplyto->item(0)->attributes AS $attributes) {
|
||||||
if ($attributes->name == "ref")
|
if ($attributes->name == "ref") {
|
||||||
$item["parent-uri"] = $attributes->textContent;
|
$item["parent-uri"] = $attributes->textContent;
|
||||||
if ($attributes->name == "href")
|
}
|
||||||
|
if ($attributes->name == "href") {
|
||||||
$related = $attributes->textContent;
|
$related = $attributes->textContent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$georsspoint = $xpath->query('georss:point', $entry);
|
$georsspoint = $xpath->query('georss:point', $entry);
|
||||||
if ($georsspoint)
|
if ($georsspoint)
|
||||||
|
@ -411,7 +427,7 @@ class ostatus {
|
||||||
if ($attributes->name == "title")
|
if ($attributes->name == "title")
|
||||||
$title = $attributes->textContent;
|
$title = $attributes->textContent;
|
||||||
}
|
}
|
||||||
if (($rel != "") AND ($href != ""))
|
if (($rel != "") AND ($href != "")) {
|
||||||
switch($rel) {
|
switch($rel) {
|
||||||
case "alternate":
|
case "alternate":
|
||||||
$item["plink"] = $href;
|
$item["plink"] = $href;
|
||||||
|
@ -450,6 +466,7 @@ class ostatus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$local_id = "";
|
$local_id = "";
|
||||||
$repeat_of = "";
|
$repeat_of = "";
|
||||||
|
@ -457,14 +474,17 @@ class ostatus {
|
||||||
$notice_info = $xpath->query('statusnet:notice_info', $entry);
|
$notice_info = $xpath->query('statusnet:notice_info', $entry);
|
||||||
if ($notice_info AND ($notice_info->length > 0)) {
|
if ($notice_info AND ($notice_info->length > 0)) {
|
||||||
foreach($notice_info->item(0)->attributes AS $attributes) {
|
foreach($notice_info->item(0)->attributes AS $attributes) {
|
||||||
if ($attributes->name == "source")
|
if ($attributes->name == "source") {
|
||||||
$item["app"] = strip_tags($attributes->textContent);
|
$item["app"] = strip_tags($attributes->textContent);
|
||||||
if ($attributes->name == "local_id")
|
}
|
||||||
|
if ($attributes->name == "local_id") {
|
||||||
$local_id = $attributes->textContent;
|
$local_id = $attributes->textContent;
|
||||||
if ($attributes->name == "repeat_of")
|
}
|
||||||
|
if ($attributes->name == "repeat_of") {
|
||||||
$repeat_of = $attributes->textContent;
|
$repeat_of = $attributes->textContent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Is it a repeated post?
|
// Is it a repeated post?
|
||||||
if (($repeat_of != "") OR ($item["verb"] == ACTIVITY_SHARE)) {
|
if (($repeat_of != "") OR ($item["verb"] == ACTIVITY_SHARE)) {
|
||||||
|
@ -473,24 +493,32 @@ class ostatus {
|
||||||
if (is_object($activityobjects)) {
|
if (is_object($activityobjects)) {
|
||||||
|
|
||||||
$orig_uri = $xpath->query("activity:object/atom:id", $activityobjects)->item(0)->nodeValue;
|
$orig_uri = $xpath->query("activity:object/atom:id", $activityobjects)->item(0)->nodeValue;
|
||||||
if (!isset($orig_uri))
|
if (!isset($orig_uri)) {
|
||||||
$orig_uri = $xpath->query('atom:id/text()', $activityobjects)->item(0)->nodeValue;
|
$orig_uri = $xpath->query('atom:id/text()', $activityobjects)->item(0)->nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
$orig_links = $xpath->query("activity:object/atom:link[@rel='alternate']", $activityobjects);
|
$orig_links = $xpath->query("activity:object/atom:link[@rel='alternate']", $activityobjects);
|
||||||
if ($orig_links AND ($orig_links->length > 0))
|
if ($orig_links AND ($orig_links->length > 0)) {
|
||||||
foreach($orig_links->item(0)->attributes AS $attributes)
|
foreach ($orig_links->item(0)->attributes AS $attributes) {
|
||||||
if ($attributes->name == "href")
|
if ($attributes->name == "href") {
|
||||||
$orig_link = $attributes->textContent;
|
$orig_link = $attributes->textContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($orig_link))
|
if (!isset($orig_link)) {
|
||||||
$orig_link = $xpath->query("atom:link[@rel='alternate']", $activityobjects)->item(0)->nodeValue;
|
$orig_link = $xpath->query("atom:link[@rel='alternate']", $activityobjects)->item(0)->nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($orig_link))
|
if (!isset($orig_link)) {
|
||||||
$orig_link = self::convert_href($orig_uri);
|
$orig_link = self::convert_href($orig_uri);
|
||||||
|
}
|
||||||
|
|
||||||
$orig_body = $xpath->query('activity:object/atom:content/text()', $activityobjects)->item(0)->nodeValue;
|
$orig_body = $xpath->query('activity:object/atom:content/text()', $activityobjects)->item(0)->nodeValue;
|
||||||
if (!isset($orig_body))
|
|
||||||
|
if (!isset($orig_body)) {
|
||||||
$orig_body = $xpath->query('atom:content/text()', $activityobjects)->item(0)->nodeValue;
|
$orig_body = $xpath->query('atom:content/text()', $activityobjects)->item(0)->nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
$orig_created = $xpath->query('atom:published/text()', $activityobjects)->item(0)->nodeValue;
|
$orig_created = $xpath->query('atom:published/text()', $activityobjects)->item(0)->nodeValue;
|
||||||
$orig_edited = $xpath->query('atom:updated/text()', $activityobjects)->item(0)->nodeValue;
|
$orig_edited = $xpath->query('atom:updated/text()', $activityobjects)->item(0)->nodeValue;
|
||||||
|
@ -511,10 +539,12 @@ class ostatus {
|
||||||
$item["verb"] = $xpath->query('activity:verb/text()', $activityobjects)->item(0)->nodeValue;
|
$item["verb"] = $xpath->query('activity:verb/text()', $activityobjects)->item(0)->nodeValue;
|
||||||
|
|
||||||
$item["object-type"] = $xpath->query('activity:object/activity:object-type/text()', $activityobjects)->item(0)->nodeValue;
|
$item["object-type"] = $xpath->query('activity:object/activity:object-type/text()', $activityobjects)->item(0)->nodeValue;
|
||||||
if (!isset($item["object-type"]))
|
|
||||||
|
if (!isset($item["object-type"])) {
|
||||||
$item["object-type"] = $xpath->query('activity:object-type/text()', $activityobjects)->item(0)->nodeValue;
|
$item["object-type"] = $xpath->query('activity:object-type/text()', $activityobjects)->item(0)->nodeValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//if ($enclosure != "")
|
//if ($enclosure != "")
|
||||||
// $item["body"] .= add_page_info($enclosure);
|
// $item["body"] .= add_page_info($enclosure);
|
||||||
|
@ -540,12 +570,14 @@ class ostatus {
|
||||||
intval($importer["uid"]), dbesc($item["parent-uri"]));
|
intval($importer["uid"]), dbesc($item["parent-uri"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($r) {
|
|
||||||
|
if (dbm::is_result($r)) {
|
||||||
$item["type"] = 'remote-comment';
|
$item["type"] = 'remote-comment';
|
||||||
$item["gravity"] = GRAVITY_COMMENT;
|
$item["gravity"] = GRAVITY_COMMENT;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
$item["parent-uri"] = $item["uri"];
|
$item["parent-uri"] = $item["uri"];
|
||||||
|
}
|
||||||
|
|
||||||
$item_id = self::completion($conversation, $importer["uid"], $item, $self);
|
$item_id = self::completion($conversation, $importer["uid"], $item, $self);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue