]> git.mxchange.org Git - friendica.git/blob - src/Module/BaseProfile.php
Remove join profile table
[friendica.git] / src / Module / BaseProfile.php
1 <?php
2
3 namespace Friendica\Module;
4
5 use Friendica\App;
6 use Friendica\BaseModule;
7 use Friendica\Core\Hook;
8 use Friendica\Core\Renderer;
9 use Friendica\DI;
10
11 class BaseProfile extends BaseModule
12 {
13         /**
14          * Returns the HTML for the profile pages tabs
15          *
16          * @param App    $a
17          * @param string $current
18          * @param bool   $is_owner
19          * @param string $nickname
20          * @return string
21          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
22          */
23         public static function getTabsHTML(App $a, string $current, bool $is_owner, string $nickname = null)
24         {
25                 if (is_null($nickname)) {
26                         $nickname = $a->user['nickname'];
27                 }
28
29                 $baseProfileUrl = DI::baseUrl() . '/profile/' . $nickname;
30
31                 $tabs = [
32                         [
33                                 'label' => DI::l10n()->t('Profile'),
34                                 'url'   => $baseProfileUrl . '/profile',
35                                 'sel'   => $current == 'profile' ? 'active' : '',
36                                 'title' => DI::l10n()->t('Profile Details'),
37                                 'id'    => 'profile-tab',
38                                 'accesskey' => 'r',
39                         ],
40                         [
41                                 'label' => DI::l10n()->t('Status'),
42                                 'url'   => $baseProfileUrl . '/status',
43                                 'sel'   => $current == 'status' ? 'active' : '',
44                                 'title' => DI::l10n()->t('Status Messages and Posts'),
45                                 'id'    => 'status-tab',
46                                 'accesskey' => 'm',
47                         ],
48                         [
49                                 'label' => DI::l10n()->t('Photos'),
50                                 'url'   => DI::baseUrl() . '/photos/' . $nickname,
51                                 'sel'   => $current == 'photos' ? 'active' : '',
52                                 'title' => DI::l10n()->t('Photo Albums'),
53                                 'id'    => 'photo-tab',
54                                 'accesskey' => 'h',
55                         ],
56                         [
57                                 'label' => DI::l10n()->t('Videos'),
58                                 'url'   => DI::baseUrl() . '/videos/' . $nickname,
59                                 'sel'   => $current == 'videos' ? 'active' : '',
60                                 'title' => DI::l10n()->t('Videos'),
61                                 'id'    => 'video-tab',
62                                 'accesskey' => 'v',
63                         ],
64                 ];
65
66                 // the calendar link for the full featured events calendar
67                 if ($is_owner && $a->theme_events_in_profile) {
68                         $tabs[] = [
69                                 'label' => DI::l10n()->t('Events'),
70                                 'url'   => DI::baseUrl() . '/events',
71                                 'sel'   => $current == 'events' ? 'active' : '',
72                                 'title' => DI::l10n()->t('Events and Calendar'),
73                                 'id'    => 'events-tab',
74                                 'accesskey' => 'e',
75                         ];
76                         // if the user is not the owner of the calendar we only show a calendar
77                         // with the public events of the calendar owner
78                 } elseif (!$is_owner) {
79                         $tabs[] = [
80                                 'label' => DI::l10n()->t('Events'),
81                                 'url'   => DI::baseUrl() . '/cal/' . $nickname,
82                                 'sel'   => $current == 'cal' ? 'active' : '',
83                                 'title' => DI::l10n()->t('Events and Calendar'),
84                                 'id'    => 'events-tab',
85                                 'accesskey' => 'e',
86                         ];
87                 }
88
89                 if ($is_owner) {
90                         $tabs[] = [
91                                 'label' => DI::l10n()->t('Personal Notes'),
92                                 'url'   => DI::baseUrl() . '/notes',
93                                 'sel'   => $current == 'notes' ? 'active' : '',
94                                 'title' => DI::l10n()->t('Only You Can See This'),
95                                 'id'    => 'notes-tab',
96                                 'accesskey' => 't',
97                         ];
98                 }
99
100                 if (empty($a->profile['hide-friends'])) {
101                         $tabs[] = [
102                                 'label' => DI::l10n()->t('Contacts'),
103                                 'url'   => $baseProfileUrl . '/contacts',
104                                 'sel'   => $current == 'contacts' ? 'active' : '',
105                                 'title' => DI::l10n()->t('Contacts'),
106                                 'id'    => 'viewcontacts-tab',
107                                 'accesskey' => 'k',
108                         ];
109                 }
110
111                 if (DI::session()->get('new_member') && $is_owner) {
112                         $tabs[] = [
113                                 'label' => DI::l10n()->t('Tips for New Members'),
114                                 'url'   => DI::baseUrl() . '/newmember',
115                                 'sel'   => false,
116                                 'title' => DI::l10n()->t('Tips for New Members'),
117                                 'id'    => 'newmember-tab',
118                         ];
119                 }
120
121                 $arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $current, 'tabs' => $tabs];
122
123                 Hook::callAll('profile_tabs', $arr);
124
125                 $tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
126
127                 return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]);
128         }
129 }