Merge pull request #8975 from MrPetovan/task/8918-move-mod-common

Move mod/common.php to src/ Part 2: Add Module\Profile\Common class
This commit is contained in:
Michael Vogel 2020-08-05 23:17:12 +02:00 committed by GitHub
commit 1fb47b96aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 258 additions and 140 deletions

View file

@ -266,7 +266,7 @@ function public_contact()
}
/**
* Returns contact id of authenticated site visitor or false
* Returns public contact id of authenticated site visitor or false
*
* @return int|bool visitor_id or false
*/

View file

@ -374,81 +374,59 @@ class Widget
}
/**
* Return common friends visitor widget
* Show a random selection of five common contacts between the visitor and the viewed profile user.
*
* @param string $profile_uid uid
* @param int $uid Viewed profile user ID
* @param string $nickname Viewed profile user nickname
* @return string|void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
public static function commonFriendsVisitor($profile_uid)
public static function commonFriendsVisitor(int $uid, string $nickname)
{
if (local_user() == $profile_uid) {
return;
if (local_user() == $uid) {
return '';
}
$zcid = 0;
$cid = Session::getRemoteContactID($profile_uid);
if (!$cid) {
if (Profile::getMyURL()) {
$contact = DBA::selectFirst('contact', ['id'],
['nurl' => Strings::normaliseLink(Profile::getMyURL()), 'uid' => $profile_uid]);
if (DBA::isResult($contact)) {
$cid = $contact['id'];
} else {
$gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => Strings::normaliseLink(Profile::getMyURL())]);
if (DBA::isResult($gcontact)) {
$zcid = $gcontact['id'];
}
}
}
$visitorPCid = local_user() ? Contact::getPublicIdByUserId(local_user()) : remote_user();
if (!$visitorPCid) {
return '';
}
if ($cid == 0 && $zcid == 0) {
return;
$localPCid = Contact::getPublicIdByUserId($uid);
$condition = [
'NOT `self` AND NOT `blocked` AND NOT `hidden` AND `id` != ?',
$localPCid,
];
$total = Contact\Relation::countCommon($localPCid, $visitorPCid, $condition);
if (!$total) {
return '';
}
if ($cid) {
$t = GContact::countCommonFriends($profile_uid, $cid);
} else {
$t = GContact::countCommonFriendsZcid($profile_uid, $zcid);
}
if (!$t) {
return;
}
if ($cid) {
$r = GContact::commonFriends($profile_uid, $cid, 0, 5, true);
} else {
$r = GContact::commonFriendsZcid($profile_uid, $zcid, 0, 5, true);
}
if (!DBA::isResult($r)) {
return;
$commonContacts = Contact\Relation::listCommon($localPCid, $visitorPCid, $condition, 0, 5, true);
if (!DBA::isResult($commonContacts)) {
return '';
}
$entries = [];
foreach ($r as $rr) {
$contact = Contact::getByURL($rr['url']);
$entry = [
'url' => Contact::magicLink($rr['url']),
'name' => $contact['name'] ?? $rr['name'],
'photo' => Contact::getThumb($contact, $rr['photo']),
foreach ($commonContacts as $contact) {
$entries[] = [
'url' => Contact::magicLink($contact['url']),
'name' => $contact['name'],
'photo' => Contact::getThumb($contact),
];
$entries[] = $entry;
}
$tpl = Renderer::getMarkupTemplate('widget/remote_friends_common.tpl');
return Renderer::replaceMacros($tpl, [
'$desc' => DI::l10n()->tt("%d contact in common", "%d contacts in common", $t),
'$desc' => DI::l10n()->tt("%d contact in common", "%d contacts in common", $total),
'$base' => DI::baseUrl(),
'$uid' => $profile_uid,
'$cid' => (($cid) ? $cid : '0'),
'$linkmore' => (($t > 5) ? 'true' : ''),
'$nickname' => $nickname,
'$linkmore' => $total > 5 ? 'true' : '',
'$more' => DI::l10n()->t('show more'),
'$items' => $entries
'$contacts' => $entries
]);
}

View file

@ -65,10 +65,10 @@ class Session
}
/**
* Returns contact ID for given user ID
* Return the user contact ID of a visitor for the given user ID they are visiting
*
* @param integer $uid User ID
* @return integer Contact ID of visitor for given user ID
* @return integer
*/
public static function getRemoteContactID($uid)
{

View file

@ -431,7 +431,7 @@ class Relation
* @return array
* @throws Exception
*/
public static function listCommon(int $sourceId, int $targetId, array $fields = [], array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
public static function listCommon(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
{
$condition = DBA::mergeConditions($condition,
["`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
@ -439,7 +439,7 @@ class Relation
$sourceId, $targetId]
);
return DI::dba()->selectToArray('contact', $fields, $condition,
return DI::dba()->selectToArray('contact', [], $condition,
['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
);
}
@ -470,7 +470,6 @@ class Relation
*
* @param int $sourceId Public contact id
* @param int $targetId Public contact id
* @param array $field Field list
* @param array $condition Additional condition array on the contact table
* @param int $count
* @param int $offset
@ -478,7 +477,7 @@ class Relation
* @return array
* @throws Exception
*/
public static function listCommonFollows(int $sourceId, int $targetId, array $fields = [], array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
public static function listCommonFollows(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
{
$condition = DBA::mergeConditions($condition,
["`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
@ -486,7 +485,7 @@ class Relation
$sourceId, $targetId]
);
return DI::dba()->selectToArray('contact', $fields, $condition,
return DI::dba()->selectToArray('contact', [], $condition,
['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
);
}
@ -516,7 +515,6 @@ class Relation
*
* @param int $sourceId Public contact id
* @param int $targetId Public contact id
* @param array $field Field list
* @param array $condition Additional condition on the contact table
* @param int $count
* @param int $offset
@ -524,7 +522,7 @@ class Relation
* @return array
* @throws Exception
*/
public static function listCommonFollowers(int $sourceId, int $targetId, array $fields = [], array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
public static function listCommonFollowers(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
{
$condition = DBA::mergeConditions($condition,
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)
@ -532,7 +530,7 @@ class Relation
$sourceId, $targetId]
);
return DI::dba()->selectToArray('contact', $fields, $condition,
return DI::dba()->selectToArray('contact', [], $condition,
['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
);
}

View file

@ -46,7 +46,7 @@ class GContact
$sourceId,
];
return Contact\Relation::countCommonFollows($sourceId, $targetIds['public'] ?? 0, [], $condition);
return Contact\Relation::countCommonFollows($sourceId, $targetIds['public'] ?? 0, $condition);
}
/**
@ -74,7 +74,7 @@ LIMIT 1",
$sourceId,
];
return Contact\Relation::countCommonFollowers($sourceId, $targetPublicContact['id'] ?? 0, [], $condition);
return Contact\Relation::countCommonFollowers($sourceId, $targetPublicContact['id'] ?? 0, $condition);
}
/**
@ -100,7 +100,7 @@ LIMIT 1",
$sourceId,
];
return Contact\Relation::listCommonFollows($sourceId, $targetIds['public'] ?? 0, [], $condition, $limit, $start, $shuffle);
return Contact\Relation::listCommonFollows($sourceId, $targetIds['public'] ?? 0, $condition, $limit, $start, $shuffle);
}
/**
@ -134,6 +134,6 @@ LIMIT 1",
$sourceId,
];
return Contact\Relation::listCommonFollows($sourceId, $targetPublicContact['id'] ?? 0, [], $condition, $limit, $start, $shuffle);
return Contact\Relation::listCommonFollows($sourceId, $targetPublicContact['id'] ?? 0, $condition, $limit, $start, $shuffle);
}
}

View file

@ -1030,7 +1030,7 @@ class Contact extends BaseModule
}
}
if (!empty($contact['uid']) && !empty($contact['rel'])) {
if (!empty($contact['uid']) && !empty($contact['rel']) && local_user() == $contact['uid']) {
switch ($contact['rel']) {
case Model\Contact::FRIEND:
$alt_text = DI::l10n()->t('Mutual Friendship');

View file

@ -0,0 +1,112 @@
<?php
/**
* @copyright Copyright (C) 2020, Friendica
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Module\Profile;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Module;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Module\BaseProfile;
use Friendica\Network\HTTPException;
class Common extends BaseProfile
{
public static function content(array $parameters = [])
{
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
$a = DI::app();
Nav::setSelected('home');
$nickname = $parameters['nickname'];
Profile::load($a, $nickname);
if (empty($a->profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
$o = self::getTabsHTML($a, 'contacts', false, $nickname);
if (!empty($a->profile['hide-friends'])) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$displayCommonTab = Session::isAuthenticated() && $a->profile['uid'] != local_user();
if (!$displayCommonTab) {
$a->redirect('profile/' . $nickname . '/contacts');
};
$sourceId = Contact::getIdForURL(Profile::getMyURL());
$targetId = Contact::getPublicIdByUserId($a->profile['uid']);
$condition = [
'blocked' => false,
'deleted' => false,
'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::FEED],
];
$total = Contact\Relation::countCommon($sourceId, $targetId, $condition);
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
$commonFollows = Contact\Relation::listCommon($sourceId, $targetId, $condition, $pager->getItemsPerPage(), $pager->getStart());
$contacts = array_map([Module\Contact::class, 'getContactTemplateVars'], $commonFollows);
$title = DI::l10n()->tt('Common contact (%s)', 'Common contacts (%s)', $total);
$desc = DI::l10n()->t(
'Both <strong>%s</strong> and yourself have publicly interacted with these contacts (follow, comment or likes on public posts).',
htmlentities($a->profile['name'], ENT_COMPAT, 'UTF-8')
);
$tpl = Renderer::getMarkupTemplate('profile/contacts.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$title' => $title,
'$desc' => $desc,
'$nickname' => $nickname,
'$type' => 'common',
'$displayCommonTab' => $displayCommonTab,
'$all_label' => DI::l10n()->t('All contacts'),
'$followers_label' => DI::l10n()->t('Followers'),
'$following_label' => DI::l10n()->t('Following'),
'$mutuals_label' => DI::l10n()->t('Mutual friends'),
'$common_label' => DI::l10n()->t('Common'),
'$noresult_label' => DI::l10n()->t('No common contacts.'),
'$contacts' => $contacts,
'$paginate' => $pager->renderFull($total),
]);
return $o;
}
}

View file

@ -28,57 +28,53 @@ use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Profile;
use Friendica\Module\BaseProfile;
use Friendica\Module\Contact as ModuleContact;
use Friendica\Model;
use Friendica\Module;
use Friendica\Network\HTTPException;
class Contacts extends BaseProfile
class Contacts extends Module\BaseProfile
{
public static function content(array $parameters = [])
{
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
throw new \Friendica\Network\HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
$a = DI::app();
//@TODO: Get value from router parameters
$nickname = $a->argv[1];
$type = ($a->argv[3] ?? '') ?: 'all';
$nickname = $parameters['nickname'];
$type = $parameters['type'] ?? 'all';
Nav::setSelected('home');
Model\Profile::load($a, $nickname);
$user = DBA::selectFirst('user', [], ['nickname' => $nickname, 'blocked' => false]);
if (!DBA::isResult($user)) {
throw new \Friendica\Network\HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
if (empty($a->profile)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
$a->profile_uid = $user['uid'];
if (!empty($a->profile['hide-friends'])) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
Profile::load($a, $nickname);
Nav::setSelected('home');
$is_owner = $a->profile['uid'] == local_user();
$o = self::getTabsHTML($a, 'contacts', $is_owner, $nickname);
if (!count($a->profile) || $a->profile['hide-friends']) {
notice(DI::l10n()->t('Permission denied.'));
return $o;
}
$condition = [
'uid' => $a->profile['uid'],
'blocked' => false,
'pending' => false,
'hidden' => false,
'archive' => false,
'self' => false,
'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::FEED]
];
switch ($type) {
case 'followers': $condition['rel'] = [1, 3]; break;
case 'following': $condition['rel'] = [2, 3]; break;
case 'mutuals': $condition['rel'] = 3; break;
case 'followers': $condition['rel'] = [Model\Contact::FOLLOWER, Model\Contact::FRIEND]; break;
case 'following': $condition['rel'] = [Model\Contact::SHARING, Model\Contact::FRIEND]; break;
case 'mutuals': $condition['rel'] = Model\Contact::FRIEND; break;
}
$total = DBA::count('contact', $condition);
@ -87,42 +83,46 @@ class Contacts extends BaseProfile
$params = ['order' => ['name' => false], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
$contacts_stmt = DBA::select('contact', [], $condition, $params);
if (!DBA::isResult($contacts_stmt)) {
notice(DI::l10n()->t('No contacts.'));
return $o;
}
$contacts = [];
while ($contact = DBA::fetch($contacts_stmt)) {
if ($contact['self']) {
continue;
}
$contacts[] = ModuleContact::getContactTemplateVars($contact);
}
DBA::close($contacts_stmt);
$contacts = array_map(
[Module\Contact::class, 'getContactTemplateVars'],
Model\Contact::selectToArray([], $condition, $params)
);
$desc = '';
switch ($type) {
case 'followers': $title = DI::l10n()->tt('Follower (%s)', 'Followers (%s)', $total); break;
case 'following': $title = DI::l10n()->tt('Following (%s)', 'Following (%s)', $total); break;
case 'mutuals': $title = DI::l10n()->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total); break;
case 'all': default: $title = DI::l10n()->tt('Contact (%s)', 'Contacts (%s)', $total); break;
case 'followers':
$title = DI::l10n()->tt('Follower (%s)', 'Followers (%s)', $total);
break;
case 'following':
$title = DI::l10n()->tt('Following (%s)', 'Following (%s)', $total);
break;
case 'mutuals':
$title = DI::l10n()->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total);
$desc = DI::l10n()->t(
'These contacts both follow and are followed by <strong>%s</strong>.',
htmlentities($a->profile['name'], ENT_COMPAT, 'UTF-8')
);
break;
case 'all':
default:
$title = DI::l10n()->tt('Contact (%s)', 'Contacts (%s)', $total);
break;
}
$tpl = Renderer::getMarkupTemplate('profile/contacts.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$title' => $title,
'$desc' => $desc,
'$nickname' => $nickname,
'$type' => $type,
'$displayCommonTab' => Session::isAuthenticated() && $a->profile['uid'] != local_user(),
'$all_label' => DI::l10n()->t('All contacts'),
'$all_label' => DI::l10n()->t('All contacts'),
'$followers_label' => DI::l10n()->t('Followers'),
'$following_label' => DI::l10n()->t('Following'),
'$mutuals_label' => DI::l10n()->t('Mutual friends'),
'$mutuals_label' => DI::l10n()->t('Mutual friends'),
'$common_label' => DI::l10n()->t('Common'),
'$noresult_label' => DI::l10n()->t('No contacts.'),
'$contacts' => $contacts,
'$paginate' => $pager->renderFull($total),

View file

@ -108,7 +108,7 @@ class Status extends BaseProfile
$o .= self::getTabsHTML($a, 'status', $is_owner, $a->profile['nickname']);
$o .= Widget::commonFriendsVisitor($a->profile['uid']);
$o .= Widget::commonFriendsVisitor($a->profile['uid'], $a->profile['nickname']);
$commpage = $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
$commvisitor = $commpage && $remote_contact;

View file

@ -252,6 +252,7 @@ return [
'/profile' => [
'/{nickname}' => [Module\Profile\Index::class, [R::GET]],
'/{nickname}/profile' => [Module\Profile\Profile::class, [R::GET]],
'/{nickname}/contacts/common' => [Module\Profile\Common::class, [R::GET]],
'/{nickname}/contacts[/{type}]' => [Module\Profile\Contacts::class, [R::GET]],
'/{nickname}/status[/{category}[/{date1}[/{date2}]]]' => [Module\Profile\Status::class, [R::GET]],
],

View file

@ -1,18 +1,29 @@
<div class="generic-page-wrapper">
{{include file="section_title.tpl"}}
{{if $desc}}
<p>{{$desc nofilter}}</p>
{{/if}}
<ul role="menubar" class="tabs">
<li role="menuitem"><a href="profile/{{$nickname}}/contacts" class="tab button{{if !$type || $type == 'all'}} active{{/if}}">{{$all_label}}</a></li>
<li role="menuitem"><a href="profile/{{$nickname}}/contacts/followers" class="tab button{{if $type == 'followers'}} active{{/if}}">{{$followers_label}}</a></li>
<li role="menuitem"><a href="profile/{{$nickname}}/contacts/following" class="tab button{{if $type == 'following'}} active{{/if}}">{{$following_label}}</a></li>
<li role="menuitem"><a href="profile/{{$nickname}}/contacts/mutuals" class="tab button{{if $type == 'mutuals'}} active{{/if}}">{{$mutuals_label}}</a></li>
{{if $displayCommonTab}}
<li role="menuitem"><a href="profile/{{$nickname}}/contacts/common" class="tab button{{if $type == 'common'}} active{{/if}}{{if !$common_count}} disabled{{/if}}">{{$common_label}}</a></li>
{{/if}}
</ul>
{{if $contacts}}
<div id="viewcontact_wrapper-{{$id}}">
{{foreach $contacts as $contact}}
{{foreach $contacts as $contact}}
{{include file="contact_template.tpl"}}
{{/foreach}}
{{/foreach}}
</div>
{{else}}
<div class="alert alert-info" role="alert">{{$noresult_label}}</div>
{{/if}}
<div class="clear"></div>
<div id="view-contact-end"></div>

View file

@ -1,22 +1,18 @@
<div id="remote-friends-in-common" class="bigwidget">
<div id="rfic-desc">{{$desc nofilter}} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{if $linkmore}}<a href="{{$base}}/common/rem/{{$uid}}/{{$cid}}">{{$more}}</a>{{/if}}</div>
{{if $items}}
{{foreach $items as $item}}
<div id="rfic-desc">{{$desc nofilter}} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{if $linkmore}}<a href="profile/{{$nickname}}/contacts/common">{{$more}}</a>{{/if}}</div>
{{foreach $contacts as $contact}}
<div class="profile-match-wrapper">
<div class="profile-match-photo">
<a href="{{$item.url}}">
<img src="{{$item.photo}}" width="80" height="80" alt="{{$item.name}}" title="{{$item.name}}" />
<a href="{{$contact.url}}">
<img src="{{$contact.photo}}" width="80" height="80" alt="{{$contact.name}}" title="{{$contact.name}}" />
</a>
</div>
<div class="profile-match-break"></div>
<div class="profile-match-name">
<a href="{{$item.url}}" title="{{$item.name}}">{{$item.name}}</a>
<a href="{{$contact.url}}" title="{{$contact.name}}">{{$contact.name}}</a>
</div>
<div class="profile-match-end"></div>
</div>
{{/foreach}}
{{/if}}
<div id="rfic-end" class="clear"></div>
</div>

View file

@ -6,7 +6,9 @@
<div class="contact-entry-photo mframe" id="contact-entry-photo-{{$contact.id}}">
<div class="contact-photo-image-wrapper hidden-xs">
<img class="contact-photo media-object xl" src="{{$contact.thumb}}" {{$contact.sparkle}} alt="{{$contact.name}}" />
<a href="{{$contact.url}}">
<img class="contact-photo media-object xl" src="{{$contact.thumb}}" {{$contact.sparkle}} alt="{{$contact.name}}" />
</a>
</div>
{{* For very small displays we use a dropdown menu for contact relating actions *}}

View file

@ -1,18 +1,38 @@
<div class="generic-page-wrapper">
{{include file="section_title.tpl"}}
<ul class="nav nav-tabs">
<li role="presentation"{{if !$type || $type == 'all'}} class="active"{{/if}}><a href="profile/{{$nickname}}/contacts">{{$all_label}}</a></li>
<li role="presentation"{{if $type == 'followers'}} class="active"{{/if}}><a href="profile/{{$nickname}}/contacts/followers">{{$followers_label}}</a></li>
<li role="presentation"{{if $type == 'following'}} class="active"{{/if}}><a href="profile/{{$nickname}}/contacts/following">{{$following_label}}</a></li>
<li role="presentation"{{if $type == 'mutuals'}} class="active"{{/if}}><a href="profile/{{$nickname}}/contacts/mutuals">{{$mutuals_label}}</a></li>
</ul>
{{if $desc}}
<p>{{$desc nofilter}}</p>
{{/if}}
<ul id="viewcontact_wrapper{{if $id}}-{{$id}}{{/if}}" class="viewcontact_wrapper media-list">
{{foreach $contacts as $contact}}
<li>{{include file="contact_template.tpl"}}</li>
{{/foreach}}
<ul class="nav nav-tabs">
<li role="presentation"{{if !$type || $type == 'all'}} class="active"{{/if}}>
<a href="profile/{{$nickname}}/contacts">{{$all_label}}</a>
</li>
<li role="presentation"{{if $type == 'followers'}} class="active"{{/if}}>
<a href="profile/{{$nickname}}/contacts/followers">{{$followers_label}}</a>
</li>
<li role="presentation"{{if $type == 'following'}} class="active"{{/if}}>
<a href="profile/{{$nickname}}/contacts/following">{{$following_label}}</a>
</li>
<li role="presentation"{{if $type == 'mutuals'}} class="active"{{/if}}>
<a href="profile/{{$nickname}}/contacts/mutuals">{{$mutuals_label}}</a>
</li>
{{if $displayCommonTab}}
<li role="presentation"{{if $type == 'common'}} class="active"{{/if}}>
<a href="profile/{{$nickname}}/contacts/common" class="tab button">{{$common_label}}</a>
</li>
{{/if}}
</ul>
{{if $contacts}}
<ul id="viewcontact_wrapper{{if $id}}-{{$id}}{{/if}}" class="viewcontact_wrapper media-list">
{{foreach $contacts as $contact}}
<li>{{include file="contact_template.tpl"}}</li>
{{/foreach}}
</ul>
{{else}}
<div class="alert alert-info" role="alert">{{$noresult_label}}</div>
{{/if}}
<div class="clear"></div>
<div id="view-contact-end"></div>