49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\F7Support\Controller;
|
|
|
|
use OCP\AppFramework\Controller;
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
|
use OCP\IRequest;
|
|
use OCP\IURLGenerator;
|
|
use OCP\IUserSession;
|
|
use OCP\Util;
|
|
|
|
class PageController extends Controller {
|
|
public function __construct(
|
|
string $AppName,
|
|
IRequest $request,
|
|
private IUserSession $userSession,
|
|
private IURLGenerator $urlGenerator
|
|
) {
|
|
parent::__construct($AppName, $request);
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
* @NoCSRFRequired
|
|
*/
|
|
public function index(): TemplateResponse {
|
|
$user = $this->userSession->getUser();
|
|
$baseUrl = $this->urlGenerator->getBaseUrl();
|
|
$serverHost = parse_url($baseUrl, PHP_URL_HOST) ?: 'localhost';
|
|
|
|
$supportApiBase = 'https://support.f7cloud.ru';
|
|
$supportParts = parse_url($supportApiBase);
|
|
$supportApiOrigin = ($supportParts['scheme'] ?? 'https') . '://' . ($supportParts['host'] ?? '');
|
|
|
|
Util::addStyle('f7support', 'f7support');
|
|
Util::addScript('f7support', 'main');
|
|
|
|
return new TemplateResponse('f7support', 'main', [
|
|
'username' => $user ? $user->getUID() : '',
|
|
'serverAddress' => $serverHost,
|
|
'supportApiBase' => $supportApiBase,
|
|
'supportApiOrigin' => $supportApiOrigin,
|
|
]);
|
|
}
|
|
}
|
|
|