3 * @copyright Copyright (C) 2010-2021, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module;
25 use Friendica\BaseModule;
26 use Friendica\Core\Hook;
27 use Friendica\Core\Renderer;
30 class BaseProfile extends BaseModule
33 * Returns the HTML for the profile pages tabs
36 * @param string $current
37 * @param bool $is_owner
38 * @param string $nickname
40 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
42 public static function getTabsHTML(App $a, string $current, bool $is_owner, array $profile)
44 $nickname = $profile['nickname'];
46 $baseProfileUrl = DI::baseUrl() . '/profile/' . $nickname;
50 'label' => DI::l10n()->t('Profile'),
51 'url' => $baseProfileUrl . '/profile',
52 'sel' => $current == 'profile' ? 'active' : '',
53 'title' => DI::l10n()->t('Profile Details'),
54 'id' => 'profile-tab',
58 'label' => DI::l10n()->t('Status'),
59 'url' => $baseProfileUrl . '/status',
60 'sel' => $current == 'status' ? 'active' : '',
61 'title' => DI::l10n()->t('Status Messages and Posts'),
66 'label' => DI::l10n()->t('Photos'),
67 'url' => DI::baseUrl() . '/photos/' . $nickname,
68 'sel' => $current == 'photos' ? 'active' : '',
69 'title' => DI::l10n()->t('Photo Albums'),
74 'label' => DI::l10n()->t('Videos'),
75 'url' => DI::baseUrl() . '/videos/' . $nickname,
76 'sel' => $current == 'videos' ? 'active' : '',
77 'title' => DI::l10n()->t('Videos'),
83 // the calendar link for the full featured events calendar
84 if ($is_owner && $a->theme_events_in_profile) {
86 'label' => DI::l10n()->t('Events'),
87 'url' => DI::baseUrl() . '/events',
88 'sel' => $current == 'events' ? 'active' : '',
89 'title' => DI::l10n()->t('Events and Calendar'),
93 // if the user is not the owner of the calendar we only show a calendar
94 // with the public events of the calendar owner
95 } elseif (!$is_owner) {
97 'label' => DI::l10n()->t('Events'),
98 'url' => DI::baseUrl() . '/cal/' . $nickname,
99 'sel' => $current == 'cal' ? 'active' : '',
100 'title' => DI::l10n()->t('Events and Calendar'),
101 'id' => 'events-tab',
108 'label' => DI::l10n()->t('Personal Notes'),
109 'url' => DI::baseUrl() . '/notes',
110 'sel' => $current == 'notes' ? 'active' : '',
111 'title' => DI::l10n()->t('Only You Can See This'),
117 if (empty($profile['hide-friends'])) {
119 'label' => DI::l10n()->t('Contacts'),
120 'url' => $baseProfileUrl . '/contacts',
121 'sel' => $current == 'contacts' ? 'active' : '',
122 'title' => DI::l10n()->t('Contacts'),
123 'id' => 'viewcontacts-tab',
128 if (DI::session()->get('new_member') && $is_owner) {
130 'label' => DI::l10n()->t('Tips for New Members'),
131 'url' => DI::baseUrl() . '/newmember',
133 'title' => DI::l10n()->t('Tips for New Members'),
134 'id' => 'newmember-tab',
138 $arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $current, 'tabs' => $tabs];
140 Hook::callAll('profile_tabs', $arr);
142 $tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
144 return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]);