]> git.mxchange.org Git - friendica.git/blob - src/Module/BaseProfile.php
Remove unused first parameter from BaseProfile::getTabsHTML
[friendica.git] / src / Module / BaseProfile.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
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.
11  *
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.
16  *
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/>.
19  *
20  */
21
22 namespace Friendica\Module;
23
24 use Friendica\App;
25 use Friendica\BaseModule;
26 use Friendica\Core\Hook;
27 use Friendica\Core\Renderer;
28 use Friendica\DI;
29
30 class BaseProfile extends BaseModule
31 {
32         /**
33          * Returns the HTML for the profile pages tabs
34          *
35          * @param string $current
36          * @param bool   $is_owner
37          * @param string $nickname
38          * @return string
39          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
40          */
41         public static function getTabsHTML(string $current, bool $is_owner, string $nickname, bool $hide_friends)
42         {
43                 $baseProfileUrl = DI::baseUrl() . '/profile/' . $nickname;
44
45                 $tabs = [
46                         [
47                                 'label' => DI::l10n()->t('Profile'),
48                                 'url'   => $baseProfileUrl . '/profile',
49                                 'sel'   => $current == 'profile' ? 'active' : '',
50                                 'title' => DI::l10n()->t('Profile Details'),
51                                 'id'    => 'profile-tab',
52                                 'accesskey' => 'r',
53                         ],
54                         [
55                                 'label' => DI::l10n()->t('Status'),
56                                 'url'   => $baseProfileUrl . '/status',
57                                 'sel'   => $current == 'status' ? 'active' : '',
58                                 'title' => DI::l10n()->t('Status Messages and Posts'),
59                                 'id'    => 'status-tab',
60                                 'accesskey' => 'm',
61                         ],
62                         [
63                                 'label' => DI::l10n()->t('Photos'),
64                                 'url'   => $baseProfileUrl . '/photos',
65                                 'sel'   => $current == 'photos' ? 'active' : '',
66                                 'title' => DI::l10n()->t('Photo Albums'),
67                                 'id'    => 'photo-tab',
68                                 'accesskey' => 'h',
69                         ],
70                         [
71                                 'label' => DI::l10n()->t('Media'),
72                                 'url'   => $baseProfileUrl . '/media',
73                                 'sel'   => $current == 'media' ? 'active' : '',
74                                 'title' => DI::l10n()->t('Media'),
75                                 'id'    => 'media-tab',
76                                 'accesskey' => 'd',
77                         ],
78                 ];
79
80                 // the calendar link for the full-featured events calendar
81                 if ($is_owner) {
82                         $tabs[] = [
83                                 'label' => DI::l10n()->t('Calendar'),
84                                 'url'   => DI::baseUrl() . '/calendar',
85                                 'sel'   => $current == 'calendar' ? 'active' : '',
86                                 'title' => DI::l10n()->t('Calendar'),
87                                 'id'    => 'calendar-tab',
88                                 'accesskey' => 'c',
89                         ];
90                         // if the user is not the owner of the calendar we only show a calendar
91                         // with the public events of the calendar owner
92                 } else {
93                         $tabs[] = [
94                                 'label' => DI::l10n()->t('Calendar'),
95                                 'url'   => DI::baseUrl() . '/calendar/show/' . $nickname,
96                                 'sel'   => $current == 'calendar' ? 'active' : '',
97                                 'title' => DI::l10n()->t('Calendar'),
98                                 'id'    => 'calendar-tab',
99                                 'accesskey' => 'c',
100                         ];
101                 }
102
103                 if ($is_owner) {
104                         $tabs[] = [
105                                 'label' => DI::l10n()->t('Personal Notes'),
106                                 'url'   => DI::baseUrl() . '/notes',
107                                 'sel'   => $current == 'notes' ? 'active' : '',
108                                 'title' => DI::l10n()->t('Only You Can See This'),
109                                 'id'    => 'notes-tab',
110                                 'accesskey' => 't',
111                         ];
112                         $tabs[] = [
113                                 'label' => DI::l10n()->t('Scheduled Posts'),
114                                 'url'   => $baseProfileUrl . '/schedule',
115                                 'sel'   => $current == 'schedule' ? 'active' : '',
116                                 'title' => DI::l10n()->t('Posts that are scheduled for publishing'),
117                                 'id'    => 'schedule-tab',
118                                 'accesskey' => 'o',
119                         ];
120                 }
121
122                 if (!$hide_friends) {
123                         $tabs[] = [
124                                 'label' => DI::l10n()->t('Contacts'),
125                                 'url'   => $baseProfileUrl . '/contacts',
126                                 'sel'   => $current == 'contacts' ? 'active' : '',
127                                 'title' => DI::l10n()->t('Contacts'),
128                                 'id'    => 'viewcontacts-tab',
129                                 'accesskey' => 'k',
130                         ];
131                 }
132
133                 if (DI::session()->get('new_member') && $is_owner) {
134                         $tabs[] = [
135                                 'label' => DI::l10n()->t('Tips for New Members'),
136                                 'url'   => DI::baseUrl() . '/newmember',
137                                 'sel'   => false,
138                                 'title' => DI::l10n()->t('Tips for New Members'),
139                                 'id'    => 'newmember-tab',
140                         ];
141                 }
142
143                 $arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $current, 'tabs' => $tabs];
144
145                 Hook::callAll('profile_tabs', $arr);
146
147                 $tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
148
149                 return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]);
150         }
151 }