Create new page_tabs template
- Replace explicit tabs in profile contacts page with new template
This commit is contained in:
parent
f5ea07c731
commit
383ddb10ed
8 changed files with 57 additions and 49 deletions
|
@ -171,4 +171,40 @@ abstract class BaseModule
|
||||||
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function getContactFilterTabs(string $baseUrl, string $current, bool $displayCommonTab)
|
||||||
|
{
|
||||||
|
$tabs = [
|
||||||
|
[
|
||||||
|
'label' => DI::l10n()->t('All contacts'),
|
||||||
|
'url' => $baseUrl . '/contacts',
|
||||||
|
'sel' => !$current || $current == 'all' ? 'active' : '',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => DI::l10n()->t('Followers'),
|
||||||
|
'url' => $baseUrl . '/contacts/followers',
|
||||||
|
'sel' => $current == 'followers' ? 'active' : '',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => DI::l10n()->t('Following'),
|
||||||
|
'url' => $baseUrl . '/contacts/following',
|
||||||
|
'sel' => $current == 'following' ? 'active' : '',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => DI::l10n()->t('Mutual friends'),
|
||||||
|
'url' => $baseUrl . '/contacts/mutuals',
|
||||||
|
'sel' => $current == 'mutuals' ? 'active' : '',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($displayCommonTab) {
|
||||||
|
$tabs[] = [
|
||||||
|
'label' => DI::l10n()->t('Common'),
|
||||||
|
'url' => $baseUrl . '/contacts/common',
|
||||||
|
'sel' => $current == 'common' ? 'active' : '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tabs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,6 @@ class Common extends BaseProfile
|
||||||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$o = self::getTabsHTML($a, 'contacts', false, $nickname);
|
|
||||||
|
|
||||||
if (!empty($a->profile['hide-friends'])) {
|
if (!empty($a->profile['hide-friends'])) {
|
||||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||||
}
|
}
|
||||||
|
@ -65,6 +63,10 @@ class Common extends BaseProfile
|
||||||
$a->redirect('profile/' . $nickname . '/contacts');
|
$a->redirect('profile/' . $nickname . '/contacts');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$o = self::getTabsHTML($a, 'contacts', false, $nickname);
|
||||||
|
|
||||||
|
$tabs = self::getContactFilterTabs('profile/' . $nickname, 'common', $displayCommonTab);
|
||||||
|
|
||||||
$sourceId = Contact::getIdForURL(Profile::getMyURL());
|
$sourceId = Contact::getIdForURL(Profile::getMyURL());
|
||||||
$targetId = Contact::getPublicIdByUserId($a->profile['uid']);
|
$targetId = Contact::getPublicIdByUserId($a->profile['uid']);
|
||||||
|
|
||||||
|
@ -92,15 +94,8 @@ class Common extends BaseProfile
|
||||||
$o .= Renderer::replaceMacros($tpl, [
|
$o .= Renderer::replaceMacros($tpl, [
|
||||||
'$title' => $title,
|
'$title' => $title,
|
||||||
'$desc' => $desc,
|
'$desc' => $desc,
|
||||||
'$nickname' => $nickname,
|
'$tabs' => $tabs,
|
||||||
'$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.'),
|
'$noresult_label' => DI::l10n()->t('No common contacts.'),
|
||||||
|
|
||||||
'$contacts' => $contacts,
|
'$contacts' => $contacts,
|
||||||
|
|
|
@ -61,6 +61,8 @@ class Contacts extends Module\BaseProfile
|
||||||
|
|
||||||
$o = self::getTabsHTML($a, 'contacts', $is_owner, $nickname);
|
$o = self::getTabsHTML($a, 'contacts', $is_owner, $nickname);
|
||||||
|
|
||||||
|
$tabs = self::getContactFilterTabs('profile/' . $nickname, $type, Session::isAuthenticated() && $a->profile['uid'] != local_user());
|
||||||
|
|
||||||
$condition = [
|
$condition = [
|
||||||
'uid' => $a->profile['uid'],
|
'uid' => $a->profile['uid'],
|
||||||
'blocked' => false,
|
'blocked' => false,
|
||||||
|
@ -113,15 +115,8 @@ class Contacts extends Module\BaseProfile
|
||||||
$o .= Renderer::replaceMacros($tpl, [
|
$o .= Renderer::replaceMacros($tpl, [
|
||||||
'$title' => $title,
|
'$title' => $title,
|
||||||
'$desc' => $desc,
|
'$desc' => $desc,
|
||||||
'$nickname' => $nickname,
|
'$tabs' => $tabs,
|
||||||
'$type' => $type,
|
|
||||||
'$displayCommonTab' => Session::isAuthenticated() && $a->profile['uid'] != local_user(),
|
|
||||||
|
|
||||||
'$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 contacts.'),
|
'$noresult_label' => DI::l10n()->t('No contacts.'),
|
||||||
|
|
||||||
'$contacts' => $contacts,
|
'$contacts' => $contacts,
|
||||||
|
|
1
view/templates/page_tabs.tpl
Normal file
1
view/templates/page_tabs.tpl
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{{include file="common_tabs.tpl" tabs=$tabs}}
|
|
@ -5,15 +5,8 @@
|
||||||
<p>{{$desc nofilter}}</p>
|
<p>{{$desc nofilter}}</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<ul role="menubar" class="tabs">
|
{{include file="page_tabs.tpl" tabs=$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}}
|
{{if $contacts}}
|
||||||
<div id="viewcontact_wrapper-{{$id}}">
|
<div id="viewcontact_wrapper-{{$id}}">
|
||||||
{{foreach $contacts as $contact}}
|
{{foreach $contacts as $contact}}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<ul role="menubar" class="tabbar list-inline visible-lg visible-md visible-sm hidden-xs">
|
<ul role="menubar" class="tabbar list-inline visible-lg visible-md visible-sm hidden-xs">
|
||||||
{{* The normal tabbar *}}
|
{{* The normal tabbar *}}
|
||||||
<li>
|
<li>
|
||||||
<ul class="tabs flex-nav" role="menu" >
|
<ul class="tabs flex-nav" role="menu" >
|
||||||
{{foreach $tabs as $tab}}
|
{{foreach $tabs as $tab}}
|
||||||
<li id="{{$tab.id}}" role="presentation" {{if $tab.sel}} class="{{$tab.sel}}" {{/if}}><a role="menuitem" href="{{$tab.url}}" {{if $tab.accesskey}}accesskey="{{$tab.accesskey}}"{{/if}} {{if $tab.title}} title="{{$tab.title}}"{{/if}}>{{$tab.label}}</a></li>
|
<li id="{{$tab.id}}" role="presentation" {{if $tab.sel}} class="{{$tab.sel}}" {{/if}}><a role="menuitem" href="{{$tab.url}}" {{if $tab.accesskey}}accesskey="{{$tab.accesskey}}"{{/if}} {{if $tab.title}} title="{{$tab.title}}"{{/if}}>{{$tab.label}}</a></li>
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
@ -36,8 +36,6 @@
|
||||||
{{$exttabs[]=$tab}}
|
{{$exttabs[]=$tab}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
7
view/theme/frio/templates/page_tabs.tpl
Normal file
7
view/theme/frio/templates/page_tabs.tpl
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
{{foreach $tabs as $tab}}
|
||||||
|
<li id="{{$tab.id}}" role="presentation"{{if $tab.sel}} class="{{$tab.sel}}"{{/if}}>
|
||||||
|
<a role="menuitem" href="{{$tab.url}}"{{if $tab.accesskey}} accesskey="{{$tab.accesskey}}"{{/if}}{{if $tab.title}} title="{{$tab.title}}"{{/if}}>{{$tab.label}}</a>
|
||||||
|
</li>
|
||||||
|
{{/foreach}}
|
||||||
|
</ul>
|
|
@ -5,25 +5,8 @@
|
||||||
<p>{{$desc nofilter}}</p>
|
<p>{{$desc nofilter}}</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<ul class="nav nav-tabs">
|
{{include file="page_tabs.tpl" tabs=$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}}
|
{{if $contacts}}
|
||||||
<ul id="viewcontact_wrapper{{if $id}}-{{$id}}{{/if}}" class="viewcontact_wrapper media-list">
|
<ul id="viewcontact_wrapper{{if $id}}-{{$id}}{{/if}}" class="viewcontact_wrapper media-list">
|
||||||
{{foreach $contacts as $contact}}
|
{{foreach $contacts as $contact}}
|
||||||
|
|
Loading…
Reference in a new issue