]> git.mxchange.org Git - friendica.git/blobdiff - mod/hovercard.php
Add not null/default value for ACL in fields
[friendica.git] / mod / hovercard.php
index 6160642762a4adcbc427d6f21b048fa62df60c19..d5951dbe00fa19457eed86c2f4d267818ce2a5d7 100644 (file)
@@ -26,12 +26,12 @@ function hovercard_init(App $a)
 
 function hovercard_content()
 {
-       $profileurl = defaults($_REQUEST, 'profileurl', '');
-       $datatype   = defaults($_REQUEST, 'datatype'  , 'json');
+       $profileurl =  $_REQUEST['profileurl'] ?? '';
+       $datatype   = ($_REQUEST['datatype']   ?? '') ?: 'json';
 
        // Get out if the system doesn't have public access allowed
        if (intval(Config::get('system', 'block_public'))) {
-               System::httpExit(401);
+               throw new \Friendica\Network\HTTPException\ForbiddenException();
        }
 
        // Return the raw content of the template. We use this to make templates usable for js functions.
@@ -41,17 +41,16 @@ function hovercard_content()
        if ($datatype == 'tpl') {
                $templatecontent = get_template_content('hovercard.tpl');
                echo $templatecontent;
-               killme();
+               exit();
        }
 
        // If a contact is connected the url is internally changed to 'redir/CID'. We need the pure url to search for
        // the contact. So we strip out the contact id from the internal url and look in the contact table for
        // the real url (nurl)
-       $cid = 0;
        if (strpos($profileurl, 'redir/') === 0) {
                $cid = intval(substr($profileurl, 6));
                $remote_contact = DBA::selectFirst('contact', ['nurl'], ['id' => $cid]);
-               $profileurl = defaults($remote_contact, 'nurl', '');
+               $profileurl = $remote_contact['nurl'] ?? '';
        }
 
        $contact = [];
@@ -96,20 +95,20 @@ function hovercard_content()
 
        // Move the contact data to the profile array so we can deliver it to
        $profile = [
-               'name'     => $contact['name'],
-               'nick'     => $contact['nick'],
-               'addr'     => defaults($contact, 'addr', $contact['url']),
-               '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'],
-               'gender'   => $contact['gender'],
-               'about'    => $contact['about'],
-               'network => Strings::formatNetworkName($contact['network'], $contact['url']),
-               'tags'     => $contact['keywords'],
-               'bd'       => $contact['birthday'] <= DBA::NULL_DATE ? '' : $contact['birthday'],
+               'name'         => $contact['name'],
+               'nick'         => $contact['nick'],
+               'addr'         => ($contact['addr'] ?? '') ?: $contact['url'],
+               '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'],
+               'gender'       => $contact['gender'],
+               'about'        => $contact['about'],
+               'network_link' => Strings::formatNetworkName($contact['network'], $contact['url']),
+               'tags'         => $contact['keywords'],
+               'bd'           => $contact['birthday'] <= DBA::NULL_DATE ? '' : $contact['birthday'],
                'account_type' => Contact::getAccountType($contact),
-               'actions'  => $actions,
+               'actions'      => $actions,
        ];
        if ($datatype == 'html') {
                $tpl = Renderer::getMarkupTemplate('hovercard.tpl');
@@ -127,16 +126,19 @@ function hovercard_content()
  * @brief Get the raw content of a template file
  *
  * @param string $template The name of the template
- * @param string $root Directory of the template
+ * @param string $root     Directory of the template
  *
  * @return string|bool Output the raw content if existent, otherwise false
+ * @throws Exception
  */
 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 = Renderer::getMarkupTemplate($template, $root);
-       $filename = $t->filename;
+       $templateEngine = Renderer::getTemplateEngine();
+       $template = $templateEngine->getTemplateFile($template, $root);
+
+       $filename = $template->filename;
 
        // Get the content of the template file
        if (file_exists($filename)) {