From 761ee2f92c374b8c7ddfe8a62e9fe97608eca80d Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 2 May 2008 17:10:28 +0200 Subject: [PATCH] Added new configuration variable to set the default SourceID If the default source id differs from the current used one, the sourceid variable will be appened into the search form, as well as into all needed links within phplogcon. This makes it easier to copy and send links around. --- src/include/functions_config.php | 8 ++++-- src/include/functions_frontendhelpers.php | 32 +++++++++++++++++++---- src/install.php | 3 ++- src/search.php | 8 +++++- src/templates/details.html | 2 +- src/templates/index.html | 13 +++++---- src/templates/search.html | 3 +++ 7 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/include/functions_config.php b/src/include/functions_config.php index bb81085..cf83742 100644 --- a/src/include/functions_config.php +++ b/src/include/functions_config.php @@ -132,8 +132,12 @@ $currentSourceID = $_SESSION['currentSourceID']; else { - // No Source stored in session, then to so now! - $_SESSION['currentSourceID'] = $currentSourceID; + if ( isset($CFG['DefaultSourceID']) && isset($content['Sources'][ $CFG['DefaultSourceID'] ]) ) + // Set Source to preconfigured sourceID! + $_SESSION['currentSourceID'] = $CFG['DefaultSourceID']; + else + // No Source stored in session, then to so now! + $_SESSION['currentSourceID'] = $currentSourceID; } } diff --git a/src/include/functions_frontendhelpers.php b/src/include/functions_frontendhelpers.php index e790e96..9520aab 100644 --- a/src/include/functions_frontendhelpers.php +++ b/src/include/functions_frontendhelpers.php @@ -67,13 +67,36 @@ function InstallFileReminder() function CreateCurrentUrl() { - global $content; + global $content, $CFG; $content['CURRENTURL'] = $_SERVER['PHP_SELF']; // . "?" . $_SERVER['QUERY_STRING'] // Init additional_url helper variable $content['additional_url'] = ""; $content['additional_url_uidonly'] = ""; $content['additional_url_sortingonly'] = ""; + $content['additional_url_sourceonly'] = ""; + + // Hidden Vars Counter + $hvCounter = 0; + + // Append SourceID into everything! + if ( (isset($CFG['DefaultSourceID']) && isset($content['Sources'][ $CFG['DefaultSourceID'] ])) && isset($_SESSION['currentSourceID']) ) + { + + // If the DefaultSourceID differes from the SourceID in our Session, we will append the sourceid within all URL's! + if ( $CFG['DefaultSourceID'] != $_SESSION['currentSourceID'] ) + { + $content['additional_url'] .= "&sourceid=" . $_SESSION['currentSourceID']; + $content['additional_url_uidonly'] = "&sourceid=" . $_SESSION['currentSourceID']; + $content['additional_url_sortingonly'] = "&sourceid=" . $_SESSION['currentSourceID']; + $content['additional_url_sourceonly'] = "&sourceid=" . $_SESSION['currentSourceID']; + + // For forms! + $content['HIDDENVARS_SOURCE'][$hvCounter]['varname'] = "sourceid"; + $content['HIDDENVARS_SOURCE'][$hvCounter]['varvalue'] = $_SESSION['currentSourceID']; + $hvCounter++; + } + } // Now the query string: if ( isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0 ) @@ -82,7 +105,6 @@ function CreateCurrentUrl() $content['CURRENTURL'] .= "?"; $queries = explode ("&", $_SERVER['QUERY_STRING']); - $counter = 0; for ( $i = 0; $i < count($queries); $i++ ) { // Some properties need to be filtered out. @@ -92,8 +114,8 @@ function CreateCurrentUrl() if ( isset($tmpvars[1]) ) // Only if value param is set! { // For forms! - $content['HIDDENVARS'][$counter]['varname'] = $tmpvars[0]; - $content['HIDDENVARS'][$counter]['varvalue'] = $tmpvars[1]; + $content['HIDDENVARS'][$hvCounter]['varname'] = $tmpvars[0]; + $content['HIDDENVARS'][$hvCounter]['varvalue'] = $tmpvars[1]; if ( strlen($tmpvars[1]) > 0 ) { @@ -114,7 +136,7 @@ function CreateCurrentUrl() $content['additional_url'] .= "&" . $tmpvars[0] . "=" . $tmpvars[1]; } - $counter++; + $hvCounter++; } } } diff --git a/src/install.php b/src/install.php index 46d4258..e38af00 100644 --- a/src/install.php +++ b/src/install.php @@ -592,7 +592,8 @@ else if ( $content['INSTALL_STEP'] == 8 ) } //Add the first source! - $firstsource = "\$CFG['Sources']['Source1']['ID'] = 'Source1';\r\n" . + $firstsource = "\$CFG['DefaultSourceID'] = 'Source1';\r\n\r\n" . + "\$CFG['Sources']['Source1']['ID'] = 'Source1';\r\n" . "\$CFG['Sources']['Source1']['Name'] = '" . $_SESSION['SourceName'] . "';\r\n" . "\$CFG['Sources']['Source1']['SourceType'] = " . $_SESSION['SourceType'] . ";\r\n"; if ( $_SESSION['SourceType'] == SOURCE_DISK ) diff --git a/src/search.php b/src/search.php index 802b7aa..37584ba 100644 --- a/src/search.php +++ b/src/search.php @@ -169,9 +169,15 @@ if ( (isset($_POST['search']) || isset($_GET['search'])) ) if ( isset($_GET['filter_message']) && strlen($_GET['filter_message']) > 0 ) $content['searchstr'] .= $_GET['filter_message']; } + + // Append sourceid if needed + if ( isset($_GET['sourceid']) && isset($content['Sources'][ $_GET['sourceid'] ]) ) + $sourceidstr = "&sourceid=" . $_GET['sourceid']; + else + $sourceidstr = ""; // Redirect to the index page now! - RedirectPage( "index.php?filter=" . urlencode( trim($content['searchstr']) ) . "&search=Search"); + RedirectPage( "index.php?filter=" . urlencode( trim($content['searchstr']) ) . "&search=Search" . $sourceidstr); } // --- diff --git a/src/templates/details.html b/src/templates/details.html index 3df4db9..573c77a 100644 --- a/src/templates/details.html +++ b/src/templates/details.html @@ -8,7 +8,7 @@
- {LN_DETAIL_BACKTOLIST} + {LN_DETAIL_BACKTOLIST} {LN_GEN_PAGE} {main_currentpagenumber} diff --git a/src/templates/index.html b/src/templates/index.html index 4c0e463..1e0aaea 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -2,6 +2,9 @@ + + +
 {LN_SEARCH_FILTER} @@ -15,7 +18,7 @@
  • {LN_GEN_PREDEFINEDSEARCHES}

  • - {DisplayName} + {DisplayName}
  • @@ -28,7 +31,7 @@
    - +
    @@ -232,7 +235,7 @@
  • - {DisplayName} + {DisplayName}
  • @@ -258,7 +261,7 @@ - + {fieldvalue} @@ -266,7 +269,7 @@ - {fieldvalue} + {fieldvalue} diff --git a/src/templates/search.html b/src/templates/search.html index 3b9df58..3a83aca 100644 --- a/src/templates/search.html +++ b/src/templates/search.html @@ -11,6 +11,9 @@
    + + +
    {popupcaption}