]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/AllFriends.php
Merge pull request #8175 from MrPetovan/task/revert-profile-default-tab
[friendica.git] / src / Module / AllFriends.php
index 238223aee03097164ac6d6924257074114b80642..662dc17e4c24c047402f27b8773b9b7b879b80e2 100644 (file)
@@ -5,8 +5,8 @@ namespace Friendica\Module;
 use Friendica\BaseModule;
 use Friendica\Content\ContactSelector;
 use Friendica\Content\Pager;
-use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
+use Friendica\DI;
 use Friendica\Model;
 use Friendica\Network\HTTPException;
 use Friendica\Util\Proxy as ProxyUtils;
@@ -16,9 +16,9 @@ use Friendica\Util\Proxy as ProxyUtils;
  */
 class AllFriends extends BaseModule
 {
-       public static function content()
+       public static function content(array $parameters = [])
        {
-               $app = self::getApp();
+               $app = DI::app();
 
                if (!local_user()) {
                        throw new HTTPException\ForbiddenException();
@@ -32,7 +32,7 @@ class AllFriends extends BaseModule
                }
 
                if (!$cid) {
-                       throw new HTTPException\BadRequestException(L10n::t('Invalid contact.'));
+                       throw new HTTPException\BadRequestException(DI::l10n()->t('Invalid contact.'));
                }
 
                $uid = $app->user['uid'];
@@ -40,19 +40,19 @@ class AllFriends extends BaseModule
                $contact = Model\Contact::getContactForUser($cid, local_user(), ['name', 'url', 'photo', 'uid', 'id']);
 
                if (empty($contact)) {
-                       throw new HTTPException\BadRequestException(L10n::t('Invalid contact.'));
+                       throw new HTTPException\BadRequestException(DI::l10n()->t('Invalid contact.'));
                }
 
-               $app->page['aside'] = "";
+               DI::page()['aside'] = "";
                Model\Profile::load($app, "", 0, Model\Contact::getDetailsByURL($contact["url"]));
 
                $total = Model\GContact::countAllFriends(local_user(), $cid);
 
-               $pager = new Pager($app->query_string);
+               $pager = new Pager(DI::args()->getQueryString());
 
                $friends = Model\GContact::allFriends(local_user(), $cid, $pager->getStart(), $pager->getItemsPerPage());
                if (empty($friends)) {
-                       return L10n::t('No friends to display.');
+                       return DI::l10n()->t('No friends to display.');
                }
 
                $id = 0;
@@ -69,16 +69,16 @@ class AllFriends extends BaseModule
                                $friend['id'] = $friend['cid'];
                                $photoMenu = Model\Contact::photoMenu($friend);
                        } else {
-                               $connlnk = $app->getBaseURL() . '/follow/?url=' . $friend['url'];
+                               $connlnk = DI::baseUrl()->get() . '/follow/?url=' . $friend['url'];
                                $photoMenu = [
-                                       'profile' => [L10n::t('View Profile'), Model\Contact::magicLinkbyId($friend['id'])],
-                                       'follow'  => [L10n::t('Connect/Follow'), $connlnk]
+                                       'profile' => [DI::l10n()->t('View Profile'), Model\Contact::magicLinkbyId($friend['id'], $friend['url'])],
+                                       'follow'  => [DI::l10n()->t('Connect/Follow'), $connlnk]
                                ];
                        }
 
                        $entry = [
-                               'url'          => Model\Contact::magicLinkbyId($friend['id']),
-                               'itemurl'      => defaults($contactDetails, 'addr', $friend['url']),
+                               'url'          => Model\Contact::magicLinkbyId($friend['id'], $friend['url']),
+                               'itemurl'      => ($contactDetails['addr'] ?? '') ?: $friend['url'],
                                'name'         => $contactDetails['name'],
                                'thumb'        => ProxyUtils::proxifyUrl($contactDetails['thumb'], false, ProxyUtils::SIZE_THUMB),
                                'img_hover'    => $contactDetails['name'],
@@ -88,7 +88,7 @@ class AllFriends extends BaseModule
                                'account_type' => Model\Contact::getAccountType($contactDetails),
                                'network'      => ContactSelector::networkToName($contactDetails['network'], $contactDetails['url']),
                                'photoMenu'    => $photoMenu,
-                               'conntxt'      => L10n::t('Connect'),
+                               'conntxt'      => DI::l10n()->t('Connect'),
                                'connlnk'      => $connlnk,
                                'id'           => ++$id,
                        ];