2017-03-28 22:50:00 +00:00
|
|
|
<?php
|
2017-11-17 01:23:18 +00:00
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
2017-03-28 22:50:00 +00:00
|
|
|
declare(strict_types=1);
|
2021-04-14 15:17:01 +00:00
|
|
|
|
2017-03-28 22:50:00 +00:00
|
|
|
namespace JKingWeb\Arsse;
|
|
|
|
|
2017-07-17 11:47:57 +00:00
|
|
|
class Arsse {
|
2024-01-10 00:04:28 +00:00
|
|
|
public const VERSION = "0.10.5";
|
2021-07-03 16:38:48 +00:00
|
|
|
public const REQUIRED_EXTENSIONS = [
|
|
|
|
"intl", // as this extension is required to prepare formatted messages, its absence will throw a distinct English-only exception
|
|
|
|
"dom",
|
|
|
|
"filter",
|
|
|
|
"json", // part of the PHP core since version 8.0
|
|
|
|
"hash", // part of the PHP core since version 7.4
|
|
|
|
"simplexml", // required by PicoFeed only
|
|
|
|
"iconv", // required by PicoFeed only
|
|
|
|
];
|
2018-10-26 18:58:04 +00:00
|
|
|
|
2021-02-07 04:51:23 +00:00
|
|
|
/** @var Factory */
|
|
|
|
public static $obj;
|
2017-07-17 11:47:57 +00:00
|
|
|
/** @var Lang */
|
2017-07-12 00:27:37 +00:00
|
|
|
public static $lang;
|
2017-07-17 11:47:57 +00:00
|
|
|
/** @var Conf */
|
2017-03-28 22:50:00 +00:00
|
|
|
public static $conf;
|
2017-07-17 11:47:57 +00:00
|
|
|
/** @var Database */
|
2017-03-28 22:50:00 +00:00
|
|
|
public static $db;
|
2017-07-17 11:47:57 +00:00
|
|
|
/** @var User */
|
2017-03-28 22:50:00 +00:00
|
|
|
public static $user;
|
|
|
|
|
2021-07-05 02:04:05 +00:00
|
|
|
/** @codeCoverageIgnore */
|
|
|
|
public static function bootstrap(): void {
|
|
|
|
$conf = file_exists(BASE."config.php") ? new Conf(BASE."config.php") : new Conf;
|
|
|
|
static::load($conf);
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:34:03 +00:00
|
|
|
public static function load(Conf $conf): void {
|
2021-02-07 04:51:23 +00:00
|
|
|
static::$obj = static::$obj ?? new Factory;
|
2018-11-06 17:32:28 +00:00
|
|
|
static::$lang = static::$lang ?? new Lang;
|
2017-03-28 22:50:00 +00:00
|
|
|
static::$conf = $conf;
|
2017-07-12 00:27:37 +00:00
|
|
|
static::$lang->set($conf->lang);
|
2018-11-06 17:32:28 +00:00
|
|
|
static::$db = static::$db ?? new Database;
|
|
|
|
static::$user = static::$user ?? new User;
|
2017-03-28 22:50:00 +00:00
|
|
|
}
|
2021-07-03 14:23:24 +00:00
|
|
|
|
2021-07-03 16:38:48 +00:00
|
|
|
/** Checks whether the specified extensions are loaded and throws an exception if any are not */
|
2021-07-03 14:23:24 +00:00
|
|
|
public static function checkExtensions(string ...$ext): void {
|
|
|
|
$missing = [];
|
|
|
|
foreach ($ext as $e) {
|
|
|
|
if (!extension_loaded($e)) {
|
|
|
|
$missing[] = $e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($missing) {
|
|
|
|
$total = sizeof($missing);
|
|
|
|
$first = $missing[0];
|
|
|
|
throw new Exception("extMissing", ['first' => $first, 'total' => $total]);
|
|
|
|
}
|
|
|
|
}
|
2017-08-29 14:50:31 +00:00
|
|
|
}
|