]> git.mxchange.org Git - friendica.git/blob - src/Module/BaseProfile.php
832c8fd2f8928e53881f845159dc20ed5b2ed4a9
[friendica.git] / src / Module / BaseProfile.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2021, 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 App    $a
36          * @param string $current
37          * @param bool   $is_owner
38          * @param string $nickname
39          * @return string
40          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
41          */
42         public static function getTabsHTML(App $a, string $current, bool $is_owner, array $profile)
43         {
44                 $nickname = $profile['nickname'];
45
46                 $baseProfileUrl = DI::baseUrl() . '/profile/' . $nickname;
47
48                 $tabs = [
49                         [
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',
55                                 'accesskey' => 'r',
56                         ],
57                         [
58                                 'label' => DI::l10n()->t('Status'),
59                                 'url'   => $baseProfileUrl . '/status',
60                                 'sel'   => $current == 'status' ? 'active' : '',
61                                 'title' => DI::l10n()->t('Status Messages and Posts'),
62                                 'id'    => 'status-tab',
63                                 'accesskey' => 'm',
64                         ],
65                         [
66                                 'label' => DI::l10n()->t('Photos'),
67                                 'url'   => DI::baseUrl() . '/photos/' . $nickname,
68                                 'sel'   => $current == 'photos' ? 'active' : '',
69                                 'title' => DI::l10n()->t('Photo Albums'),
70                                 'id'    => 'photo-tab',
71                                 'accesskey' => 'h',
72                         ],
73 // @todo Currently deactivated since it doesn't really work
74 //                      [
75 //                              'label' => DI::l10n()->t('Videos'),
76 //                              'url'   => DI::baseUrl() . '/videos/' . $nickname,
77 //                              'sel'   => $current == 'videos' ? 'active' : '',
78 //                              'title' => DI::l10n()->t('Videos'),
79 //                              'id'    => 'video-tab',
80 //                              'accesskey' => 'v',
81 //                      ],
82                 ];
83
84                 // the calendar link for the full featured events calendar
85                 if ($is_owner && $a->getThemeInfoValue('events_in_profile')) {
86                         $tabs[] = [
87                                 'label' => DI::l10n()->t('Events'),
88                                 'url'   => DI::baseUrl() . '/events',
89                                 'sel'   => $current == 'events' ? 'active' : '',
90                                 'title' => DI::l10n()->t('Events and Calendar'),
91                                 'id'    => 'events-tab',
92                                 'accesskey' => 'e',
93                         ];
94                         // if the user is not the owner of the calendar we only show a calendar
95                         // with the public events of the calendar owner
96                 } elseif (!$is_owner) {
97                         $tabs[] = [
98                                 'label' => DI::l10n()->t('Events'),
99                                 'url'   => DI::baseUrl() . '/cal/' . $nickname,
100                                 'sel'   => $current == 'cal' ? 'active' : '',
101                                 'title' => DI::l10n()->t('Events and Calendar'),
102                                 'id'    => 'events-tab',
103                                 'accesskey' => 'e',
104                         ];
105                 }
106
107                 if ($is_owner) {
108                         $tabs[] = [
109                                 'label' => DI::l10n()->t('Personal Notes'),
110                                 'url'   => DI::baseUrl() . '/notes',
111                                 'sel'   => $current == 'notes' ? 'active' : '',
112                                 'title' => DI::l10n()->t('Only You Can See This'),
113                                 'id'    => 'notes-tab',
114                                 'accesskey' => 't',
115                         ];
116                         $tabs[] = [
117                                 'label' => DI::l10n()->t('Scheduled Posts'),
118                                 'url'   => $baseProfileUrl . '/schedule',
119                                 'sel'   => $current == 'schedule' ? 'active' : '',
120                                 'title' => DI::l10n()->t('Posts that are scheduled for publishing'),
121                                 'id'    => 'schedule-tab',
122                                 'accesskey' => 'o',
123                         ];
124                 }
125
126                 if (empty($profile['hide-friends'])) {
127                         $tabs[] = [
128                                 'label' => DI::l10n()->t('Contacts'),
129                                 'url'   => $baseProfileUrl . '/contacts',
130                                 'sel'   => $current == 'contacts' ? 'active' : '',
131                                 'title' => DI::l10n()->t('Contacts'),
132                                 'id'    => 'viewcontacts-tab',
133                                 'accesskey' => 'k',
134                         ];
135                 }
136
137                 if (DI::session()->get('new_member') && $is_owner) {
138                         $tabs[] = [
139                                 'label' => DI::l10n()->t('Tips for New Members'),
140                                 'url'   => DI::baseUrl() . '/newmember',
141                                 'sel'   => false,
142                                 'title' => DI::l10n()->t('Tips for New Members'),
143                                 'id'    => 'newmember-tab',
144                         ];
145                 }
146
147                 $arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $current, 'tabs' => $tabs];
148
149                 Hook::callAll('profile_tabs', $arr);
150
151                 $tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
152
153                 return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]);
154         }
155 }