From 297ca06d36853efe7d51591aa5aa09629a8543d4 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Mon, 26 Jan 2009 16:18:54 +0100 Subject: [PATCH] Enhanced Pager performance, especially when using larger databases as logsource or when filtering --- src/index.php | 78 +++++++++++++++++++++++++++++++++++++--- src/templates/index.html | 4 +-- 2 files changed, 75 insertions(+), 7 deletions(-) diff --git a/src/index.php b/src/index.php index e68f8fe..d2d7fb5 100644 --- a/src/index.php +++ b/src/index.php @@ -99,7 +99,7 @@ else $content['EXPORT_ENABLED'] = true; // Init Pager variables -// $content['uid_previous'] = UID_UNKNOWN; +$content['uid_previous'] = UID_UNKNOWN; $content['uid_next'] = UID_UNKNOWN; $content['uid_first'] = UID_UNKNOWN; $content['uid_last'] = UID_UNKNOWN; @@ -651,8 +651,8 @@ if ( isset($content['Sources'][$currentSourceID]) ) //print_r ( $content['syslogmessages'] ); // Move below processing - Read First and LAST UID's before start reading the stream! - $content['uid_last'] = $stream->GetLastPageUID(); - $content['uid_first'] = $stream->GetFirstPageUID(); +// $content['uid_last'] = $stream->GetLastPageUID(); +/// $content['uid_first'] = $stream->GetFirstPageUID(); if ( $content['main_recordcount'] == -1 || $content['main_recordcount'] > $content['CurrentViewEntriesPerPage'] ) { @@ -676,6 +676,7 @@ if ( isset($content['Sources'][$currentSourceID]) ) } // --- +/* // --- Handle uid_previous page button if ( $content['uid_current'] != UID_UNKNOWN ) { @@ -700,9 +701,60 @@ if ( isset($content['Sources'][$currentSourceID]) ) $content['main_pager_previous_found'] = false; //echo $content['uid_previous']; // --- - - // --- Handle uid_last page button +*/ + + // --- Handle uid_previous page button + if ( $content['read_direction'] == EnumReadDirection::Forward ) + { + if ( $ret == SUCCESS ) + { + // Try to read the next one! + $ret = $stream->ReadNext($uID, $tmp); + if ( $ret == SUCCESS ) + $content['main_pager_previous_found'] = true; + else + $content['main_pager_previous_found'] = false; + } + else + $content['main_pager_previous_found'] = false; + } + else + { + if ( $content['uid_current'] == $content['uid_previous'] ) + $content['main_pager_previous_found'] = false; + else + $content['main_pager_previous_found'] = true; + } + + + // --- + + // --- Handle uid_last and uid_next page button + if ( $content['read_direction'] == EnumReadDirection::Forward ) + { + if ( $content['uid_current'] == $content['uid_last'] ) + { + $content['main_pager_last_found'] = false; + $content['main_pager_next_found'] = false; + } + else + { + $content['main_pager_last_found'] = true; + $content['main_pager_next_found'] = true; + } + + // Restore uid_current if necessary + $content['uid_current'] = $lastUid; + } + else + { + $content['main_pager_last_found'] = true; + $content['main_pager_next_found'] = true; + } + // --- + //!!!!!!!! +/* // if we found a last uid, and if it is not the current one (which means we already are on the last page ;)! if ( $content['uid_last'] != -1 && $content['uid_last'] != $content['uid_current']) $content['main_pager_last_found'] = true; @@ -723,8 +775,23 @@ if ( isset($content['Sources'][$currentSourceID]) ) // As we went back, we need to change the currend uid to the latest read one $content['uid_current'] = $lastUid; } +*/ // --- + // --- Handle uid_first page button + if ( $content['uid_current'] == $content['uid_first'] ) + { + $content['main_pager_first_found'] = false; + $content['main_pager_previous_found'] = false; // If there is no FIRST, there is no going back! + } + else if ( !$content['main_pager_previous_found'] ) + $content['main_pager_first_found'] = false; + else + $content['main_pager_first_found'] = true; + // --- + +// $content['uid_first'] +/* // --- Handle uid_first page button if ( $content['main_pager_previous_found'] == false || $content['uid_current'] == UID_UNKNOWN || @@ -736,6 +803,7 @@ if ( isset($content['Sources'][$currentSourceID]) ) else $content['main_pager_first_found'] = true; // --- +*/ } else // Disable pager in this case! $content['main_pagerenabled'] = false; diff --git a/src/templates/index.html b/src/templates/index.html index 824e05e..3139970 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -217,7 +217,7 @@ - + @@ -374,7 +374,7 @@ - +