Publier Globinours 1.0.0-rc.3
This commit is contained in:
parent
ea8c24d622
commit
9a2b4068da
325 changed files with 38230 additions and 20 deletions
26
app/Controllers/SearchController.php
Normal file
26
app/Controllers/SearchController.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
final class SearchController
|
||||
{
|
||||
public static function index(): void
|
||||
{
|
||||
$q = mb_substr(trim((string) ($_GET['q'] ?? '')), 0, 120);
|
||||
render('search.php', [
|
||||
'title' => t('search.title'),
|
||||
'searchQuery' => $q,
|
||||
'searchResults' => GlobalSearchService::search($q, 20),
|
||||
]);
|
||||
}
|
||||
public static function json(): void
|
||||
{
|
||||
$q = mb_substr(trim((string) ($_GET['q'] ?? '')), 0, 120);
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Cache-Control: private, no-store');
|
||||
echo json_encode(
|
||||
['query' => $q, 'groups' => GlobalSearchService::search($q)],
|
||||
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue