]> git.mxchange.org Git - friendica.git/commitdiff
Create new page_tabs template
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 6 Aug 2020 14:34:11 +0000 (10:34 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Fri, 7 Aug 2020 02:59:09 +0000 (22:59 -0400)
- Replace explicit tabs in profile contacts page with new template

src/BaseModule.php
src/Module/Profile/Common.php
src/Module/Profile/Contacts.php
view/templates/page_tabs.tpl [new file with mode: 0644]
view/templates/profile/contacts.tpl
view/theme/frio/templates/common_tabs.tpl
view/theme/frio/templates/page_tabs.tpl [new file with mode: 0644]
view/theme/frio/templates/profile/contacts.tpl

index 0e0fedb80c35925b4809595287c88254ae2a4c12..ce7774bfd09a634b0b53d7a54d5c14fc74dd6cdc 100644 (file)
@@ -171,4 +171,40 @@ abstract class BaseModule
                        throw new \Friendica\Network\HTTPException\ForbiddenException();
                }
        }
+
+       protected static function getContactFilterTabs(string $baseUrl, string $current, bool $displayCommonTab)
+       {
+               $tabs = [
+                       [
+                               'label' => DI::l10n()->t('All contacts'),
+                               'url'   => $baseUrl . '/contacts',
+                               'sel'   => !$current || $current == 'all' ? 'active' : '',
+                       ],
+                       [
+                               'label' => DI::l10n()->t('Followers'),
+                               'url'   => $baseUrl . '/contacts/followers',
+                               'sel'   => $current == 'followers' ? 'active' : '',
+                       ],
+                       [
+                               'label' => DI::l10n()->t('Following'),
+                               'url'   => $baseUrl . '/contacts/following',
+                               'sel'   => $current == 'following' ? 'active' : '',
+                       ],
+                       [
+                               'label' => DI::l10n()->t('Mutual friends'),
+                               'url'   => $baseUrl . '/contacts/mutuals',
+                               'sel'   => $current == 'mutuals' ? 'active' : '',
+                       ],
+               ];
+
+               if ($displayCommonTab) {
+                       $tabs[] = [
+                               'label' => DI::l10n()->t('Common'),
+                               'url'   => $baseUrl . '/contacts/common',
+                               'sel'   => $current == 'common' ? 'active' : '',
+                       ];
+               }
+
+               return $tabs;
+       }
 }
index 0b08d327c950fcbe386e369d82761b0ec2f8fa39..a9d00fce5f50a15b1be288fa13b70652d45768b1 100644 (file)
@@ -53,8 +53,6 @@ class Common extends BaseProfile
                        throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
                }
 
-               $o = self::getTabsHTML($a, 'contacts', false, $nickname);
-
                if (!empty($a->profile['hide-friends'])) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
@@ -65,6 +63,10 @@ class Common extends BaseProfile
                        $a->redirect('profile/' . $nickname . '/contacts');
                };
 
+               $o = self::getTabsHTML($a, 'contacts', false, $nickname);
+
+               $tabs = self::getContactFilterTabs('profile/' . $nickname, 'common', $displayCommonTab);
+
                $sourceId = Contact::getIdForURL(Profile::getMyURL());
                $targetId = Contact::getPublicIdByUserId($a->profile['uid']);
 
