]> git.mxchange.org Git - friendica.git/blob - src/Module/BaseProfile.php
Fixing PUBLIC usage, Fixing DB-View, Creating tests
[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, string $nickname, bool $hide_friends)
43         {
44                 $baseProfileUrl = DI::baseUrl() . '/profile/' . $nickname;
45
46                 $tabs = [
47                         [
48                                 'label' => DI::l10n()->t('Profile'),
49                                 'url'   => $baseProfileUrl . '/profile',
50                                 'sel'   => $current == 'profile' ? 'active' : '',
51                                 'title' => DI::l10n()->t('Profile Details'),
52                                 'id'    => 'profile-tab',
53                                 'accesskey' => 'r',
54                         ],
55                         [
56                                 'label' => DI::l10n()->t('Status'),
57                                 'url'   => $baseProfileUrl . '/status',
58                                 'sel'   => $current == 'status' ? 'active' : '',
59                                 'title' => DI::l10n()->t('Status Messages and Posts'),
60                                 'id'    => 'status-tab',
61                                 'accesskey' => 'm',
62                         ],
63                         [
64                                 'label' => DI::l10n()->t('Photos'),
65                                 'url'   => DI::baseUrl() . '/photos/' . $nickname,
66                                 'sel'   => $current == 'photos' ? 'active' : '',
67                                 'title' => DI::l10n()->t('Photo Albums'),
68                                 'id'    => 'photo-tab',
69                                 'accesskey' => 'h',
70                         ],
71                         [
72                                 'label' => DI::l10n()->t('Media'),
73                                 'url'   => $baseProfileUrl . '/media',
74                                 'sel'   => $current == 'media' ? 'active' : '',
75                                 'title' => DI::l10n()->t('Media'),
76                                 'id'    => 'media-tab',
77                                 'accesskey' => 'd',
78                         ],
79                 ];
80
81                 // the calendar link for the full featured events calendar
82                 if ($is_owner && $a->getThemeInfoValue('events_in_profile')) {
83                         $tabs[] = [
84                                 'label' => DI::l10n()->t('Events'),
85                                 'url'   => DI::baseUrl() . '/events',
86                                 'sel'   => $current == 'events' ? 'active' : '',
87                                 'title' => DI::l10n()->t('Events and Calendar'),
88                                 'id'    => 'events-tab',
89                                 'accesskey' => 'e',
90                         ];
91                         // if the user is not the owner of the calendar we only show a calendar
92                         // with the public events of the calendar owner
93                 } elseif (!$is_owner) {
94                         $tabs[] = [
95                                 'label' => DI::l10n()->t('Events'),
96                                 'url'   => DI::baseUrl() . '/cal/' . $nickname,
97                                 'sel'   => $current == 'cal' ? 'active' : '',
98                                 'title' => DI::l10n()->t('Events and Calendar'),
99                                 'id'    => 'events-tab',
100                                 'accesskey' => 'e',
101                         ];
102                 }
103
104                 if ($is_owner) {
105                         $tabs[] = [
106                                 'label' => DI::l10n()->t('Personal Notes'),
107                                 'url'   => DI::baseUrl() . '/notes',
108                                 'sel'   => $current == 'notes' ? 'active' : '',
109                                 'title' => DI::l10n()->t('Only You Can See This'),
110                                 'id'    => 'notes-tab',
111                                 'accesskey' => 't',
112                         ];
113                         $tabs[] = [
114                                 'label' => DI::l10n()->t('Scheduled Posts'),
115                                 'url'   => $baseProfileUrl . '/schedule',
116                                 'sel'   => $current == 'schedule' ? 'active' : '',
117                                 'title' => DI::l10n()->t('Posts that are scheduled for publishing'),
118                                 'id'    => 'schedule-tab',
119                                 'accesskey' => 'o',
120                         ];
121                 }
122
123                 if (!$hide_friends) {
124                         $tabs[] = [
125                                 'label' => DI::l10n()->t('Contacts'),
126                                 'url'   => $baseProfileUrl . '/contacts',
127                                 'sel'   => $current == 'contacts' ? 'active' : '',
128                                 'title' => DI::l10n()->t('Contacts'),
129                                 'id'    => 'viewcontacts-tab',
130                                 'accesskey' => 'k',
131                         ];
132                 }
133
134                 if (DI::session()->get('new_member') && $is_owner) {
135                         $tabs[] = [
136                                 'label' => DI::l10n()->t('Tips for New Members'),
137                                 'url'   => DI::baseUrl() . '/newmember',
138                                 'sel'   => false,
139                                 'title' => DI::l10n()->t('Tips for New Members'),
140                                 'id'    => 'newmember-tab',
141                         ];
142                 }
143
144                 $arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $current, 'tabs' => $tabs];
145
146                 Hook::callAll('profile_tabs', $arr);
147
148                 $tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
149
150                 return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]);
151         }
152 }