chimera-mark2-core-release/core/fox/meta/settings.php

86 lines
2.8 KiB
PHP
Raw Permalink Normal View History

2022-04-26 19:48:03 +00:00
<?php
namespace fox\meta;
/**
*
* Class fox\meta\settings
*
* @copyright MX STAR LLC 2018-2022
* @version 4.0.0
* @author Pavel Dmitriev
* @license GPLv3
*
**/
2022-08-23 21:40:48 +00:00
use fox\cache;
2022-04-26 19:48:03 +00:00
use fox\externalCallable;
use fox\request;
use fox\config;
2022-08-23 21:40:48 +00:00
use fox\moduleInfo;
2022-04-26 19:48:03 +00:00
use fox\time;
use fox\modules;
use fox\oAuthProfile;
class settings implements externalCallable
{
public static function APICall(request $request)
{
2022-08-23 21:40:48 +00:00
$c=new cache();
$oauth=$c->get("coreSettingsOauthProfiles");
if ($oauth==null) {
$profiles = oAuthProfile::search()->result;
$oauth=[];
foreach ($profiles as $p) {
if ($p->enabled) {
$oauth[] = [
"name"=>$p->name,
"id"=>$p->id,
"icon"=>$p->getClient(null)->getAuthIcon(),
];
}
}
$c->set("coreSettingsOauthProfiles", $oauth);
}
$themes=$c->get("coreSettingsThemes");
if ($themes==null) {
$themes=[];
foreach (moduleInfo::getByFeature("theme") as $mod) {
if ($mod->themes) {
$themes=array_merge($themes, $mod->themes);
} else {
$themes[$mod->name]=$mod->title;
}
2022-04-26 19:48:03 +00:00
}
2022-08-23 21:40:48 +00:00
$c->set("coreSettingsThemes",$themes);
2022-04-26 19:48:03 +00:00
}
2022-08-23 21:40:48 +00:00
$coreLangs=$c->get("coreSettingsLanguages");
if ($coreLangs==null) {
$coreLangs=modules::list()["core"]->languages;
$c->set("coreSettingsLanguages",$coreLangs);
}
2023-03-07 11:25:14 +00:00
2022-04-26 19:48:03 +00:00
return [
"title" => config::get("TITLE"),
"sitePrefix" => config::get("SITEPREFIX"),
"theme" => config::get("DEFAULT_THEME") === null ? "chimera" : config::get("DEFAULT_THEME"),
"buildVersion" => "undefined",
"buildDate" => time::current()->dayStart,
"pageSize" => config::get("DEFAULT_PAGESIZE") === null ? "30" : config::get("DEFAULT_PAGESIZE"),
"language" => config::get("DEFAULT_LANGUAGE") === null ? "ru" : config::get("DEFAULT_LANGUAGE"),
"defaultModule" => config::get("DEFAULT_MODULE") === null ? "core" : config::get("DEFAULT_MODULE"),
"sessionRenewInterval" => config::get("SESSION_RENEW_SEC") === null ? "3600" : config::get("SESSION_RENEW_SEC"),
2022-08-23 21:40:48 +00:00
"coreLanguages" => $coreLangs,
2022-04-26 19:48:03 +00:00
"oauthProfiles"=>$oauth,
2022-08-23 21:40:48 +00:00
"themes"=>$themes,
2023-03-07 11:25:14 +00:00
"rabbitMqEnabled"=>strtolower(config::get("RABBITMQ_ENABLED"))==="true",
"rabbitMqWS"=>config::get("RABBITMQ_WS_URL")===null?"/rabbitmq":config::get("RABBITMQ_WS_URL"),
"rabbitMqVHost"=>config::get("RABBITMQ_VHOST")===null?"/":config::get("RABBITMQ_VHOST")
2022-04-26 19:48:03 +00:00
];
}
}
?>