]> git.mxchange.org Git - friendica.git/commitdiff
fetch the full name of a contact from the poco fields (if present)
authorMichael Vogel <icarus@dabo.de>
Sat, 13 Jun 2015 07:08:52 +0000 (09:08 +0200)
committerMichael Vogel <icarus@dabo.de>
Sat, 13 Jun 2015 07:08:52 +0000 (09:08 +0200)
include/Scrape.php

index ce18bb10333f5c5dddf573c609263512716a28e3..1bb1998b0d9235276fb0f1c59b41795e3851d5ee 100644 (file)
@@ -670,6 +670,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
                                        $vcard['fn'] = trim(unxmlify($author->get_email()));
                                if(strpos($vcard['fn'],'@') !== false)
                                        $vcard['fn'] = substr($vcard['fn'],0,strpos($vcard['fn'],'@'));
+
                                $email = unxmlify($author->get_email());
                                if(! $profile && $author->get_link())
                                        $profile = trim(unxmlify($author->get_link()));
@@ -681,6 +682,15 @@ function probe_url($url, $mode = PROBE_NORMAL) {
                                                        $vcard['photo'] = $elems['link'][0]['attribs']['']['href'];
                                        }
                                }
+                               // Fetch fullname via poco:displayName
+                               $pocotags = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
+                               if ($pocotags) {
+                                       $elems = $pocotags[0]['child']['http://portablecontacts.net/spec/1.0'];
+                                       if (isset($elems["displayName"]))
+                                               $vcard['fn'] = $elems["displayName"][0]["data"];
+                                       if (isset($elems["preferredUsername"]))
+                                               $vcard['nick'] = $elems["preferredUsername"][0]["data"];
+                               }
                        }
                        else {
                                $item = $feed->get_item(0);
@@ -757,18 +767,18 @@ function probe_url($url, $mode = PROBE_NORMAL) {
                $vcard['fn'] = $url;
 
        if (($notify != "") AND ($poll != "")) {
-               $baseurl = matching($notify, $poll);
+               $baseurl = matching(normalise_link($notify), normalise_link($poll));
 
-               $baseurl2 = matching($baseurl, $profile);
+               $baseurl2 = matching($baseurl, normalise_link($profile));
                if ($baseurl2 != "")
                        $baseurl = $baseurl2;
        }
 
        if (($baseurl == "") AND ($notify != ""))
-               $baseurl = matching($profile, $notify);
+               $baseurl = matching(normalise_link($profile), normalise_link($notify));
 
        if (($baseurl == "") AND ($poll != ""))
-               $baseurl = matching($profile, $poll);
+               $baseurl = matching(normalise_link($profile), normalise_link($poll));
 
        $baseurl = rtrim($baseurl, "/");