- public static function init()
- {
- $a = self::getApp();
-
- if (!local_user()) {
- return;
- }
-
- $nets = defaults($_GET, 'nets', '');
- if ($nets == "all") {
- $nets = "";
- }
-
- if (!x($a->page, 'aside')) {
- $a->page['aside'] = '';
- }
-
- $contact_id = null;
- $contact = null;
- if ((($a->argc == 2) && intval($a->argv[1])) || (($a->argc == 3) && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations']))) {
- $contact_id = intval($a->argv[1]);
- $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
-
- if (!DBA::isResult($contact)) {
- $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => 0]);
- }
-
- // Don't display contacts that are about to be deleted
- if ($contact['network'] == Protocol::PHANTOM) {
- $contact = false;
- }
- }
-
- if (DBA::isResult($contact)) {
- if ($contact['self']) {
- if (($a->argc == 3) && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])) {
- goaway('profile/' . $contact['nick']);
- } else {
- goaway('profile/' . $contact['nick'] . '?tab=profile');
- }
- }
-
- $a->data['contact'] = $contact;
-
- if (($a->data['contact']['network'] != "") && ($a->data['contact']['network'] != Protocol::DFRN)) {
- $networkname = format_network_name($a->data['contact']['network'], $a->data['contact']['url']);
- } else {
- $networkname = '';
- }
-
- /// @TODO Add nice spaces
- $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [
- '$name' => htmlentities($a->data['contact']['name']),
- '$photo' => $a->data['contact']['photo'],
- '$url' => Model\Contact::MagicLink($a->data['contact']['url']),
- '$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""),
- '$network_name' => $networkname,
- '$network' => L10n::t('Network:'),
- '$account_type' => Model\Contact::getAccountType($a->data['contact'])
- ]);
-
- $findpeople_widget = '';
- $follow_widget = '';
- $networks_widget = '';
- } else {
- $vcard_widget = '';
- $networks_widget = Widget::networks('contacts', $nets);
- if (isset($_GET['add'])) {
- $follow_widget = Widget::follow($_GET['add']);
- } else {
- $follow_widget = Widget::follow();
- }
-
- $findpeople_widget = Widget::findPeople();
- }
-
- if ($contact['uid'] != 0) {
- $groups_widget = Model\Group::sidebarWidget('contacts', 'group', 'full', 'everyone', $contact_id);
- } else {
- $groups_widget = null;
- }
-
- $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"), [
- '$vcard_widget' => $vcard_widget,
- '$findpeople_widget' => $findpeople_widget,
- '$follow_widget' => $follow_widget,
- '$groups_widget' => $groups_widget,
- '$networks_widget' => $networks_widget
- ]);
-
- $base = $a->getBaseURL();
- $tpl = get_markup_template("contacts-head.tpl");
- $a->page['htmlhead'] .= replace_macros($tpl, [
- '$baseurl' => System::baseUrl(true),
- '$base' => $base
- ]);
- }
-