]> git.mxchange.org Git - friendica.git/blobdiff - src/App/Arguments.php
Update copyright
[friendica.git] / src / App / Arguments.php
index ae6c64a4f39715db1577e29a04d7ec7e294f659a..ef1ed928563ea72665f17138c2776d0c012ea8d9 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
  *
@@ -30,6 +30,8 @@ namespace Friendica\App;
  */
 class Arguments
 {
+       const DEFAULT_MODULE = 'home';
+
        /**
         * @var string The complete query string
         */
@@ -38,6 +40,10 @@ class Arguments
         * @var string The current Friendica command
         */
        private $command;
+       /**
+        * @var string The name of the current module
+        */
+       private $moduleName;
        /**
         * @var array The arguments of the current execution
         */
@@ -47,10 +53,11 @@ class Arguments
         */
        private $argc;
 
-       public function __construct(string $queryString = '', string $command = '', array $argv = [], int $argc = 0)
+       public function __construct(string $queryString = '', string $command = '', string $moduleName = '', array $argv = [], int $argc = 0)
        {
                $this->queryString = $queryString;
                $this->command     = $command;
+               $this->moduleName  = $moduleName;
                $this->argv        = $argv;
                $this->argc        = $argc;
        }
@@ -71,6 +78,14 @@ class Arguments
                return $this->command;
        }
 
+       /**
+        * @return string The module name based on the arguments
+        */
+       public function getModuleName(): string
+       {
+               return $this->moduleName;
+       }
+
        /**
         * @return array All arguments of this call
         */
@@ -172,6 +187,18 @@ class Arguments
 
                $queryString = $command . ($queryParameters ? '?' . http_build_query($queryParameters) : '');
 
-               return new Arguments($queryString, $command, $argv, $argc);
+               if ($argc > 0) {
+                       $module = str_replace('.', '_', $argv[0]);
+                       $module = str_replace('-', '_', $module);
+               } else {
+                       $module = self::DEFAULT_MODULE;
+               }
+
+               // Compatibility with the Firefox App
+               if (($module == "users") && ($command == "users/sign_in")) {
+                       $module = "login";
+               }
+
+               return new Arguments($queryString, $command, $module, $argv, $argc);
        }
 }