@@ -92,15 +94,8 @@ class Common extends BaseProfile
                $o .= Renderer::replaceMacros($tpl, [
                        '$title'    => $title,
                        '$desc'     => $desc,
-                       '$nickname' => $nickname,
-                       '$type'     => 'common',
-                       '$displayCommonTab' => $displayCommonTab,
-
-                       '$all_label'       => DI::l10n()->t('All contacts'),
-                       '$followers_label' => DI::l10n()->t('Followers'),
-                       '$following_label' => DI::l10n()->t('Following'),
-                       '$mutuals_label'   => DI::l10n()->t('Mutual friends'),
-                       '$common_label'    => DI::l10n()->t('Common'),
+                       '$tabs'     => $tabs,
+
                        '$noresult_label'  => DI::l10n()->t('No common contacts.'),
 
                        '$contacts' => $contacts,
index 938dbd3d05ec943d2bf7a28679ae3d2d0a38ae07..6981b43a4205d4d1241cabbbbfb289bea925d222 100644 (file)
@@ -61,6 +61,8 @@ class Contacts extends Module\BaseProfile
 
                $o = self::getTabsHTML($a, 'contacts', $is_owner, $nickname);
 
+               $tabs = self::getContactFilterTabs('profile/' . $nickname, $type, Session::isAuthenticated() && $a->profile['uid'] != local_user());
+
                $condition = [
                        'uid'     => $a->profile['uid'],
                        'blocked' => false,
@@ -113,15 +115,8 @@ class Contacts extends Module\BaseProfile
                $o .= Renderer::replaceMacros($tpl, [
                        '$title'    => $title,
                        '$desc'     => $desc,
-                       '$nickname' => $nickname,
-                       '$type'     => $type,
-                       '$displayCommonTab' => Session::isAuthenticated() && $a->profile['uid'] != local_user(),
-
-                       '$all_label'       => DI::l10n()->t('All contacts'),
-                       '$followers_label' => DI::l10n()->t('Followers'),
-                       '$following_label' => DI::l10n()->t('Following'),
-                       '$mutuals_label'   => DI::l10n()->t('Mutual friends'),
-                       '$common_label'    => DI::l10n()->t('Common'),
+                       '$tabs'     => $tabs,
+
                        '$noresult_label'  => DI::l10n()->t('No contacts.'),
 
                        '$contacts' => $contacts,
diff --git a/view/templates/page_tabs.tpl b/view/templates/page_tabs.tpl
new file mode 100644 (file)
index 0000000..d5bf9c5
--- /dev/null
@@ -0,0 +1 @@
+{{include file="common_tabs.tpl" tabs=$tabs}}
\ No newline at end of file
index 4a1379f17b67608b88779e60eb70eaea1b14a19d..7e2ae9e83ddedca7b09de4804c70a2855a2ba569 100644 (file)
@@ -5,15 +5,8 @@
        <p>{{$desc nofilter}}</p>
 {{/if}}
 
-       <ul role="menubar" class="tabs">
-               <li role="menuitem"><a href="profile/{{$nickname}}/contacts" class="tab button{{if !$type || $type == 'all'}} active{{/if}}">{{$all_label}}</a></li>
-               <li role="menuitem"><a href="profile/{{$nickname}}/contacts/followers" class="tab button{{if $type == 'followers'}} active{{/if}}">{{$followers_label}}</a></li>
-               <li role="menuitem"><a href="profile/{{$nickname}}/contacts/following" class="tab button{{if $type == 'following'}} active{{/if}}">{{$following_label}}</a></li>
-               <li role="menuitem"><a href="profile/{{$nickname}}/contacts/mutuals" class="tab button{{if $type == 'mutuals'}} active{{/if}}">{{$mutuals_label}}</a></li>
-       {{if $displayCommonTab}}
-               <li role="menuitem"><a href="profile/{{$nickname}}/contacts/common" class="tab button{{if $type == 'common'}} active{{/if}}{{if !$common_count}} disabled{{/if}}">{{$common_label}}</a></li>
-       {{/if}}
-       </ul>
+       {{include file="page_tabs.tpl" tabs=$tabs}}
+
 {{if $contacts}}
        <div id="viewcontact_wrapper-{{$id}}">
        {{foreach $contacts as $contact}}
index 76c6db039820712b43d5b72c1356429a8063a554..27ae11686b9e691b295b5e1d419e95fab811224d 100644 (file)
@@ -4,7 +4,7 @@
        <ul role="menubar" class="tabbar list-inline visible-lg visible-md visible-sm hidden-xs">
                {{* The normal tabbar *}}
                <li>
-                       <ul class="tabs  flex-nav" role="menu" >
+                       <ul class="tabs flex-nav" role="menu" >
                        {{foreach $tabs as $tab}}
                                <li id="{{$tab.id}}" role="presentation" {{if $tab.sel}} class="{{$tab.sel}}" {{/if}}><a role="menuitem" href="{{$tab.url}}" {{if $tab.accesskey}}accesskey="{{$tab.accesskey}}"{{/if}} {{if $tab.title}} title="{{$tab.title}}"{{/if}}>{{$tab.label}}</a></li>
                        {{/foreach}}
@@ -36,8 +36,6 @@
                                        {{$exttabs[]=$tab}}
                                        {{/if}}
                                {{/foreach}}
-
-
                        </ul>
                </li>
 
diff --git a/view/theme/frio/templates/page_tabs.tpl b/view/theme/frio/templates/page_tabs.tpl
new file mode 100644 (file)
index 0000000..a489d03
--- /dev/null
@@ -0,0 +1,7 @@
+<ul class="nav nav-tabs">
+{{foreach $tabs as $tab}}
+       <li id="{{$tab.id}}" role="presentation"{{if $tab.sel}} class="{{$tab.sel}}"{{/if}}>
+               <a role="menuitem" href="{{$tab.url}}"{{if $tab.accesskey}} accesskey="{{$tab.accesskey}}"{{/if}}{{if $tab.title}} title="{{$tab.title}}"{{/if}}>{{$tab.label}}</a>
+       </li>
+{{/foreach}}
+</ul>
index 000b9767743f722d6f5b8a84a01eeea6a5f20579..513223f318eb86b4f105e287b13cdf6bea78b589 100644 (file)
@@ -5,25 +5,8 @@
        <p>{{$desc nofilter}}</p>
 {{/if}}
 
-       <ul class="nav nav-tabs">
-               <li role="presentation"{{if !$type || $type == 'all'}} class="active"{{/if}}>
-                       <a href="profile/{{$nickname}}/contacts">{{$all_label}}</a>
-               </li>
-               <li role="presentation"{{if $type == 'followers'}} class="active"{{/if}}>
-                       <a href="profile/{{$nickname}}/contacts/followers">{{$followers_label}}</a>
-               </li>
-               <li role="presentation"{{if $type == 'following'}} class="active"{{/if}}>
-                       <a href="profile/{{$nickname}}/contacts/following">{{$following_label}}</a>
-               </li>
-               <li role="presentation"{{if $type == 'mutuals'}} class="active"{{/if}}>
-                       <a href="profile/{{$nickname}}/contacts/mutuals">{{$mutuals_label}}</a>
-               </li>
-       {{if $displayCommonTab}}
-               <li role="presentation"{{if $type == 'common'}} class="active"{{/if}}>
-                       <a href="profile/{{$nickname}}/contacts/common" class="tab button">{{$common_label}}</a>
-               </li>
-       {{/if}}
-       </ul>
+       {{include file="page_tabs.tpl" tabs=$tabs}}
+
 {{if $contacts}}
        <ul id="viewcontact_wrapper{{if $id}}-{{$id}}{{/if}}" class="viewcontact_wrapper media-list">
        {{foreach $contacts as $contact}}