Add current tab parameter to Model\Profile::getTabs
This commit is contained in:
parent
709eba6ce3
commit
c65faecc8c
|
@ -147,7 +147,7 @@ function cal_content(App $a)
|
|||
$sql_extra = " AND `event`.`cid` = 0 " . $sql_perms;
|
||||
|
||||
// get the tab navigation bar
|
||||
$tabs = Profile::getTabs($a, false, $a->data['user']['nickname']);
|
||||
$tabs = Profile::getTabs($a, 'cal', false, $a->data['user']['nickname']);
|
||||
|
||||
// The view mode part is similiar to /mod/events.php
|
||||
if ($mode == 'view') {
|
||||
|
|
|
@ -246,7 +246,7 @@ function events_content(App $a)
|
|||
$tabs = '';
|
||||
// tabs
|
||||
if ($a->theme_events_in_profile) {
|
||||
$tabs = Profile::getTabs($a, true);
|
||||
$tabs = Profile::getTabs($a, 'events', true);
|
||||
}
|
||||
|
||||
$mode = 'view';
|
||||
|
|
|
@ -28,7 +28,7 @@ function notes_content(App $a, $update = false)
|
|||
return;
|
||||
}
|
||||
|
||||
$o = Profile::getTabs($a, true);
|
||||
$o = Profile::getTabs($a, 'notes', true);
|
||||
|
||||
if (!$update) {
|
||||
$o .= '<h3>' . L10n::t('Personal Notes') . '</h3>';
|
||||
|
|
|
@ -950,7 +950,7 @@ function photos_content(App $a)
|
|||
|
||||
// tabs
|
||||
$is_owner = (local_user() && (local_user() == $owner_uid));
|
||||
$o .= Profile::getTabs($a, $is_owner, $a->data['user']['nickname']);
|
||||
$o .= Profile::getTabs($a, 'photos', $is_owner, $a->data['user']['nickname']);
|
||||
|
||||
// Display upload form
|
||||
if ($datatype === 'upload') {
|
||||
|
|
|
@ -217,7 +217,7 @@ function videos_content(App $a)
|
|||
|
||||
// tabs
|
||||
$_is_owner = (local_user() && (local_user() == $owner_uid));
|
||||
$o .= Profile::getTabs($a, $_is_owner, $a->data['user']['nickname']);
|
||||
$o .= Profile::getTabs($a, 'videos', $_is_owner, $a->data['user']['nickname']);
|
||||
|
||||
//
|
||||
// dispatch request
|
||||
|
|
|
@ -877,32 +877,35 @@ class Profile
|
|||
return '';
|
||||
}
|
||||
|
||||
public static function getTabs($a, $is_owner = false, $nickname = null)
|
||||
/**
|
||||
* @param App $a
|
||||
* @param string $current
|
||||
* @param bool $is_owner
|
||||
* @param string $nickname
|
||||
* @return string
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function getTabs(App $a, string $current, bool $is_owner, string $nickname = null)
|
||||
{
|
||||
if (is_null($nickname)) {
|
||||
$nickname = $a->user['nickname'];
|
||||
}
|
||||
|
||||
$tab = false;
|
||||
if (!empty($_GET['tab'])) {
|
||||
$tab = Strings::escapeTags(trim($_GET['tab']));
|
||||
}
|
||||
|
||||
$url = System::baseUrl() . '/profile/' . $nickname;
|
||||
$baseProfileUrl = System::baseUrl() . '/profile/' . $nickname;
|
||||
|
||||
$tabs = [
|
||||
[
|
||||
'label' => L10n::t('Status'),
|
||||
'url' => $url,
|
||||
'sel' => !$tab && $a->argv[0] == 'profile' && (empty($a->argv[2]) || $a->argv[2] !== 'contacts') ? 'active' : '',
|
||||
'url' => $baseProfileUrl,
|
||||
'sel' => !$current ? 'active' : '',
|
||||
'title' => L10n::t('Status Messages and Posts'),
|
||||
'id' => 'status-tab',
|
||||
'accesskey' => 'm',
|
||||
],
|
||||
[
|
||||
'label' => L10n::t('Profile'),
|
||||
'url' => $url . '/?tab=profile',
|
||||
'sel' => $tab == 'profile' ? 'active' : '',
|
||||
'url' => $baseProfileUrl . '/?tab=profile',
|
||||
'sel' => $current == 'profile' ? 'active' : '',
|
||||
'title' => L10n::t('Profile Details'),
|
||||
'id' => 'profile-tab',
|
||||
'accesskey' => 'r',
|
||||
|
@ -910,7 +913,7 @@ class Profile
|
|||
[
|
||||
'label' => L10n::t('Photos'),
|
||||
'url' => System::baseUrl() . '/photos/' . $nickname,
|
||||
'sel' => !$tab && $a->argv[0] == 'photos' ? 'active' : '',
|
||||
'sel' => $current == 'photos' ? 'active' : '',
|
||||
'title' => L10n::t('Photo Albums'),
|
||||
'id' => 'photo-tab',
|
||||
'accesskey' => 'h',
|
||||
|
@ -918,7 +921,7 @@ class Profile
|
|||
[
|
||||
'label' => L10n::t('Videos'),
|
||||
'url' => System::baseUrl() . '/videos/' . $nickname,
|
||||
'sel' => !$tab && $a->argv[0] == 'videos' ? 'active' : '',
|
||||
'sel' => $current == 'videos' ? 'active' : '',
|
||||
'title' => L10n::t('Videos'),
|
||||
'id' => 'video-tab',
|
||||
'accesskey' => 'v',
|
||||
|
@ -930,7 +933,7 @@ class Profile
|
|||
$tabs[] = [
|
||||
'label' => L10n::t('Events'),
|
||||
'url' => System::baseUrl() . '/events',
|
||||
'sel' => !$tab && $a->argv[0] == 'events' ? 'active' : '',
|
||||
'sel' => $current == 'events' ? 'active' : '',
|
||||
'title' => L10n::t('Events and Calendar'),
|
||||
'id' => 'events-tab',
|
||||
'accesskey' => 'e',
|
||||
|
@ -941,7 +944,7 @@ class Profile
|
|||
$tabs[] = [
|
||||
'label' => L10n::t('Events'),
|
||||
'url' => System::baseUrl() . '/cal/' . $nickname,
|
||||
'sel' => !$tab && $a->argv[0] == 'cal' ? 'active' : '',
|
||||
'sel' => $current == 'cal' ? 'active' : '',
|
||||
'title' => L10n::t('Events and Calendar'),
|
||||
'id' => 'events-tab',
|
||||
'accesskey' => 'e',
|
||||
|
@ -952,7 +955,7 @@ class Profile
|
|||
$tabs[] = [
|
||||
'label' => L10n::t('Personal Notes'),
|
||||
'url' => System::baseUrl() . '/notes',
|
||||
'sel' => !$tab && $a->argv[0] == 'notes' ? 'active' : '',
|
||||
'sel' => $current == 'notes' ? 'active' : '',
|
||||
'title' => L10n::t('Only You Can See This'),
|
||||
'id' => 'notes-tab',
|
||||
'accesskey' => 't',
|
||||
|
@ -972,15 +975,15 @@ class Profile
|
|||
if ($is_owner || empty($a->profile['hide-friends'])) {
|
||||
$tabs[] = [
|
||||
'label' => L10n::t('Contacts'),
|
||||
'url' => System::baseUrl() . '/profile/' . $nickname . '/contacts',
|
||||
'sel' => !$tab && !empty($a->argv[2]) && $a->argv[2] == 'contacts' ? 'active' : '',
|
||||
'url' => $baseProfileUrl . '/contacts',
|
||||
'sel' => $current == 'contacts' ? 'active' : '',
|
||||
'title' => L10n::t('Contacts'),
|
||||
'id' => 'viewcontacts-tab',
|
||||
'accesskey' => 'k',
|
||||
];
|
||||
}
|
||||
|
||||
$arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $tab, 'tabs' => $tabs];
|
||||
$arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $current, 'tabs' => $tabs];
|
||||
Hook::callAll('profile_tabs', $arr);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
|
||||
|
|
|
@ -178,12 +178,9 @@ class Profile extends BaseModule
|
|||
}
|
||||
|
||||
if (!$update) {
|
||||
$tab = false;
|
||||
if (!empty($_GET['tab'])) {
|
||||
$tab = Strings::escapeTags(trim($_GET['tab']));
|
||||
}
|
||||
$tab = Strings::escapeTags(trim(defaults($_GET, 'tab', '')));
|
||||
|
||||
$o .= ProfileModel::getTabs($a, $is_owner, $a->profile['nickname']);
|
||||
$o .= ProfileModel::getTabs($a, $tab, $is_owner, $a->profile['nickname']);
|
||||
|
||||
if ($tab === 'profile') {
|
||||
$o .= ProfileModel::getAdvanced($a);
|
||||
|
|
|
@ -44,7 +44,7 @@ class Contacts extends BaseModule
|
|||
$is_owner = $a->profile['profile_uid'] == local_user();
|
||||
|
||||
// tabs
|
||||
$o = Profile::getTabs($a, $is_owner, $nickname);
|
||||
$o = Profile::getTabs($a, 'contacts', $is_owner, $nickname);
|
||||
|
||||
if (!count($a->profile) || $a->profile['hide-friends']) {
|
||||
notice(L10n::t('Permission denied.') . EOL);
|
||||
|
|
Loading…
Reference in New Issue
Block a user