/***
* @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
* - App::MODE_NORMAL : Normal run with all features enabled
*
* @param string $basepath the Basepath of the Application
- *
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- 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 . '/config/local.config.php')
+ && !file_exists($this->basepath . '/config/local.ini.php')
+ && !file_exists($this->basepath . '/.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;
}
/**
*
* @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;
}
*
* @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);
}
/**
*
* @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);
}
}