X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FApp%2FMode.php;h=d9f5cdbd4c5b09f79cfa1f12c0dbd9f975e81e5e;hb=2a881cc2e71b1677cc9ce98001ae3f157743e542;hp=189573e3782d994afe95d684619c23a5cc3b5a80;hpb=3b41535dfe9d8285264ebae2c2c111a359e7288a;p=friendica.git diff --git a/src/App/Mode.php b/src/App/Mode.php index 189573e378..d9f5cdbd4c 100644 --- a/src/App/Mode.php +++ b/src/App/Mode.php @@ -20,9 +20,19 @@ class Mode /*** * @var int the mode of this Application * - * Default is 0 (= not set) */ - private static $mode = 0; + private $mode; + + /** + * @var string the basepath of the application + */ + private $basepath; + + public function __construct($basepath = '') + { + $this->basepath = $basepath; + $this->mode = 0; + } /** * Sets the App mode @@ -34,34 +44,38 @@ class Mode * @param string $basepath the Basepath of the Application * */ - public static function determine($basepath) + public function determine($basepath = null) { - self::$mode = 0; + if (!empty($basepath)) { + $this->basepath = $basepath; + } + + $this->mode = 0; - if (!file_exists($basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php') - && !file_exists($basepath . DIRECTORY_SEPARATOR . '.htconfig.php')) { + if (!file_exists($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php') + && !file_exists($this->basepath . DIRECTORY_SEPARATOR . '.htconfig.php')) { return; } - self::$mode |= Mode::LOCALCONFIGPRESENT; + $this->mode |= Mode::LOCALCONFIGPRESENT; if (!DBA::connected()) { return; } - self::$mode |= Mode::DBAVAILABLE; + $this->mode |= Mode::DBAVAILABLE; if (DBA::fetchFirst("SHOW TABLES LIKE 'config'") === false) { return; } - self::$mode |= Mode::DBCONFIGAVAILABLE; + $this->mode |= Mode::DBCONFIGAVAILABLE; if (Config::get('system', 'maintenance')) { return; } - self::$mode |= Mode::MAINTENANCEDISABLED; + $this->mode |= Mode::MAINTENANCEDISABLED; } /** @@ -71,9 +85,9 @@ class Mode * * @return bool returns true, if the mode is set */ - public static function has($mode) + public function has($mode) { - return self::$mode & $mode; + return ($this->mode & $mode) > 0; } @@ -82,10 +96,10 @@ class Mode * * @return bool */ - public static function isInstall() + public function isInstall() { - return !self::has(Mode::LOCALCONFIGPRESENT) || - !self::has(MODE::DBCONFIGAVAILABLE); + return !$this->has(Mode::LOCALCONFIGPRESENT) || + !$this->has(MODE::DBCONFIGAVAILABLE); } /** @@ -93,11 +107,11 @@ class Mode * * @return bool */ - public static function isNormal() + public function isNormal() { - return self::has(Mode::LOCALCONFIGPRESENT) && - self::has(Mode::DBAVAILABLE) && - self::has(Mode::DBCONFIGAVAILABLE) && - self::has(Mode::MAINTENANCEDISABLED); + return $this->has(Mode::LOCALCONFIGPRESENT) && + $this->has(Mode::DBAVAILABLE) && + $this->has(Mode::DBCONFIGAVAILABLE) && + $this->has(Mode::MAINTENANCEDISABLED); } }