]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/RemoteFollow.php
"DI" calls are replaced
[friendica.git] / src / Module / RemoteFollow.php
index 171ea553095646e7bcfcea0f708996252f72f56d..130c76319c12b43c073d3fd7bcd9971a0f5e6825 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -21,7 +21,7 @@
 
 namespace Friendica\Module;
 
-use Friendica\App\BaseURL;
+use Friendica\App;
 use Friendica\App\Page;
 use Friendica\BaseModule;
 use Friendica\Content\Widget;
@@ -36,6 +36,8 @@ use Friendica\Model\Profile;
 use Friendica\Model\User;
 use Friendica\Network\HTTPException;
 use Friendica\Network\Probe;
+use Friendica\Util\Profiler;
+use Psr\Log\LoggerInterface;
 
 /**
  * Remotely follow the account on this system by the provided account
@@ -46,48 +48,45 @@ class RemoteFollow extends BaseModule
        protected $owner;
        /** @var Page */
        protected $page;
-       /** @var BaseURL */
-       protected $baseUrl;
 
-       public function __construct(L10n $l10n, Page $page, BaseURL $baseUrl, array $parameters = [])
+       public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, App\Page $page, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
        {
-               parent::__construct($l10n, $parameters);
+               parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
                $this->owner = User::getOwnerDataByNick($this->parameters['profile']);
                if (!$this->owner) {
-                       throw new HTTPException\NotFoundException($this->l10n->t('User not found.'));
+                       throw new HTTPException\NotFoundException($this->t('User not found.'));
                }
 
-               $this->baseUrl = $baseUrl;
                $this->page    = $page;
        }
 
-       public function post()
+       protected function post(array $request = [])
        {
                if (!empty($_POST['cancel']) || empty($_POST['dfrn_url'])) {
                        $this->baseUrl->redirect();
                }
        
                if (empty($this->owner)) {
-                       notice($this->l10n->t('Profile unavailable.'));
+                       notice($this->t('Profile unavailable.'));
                        return;
                }
                
                $url = Probe::cleanURI($_POST['dfrn_url']);
                if (!strlen($url)) {
-                       notice($this->l10n->t("Invalid locator"));
+                       notice($this->t("Invalid locator"));
                        return;
                }
 
                // Detect the network, make sure the provided URL is valid
                $data = Contact::getByURL($url);
                if (!$data) {
-                       notice($this->l10n->t("The provided profile link doesn't seem to be valid"));
+                       notice($this->t("The provided profile link doesn't seem to be valid"));
                        return;
                }
 
                if (empty($data['subscribe'])) {
-                       notice($this->l10n->t("Remote subscription can't be done for your network. Please subscribe directly on your system."));
+                       notice($this->t("Remote subscription can't be done for your network. Please subscribe directly on your system."));
                        return;
                }
 
@@ -106,7 +105,7 @@ class RemoteFollow extends BaseModule
                System::externalRedirect($follow_link);
        }
 
-       public function content(): string
+       protected function content(array $request = []): string
        {
                if (empty($this->owner)) {
                        return '';
@@ -119,13 +118,13 @@ class RemoteFollow extends BaseModule
 
                $tpl = Renderer::getMarkupTemplate('auto_request.tpl');
                $o = Renderer::replaceMacros($tpl, [
-                       '$header'        => $this->l10n->t('Friend/Connection Request'),
-                       '$page_desc'     => $this->l10n->t('Enter your Webfinger address (user@domain.tld) or profile URL here. If this isn\'t supported by your system, you have to subscribe to <strong>%s</strong> or <strong>%s</strong> directly on your system.', $target_addr, $target_url),
-                       '$invite_desc'   => $this->l10n->t('If you are not yet a member of the free social web, <a href="%s">follow this link to find a public Friendica node and join us today</a>.', Search::getGlobalDirectory() . '/servers'),
-                       '$your_address'  => $this->l10n->t('Your Webfinger address or profile URL:'),
-                       '$pls_answer'    => $this->l10n->t('Please answer the following:'),
-                       '$submit'        => $this->l10n->t('Submit Request'),
-                       '$cancel'        => $this->l10n->t('Cancel'),
+                       '$header'        => $this->t('Friend/Connection Request'),
+                       '$page_desc'     => $this->t('Enter your Webfinger address (user@domain.tld) or profile URL here. If this isn\'t supported by your system, you have to subscribe to <strong>%s</strong> or <strong>%s</strong> directly on your system.', $target_addr, $target_url),
+                       '$invite_desc'   => $this->t('If you are not yet a member of the free social web, <a href="%s">follow this link to find a public Friendica node and join us today</a>.', Search::getGlobalDirectory() . '/servers'),
+                       '$your_address'  => $this->t('Your Webfinger address or profile URL:'),
+                       '$pls_answer'    => $this->t('Please answer the following:'),
+                       '$submit'        => $this->t('Submit Request'),
+                       '$cancel'        => $this->t('Cancel'),
 
                        '$request'       => 'remote_follow/' . $this->parameters['profile'],
                        '$name'          => $this->owner['name'],