2023-10-06 21:11:28 +00:00
|
|
|
<?php
|
|
|
|
namespace Seria;
|
|
|
|
|
2023-12-15 02:04:53 +00:00
|
|
|
use Syokuhou\IConfig;
|
2023-10-06 21:11:28 +00:00
|
|
|
use Seria\Users\UserInfo;
|
|
|
|
|
|
|
|
class SiteInfo {
|
2023-12-15 02:04:53 +00:00
|
|
|
public function __construct(private IConfig $config) {}
|
|
|
|
|
2023-10-06 21:11:28 +00:00
|
|
|
public function getName(): string {
|
2023-12-15 02:04:53 +00:00
|
|
|
return $this->config->getString('name');
|
2023-10-06 21:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getHost(): string {
|
2023-12-15 02:04:53 +00:00
|
|
|
return $this->config->getString('host');
|
2023-10-06 21:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getMainSiteName(): string {
|
2023-12-15 02:04:53 +00:00
|
|
|
return $this->config->getString('parent');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLoginUrl(): string {
|
|
|
|
return $this->config->getString('login');
|
2023-10-06 21:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getProfileUrl(UserInfo|string $userInfo): string {
|
|
|
|
if($userInfo instanceof UserInfo)
|
|
|
|
$userInfo = $userInfo->getId();
|
|
|
|
|
2023-12-15 02:04:53 +00:00
|
|
|
return sprintf($this->config->getString('profile'), $userInfo);
|
2023-10-06 21:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getAvatarUrl(UserInfo|string $userInfo, int $res = 0): string {
|
|
|
|
if($userInfo instanceof UserInfo)
|
|
|
|
$userInfo = $userInfo->getId();
|
|
|
|
|
2023-12-15 02:04:53 +00:00
|
|
|
return sprintf($this->config->getString($res < 1 ? 'avatar' : 'avatar:res'), $userInfo, $res);
|
2023-10-06 21:11:28 +00:00
|
|
|
}
|
|
|
|
}
|