You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.4 KiB
PHTML
42 lines
1.4 KiB
PHTML
|
3 weeks ago
|
<?php
|
||
|
|
|
||
|
|
namespace App\Controllers;
|
||
|
|
|
||
|
|
use App\Services\LegalDocumentService;
|
||
|
|
|
||
|
|
final class LegalController extends HomeController
|
||
|
|
{
|
||
|
|
public function terms($request, $response, $args)
|
||
|
|
{
|
||
|
|
return $this->renderDocument($request, $response, 'terms');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function privacy($request, $response, $args)
|
||
|
|
{
|
||
|
|
return $this->renderDocument($request, $response, 'privacy');
|
||
|
|
}
|
||
|
|
|
||
|
|
private function renderDocument($request, $response, string $slug)
|
||
|
|
{
|
||
|
|
$query = $request->getQueryParams();
|
||
|
|
$requestedLocale = $query['lang'] ?? '';
|
||
|
|
$locale = is_string($requestedLocale) && in_array($requestedLocale, ['zh-CN', 'en'], true)
|
||
|
|
? $requestedLocale
|
||
|
|
: ($this->language === 'true' ? 'en' : 'zh-CN');
|
||
|
|
$document = LegalDocumentService::published($slug, $locale, (string) $this->appName);
|
||
|
|
$smarty = $this->view()->assign([
|
||
|
|
'cdn' => $this->cdn,
|
||
|
|
'backup_cdn' => $this->backup_cdn,
|
||
|
|
'appName' => $this->appName,
|
||
|
|
'seo' => $this->seo,
|
||
|
|
'language' => $locale === 'en' ? 'true' : 'false',
|
||
|
|
'legal_document' => $document,
|
||
|
|
'legal_slug' => $slug,
|
||
|
|
]);
|
||
|
|
$response->getBody()->write($smarty->fetch('legal.tpl'));
|
||
|
|
return $response
|
||
|
|
->withHeader('Cache-Control', 'public, max-age=60')
|
||
|
|
->withHeader('X-Content-Type-Options', 'nosniff');
|
||
|
|
}
|
||
|
|
}
|