From 7a15a177372cb13b5d50933b5797c3f288155493 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 25 Apr 2008 17:43:51 +0200 Subject: [PATCH] Added backlink to ListView in detailpage and added Records per Page selector The records per page selector makes it possible to change the pagesize on the fly. By default, the pagesize from the config.php will be used. --- src/include/functions_common.php | 49 +++++++++++++++++++++++++------- src/index.php | 4 +-- src/lang/de/main.php | 1 + src/lang/en/main.php | 1 + src/templates/details.html | 3 +- src/templates/index.html | 19 ++++++++++++- src/userchange.php | 11 +++++-- 7 files changed, 71 insertions(+), 17 deletions(-) diff --git a/src/include/functions_common.php b/src/include/functions_common.php index 9df8945..11a2332 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -183,6 +183,9 @@ function InitPhpLogCon() // Init Predefined Searches List CreatePredefinedSearches(); + // Init predefined paging sizes + CreatePagesizesList(); + // --- Enable PHP Debug Mode InitPhpDebugMode(); // --- @@ -241,6 +244,23 @@ function CreateDBTypesList( $selectedDBType ) } +function CreatePagesizesList() +{ + global $CFG, $content; + + $content['pagesizes'][0] = array( "ID" => 0, "Selected" => "", "DisplayName" => "Preconfigured (" . $CFG['ViewEntriesPerPage'] . ")", "Value" => $CFG['ViewEntriesPerPage'] ); + $content['pagesizes'][1] = array( "ID" => 1, "Selected" => "", "DisplayName" => " 25 records per page", "Value" => 25 ); + $content['pagesizes'][2] = array( "ID" => 2, "Selected" => "", "DisplayName" => " 50 records per page", "Value" => 50 ); + $content['pagesizes'][3] = array( "ID" => 3, "Selected" => "", "DisplayName" => " 75 records per page", "Value" => 75 ); + $content['pagesizes'][4] = array( "ID" => 4, "Selected" => "", "DisplayName" => " 100 records per page", "Value" => 100 ); + + // Set default selected pagesize + $content['pagesizes'][ $_SESSION['PAGESIZE_ID'] ]["Selected"] = "selected"; + + // The content variable will now contain the user selected oaging size + $content["ViewEntriesPerPage"] = $content['pagesizes'][ $_SESSION['PAGESIZE_ID'] ]["Value"]; +} + function CreatePredefinedSearches() { global $CFG, $content; @@ -316,17 +336,17 @@ function InitFrontEndVariables() { global $content; - $content['MENU_FOLDER_OPEN'] = "image=" . $content['BASEPATH'] . "images/icons/folder_closed.png"; - $content['MENU_FOLDER_CLOSED'] = "overimage=" . $content['BASEPATH'] . "images/icons/folder.png"; - $content['MENU_HOMEPAGE'] = "image=" . $content['BASEPATH'] . "images/icons/home.png"; - $content['MENU_LINK'] = "image=" . $content['BASEPATH'] . "images/icons/link.png"; - $content['MENU_PREFERENCES'] = "image=" . $content['BASEPATH'] . "images/icons/preferences.png"; - $content['MENU_ADMINENTRY'] = "image=" . $content['BASEPATH'] . "images/icons/star_blue.png"; - $content['MENU_ADMINLOGOFF'] = "image=" . $content['BASEPATH'] . "images/icons/exit.png"; - $content['MENU_ADMINUSERS'] = "image=" . $content['BASEPATH'] . "images/icons/businessmen.png"; - $content['MENU_SEARCH'] = "image=" . $content['BASEPATH'] . "images/icons/view.png"; - $content['MENU_SELECTION_DISABLED'] = "image=" . $content['BASEPATH'] . "images/icons/selection.png"; - $content['MENU_SELECTION_ENABLED'] = "image=" . $content['BASEPATH'] . "images/icons/selection_delete.png"; + $content['MENU_FOLDER_OPEN'] = $content['BASEPATH'] . "images/icons/folder_closed.png"; + $content['MENU_FOLDER_CLOSED'] = $content['BASEPATH'] . "images/icons/folder.png"; + $content['MENU_HOMEPAGE'] = $content['BASEPATH'] . "images/icons/home.png"; + $content['MENU_LINK'] = $content['BASEPATH'] . "images/icons/link.png"; + $content['MENU_PREFERENCES'] = $content['BASEPATH'] . "images/icons/preferences.png"; + $content['MENU_ADMINENTRY'] = $content['BASEPATH'] . "images/icons/star_blue.png"; + $content['MENU_ADMINLOGOFF'] = $content['BASEPATH'] . "images/icons/exit.png"; + $content['MENU_ADMINUSERS'] = $content['BASEPATH'] . "images/icons/businessmen.png"; + $content['MENU_SEARCH'] = $content['BASEPATH'] . "images/icons/view.png"; + $content['MENU_SELECTION_DISABLED'] = $content['BASEPATH'] . "images/icons/selection.png"; + $content['MENU_SELECTION_ENABLED'] = $content['BASEPATH'] . "images/icons/selection_delete.png"; $content['MENU_PAGER_BEGIN'] = $content['BASEPATH'] . "images/icons/media_beginning.png"; $content['MENU_PAGER_PREVIOUS'] = $content['BASEPATH'] . "images/icons/media_rewind.png"; @@ -412,6 +432,13 @@ function InitConfigurationValues() } } + // Paging Size handling! + if ( !isset($_SESSION['PAGESIZE_ID']) ) + { + // Default is 0! + $_SESSION['PAGESIZE_ID'] = 0; + } + // Theme Handling if ( !isset($content['web_theme']) ) { $content['web_theme'] = $CFG['ViewDefaultTheme'] /*"default"*/; } if ( isset($_SESSION['CUSTOM_THEME']) && VerifyTheme($_SESSION['CUSTOM_THEME']) ) diff --git a/src/index.php b/src/index.php index 24e08a9..11199ba 100644 --- a/src/index.php +++ b/src/index.php @@ -396,11 +396,11 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['Sources'][$c // Increment Counter $counter++; - } while ($counter < $CFG['ViewEntriesPerPage'] && ($ret = $stream->ReadNext($uID, $logArray)) == SUCCESS); + } while ($counter < $content['ViewEntriesPerPage'] && ($ret = $stream->ReadNext($uID, $logArray)) == SUCCESS); //print_r ( $content['syslogmessages'] ); - if ( $content['main_recordcount'] == -1 || $content['main_recordcount'] > $CFG['ViewEntriesPerPage'] ) + if ( $content['main_recordcount'] == -1 || $content['main_recordcount'] > $content['ViewEntriesPerPage'] ) { // Enable Pager in any case here! $content['main_pagerenabled'] = true; diff --git a/src/lang/de/main.php b/src/lang/de/main.php index 055cbf6..ce728b7 100644 --- a/src/lang/de/main.php +++ b/src/lang/de/main.php @@ -118,5 +118,6 @@ $content['LN_CFG_FIRSTSYSLOGSOURCE'] = "Erste Syslog Quelle"; // Details page $content['LN_DETAILS_FORSYSLOGMSG'] = "Details for the syslog messages with id"; $content['LN_DETAILS_DETAILSFORMSG'] = "Details for message id"; +$content['LN_DETAIL_BACKTOLIST'] = "Back to Listview"; ?> diff --git a/src/lang/en/main.php b/src/lang/en/main.php index eeca194..99d76e4 100644 --- a/src/lang/en/main.php +++ b/src/lang/en/main.php @@ -118,5 +118,6 @@ $content['LN_CFG_FIRSTSYSLOGSOURCE'] = "First Syslog Source"; // Details page $content['LN_DETAILS_FORSYSLOGMSG'] = "Details for the syslog messages with id"; $content['LN_DETAILS_DETAILSFORMSG'] = "Details for message id"; +$content['LN_DETAIL_BACKTOLIST'] = "Back to Listview"; ?> \ No newline at end of file diff --git a/src/templates/details.html b/src/templates/details.html index e3d1b65..3df4db9 100644 --- a/src/templates/details.html +++ b/src/templates/details.html @@ -7,7 +7,8 @@ - - +
+ + {LN_DETAIL_BACKTOLIST} {LN_GEN_PAGE} {main_currentpagenumber} diff --git a/src/templates/index.html b/src/templates/index.html index 2636778..d1e8c77 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -101,7 +101,24 @@ {LN_GEN_PAGERSIZE}:{ViewEntriesPerPage} + +
+ + + + + +
+ +
+
+ +
Pager:   diff --git a/src/userchange.php b/src/userchange.php index 4a4a36e..6e8ad39 100644 --- a/src/userchange.php +++ b/src/userchange.php @@ -50,17 +50,24 @@ else if ( isset($_GET['op']) ) { - if ( $_GET['op'] == "changestyle" ) + if ( $_GET['op'] == "changestyle" && isset($_GET['stylename']) ) { if ( VerifyTheme($_GET['stylename']) ) $_SESSION['CUSTOM_THEME'] = $_GET['stylename']; } - if ( $_GET['op'] == "changelang" ) + if ( $_GET['op'] == "changelang" && isset($_GET['langcode']) ) { if ( VerifyLanguage($_GET['langcode']) ) $_SESSION['CUSTOM_LANG'] = $_GET['langcode']; } + + if ( $_GET['op'] == "changepagesize" && isset($_GET['pagesizeid']) ) + { + if ( intval($_GET['pagesizeid']) >= 0 && intval($_GET['pagesizeid']) < 5 ) + $_SESSION['PAGESIZE_ID'] = intval($_GET['pagesizeid']); + } + } // Final redirect