X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fcommon.php;h=f45bbb0175c1498d344fb542ac7f526e4ad80602;hb=269221f0133b7961c7df403a44e20420c45c1d44;hp=fc8829aa51a1c42a8fa5765eca123788fec4dd87;hpb=045a0b2a007d869fc141f3f4a7a1761589565fdf;p=friendica.git diff --git a/mod/common.php b/mod/common.php index fc8829aa51..f45bbb0175 100644 --- a/mod/common.php +++ b/mod/common.php @@ -1,14 +1,16 @@ page['aside'] = ""; - profile_load($a, "", 0, Contact::getDetailsByURL($c[0]["url"])); + $contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => $uid]); + + if (DBM::is_result($contact)) { + $a->page['aside'] = ""; + Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"])); + } } else { - $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", - intval($uid) - ); - /// @TODO Handle $c with DBM::is_result() - $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array( - '$name' => htmlentities($c[0]['name']), - '$photo' => $c[0]['photo'], - 'url' => 'contacts/' . $cid - )); - - if (!x($a->page, 'aside')) { - $a->page['aside'] = ''; + $contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]); + + if (DBM::is_result($contact)) { + $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [ + '$name' => htmlentities($contact['name']), + '$photo' => $contact['photo'], + 'url' => 'contacts/' . $cid + ]); + + if (!x($a->page, 'aside')) { + $a->page['aside'] = ''; + } + $a->page['aside'] .= $vcard_widget; } - $a->page['aside'] .= $vcard_widget; } - if (!DBM::is_result($c)) { + if (!DBM::is_result($contact)) { return; } - if (!$cid && get_my_url()) { - /// @todo : Initialize $profile_uid - $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1", - dbesc(normalise_link(get_my_url())), - intval($profile_uid) - ); - if (DBM::is_result($r)) { - $cid = $r[0]['id']; + if (!$cid && Profile::getMyURL()) { + $contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $uid]); + if (DBM::is_result($contact)) { + $cid = $contact['id']; } else { - $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", - dbesc(normalise_link(get_my_url())) - ); - if (DBM::is_result($r)) { - $zcid = $r[0]['id']; + $gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]); + if (DBM::is_result($gcontact)) { + $zcid = $gcontact['id']; } } } @@ -93,7 +88,7 @@ function common_content(App $a) if ($t > 0) { $a->set_pager_total($t); } else { - notice(t('No contacts in common.') . EOL); + notice(L10n::t('No contacts in common.') . EOL); return $o; } @@ -120,7 +115,7 @@ function common_content(App $a) $photo_menu = Contact::photoMenu($rr); - $entry = array( + $entry = [ 'url' => $rr['url'], 'itemurl' => defaults($contact_details, 'addr', $rr['url']), 'name' => $contact_details['name'], @@ -130,10 +125,10 @@ function common_content(App $a) 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => Contact::getAccountType($contact_details), - 'network' => network_to_name($contact_details['network'], $contact_details['url']), + 'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']), 'photo_menu' => $photo_menu, 'id' => ++$id, - ); + ]; $entries[] = $entry; } @@ -142,17 +137,17 @@ function common_content(App $a) if ($cmd === 'loc' && $cid && local_user() == $uid) { $tab_str = contacts_tab($a, $cid, 4); } else { - $title = t('Common Friends'); + $title = L10n::t('Common Friends'); } $tpl = get_markup_template('viewcontact_template.tpl'); - $o .= replace_macros($tpl, array( + $o .= replace_macros($tpl, [ '$title' => $title, '$tab_str' => $tab_str, '$contacts' => $entries, '$paginate' => paginate($a), - )); + ]); return $o; }