<commit_before><?php

namespace Friendica\Module;

use Friendica\App;
use Friendica\BaseModule;
use Friendica\Content\ContactSelector;
use Friendica\Content\Nav;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Widget;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Core\ACL;
use Friendica\Module\Login;

/**
 *  Manages and show Contacts and their content
 *
 *  @brief manages contacts
 */
class Contact extends BaseModule 
{
	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'         => defaults($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('contact', $nets);<commit_msg>Replace unwarranted uses of $a->data['contact']<commit_after><?php

namespace Friendica\Module;

use Friendica\App;
use Friendica\BaseModule;
use Friendica\Content\ContactSelector;
use Friendica\Content\Nav;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Widget;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Core\ACL;
use Friendica\Module\Login;

/**
 *  Manages and show Contacts and their content
 *
 *  @brief manages contacts
 */
class Contact extends BaseModule 
{
	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 (($contact['network'] != '') && ($contact['network'] != Protocol::DFRN)) {
				$networkname = format_network_name($contact['network'], $contact['url']);
			} else {
				$networkname = '';
			}

			/// @TODO Add nice spaces
			$vcard_widget = replace_macros(get_markup_template('vcard-widget.tpl'), [
				'$name'         => htmlentities($contact['name']),
				'$photo'        => $contact['photo'],
				'$url'          => Model\Contact::MagicLink($contact['url']),
				'$addr'         => defaults($contact, 'addr', ''),
				'$network_name' => $networkname,
				'$network'      => L10n::t('Network:'),
				'$account_type' => Model\Contact::getAccountType($contact)
			]);

			$findpeople_widget = '';
			$follow_widget = '';
			$networks_widget = '';
		} else {
			$vcard_widget = '';
			$networks_widget = Widget::networks('contact', $nets);
{'fraction_non_alphanumeric': 0.2194146518814761, 'fraction_numerical': 0.005089983639338302, 'mean_word_length': 3.988213961922031, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1269881', 'n_tokens_mistral': 2161, 'n_tokens_neox': 1896, 'n_words': 355}