+ $mode |= Mode::MAINTENANCEDISABLED;
+
+ return new Mode($mode, $this->isBackend, $this->isAjax, $this->isMobile, $this->isTablet);
+ }
+
+ /**
+ * Checks if the site is called via a backend process
+ *
+ * @param bool $isBackend True, if the call is from a backend script (daemon, worker, ...)
+ * @param array $server The $_SERVER variable
+ * @param Arguments $args The Friendica App arguments
+ * @param MobileDetect $mobileDetect The mobile detection library
+ *
+ * @return Mode returns the determined mode
+ */
+ public function determineRunMode(bool $isBackend, array $server, Arguments $args, MobileDetect $mobileDetect): Mode
+ {
+ foreach (self::BACKEND_CONTENT_TYPES as $type) {
+ if (strpos(strtolower($server['HTTP_ACCEPT'] ?? ''), $type) !== false) {
+ $isBackend = true;
+ }
+ }
+
+ $isBackend = $isBackend || in_array($args->getModuleName(), static::BACKEND_MODULES);
+ $isMobile = $mobileDetect->isMobile();
+ $isTablet = $mobileDetect->isTablet();
+ $isAjax = strtolower($server['HTTP_X_REQUESTED_WITH'] ?? '') == 'xmlhttprequest';
+
+ return new Mode($this->mode, $isBackend, $isAjax, $isMobile, $isTablet);