A free, self-hostable news aggregator…
Add log search to the logs page (#9059)
Gerard Alvear Porras7321c1e9fbb6
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.phpindex 8ccaa45c6..0d65ef60b 100644--- a/app/Controllers/indexController.php+++ b/app/Controllers/indexController.php@@ -452,6 +452,14 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {}$logs = FreshRSS_LogDAO::lines(); //TODO: ask only the necessary lines+ $search = trim(Minz_Request::paramString('search', plaintext: true));+ if ($search !== '') {+ $logs = array_values(array_filter($logs, static fn(FreshRSS_Log $log): bool =>+ stripos($log->level(), $search) !== false ||+ stripos($log->date(), $search) !== false ||+ stripos($log->info(), $search) !== false));+ }+ $this->view->logSearch = $search;//gestion pagination$page = Minz_Request::paramInt('page') ?: 1;diff --git a/app/Models/View.php b/app/Models/View.phpindex 5990a41b8..9f1bf351c 100644--- a/app/Models/View.php+++ b/app/Models/View.php@@ -110,6 +110,7 @@ class FreshRSS_View extends Minz_View {public int $currentPage;public Minz_Paginator $logsPaginator;public int $nbPage;+ public string $logSearch = '';// RSS viewpublic FreshRSS_UserQuery $userQuery;diff --git a/app/views/index/logs.phtml b/app/views/index/logs.phtmlindex 5e4812a3a..e29466e88 100644--- a/app/views/index/logs.phtml+++ b/app/views/index/logs.phtml@@ -6,6 +6,14 @@<main class="post"><h1><?= _t('index.log') ?></h1>+ <form method="get" action="<?= _url('index', 'logs') ?>" class="form-inline">+ <input type="hidden" name="c" value="index" />+ <input type="hidden" name="a" value="logs" />+ <label for="log-search"><?= _t('gen.action.filter') ?></label>+ <input type="search" id="log-search" name="search" value="<?= htmlspecialchars($this->logSearch, ENT_COMPAT, 'UTF-8') ?>" />+ <button type="submit" class="btn"><?= _t('gen.action.filter') ?></button>+ </form>+<?php/** @var list<FreshRSS_Log> $items */$items = $this->logsPaginator->items();