]> git.mxchange.org Git - friendica.git/blobdiff - mod/hovercard.php
Merge pull request #6055 from zeroadam/FileTagHotFix
[friendica.git] / mod / hovercard.php
index 40d32be7ad6895462ec49cec4aba05e58db98c11..1e2e14afb634b8bd74151c31df8881be0ae4e189 100644 (file)
 
 use Friendica\App;
 use Friendica\Core\Config;
+use Friendica\Core\Renderer;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Model\GContact;
+use Friendica\Util\Proxy as ProxyUtils;
 
 function hovercard_init(App $a)
 {
@@ -54,10 +56,32 @@ function hovercard_content()
        $contact = [];
        // if it's the url containing https it should be converted to http
        $nurl = normalise_link(GContact::cleanContactUrl($profileurl));
-       if ($nurl) {
-               // Search for contact data
+       if (!$nurl) {
+               return;
+       }
+
+       // Search for contact data
+       // Look if the local user has got the contact
+       if (local_user()) {
+               $contact = Contact::getDetailsByURL($nurl, local_user());
+       }
+
+       // If not then check the global user
+       if (!count($contact)) {
                $contact = Contact::getDetailsByURL($nurl);
        }
+
+       // Feeds url could have been destroyed through "cleanContactUrl", so we now use the original url
+       if (!count($contact) && local_user()) {
+               $nurl = normalise_link($profileurl);
+               $contact = Contact::getDetailsByURL($nurl, local_user());
+       }
+
+       if (!count($contact)) {
+               $nurl = normalise_link($profileurl);
+               $contact = Contact::getDetailsByURL($nurl);
+       }
+
        if (!count($contact)) {
                return;
        }
@@ -74,7 +98,7 @@ function hovercard_content()
                'name'     => $contact['name'],
                'nick'     => $contact['nick'],
                'addr'     => defaults($contact, 'addr', $contact['url']),
-               'thumb'    => proxy_url($contact['thumb'], false, PROXY_SIZE_THUMB),
+               'thumb'    => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
                'url'      => Contact::magicLink($contact['url']),
                'nurl'     => $contact['nurl'], // We additionally store the nurl as identifier
                'location' => $contact['location'],
@@ -87,8 +111,8 @@ function hovercard_content()
                'actions'  => $actions,
        ];
        if ($datatype == 'html') {
-               $tpl = get_markup_template('hovercard.tpl');
-               $o = replace_macros($tpl, [
+               $tpl = Renderer::getMarkupTemplate('hovercard.tpl');
+               $o = Renderer::replaceMacros($tpl, [
                        '$profile' => $profile,
                ]);
 
@@ -110,7 +134,7 @@ function get_template_content($template, $root = '')
 {
        // We load the whole template system to get the filename.
        // Maybe we can do it a little bit smarter if I get time.
-       $t = get_markup_template($template, $root);
+       $t = Renderer::getMarkupTemplate($template, $root);
        $filename = $t->filename;
 
        // Get the content of the template file