moteur de recherche : trigram+substring, navbar, page resultats
This commit is contained in:
@@ -1502,6 +1502,27 @@ switch ($action) {
|
||||
include BASE_PATH . '/templates/profile.php';
|
||||
break;
|
||||
|
||||
case 'search':
|
||||
require_once BASE_PATH . '/src/SearchEngine.php';
|
||||
$searchQuery = trim($_GET['q'] ?? '');
|
||||
$searchResults = [];
|
||||
if ($searchQuery !== '') {
|
||||
$privateCats = $articles->getPrivateCategories();
|
||||
$searchPool = array_values(array_filter($articles->getAll(true), static function (array $a) use ($privateCats): bool {
|
||||
$cat = trim($a['category'] ?? '');
|
||||
if ($cat !== '' && in_array($cat, $privateCats, true) && !isLoggedIn()) {
|
||||
return false;
|
||||
}
|
||||
if (strtotime((string)($a['published_at'] ?? '')) > time() && !isLoggedIn()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}));
|
||||
$searchResults = (new SearchEngine())->search($searchQuery, $searchPool);
|
||||
}
|
||||
include BASE_PATH . '/templates/search.php';
|
||||
break;
|
||||
|
||||
case 'list':
|
||||
default:
|
||||
$privateCats = $articles->getPrivateCategories();
|
||||
|
||||
Reference in New Issue
Block a user