Merge pull request #8952 from annando/contact-template
Use a single function to create the template data for contacts
This commit is contained in:
commit
2b9ef97adc
|
@ -20,13 +20,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\ContactSelector;
|
|
||||||
use Friendica\Content\Pager;
|
use Friendica\Content\Pager;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model;
|
use Friendica\Model;
|
||||||
use Friendica\Model\Contact;
|
|
||||||
use Friendica\Module;
|
use Friendica\Module;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
|
@ -119,34 +117,12 @@ function common_content(App $a)
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = 0;
|
|
||||||
|
|
||||||
$entries = [];
|
$entries = [];
|
||||||
foreach ($common_friends as $common_friend) {
|
foreach ($common_friends as $common_friend) {
|
||||||
//get further details of the contact
|
$contact = Model\Contact::getByURLForUser($common_friend['url'], local_user());
|
||||||
$contact_details = Model\Contact::getByURLForUser($common_friend['url'], $uid);
|
if (!empty($contact)) {
|
||||||
|
$entries[] = Module\Contact::getContactTemplateVars($contact);
|
||||||
// $rr['id'] is needed to use contact_photo_menu()
|
}
|
||||||
/// @TODO Adding '/" here avoids E_NOTICE on missing constants
|
|
||||||
$common_friend['id'] = $common_friend['cid'];
|
|
||||||
|
|
||||||
$photo_menu = Model\Contact::photoMenu($common_friend);
|
|
||||||
|
|
||||||
$entry = [
|
|
||||||
'url' => Model\Contact::magicLink($common_friend['url']),
|
|
||||||
'itemurl' => ($contact_details['addr'] ?? '') ?: $common_friend['url'],
|
|
||||||
'name' => $contact_details['name'],
|
|
||||||
'thumb' => Contact::getThumb($contact_details),
|
|
||||||
'img_hover' => $contact_details['name'],
|
|
||||||
'details' => $contact_details['location'],
|
|
||||||
'tags' => $contact_details['keywords'],
|
|
||||||
'about' => $contact_details['about'],
|
|
||||||
'account_type' => Model\Contact::getAccountType($contact_details),
|
|
||||||
'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
|
|
||||||
'photo_menu' => $photo_menu,
|
|
||||||
'id' => ++$id,
|
|
||||||
];
|
|
||||||
$entries[] = $entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = '';
|
$title = '';
|
||||||
|
|
|
@ -27,6 +27,7 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
|
use Friendica\Module\Contact as ModuleContact;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for /match.
|
* Controller for /match.
|
||||||
|
@ -91,33 +92,10 @@ function match_content(App $a)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround for wrong directory photo URL
|
$contact = Contact::getByURLForUser($profile->url, local_user());
|
||||||
$profile->photo = str_replace('http:///photo/', Search::getGlobalDirectory() . '/photo/', $profile->photo);
|
if (!empty($contact)) {
|
||||||
|
$entries[] = ModuleContact::getContactTemplateVars($contact);
|
||||||
$connlnk = DI::baseUrl() . '/follow/?url=' . $profile->url;
|
}
|
||||||
$photo_menu = [
|
|
||||||
'profile' => [DI::l10n()->t("View Profile"), Contact::magicLink($profile->url)],
|
|
||||||
'follow' => [DI::l10n()->t("Connect/Follow"), $connlnk]
|
|
||||||
];
|
|
||||||
|
|
||||||
$contact_details = Contact::getByURL($profile->url, false);
|
|
||||||
|
|
||||||
$entry = [
|
|
||||||
'url' => Contact::magicLink($profile->url),
|
|
||||||
'itemurl' => $contact_details['addr'] ?? $profile->url,
|
|
||||||
'name' => $profile->name,
|
|
||||||
'details' => $contact_details['location'] ?? '',
|
|
||||||
'tags' => $contact_details['keywords'] ?? '',
|
|
||||||
'about' => $contact_details['about'] ?? '',
|
|
||||||
'account_type' => Contact::getAccountType($contact_details),
|
|
||||||
'thumb' => Contact::getThumb($contact_details, $profile->photo),
|
|
||||||
'conntxt' => DI::l10n()->t('Connect'),
|
|
||||||
'connlnk' => $connlnk,
|
|
||||||
'img_hover' => $profile->tags,
|
|
||||||
'photo_menu' => $photo_menu,
|
|
||||||
'id' => $i,
|
|
||||||
];
|
|
||||||
$entries[] = $entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\ContactSelector;
|
|
||||||
use Friendica\Content\Widget;
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Module\Contact as ModuleContact;
|
||||||
|
|
||||||
function suggest_init(App $a)
|
function suggest_init(App $a)
|
||||||
{
|
{
|
||||||
|
@ -89,25 +89,9 @@ function suggest_content(App $a)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = 0;
|
|
||||||
$entries = [];
|
$entries = [];
|
||||||
|
|
||||||
foreach ($contacts as $contact) {
|
foreach ($contacts as $contact) {
|
||||||
$entry = [
|
$entries[] = ModuleContact::getContactTemplateVars($contact);
|
||||||
'url' => Contact::magicLink($contact['url']),
|
|
||||||
'itemurl' => $contact['addr'] ?: $contact['url'],
|
|
||||||
'name' => $contact['name'],
|
|
||||||
'thumb' => Contact::getThumb($contact),
|
|
||||||
'img_hover' => $contact['url'],
|
|
||||||
'details' => $contact['location'],
|
|
||||||
'tags' => $contact['keywords'],
|
|
||||||
'about' => $contact['about'],
|
|
||||||
'account_type' => Contact::getAccountType($contact),
|
|
||||||
'network' => ContactSelector::networkToName($contact['network'], $contact['url']),
|
|
||||||
'photo_menu' => Contact::photoMenu($contact),
|
|
||||||
'id' => ++$id,
|
|
||||||
];
|
|
||||||
$entries[] = $entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
|
$tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Content\ContactSelector;
|
|
||||||
use Friendica\Content\Pager;
|
use Friendica\Content\Pager;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -73,44 +72,12 @@ class AllFriends extends BaseModule
|
||||||
return DI::l10n()->t('No friends to display.');
|
return DI::l10n()->t('No friends to display.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = 0;
|
|
||||||
|
|
||||||
$entries = [];
|
$entries = [];
|
||||||
foreach ($friends as $friend) {
|
foreach ($friends as $friend) {
|
||||||
//get further details of the contact
|
$contact = Model\Contact::getByURLForUser($friend['url'], local_user());
|
||||||
$contactDetails = Model\Contact::getByURLForUser($friend['url'], $uid) ?: $friend;
|
if (!empty($contact)) {
|
||||||
|
$entries[] = Contact::getContactTemplateVars($contact);
|
||||||
$connlnk = '';
|
|
||||||
// $friend[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photoMenu
|
|
||||||
// If the contact is not common to the user, Connect/Follow' will be added to the photo menu
|
|
||||||
if ($friend['cid']) {
|
|
||||||
$friend['id'] = $friend['cid'];
|
|
||||||
$photoMenu = Model\Contact::photoMenu($friend);
|
|
||||||
} else {
|
|
||||||
$connlnk = DI::baseUrl()->get() . '/follow/?url=' . $friend['url'];
|
|
||||||
$photoMenu = [
|
|
||||||
'profile' => [DI::l10n()->t('View Profile'), Model\Contact::magicLinkbyId($friend['id'], $friend['url'])],
|
|
||||||
'follow' => [DI::l10n()->t('Connect/Follow'), $connlnk]
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = [
|
|
||||||
'url' => Model\Contact::magicLinkbyId($friend['id'], $friend['url']),
|
|
||||||
'itemurl' => ($contactDetails['addr'] ?? '') ?: $friend['url'],
|
|
||||||
'name' => $contactDetails['name'],
|
|
||||||
'thumb' => Model\Contact::getThumb($contactDetails),
|
|
||||||
'img_hover' => $contactDetails['name'],
|
|
||||||
'details' => $contactDetails['location'],
|
|
||||||
'tags' => $contactDetails['keywords'],
|
|
||||||
'about' => $contactDetails['about'],
|
|
||||||
'account_type' => Model\Contact::getAccountType($contactDetails),
|
|
||||||
'network' => ContactSelector::networkToName($contactDetails['network'], $contactDetails['url']),
|
|
||||||
'photoMenu' => $photoMenu,
|
|
||||||
'conntxt' => DI::l10n()->t('Connect'),
|
|
||||||
'connlnk' => $connlnk,
|
|
||||||
'id' => ++$id,
|
|
||||||
];
|
|
||||||
$entries[] = $entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$tab_str = Contact::getTabsHTML($app, $contact, 4);
|
$tab_str = Contact::getTabsHTML($app, $contact, 4);
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Content\ContactSelector;
|
|
||||||
use Friendica\Content\Pager;
|
use Friendica\Content\Pager;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Search;
|
use Friendica\Core\Search;
|
||||||
|
@ -119,66 +118,15 @@ class BaseSearch extends BaseModule
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = 0;
|
|
||||||
$entries = [];
|
$entries = [];
|
||||||
foreach ($results->getResults() as $result) {
|
foreach ($results->getResults() as $result) {
|
||||||
|
|
||||||
// in case the result is a contact result, add a contact-specific entry
|
// in case the result is a contact result, add a contact-specific entry
|
||||||
if ($result instanceof ContactResult) {
|
if ($result instanceof ContactResult) {
|
||||||
|
$contact = Model\Contact::getByURLForUser($result->getUrl(), local_user());
|
||||||
$alt_text = '';
|
if (!empty($contact)) {
|
||||||
$location = '';
|
$entries[] = Contact::getContactTemplateVars($contact);
|
||||||
$about = '';
|
|
||||||
$accountType = '';
|
|
||||||
$photo_menu = [];
|
|
||||||
|
|
||||||
// If We already know this contact then don't show the "connect" button
|
|
||||||
if ($result->getCid() > 0 || $result->getPCid() > 0) {
|
|
||||||
$connLink = "";
|
|
||||||
$connTxt = "";
|
|
||||||
$contact = Model\Contact::getById(
|
|
||||||
($result->getCid() > 0) ? $result->getCid() : $result->getPCid()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!empty($contact)) {
|
|
||||||
$photo_menu = Model\Contact::photoMenu($contact);
|
|
||||||
$details = Contact::getContactTemplateVars($contact);
|
|
||||||
$alt_text = $details['alt_text'];
|
|
||||||
$location = $contact['location'];
|
|
||||||
$about = $contact['about'];
|
|
||||||
$accountType = Model\Contact::getAccountType($contact);
|
|
||||||
} else {
|
|
||||||
$photo_menu = [];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$connLink = DI::baseUrl()->get() . '/follow/?url=' . $result->getUrl();
|
|
||||||
$connTxt = DI::l10n()->t('Connect');
|
|
||||||
|
|
||||||
$photo_menu['profile'] = [DI::l10n()->t("View Profile"), Model\Contact::magicLink($result->getUrl())];
|
|
||||||
$photo_menu['follow'] = [DI::l10n()->t("Connect/Follow"), $connLink];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$photo = str_replace("http:///photo/", Search::getGlobalDirectory() . "/photo/", $result->getPhoto());
|
|
||||||
$contact = Model\Contact::getByURL($result->getUrl());
|
|
||||||
|
|
||||||
$entry = [
|
|
||||||
'alt_text' => $alt_text,
|
|
||||||
'url' => Model\Contact::magicLink($result->getUrl()),
|
|
||||||
'itemurl' => $result->getItem(),
|
|
||||||
'name' => $contact['name'] ?? $result->getName(),
|
|
||||||
'thumb' => Model\Contact::getThumb($contact, $photo),
|
|
||||||
'img_hover' => $result->getTags(),
|
|
||||||
'conntxt' => $connTxt,
|
|
||||||
'connlnk' => $connLink,
|
|
||||||
'photo_menu' => $photo_menu,
|
|
||||||
'details' => $location,
|
|
||||||
'tags' => $result->getTags(),
|
|
||||||
'about' => $about,
|
|
||||||
'account_type' => $accountType,
|
|
||||||
'network' => ContactSelector::networkToName($result->getNetwork(), $result->getUrl()),
|
|
||||||
'id' => ++$id,
|
|
||||||
];
|
|
||||||
$entries[] = $entry;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -483,21 +483,17 @@ class Contact extends BaseModule
|
||||||
$contact['blocked'] = Model\Contact::isBlockedByUser($contact['id'], local_user());
|
$contact['blocked'] = Model\Contact::isBlockedByUser($contact['id'], local_user());
|
||||||
$contact['readonly'] = Model\Contact::isIgnoredByUser($contact['id'], local_user());
|
$contact['readonly'] = Model\Contact::isIgnoredByUser($contact['id'], local_user());
|
||||||
|
|
||||||
$dir_icon = '';
|
|
||||||
$relation_text = '';
|
$relation_text = '';
|
||||||
switch ($contact['rel']) {
|
switch ($contact['rel']) {
|
||||||
case Model\Contact::FRIEND:
|
case Model\Contact::FRIEND:
|
||||||
$dir_icon = 'images/lrarrow.gif';
|
|
||||||
$relation_text = DI::l10n()->t('You are mutual friends with %s');
|
$relation_text = DI::l10n()->t('You are mutual friends with %s');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Model\Contact::FOLLOWER;
|
case Model\Contact::FOLLOWER;
|
||||||
$dir_icon = 'images/larrow.gif';
|
|
||||||
$relation_text = DI::l10n()->t('You are sharing with %s');
|
$relation_text = DI::l10n()->t('You are sharing with %s');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Model\Contact::SHARING;
|
case Model\Contact::SHARING;
|
||||||
$dir_icon = 'images/rarrow.gif';
|
|
||||||
$relation_text = DI::l10n()->t('%s is sharing with you');
|
$relation_text = DI::l10n()->t('%s is sharing with you');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -612,7 +608,6 @@ class Contact extends BaseModule
|
||||||
'$ffi_keyword_denylist' => ['ffi_keyword_denylist', DI::l10n()->t('Keyword Deny List'), $contact['ffi_keyword_denylist'], DI::l10n()->t('Comma separated list of keywords that should not be converted to hashtags, when "Fetch information and keywords" is selected')],
|
'$ffi_keyword_denylist' => ['ffi_keyword_denylist', DI::l10n()->t('Keyword Deny List'), $contact['ffi_keyword_denylist'], DI::l10n()->t('Comma separated list of keywords that should not be converted to hashtags, when "Fetch information and keywords" is selected')],
|
||||||
'$photo' => Model\Contact::getPhoto($contact),
|
'$photo' => Model\Contact::getPhoto($contact),
|
||||||
'$name' => $contact['name'],
|
'$name' => $contact['name'],
|
||||||
'$dir_icon' => $dir_icon,
|
|
||||||
'$sparkle' => $sparkle,
|
'$sparkle' => $sparkle,
|
||||||
'$url' => $url,
|
'$url' => $url,
|
||||||
'$profileurllabel'=> DI::l10n()->t('Profile URL'),
|
'$profileurllabel'=> DI::l10n()->t('Profile URL'),
|
||||||
|
@ -1009,25 +1004,27 @@ class Contact extends BaseModule
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getContactTemplateVars(array $rr)
|
/**
|
||||||
|
* Return the fields for the contact template
|
||||||
|
*
|
||||||
|
* @param array $contact Contact array
|
||||||
|
* @return array Template fields
|
||||||
|
*/
|
||||||
|
public static function getContactTemplateVars(array $contact)
|
||||||
{
|
{
|
||||||
$dir_icon = '';
|
|
||||||
$alt_text = '';
|
$alt_text = '';
|
||||||
|
|
||||||
if (!empty($rr['uid']) && !empty($rr['rel'])) {
|
if (!empty($contact['uid']) && !empty($contact['rel'])) {
|
||||||
switch ($rr['rel']) {
|
switch ($contact['rel']) {
|
||||||
case Model\Contact::FRIEND:
|
case Model\Contact::FRIEND:
|
||||||
$dir_icon = 'images/lrarrow.gif';
|
|
||||||
$alt_text = DI::l10n()->t('Mutual Friendship');
|
$alt_text = DI::l10n()->t('Mutual Friendship');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Model\Contact::FOLLOWER;
|
case Model\Contact::FOLLOWER;
|
||||||
$dir_icon = 'images/larrow.gif';
|
|
||||||
$alt_text = DI::l10n()->t('is a fan of yours');
|
$alt_text = DI::l10n()->t('is a fan of yours');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Model\Contact::SHARING;
|
case Model\Contact::SHARING;
|
||||||
$dir_icon = 'images/rarrow.gif';
|
|
||||||
$alt_text = DI::l10n()->t('you are a fan of');
|
$alt_text = DI::l10n()->t('you are a fan of');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1036,7 +1033,7 @@ class Contact extends BaseModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = Model\Contact::magicLink($rr['url']);
|
$url = Model\Contact::magicLink($contact['url']);
|
||||||
|
|
||||||
if (strpos($url, 'redir/') === 0) {
|
if (strpos($url, 'redir/') === 0) {
|
||||||
$sparkle = ' class="sparkle" ';
|
$sparkle = ' class="sparkle" ';
|
||||||
|
@ -1044,37 +1041,36 @@ class Contact extends BaseModule
|
||||||
$sparkle = '';
|
$sparkle = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rr['pending']) {
|
if ($contact['pending']) {
|
||||||
if (in_array($rr['rel'], [Model\Contact::FRIEND, Model\Contact::SHARING])) {
|
if (in_array($contact['rel'], [Model\Contact::FRIEND, Model\Contact::SHARING])) {
|
||||||
$alt_text = DI::l10n()->t('Pending outgoing contact request');
|
$alt_text = DI::l10n()->t('Pending outgoing contact request');
|
||||||
} else {
|
} else {
|
||||||
$alt_text = DI::l10n()->t('Pending incoming contact request');
|
$alt_text = DI::l10n()->t('Pending incoming contact request');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rr['self']) {
|
if ($contact['self']) {
|
||||||
$dir_icon = 'images/larrow.gif';
|
|
||||||
$alt_text = DI::l10n()->t('This is you');
|
$alt_text = DI::l10n()->t('This is you');
|
||||||
$url = $rr['url'];
|
$url = $contact['url'];
|
||||||
$sparkle = '';
|
$sparkle = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'img_hover' => DI::l10n()->t('Visit %s\'s profile [%s]', $rr['name'], $rr['url']),
|
'id' => $contact['id'],
|
||||||
'edit_hover'=> DI::l10n()->t('Edit contact'),
|
'url' => $url,
|
||||||
'photo_menu'=> Model\Contact::photoMenu($rr),
|
'img_hover' => DI::l10n()->t('Visit %s\'s profile [%s]', $contact['name'], $contact['url']),
|
||||||
'id' => $rr['id'],
|
'photo_menu' => Model\Contact::photoMenu($contact),
|
||||||
'alt_text' => $alt_text,
|
'thumb' => Model\Contact::getThumb($contact),
|
||||||
'dir_icon' => $dir_icon,
|
'alt_text' => $alt_text,
|
||||||
'thumb' => Model\Contact::getThumb($rr),
|
'name' => $contact['name'],
|
||||||
'name' => $rr['name'],
|
'nick' => $contact['nick'],
|
||||||
'username' => $rr['name'],
|
'details' => $contact['location'],
|
||||||
'account_type' => Model\Contact::getAccountType($rr),
|
'tags' => $contact['keywords'],
|
||||||
'sparkle' => $sparkle,
|
'about' => $contact['about'],
|
||||||
'itemurl' => ($rr['addr'] ?? '') ?: $rr['url'],
|
'account_type' => Model\Contact::getAccountType($contact),
|
||||||
'url' => $url,
|
'sparkle' => $sparkle,
|
||||||
'network' => ContactSelector::networkToName($rr['network'], $rr['url'], $rr['protocol']),
|
'itemurl' => ($contact['addr'] ?? '') ?: $contact['url'],
|
||||||
'nick' => $rr['nick'],
|
'network' => ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Session;
|
use Friendica\Core\Session;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
@ -83,7 +83,10 @@ class Directory extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($profiles['entries'] as $entry) {
|
foreach ($profiles['entries'] as $entry) {
|
||||||
$entries[] = self::formatEntry($entry, $photo);
|
$contact = Model\Contact::getByURLForUser($entry['url'], local_user());
|
||||||
|
if (!empty($contact)) {
|
||||||
|
$entries[] = Contact::getContactTemplateVars($contact);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,18 +163,18 @@ class Directory extends BaseModule
|
||||||
$location_e = $location;
|
$location_e = $location;
|
||||||
|
|
||||||
$photo_menu = [
|
$photo_menu = [
|
||||||
'profile' => [DI::l10n()->t("View Profile"), Contact::magicLink($profile_link)]
|
'profile' => [DI::l10n()->t("View Profile"), Model\Contact::magicLink($profile_link)]
|
||||||
];
|
];
|
||||||
|
|
||||||
$entry = [
|
$entry = [
|
||||||
'id' => $contact['id'],
|
'id' => $contact['id'],
|
||||||
'url' => Contact::magicLink($profile_link),
|
'url' => Model\Contact::magicLink($profile_link),
|
||||||
'itemurl' => $itemurl,
|
'itemurl' => $itemurl,
|
||||||
'thumb' => Contact::getThumb($contact),
|
'thumb' => Model\Contact::getThumb($contact),
|
||||||
'img_hover' => $contact['name'],
|
'img_hover' => $contact['name'],
|
||||||
'name' => $contact['name'],
|
'name' => $contact['name'],
|
||||||
'details' => $details,
|
'details' => $details,
|
||||||
'account_type' => Contact::getAccountType($contact),
|
'account_type' => Model\Contact::getAccountType($contact),
|
||||||
'profile' => $profile,
|
'profile' => $profile,
|
||||||
'location' => $location_e,
|
'location' => $location_e,
|
||||||
'tags' => $contact['pub_keywords'],
|
'tags' => $contact['pub_keywords'],
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Profile;
|
namespace Friendica\Module\Profile;
|
||||||
|
|
||||||
use Friendica\Content\ContactSelector;
|
|
||||||
use Friendica\Content\Nav;
|
use Friendica\Content\Nav;
|
||||||
use Friendica\Content\Pager;
|
use Friendica\Content\Pager;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
|
@ -29,9 +28,9 @@ use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
use Friendica\Core\Session;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Module\BaseProfile;
|
use Friendica\Module\BaseProfile;
|
||||||
|
use Friendica\Module\Contact as ModuleContact;
|
||||||
|
|
||||||
class Contacts extends BaseProfile
|
class Contacts extends BaseProfile
|
||||||
{
|
{
|
||||||
|
@ -101,25 +100,7 @@ class Contacts extends BaseProfile
|
||||||
if ($contact['self']) {
|
if ($contact['self']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$contacts[] = ModuleContact::getContactTemplateVars($contact);
|
||||||
$contact_details = Contact::getByURLForUser($contact['url'], $a->profile['uid']) ?: $contact;
|
|
||||||
|
|
||||||
$contacts[] = [
|
|
||||||
'id' => $contact['id'],
|
|
||||||
'img_hover' => DI::l10n()->t('Visit %s\'s profile [%s]', $contact_details['name'], $contact['url']),
|
|
||||||
'photo_menu' => Contact::photoMenu($contact),
|
|
||||||
'thumb' => Contact::getThumb($contact_details),
|
|
||||||
'name' => substr($contact_details['name'], 0, 20),
|
|
||||||
'username' => $contact_details['name'],
|
|
||||||
'details' => $contact_details['location'],
|
|
||||||
'tags' => $contact_details['keywords'],
|
|
||||||
'about' => $contact_details['about'],
|
|
||||||
'account_type' => Contact::getAccountType($contact_details),
|
|
||||||
'url' => Contact::magicLink($contact['url']),
|
|
||||||
'sparkle' => '',
|
|
||||||
'itemurl' => $contact_details['addr'] ? : $contact['url'],
|
|
||||||
'network' => ContactSelector::networkToName($contact['network'], $contact['url'], $contact['protocol']),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DBA::close($contacts_stmt);
|
DBA::close($contacts_stmt);
|
||||||
|
|
Loading…
Reference in a new issue