From 5cfc5914f29a9ff9ad5231bc4eb9027ad1bc2523 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 6 Feb 2021 15:33:19 +0300 Subject: [PATCH] log viewer: show total pages --- classes/pref/system.php | 109 +++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 45 deletions(-) diff --git a/classes/pref/system.php b/classes/pref/system.php index 707869e3f..9b8ce29be 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -2,6 +2,8 @@ class Pref_System extends Handler_Protected { + private $log_page_limit = 15; + function before($method) { if (parent::before($method)) { if ($_SESSION["access_level"] < 10) { @@ -24,16 +26,6 @@ class Pref_System extends Handler_Protected { } private function log_viewer(int $page, int $severity) { - print ""; - - print " - - - - - - "; - $errno_values = []; switch ($severity) { @@ -52,9 +44,70 @@ class Pref_System extends Handler_Protected { $errno_filter_qpart = "true"; } - $limit = 10; + $limit = $this->log_page_limit; $offset = $limit * $page; + $sth = $this->pdo->prepare("SELECT + COUNT(id) AS total_pages + FROM + ttrss_error_log + WHERE + $errno_filter_qpart"); + + $sth->execute($errno_values); + + if ($res = $sth->fetch()) { + $total_pages = (int)($res["total_pages"] / $limit); + } else { + $total_pages = 0; + } + + print "
"; + + print "
"; + + print ""; + + print ""; + + print ""; + + $next_page_disabled = $page >= $total_pages ? "disabled" : ""; + + print ""; + + print ""; + + print "
"; + + print __("Severity:") . " "; + print_select_hash("severity", $severity, + [ + E_USER_ERROR => __("Errors"), + E_USER_WARNING => __("Warnings"), + E_USER_NOTICE => __("Everything") + ], 'dojoType="fox.form.Select" onchange="Helpers.updateEventLog()"'); + + print "
"; # pull-right + + print "
"; # toolbar + + print '
'; + + print "
".__("Error")."".__("Filename")."".__("Message")."".__("User")."".__("Date")."
"; + + print " + + + + + + "; + $sth = $this->pdo->prepare("SELECT errno, errstr, filename, lineno, created_at, login, context FROM @@ -99,40 +152,6 @@ class Pref_System extends Handler_Protected { if (LOG_DESTINATION == "sql") { - print "
"; - - print "
"; - - print ""; - - print ""; - - print ""; - - print ""; - - print ""; - - print "
"; - - print __("Severity:") . " "; - print_select_hash("severity", $severity, - [ - E_USER_ERROR => __("Errors"), - E_USER_WARNING => __("Warnings"), - E_USER_NOTICE => __("Everything") - ], 'dojoType="fox.form.Select" onchange="Helpers.updateEventLog()"'); - - print "
"; # pull-right - - print "
"; # toolbar - - print '
'; - $this->log_viewer($page, $severity); } else {
".__("Error")."".__("Filename")."".__("Message")."".__("User")."".__("Date")."