]> git.mxchange.org Git - friendica.git/blobdiff - src/App.php
Moved functions out of boot.php into class
[friendica.git] / src / App.php
index d763cfa43fccdb42fdbc41a9148452d9cf681ec1..968f07b0c40cfed35247527b0cc7a3d4e810ff52 100644 (file)
@@ -110,6 +110,11 @@ class App
         */
        private $currentTheme;
 
+       /**
+        * @var bool check if request was an AJAX (xmlhttprequest) request
+        */
+       private $isAjax;
+
        /**
         * Register a stylesheet file path to be included in the <head> tag of every page.
         * Inclusion is done in App->initHead().
@@ -322,6 +327,8 @@ class App
                $this->is_mobile = $mobile_detect->isMobile();
                $this->is_tablet = $mobile_detect->isTablet();
 
+               $this->isAjax = strtolower(defaults($_SERVER, 'HTTP_X_REQUESTED_WITH')) == 'xmlhttprequest';
+
                // Register template engines
                $this->registerTemplateEngine('Friendica\Render\FriendicaSmartyEngine');
        }
@@ -1221,7 +1228,7 @@ class App
                        }
                }
 
-               $load = current_load();
+               $load = System::currentLoad();
                if ($load) {
                        if (intval($load) > $maxsysload) {
                                logger('system: load ' . $load . ' for ' . $process . ' tasks (' . $maxsysload . ') too high.');
@@ -1572,4 +1579,32 @@ class App
        {
                return Core\Theme::getStylesheetPath($this->getCurrentTheme());
        }
+
+       /**
+        * Check if request was an AJAX (xmlhttprequest) request.
+        *
+        * @return boolean true if it was an AJAX request
+        */
+       public function isAjax()
+       {
+               return $this->isAjax;
+       }
+
+       /**
+        * Returns the value of a argv key
+        * TODO there are a lot of $a->argv usages in combination with defaults() which can be replaced with this method
+        *
+        * @param int $position the position of the argument
+        * @param mixed $default the default value if not found
+        *
+        * @return mixed returns the value of the argument
+        */
+       public function getArgumentValue($position, $default = '')
+       {
+               if (array_key_exists($position, $this->argv)) {
+                       return $this->argv[$position];
+               }
+
+               return $default;
+       }
 }