Initial import of f7support application.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\F7Support;
|
||||
|
||||
use OCP\AppFramework\App;
|
||||
|
||||
class Application extends App {
|
||||
public const APP_ID = 'f7support';
|
||||
|
||||
public function __construct(array $urlParams = []) {
|
||||
parent::__construct(self::APP_ID, $urlParams);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user