streams/Code/Lib/System.php

156 lines
4.7 KiB
PHP
Raw Normal View History

<?php
2022-02-16 04:08:28 +00:00
namespace Code\Lib;
2018-10-08 02:54:25 +00:00
use App;
2022-02-16 04:08:28 +00:00
use Code\Extend\Hook;
2022-01-28 23:12:22 +00:00
use URLify;
2018-10-08 02:54:25 +00:00
2021-12-03 03:01:39 +00:00
class System
{
public static function get_platform_name()
{
if (is_array(App::$config) && is_array(App::$config['system']) && array_key_exists('platform_name', App::$config['system'])) {
return App::$config['system']['platform_name'];
}
return PLATFORM_NAME;
}
2022-08-28 06:06:24 +00:00
public static function get_site_name(): string
2021-12-03 03:01:39 +00:00
{
2022-02-17 20:08:59 +00:00
if (is_array(App::$sys_channel) && isset(App::$sys_channel['channel_name'])) {
return App::$sys_channel['channel_name'];
2021-12-03 03:01:39 +00:00
}
return '';
}
2022-01-28 22:51:16 +00:00
public static function get_project_name()
{
2022-01-28 23:33:34 +00:00
$project = EMPTY_STR;
2022-01-28 23:12:22 +00:00
$name = self::get_site_name();
2022-01-28 22:51:16 +00:00
if ($name) {
$words = explode(' ', $name);
2022-03-01 23:45:04 +00:00
// restrict result to characters allowed by the nodeinfo specification
$project = preg_replace('/[^a-z0-9-]/', '-', strtolower(URLify::transliterate($words[0])));
2022-01-28 22:51:16 +00:00
}
2022-01-28 23:33:34 +00:00
if (!$project) {
2022-01-28 23:12:22 +00:00
$project = self::get_platform_name();
2022-01-28 22:51:16 +00:00
}
return $project;
}
2021-12-03 03:01:39 +00:00
public static function get_banner()
{
if (is_array(App::$config) && is_array(App::$config['system']) && array_key_exists('banner', App::$config['system']) && App::$config['system']['banner']) {
return App::$config['system']['banner'];
}
return self::get_site_name();
}
public static function get_project_icon()
{
2022-02-17 20:08:59 +00:00
if (isset(App::$sys_channel['xchan_photo_l'])) {
2022-02-17 20:39:21 +00:00
return App::$sys_channel['xchan_photo_l'];
2022-01-28 22:52:24 +00:00
}
2021-12-03 03:01:39 +00:00
if (is_array(App::$config) && is_array(App::$config['system']) && array_key_exists('icon', App::$config['system'])) {
return App::$config['system']['icon'];
}
return z_root() . '/images/' . PLATFORM_NAME . '-64.png';
}
public static function get_project_favicon()
{
if (is_array(App::$config) && is_array(App::$config['system']) && array_key_exists('favicon', App::$config['system'])) {
return App::$config['system']['favicon'];
}
return z_root() . '/images/' . PLATFORM_NAME . '.ico';
}
public static function get_project_version()
{
if (array_path_exists('system/hide_version', App::$config) && intval(App::$config['system']['hide_version'])) {
return '';
}
if (is_array(App::$config) && is_array(App::$config['system']) && array_key_exists('std_version', App::$config['system'])) {
return App::$config['system']['std_version'];
}
return self::get_std_version();
}
2022-08-28 06:06:24 +00:00
public static function get_update_version(): int|string
2021-12-03 03:01:39 +00:00
{
if (is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['hide_version']) {
return EMPTY_STR;
}
return DB_UPDATE_VERSION;
}
public static function get_notify_icon()
{
if (is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['email_notify_icon_url']) {
return App::$config['system']['email_notify_icon_url'];
}
return self::get_project_icon();
}
public static function get_site_icon()
{
return self::get_project_icon();
}
public static function get_site_favicon()
{
if (is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['site_favicon_url']) {
return App::$config['system']['site_favicon_url'];
}
return self::get_project_favicon();
}
public static function get_project_link()
{
if (is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['project_link']) {
return App::$config['system']['project_link'];
}
return 'https://zotlabs.com/' . PLATFORM_NAME;
}
public static function get_project_srclink()
{
if (is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['project_srclink']) {
return App::$config['system']['project_srclink'];
}
if (PLATFORM_NAME === 'streams') {
return 'https://codeberg.org/streams/' . PLATFORM_NAME;
2021-10-28 00:47:17 +00:00
}
2021-12-03 03:01:39 +00:00
return 'https://codeberg.org/zot/' . PLATFORM_NAME;
}
public static function ebs()
{
2022-08-21 00:15:14 +00:00
return Config::Get('system','ebsstate', 'armed');
2021-12-03 03:01:39 +00:00
}
public static function get_zot_revision()
{
$x = [ 'revision' => ZOT_REVISION ];
Hook::call('zot_revision', $x);
2021-12-03 03:01:39 +00:00
return $x['revision'];
}
2022-08-28 06:06:24 +00:00
public static function get_std_version(): string
2021-12-03 03:01:39 +00:00
{
if (defined('STD_VERSION')) {
return STD_VERSION;
}
return '0.0.0';
}
}